-
Notifications
You must be signed in to change notification settings - Fork 83
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
E2E Test For Hook-Enabled ERC-1271 Signatures #1832
Conversation
ffcce9e
to
57948a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. This allows for some very nice use cases, where users can e.g. bridge funds to a specific mainnet address and sign an order in the name of that address in which the safe is deployed in a pre-hook and proceeds are swapped back to their address on the original chain in a post hook.
fn domain_separator(&self) -> DomainSeparator { | ||
let mut buffer = [0_u8; 96]; | ||
buffer[0..32].copy_from_slice(&hex!( | ||
"47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these magic numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry - meant to include links to code but forgot. Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some documentation with links to the code that was ported and where the magic numbers come from.
282617c
to
ba63849
Compare
c82b060
to
04549bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test and easy to understand. 👍
Follow up to #1827 (comment) - thanks @fleupold for the wonderful idea! This PR changes instances of `eth_call` with state override simulations **where we are only overriding the Settlement contract code** to make use of `StorageAccessible`. It does this with an additional support `Reader` contract in order to avoid needing to manage deployments on-chain for the `StorageAccessible` target (i.e. the reader logic). See the comment in the `Reader.sol` file for more details on how this works. Specifically, we changed the following two simulations to no longer require state overrides (i.e. we do not need a special node to handle those requests, and it will Just Work™ on Gnosis Chain): * Account balance simulations with pre-hooks * ERC-1271 signature validation with pre-hooks In a follow up PRs I will: 1. #1832 2. Remove the redundant `Web3` strategy for both account balance and signature verification simulation ### Release notes Hooks E2E test continues to pass **without the nasty `----account-balances-optimistic-pre-interaction-handling=true` hack** which used to disable balance checks for orders with pre-hooks. This means that not only are we E2E testing that executing orders with pre-hooks are working, we are also checking that balance simulations work 🎉. You can double check this is actually doing something by applying a patch like this: ```diff diff --git a/crates/e2e/tests/e2e/hooks.rs b/crates/e2e/tests/e2e/hooks.rs index 42d8d072..84d978b5 100644 --- a/crates/e2e/tests/e2e/hooks.rs +++ b/crates/e2e/tests/e2e/hooks.rs @@ -66,7 +66,7 @@ async fn test(web3: Web3) { full: json!({ "metadata": { "hooks": { - "pre": [permit, steal_cow], + "pre": [/*permit, */steal_cow], "post": [steal_weth], }, }, ``` And see the E2E test fail as expected with: ``` thread 'hooks::local_node_test' panicked at 'called `Result::unwrap()` on an `Err` value: (400, "{\"errorType\":\"InsufficientAllowance\",\"description\":\"order owner must give allowance to VaultRelayer\"}")', crates/e2e/tests/e2e/hooks.rs:83:41 ``` I also ran the `cargo test -p shared -- --nocapture --ignored account_balances::simulation` manual test which continues to work.
04549bf
to
27b0509
Compare
Now, thanks to #1831, we no longer depend on
eth_call
with state override support for simulating ERC-1271 signature validation for orders with pre-hooks. This means that we can finally write an E2E test for this!This PR does just that - it executes an order on behalf of a Safe that is created just-in-time for the settlement as part of a pre-hook. Note that we assert that the ERC-1271 order is created for a Safe with no code!
Test Plan
This is the test!