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: implement Optimism builder DA limits #13757

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

meyer9
Copy link
Contributor

@meyer9 meyer9 commented Jan 9, 2025

Addresses #13131

This PR adds:

  • a new attribute to BestTransactionsAttributes that will let us request all transactions under a certain DA size
  • transactions in the pending pool to be removed if a transaction's DA size exceeds the maximum set
  • transactions are marked invalid during block building if they cause the block to exceed the max da size

Open question: revm currently isn't updated, so I'm referencing the needed crate using a git spec. We could also just clone the function into a reth crate and remove it once we update revm if we want to avoid the git crate reference.

Comment on lines 76 to 82
/// Returns the estimated compressed size of a transaction.
pub fn da_usage(&self) -> u64 {
let mut tx_ser: Vec<u8> = Vec::new();
// TODO: check handling of deposit/blob txs - I think they're treated as 0 usage
self.transaction.legacy().unwrap().eip2718_encode(&self.signature, &mut tx_ser);

estimate_tx_compressed_size(&tx_ser)
Copy link
Member

Choose a reason for hiding this comment

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

kind of unfortunate perf wise if we need to serialize every tx, right? should this be memoized somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed - is there a standard way to memoize serialized values? I added a simple memoized property to the struct here, but there might be a better way to do it. d41de90

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can do this if we change the OpTransactionSigned type and a lazy field for this there, however this wouldn't enough for the building use case because this operates on OpPooledTx mostly, though luckily we can already provide different types for this.

I need to think about this a bit, because I had some ideas how we can improve the builder interface.
and ideally also solve the issue with repeated 2718 encoding as well.

@meyer9
Copy link
Contributor Author

meyer9 commented Jan 11, 2025

Tested end-to-end using Kurtosis and setting block limits manually. I'm planning to add automated tests soon as well, but should be ready to review!

@meyer9 meyer9 marked this pull request as ready for review January 11, 2025 00: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.

3 participants