execution-spec-tests
execution-spec-tests copied to clipboard
Python tool to create a test from a real devnet issue
Create a python tool in this repository that is capable of creating a blockchain test from an invalid block on any devnet, testnet or shadowfork.
The tool must perform the following sequence:
- Query the block
N
to fetch the transactions and header properties of the block where theINVALID
issue was found - Create a set of touched addresses
L
and for each transaction add the sender and recipient addresses to the list - Fetch the account information (balance, nonce, code, storage) of all addresses in
L
at blockN - 1
and add them to thealloc
of the test - Run the block
N
as block 1 of a blockchain test, with thealloc
information at genesis - Analyze the execution trace of all transactions and for each call to a different account (
CALL
,CALLCODE
,DELEGATECALL
,STATICCALL
,SELFDESTRUCT
), account information fetch (BALANCE
,EXTCODESIZE
,EXTCODECOPY
,EXTCODEHASH
), or contract creation (CREATE
,CREATE2
), add the target address toL
- If
L
now contains more addresses, go to (3), otherwise proceed - Blockchain test comprises the Genesis with the
alloc
collected and the Block 1 with the transactions of blockN
with as many properties carried over as possible (Number might be difficult, and if any of the transactions queryNUMBER
opcode, this might result in deviation of execution) - (Optional)
alloc
can be compressed by running the block and then analyzing the trace and then discard the storage keys that are never read on all accounts.