Skip to content

feat: implement Optimism builder DA limits#13757

Merged
mattsse merged 18 commits intoparadigmxyz:mainfrom
meyer9:meyer9/txpool-da-config
Jan 21, 2025
Merged

feat: implement Optimism builder DA limits#13757
mattsse merged 18 commits intoparadigmxyz:mainfrom
meyer9:meyer9/txpool-da-config

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
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
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.

cool, featurewise this is complete, but I'd like to exclude the compressed size caching in this pr because atm this doesn't have any effect anyway

Comment on lines +560 to +583
Copy link
Collaborator

Choose a reason for hiding this comment

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

this makes sense, we def need this here

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to exclude this from this pr, because due to how we pull in txs from the pool this currently doesn't give us any benefits. I'll tackle this perf improvement shortly, because what we need to change here is op pooled type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, I'll update to restrict the uncompressed size of the tx

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if this will be optimized by the compiler, but I think this is fine for now.

we could make this nicer by moving this into a new function of executioninfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved it to execution info and fixed the short circuiting, but lmk if you had something else in mind and I can change it

@meyer9 meyer9 force-pushed the meyer9/txpool-da-config branch from 4b04de7 to ab3f07f Compare January 13, 2025 18:15
@meyer9 meyer9 requested a review from mattsse January 13, 2025 18:15
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, only one q re da size tracking

Comment on lines +563 to +571
if tx_data_limit.is_some_and(|da_limit| tx.length() as u64 > da_limit) {
return true;
}

if block_data_limit
.is_some_and(|da_limit| self.cumulative_da_bytes_used + (tx.length() as u64) > da_limit)
{
return true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this now uses the length instead of the flz compressed length

should we change this here? or is this fine for this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah sorry, I may have misunderstood. I think it's OK to use uncompressed size temporarily until we implement DA cost tracking. I thought the comment above meant to remove the compressed size calculation for now, but I could add it back in without modifying the pooled tx type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote an example implementation of this here, but I'm a little concerned about changing revm versions to a Git hash: dbe1610

If this looks OK, I can add it to this PR, but if this isn't urgent, we can just implement after the issue you created.

Copy link
Collaborator

Choose a reason for hiding this comment

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

meh that's unfortunate that this wasn't included in the latest revm release...

bluealloy/revm#1985

@mattsse mattsse added this to the Release 1.2.0 milestone Jan 20, 2025
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.

I'm merging this now, and start working on some changes so that we get access to #13806

@mattsse mattsse added this pull request to the merge queue Jan 21, 2025
Merged via the queue into paradigmxyz:main with commit 6dabd52 Jan 21, 2025
43 checks passed
refcell pushed a commit to ethereum-optimism/op-reth that referenced this pull request Jan 24, 2025
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 22, 2026
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants