@aztec/sequencer-client 0.0.1-commit.f146247c → 0.0.1-commit.f224bb98b
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 +23 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +99 -16
- package/dest/config.d.ts +24 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +40 -28
- 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/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.d.ts +26 -7
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +299 -30
- package/dest/sequencer/checkpoint_proposal_job.d.ts +8 -4
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +132 -79
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +86 -15
- package/dest/sequencer/sequencer.d.ts +26 -13
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +41 -40
- 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 +8 -8
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -34
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +135 -18
- package/src/config.ts +54 -38
- package/src/global_variable_builder/global_builder.ts +1 -1
- 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.ts +300 -43
- package/src/sequencer/checkpoint_proposal_job.ts +171 -86
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +52 -46
- 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 +60 -46
- package/src/test/utils.ts +5 -2
|
@@ -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 } = 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 },
|
|
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 } {
|
|
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 };
|
|
335
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -11,59 +11,63 @@ 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
|
-
maxDABlockGas: 10e9,
|
|
42
|
-
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
perBlockAllocationMultiplier: 2,
|
|
43
44
|
enforceTimeTable: true,
|
|
44
|
-
attestationPropagationTime:
|
|
45
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
45
46
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
47
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
48
|
skipCollectingAttestations: false,
|
|
48
49
|
skipInvalidateBlockAsProposer: false,
|
|
49
50
|
broadcastInvalidBlockProposal: false,
|
|
50
51
|
injectFakeAttestation: false,
|
|
52
|
+
injectHighSValueAttestation: false,
|
|
53
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
51
54
|
fishermanMode: false,
|
|
52
55
|
shuffleAttestationOrdering: false,
|
|
53
56
|
skipPushProposedBlocksToArchiver: false,
|
|
54
|
-
|
|
57
|
+
skipPublishingCheckpointsPercent: 0,
|
|
58
|
+
} satisfies ResolvedSequencerConfig;
|
|
55
59
|
|
|
56
60
|
/**
|
|
57
61
|
* Configuration settings for the SequencerClient.
|
|
58
62
|
*/
|
|
59
|
-
export type SequencerClientConfig =
|
|
63
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
60
64
|
KeyStoreConfig &
|
|
61
65
|
ValidatorClientConfig &
|
|
62
|
-
|
|
66
|
+
SequencerTxSenderConfig &
|
|
63
67
|
SequencerConfig &
|
|
64
68
|
L1ReaderConfig &
|
|
65
69
|
ChainConfig &
|
|
66
|
-
Pick<P2PConfig, '
|
|
70
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
67
71
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
68
72
|
|
|
69
73
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
@@ -72,10 +76,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
72
76
|
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
73
77
|
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
74
78
|
},
|
|
75
|
-
|
|
76
|
-
env: '
|
|
77
|
-
description: 'The maximum number of txs
|
|
78
|
-
|
|
79
|
+
maxTxsPerCheckpoint: {
|
|
80
|
+
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
81
|
+
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
82
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
79
83
|
},
|
|
80
84
|
minTxsPerBlock: {
|
|
81
85
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -94,12 +98,19 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
94
98
|
maxL2BlockGas: {
|
|
95
99
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
96
100
|
description: 'The maximum L2 block gas.',
|
|
97
|
-
|
|
101
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
98
102
|
},
|
|
99
103
|
maxDABlockGas: {
|
|
100
104
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
101
105
|
description: 'The maximum DA block gas.',
|
|
102
|
-
|
|
106
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
107
|
+
},
|
|
108
|
+
perBlockAllocationMultiplier: {
|
|
109
|
+
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
110
|
+
description:
|
|
111
|
+
'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
|
|
112
|
+
' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
113
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
|
|
103
114
|
},
|
|
104
115
|
coinbase: {
|
|
105
116
|
env: 'COINBASE',
|
|
@@ -119,11 +130,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
119
130
|
env: 'ACVM_BINARY_PATH',
|
|
120
131
|
description: 'The path to the ACVM binary',
|
|
121
132
|
},
|
|
122
|
-
maxBlockSizeInBytes: {
|
|
123
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
124
|
-
description: 'Max block size',
|
|
125
|
-
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
126
|
-
},
|
|
127
133
|
enforceTimeTable: {
|
|
128
134
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
129
135
|
description: 'Whether to enforce the time table when building blocks',
|
|
@@ -181,6 +187,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
181
187
|
description: 'Inject a fake attestation (for testing only)',
|
|
182
188
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
183
189
|
},
|
|
190
|
+
injectHighSValueAttestation: {
|
|
191
|
+
description: 'Inject a malleable attestation with a high-s value (for testing only)',
|
|
192
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
|
|
193
|
+
},
|
|
194
|
+
injectUnrecoverableSignatureAttestation: {
|
|
195
|
+
description: 'Inject an attestation with an unrecoverable signature (for testing only)',
|
|
196
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
|
|
197
|
+
},
|
|
184
198
|
fishermanMode: {
|
|
185
199
|
env: 'FISHERMAN_MODE',
|
|
186
200
|
description:
|
|
@@ -191,13 +205,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
191
205
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
192
206
|
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
193
207
|
},
|
|
194
|
-
|
|
195
|
-
env: 'SEQ_BLOCK_DURATION_MS',
|
|
196
|
-
description:
|
|
197
|
-
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
198
|
-
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
199
|
-
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
200
|
-
},
|
|
208
|
+
...sharedSequencerConfigMappings,
|
|
201
209
|
buildCheckpointIfEmpty: {
|
|
202
210
|
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
203
211
|
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
@@ -207,7 +215,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
207
215
|
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
208
216
|
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
209
217
|
},
|
|
210
|
-
|
|
218
|
+
minBlocksForCheckpoint: {
|
|
219
|
+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
|
|
220
|
+
},
|
|
221
|
+
skipPublishingCheckpointsPercent: {
|
|
222
|
+
env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
|
|
223
|
+
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
224
|
+
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
225
|
+
},
|
|
226
|
+
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
211
227
|
};
|
|
212
228
|
|
|
213
229
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -215,8 +231,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
215
231
|
...sequencerConfigMappings,
|
|
216
232
|
...keyStoreConfigMappings,
|
|
217
233
|
...l1ReaderConfigMappings,
|
|
218
|
-
...
|
|
219
|
-
...
|
|
234
|
+
...sequencerTxSenderConfigMappings,
|
|
235
|
+
...sequencerPublisherConfigMappings,
|
|
220
236
|
...chainConfigMappings,
|
|
221
237
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
222
238
|
};
|
|
@@ -120,7 +120,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
120
|
coinbase: EthAddress,
|
|
121
121
|
feeRecipient: AztecAddress,
|
|
122
122
|
slotNumber: SlotNumber,
|
|
123
|
-
): Promise<CheckpointGlobalVariables
|
|
123
|
+
): Promise<CheckpointGlobalVariables> {
|
|
124
124
|
const { chainId, version } = this;
|
|
125
125
|
|
|
126
126
|
const timestamp = getTimestampForSlot(slotNumber, {
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
3
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
|
-
import {
|
|
5
|
-
type ConfigMappingsType,
|
|
6
|
-
SecretValue,
|
|
7
|
-
booleanConfigHelper,
|
|
8
|
-
getConfigFromMappings,
|
|
9
|
-
} from '@aztec/foundation/config';
|
|
4
|
+
import { type ConfigMappingsType, SecretValue, booleanConfigHelper } from '@aztec/foundation/config';
|
|
10
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
6
|
|
|
12
|
-
/**
|
|
13
|
-
* The configuration of the rollup transaction publisher.
|
|
14
|
-
*/
|
|
7
|
+
/** Configuration of the transaction publisher. */
|
|
15
8
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
16
|
-
/**
|
|
17
|
-
* The private key to be used by the publisher.
|
|
18
|
-
*/
|
|
9
|
+
/** The private key to be used by the publisher. */
|
|
19
10
|
publisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
20
11
|
|
|
21
|
-
/**
|
|
22
|
-
* Publisher addresses to be used with a remote signer
|
|
23
|
-
*/
|
|
12
|
+
/** Publisher addresses to be used with a remote signer */
|
|
24
13
|
publisherAddresses?: EthAddress[];
|
|
25
14
|
};
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
export type ProverTxSenderConfig = L1ReaderConfig & {
|
|
17
|
+
proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
18
|
+
proverPublisherAddresses?: EthAddress[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SequencerTxSenderConfig = L1ReaderConfig & {
|
|
22
|
+
sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
23
|
+
sequencerPublisherAddresses?: EthAddress[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
publisherPrivateKeys: config.proverPublisherPrivateKeys,
|
|
30
|
+
publisherAddresses: config.proverPublisherAddresses,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
|
|
35
|
+
return {
|
|
36
|
+
...config,
|
|
37
|
+
publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
|
|
38
|
+
publisherAddresses: config.sequencerPublisherAddresses,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Configuration of the L1Publisher. */
|
|
30
43
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
31
44
|
BlobClientConfig & {
|
|
32
45
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
@@ -35,37 +48,83 @@ export type PublisherConfig = L1TxUtilsConfig &
|
|
|
35
48
|
fishermanMode?: boolean;
|
|
36
49
|
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
37
50
|
publisherForwarderAddress?: EthAddress;
|
|
51
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
52
|
+
l1TxFailedStore?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
56
|
+
BlobClientConfig & {
|
|
57
|
+
fishermanMode?: boolean;
|
|
58
|
+
proverPublisherAllowInvalidStates?: boolean;
|
|
59
|
+
proverPublisherForwarderAddress?: EthAddress;
|
|
38
60
|
};
|
|
39
61
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
63
|
+
BlobClientConfig & {
|
|
64
|
+
fishermanMode?: boolean;
|
|
65
|
+
sequencerPublisherAllowInvalidStates?: boolean;
|
|
66
|
+
sequencerPublisherForwarderAddress?: EthAddress;
|
|
67
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
68
|
+
l1TxFailedStore?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
72
|
+
return {
|
|
73
|
+
...config,
|
|
74
|
+
publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
|
|
75
|
+
publisherForwarderAddress: config.proverPublisherForwarderAddress,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
|
|
80
|
+
return {
|
|
81
|
+
...config,
|
|
82
|
+
publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
|
|
83
|
+
publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
|
|
84
|
+
l1TxFailedStore: config.l1TxFailedStore,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
|
|
43
89
|
...l1ReaderConfigMappings,
|
|
44
|
-
|
|
45
|
-
env:
|
|
46
|
-
description: 'The private keys to be used by the publisher.',
|
|
90
|
+
proverPublisherPrivateKeys: {
|
|
91
|
+
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
92
|
+
description: 'The private keys to be used by the prover publisher.',
|
|
47
93
|
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
48
94
|
defaultValue: [],
|
|
49
|
-
fallback: [
|
|
95
|
+
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
50
96
|
},
|
|
51
|
-
|
|
52
|
-
env:
|
|
97
|
+
proverPublisherAddresses: {
|
|
98
|
+
env: `PROVER_PUBLISHER_ADDRESSES`,
|
|
53
99
|
description: 'The addresses of the publishers to use with remote signers',
|
|
54
100
|
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
55
101
|
defaultValue: [],
|
|
56
102
|
},
|
|
57
|
-
}
|
|
103
|
+
};
|
|
58
104
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
105
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
|
|
106
|
+
...l1ReaderConfigMappings,
|
|
107
|
+
sequencerPublisherPrivateKeys: {
|
|
108
|
+
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
109
|
+
description: 'The private keys to be used by the sequencer publisher.',
|
|
110
|
+
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
111
|
+
defaultValue: [],
|
|
112
|
+
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
113
|
+
},
|
|
114
|
+
sequencerPublisherAddresses: {
|
|
115
|
+
env: `SEQ_PUBLISHER_ADDRESSES`,
|
|
116
|
+
description: 'The addresses of the publishers to use with remote signers',
|
|
117
|
+
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
118
|
+
defaultValue: [],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
62
121
|
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
122
|
+
export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
|
|
123
|
+
...l1TxUtilsConfigMappings,
|
|
124
|
+
...blobClientConfigMapping,
|
|
125
|
+
sequencerPublisherAllowInvalidStates: {
|
|
126
|
+
env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
67
127
|
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
68
|
-
env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
69
128
|
...booleanConfigHelper(true),
|
|
70
129
|
},
|
|
71
130
|
fishermanMode: {
|
|
@@ -74,15 +133,34 @@ export const getPublisherConfigMappings: (
|
|
|
74
133
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
75
134
|
...booleanConfigHelper(false),
|
|
76
135
|
},
|
|
77
|
-
|
|
78
|
-
env:
|
|
136
|
+
sequencerPublisherForwarderAddress: {
|
|
137
|
+
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
79
138
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
80
139
|
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
81
140
|
},
|
|
141
|
+
l1TxFailedStore: {
|
|
142
|
+
env: 'L1_TX_FAILED_STORE',
|
|
143
|
+
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
82
148
|
...l1TxUtilsConfigMappings,
|
|
83
149
|
...blobClientConfigMapping,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
150
|
+
proverPublisherAllowInvalidStates: {
|
|
151
|
+
env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
152
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
153
|
+
...booleanConfigHelper(true),
|
|
154
|
+
},
|
|
155
|
+
fishermanMode: {
|
|
156
|
+
env: 'FISHERMAN_MODE',
|
|
157
|
+
description:
|
|
158
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
159
|
+
...booleanConfigHelper(false),
|
|
160
|
+
},
|
|
161
|
+
proverPublisherForwarderAddress: {
|
|
162
|
+
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
163
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
164
|
+
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
165
|
+
},
|
|
166
|
+
};
|
package/src/publisher/index.ts
CHANGED
|
@@ -3,3 +3,6 @@ export { SequencerPublisherFactory } from './sequencer-publisher-factory.js';
|
|
|
3
3
|
|
|
4
4
|
// Used for tests
|
|
5
5
|
export { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
6
|
+
|
|
7
|
+
// Failed L1 tx store (optional, for test networks)
|
|
8
|
+
export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
|
|
4
|
+
import type { L1TxFailedStore } from './failed_tx_store.js';
|
|
5
|
+
import { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates an L1TxFailedStore from a config string.
|
|
9
|
+
* Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
|
|
10
|
+
* @param config - Config string (e.g., 'gs://bucket/path', 's3://bucket/path', 'file:///path'). If undefined, returns undefined.
|
|
11
|
+
* @param logger - Optional logger.
|
|
12
|
+
* @returns The store instance, or undefined if config is not provided.
|
|
13
|
+
*/
|
|
14
|
+
export async function createL1TxFailedStore(
|
|
15
|
+
config: string | undefined,
|
|
16
|
+
logger: Logger = createLogger('sequencer:l1-tx-failed-store'),
|
|
17
|
+
): Promise<L1TxFailedStore | undefined> {
|
|
18
|
+
if (!config) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fileStore = await createFileStore(config, logger);
|
|
23
|
+
if (!fileStore) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Failed to create file store from config: '${config}'. ` +
|
|
26
|
+
`Supported formats: 'gs://bucket/path', 's3://bucket/path', 'file:///path'.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
logger.info(`Created L1 tx failed store`, { config });
|
|
31
|
+
return new FileStoreL1TxFailedStore(fileStore, logger);
|
|
32
|
+
}
|