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

fix: also parsing calldata of commitBatchesSharedBridge #103

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

vbar
Copy link
Collaborator

@vbar vbar commented Jun 10, 2024

No description provided.

@vbar vbar requested a review from zeapoz June 10, 2024 12:50
@@ -595,18 +601,27 @@ impl L1Fetcher {

pub async fn parse_calldata(
l1_block_number: u64,
commit_blocks_fn: &Function,
commit_candidates: &Vec<Function>,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
commit_candidates: &Vec<Function>,
commit_candidates: &[Function],

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah yes, clippy already told me... :-)

return Err(ParseError::InvalidCalldata("too short".to_string()));
}

let commit_fn = commit_candidates
Copy link
Member

Choose a reason for hiding this comment

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

How about using a HashMap mapping the output of the short_signature to the
corresponding function instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMHO 1 or 2 candidates is too few for anything but an array...

Copy link
Member

Choose a reason for hiding this comment

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

I guess, but I'm not a big fan of this iterator/find stuff. I'd much rather have
the calldata[..4] be mapped directly via some lookup table

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But the lookup table will have additional allocations (e.g. HashMap has arrays for its buckets, but it has multiple buckets), and constructing a custom structure (i.e. a perfect hash, or just pre-computing the signatures into a second vector) is way too much hassle for something that is far from a demonstrated performance bottleneck...

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking this more of as a what would be the ideal should we need to expand upon this in the future, rather than what would result in the least allocations. However, for now, I'm okay with merging this as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, the obvious generalization is to get the parsing code from the incoming data, removing the boojum_mode flag - but whether that will be possible for the next expansion remains to be seen... :-)

@vbar vbar merged commit ead5d4a into main Jun 10, 2024
4 checks passed
@vbar vbar deleted the fix/commit-batches-shared-bridge branch June 10, 2024 14:00
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