@aztec/stdlib 5.0.0-nightly.20260611 → 5.0.0-nightly.20260613

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dest/block/l2_block_source.d.ts +7 -1
  2. package/dest/block/l2_block_source.d.ts.map +1 -1
  3. package/dest/block/l2_block_stream/interfaces.d.ts +44 -8
  4. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  5. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  6. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  7. package/dest/block/l2_block_stream/l2_block_stream.js +13 -4
  8. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +6 -12
  9. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  10. package/dest/block/l2_block_stream/l2_tips_memory_store.js +8 -32
  11. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +9 -18
  12. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  13. package/dest/block/l2_block_stream/l2_tips_store_base.js +52 -58
  14. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  15. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  16. package/dest/block/test/l2_tips_store_test_suite.js +202 -34
  17. package/dest/config/index.d.ts +2 -1
  18. package/dest/config/index.d.ts.map +1 -1
  19. package/dest/config/index.js +1 -0
  20. package/dest/config/network-consensus-config.d.ts +72 -0
  21. package/dest/config/network-consensus-config.d.ts.map +1 -0
  22. package/dest/config/network-consensus-config.js +231 -0
  23. package/dest/config/sequencer-config.d.ts +3 -1
  24. package/dest/config/sequencer-config.d.ts.map +1 -1
  25. package/dest/config/sequencer-config.js +5 -4
  26. package/dest/contract/interfaces/node-info.d.ts +11 -1
  27. package/dest/contract/interfaces/node-info.d.ts.map +1 -1
  28. package/dest/contract/interfaces/node-info.js +7 -1
  29. package/dest/gas/gas_settings.d.ts +7 -13
  30. package/dest/gas/gas_settings.d.ts.map +1 -1
  31. package/dest/gas/gas_settings.js +9 -16
  32. package/dest/gas/index.d.ts +2 -1
  33. package/dest/gas/index.d.ts.map +1 -1
  34. package/dest/gas/index.js +1 -0
  35. package/dest/gas/tx_gas_limits.d.ts +72 -0
  36. package/dest/gas/tx_gas_limits.d.ts.map +1 -0
  37. package/dest/gas/tx_gas_limits.js +85 -0
  38. package/dest/interfaces/aztec-node-admin.d.ts +18 -17
  39. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  40. package/dest/interfaces/aztec-node-admin.js +1 -1
  41. package/dest/interfaces/aztec-node-debug.d.ts +15 -2
  42. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
  43. package/dest/interfaces/aztec-node-debug.js +9 -1
  44. package/dest/interfaces/aztec-node.d.ts +40 -11
  45. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  46. package/dest/interfaces/aztec-node.js +42 -5
  47. package/dest/interfaces/block-builder.d.ts +3 -1
  48. package/dest/interfaces/block-builder.d.ts.map +1 -1
  49. package/dest/interfaces/client.d.ts +2 -1
  50. package/dest/interfaces/client.d.ts.map +1 -1
  51. package/dest/interfaces/configs.d.ts +12 -6
  52. package/dest/interfaces/configs.d.ts.map +1 -1
  53. package/dest/interfaces/configs.js +2 -1
  54. package/dest/interfaces/get_tx_by_hash_options.d.ts +9 -0
  55. package/dest/interfaces/get_tx_by_hash_options.d.ts.map +1 -0
  56. package/dest/interfaces/get_tx_by_hash_options.js +4 -0
  57. package/dest/interfaces/p2p.d.ts +32 -8
  58. package/dest/interfaces/p2p.d.ts.map +1 -1
  59. package/dest/interfaces/p2p.js +12 -2
  60. package/dest/interfaces/proving-job.d.ts +70 -70
  61. package/dest/interfaces/validator.d.ts +3 -3
  62. package/dest/interfaces/validator.d.ts.map +1 -1
  63. package/dest/interfaces/validator.js +1 -1
  64. package/dest/tests/factories.d.ts +1 -1
  65. package/dest/tests/factories.d.ts.map +1 -1
  66. package/dest/tests/factories.js +4 -1
  67. package/dest/tests/mocks.d.ts +1 -1
  68. package/dest/tests/mocks.d.ts.map +1 -1
  69. package/dest/tests/mocks.js +3 -2
  70. package/dest/timetable/budgets.d.ts +4 -2
  71. package/dest/timetable/budgets.d.ts.map +1 -1
  72. package/dest/timetable/budgets.js +2 -1
  73. package/dest/timetable/build_proposer_timetable.d.ts +21 -0
  74. package/dest/timetable/build_proposer_timetable.d.ts.map +1 -0
  75. package/dest/timetable/build_proposer_timetable.js +17 -0
  76. package/dest/timetable/consensus_timetable.d.ts +5 -7
  77. package/dest/timetable/consensus_timetable.d.ts.map +1 -1
  78. package/dest/timetable/consensus_timetable.js +6 -8
  79. package/dest/timetable/index.d.ts +2 -1
  80. package/dest/timetable/index.d.ts.map +1 -1
  81. package/dest/timetable/index.js +1 -0
  82. package/dest/timetable/proposer_timetable.d.ts +18 -24
  83. package/dest/timetable/proposer_timetable.d.ts.map +1 -1
  84. package/dest/timetable/proposer_timetable.js +26 -55
  85. package/dest/tx/fee_provider.d.ts +2 -2
  86. package/dest/tx/fee_provider.d.ts.map +1 -1
  87. package/dest/tx/validator/error_texts.d.ts +2 -2
  88. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  89. package/dest/tx/validator/error_texts.js +1 -1
  90. package/package.json +8 -8
  91. package/src/block/l2_block_source.ts +7 -0
  92. package/src/block/l2_block_stream/interfaces.ts +39 -7
  93. package/src/block/l2_block_stream/l2_block_stream.ts +21 -3
  94. package/src/block/l2_block_stream/l2_tips_memory_store.ts +12 -41
  95. package/src/block/l2_block_stream/l2_tips_store_base.ts +63 -93
  96. package/src/block/test/l2_tips_store_test_suite.ts +197 -24
  97. package/src/config/index.ts +1 -0
  98. package/src/config/network-consensus-config.ts +302 -0
  99. package/src/config/sequencer-config.ts +7 -5
  100. package/src/contract/interfaces/node-info.ts +11 -0
  101. package/src/gas/README.md +92 -0
  102. package/src/gas/gas_settings.ts +11 -21
  103. package/src/gas/index.ts +1 -0
  104. package/src/gas/tx_gas_limits.ts +123 -0
  105. package/src/interfaces/aztec-node-admin.ts +1 -1
  106. package/src/interfaces/aztec-node-debug.ts +17 -2
  107. package/src/interfaces/aztec-node.ts +74 -13
  108. package/src/interfaces/block-builder.ts +2 -0
  109. package/src/interfaces/client.ts +1 -0
  110. package/src/interfaces/configs.ts +10 -6
  111. package/src/interfaces/get_tx_by_hash_options.ts +14 -0
  112. package/src/interfaces/p2p.ts +21 -8
  113. package/src/interfaces/validator.ts +5 -5
  114. package/src/tests/factories.ts +7 -1
  115. package/src/tests/mocks.ts +7 -2
  116. package/src/timetable/README.md +10 -2
  117. package/src/timetable/budgets.ts +5 -2
  118. package/src/timetable/build_proposer_timetable.ts +42 -0
  119. package/src/timetable/consensus_timetable.ts +8 -14
  120. package/src/timetable/index.ts +1 -0
  121. package/src/timetable/proposer_timetable.ts +37 -61
  122. package/src/tx/fee_provider.ts +1 -1
  123. package/src/tx/validator/error_texts.ts +2 -1
@@ -0,0 +1,302 @@
1
+ import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
2
+ import { type EnvVar, pickConfigMappings } from '@aztec/foundation/config';
3
+
4
+ import type { SequencerConfig } from '../interfaces/configs.js';
5
+ import {
6
+ DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME,
7
+ DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME,
8
+ DEFAULT_MIN_BLOCK_DURATION,
9
+ DEFAULT_P2P_PROPAGATION_TIME,
10
+ } from '../timetable/budgets.js';
11
+ import { ProposerTimetable } from '../timetable/proposer_timetable.js';
12
+ import { sharedSequencerConfigMappings } from './sequencer-config.js';
13
+
14
+ /**
15
+ * Environment variables whose values must be identical across every node of a network. They fall into three
16
+ * categories, all consensus-critical:
17
+ *
18
+ * - Timing/protocol consensus: slot and epoch durations, block sub-slot duration, max blocks per checkpoint, and
19
+ * the checkpoint-proposal materialization grace. Proposers and validators must agree on these to land on the
20
+ * same proposed chain and the same checkpoint-proposal receive/handoff deadlines.
21
+ * - Network identity and L1-posted deployment params: the L1 chain id and the staking/governance/slashing
22
+ * parameters baked into the deployed rollup contract (committee size, lags, thresholds, mana target, fee
23
+ * pricing, governance/slashing round sizes, quorums, slash amounts, etc.). A node disagreeing with the rollup
24
+ * it points at would compute the wrong epoch geometry, fees, or slashing rounds.
25
+ * - Node-side slashing offense consensus: the offense detection/penalty parameters validators apply locally to
26
+ * decide which payloads to sign. Validators must agree on these to reach the on-chain slashing quorum.
27
+ *
28
+ * Deliberately excluded: bootnodes, P2P/store/OTEL/sentinel settings, SEQ_MIN_TX_PER_BLOCK, SEQ_MAX_TX_PER_*,
29
+ * AZTEC_SLASHER_ENABLED, PROVER_REAL_PROOFS, TRANSACTIONS_DISABLED, and AZTEC_ENTRY_QUEUE_* (mainnet-only genesis
30
+ * params enforced by L1).
31
+ */
32
+ export const NETWORK_CONSENSUS_ENV_VARS = [
33
+ // Timing/protocol consensus.
34
+ 'ETHEREUM_SLOT_DURATION',
35
+ 'AZTEC_SLOT_DURATION',
36
+ 'AZTEC_EPOCH_DURATION',
37
+ 'SEQ_BLOCK_DURATION_MS',
38
+ 'MAX_BLOCKS_PER_CHECKPOINT',
39
+ 'CHECKPOINT_PROPOSAL_SYNC_GRACE_SECONDS',
40
+
41
+ // Network identity / L1-posted deployment params.
42
+ 'L1_CHAIN_ID',
43
+ 'AZTEC_TARGET_COMMITTEE_SIZE',
44
+ 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
45
+ 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
46
+ 'AZTEC_ACTIVATION_THRESHOLD',
47
+ 'AZTEC_EJECTION_THRESHOLD',
48
+ 'AZTEC_LOCAL_EJECTION_THRESHOLD',
49
+ 'AZTEC_EXIT_DELAY_SECONDS',
50
+ 'AZTEC_INBOX_LAG',
51
+ 'AZTEC_PROOF_SUBMISSION_EPOCHS',
52
+ 'AZTEC_MANA_TARGET',
53
+ 'AZTEC_PROVING_COST_PER_MANA',
54
+ 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
55
+ 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
56
+ 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
57
+ 'AZTEC_SLASHING_QUORUM',
58
+ 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
59
+ 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
60
+ 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
61
+ 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
62
+ 'AZTEC_SLASHING_VETOER',
63
+ 'AZTEC_SLASHING_DISABLE_DURATION',
64
+ 'AZTEC_SLASH_AMOUNT_SMALL',
65
+ 'AZTEC_SLASH_AMOUNT_MEDIUM',
66
+ 'AZTEC_SLASH_AMOUNT_LARGE',
67
+
68
+ // Node-side slashing offense consensus.
69
+ 'SLASH_OFFENSE_EXPIRATION_ROUNDS',
70
+ 'SLASH_MAX_PAYLOAD_SIZE',
71
+ 'SLASH_EXECUTE_ROUNDS_LOOK_BACK',
72
+ 'SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS',
73
+ 'SLASH_DATA_WITHHOLDING_PENALTY',
74
+ 'SLASH_INACTIVITY_TARGET_PERCENTAGE',
75
+ 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD',
76
+ 'SLASH_INACTIVITY_PENALTY',
77
+ 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY',
78
+ 'SLASH_DUPLICATE_PROPOSAL_PENALTY',
79
+ 'SLASH_DUPLICATE_ATTESTATION_PENALTY',
80
+ 'SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY',
81
+ 'SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
82
+ 'SLASH_UNKNOWN_PENALTY',
83
+ 'SLASH_INVALID_BLOCK_PENALTY',
84
+ 'SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
85
+ 'SLASH_GRACE_PERIOD_L2_SLOTS',
86
+ ] as const satisfies readonly EnvVar[];
87
+
88
+ /** A consensus-critical environment variable name; see {@link NETWORK_CONSENSUS_ENV_VARS}. */
89
+ export type ConsensusEnvVar = (typeof NETWORK_CONSENSUS_ENV_VARS)[number];
90
+
91
+ /**
92
+ * The subset of consensus-critical timing config whose geometry can be validated in isolation. Composed by
93
+ * picking the canonical fields from their owning config types so the field set never drifts from the config
94
+ * layer: slot durations from {@link L1ContractsConfig}, block sub-slot/checkpoint timings from
95
+ * {@link SequencerConfig} (whose fields are optional there, hence `Required`).
96
+ */
97
+ export type NetworkConsensusConfig = Pick<L1ContractsConfig, 'aztecSlotDuration' | 'ethereumSlotDuration'> &
98
+ Required<Pick<SequencerConfig, 'blockDurationMs' | 'maxBlocksPerCheckpoint' | 'checkpointProposalSyncGraceSeconds'>>;
99
+
100
+ /** Config mappings for the slot-timing fields of {@link NetworkConsensusConfig}, picked from their owners. */
101
+ const networkConsensusConfigMappings = {
102
+ ...pickConfigMappings(l1ContractsConfigMappings, ['aztecSlotDuration', 'ethereumSlotDuration']),
103
+ ...pickConfigMappings(sharedSequencerConfigMappings, [
104
+ 'blockDurationMs',
105
+ 'maxBlocksPerCheckpoint',
106
+ 'checkpointProposalSyncGraceSeconds',
107
+ ]),
108
+ };
109
+
110
+ /**
111
+ * Extracts the timing {@link NetworkConsensusConfig} from a generated network config object. The env-var names
112
+ * and the per-field parsing both come from the canonical config mappings (`l1ContractsConfigMappings` and
113
+ * `sharedSequencerConfigMappings`), so each field is parsed exactly as the node's config layer would parse it.
114
+ * A field whose env var is absent becomes `NaN`, which {@link validateNetworkConsensusConfig} reports as an
115
+ * error. Never throws: parse helpers that would throw or yield `undefined` are coerced to `NaN`.
116
+ */
117
+ export function getConsensusConfigFromNetworkEnv(
118
+ values: Record<string, string | number | boolean>,
119
+ ): NetworkConsensusConfig {
120
+ const result = {} as Record<keyof NetworkConsensusConfig, number>;
121
+ for (const [field, mapping] of Object.entries(networkConsensusConfigMappings)) {
122
+ const raw = mapping.env !== undefined ? values[mapping.env] : undefined;
123
+ if (raw === undefined) {
124
+ result[field as keyof NetworkConsensusConfig] = NaN;
125
+ continue;
126
+ }
127
+ let parsed: number | undefined;
128
+ try {
129
+ parsed = mapping.parseEnv ? mapping.parseEnv(String(raw)) : Number(raw);
130
+ } catch {
131
+ parsed = NaN;
132
+ }
133
+ result[field as keyof NetworkConsensusConfig] = parsed ?? NaN;
134
+ }
135
+ return result;
136
+ }
137
+
138
+ /**
139
+ * Validates a {@link NetworkConsensusConfig} for self-consistency, returning a list of error messages (empty
140
+ * when valid). Used by the cli unit test that gates the generated network configs.
141
+ *
142
+ * The check requires `maxBlocksPerCheckpoint` to be *exactly* what a {@link ProposerTimetable} built from the
143
+ * same slot timings and the production default budgets derives. This exact-equality requirement ensures the
144
+ * published network value is precisely what the production default budgets produce, so every node running those
145
+ * defaults agrees on the per-checkpoint block count without clamping.
146
+ */
147
+ export function validateNetworkConsensusConfig(config: NetworkConsensusConfig): string[] {
148
+ const errors: string[] = [];
149
+
150
+ for (const [field, value] of Object.entries(config)) {
151
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
152
+ errors.push(`${field} must be a finite number (got ${value})`);
153
+ }
154
+ }
155
+ if (errors.length > 0) {
156
+ return errors;
157
+ }
158
+
159
+ if (config.ethereumSlotDuration <= 0) {
160
+ errors.push(`ethereumSlotDuration must be positive (got ${config.ethereumSlotDuration})`);
161
+ }
162
+ if (config.blockDurationMs <= 0) {
163
+ errors.push(`blockDurationMs must be positive (got ${config.blockDurationMs})`);
164
+ }
165
+ if (config.aztecSlotDuration <= 0) {
166
+ errors.push(`aztecSlotDuration must be positive (got ${config.aztecSlotDuration})`);
167
+ }
168
+ if (config.ethereumSlotDuration > 0 && config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
169
+ errors.push(
170
+ `aztecSlotDuration (${config.aztecSlotDuration}s) must be a multiple of ethereumSlotDuration ` +
171
+ `(${config.ethereumSlotDuration}s)`,
172
+ );
173
+ }
174
+ if (config.blockDurationMs / 1000 > config.aztecSlotDuration) {
175
+ errors.push(
176
+ `blockDurationMs (${config.blockDurationMs}ms) exceeds aztecSlotDuration (${config.aztecSlotDuration}s)`,
177
+ );
178
+ }
179
+ if (config.maxBlocksPerCheckpoint < 1) {
180
+ errors.push(`maxBlocksPerCheckpoint must be at least 1 (got ${config.maxBlocksPerCheckpoint})`);
181
+ }
182
+ if (config.checkpointProposalSyncGraceSeconds < 0) {
183
+ errors.push(
184
+ `checkpointProposalSyncGraceSeconds must be non-negative (got ${config.checkpointProposalSyncGraceSeconds})`,
185
+ );
186
+ }
187
+ if (errors.length > 0) {
188
+ return errors;
189
+ }
190
+
191
+ let computed: number;
192
+ try {
193
+ computed = new ProposerTimetable({
194
+ l1Constants: {
195
+ l1GenesisTime: 0n,
196
+ slotDuration: config.aztecSlotDuration,
197
+ ethereumSlotDuration: config.ethereumSlotDuration,
198
+ },
199
+ blockDuration: config.blockDurationMs / 1000,
200
+ minBlockDuration: DEFAULT_MIN_BLOCK_DURATION,
201
+ p2pPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
202
+ checkpointProposalPrepareTime: DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME,
203
+ checkpointProposalInitTime: DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME,
204
+ checkpointProposalSyncGrace: config.checkpointProposalSyncGraceSeconds,
205
+ }).getMaxBlocksPerCheckpoint();
206
+ } catch (err) {
207
+ // The timetable constructor throws when not even one block fits the default budgets; report instead.
208
+ errors.push(
209
+ `maxBlocksPerCheckpoint (${config.maxBlocksPerCheckpoint}) cannot be achieved: the default operational ` +
210
+ `budgets fit fewer than one block for slot duration ${config.aztecSlotDuration}s and block duration ` +
211
+ `${config.blockDurationMs / 1000}s (${err instanceof Error ? err.message : String(err)})`,
212
+ );
213
+ return errors;
214
+ }
215
+
216
+ if (computed !== config.maxBlocksPerCheckpoint) {
217
+ errors.push(
218
+ `maxBlocksPerCheckpoint (${config.maxBlocksPerCheckpoint}) does not match the ${computed} blocks the ` +
219
+ `production default budgets derive for slot duration ${config.aztecSlotDuration}s and block duration ` +
220
+ `${config.blockDurationMs / 1000}s`,
221
+ );
222
+ }
223
+
224
+ return errors;
225
+ }
226
+
227
+ /**
228
+ * Enforces that operators do not silently override consensus-critical values diverging from the network config.
229
+ *
230
+ * For each var in {@link NETWORK_CONSENSUS_ENV_VARS} present in `networkConfig`: if the operator set it in `env`
231
+ * to a conflicting value, this throws unless `ALLOW_OVERRIDING_NETWORK_CONFIG` is truthy (in which case it logs
232
+ * and keeps the operator value).
233
+ *
234
+ * This function is pure: it never writes to `env`. Instead it returns the canonical env writes the caller
235
+ * should apply — a map of env-var name to canonical string value for every numeric var whose env value matched
236
+ * the network value numerically. Applying these closes a bypass where the config layer parses some vars with
237
+ * `parseInt` (which reads '6e3' as 6); rewriting them to the network value's string form keeps the operator's
238
+ * numerically-equal value but in canonical form. Vars kept under `ALLOW_OVERRIDING_NETWORK_CONFIG` (genuine
239
+ * conflicts) are not included, so the operator value is preserved untouched.
240
+ *
241
+ * @returns Canonical env writes (env-var name -> canonical string value) for the caller to apply.
242
+ */
243
+ export function checkConsensusEnvOverrides(
244
+ networkConfig: Record<string, string | number | boolean>,
245
+ env: { [key: string]: string | undefined } = process.env,
246
+ log?: (msg: string) => void,
247
+ ): Record<string, string> {
248
+ const allowOverride = allowsNetworkConfigOverride(env);
249
+ const canonical: Record<string, string> = {};
250
+ const conflicts: string[] = [];
251
+
252
+ for (const envVar of NETWORK_CONSENSUS_ENV_VARS) {
253
+ const networkValue = networkConfig[envVar];
254
+ if (networkValue === undefined) {
255
+ continue;
256
+ }
257
+
258
+ const current = env[envVar];
259
+ if (current === undefined || current === '') {
260
+ continue;
261
+ }
262
+
263
+ const networkIsNumeric = typeof networkValue === 'number';
264
+ const matches = networkIsNumeric ? Number(current) === networkValue : current === String(networkValue);
265
+ if (matches) {
266
+ if (networkIsNumeric) {
267
+ canonical[envVar] = String(networkValue);
268
+ }
269
+ continue;
270
+ }
271
+
272
+ const conflict = `${envVar}=${current} conflicts with the network value ${networkValue}`;
273
+ if (allowOverride) {
274
+ log?.(
275
+ `Environment variable ${conflict}. Consensus-critical values must match across the network, but ` +
276
+ `ALLOW_OVERRIDING_NETWORK_CONFIG is set so the operator value is kept (only do this if you know what ` +
277
+ `you are doing).`,
278
+ );
279
+ continue;
280
+ }
281
+ conflicts.push(conflict);
282
+ }
283
+
284
+ // Accumulate every conflict so the operator sees all the env vars they need to reconcile at once, rather than
285
+ // fixing them one failed startup at a time.
286
+ if (conflicts.length > 0) {
287
+ throw new Error(
288
+ `Environment variables conflict with consensus-critical network values:\n` +
289
+ conflicts.map(c => ` - ${c}`).join('\n') +
290
+ `\nConsensus-critical values must match across the network. Set ALLOW_OVERRIDING_NETWORK_CONFIG=1 to ` +
291
+ `override (only do this if you know what you are doing).`,
292
+ );
293
+ }
294
+
295
+ return canonical;
296
+ }
297
+
298
+ /** Whether the env opts into overriding network-wide consensus values (`ALLOW_OVERRIDING_NETWORK_CONFIG`). */
299
+ export function allowsNetworkConfigOverride(env: { [key: string]: string | undefined } = process.env): boolean {
300
+ const value = env.ALLOW_OVERRIDING_NETWORK_CONFIG;
301
+ return value === '1' || value?.toLowerCase() === 'true';
302
+ }
@@ -7,12 +7,16 @@ import {
7
7
 
8
8
  import type { SequencerConfig } from '../interfaces/configs.js';
9
9
  import {
10
+ DEFAULT_BLOCK_DURATION,
10
11
  DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME,
11
12
  DEFAULT_MIN_BLOCK_DURATION,
12
13
  DEFAULT_P2P_PROPAGATION_TIME,
13
14
  getDefaultCheckpointProposalSyncGrace,
14
15
  } from '../timetable/index.js';
15
16
 
17
+ /** Default duration per block in milliseconds, used to derive how many blocks fit in a slot. */
18
+ export const DEFAULT_BLOCK_DURATION_MS = DEFAULT_BLOCK_DURATION * 1000;
19
+
16
20
  /** Default maximum number of transactions per block. */
17
21
  export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
18
22
 
@@ -40,10 +44,8 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
40
44
  > = {
41
45
  blockDurationMs: {
42
46
  env: 'SEQ_BLOCK_DURATION_MS',
43
- description:
44
- 'Duration per block in milliseconds when building multiple blocks per slot. ' +
45
- 'If undefined (default), builds a single block per slot using the full slot duration.',
46
- ...optionalNumberConfigHelper(),
47
+ description: 'Duration per block in milliseconds, used to derive how many blocks fit in a slot.',
48
+ ...numberConfigHelper(DEFAULT_BLOCK_DURATION_MS),
47
49
  },
48
50
  expectedBlockProposalsPerSlot: {
49
51
  env: 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT',
@@ -57,7 +59,7 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
57
59
  description:
58
60
  'Consensus grace in seconds for a received checkpoint proposal to materialize into local proposed state. ' +
59
61
  'Defaults to twice the block duration.',
60
- defaultValue: getDefaultCheckpointProposalSyncGrace(undefined),
62
+ defaultValue: getDefaultCheckpointProposalSyncGrace(DEFAULT_BLOCK_DURATION_MS / 1000),
61
63
  ...optionalNumberConfigHelper(),
62
64
  },
63
65
  maxTxsPerBlock: {
@@ -5,6 +5,12 @@ import { z } from 'zod';
5
5
 
6
6
  import { type ProtocolContractAddresses, ProtocolContractAddressesSchema } from './protocol_contract_addresses.js';
7
7
 
8
+ /** Limits a single transaction may declare on a network. */
9
+ export interface TxsLimits {
10
+ /** Maximum gas limits a single tx may declare: the smaller of the per-tx maximum and the per-block allocation. */
11
+ gas: { daGas: number; l2Gas: number };
12
+ }
13
+
8
14
  /** Provides basic information about the running node. */
9
15
  export interface NodeInfo {
10
16
  /** Version as tracked in the aztec-packages repository. */
@@ -21,6 +27,8 @@ export interface NodeInfo {
21
27
  protocolContractAddresses: ProtocolContractAddresses;
22
28
  /** Whether the node requires real proofs for transaction submission. */
23
29
  realProofs: boolean;
30
+ /** Limits a single tx may declare on this network. Clients rely on this to set fallback gas limits. */
31
+ txsLimits: TxsLimits;
24
32
  }
25
33
 
26
34
  export const NodeInfoSchema: ZodFor<NodeInfo> = z
@@ -32,5 +40,8 @@ export const NodeInfoSchema: ZodFor<NodeInfo> = z
32
40
  l1ContractAddresses: L1ContractAddressesSchema,
33
41
  protocolContractAddresses: ProtocolContractAddressesSchema,
34
42
  realProofs: z.boolean(),
43
+ txsLimits: z.object({
44
+ gas: z.object({ daGas: z.number().int().nonnegative(), l2Gas: z.number().int().nonnegative() }),
45
+ }),
35
46
  })
36
47
  .transform(obj => ({ enr: undefined, ...obj }));
package/src/gas/README.md CHANGED
@@ -146,6 +146,98 @@ newPrice = currentPrice * (10000 + modifierBps) / 10000
146
146
  | `LAG` | 2 slots |
147
147
  | `LIFETIME` | 5 slots |
148
148
 
149
+ ## Gas and Data Limits
150
+
151
+ The fee model above is *how much you pay* per unit of gas; this section is *how much you may use*. Limits
152
+ form a hierarchy from a single transaction up to a whole checkpoint, and a tx that is admissible for relay
153
+ must also be buildable into a block and fit a valid checkpoint.
154
+
155
+ ### Per-tx protocol maxima
156
+
157
+ Hard ceilings on what any single tx may declare, independent of network configuration. Declaring more is
158
+ rejected everywhere a tx is validated.
159
+
160
+ - **`MAX_TX_DA_GAS`** (271,200) — `MAX_TX_BLOB_DATA_SIZE_IN_FIELDS` (8,475) × `DA_GAS_PER_FIELD` (32). This
161
+ is the most DA a single tx's effects can encode into a blob, so it is the most DA gas a tx could ever use.
162
+ Defined in `constants/src/constants.ts`.
163
+ - **`MAX_PROCESSABLE_L2_GAS`** (6,540,000) — the AVM's maximum processable L2 gas, derived in Noir as
164
+ `PUBLIC_TX_L2_GAS_OVERHEAD + AVM_MAX_PROCESSABLE_L2_GAS` (`constants/src/constants.gen.ts`).
165
+
166
+ ### Network admission limits
167
+
168
+ The most a single tx may *declare* and still be relayed across the network. Computed by
169
+ `computeNetworkTxGasLimits` in `tx_gas_limits.ts` per dimension as:
170
+
171
+ ```
172
+ min(per-tx max, ceil(checkpointBudget / blocksPerCheckpoint * minMultiplier))
173
+ ```
174
+
175
+ The per-block share mirrors what a proposer grants the first block of a checkpoint
176
+ (`CheckpointBuilder.capLimitsByCheckpointBudgets`), so a tx declaring this much is packable into a block.
177
+ The network-minimum multipliers are `MIN_PER_BLOCK_ALLOCATION_MULTIPLIER` (1.2, L2 and tx count) and
178
+ `MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER` (1.5, DA). DA's is higher so a maximal contract class
179
+ registration (~97k DA gas) fits a single block at mainnet geometry (72s slots, 6s blocks → 10 blocks per
180
+ checkpoint).
181
+
182
+ The DA budget is `getDaCheckpointBudgetForTxs(maxBlocksPerCheckpoint)`, not the raw
183
+ `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT` (786,432). Blob encoding spends overhead fields that no tx pays DA
184
+ gas for — one checkpoint-end marker field and the per-block block-end fields (7 for the first block, 6 for
185
+ each subsequent block, `blob-lib/src/encoding/block_blob_data.ts`) — so the raw constant is unattainable. The
186
+ getter nets out the full overhead for a checkpoint of `maxBlocksPerCheckpoint` blocks: at mainnet geometry
187
+ (10 blocks) that is `(24,576 − 1 − 7 − 9×6) × 32 = 24,514 × 32 = 784,448` DA gas. Subtracting every block's
188
+ overhead (not just the first) keeps admission at or below the builder's first-block blob-field cap at every
189
+ geometry — the builder is the most generous for the first block (it only reserves that block's own block-end
190
+ overhead), so being conservative here is what guarantees admitted ⇒ buildable. Without this netting a tx
191
+ near the raw limit would be admitted but never buildable.
192
+
193
+ These limits depend on network-wide inputs only (timetable-derived blocks-per-checkpoint, checkpoint
194
+ budgets, the network-minimum multipliers), never on a node's local restrictiveness. Every node always
195
+ advertises them in `NodeInfo.txsLimits` (a required field); wallets read it and pass `txsLimits.gas` to
196
+ `GasSettings.fallback` as the default gas limits when sending without explicit limits, and they are enforced
197
+ by `GasLimitsValidator` (clamped to the per-tx protocol maxima) at three points: RPC tx acceptance
198
+ (`aztec-node/src/aztec-node/server.ts`), gossip validation (`p2p/src/services/libp2p/libp2p_service.ts`),
199
+ and pending-pool admission (`p2p/src/client/factory.ts`). They are deliberately *not* enforced at reqresp or
200
+ block-proposal validation — admission is relay policy, not block validity.
201
+
202
+ ### Per-block builder budgets
203
+
204
+ While packing a checkpoint, `CheckpointBuilder.capLimitsByCheckpointBudgets`
205
+ (`validator-client/src/checkpoint_builder.ts`) computes each block's budget as a fair share of the remaining
206
+ checkpoint budget across the remaining blocks, scaled by the configured multipliers. Operators may raise the
207
+ multipliers above the network minimums but not lower them — the sequencer fails startup otherwise
208
+ (`assertConfigMeetsNetworkTxLimits` in `sequencer-client/src/sequencer/sequencer.ts`), since a node that
209
+ allocates less than it admits would accept txs over RPC/gossip that its builder can never pack.
210
+
211
+ The fair share is then min'ed with the operator's absolute per-block caps `maxL2BlockGas` / `maxDABlockGas`
212
+ and the blob-field cap (checkpoint capacity net of the checkpoint-end marker and this block's block-end
213
+ overhead). The absolute caps are allowed to be restrictive: a cap below the network admission limit only
214
+ produces a startup warning, not a failure, because such txs simply stay in the pool for other proposers to
215
+ include.
216
+
217
+ ### Per-checkpoint budgets
218
+
219
+ The outermost limits, enforced as proposal validity in `validateCheckpointLimits`
220
+ (`stdlib/src/checkpoint/validate.ts`) and physically by blob encoding:
221
+
222
+ - **Mana** — total L2 gas across all blocks ≤ `rollupManaLimit` (= `manaTarget × 2` on L1,
223
+ `l1-contracts/src/core/libraries/rollup/FeeLib.sol`).
224
+ - **DA gas** — total DA gas ≤ raw `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT` (786,432).
225
+ - **Blob fields** — total ≤ `BLOBS_PER_CHECKPOINT × FIELDS_PER_BLOB` (6 × 4,096 = 24,576).
226
+ - **Tx counts** — total txs ≤ `maxTxsPerCheckpoint` when configured.
227
+
228
+ ### Summary
229
+
230
+ | Limit | Value (mainnet defaults) | Scope | Where enforced |
231
+ | --------------------------------------- | ------------------------------- | ------------- | ----------------------------------------------------------- |
232
+ | `MAX_TX_DA_GAS` | 271,200 | per-tx | every gas validator (hard ceiling) |
233
+ | `MAX_PROCESSABLE_L2_GAS` | 6,540,000 | per-tx | every gas validator (hard ceiling) |
234
+ | Network DA admission limit | min(271,200, ceil(784,448/10×1.5)) = 117,668 | per-tx (relay) | RPC, gossip, pending pool (`GasLimitsValidator`) |
235
+ | Network L2 admission limit | min(6,540,000, ceil(manaLimit/10×1.2)) | per-tx (relay) | RPC, gossip, pending pool (`GasLimitsValidator`) |
236
+ | Per-block fair share + caps | remaining budget / blocks × multiplier, min absolute caps & blob-field cap | per-block | `CheckpointBuilder.capLimitsByCheckpointBudgets` |
237
+ | `rollupManaLimit` | `manaTarget × 2` | per-checkpoint | `validateCheckpointLimits` |
238
+ | `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT` | 786,432 | per-checkpoint | `validateCheckpointLimits` + blob encoding |
239
+ | `BLOBS_PER_CHECKPOINT × FIELDS_PER_BLOB`| 24,576 | per-checkpoint | `validateCheckpointLimits` + blob encoding |
240
+
149
241
  ## TypeScript Types
150
242
 
151
243
  - **`Gas`** — mana quantity in two dimensions (`daGas`, `l2Gas`).
@@ -8,13 +8,6 @@ import { z } from 'zod';
8
8
  import { Gas, GasDimensions } from './gas.js';
9
9
  import { GasFees } from './gas_fees.js';
10
10
 
11
- /** Approximate max DA gas limit. Arbitrary, assuming 4 blocks per checkpoint — users should use gas estimation. */
12
- export const APPROXIMATE_MAX_DA_GAS_PER_BLOCK = Math.floor(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT / 4);
13
- /** Fallback teardown L2 gas limit. Arbitrary — users should use gas estimation. */
14
- export const FALLBACK_TEARDOWN_L2_GAS_LIMIT = Math.floor(MAX_PROCESSABLE_L2_GAS / 8);
15
- /** Fallback teardown DA gas limit. Arbitrary — users should use gas estimation. */
16
- export const FALLBACK_TEARDOWN_DA_GAS_LIMIT = Math.floor(APPROXIMATE_MAX_DA_GAS_PER_BLOCK / 2);
17
-
18
11
  // For gas estimation, we use intentionally high limits above what the network can process,
19
12
  // so the simulation runs without hitting gas caps. Since teardown gas is counted towards total,
20
13
  // the total estimation limit is teardown + max processable.
@@ -106,31 +99,28 @@ export class GasSettings {
106
99
 
107
100
  /**
108
101
  * Fills in gas limits high enough for transactions to be included in most cases.
109
- * gasLimits is set to the maximum the protocol allows; since teardown gas is reserved
110
- * from gasLimits during private execution (see gas_meter.nr), the effective gas available
111
- * for app logic will be gasLimits - teardownGasLimits - privateOverhead.
112
- * The DA gas limit is set to an approximate max per block assuming 4 blocks per checkpoint,
113
- * since using the maximum per checkpoint would cause nodes to reject transactions.
102
+ * Callers must supply `gasLimits` typically the most a single tx may declare on the network
103
+ * (`min(per-tx max, per-block allocation)`), i.e. a node's advertised `txsLimits.gas`. Since teardown gas
104
+ * is reserved from gasLimits during private execution (see gas_meter.nr), the effective gas available for
105
+ * app logic is gasLimits - teardownGasLimits - privateOverhead; the teardown default is derived from the
106
+ * effective total so it always stays below it.
114
107
  * These values won't work if:
115
108
  * - Teardown consumes more than the arbitrarily assigned fallback limits
116
109
  * - The rest of the transaction consumes more than the remaining gas after teardown
117
110
  * - The DA gas limit is too low for the transaction, while still within the checkpoint limit
118
111
  */
119
112
  static fallback(overrides: {
120
- gasLimits?: Gas;
113
+ gasLimits: Gas;
121
114
  teardownGasLimits?: Gas;
122
115
  maxFeesPerGas: GasFees;
123
116
  maxPriorityFeesPerGas?: GasFees;
124
117
  }) {
118
+ const gasLimits = overrides.gasLimits;
119
+ const teardownGasLimits =
120
+ overrides.teardownGasLimits ?? new Gas(Math.floor(gasLimits.daGas / 2), Math.floor(gasLimits.l2Gas / 8));
125
121
  return GasSettings.from({
126
- gasLimits: overrides.gasLimits ?? {
127
- l2Gas: MAX_PROCESSABLE_L2_GAS,
128
- daGas: APPROXIMATE_MAX_DA_GAS_PER_BLOCK,
129
- },
130
- teardownGasLimits: overrides.teardownGasLimits ?? {
131
- l2Gas: FALLBACK_TEARDOWN_L2_GAS_LIMIT,
132
- daGas: FALLBACK_TEARDOWN_DA_GAS_LIMIT,
133
- },
122
+ gasLimits,
123
+ teardownGasLimits,
134
124
  maxFeesPerGas: overrides.maxFeesPerGas,
135
125
  maxPriorityFeesPerGas: overrides.maxPriorityFeesPerGas ?? GasFees.empty(),
136
126
  });
package/src/gas/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './gas.js';
3
3
  export * from './gas_fees.js';
4
4
  export * from './gas_settings.js';
5
5
  export * from './gas_used.js';
6
+ export * from './tx_gas_limits.js';
@@ -0,0 +1,123 @@
1
+ import {
2
+ NUM_BLOCK_END_BLOB_FIELDS,
3
+ NUM_CHECKPOINT_END_MARKER_FIELDS,
4
+ NUM_FIRST_BLOCK_END_BLOB_FIELDS,
5
+ } from '@aztec/blob-lib/encoding';
6
+ import {
7
+ BLOBS_PER_CHECKPOINT,
8
+ DA_GAS_PER_FIELD,
9
+ FIELDS_PER_BLOB,
10
+ MAX_PROCESSABLE_L2_GAS,
11
+ MAX_TX_DA_GAS,
12
+ } from '@aztec/constants';
13
+
14
+ import { type ProposerTimetableConfig, buildProposerTimetable } from '../timetable/build_proposer_timetable.js';
15
+ import type { SlotTimingConstants } from '../timetable/consensus_timetable.js';
16
+ import { Gas } from './gas.js';
17
+
18
+ /**
19
+ * Network-minimum per-block budget multiplier for L2 gas and tx-count allocation. A block packer must
20
+ * grant at least this share of the even per-block split to a single tx; operators may configure a higher
21
+ * multiplier (more generous), but not a lower one — enforced at sequencer startup. Also used as the default
22
+ * for `SequencerConfig.perBlockAllocationMultiplier`.
23
+ */
24
+ export const MIN_PER_BLOCK_ALLOCATION_MULTIPLIER = 1.2;
25
+
26
+ /**
27
+ * Network-minimum per-block budget multiplier for DA gas, applied in place of the general
28
+ * {@link MIN_PER_BLOCK_ALLOCATION_MULTIPLIER}. Higher than the general multiplier so the largest tx we
29
+ * want to support — a maximal contract class registration (~97k DA gas) — fits a single block under v5
30
+ * mainnet geometry (72s slots, 6s blocks → 10 blocks per checkpoint). A builder may configure a higher
31
+ * multiplier but never a lower one. Also used as the default for
32
+ * `SequencerConfig.perBlockDAAllocationMultiplier`.
33
+ */
34
+ export const MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER = 1.5;
35
+
36
+ /**
37
+ * The DA gas budget available to tx data within a checkpoint of `maxBlocksPerCheckpoint` blocks. This is the
38
+ * raw blob capacity (`BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB * DA_GAS_PER_FIELD`) minus the fields the blob
39
+ * encoding reserves for overhead that no tx pays DA gas for:
40
+ *
41
+ * - one checkpoint-end marker field (`NUM_CHECKPOINT_END_MARKER_FIELDS`),
42
+ * - the first block's block-end fields (`NUM_FIRST_BLOCK_END_BLOB_FIELDS`, 7), and
43
+ * - `NUM_BLOCK_END_BLOB_FIELDS` (6) for each of the `blocks - 1` subsequent blocks.
44
+ *
45
+ * Subtracting the overhead for every block (not just the first) keeps the network DA admission limit at or
46
+ * below the builder's first-block blob-field cap at every geometry. The builder is the MOST generous for the
47
+ * first block — it only reserves that block's own block-end overhead — so being conservative here (assuming
48
+ * the checkpoint is full of blocks, each spending its share) is what guarantees admitted ⇒ buildable: a tx
49
+ * admitted under this budget always fits the first block's blob-field cap, regardless of how many blocks the
50
+ * builder ends up packing.
51
+ *
52
+ * @param maxBlocksPerCheckpoint - Number of blocks the checkpoint may contain; clamped to at least 1.
53
+ */
54
+ export function getDaCheckpointBudgetForTxs(maxBlocksPerCheckpoint: number): number {
55
+ const blocks = Math.max(1, maxBlocksPerCheckpoint);
56
+ // Clamp at zero: for absurd geometries (blocks greater than ~4094) the per-block overhead alone exceeds the
57
+ // raw blob capacity, which would otherwise yield a negative advertised DA budget.
58
+ const fields = Math.max(
59
+ 0,
60
+ BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB -
61
+ NUM_CHECKPOINT_END_MARKER_FIELDS -
62
+ NUM_FIRST_BLOCK_END_BLOB_FIELDS -
63
+ (blocks - 1) * NUM_BLOCK_END_BLOB_FIELDS,
64
+ );
65
+ return fields * DA_GAS_PER_FIELD;
66
+ }
67
+
68
+ /**
69
+ * Computes the maximum gas a single tx may declare on a network: the smaller of the per-tx protocol
70
+ * maximum and the per-block allocation a proposer grants to the first block of a checkpoint. The per-block
71
+ * allocation mirrors `CheckpointBuilder.capLimitsByCheckpointBudgets`
72
+ * (`ceil(checkpointBudget / maxBlocksPerCheckpoint * multiplier)`) using the network-minimum multipliers, so
73
+ * a tx declaring this much is admissible into a block under that geometry.
74
+ *
75
+ * This is a *network* limit: a function of network-wide constants only (timetable-derived
76
+ * blocks-per-checkpoint, checkpoint budgets, the network-minimum multipliers). It must NOT depend on a
77
+ * node's local restrictiveness — its multipliers configured above the network minimum, or its
78
+ * `maxDABlockGas` / `validateMaxDABlockGas` caps — because those make a node stricter at block-building
79
+ * time but cannot define what the network considers a valid tx for relay. The same value is advertised by
80
+ * `getNodeInfo` and enforced by the RPC/gossip/pool gas validators.
81
+ *
82
+ * The DA budget is {@link getDaCheckpointBudgetForTxs} evaluated at the clamped blocks-per-checkpoint — the
83
+ * raw blob capacity net of encoding overhead for every block — so the admission limit is consistent with the
84
+ * builder's blob-field cap.
85
+ *
86
+ * @param manaCheckpointBudget - L2 (mana) budget per checkpoint (`rollupManaLimit`).
87
+ */
88
+ export function computeNetworkTxGasLimits(opts: { maxBlocksPerCheckpoint: number; manaCheckpointBudget: number }): Gas {
89
+ const blocks = Math.max(1, opts.maxBlocksPerCheckpoint);
90
+ const daBudget = getDaCheckpointBudgetForTxs(blocks);
91
+
92
+ // Clamp by the whole-checkpoint budget too: at small block counts the per-block share scaled by the
93
+ // multiplier can exceed the checkpoint budget itself (e.g. at blocks=1 a >1 multiplier overshoots), which
94
+ // would admit a tx no builder can ever pack — the builder caps each block by the remaining budget. Clamping
95
+ // by the budget makes "admitted ⇒ buildable" unconditional. (For DA the per-tx maximum always binds first,
96
+ // so the budget clamp is currently moot, but it keeps the invariant explicit.)
97
+ const daGas = Math.min(
98
+ MAX_TX_DA_GAS,
99
+ daBudget,
100
+ Math.ceil((daBudget / blocks) * MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER),
101
+ );
102
+ const l2Gas = Math.min(
103
+ MAX_PROCESSABLE_L2_GAS,
104
+ opts.manaCheckpointBudget,
105
+ Math.ceil((opts.manaCheckpointBudget / blocks) * MIN_PER_BLOCK_ALLOCATION_MULTIPLIER),
106
+ );
107
+
108
+ return new Gas(daGas, l2Gas);
109
+ }
110
+
111
+ /**
112
+ * Network tx gas limits derived from a sequencer/p2p config and the L1 slot-timing + mana constants. The
113
+ * single source of truth shared by `getNodeInfo` (advertising) and the RPC/gossip/pool gas validators
114
+ * (enforcing), so a node never rejects a tx it advertised as admissible. Always uses the network-minimum
115
+ * multipliers, never the node's (possibly higher) configured multipliers.
116
+ */
117
+ export function getNetworkTxGasLimits(
118
+ config: ProposerTimetableConfig,
119
+ l1Constants: SlotTimingConstants & { rollupManaLimit: number },
120
+ ): Gas {
121
+ const maxBlocksPerCheckpoint = buildProposerTimetable(config, l1Constants).getMaxBlocksPerCheckpoint();
122
+ return computeNetworkTxGasLimits({ maxBlocksPerCheckpoint, manaCheckpointBudget: l1Constants.rollupManaLimit });
123
+ }