Consensys / linea-tracer

Part of the Linea stack responsible for extracting data from the execution of an EVM client in order to construct large matrices called execution traces.
https://linea.build
Other
35 stars 28 forks source link

feat: advanced testing framework #955

Open lorenzogentile404 opened 3 months ago

lorenzogentile404 commented 3 months ago

Notes from @OlivierBBB: https://hackmd.io/@olivierbbb/SkOB9AWsC

The purpose of this issue is summarising possible approach to build an advanced testing framework.

First of all, we should check if there is already something existing and ready to use in Java.

If not:

Approach A

The testing library should allow:

Note: Currently, in order to do not create too many smart contracts to test different slightly different cases, we create larger than necessary smart contracts (e.g., in the case of SELFDESTRUCT) and we interact with them in different ways. Such modularity, would allow a more flexible way to define smart contracts for testing that contain only what we need for the specific test case.

Note: mapping Java on Solidity instead of Bytecode directly may make the process quicker and is not a limitation due to the observation above. Mapping Java directly on Bytecode may lead to face the complexity of creating a Solidity-like language in Java, that is unnecessary;

Feel free to add other ideas below.

OlivierBBB commented 3 months ago

Desiderata

A complex contract B that can CREATE2 with complex initC potentially leading to the deployment of complex contract C with complex behaviour, too. They should be able to call each other (in all possible combinations) and do other complex stuff.

Contract B

A contract B which can:

Initialization code initC

Some init code initC that can:

Deployed contract C

initC should, if it leads to a deployment, always deploy the same code (e.g. obtained by an EXTCODESIZE / EXTCODECOPY / RETURN combo) or to empty deployment code or to a failed deployment. When it deploys nontrivially the resulting account C should be able to

Complex example run

Reading order:

20240825_235035

Slightly more readable picture (of a slightly more complex scenario)

20240826_001632