eth-tester icon indicating copy to clipboard operation
eth-tester copied to clipboard

Tools for testing chain reorgs

Open palango opened this issue 6 years ago • 3 comments

What was wrong?

It would be nice to be able to test chain-reorg in a simple manner. I'm not sure where in the stack the fits best but something like

EthereumTester.mine_reorg(reorg_depth=1)

might work.

Main use case would be testing scenarios where state is updated from block contents and has to be updated when the chain changes.

palango avatar Mar 07 '18 15:03 palango

@palango could the snapshot/revert functionality provide you with what you need?

  • snapshot at the depth that you want the reorg to originate from
  • mine some blocks
  • revert
  • mine some different blocks

pipermerriam avatar Mar 07 '18 16:03 pipermerriam

@pipermerriam This is a good idea. The only problem I can see that the deleted flags (see ethereum/web3.py#684) of events might not be set correctly as the client doesn't know that it got reverted to an old snapshot.

palango avatar Mar 07 '18 16:03 palango

Hrm, yeah, we don't have a good mechanism for that currently but I'm very supportive of adding it as a feature. I suspect this can be added as a feature on-top of the snapshot/revert API. Maybe even adding a reorg=True flag to the revert function to signal that the invalidated log entries should not be removed, but marked as deleted.

pipermerriam avatar Mar 08 '18 20:03 pipermerriam