Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWYNETH] reorg support #48

Closed
wants to merge 3 commits into from
Closed

[GWYNETH] reorg support #48

wants to merge 3 commits into from

Conversation

adaki2004
Copy link

No description provided.

if let Some(block_hash) = l2_block_hash {
self.engine_api.update_forkchoice(block_hash, block_hash).await?;
} else {
return Err(eyre::eyre!("No suitable L2 block found for revert"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to error out because simply no L2 block proposed in the reorg range?

@@ -71,6 +81,7 @@ pub struct Rollup<Node: reth_node_api::FullNodeComponents> {
ctx: ExExContext<Node>,
node: GwynethFullNode,
engine_api: EngineApiContext<GwynethEngineTypes>,
l1_l2_ring_buffer: VecDeque<L1L2Mapping>,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can also just use an array/vec of constant RING_BUFFER_SIZE size, and then index into this array as l1_block_number % RING_BUFFER_SIZE. Might be easier, don't know.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use VecDeque rather, cause it works well for ring buffers. Using pop_front() & push_back() , so the placement of blocks for caching is contagious.
With %, you need to deal with edge cases. (E.g.: you are in the "bucket" of 127, and you need to reorg. But in the last 127 blocks there were no L2 block, so then you need to go till the 128, so basically traverse backwards and found the proper L2 info. With VecDequeue you just need to go backwards till the L1_saved < L1 reorged).

@github-actions github-actions bot closed this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants