Merge pull request #2476 from 0xProject/fix/erc20-bridge-sampler/dev-utils-gas-stipend

ERC20BridgeSampler: Catch DevUtils reverts
This commit is contained in:
Lawrence Forman 2020-02-07 10:08:40 -05:00 committed by GitHub
commit 79362b0dba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 6 deletions

View File

@ -1,4 +1,13 @@
[
{
"version": "1.3.0",
"changes": [
{
"note": "Catch reverts to `DevUtils` calls",
"pr": 2476
}
]
},
{
"timestamp": 1580988106,
"version": "1.2.1",

View File

@ -40,7 +40,7 @@ contract ERC20BridgeSampler is
uint256 constant internal KYBER_SAMPLE_CALL_GAS = 1500e3;
uint256 constant internal UNISWAP_SAMPLE_CALL_GAS = 150e3;
uint256 constant internal ETH2DAI_SAMPLE_CALL_GAS = 1000e3;
uint256 constant internal DEV_UTILS_SAMPLE_CALL_GAS = 500e3;
uint256 constant internal DEV_UTILS_CALL_GAS = 500e3;
address constant private UNISWAP_SOURCE = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95;
address constant private ETH2DAI_SOURCE = 0x39755357759cE0d7f32dC8dC45414CCa409AE24e;
address constant private KYBER_SOURCE = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755;
@ -205,13 +205,28 @@ contract ERC20BridgeSampler is
orderFillableTakerAssetAmounts[i] = 0;
continue;
}
// solhint-disable indent
(bool didSucceed, bytes memory resultData) =
_getDevUtilsAddress()
.staticcall
.gas(DEV_UTILS_CALL_GAS)
(abi.encodeWithSelector(
IDevUtils(_getDevUtilsAddress()).getOrderRelevantState.selector,
orders[i],
orderSignatures[i]
));
// solhint-enable indent
if (!didSucceed) {
orderFillableTakerAssetAmounts[i] = 0;
continue;
}
(
LibOrder.OrderInfo memory orderInfo,
uint256 fillableTakerAssetAmount,
bool isValidSignature
) = IDevUtils(_getDevUtilsAddress()).getOrderRelevantState.gas(DEV_UTILS_SAMPLE_CALL_GAS)(
orders[i],
orderSignatures[i]
) = abi.decode(
resultData,
(LibOrder.OrderInfo, uint256, bool)
);
// The fillable amount is zero if the order is not fillable or if the
// signature is invalid.

View File

@ -5,6 +5,10 @@
{
"note": "Update `ERC20BridgeSampler` and `Eth2Dai` on mainnet and kovan.",
"pr": 2474
},
{
"note": "Update `ERC20BridgeSampler` address on mainnet and kovan.",
"pr": 2476
}
]
},

View File

@ -23,7 +23,7 @@
"devUtils": "0x161793cdca4ff9e766a706c2c49c36ac1340bbcd",
"erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0",
"uniswapBridge": "0x533344cfdf2a3e911e2cf4c6f5ed08e791f5355f",
"erc20BridgeSampler": "0x45d41caec1cd893517e6e4e8222717d3d7a3bcb0",
"erc20BridgeSampler": "0x38b55fb7b13cbfbf8781e0f11a77b6199ae10a11",
"kyberBridge": "0xf342f3a80fdc9b48713d58fe97e17f5cc764ee62",
"eth2DaiBridge": "0xe3379a1956f4a79f39eb2e87bb441419e167538e",
"chaiBridge": "0x77c31eba23043b9a72d13470f3a3a311344d7438",
@ -114,7 +114,7 @@
"erc20BridgeProxy": "0xfb2dd2a1366de37f7241c83d47da58fd503e2c64",
"uniswapBridge": "0x8224aa8fe5c9f07d5a59c735386ff6cc6aaeb568",
"eth2DaiBridge": "0x9485d65c6a2fae0d519cced5bd830e57c41998a9",
"erc20BridgeSampler": "0x5ad1553c2e60db118d2c01c0b73ac71e6c586b84",
"erc20BridgeSampler": "0x76a3d21fc9c16afd29eb12a5bdcedd5ddbf24357",
"kyberBridge": "0xde7b2747624a647600fdb349184d0448ab954929",
"chaiBridge": "0x0000000000000000000000000000000000000000",
"dydxBridge": "0x0000000000000000000000000000000000000000"