Skip to content

Add an "Authentic" execution mode for tests & scripts #6910

Closed
@Philogy

Description

@Philogy

Component

Forge

Describe the feature you would like

Core Description

I'd like a fundamentally different execution method in foundry. One that executes individual view calls using actual independent eth_calls against the environment and non-view calls as top-level transactions. This is unlike the current default and only execution mode which is all executed within 1 top-level transaction leading to several (often) undesirable side effects:

There are likely more issues that I'm missing. The pain of the above issues is compounded when attempting to use foundry scripts for more special transaction sequences as this mismatch may lead to false positive reverts preventing the script runner from submitting transactions (#6825).

There are a bunch of separate feature requests attempting to address different aspects of this:

While the current execution mode (using one big tx to run tests and simulations) is desirable for many use cases & reasons (faster test & sim execution, testing intra-tx changes). It's undesirable in many others. Instead of solving the different symptoms by adding new cheat codes I suggest taking a more holistic approach: adding a new execution mode.

The new Execution Mode

I'm likely oversimplifying (due to a lack of knowledge of revm and foundry internals please correct where required) but I wanted to offer a potential design/approach for this new mode. In this mode you'd run 2, separate instances of revm within foundry. One that runs the actual test/script and the other that maintains the actual simulated/forked state. CALLs and STATICCALLs made in the simulation environment are dispatched as eth_calls and actual top-level transactions into the second "world" environment. Results are relayed into the first.

While this does add some overhead this solves all the aforementioned issues with one 1 (all be it larger) change without requiring the addition of many separate cheat codes and requiring devs to manually adds this everywhere just so their tests can accurately account gas.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Completed

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions