Skip to content

perf: remove unnecessary clones in payload building#392

Merged
julio4 merged 2 commits intoflashbots:mainfrom
0xl3on:0xl3on/remove-extra-allocations-during-block-building
Feb 19, 2026
Merged

perf: remove unnecessary clones in payload building#392
julio4 merged 2 commits intoflashbots:mainfrom
0xl3on:0xl3on/remove-extra-allocations-during-block-building

Conversation

@0xl3on
Copy link
Contributor

@0xl3on 0xl3on commented Feb 17, 2026

📝 Summary

Closes #391
Remove some allocations while still reducing LoC


✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

Copy link
Member

@julio4 julio4 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, looks solid! If you want to look into logs bloom feel free else we can merge it.

Comment on lines +925 to +930
let receipts_root = calculate_receipt_root_no_memo_optimism(
&info.receipts,
&ctx.chain_spec,
ctx.attributes().timestamp(),
);

let receipts_root = execution_outcome
.generic_receipts_root_slow(block_number, |receipts| {
calculate_receipt_root_no_memo_optimism(
receipts,
&ctx.chain_spec,
ctx.attributes().timestamp(),
)
})
.ok_or_else(|| {
PayloadBuilderError::Other(
eyre::eyre!(
"receipts and block number not in range, block number {}",
block_number
)
.into(),
)
})?;
let logs_bloom = execution_outcome
.block_logs_bloom(block_number)
.ok_or_else(|| {
PayloadBuilderError::Other(
eyre::eyre!(
"logs bloom and block number not in range, block number {}",
block_number
)
.into(),
)
})?;
let logs_bloom = alloy_primitives::logs_bloom(info.receipts.iter().flat_map(|r| r.logs()));
Copy link
Member

Choose a reason for hiding this comment

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

I think we could try to compute logs bloom first with &info.receipts.with_bloom_ref() / ReceiptWithBloom and use calculate_receipt_root_optimism with memoized logs blooms to not compute it twice.

Copy link
Contributor Author

@0xl3on 0xl3on Feb 18, 2026

Choose a reason for hiding this comment

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

I think we could try to compute logs bloom first with &info.receipts.with_bloom_ref() / ReceiptWithBloom and use calculate_receipt_root_optimism with memoized logs blooms to not compute it twice.

Yes, good idea

I'll open a PR there suggesting changing the visibility, because atm its pub(crate) (https://github.com/ethereum-optimism/optimism/blame/2eb7e3c074b6b77cf94956529508ec882b0b5f18/rust/op-reth/crates/consensus/src/proof.rs#L12)

So I think for now we can merge this and once its merged there I update here?

edit: saw you opened the PR already!

Copy link
Member

Choose a reason for hiding this comment

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

yeah found out the same. Sorry for the frontrun

Co-authored-by: Julio <30329843+julio4@users.noreply.github.com>
@julio4 julio4 enabled auto-merge (squash) February 19, 2026 09:11
@julio4 julio4 merged commit 1d701d2 into flashbots:main Feb 19, 2026
4 checks passed
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.

Unnecessarily using ExecutionOutcome during payload building

2 participants