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

feat: reconstructing state using CommitBlockInfoV2 #51

Merged
merged 17 commits into from
Feb 6, 2024
Merged

Conversation

zeapoz
Copy link
Member

@zeapoz zeapoz commented Jan 2, 2024

  • Implements reconstruction of state using Boojum-formatted blocks

@zeapoz zeapoz requested a review from vbar January 2, 2024 14:18
@zeapoz zeapoz self-assigned this Jan 2, 2024
@zeapoz zeapoz force-pushed the feat/boojum-support branch from ab123b0 to cc6e295 Compare January 2, 2024 14:26
chore: procure l1_block_number outside commit block info

ref: introduce separate modules for v1 & v2

feat: commit block v2 parsing

chore: correct `BOOJUM_BLOCK` value
@zeapoz zeapoz force-pushed the feat/boojum-support branch from cc6e295 to 4441b38 Compare January 19, 2024 10:43
Copy link
Member Author

@zeapoz zeapoz left a comment

Choose a reason for hiding this comment

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

Looks nice! 👍

state-reconstruct-fetcher/src/l1_fetcher.rs Outdated Show resolved Hide resolved
state-reconstruct-fetcher/src/l1_fetcher.rs Outdated Show resolved Hide resolved
@@ -367,6 +381,7 @@ impl L1Fetcher {
let contracts = self.contracts.clone();
Ok(tokio::spawn({
async move {
let mut boojum_mode = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

Nice one! I like this approach more!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually had an error where parsing failed, in v1, at a point where it should have been doing v2 - I'm not sure whether this fixed the problem, but I haven't seen it again... :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh, in that case, let's keep that in mind should that be encountered sometime in the future

state-reconstruct-fetcher/src/l1_fetcher.rs Outdated Show resolved Hide resolved
// assert_eq!(previous_enumeration_index, tree.next_enumeration_index());

// Parse blocks using [`CommitBlockInfoV1`] or [`CommitBlockInfoV2`]
let mut vec = parse_commit_block_info(&new_blocks_data, boojum_mode).await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
let mut vec = parse_commit_block_info(&new_blocks_data, boojum_mode).await?;
let mut block_infos = parse_commit_block_info(&new_blocks_data, boojum_mode).await?;

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

Comment on lines +64 to +65
self.latest_l2_block_num
.saturating_sub(self.first_l2_block_num)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is fine for now, but ideally we should make sure that latest_l2_block_num is always defined before calling and thus implicitly latest_l2_block_num >= first_l2_block_num

Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK it wasn't undefined, but too low, after restart - those metrics still have room for improvement...

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, I would think that the latest_l2_block_num should be set to the same value as first_l2_block_num on start, but evidently it's not...

@@ -299,3 +298,33 @@ impl TryFrom<&abi::Token> for ExtractedToken {
})
}
}

#[cfg(test)]
mod tests {
Copy link
Member Author

Choose a reason for hiding this comment

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

Great call making some tests for this!

@@ -101,15 +101,15 @@ impl TryFrom<&abi::Token> for V1 {
for initial_calldata in initial_changes_calldata[4..].chunks(64) {
let mut t = initial_calldata.array_chunks::<32>();
let key = *t.next().ok_or_else(|| {
ParseError::InvalidCommitBlockInfo("initialStorageChanges".to_string())
ParseError::InvalidCommitBlockInfo("initialStorageChanges key".to_string())
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
ParseError::InvalidCommitBlockInfo("initialStorageChanges key".to_string())
ParseError::InvalidCommitBlockInfo("initialStorageChangesKey".to_string())

We should adhere to the pre-defined format. Ditto for the rest of the ParseErrors

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, why should the code be a single word - is that some kind of Rust convention?

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, not really. This is just what we have been doing up until this point

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well OK, just to be consistent...

@vbar vbar merged commit 5b7dc9d into main Feb 6, 2024
0 of 4 checks passed
@vbar vbar deleted the feat/boojum-support branch February 6, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants