Skip to content

feat(l2): add privileged transaction cap #3776

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

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

Conversation

iovoid
Copy link
Contributor

@iovoid iovoid commented Jul 22, 2025

Motivation

If the l2 batches include too many privileged transactions, it may happen that the gas cost of getPendingTransactionsVersionedHash(uint16 n) becomes so high it's impossible to commit batches.

Description

To prevent this, we record the privileged transaction count of the batch being built and ensure no more than a fixed amount (300 for now) is added.

We add a spammer (that makes 1800 privileged transactions) as a regression test.

Additionally, this allows enforcing intra-batch ordering of privileged transactions. This prevents the following scenario from happening:

  • A sends two deposits with gas values 1 (deposit 1) and 10M (deposit 2)
  • B then sends a deposit with gas value 1 (deposit 3)
  • The sequencer includes A's first deposit, but not the second because it's too big for the block. Deposit 3 is included because it's small.
  • The resulting inclusion order is 1, 3. This out-of-order and therefore the batch is invalid.

@iovoid iovoid requested a review from a team as a code owner July 22, 2025 18:02
@github-actions github-actions bot added the L2 Rollup client label Jul 22, 2025
@iovoid iovoid moved this to In Review in ethrex_l2 Jul 22, 2025
Copy link

github-actions bot commented Jul 22, 2025

Lines of code report

Total lines added: 144
Total lines removed: 0
Total lines changed: 144

Detailed view
+--------------------------------------------------------------+-------+------+
| File                                                         | Lines | Diff |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer.rs                 | 190   | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer/payload_builder.rs | 342   | +26  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs                   | 540   | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/api.rs                          | 108   | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store.rs                        | 306   | +9   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/in_memory.rs           | 290   | +14  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/libmdbx.rs             | 464   | +34  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/redb.rs                | 445   | +23  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/sql.rs                 | 794   | +27  |
+--------------------------------------------------------------+-------+------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

1 participant