Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unifying anvil_reorg and anvil_rollback #10267

spalladino started this conversation in Ideas
Discussion options

Looking into how to simulate reorgs in Anvil, I found two methods:

  • anvil_reorg(depth, new_txs), implemented by @tsnewnami will rollback depth blocks, and create new ones in their place, optionally using txs provided.
  • anvil_rollback(depth), implemented by @jorgemmsilva, will rollback depth blocks.

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?

You must be logged in to vote

Replies: 2 comments

Comment options

bonus points: fix the WS api, right now the eth_subscribe for newHeads won't properly communicate reorgs, as far as I can tell

You must be logged in to vote
0 replies
Comment options

@jorgemmsilva that'd be great, but one step at a time. I'm waiting for green light from a maintainer before going forward!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /