Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

EIP-712 implementation #9631

Merged
merged 10 commits into from
Oct 30, 2018
Merged

EIP-712 implementation #9631

merged 10 commits into from
Oct 30, 2018

Conversation

seunlanlege
Copy link
Member

@seunlanlege seunlanlege commented Sep 24, 2018

closes #9424

Missing

  • encode nested array types

@parity-cla-bot
Copy link

It looks like @seunlanlege signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@seunlanlege seunlanlege changed the title (WIP) EIP-712 implementation Missing [] encode array types [] json schema validation logic [] some primitive ethabiv1 types are missing, can't seem to find a comprehensive list of them (WIP) EIP-712 implementation Sep 24, 2018
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks pretty good, couple of minor style grumbles, and couple security issues (disambiguation), that I haven't seen mentioned explicitly in the spec though.

Cargo.toml Outdated
@@ -135,7 +135,7 @@ members = [
"util/triehash-ethereum",
"util/keccak-hasher",
"util/patricia-trie-ethereum",
"util/fastmap",
"util/fastmap"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We prefer to keep trailing commas - so that every line is the same and you can easily add/remove or reorder them.

util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Show resolved Hide resolved
match &*field.type_ {
// Array type e.g uint256[], string[]
ty if ty.rfind(']') == Some(ty.len() - 1) => {
let array_type = ty.split('[').collect::<Vec<_>>()[0];
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to collect(), just use first() and handle possible error (cause what if there is ] in the type but not [?) or maybe better just take a substr up to position of [

util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
@5chdn 5chdn added this to the 2.2 milestone Sep 25, 2018
@5chdn 5chdn added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M4-core ⛓ Core client code / Rust. labels Sep 25, 2018
@5chdn
Copy link
Contributor

5chdn commented Sep 29, 2018

Can you set git user name and mail?

https://help.github.com/articles/setting-your-commit-email-address-in-git/

@seunlanlege
Copy link
Member Author

@5chdn my git configs are set
screenshot from 2018-10-01 08-23-18

@5chdn
Copy link
Contributor

5chdn commented Oct 1, 2018

Can you associate the email with your Github account? It does not show your identity for commits

@seunlanlege
Copy link
Member Author

ok done.

@seunlanlege seunlanlege changed the title (WIP) EIP-712 implementation EIP-712 implementation Oct 1, 2018
@5chdn 5chdn added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Oct 1, 2018
Cargo.lock Outdated Show resolved Hide resolved
Copy link
Collaborator

@tomusdrw tomusdrw 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!

util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
mod parser;
use parser::*;
pub use error::*;
pub use eip712::*;
Copy link
Collaborator

Choose a reason for hiding this comment

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

pub use should be a separate section. Also can we avoid wildcard imports? Is there really so many things there that they can't be listed?

Maybe it's better to just make all the modules (parser, error, eip712) public and just use more explicit path instead?

util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/lib.rs Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Show resolved Hide resolved
@seunlanlege seunlanlege changed the title EIP-712 implementation EIP-191/EIP-712 implementation Oct 3, 2018
@seunlanlege seunlanlege force-pushed the EIP-712 branch 2 times, most recently from 05526ca to 08344e0 Compare October 4, 2018 11:15
@seunlanlege seunlanlege changed the title EIP-191/EIP-712 implementation EIP-712 implementation Oct 4, 2018
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

There are some submodules changes still.

util/EIP-712/src/eip712.rs Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/parser.rs Outdated Show resolved Hide resolved
util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
util/EIP-712/src/parser.rs Outdated Show resolved Hide resolved
util/EIP-712/src/parser.rs Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
rpc/src/v1/traits/personal.rs Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,303 @@
extern crate serde;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add unused_extern_crates as well?

util/EIP-712/Cargo.toml Outdated Show resolved Hide resolved
@5chdn
Copy link
Contributor

5chdn commented Oct 26, 2018

@seunlanlege please rebase this on master

@tomusdrw @ordian could you give this a final review?

@seunlanlege seunlanlege mentioned this pull request Oct 26, 2018
Cargo.lock Outdated Show resolved Hide resolved
util/EIP-712/src/error.rs Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
util/EIP-712/src/encode.rs Show resolved Hide resolved
util/EIP-712/src/encode.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Lgtm, let's get it merged :)

Cargo.lock Outdated Show resolved Hide resolved
util/EIP-712/src/eip712.rs Outdated Show resolved Hide resolved
util/EIP-712/src/parser.rs Outdated Show resolved Hide resolved
…aced LinkedHashSet with IndexSet, added API spec to docs, fixed Type::Byte encoding branch
@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 30, 2018
@ordian ordian merged commit 61c1646 into master Oct 30, 2018
@ordian ordian deleted the EIP-712 branch October 30, 2018 21:12
seunlanlege added a commit that referenced this pull request Nov 14, 2018
* EIP-712 impl

* added more tests

* removed size parsing unwrap

* corrected TYPE_REGEX to disallow zero sized fixed length arrays, replaced LinkedHashSet with IndexSet, added API spec to docs, fixed Type::Byte encoding branch

* use Option<u64> instead of u64 for Type::Array::Length

* replace `.iter()` with  `.values()`

Co-Authored-By: seunlanlege <[email protected]>

* tabify eip712.rs

* use proper comments for docs

* Cargo.lock: revert unrelated changes

* tabify encode.rs
This was referenced Nov 14, 2018
seunlanlege added a commit that referenced this pull request Nov 14, 2018
* EIP-712 impl

* added more tests

* removed size parsing unwrap

* corrected TYPE_REGEX to disallow zero sized fixed length arrays, replaced LinkedHashSet with IndexSet, added API spec to docs, fixed Type::Byte encoding branch

* use Option<u64> instead of u64 for Type::Array::Length

* replace `.iter()` with  `.values()`

Co-Authored-By: seunlanlege <[email protected]>

* tabify eip712.rs

* use proper comments for docs

* Cargo.lock: revert unrelated changes

* tabify encode.rs
Tbaut added a commit that referenced this pull request Nov 14, 2018
* Bump beta to version 2.2.1

* fix: Intermittent failing CI due to addr in use (#9885)

Allow OS to set port at runtime

* Use Weak reference in PubSubClient (#9886)

* Fix json tracer overflow (#9873)

* Fix json tracer overflow

* Replace trace_executed with a direct trace push

* Remove unused variable

* Add test for 5a51

* Remove duplicate json!

* Fix docker script (#9854)


* Dockerfile: change source path of the newly added check_sync.sh (#9869)

* Allow to seal work on latest block (#9876)

* Allow to seal work on latest block.

* Test from @todr to check sealing conditions.

* gitlab-ci: make android release build succeed (#9743)

* use docker cargo config file for android builds

* make android build succeed

* ethcore: use Machine::verify_transaction on parent block (#9900)

* ethcore: use Machine::verify_transaction on parent block

also fixes off-by-one activation of transaction permission contract

* ethcore: clarify call to verify_transaction

* foundation: #6692865, ropsten: #4417537, kovan: #9363457

* Remove rust-toolchain file (#9906)

* EIP-712 implementation (#9631)

* EIP-712 impl

* added more tests

* removed size parsing unwrap

* corrected TYPE_REGEX to disallow zero sized fixed length arrays, replaced LinkedHashSet with IndexSet, added API spec to docs, fixed Type::Byte encoding branch

* use Option<u64> instead of u64 for Type::Array::Length

* replace `.iter()` with  `.values()`

Co-Authored-By: seunlanlege <[email protected]>

* tabify eip712.rs

* use proper comments for docs

* Cargo.lock: revert unrelated changes

* tabify encode.rs

* EIP 191 (#9701)

* added sign_191 rpc method

* fixed hash_structured_data return type

* added ConfirmationPayload::SignMessage for non-prefixed signatures, added tests for sign191

* renamed WithValidator -> PresignedTransaction

* rename applicationData to data in test

* adds docs for EIP191Version, renamed SignRequest to EIP191SignRequest

* light-fetch: Differentiate between out-of-gas/manual throw and use required gas from response on failure (#9824)

* fix start_gas, handle OOG exceptions & NotEnoughGas

* Change START_GAS: 50_000 -> 60_000
* When the `OutOfGas exception` is received then try to double the gas until it succeeds or block gas limit is reached
* When `NotEnoughBasGas error` is received then use the required gas provided in the response

* fix(light-fetch): ensure block_gas_limit is tried

Try the `block_gas_limit` before regard the execution as an error

* Update rpc/src/v1/helpers/light_fetch.rs

Co-Authored-By: niklasad1 <[email protected]>

* simplify cargo audit

* Use block header for building finality (#9914)

* ci: nuke the gitlab caches (#9855)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement EIP-712 Signing API
8 participants