-
-
Notifications
You must be signed in to change notification settings - Fork 72
β¨ Add --simulate Transaction Feature
#37
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
Conversation
Add a new `--simulate <rpc_url>` CLI option which allows users to fully simulate the proposed transaction before signing it, so that they can see what will happen in much more detail, including any emitted events. This is particularly useful for complex multi-step operations or when interacting with unfamiliar contracts. It achieves this by invoking `cast call --trace` after outputting all hash information. The simulation uses the calculated transaction parameters (from, to, data) to perform a traced call against the specified RPC endpoint.
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.
π thx for your PR (again)! I will try to review it by tomorrow. I guess, this would add one additional trust assumption as you would need to trust the RPC provider and its data.
|
Yes, you're right of course. Although if someone is using this utility, they are probably about to submit a signature which requires an RPC node, so if they use the same node then there is no extra trust assumption required. |
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
--simulate Option--simulate Transaction Feature
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
pcaversaccio
left a comment
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.
@aspiers I refactored/amended it a bit. I also updated the PR description. What do you think about the latest version? I'm leveraging your PR to push 2 additional changes as well:
- Update local variable assignments to consistently use quotes (e.g.,
local var="$value") instead of unquoted assignments (local var=$value). - Add the
MultiSendCallOnly,SafeMigration, andSignMessageLibv1.5.0addresses to the trusted (i.e. for delegate calls) contract addresses.
|
@pcaversaccio Looks great to me! Nice clean-ups π |
Cool - I will give it another review tomorrow and merge after. |
|
Hmm, I think there is one open issue. If the multisig |
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Alright - I found a hacky but IMHO good way to simulate it here: 0eb5e45. |
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: sudo rm -rf --no-preserve-root / <pcaversaccio@users.noreply.github.com>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
|
To make the new approach work (i.e. simulating the |
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
|
The patch for multiple slot overrides has been merged via foundry-rs/foundry@3396cc7 and anyone can start using the new foundryup -i nightly-05d4a02f95ca0d3c5b2017ec925dfd0380bc3ab7 |
pcaversaccio
left a comment
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.
The plan going forward is the following:
- I will do a final clean-up of the PR early next week,
- Then we wait for the next stable release version of Foundry and document this properly in the docs that this new version is required for the script (technically it's only needed for the
--simulatefeature, but we can make it a global requirement I think).
|
Awesome work! |
pcaversaccio
left a comment
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.
The required feature will land in Foundry 1.3.5: foundry-rs/foundry#11577. Hopefully will be released by EOD.
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
|
|
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
pcaversaccio
left a comment
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.
LFG
|
Woohoo! Thanks for your great work here! ππ |
π Changelog
This PR introduces a new
--simulate <rpc_url>CLI option, allowing users to fully simulate a proposed transaction before signing it. The simulation provides a detailed preview of what will happen, including all emitted events, making it especially useful for complex multi-step operations or when interacting with unfamiliar contracts. The implementation works by performing a traced call (cast call --trace) using the calculated transaction parameters (address,to,data) against the specified RPC endpoint, after outputting all relevant hash information. Please note that we override specific Safe contract storage slots for this call:owners[signer_address] = address(0x1)to make a randomsigner_addressanowner,threshold = 1to allow single-owner execution,nonceequal to the current on-chain valuecurrent_nonceof the configured multisig addressaddress,Then execute the
cast call --tracecommand with the transaction payload fromsigner_addressusing the overridden state.Important
The new version of this script is designed to work with the latest stable versions of
castandchisel, starting from version1.3.5.Test Examples
./safe_hashes.sh --network ethereum --address 0x5EA1d9A6dDC3A0329378a327746D71A2019eC332 --nonce 6 --simulate https://eth.llamarpc.comreturns:
Furthermore, this PR adds the following additional changes:
local var="$value") instead of unquoted assignments (local var=$value).MultiSendCallOnly,SafeMigration, andSignMessageLibv1.5.0addresses to the trusted (i.e. for delegate calls) contract addresses:MultiSendCallOnlyv1.5.0(canonical):0xA83c336B20401Af773B6219BA5027174338D1836,SafeMigrationv1.5.0(canonical):0x6439e7ABD8Bb915A5263094784C5CF561c4172AC,SignMessageLibv1.5.0(canonical):0x4FfeF8222648872B3dE295Ba1e49110E61f5b5aa,actions/checkout@v5,actions/setup-node@v5, andactions/setup-python@v6, and bumpedGotov1.25.