@aztec/sequencer-client 0.0.1-commit.1142ef1 → 0.0.1-commit.125b3452
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.
- package/dest/client/sequencer-client.d.ts +24 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +101 -16
- package/dest/config.d.ts +25 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +49 -30
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +7 -6
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +12 -4
- package/dest/publisher/sequencer-publisher.d.ts +26 -8
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +349 -49
- package/dest/sequencer/checkpoint_proposal_job.d.ts +33 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +217 -66
- package/dest/sequencer/checkpoint_voter.d.ts +3 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +34 -10
- package/dest/sequencer/index.d.ts +1 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -1
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +111 -30
- package/dest/sequencer/sequencer.d.ts +42 -19
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +107 -50
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +27 -19
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +67 -38
- package/dest/test/utils.d.ts +8 -8
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +12 -11
- package/package.json +29 -28
- package/src/client/sequencer-client.ts +135 -18
- package/src/config.ts +65 -41
- package/src/global_variable_builder/global_builder.ts +6 -5
- package/src/index.ts +1 -6
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +344 -61
- package/src/sequencer/checkpoint_proposal_job.ts +306 -81
- package/src/sequencer/checkpoint_voter.ts +32 -7
- package/src/sequencer/index.ts +0 -1
- package/src/sequencer/metrics.ts +124 -32
- package/src/sequencer/sequencer.ts +131 -53
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +122 -78
- package/src/test/utils.ts +24 -14
- package/dest/sequencer/block_builder.d.ts +0 -26
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -129
- package/src/sequencer/block_builder.ts +0 -216
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
3
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
4
|
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
4
5
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
6
|
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
-
import {
|
|
7
|
+
import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
7
8
|
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -18,21 +19,27 @@ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
|
18
19
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
19
20
|
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
20
21
|
|
|
21
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
DefaultSequencerConfig,
|
|
24
|
+
type SequencerClientConfig,
|
|
25
|
+
getPublisherConfigFromSequencerConfig,
|
|
26
|
+
} from '../config.js';
|
|
22
27
|
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
23
28
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
24
29
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
30
|
+
import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
33
|
* Encapsulates the full sequencer and publisher.
|
|
28
34
|
*/
|
|
29
35
|
export class SequencerClient {
|
|
30
36
|
constructor(
|
|
31
|
-
protected publisherManager: PublisherManager<
|
|
37
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
32
38
|
protected sequencer: Sequencer,
|
|
33
39
|
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
34
40
|
protected validatorClient?: ValidatorClient,
|
|
35
41
|
private l1Metrics?: L1Metrics,
|
|
42
|
+
private delayer_?: Delayer,
|
|
36
43
|
) {}
|
|
37
44
|
|
|
38
45
|
/**
|
|
@@ -62,7 +69,7 @@ export class SequencerClient {
|
|
|
62
69
|
blobClient: BlobClientInterface;
|
|
63
70
|
dateProvider: DateProvider;
|
|
64
71
|
epochCache?: EpochCache;
|
|
65
|
-
l1TxUtils:
|
|
72
|
+
l1TxUtils: L1TxUtils[];
|
|
66
73
|
nodeKeyStore: KeystoreManager;
|
|
67
74
|
},
|
|
68
75
|
) {
|
|
@@ -85,7 +92,11 @@ export class SequencerClient {
|
|
|
85
92
|
publicClient,
|
|
86
93
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
87
94
|
);
|
|
88
|
-
const publisherManager = new PublisherManager(
|
|
95
|
+
const publisherManager = new PublisherManager(
|
|
96
|
+
l1TxUtils,
|
|
97
|
+
getPublisherConfigFromSequencerConfig(config),
|
|
98
|
+
log.getBindings(),
|
|
99
|
+
);
|
|
89
100
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
90
101
|
const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
|
|
91
102
|
rollupContract.getL1GenesisTime(),
|
|
@@ -132,17 +143,14 @@ export class SequencerClient {
|
|
|
132
143
|
});
|
|
133
144
|
|
|
134
145
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
135
|
-
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
|
|
136
|
-
|
|
137
|
-
const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
147
|
+
const globalsBuilder = new GlobalVariableBuilder({
|
|
148
|
+
...config,
|
|
149
|
+
l1GenesisTime,
|
|
150
|
+
slotDuration: Number(slotDuration),
|
|
151
|
+
ethereumSlotDuration,
|
|
152
|
+
rollupVersion,
|
|
153
|
+
});
|
|
146
154
|
|
|
147
155
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
148
156
|
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
@@ -152,6 +160,15 @@ export class SequencerClient {
|
|
|
152
160
|
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
153
161
|
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
154
162
|
|
|
163
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock, maxBlocksPerCheckpoint } = computeBlockLimits(
|
|
164
|
+
config,
|
|
165
|
+
rollupManaLimit,
|
|
166
|
+
l1PublishingTime,
|
|
167
|
+
log,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
|
|
171
|
+
|
|
155
172
|
const sequencer = new Sequencer(
|
|
156
173
|
publisherFactory,
|
|
157
174
|
validatorClient,
|
|
@@ -166,14 +183,17 @@ export class SequencerClient {
|
|
|
166
183
|
deps.dateProvider,
|
|
167
184
|
epochCache,
|
|
168
185
|
rollupContract,
|
|
169
|
-
{ ...config, l1PublishingTime, maxL2BlockGas
|
|
186
|
+
{ ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock, maxBlocksPerCheckpoint },
|
|
170
187
|
telemetryClient,
|
|
171
188
|
log,
|
|
172
189
|
);
|
|
173
190
|
|
|
174
|
-
|
|
191
|
+
sequencer.init();
|
|
192
|
+
|
|
193
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
194
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
175
195
|
|
|
176
|
-
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
|
|
196
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
177
197
|
}
|
|
178
198
|
|
|
179
199
|
/**
|
|
@@ -208,6 +228,16 @@ export class SequencerClient {
|
|
|
208
228
|
return this.sequencer;
|
|
209
229
|
}
|
|
210
230
|
|
|
231
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
232
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
233
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
237
|
+
getDelayer(): Delayer | undefined {
|
|
238
|
+
return this.delayer_;
|
|
239
|
+
}
|
|
240
|
+
|
|
211
241
|
get validatorAddresses(): EthAddress[] | undefined {
|
|
212
242
|
return this.sequencer.getValidatorAddresses();
|
|
213
243
|
}
|
|
@@ -216,3 +246,90 @@ export class SequencerClient {
|
|
|
216
246
|
return this.sequencer.maxL2BlockGas;
|
|
217
247
|
}
|
|
218
248
|
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Computes per-block L2 gas, DA gas, and TX count budgets based on the L1 rollup limits and the timetable.
|
|
252
|
+
* If the user explicitly set a limit, it is capped at the corresponding checkpoint limit.
|
|
253
|
+
* Otherwise, derives it as (checkpointLimit / maxBlocks) * multiplier, capped at the checkpoint limit.
|
|
254
|
+
*/
|
|
255
|
+
export function computeBlockLimits(
|
|
256
|
+
config: SequencerClientConfig,
|
|
257
|
+
rollupManaLimit: number,
|
|
258
|
+
l1PublishingTime: number,
|
|
259
|
+
log: ReturnType<typeof createLogger>,
|
|
260
|
+
): { maxL2BlockGas: number; maxDABlockGas: number; maxTxsPerBlock: number; maxBlocksPerCheckpoint: number } {
|
|
261
|
+
const maxNumberOfBlocks = new SequencerTimetable({
|
|
262
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
263
|
+
aztecSlotDuration: config.aztecSlotDuration,
|
|
264
|
+
l1PublishingTime,
|
|
265
|
+
p2pPropagationTime: config.attestationPropagationTime,
|
|
266
|
+
blockDurationMs: config.blockDurationMs,
|
|
267
|
+
enforce: config.enforceTimeTable ?? DefaultSequencerConfig.enforceTimeTable,
|
|
268
|
+
}).maxNumberOfBlocks;
|
|
269
|
+
|
|
270
|
+
const multiplier = config.perBlockAllocationMultiplier ?? DefaultSequencerConfig.perBlockAllocationMultiplier;
|
|
271
|
+
|
|
272
|
+
// Compute maxL2BlockGas
|
|
273
|
+
let maxL2BlockGas: number;
|
|
274
|
+
if (config.maxL2BlockGas !== undefined) {
|
|
275
|
+
if (config.maxL2BlockGas > rollupManaLimit) {
|
|
276
|
+
log.warn(
|
|
277
|
+
`Provided MAX_L2_BLOCK_GAS ${config.maxL2BlockGas} exceeds L1 rollup mana limit ${rollupManaLimit} (capping)`,
|
|
278
|
+
);
|
|
279
|
+
maxL2BlockGas = rollupManaLimit;
|
|
280
|
+
} else {
|
|
281
|
+
maxL2BlockGas = config.maxL2BlockGas;
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
maxL2BlockGas = Math.min(rollupManaLimit, Math.ceil((rollupManaLimit / maxNumberOfBlocks) * multiplier));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Compute maxDABlockGas
|
|
288
|
+
const daCheckpointLimit = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
289
|
+
let maxDABlockGas: number;
|
|
290
|
+
if (config.maxDABlockGas !== undefined) {
|
|
291
|
+
if (config.maxDABlockGas > daCheckpointLimit) {
|
|
292
|
+
log.warn(
|
|
293
|
+
`Provided MAX_DA_BLOCK_GAS ${config.maxDABlockGas} exceeds DA checkpoint limit ${daCheckpointLimit} (capping)`,
|
|
294
|
+
);
|
|
295
|
+
maxDABlockGas = daCheckpointLimit;
|
|
296
|
+
} else {
|
|
297
|
+
maxDABlockGas = config.maxDABlockGas;
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
maxDABlockGas = Math.min(daCheckpointLimit, Math.ceil((daCheckpointLimit / maxNumberOfBlocks) * multiplier));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Compute maxTxsPerBlock
|
|
304
|
+
const defaultMaxTxsPerBlock = 32;
|
|
305
|
+
let maxTxsPerBlock: number;
|
|
306
|
+
if (config.maxTxsPerBlock !== undefined) {
|
|
307
|
+
if (config.maxTxsPerCheckpoint !== undefined && config.maxTxsPerBlock > config.maxTxsPerCheckpoint) {
|
|
308
|
+
log.warn(
|
|
309
|
+
`Provided MAX_TX_PER_BLOCK ${config.maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
310
|
+
);
|
|
311
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
312
|
+
} else {
|
|
313
|
+
maxTxsPerBlock = config.maxTxsPerBlock;
|
|
314
|
+
}
|
|
315
|
+
} else if (config.maxTxsPerCheckpoint !== undefined) {
|
|
316
|
+
maxTxsPerBlock = Math.min(
|
|
317
|
+
config.maxTxsPerCheckpoint,
|
|
318
|
+
Math.ceil((config.maxTxsPerCheckpoint / maxNumberOfBlocks) * multiplier),
|
|
319
|
+
);
|
|
320
|
+
} else {
|
|
321
|
+
maxTxsPerBlock = defaultMaxTxsPerBlock;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
log.info(`Computed block limits L2=${maxL2BlockGas} DA=${maxDABlockGas} maxTxs=${maxTxsPerBlock}`, {
|
|
325
|
+
maxL2BlockGas,
|
|
326
|
+
maxDABlockGas,
|
|
327
|
+
maxTxsPerBlock,
|
|
328
|
+
rollupManaLimit,
|
|
329
|
+
daCheckpointLimit,
|
|
330
|
+
maxNumberOfBlocks,
|
|
331
|
+
multiplier,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock, maxBlocksPerCheckpoint: maxNumberOfBlocks };
|
|
335
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -11,60 +11,64 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
11
11
|
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
12
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
13
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type ChainConfig,
|
|
16
|
+
type SequencerConfig,
|
|
17
|
+
chainConfigMappings,
|
|
18
|
+
sharedSequencerConfigMappings,
|
|
19
|
+
} from '@aztec/stdlib/config';
|
|
15
20
|
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
21
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
16
22
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
17
23
|
|
|
18
24
|
import {
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
type SequencerPublisherConfig,
|
|
26
|
+
type SequencerTxSenderConfig,
|
|
27
|
+
sequencerPublisherConfigMappings,
|
|
28
|
+
sequencerTxSenderConfigMappings,
|
|
23
29
|
} from './publisher/config.js';
|
|
24
30
|
|
|
25
31
|
export * from './publisher/config.js';
|
|
26
32
|
export type { SequencerConfig };
|
|
27
33
|
|
|
28
|
-
export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
|
|
29
|
-
|
|
30
34
|
/**
|
|
31
35
|
* Default values for SequencerConfig.
|
|
32
36
|
* Centralized location for all sequencer configuration defaults.
|
|
33
37
|
*/
|
|
34
|
-
export const DefaultSequencerConfig
|
|
38
|
+
export const DefaultSequencerConfig = {
|
|
35
39
|
sequencerPollingIntervalMS: 500,
|
|
36
|
-
maxTxsPerBlock: 32,
|
|
37
40
|
minTxsPerBlock: 1,
|
|
38
41
|
buildCheckpointIfEmpty: false,
|
|
39
42
|
publishTxsWithProposals: false,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
perBlockAllocationMultiplier: 1.2,
|
|
44
|
+
redistributeCheckpointBudget: true,
|
|
43
45
|
enforceTimeTable: true,
|
|
44
|
-
attestationPropagationTime:
|
|
46
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
45
47
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
48
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
49
|
skipCollectingAttestations: false,
|
|
48
50
|
skipInvalidateBlockAsProposer: false,
|
|
49
51
|
broadcastInvalidBlockProposal: false,
|
|
50
52
|
injectFakeAttestation: false,
|
|
53
|
+
injectHighSValueAttestation: false,
|
|
54
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
51
55
|
fishermanMode: false,
|
|
52
56
|
shuffleAttestationOrdering: false,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
57
|
+
skipPushProposedBlocksToArchiver: false,
|
|
58
|
+
skipPublishingCheckpointsPercent: 0,
|
|
59
|
+
} satisfies ResolvedSequencerConfig;
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* Configuration settings for the SequencerClient.
|
|
59
63
|
*/
|
|
60
|
-
export type SequencerClientConfig =
|
|
64
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
61
65
|
KeyStoreConfig &
|
|
62
66
|
ValidatorClientConfig &
|
|
63
|
-
|
|
67
|
+
SequencerTxSenderConfig &
|
|
64
68
|
SequencerConfig &
|
|
65
69
|
L1ReaderConfig &
|
|
66
70
|
ChainConfig &
|
|
67
|
-
Pick<P2PConfig, '
|
|
71
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
68
72
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
69
73
|
|
|
70
74
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
@@ -73,10 +77,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
73
77
|
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
74
78
|
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
75
79
|
},
|
|
76
|
-
|
|
77
|
-
env: '
|
|
78
|
-
description: 'The maximum number of txs
|
|
79
|
-
|
|
80
|
+
maxTxsPerCheckpoint: {
|
|
81
|
+
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
82
|
+
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
83
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
80
84
|
},
|
|
81
85
|
minTxsPerBlock: {
|
|
82
86
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -95,12 +99,28 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
95
99
|
maxL2BlockGas: {
|
|
96
100
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
97
101
|
description: 'The maximum L2 block gas.',
|
|
98
|
-
|
|
102
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
99
103
|
},
|
|
100
104
|
maxDABlockGas: {
|
|
101
105
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
102
106
|
description: 'The maximum DA block gas.',
|
|
103
|
-
|
|
107
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
108
|
+
},
|
|
109
|
+
perBlockAllocationMultiplier: {
|
|
110
|
+
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
111
|
+
description:
|
|
112
|
+
'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
|
|
113
|
+
' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
114
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
|
|
115
|
+
},
|
|
116
|
+
redistributeCheckpointBudget: {
|
|
117
|
+
env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
|
|
118
|
+
description:
|
|
119
|
+
'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
|
|
120
|
+
...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget),
|
|
121
|
+
},
|
|
122
|
+
maxBlocksPerCheckpoint: {
|
|
123
|
+
description: 'Computed max number of blocks per checkpoint from timetable.',
|
|
104
124
|
},
|
|
105
125
|
coinbase: {
|
|
106
126
|
env: 'COINBASE',
|
|
@@ -120,11 +140,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
120
140
|
env: 'ACVM_BINARY_PATH',
|
|
121
141
|
description: 'The path to the ACVM binary',
|
|
122
142
|
},
|
|
123
|
-
maxBlockSizeInBytes: {
|
|
124
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
125
|
-
description: 'Max block size',
|
|
126
|
-
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
127
|
-
},
|
|
128
143
|
enforceTimeTable: {
|
|
129
144
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
130
145
|
description: 'Whether to enforce the time table when building blocks',
|
|
@@ -182,6 +197,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
182
197
|
description: 'Inject a fake attestation (for testing only)',
|
|
183
198
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
184
199
|
},
|
|
200
|
+
injectHighSValueAttestation: {
|
|
201
|
+
description: 'Inject a malleable attestation with a high-s value (for testing only)',
|
|
202
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
|
|
203
|
+
},
|
|
204
|
+
injectUnrecoverableSignatureAttestation: {
|
|
205
|
+
description: 'Inject an attestation with an unrecoverable signature (for testing only)',
|
|
206
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
|
|
207
|
+
},
|
|
185
208
|
fishermanMode: {
|
|
186
209
|
env: 'FISHERMAN_MODE',
|
|
187
210
|
description:
|
|
@@ -192,24 +215,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
192
215
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
193
216
|
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
194
217
|
},
|
|
195
|
-
|
|
196
|
-
env: 'SEQ_BLOCK_DURATION_MS',
|
|
197
|
-
description:
|
|
198
|
-
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
199
|
-
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
200
|
-
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
201
|
-
},
|
|
218
|
+
...sharedSequencerConfigMappings,
|
|
202
219
|
buildCheckpointIfEmpty: {
|
|
203
220
|
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
204
221
|
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
205
222
|
...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
|
|
206
223
|
},
|
|
207
|
-
// TODO(palla/mbps): Change default to false once block sync is stable
|
|
208
224
|
skipPushProposedBlocksToArchiver: {
|
|
209
225
|
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
210
226
|
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
211
227
|
},
|
|
212
|
-
|
|
228
|
+
minBlocksForCheckpoint: {
|
|
229
|
+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
|
|
230
|
+
},
|
|
231
|
+
skipPublishingCheckpointsPercent: {
|
|
232
|
+
env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
|
|
233
|
+
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
234
|
+
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
235
|
+
},
|
|
236
|
+
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
213
237
|
};
|
|
214
238
|
|
|
215
239
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -217,8 +241,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
217
241
|
...sequencerConfigMappings,
|
|
218
242
|
...keyStoreConfigMappings,
|
|
219
243
|
...l1ReaderConfigMappings,
|
|
220
|
-
...
|
|
221
|
-
...
|
|
244
|
+
...sequencerTxSenderConfigMappings,
|
|
245
|
+
...sequencerPublisherConfigMappings,
|
|
222
246
|
...chainConfigMappings,
|
|
223
247
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
224
248
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
2
3
|
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
4
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
5
|
import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
@@ -16,7 +17,7 @@ import type {
|
|
|
16
17
|
} from '@aztec/stdlib/tx';
|
|
17
18
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
18
19
|
|
|
19
|
-
import { createPublicClient
|
|
20
|
+
import { createPublicClient } from 'viem';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Simple global variables builder.
|
|
@@ -53,7 +54,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
53
54
|
|
|
54
55
|
this.publicClient = createPublicClient({
|
|
55
56
|
chain: chain.chainInfo,
|
|
56
|
-
transport:
|
|
57
|
+
transport: makeL1HttpTransport(chain.rpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
57
58
|
pollingInterval: config.viemPollingIntervalMS,
|
|
58
59
|
});
|
|
59
60
|
|
|
@@ -69,9 +70,9 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
69
70
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
70
71
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
71
72
|
|
|
72
|
-
const
|
|
73
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
73
74
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
74
|
-
SlotNumber.fromBigInt(BigInt(
|
|
75
|
+
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
75
76
|
);
|
|
76
77
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
77
78
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
@@ -120,7 +121,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
121
|
coinbase: EthAddress,
|
|
121
122
|
feeRecipient: AztecAddress,
|
|
122
123
|
slotNumber: SlotNumber,
|
|
123
|
-
): Promise<CheckpointGlobalVariables
|
|
124
|
+
): Promise<CheckpointGlobalVariables> {
|
|
124
125
|
const { chainId, version } = this;
|
|
125
126
|
|
|
126
127
|
const timestamp = getTimestampForSlot(slotNumber, {
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
-
export {
|
|
5
|
-
FullNodeBlockBuilder as BlockBuilder,
|
|
6
|
-
Sequencer,
|
|
7
|
-
SequencerState,
|
|
8
|
-
type SequencerEvents,
|
|
9
|
-
} from './sequencer/index.js';
|
|
4
|
+
export { Sequencer, SequencerState, type SequencerEvents } from './sequencer/index.js';
|
|
10
5
|
|
|
11
6
|
// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
|
|
12
7
|
// ISSUE(#9832)
|