Skip to content

feat: simulates transactions in forge and exposes state diff and sim info#72

Merged
stevieraykatz merged 3 commits intobase:mainfrom
mds1:mds/simulations
Apr 11, 2024
Merged

feat: simulates transactions in forge and exposes state diff and sim info#72
stevieraykatz merged 3 commits intobase:mainfrom
mds1:mds/simulations

Conversation

@mds1
Copy link
Contributor

@mds1 mds1 commented Apr 10, 2024

To facilitate the following features:

  1. State diff assertions using state diffs from foundry.
  2. Exposing transaction simulation payloads for simulating with external tools such as Tenderly.
  3. Failing when a simulation or execution reverts or does not result in any state changes.

The below changes were made:

  1. The postCheck hook takes state diff and simulation payload inputs.
  2. The postCheck hook is mutable to enable ffi calls to further validate the transaction results.
  3. Anytime a transaction is executed, whether simulated or broadcast, the state diff is recorded and returned to the caller.
  4. The postCheck hook is always run after a transaction, whether simulated or broadcast.
  5. Booleans returned from methods have been removed, as the methods will now revert if a transaction fails so they are no longer needed.

We had to copy out logic from the base repo in order to execute a simulation in foundry and make assertions on the state diff, as you can see here: ethereum-optimism/superchain-ops@815a5c4

I'd still need to test this branch and make sure no changes were missed, and that it works properly to let us simplify that linked commit, but I wanted to open this draft PR to get feedback on the architecture from a high level and see if you'd be open to merging this PR. — Edit: I've now tested this in the upstream ethereum-optimism/superchain-ops#130 and it seems to be working!

…info

To facilitate the following features:
1. State diff assertions using state diffs from foundry.
2. Exposing transaction simulation payloads for simulating with external
tools such as Tenderly.
3. Failing when a simulation or execution reverts or does not result in
any state changes.

The below changes were made:
1. The postCheck hook takes state diff and simulation payload inputs.
2. The postCheck hook is mutable to enable ffi calls to further validate
the transaction results.
3. Anytime a transaction is executed, whether simulated or broadcast,
the state diff is recorded and returned to the caller.
4. The postCheck hook is always run after a transaction, whether
simulated or broadcast.
5. Booleans returned from methods have been removed, as the methods will
now revert if a transaction fails so they are no longer needed.
Copy link
Member

@stevieraykatz stevieraykatz left a comment

Choose a reason for hiding this comment

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

Great work!

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.

3 participants