py-evm
py-evm copied to clipboard
Make sure `persist_block` persists transactions
What is wrong?
Our current Py-EVM APIs aren't fully capable of backfilling blocks without executing them.
Currently set_block_transactions is the place where we deal with RLP encoding transactions and storing them in the db.
https://github.com/ethereum/py-evm/blob/6fef9c25eff570471d147a4f4a6d4eba00262f57/eth/vm/base.py#L315-L322
But this is only being done on the VM level during the execution of blocks. If all I want is to backfill ancient blocks (because we are beam syncing) then just calling something like persist_block wouldn't do the trick when it comes to storing the actual transactions in the db.
How can it be fixed
From @carver via chat
Hm, yes, but that sounds like a bug in persist_block() to me. So I think that means we need:
- a test that after a persist_block(), it's possible to load a transaction body
- a test that after a persist_block(), it's possible to load a receipt body
- implement something like these lines in persist_block() https://github.com/ethereum/py-evm/blob/6fef9c25eff570471d147a4f4a6d4eba00262f57/eth/vm/base.py#L321-L325
- make sure the transaction root and receipt root in the built tries here ^ match the claimed roots in the header (before persisting them to disk) This is definitely a place where I'd want to see the red tests from 1 and 2 before implementing 3 and 4