-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
perf(primitives): avoid cloning receipts when calculating the root #8350
Conversation
@@ -104,20 +101,25 @@ pub fn calculate_receipt_root_optimism( | |||
ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false)) | |||
} | |||
|
|||
/// Calculates the receipt root for a header. | |||
pub fn calculate_receipt_root_ref(receipts: &[ReceiptWithBloomRef<'_>]) -> B256 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh, would be nice to have one method for both cases, unsure if it's possible though
87fe8d5
to
87d7357
Compare
87d7357
to
40155a1
Compare
/// NOTE: Prefer [`calculate_receipt_root_optimism`] if you have log blooms memoized. | ||
#[cfg(feature = "optimism")] | ||
pub fn calculate_receipt_root_ref_optimism( | ||
pub fn calculate_receipt_root_no_memo_optimism( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not to self to move this shortly
|
||
/// Calculates the bloom filter for the receipt and returns the [ReceiptWithBloomRef] container | ||
/// type. | ||
pub fn with_bloom_ref(&self) -> ReceiptWithBloomRef<'_> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as_bloom_ref ? maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats what the type is called, it would also make more sense to highlight that this is slow and not have Into impls
We can re-use the ref-type
ReceiptWithBloomRef
instead of cloning intoReceiptWithBloom
to calculate the logs blooms and receipt root.Drive-by: use
encode_fixed_size
to RLP encode the receipt index on the stack.Closes #8340