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

Migrate to Web3.py v5 #2038

Merged
merged 15 commits into from
Aug 8, 2019
Merged

Migrate to Web3.py v5 #2038

merged 15 commits into from
Aug 8, 2019

Conversation

feuGeneA
Copy link
Contributor

@feuGeneA feuGeneA commented Aug 7, 2019

Fixes #2029

This PR started as simply a migration, but turned into a bit more.

First of all, the migration exposed a lack of a clean command in the sra_client package, which was causing headaches and which I've fixed here. Also, a recent change I made to build components in parallel simply doesn't make sense; they need to be built in dependency order, and I've fixed that here. And, it turns out that the dependency order stored in the monorepo scripts was mixed up, so I fixed it and also provided a script to automatically produce that dependency order by inspecting the packages' dependencies.

The migration also turned up two problems with the SRA client tests. One of those problems is that currently Launch Kit Backend does not support EIP-55 checksummed addresses. This is a problem because Web3.py v5 enforces all addresses coming through its interfaces to be checksummed, which throws a kink in the SRA tests. I've raised 0xProject/0x-launch-kit-backend#73 to track this problem, and @dekz has created a custom build (docker image, used in CI here) that allows my tests to post an order with a checksummed address, but because retrieving an order still conveys a toLower()ed address, the SRA example has been temporarily modified to checksum the maker address in the order retrieved from launch kit before it proceeds to fill that order.

The other problem with the SRA tests is with the migration to the new Launch Kit Backend docker image. Previously these tests were using 0xorg/launch-kit-ci, but that was a one-off thing created just for CI, back before there was a regularly maintained docker image of Launch Kit. In this PR I changed the setup to use 0xorg/launch-kit-backend instead, since it's regularly maintained/updated. However, there is an outstanding problem with this setup in CircleCI, which I will need to raise with their support team. If you look at the commit where I changed docker images, you'll see that there are two places the image has changed: in .circleci/config.yml, and in python-packages/sra_client/test/relayer/docker-compose.yml. Note that both before and after that commit, those two files have an effectively identical configuration. However, while the new docker-compose.yml file works great for local development, the .circleci/config.yml file is simply not working. The docker image never produces any output in the build run, and the tests time out trying to connect to the relayer endpoint. For this reason, this PR disables the SRA client tests for CI. (They remain enabled for local development.)

Finally, I happened to notice some problems with the generated docs for the contract wrappers, which I've also fixed in this PR. The latest build of the contract wrapper documentation is here. The problems were that (a) we weren't generating docs for all of the wrappers (just Exchange and ERC20Token), and (b) the docs weren't including the contract wrappers' member variables, which are the instantiated, named method classes.

  • Migrate to new API.
  • Update launch-kit-ci docker image with recent changes to JSON schema for address data type. Web3.py 5.x is now handling all addresses with checksum formatting, and the current launch-kit-ci image is still using the old JSON schema which only allows lower-case hex digits in an address. Punted on this, and raised EIP-55 checksummed addresses not supported 0x-launch-kit-backend#73 .
  • Add new entries to the relevant CHANGELOG.jsons.

@feuGeneA feuGeneA self-assigned this Aug 7, 2019
@feuGeneA feuGeneA added the python label Aug 7, 2019
@feuGeneA feuGeneA changed the title Fix/python/migrate to web3 v5 Migrate to Web3.py v5 Aug 7, 2019
@buildsize
Copy link

buildsize bot commented Aug 7, 2019

File name Previous Size New Size Change
init.py 141.35 KB 144.25 KB 2.89 KB (2%)
abi_gen_dummy.ts 144.09 KB [deleted]
lib_dummy.ts 4.74 KB [deleted]
test_lib_dummy.ts 12.61 KB [deleted]
environment.pickle 1.56 MB 1.56 MB 0 bytes (0%)
index.doctree 189.53 KB 191 KB 1.47 KB (1%)
.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.81 KB 2.81 KB 0 bytes (0%)
searchindex.js 5.83 KB 5.84 KB 16 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.83 KB 11.83 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 261.76 KB 261.76 KB 0 bytes (0%)
jquery.js 84.63 KB 84.63 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 17.89 KB 17.89 KB 0 bytes (0%)
contract_artifacts.html 7.94 KB 7.94 KB 0 bytes (0%)
_bootstrap.html 142.73 KB 142.73 KB 0 bytes (0%)
json_schemas.html 12.43 KB 12.43 KB 0 bytes (0%)
order_utils.html 44.87 KB 44.83 KB -40 bytes (0%)
erc20_token.html 80.16 KB 88.14 KB 7.99 KB (10%)
exchange.html 458.92 KB 506.16 KB 47.25 KB (10%)
tx_params.html 8.83 KB 8.83 KB 0 bytes (0%)
local_message_signer.html 15.07 KB 15.07 KB 8 bytes (0%)
asset_data_utils.html 22.65 KB 22.65 KB 0 bytes (0%)
default_api.html 118.49 KB 118.49 KB 0 bytes (0%)
globals.html 13.15 KB [deleted]
asset_proxy_owner.assetproxyownercontract.html 419.2 KB [deleted]
coordinator.coordinatorcontract.html 153.51 KB [deleted]
coordinator_registry.coordinatorregistrycontract.html 95.28 KB [deleted]
dummy_erc20_token.dummyerc20tokencontract.html 250.08 KB [deleted]
dummy_erc721_token.dummyerc721tokencontract.html 291.13 KB [deleted]
dutch_auction.dutchauctioncontract.html 138.38 KB [deleted]
erc20_proxy.erc20proxycontract.html 180.44 KB [deleted]
erc20_token.erc20tokencontract.html 152.99 KB [deleted]
erc721_proxy.erc721proxycontract.html 180.76 KB [deleted]
erc721_token.erc721tokencontract.html 208.09 KB [deleted]
eth_balance_checker.ethbalancecheckercontract.html 63.85 KB [deleted]
exchange.exchangecontract.html 705.67 KB [deleted]
forwarder.forwardercontract.html 166.9 KB [deleted]
i_asset_proxy.iassetproxycontract.html 166.84 KB [deleted]
i_validator.ivalidatorcontract.html 63.74 KB [deleted]
i_wallet.iwalletcontract.html 62.67 KB [deleted]
multi_asset_proxy.multiassetproxycontract.html 218.05 KB [deleted]
order_validator.ordervalidatorcontract.html 137.28 KB [deleted]
weth9.weth9contract.html 201.33 KB [deleted]
zrx_token.zrxtokencontract.html 170.85 KB [deleted]
asset_proxy_owner.assetproxyownerevents.html 26.5 KB [deleted]
coordinator_registry.coordinatorregistryevents.html 12.82 KB [deleted]
dummy_erc20_token.dummyerc20tokenevents.html 13.73 KB [deleted]
dummy_erc721_token.dummyerc721tokenevents.html 15.06 KB [deleted]
erc20_proxy.erc20proxyevents.html 13.94 KB [deleted]
erc20_token.erc20tokenevents.html 13.55 KB [deleted]
erc721_proxy.erc721proxyevents.html 13.97 KB [deleted]
erc721_token.erc721tokenevents.html 14.83 KB [deleted]
exchange.exchangeevents.html 17.13 KB [deleted]
multi_asset_proxy.multiassetproxyevents.html 15.5 KB [deleted]
weth9.weth9events.html 15.51 KB [deleted]
zrx_token.zrxtokenevents.html 13.46 KB [deleted]
asset_proxy_owner.assetproxyownerassetproxyregistrationeventargs.html 17.28 KB [deleted]
asset_proxy_owner.assetproxyownerconfirmationeventargs.html 17.08 KB [deleted]
asset_proxy_owner.assetproxyownerconfirmationtimeseteventargs.html 17.23 KB [deleted]
asset_proxy_owner.assetproxyownerdepositeventargs.html 16.96 KB [deleted]
asset_proxy_owner.assetproxyownerexecutioneventargs.html 16.12 KB [deleted]
asset_proxy_owner.assetproxyownerexecutionfailureeventargs.html 16.17 KB [deleted]
asset_proxy_owner.assetproxyownerowneradditioneventargs.html 16.07 KB [deleted]
asset_proxy_owner.assetproxyownerownerremovaleventargs.html 16.07 KB [deleted]
asset_proxy_owner.assetproxyownerrequirementchangeeventargs.html 16.12 KB [deleted]
asset_proxy_owner.assetproxyownerrevocationeventargs.html 17.06 KB [deleted]
asset_proxy_owner.assetproxyownersubmissioneventargs.html 16.13 KB [deleted]
asset_proxy_owner.assetproxyownertimelockchangeeventargs.html 16.2 KB [deleted]
coordinator_registry.coordinatorregistrycoordinatorendpointseteventargs.html 14.7 KB [deleted]
dummy_erc20_token.dummyerc20tokenapprovaleventargs.html 15.38 KB [deleted]
dummy_erc20_token.dummyerc20tokentransfereventargs.html 15.34 KB [deleted]
dummy_erc721_token.dummyerc721tokenapprovaleventargs.html 15.72 KB [deleted]
dummy_erc721_token.dummyerc721tokenapprovalforalleventargs.html 15.77 KB [deleted]
dummy_erc721_token.dummyerc721tokentransfereventargs.html 15.67 KB [deleted]
erc20_proxy.erc20proxyauthorizedaddressaddedeventargs.html 14.45 KB [deleted]
erc20_proxy.erc20proxyauthorizedaddressremovedeventargs.html 14.47 KB [deleted]
erc20_token.erc20tokenapprovaleventargs.html 15.17 KB [deleted]
erc20_token.erc20tokentransfereventargs.html 15.12 KB [deleted]
erc721_proxy.erc721proxyauthorizedaddressaddedeventargs.html 14.49 KB [deleted]
erc721_proxy.erc721proxyauthorizedaddressremovedeventargs.html 14.5 KB [deleted]
erc721_token.erc721tokenapprovaleventargs.html 15.48 KB [deleted]
erc721_token.erc721tokenapprovalforalleventargs.html 15.53 KB [deleted]
erc721_token.erc721tokentransfereventargs.html 15.43 KB [deleted]
exchange.exchangeassetproxyregisteredeventargs.html 14.95 KB [deleted]
exchange.exchangecanceleventargs.html 18.8 KB [deleted]
exchange.exchangecanceluptoeventargs.html 15.9 KB [deleted]
exchange.exchangefilleventargs.html 23.7 KB [deleted]
exchange.exchangesignaturevalidatorapprovaleventargs.html 16.07 KB [deleted]
multi_asset_proxy.multiassetproxyassetproxyregisteredeventargs.html 14.93 KB [deleted]
multi_asset_proxy.multiassetproxyauthorizedaddressaddedeventargs.html 14.93 KB [deleted]
multi_asset_proxy.multiassetproxyauthorizedaddressremovedeventargs.html 14.95 KB [deleted]
weth9.weth9approvaleventargs.html 15.31 KB [deleted]
weth9.weth9depositeventargs.html 14.42 KB [deleted]
weth9.weth9transfereventargs.html 15.27 KB [deleted]
weth9.weth9withdrawaleventargs.html 14.45 KB [deleted]
zrx_token.zrxtokenapprovaleventargs.html 15.06 KB [deleted]
zrx_token.zrxtokentransfereventargs.html 15.02 KB [deleted]
asset_proxy_owner.html 21.01 KB [deleted]
coordinator.html 10.54 KB [deleted]
coordinator_registry.html 13.35 KB [deleted]
dummy_erc20_token.html 13.78 KB [deleted]
dummy_erc721_token.html 14.55 KB [deleted]
dutch_auction.html 10.57 KB [deleted]
erc20_proxy.html 13.76 KB [deleted]
erc20_token.html 13.54 KB [deleted]
erc721_proxy.html 13.8 KB [deleted]
erc721_token.html 14.26 KB [deleted]
eth_balance_checker.html 10.63 KB [deleted]
exchange.html 15.33 KB [deleted]
forwarder.html 10.52 KB [deleted]
i_asset_proxy.html 10.56 KB [deleted]
i_validator.html 10.54 KB [deleted]
i_wallet.html 10.51 KB [deleted]
multi_asset_proxy.html 14.81 KB [deleted]
order_validator.html 10.59 KB [deleted]
weth9.html 14.36 KB [deleted]
zrx_token.html 13.4 KB [deleted]
main.css 69.04 KB [deleted]
main.css.map 30.1 KB [deleted]
icons.png 9.26 KB [deleted]
[email protected] 27.09 KB [deleted]
widgets.png 480 bytes [deleted]
[email protected] 855 bytes [deleted]
main.js 148.53 KB [deleted]
search.js 517.35 KB [deleted]
erc1155_proxy.erc1155proxycontract.html 194.88 KB [deleted]
static_call_proxy.staticcallproxycontract.html 71.1 KB [deleted]
erc1155_proxy.erc1155proxyevents.html 13.73 KB [deleted]
erc1155_proxy.erc1155proxyauthorizedaddressaddedeventargs.html 14.25 KB [deleted]
erc1155_proxy.erc1155proxyauthorizedaddressremovedeventargs.html 14.27 KB [deleted]
erc1155_proxy.html 13.71 KB [deleted]
static_call_proxy.html 10.61 KB [deleted]
asset_proxy_owner.html [new file] 341.77 KB
coordinator.html [new file] 127.47 KB
coordinator_registry.html [new file] 36.15 KB
dutch_auction.html [new file] 54.84 KB
erc20_proxy.html [new file] 105.63 KB
erc721_proxy.html [new file] 105.72 KB
erc721_token.html [new file] 141.96 KB
eth_balance_checker.html [new file] 21.03 KB
forwarder.html [new file] 107.42 KB
i_asset_proxy.html [new file] 89.89 KB
i_validator.html [new file] 25.7 KB
i_wallet.html [new file] 23.21 KB
multi_asset_proxy.html [new file] 141.39 KB
order_validator.html [new file] 115.34 KB
weth9.html [new file] 129.04 KB
zrx_token.html [new file] 107.34 KB

@feuGeneA feuGeneA force-pushed the fix/python/migrate-to-web3-v5 branch 2 times, most recently from c00f47b to 88b25df Compare August 7, 2019 18:51
Install Python packages in dependency order, not in parallel.
...and include a script to produce the proper ordering.
@feuGeneA feuGeneA force-pushed the fix/python/migrate-to-web3-v5 branch 2 times, most recently from 4295625 to adca5f0 Compare August 7, 2019 19:03
@coveralls
Copy link

coveralls commented Aug 7, 2019

Coverage Status

Coverage increased (+0.03%) to 82.035% when pulling 2e5501a on fix/python/migrate-to-web3-v5 into 5ac7ff7 on development.

@feuGeneA feuGeneA force-pushed the fix/python/migrate-to-web3-v5 branch 7 times, most recently from 26f0b2f to 039ab78 Compare August 8, 2019 00:26
@feuGeneA feuGeneA force-pushed the fix/python/migrate-to-web3-v5 branch 4 times, most recently from ec93726 to 590c0d8 Compare August 8, 2019 12:55
This was discovered while minimizing CircleCI steps to dianose a problem
with running the Launch Kit Backend in CircleCI.

These classes should be imported via the
zero_ex.contract_wrappers.exchange and
zero_ex.contract_wrappers.erc20_token modules, respectively.  We
permitted importing them from just zero_ex.contract_wrappers back when
they were the only wrappers we had, but now that we have so many
different contracts being wrapped, this is just another list to keep
manually updated (which, obviously is error prone, since it slipped
through the cracks already), so it's better to just not support this
type of import.
Without this, generated documentation was not including the class
members that represent the contract methods, rendering the usage
unclear.
@feuGeneA feuGeneA force-pushed the fix/python/migrate-to-web3-v5 branch from 590c0d8 to d81927a Compare August 8, 2019 14:01
@feuGeneA feuGeneA requested a review from xianny as a code owner August 8, 2019 14:01
Previously these teses were using 0xorg/launch-kit-ci, but that was a
one-off thing created just for CI, back before there was a regularly
maintained docker image of Launch Kit.

Changed to use 0xorg/launch-kit-backend since it's regularly
maintained/updated.

Because the -backend image is using a different Linux distribution
(Alpine), the commands used to wait for ganache startup also had to
change.

The tag used, 74bcc39, is provisional due to the pending Issue at
0xProject/0x-launch-kit-backend#73 .  When
that issue is resolved, the tag suffix on the imag name should be
removed.
Due to problem with launch-kit-backend, documented at
0xProject/0x-launch-kit-backend#73 ,
we need to checksum the makerAddress, in the order retrieved from the
relayer, before filling it, otherwise Web3.py gives this error:

InvalidAddress('Web3.py only accepts checksum addresses. The software
that gave you this non-checksum address should be considered unsafe,
please file it as a bug on their platform. Try using an ENS name
instead. Or, if you must accept lower safety, use
Web3.toChecksumAddress(lower_case_address).',
'0x5409ed021d9299bf6814279a6a1411a7e866a631')
Formerly CHANGELOG was in chronological order.  Now it's in reverse
chronological order.
@@ -446,8 +446,8 @@ def validate_and_normalize_inputs(self, _hash: bytes, v: int, r: bytes, s: bytes
def call(self, _hash: bytes, v: int, r: bytes, s: bytes, tx_params: Optional[TxParams] = None) -> str:
"""Execute underlying contract method via eth_call.

test that devdocs will be generated and that multiline devdocs will
look okay
test that devdocs will be generated andthat multiline devdocs will look
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like we need 1 space here!

@@ -246,11 +246,9 @@ def run(self):
"0x-contract-artifacts",
"0x-json-schemas",
"0x-order-utils",
"0x-web3",
"web3",
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@xianny xianny left a comment

Choose a reason for hiding this comment

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

There is one thing where newlines in doc comments get concatenated.

Apart from that, looks good to me - with the caveat that I don't know much about Python, so I'm relying on CI passing to signal that it works!

@feuGeneA feuGeneA merged commit ec80712 into development Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Python dependencies to use mainline Web3.py rather than the 0x fork
3 participants