Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement EIP 712 #57

Merged
merged 15 commits into from
Apr 4, 2019
Merged

Conversation

Bhargavasomu
Copy link
Contributor

@Bhargavasomu Bhargavasomu commented Mar 18, 2019

What was wrong?

Fixes Issue #35

How was it fixed?

Example.js of the EIP was taken as reference.

TODOS

  1. Supporting the scenario where the data could be arrays (Including error handling etc.)
  2. Validation of the JSON Structured data. (With the use of Regex)
  3. Appropriate Error Handling. (Especially in case where the data is not of the specified corresponding type)
  4. Add tests for the failing or Exception rising cases
  5. Add tests for the Array Data and its corresponding Errors or Exceptions.

Cute Animal Picture

put a cute animal picture link inside the parentheses

@Bhargavasomu Bhargavasomu changed the title Implement EIP 712 [WIP] Implement EIP 712 Mar 18, 2019
@Bhargavasomu
Copy link
Contributor Author

Bhargavasomu commented Mar 18, 2019

@kclowes @pipermerriam there is still stuff to be done and this is just a WIP, but could you please give me a preliminary review? Thankyou.

The hash values match with those given in Example.js which is mentioned in the EIP.

@fubuloubu
Copy link
Contributor

@Bhargavasomu I'm working on adding EIP 712 support in a Plasma Cash client I am writting in Python here: https://github.com/zatoichi-labs/plasma-cash-vyper/tree/signed-structs

I can try and implement using your updates to see how the EIP 712 compatibility works in a practical use case.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

Looking good @Bhargavasomu! I just left a few comments

tests/core/test_EIP712.py Outdated Show resolved Hide resolved
tests/core/test_accounts.py Show resolved Hide resolved
tests/core/test_EIP712.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
tests/core/test_EIP712.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@Bhargavasomu
Copy link
Contributor Author

Bhargavasomu commented Mar 21, 2019

Also @kclowes should we move out the EIP712 functionalities into a separate _utils file? Because it seems worth another file.

EDIT - I have added the best validation I can do to the JSON message in the latest push. Please check it out. The only part left now, is supporting the array data fields. Please let me know if the structure needs to be changed in the code before we finalize the stuff.

/cc @pipermerriam

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

I

eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
eth_account/_utils/signing.py Outdated Show resolved Hide resolved
@Bhargavasomu
Copy link
Contributor Author

Also I feel that this whole EIP 712 can have its own _utils module which would include the validation.py and hashing.py as separate files. Am I good to go on that (or) do you feel that putting all of them in the same file is good?

@pipermerriam
Copy link
Member

I'm fine having an eth_account._utils.eip712 module.

@kclowes
Copy link
Collaborator

kclowes commented Mar 21, 2019

If it's all the same to you two, I'd rather call it something more descriptive like structured_data_signing or something rather than eip712

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

High level this looks good. Leaving it to @kclowes for final review. @carver might want to give it a look too since this is the eth-account codebase and this stuff is sensitive code in case there are any red flags you see that I dont.

eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
@carver
Copy link
Contributor

carver commented Mar 22, 2019

@carver might want to give it a look too since this is the eth-account codebase and this stuff is sensitive code in case there are any red flags you see that I dont.

I have some ideas about how I would restructure the code (including some code not added in this PR), and add a new API, but it is not a quick thing so I'll save it for later. Edit: created #58

I don't see any red flags in any of the existing code. I didn't do a deep dive on the structured message encoder implementation, but it's all pretty separated from any key handling. No objections 👍

@davesque
Copy link
Contributor

@Bhargavasomu I just cut a new eth-abi beta release that fixes the type parsing issue: ethereum/eth-abi#126

@Bhargavasomu Bhargavasomu changed the title [WIP] Implement EIP 712 Implement EIP 712 Mar 25, 2019
@Bhargavasomu
Copy link
Contributor Author

@pipermerriam @kclowes The whole EIP has been implemented (Apart from the rendering changes that need to be made in web3.py side). Could you please review. Thankyou.

eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
@Bhargavasomu
Copy link
Contributor Author

@pipermerriam @kclowes review please.

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

@kclowes all of my issues have been addressed (assuming the things in this review are cleaned up as somu see's fit)

eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
eth_account/_utils/structured_data/hashing.py Outdated Show resolved Hide resolved
@Bhargavasomu
Copy link
Contributor Author

@pipermerriam I have addressed all your issues. Thankyou.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

Looks good to me @Bhargavasomu!

@davesque
Copy link
Contributor

I think this was requested here. Just added some new methods to the eth-abi API to allow for checking if a type is recognized by the registry. Cut eth-abi v2.0.0-beta.8 just now which includes those features.

@Bhargavasomu
Copy link
Contributor Author

@davesque I don't think the new version of eth-abi which is 2.0.0b8 is found by python 3.5. It's recognized only by python 3.6

@davesque
Copy link
Contributor

davesque commented Mar 31, 2019

@Bhargavasomu Correct. Python 3.5 support (and, thus, also pypy support) was removed.

@Bhargavasomu
Copy link
Contributor Author

@davesque but here in eth-account, we are supporting both python 3.5 and pypy.

@pipermerriam @carver should we remove the support for python 3.5 and pypy?

@pipermerriam
Copy link
Member

@Bhargavasomu we're discussing internally what we want to do about this python issue. Maybe you can revert your last changes and keep this PR using it's own hand rolled utility and open an issue to track the need to update once python3.5 is no longer supported.

@Bhargavasomu
Copy link
Contributor Author

This PR is now back to the old version and have opened the issue here #59

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

This looks good to me @Bhargavasomu! Nice work!

@Bhargavasomu
Copy link
Contributor Author

Is there something more to be done as part of this PR? If not, could someone please merge this?

@kclowes kclowes merged commit 32f98c8 into ethereum:master Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants