execution-spec-tests icon indicating copy to clipboard operation
execution-spec-tests copied to clipboard

Python tool to create a test from a real devnet issue

Open marioevz opened this issue 1 year ago • 2 comments

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:

  1. Query the block N to fetch the transactions and header properties of the block where the INVALID issue was found
  2. Create a set of touched addresses L and for each transaction add the sender and recipient addresses to the list
  3. Fetch the account information (balance, nonce, code, storage) of all addresses in L at block N - 1 and add them to the alloc of the test
  4. Run the block N as block 1 of a blockchain test, with the alloc information at genesis
  5. 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 to L
  6. If L now contains more addresses, go to (3), otherwise proceed
  7. Blockchain test comprises the Genesis with the alloc collected and the Block 1 with the transactions of block N with as many properties carried over as possible (Number might be difficult, and if any of the transactions query NUMBER opcode, this might result in deviation of execution)
  8. (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.

marioevz avatar Sep 29 '23 17:09 marioevz