foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(anvil): 7368 reorg

Open Edwardjes opened this issue 7 months ago • 4 comments

closes https://github.com/foundry-rs/foundry/issues/7368

Motivation

Chain reorgs are an unavoidable part of the Ethereum PoS network, and applications should be tolerant to them. L2's also often rely on Ethereum for their finality, such as OP and the derivation pipeline. Having functionality to test reorgs is an important part of building fault-tolerant and resilient systems. What happens when your indexer reorgs? How will you relayer service handle duplicate nonces being consumed? Should the reorged relay transactions be resubmitted? Any service that has side effects from chain state needs to be tested against reorg scenarios.

Solution

  • Find the common ancestor between current chain and reorg chain
  • Revert state back to common ancestor
  • Mine new blocks to the desired len, optionally passing in a set of tx block pairs

Edwardjes avatar Jul 21 '24 22:07 Edwardjes