foundry
foundry copied to clipboard
feat(`anvil`): support for multi-block depth reorgs in Anvil
Component
Anvil
Describe the feature you would like
Add support for simulating reorgs of multiple block depths (n ≥ 1) in Anvil, enabling developers to thoroughly test smart contracts and infrastructure against reorg scenarios.
Example of a 3-block deep reorg:
Before reorg:
Block 100 <- Block 101 <- Block 102 <- Block 103 <- Block 104
After reorg:
┌─ Block 102 <- Block 103 <- Block 104 (Uncles)
|
Block 100 <- Block 101 <- Block 102' <- Block 103' <- Block 104' (New canonical chain)
Additional discussion and insights are sought from @mattsse on how best to implement this feature, including:
- How to specify the depth of the reorg
- What transactions should be included in the new canonical chain
- How to handle transaction filters for each block in the reorg
Additional context
Reorgs can cause critical infrastructure to break if not handled correctly. Implementing a testing framework for multi-block depth reorgs in Anvil would help mitigate these risks and promote best practices in reorg testing. This issue is inspired from issue 1799.