Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Swallow reverts in ERC20BridgeSampler #2395

Conversation

dorothy-zbornak
Copy link
Contributor

Description

Quoting external DEXes can revert if the market does not exist (e.g., asking Eth2Dai for ZRX). We could whitelist/blacklist exchanges from pairs in asset-swapper, but it's simpler to just swallow these errors and return zero for the quotes in the sampler contract.

In addition, the sampler will no longer query fillable status for native orders with either:

  • 0 makerAssetAmount
  • 0 takerAssetAmount
  • Empty signature

This is to simplify the case where we don't have any native orders to pass to the sampler, which the sampler needs to extract the token information. Previously we had to clumsily pass in an order with 1 in the asset amounts and a Wallet signature type.

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@buildsize
Copy link

buildsize bot commented Dec 13, 2019

File name Previous Size New Size Change
init.py 60.25 KB 60.25 KB 0 bytes (0%)
abi_gen_dummy.ts 77.76 KB [deleted]
lib_dummy.ts 7.13 KB [deleted]
test_lib_dummy.ts 10.38 KB [deleted]
environment.pickle 1.61 MB 1.61 MB 0 bytes (0%)
index.doctree 187.37 KB 187.37 KB 0 bytes (0%)
.buildinfo 230 bytes 230 bytes 0 bytes (0%)
genindex.html 5.6 KB 5.6 KB 0 bytes (0%)
index.html 2.52 KB 2.52 KB 0 bytes (0%)
objects.inv 375 bytes 375 bytes 0 bytes (0%)
py-modindex.html 3.07 KB 3.07 KB 0 bytes (0%)
search.html 2.84 KB 2.84 KB 0 bytes (0%)
searchindex.js 6.31 KB 6.31 KB 0 bytes (0%)
index.rst.txt 415 bytes 415 bytes 0 bytes (0%)
alabaster.css 10.92 KB 10.92 KB 0 bytes (0%)
basic.css 11.89 KB 11.89 KB 0 bytes (0%)
custom.css 42 bytes 42 bytes 0 bytes (0%)
doctools.js 9.05 KB 9.05 KB 0 bytes (0%)
documentation_options.js 303 bytes 303 bytes 0 bytes (0%)
file.png 286 bytes 286 bytes 0 bytes (0%)
jquery-[version].js 273.79 KB 273.79 KB 0 bytes (0%)
jquery.js 86.08 KB 86.08 KB 0 bytes (0%)
language_data.js 10.59 KB 10.59 KB 0 bytes (0%)
minus.png 90 bytes 90 bytes 0 bytes (0%)
plus.png 90 bytes 90 bytes 0 bytes (0%)
pygments.css 4.69 KB 4.69 KB 0 bytes (0%)
searchtools.js 15.61 KB 15.61 KB 0 bytes (0%)
underscore-[version].js 34.34 KB 34.34 KB 0 bytes (0%)
underscore.js 11.86 KB 11.86 KB 0 bytes (0%)
contract_addresses.html 16.8 KB 16.8 KB 0 bytes (0%)
contract_artifacts.html 8.24 KB 8.24 KB 0 bytes (0%)
json_schemas.html 12.56 KB 12.56 KB 0 bytes (0%)
order_utils.html 47.16 KB 47.16 KB 0 bytes (0%)
erc20_token.html 93.56 KB 93.56 KB 0 bytes (0%)
exchange.html 718.38 KB 718.38 KB 0 bytes (0%)
tx_params.html 9.41 KB 9.41 KB 0 bytes (0%)
local_message_signer.html 15.08 KB 15.08 KB 0 bytes (0%)
asset_data_utils.html 22.66 KB 22.66 KB 0 bytes (0%)
default_api.html 113.17 KB 113.17 KB 0 bytes (0%)
asset_proxy_owner.html 337.39 KB 337.39 KB 0 bytes (0%)
coordinator.html 128.72 KB 128.72 KB 0 bytes (0%)
coordinator_registry.html 39.59 KB 39.59 KB 0 bytes (0%)
dutch_auction.html 66.13 KB 66.13 KB 0 bytes (0%)
erc20_proxy.html 109.07 KB 109.07 KB 0 bytes (0%)
erc721_proxy.html 109.19 KB 109.19 KB 0 bytes (0%)
erc721_token.html 150.2 KB 150.2 KB 0 bytes (0%)
forwarder.html 124.01 KB 124.01 KB 0 bytes (0%)
i_asset_proxy.html 40.18 KB 40.18 KB 0 bytes (0%)
i_validator.html 27.06 KB 27.06 KB 0 bytes (0%)
i_wallet.html 24.9 KB 24.9 KB 0 bytes (0%)
multi_asset_proxy.html 144.04 KB 144.04 KB 0 bytes (0%)
order_validator.html 107.69 KB 107.69 KB 0 bytes (0%)
weth9.html 132.09 KB 132.09 KB 0 bytes (0%)
zrx_token.html 107.61 KB 107.61 KB 0 bytes (0%)
dev_utils.html 526.89 KB 526.89 KB 0 bytes (0%)
types.html 8.54 KB 8.54 KB 0 bytes (0%)
erc1155_mintable.html 276.51 KB 276.51 KB 0 bytes (0%)
erc1155_proxy.html 130.38 KB 130.38 KB 0 bytes (0%)
static_call_proxy.html 34.04 KB 34.04 KB 0 bytes (0%)

@coveralls
Copy link

coveralls commented Dec 13, 2019

Coverage Status

Coverage remained the same at 77.804% when pulling ebccf10 on feat/contracts/erc20-bridge-sampler/graceful-reverts into a556d91 on development.

@dorothy-zbornak dorothy-zbornak force-pushed the feat/contracts/erc20-bridge-sampler/graceful-reverts branch from 6e3e7a8 to 7737a9c Compare December 13, 2019 07:54
@dorothy-zbornak dorothy-zbornak force-pushed the feat/contracts/erc20-bridge-sampler/graceful-reverts branch from 7737a9c to b5d7b22 Compare December 13, 2019 08:02
/// @dev Address of the 0x Exchange contract.
address constant public EXCHANGE_ADDRESS = 0x080bf510FCbF18b91105470639e9561022937712;
/// @dev Address of the 0x DevUtils contract.
address constant public DEVUTILS_ADDRESS = 0xcCc2431a7335F21d9268bA62F0B32B0f2EFC463f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use MixinDeploymentConstants in the contracts-utils package for this?

Also nit: this should be DEV_UTILS_ADDRESS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're OK with adding kyber and all that jazz to it, sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh they already are there 🙃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it. The unused internal functions won't be part of the bytecode anyways from my understanding.

));
uint256 rate = 0;
if (didSucceed) {
(rate,) = abi.decode(resultData, (uint256, uint256));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(rate,) = abi.decode(resultData, (uint256)) would be a bit more efficient here.

// convert them to maker asset amounts.
for (uint256 i = 0; i < orders.length; ++i) {
if (orderFillableMakerAssetAmounts[i] != 0) {
orderFillableMakerAssetAmounts[i] = LibMath.getPartialAmountFloor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use getPartialAmountCeil here? This will underestimate the actual fillable amount.

@dorothy-zbornak dorothy-zbornak force-pushed the feat/contracts/erc20-bridge-sampler/graceful-reverts branch 2 times, most recently from 8e04b8b to 3a1ac4f Compare December 13, 2019 17:46
@dorothy-zbornak dorothy-zbornak force-pushed the feat/contracts/erc20-bridge-sampler/graceful-reverts branch from 3a1ac4f to ebccf10 Compare December 13, 2019 17:48
Copy link
Contributor

@hysz hysz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@dorothy-zbornak dorothy-zbornak merged commit 70870ff into development Dec 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants