eth-tester
eth-tester copied to clipboard
Tools for testing chain reorgs
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 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 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.
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.