feat: rollup mana limit gas validation#21219
Open
mrzeszutko wants to merge 1 commit intomerge-train/spartanfrom
Open
feat: rollup mana limit gas validation#21219mrzeszutko wants to merge 1 commit intomerge-train/spartanfrom
mrzeszutko wants to merge 1 commit intomerge-train/spartanfrom
Conversation
Contributor
|
We shouldn't go the Also, it'd be good to extend this check to DA limits as well since we're at it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Transactions whose gas limits exceed the block or checkpoint mana limit are currently silently dropped during block building, causing users'
.wait()calls to hang indefinitely. This PR adds early rejection at the gossip and RPC entry points by checkingmin(MAX_PROCESSABLE_L2_GAS, rollupManaLimit, maxBlockL2Gas).Changes
Promote
rollupManaLimittoL1RollupConstantsrollupManaLimit: numberto theL1RollupConstantstype,EmptyL1RollupConstants(defaults toInfinity), and the Zod schema& { rollupManaLimit?: number }extensions from the archiver, sequencer, and block-builder types — they now get it from the base typeEpochCache.create()andRollupContract.getRollupConstants()to fetch and includerollupManaLimitfrom L1Shared
deriveMaxBlockL2Gasutilitystdlib/src/gas/block_gas_limit.tsthat derives the per-block L2 gas limit from the checkpoint-level rollup mana limit:min(rollupManaLimit, ceil(rollupManaLimit / maxBlocksPerSlot * multiplier)), with an optional explicit limit override (capped at the rollup mana limit)DEFAULT_PER_BLOCK_ALLOCATION_MULTIPLIER = 2constant from the same modulecomputeBlockLimits) and the gossip path (createFirstStageMessageValidators), so both compute the same block gas limit from the same shared logicValidate against all three gas limits
GasLimitsValidatornow accepts{ rollupManaLimit, maxBlockL2Gas?, bindings? }and computes an effective max asmin(MAX_PROCESSABLE_L2_GAS, rollupManaLimit, maxBlockL2Gas). Rejection logs include all three individual limits for debuggability.rollupManaLimitis required — it is always available from L1. OnlymaxBlockL2Gasis optional since it depends on node configuration.GasTxValidatorforwards these options when constructing its innerGasLimitsValidatorcreateFirstStageTxValidationsForGossipedTransactions,createTxValidatorForAcceptingTxsOverRPC,createTxValidatorForTransactionsEnteringPendingTxPool) accept and pass through the new limitsPlumb limits to entry points
libp2p_service.ts): FetchesrollupManaLimitfromarchiver.getL1Constants(), computesmaxBlockL2GasviaderiveMaxBlockL2GasusingcalculateMaxBlocksPerSlotandDEFAULT_PER_BLOCK_ALLOCATION_MULTIPLIER— same derivation as the sequenceraztec-node/server.ts): FetchesrollupManaLimitfromblockSource.getL1Constants()andmaxBlockL2Gasfrom the sequencer client's already-computed block limitclient/factory.ts): FetchesrollupManaLimitfromarchiver.getL1Constants()Unit tests
Six new tests in
gas_validator.test.tscovering:rollupManaLimitmaxBlockL2GasMAX_PROCESSABLE_L2_GAS)GasTxValidatorNotes
maxBlockL2Gasfrom existing config (blockDurationMs, slot durations from L1 constants) using the same shared function as the sequencer.rollupManaLimitin theirL1RollupConstantsobjectsFixes A-68