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

perf(op-receipts): reuse l1_block_info for multiple receipts #13781

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

hai-rise
Copy link
Contributor

@hai-rise hai-rise commented Jan 13, 2025

This PR allows reusing L1BlockInfo when building OP receipts for multiple transactions (of the same block). Came across this as we built fast pre-confirmations for users 🙏.

@hai-rise hai-rise marked this pull request as draft January 13, 2025 04:26
Ok(OpReceiptBuilder::new(
&self.inner.eth_api.provider().chain_spec(),
tx,
meta,
receipt,
&receipts,
l1_block_info.clone(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main motivation as L1BlockInfo is 312 bytes and this clone can scale to 100k+ transactions/block for high-performance chains.

@hai-rise hai-rise marked this pull request as ready for review January 13, 2025 04:42
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +63 to +66
// We must clear this cache as different L2 transactions can have different
// L1 costs. A potential improvement here is to only clear the cache if the
// new transaction input has changed, since otherwise the L1 cost wouldn't.
l1_block_info.clear_tx_l1_cost();
Copy link
Collaborator

Choose a reason for hiding this comment

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

-.-
I knew that introducing this behaviour would end causing problems somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a dangerous but manageable one 🙏.

@mattsse mattsse added this pull request to the merge queue Jan 13, 2025
@mattsse mattsse added A-rpc Related to the RPC implementation A-op-reth Related to Optimism and op-reth labels Jan 13, 2025
Merged via the queue into paradigmxyz:main with commit 2352664 Jan 13, 2025
43 checks passed
@hai-rise hai-rise deleted the op-receipt branch January 13, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth A-rpc Related to the RPC implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants