-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Unifying anvil_reorg and anvil_rollback
#10267
-
Looking into how to simulate reorgs in Anvil, I found two methods:
anvil_reorg(depth, new_txs), implemented by @tsnewnami will rollbackdepthblocks, and create new ones in their place, optionally using txs provided.anvil_rollback(depth), implemented by @jorgemmsilva, will rollbackdepthblocks.
Aside from being quite similar, there is no method to reorg N blocks and add M blocks in their place (with N != M), since anvil_reorg will guarantee the block height is preserved.
Would it make sense to invest effort in unifying the two methods, and allowing to mine a customisable amount of blocks? So instead of having the following, where always depth new blocks are mined:
struct ReorgOptions {
// The depth of the reorg
pub depth: u64,
// List of transaction requests and blocks pairs to be mined into the new chain
pub tx_block_pairs: Vec<(TransactionData, u64)>,
}
Have something like:
struct ReorgOptions {
// The depth of the reorg
pub depth: u64,
// List of blocks to be mined after the reorg, with the transactions for each block
pub new_blocks: Vec<Vec<TransactionData>>,
}
Assuming there is appetite for a change like this, would it be best to implement as a new method, or to break compatibility and replace the existing anvil_reorg?
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 2 comments
-
bonus points: fix the WS api, right now the eth_subscribe for newHeads won't properly communicate reorgs, as far as I can tell
Beta Was this translation helpful? Give feedback.
All reactions
-
@jorgemmsilva that'd be great, but one step at a time. I'm waiting for green light from a maintainer before going forward!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1