Skip to content

fix: snapshot and restore Safe nonce#77

Merged
mdehoog merged 2 commits into
base:mainfrom
mds1:fix/safe-nonce
Apr 18, 2024
Merged

fix: snapshot and restore Safe nonce#77
mdehoog merged 2 commits into
base:mainfrom
mds1:fix/safe-nonce

Conversation

@mds1

@mds1 mds1 commented Apr 18, 2024

Copy link
Copy Markdown
Contributor

We recently merged #72. Prior to this PR, foundry did not simulate the transaction, and just logged the data needed to generate the tenderly sim. As a result, when forge called safe.nonce() at the very end of the solidity script, it matched what was on the actual chain.

In that PR, we modified the scripts so forge always applies the required state overrides and simulates the transaction. This was done so we can use the state diff recording cheats in foundry and make assertions on the diff.
However, the actual logging of the Data to sign: that's in the terminal calls safe.nonce() after the foundry simulation, so it's one too high.

This PR snapshots the safe nonce prior to simulation and restores it after, so the data to sign is corrected logged.

mds1 and others added 2 commits April 17, 2024 17:53
Co-authored-by: Emiliano Bonassi <emiliano@conduit.xyz>

abstract contract MultisigBase is Simulator {
IMulticall3 internal constant multicall = IMulticall3(MULTICALL3_ADDRESS);
bytes32 internal constant SAFE_NONCE_SLOT = bytes32(uint256(5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is risk this will collide with another value that is automatically assigned by solc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants