py-evm icon indicating copy to clipboard operation
py-evm copied to clipboard

Make sure `persist_block` persists transactions

Open cburgdorf opened this issue 5 years ago • 0 comments

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:

  1. a test that after a persist_block(), it's possible to load a transaction body
  2. a test that after a persist_block(), it's possible to load a receipt body
  3. implement something like these lines in persist_block() https://github.com/ethereum/py-evm/blob/6fef9c25eff570471d147a4f4a6d4eba00262f57/eth/vm/base.py#L321-L325
  4. 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

cburgdorf avatar May 14 '20 08:05 cburgdorf