@aztec/sequencer-client 0.0.1-commit.5476d83 → 0.0.1-commit.5914bae
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 +25 -16
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +69 -29
- package/dest/config.d.ts +34 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +105 -44
- package/dest/global_variable_builder/global_builder.d.ts +27 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +65 -54
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +37 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +104 -39
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +14 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +76 -53
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +691 -169
- package/dest/sequencer/checkpoint_proposal_job.d.ts +102 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1247 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +106 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +38 -6
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +216 -72
- package/dest/sequencer/sequencer.d.ts +125 -133
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +733 -640
- package/dest/sequencer/timetable.d.ts +54 -16
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +147 -62
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +6 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +233 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +104 -0
- package/package.json +32 -30
- package/src/client/sequencer-client.ts +99 -53
- package/src/config.ts +121 -54
- package/src/global_variable_builder/global_builder.ts +76 -73
- package/src/global_variable_builder/index.ts +1 -1
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +122 -50
- package/src/publisher/sequencer-publisher-factory.ts +28 -10
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +406 -215
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +976 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +268 -82
- package/src/sequencer/sequencer.ts +481 -845
- package/src/sequencer/timetable.ts +178 -83
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +5 -6
- package/src/test/mock_checkpoint_builder.ts +325 -0
- package/src/test/utils.ts +167 -0
- package/dest/sequencer/block_builder.d.ts +0 -27
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -222
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -132
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
isAnvilTestChain,
|
|
9
|
-
} from '@aztec/ethereum';
|
|
10
|
-
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
4
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
5
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
6
|
+
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
8
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
11
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
11
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
14
12
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
15
13
|
import type { P2P } from '@aztec/p2p';
|
|
16
14
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
17
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
18
|
-
import type {
|
|
19
|
-
IFullNodeBlockBuilder,
|
|
20
|
-
ValidatorClientFullConfig,
|
|
21
|
-
WorldStateSynchronizer,
|
|
22
|
-
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
+
import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
16
|
+
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
23
17
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
24
18
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
25
19
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
26
|
-
import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
20
|
+
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
27
21
|
|
|
28
|
-
import type
|
|
29
|
-
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
22
|
+
import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
|
|
23
|
+
import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
30
24
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
31
25
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
32
26
|
|
|
@@ -35,11 +29,12 @@ import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
|
35
29
|
*/
|
|
36
30
|
export class SequencerClient {
|
|
37
31
|
constructor(
|
|
38
|
-
protected publisherManager: PublisherManager<
|
|
32
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
39
33
|
protected sequencer: Sequencer,
|
|
40
|
-
protected
|
|
34
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
41
35
|
protected validatorClient?: ValidatorClient,
|
|
42
36
|
private l1Metrics?: L1Metrics,
|
|
37
|
+
private delayer_?: Delayer,
|
|
43
38
|
) {}
|
|
44
39
|
|
|
45
40
|
/**
|
|
@@ -57,20 +52,21 @@ export class SequencerClient {
|
|
|
57
52
|
public static async new(
|
|
58
53
|
config: SequencerClientConfig,
|
|
59
54
|
deps: {
|
|
60
|
-
validatorClient: ValidatorClient
|
|
55
|
+
validatorClient: ValidatorClient;
|
|
61
56
|
p2pClient: P2P;
|
|
62
57
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
63
58
|
slasherClient: SlasherClientInterface | undefined;
|
|
64
|
-
|
|
65
|
-
l2BlockSource: L2BlockSource;
|
|
59
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
60
|
+
l2BlockSource: L2BlockSource & L2BlockSink;
|
|
66
61
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
67
62
|
telemetry: TelemetryClient;
|
|
68
63
|
publisherFactory?: SequencerPublisherFactory;
|
|
69
|
-
|
|
64
|
+
blobClient: BlobClientInterface;
|
|
70
65
|
dateProvider: DateProvider;
|
|
71
66
|
epochCache?: EpochCache;
|
|
72
|
-
l1TxUtils:
|
|
67
|
+
l1TxUtils: L1TxUtils[];
|
|
73
68
|
nodeKeyStore: KeystoreManager;
|
|
69
|
+
globalVariableBuilder: GlobalVariableBuilder;
|
|
74
70
|
},
|
|
75
71
|
) {
|
|
76
72
|
const {
|
|
@@ -78,7 +74,7 @@ export class SequencerClient {
|
|
|
78
74
|
p2pClient,
|
|
79
75
|
worldStateSynchronizer,
|
|
80
76
|
slasherClient,
|
|
81
|
-
|
|
77
|
+
checkpointsBuilder,
|
|
82
78
|
l2BlockSource,
|
|
83
79
|
l1ToL2MessageSource,
|
|
84
80
|
telemetry: telemetryClient,
|
|
@@ -92,11 +88,16 @@ export class SequencerClient {
|
|
|
92
88
|
publicClient,
|
|
93
89
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
94
90
|
);
|
|
95
|
-
const publisherManager = new PublisherManager(
|
|
91
|
+
const publisherManager = new PublisherManager(
|
|
92
|
+
l1TxUtils,
|
|
93
|
+
getPublisherConfigFromSequencerConfig(config),
|
|
94
|
+
log.getBindings(),
|
|
95
|
+
);
|
|
96
96
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
97
|
-
const [l1GenesisTime, slotDuration] = await Promise.all([
|
|
97
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
98
98
|
rollupContract.getL1GenesisTime(),
|
|
99
99
|
rollupContract.getSlotDuration(),
|
|
100
|
+
rollupContract.getManaLimit().then(Number),
|
|
100
101
|
] as const);
|
|
101
102
|
|
|
102
103
|
const governanceProposerContract = new GovernanceProposerContract(
|
|
@@ -125,7 +126,7 @@ export class SequencerClient {
|
|
|
125
126
|
deps.publisherFactory ??
|
|
126
127
|
new SequencerPublisherFactory(config, {
|
|
127
128
|
telemetry: telemetryClient,
|
|
128
|
-
|
|
129
|
+
blobClient: deps.blobClient,
|
|
129
130
|
epochCache,
|
|
130
131
|
governanceProposerContract,
|
|
131
132
|
slashFactoryContract,
|
|
@@ -135,33 +136,22 @@ export class SequencerClient {
|
|
|
135
136
|
nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
|
|
136
137
|
logger: log,
|
|
137
138
|
});
|
|
138
|
-
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
139
139
|
|
|
140
140
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
141
141
|
|
|
142
|
-
const
|
|
143
|
-
let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
|
|
144
|
-
if (sequencerManaLimit > rollupManaLimit) {
|
|
145
|
-
log.warn(
|
|
146
|
-
`Provided maxL2BlockGas of ${sequencerManaLimit} is greater than the maximum allowed by the L1 (${rollupManaLimit}), setting limit to ${rollupManaLimit}`,
|
|
147
|
-
);
|
|
148
|
-
sequencerManaLimit = rollupManaLimit;
|
|
149
|
-
}
|
|
142
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
150
143
|
|
|
151
144
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
152
|
-
// Otherwise,
|
|
153
|
-
// maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
|
|
145
|
+
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
154
146
|
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
155
|
-
//
|
|
147
|
+
// reduce the publishing time allowance. However, we prefer being conservative.
|
|
156
148
|
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
157
|
-
const
|
|
158
|
-
const
|
|
149
|
+
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
150
|
+
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
151
|
+
|
|
152
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
159
153
|
|
|
160
|
-
const l1Constants = {
|
|
161
|
-
l1GenesisTime,
|
|
162
|
-
slotDuration: Number(slotDuration),
|
|
163
|
-
ethereumSlotDuration,
|
|
164
|
-
};
|
|
154
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
|
|
165
155
|
|
|
166
156
|
const sequencer = new Sequencer(
|
|
167
157
|
publisherFactory,
|
|
@@ -172,19 +162,22 @@ export class SequencerClient {
|
|
|
172
162
|
slasherClient,
|
|
173
163
|
l2BlockSource,
|
|
174
164
|
l1ToL2MessageSource,
|
|
175
|
-
|
|
165
|
+
checkpointsBuilder,
|
|
176
166
|
l1Constants,
|
|
177
167
|
deps.dateProvider,
|
|
178
168
|
epochCache,
|
|
179
169
|
rollupContract,
|
|
180
|
-
{ ...config,
|
|
170
|
+
{ ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
|
|
181
171
|
telemetryClient,
|
|
182
172
|
log,
|
|
183
173
|
);
|
|
184
174
|
|
|
185
|
-
|
|
175
|
+
sequencer.init();
|
|
176
|
+
|
|
177
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
178
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
186
179
|
|
|
187
|
-
return new SequencerClient(publisherManager, sequencer,
|
|
180
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
188
181
|
}
|
|
189
182
|
|
|
190
183
|
/**
|
|
@@ -193,7 +186,7 @@ export class SequencerClient {
|
|
|
193
186
|
*/
|
|
194
187
|
public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
|
|
195
188
|
this.sequencer.updateConfig(config);
|
|
196
|
-
this.
|
|
189
|
+
this.checkpointsBuilder.updateConfig(config);
|
|
197
190
|
this.validatorClient?.updateConfig(config);
|
|
198
191
|
}
|
|
199
192
|
|
|
@@ -215,10 +208,25 @@ export class SequencerClient {
|
|
|
215
208
|
this.l1Metrics?.stop();
|
|
216
209
|
}
|
|
217
210
|
|
|
211
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */
|
|
212
|
+
public trigger() {
|
|
213
|
+
return this.sequencer.trigger();
|
|
214
|
+
}
|
|
215
|
+
|
|
218
216
|
public getSequencer(): Sequencer {
|
|
219
217
|
return this.sequencer;
|
|
220
218
|
}
|
|
221
219
|
|
|
220
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
221
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
222
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
226
|
+
getDelayer(): Delayer | undefined {
|
|
227
|
+
return this.delayer_;
|
|
228
|
+
}
|
|
229
|
+
|
|
222
230
|
get validatorAddresses(): EthAddress[] | undefined {
|
|
223
231
|
return this.sequencer.getValidatorAddresses();
|
|
224
232
|
}
|
|
@@ -227,3 +235,41 @@ export class SequencerClient {
|
|
|
227
235
|
return this.sequencer.maxL2BlockGas;
|
|
228
236
|
}
|
|
229
237
|
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
241
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
242
|
+
*/
|
|
243
|
+
function capPerBlockLimits(
|
|
244
|
+
config: SequencerClientConfig,
|
|
245
|
+
rollupManaLimit: number,
|
|
246
|
+
log: ReturnType<typeof createLogger>,
|
|
247
|
+
): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
|
|
248
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
249
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
250
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
251
|
+
maxL2BlockGas = rollupManaLimit;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
255
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
256
|
+
log.warn(
|
|
257
|
+
`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
|
|
258
|
+
);
|
|
259
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
263
|
+
if (
|
|
264
|
+
maxTxsPerBlock !== undefined &&
|
|
265
|
+
config.maxTxsPerCheckpoint !== undefined &&
|
|
266
|
+
maxTxsPerBlock > config.maxTxsPerCheckpoint
|
|
267
|
+
) {
|
|
268
|
+
log.warn(
|
|
269
|
+
`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
270
|
+
);
|
|
271
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
|
|
275
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type L1ReaderConfig,
|
|
4
|
-
l1ContractsConfigMappings,
|
|
5
|
-
l1ReaderConfigMappings,
|
|
6
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
7
3
|
import {
|
|
8
4
|
type ConfigMappingsType,
|
|
9
5
|
booleanConfigHelper,
|
|
@@ -12,67 +8,116 @@ import {
|
|
|
12
8
|
pickConfigMappings,
|
|
13
9
|
} from '@aztec/foundation/config';
|
|
14
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore';
|
|
16
|
-
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p';
|
|
11
|
+
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
|
+
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
17
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
18
|
-
import {
|
|
19
|
-
|
|
14
|
+
import {
|
|
15
|
+
type ChainConfig,
|
|
16
|
+
type SequencerConfig,
|
|
17
|
+
chainConfigMappings,
|
|
18
|
+
sharedSequencerConfigMappings,
|
|
19
|
+
} from '@aztec/stdlib/config';
|
|
20
|
+
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
21
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
22
|
+
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
20
23
|
|
|
21
24
|
import {
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
type SequencerPublisherConfig,
|
|
26
|
+
type SequencerTxSenderConfig,
|
|
27
|
+
sequencerPublisherConfigMappings,
|
|
28
|
+
sequencerTxSenderConfigMappings,
|
|
26
29
|
} from './publisher/config.js';
|
|
27
30
|
|
|
28
31
|
export * from './publisher/config.js';
|
|
29
32
|
export type { SequencerConfig };
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Default values for SequencerConfig.
|
|
36
|
+
* Centralized location for all sequencer configuration defaults.
|
|
37
|
+
*/
|
|
38
|
+
export const DefaultSequencerConfig = {
|
|
39
|
+
sequencerPollingIntervalMS: 500,
|
|
40
|
+
minTxsPerBlock: 1,
|
|
41
|
+
buildCheckpointIfEmpty: false,
|
|
42
|
+
publishTxsWithProposals: false,
|
|
43
|
+
perBlockAllocationMultiplier: 1.2,
|
|
44
|
+
redistributeCheckpointBudget: true,
|
|
45
|
+
enforceTimeTable: true,
|
|
46
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
47
|
+
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
48
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
49
|
+
skipCollectingAttestations: false,
|
|
50
|
+
skipInvalidateBlockAsProposer: false,
|
|
51
|
+
broadcastInvalidBlockProposal: false,
|
|
52
|
+
injectFakeAttestation: false,
|
|
53
|
+
injectHighSValueAttestation: false,
|
|
54
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
55
|
+
fishermanMode: false,
|
|
56
|
+
shuffleAttestationOrdering: false,
|
|
57
|
+
skipPushProposedBlocksToArchiver: false,
|
|
58
|
+
skipPublishingCheckpointsPercent: 0,
|
|
59
|
+
} satisfies ResolvedSequencerConfig;
|
|
32
60
|
|
|
33
61
|
/**
|
|
34
62
|
* Configuration settings for the SequencerClient.
|
|
35
63
|
*/
|
|
36
|
-
export type SequencerClientConfig =
|
|
64
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
37
65
|
KeyStoreConfig &
|
|
38
66
|
ValidatorClientConfig &
|
|
39
|
-
|
|
67
|
+
SequencerTxSenderConfig &
|
|
40
68
|
SequencerConfig &
|
|
41
69
|
L1ReaderConfig &
|
|
42
70
|
ChainConfig &
|
|
43
|
-
Pick<P2PConfig, '
|
|
71
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
44
72
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
45
73
|
|
|
46
74
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
47
|
-
|
|
48
|
-
env: '
|
|
49
|
-
description: 'The number of ms to wait between polling for
|
|
50
|
-
...numberConfigHelper(
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
env: '
|
|
54
|
-
description: 'The maximum number of txs
|
|
55
|
-
|
|
75
|
+
sequencerPollingIntervalMS: {
|
|
76
|
+
env: 'SEQ_POLLING_INTERVAL_MS',
|
|
77
|
+
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
78
|
+
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
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),
|
|
56
84
|
},
|
|
57
85
|
minTxsPerBlock: {
|
|
58
86
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
59
87
|
description: 'The minimum number of txs to include in a block.',
|
|
60
|
-
...numberConfigHelper(
|
|
88
|
+
...numberConfigHelper(DefaultSequencerConfig.minTxsPerBlock),
|
|
89
|
+
},
|
|
90
|
+
minValidTxsPerBlock: {
|
|
91
|
+
description:
|
|
92
|
+
'The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock.',
|
|
61
93
|
},
|
|
62
94
|
publishTxsWithProposals: {
|
|
63
95
|
env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
|
|
64
96
|
description: 'Whether to publish txs with proposals.',
|
|
65
|
-
...booleanConfigHelper(
|
|
97
|
+
...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
|
|
66
98
|
},
|
|
67
99
|
maxL2BlockGas: {
|
|
68
100
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
69
101
|
description: 'The maximum L2 block gas.',
|
|
70
|
-
|
|
102
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
71
103
|
},
|
|
72
104
|
maxDABlockGas: {
|
|
73
105
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
74
106
|
description: 'The maximum DA block gas.',
|
|
75
|
-
|
|
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),
|
|
76
121
|
},
|
|
77
122
|
coinbase: {
|
|
78
123
|
env: 'COINBASE',
|
|
@@ -92,78 +137,100 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
92
137
|
env: 'ACVM_BINARY_PATH',
|
|
93
138
|
description: 'The path to the ACVM binary',
|
|
94
139
|
},
|
|
95
|
-
maxBlockSizeInBytes: {
|
|
96
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
97
|
-
description: 'Max block size',
|
|
98
|
-
...numberConfigHelper(1024 * 1024),
|
|
99
|
-
},
|
|
100
140
|
enforceTimeTable: {
|
|
101
141
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
102
142
|
description: 'Whether to enforce the time table when building blocks',
|
|
103
|
-
...booleanConfigHelper(),
|
|
104
|
-
defaultValue: true,
|
|
143
|
+
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
|
|
105
144
|
},
|
|
106
145
|
governanceProposerPayload: {
|
|
107
146
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
108
147
|
description: 'The address of the payload for the governanceProposer',
|
|
109
148
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
110
|
-
defaultValue: EthAddress.ZERO,
|
|
111
149
|
},
|
|
112
|
-
|
|
113
|
-
env: '
|
|
114
|
-
description: 'How
|
|
150
|
+
l1PublishingTime: {
|
|
151
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
152
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
115
153
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
116
154
|
},
|
|
117
155
|
attestationPropagationTime: {
|
|
118
156
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
119
157
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
120
|
-
...numberConfigHelper(
|
|
158
|
+
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
121
159
|
},
|
|
122
160
|
fakeProcessingDelayPerTxMs: {
|
|
123
161
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
124
162
|
},
|
|
163
|
+
fakeThrowAfterProcessingTxCount: {
|
|
164
|
+
description: 'Used for testing to throw an error after processing N txs',
|
|
165
|
+
},
|
|
125
166
|
secondsBeforeInvalidatingBlockAsCommitteeMember: {
|
|
126
167
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
|
|
127
168
|
description:
|
|
128
169
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
|
|
129
170
|
' The next proposer is expected to invalidate, so the committee acts as a fallback.',
|
|
130
|
-
...numberConfigHelper(
|
|
171
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
|
|
131
172
|
},
|
|
132
173
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
|
|
133
174
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
|
|
134
175
|
description:
|
|
135
176
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a non-committee member (zero to never invalidate).' +
|
|
136
177
|
' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
|
|
137
|
-
...numberConfigHelper(
|
|
178
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
|
|
138
179
|
},
|
|
139
180
|
skipCollectingAttestations: {
|
|
140
181
|
description:
|
|
141
182
|
'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
|
|
142
|
-
...booleanConfigHelper(
|
|
183
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
|
|
143
184
|
},
|
|
144
185
|
skipInvalidateBlockAsProposer: {
|
|
145
186
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
146
|
-
...booleanConfigHelper(
|
|
187
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
147
188
|
},
|
|
148
189
|
broadcastInvalidBlockProposal: {
|
|
149
190
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
150
|
-
...booleanConfigHelper(
|
|
191
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
151
192
|
},
|
|
152
193
|
injectFakeAttestation: {
|
|
153
194
|
description: 'Inject a fake attestation (for testing only)',
|
|
154
|
-
...booleanConfigHelper(
|
|
195
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
196
|
+
},
|
|
197
|
+
injectHighSValueAttestation: {
|
|
198
|
+
description: 'Inject a malleable attestation with a high-s value (for testing only)',
|
|
199
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
|
|
200
|
+
},
|
|
201
|
+
injectUnrecoverableSignatureAttestation: {
|
|
202
|
+
description: 'Inject an attestation with an unrecoverable signature (for testing only)',
|
|
203
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
|
|
155
204
|
},
|
|
156
205
|
fishermanMode: {
|
|
157
206
|
env: 'FISHERMAN_MODE',
|
|
158
207
|
description:
|
|
159
208
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
160
|
-
...booleanConfigHelper(
|
|
209
|
+
...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
|
|
161
210
|
},
|
|
162
211
|
shuffleAttestationOrdering: {
|
|
163
212
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
164
|
-
...booleanConfigHelper(
|
|
213
|
+
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
214
|
+
},
|
|
215
|
+
...sharedSequencerConfigMappings,
|
|
216
|
+
buildCheckpointIfEmpty: {
|
|
217
|
+
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
218
|
+
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
219
|
+
...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
|
|
220
|
+
},
|
|
221
|
+
skipPushProposedBlocksToArchiver: {
|
|
222
|
+
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
223
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
224
|
+
},
|
|
225
|
+
minBlocksForCheckpoint: {
|
|
226
|
+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
|
|
227
|
+
},
|
|
228
|
+
skipPublishingCheckpointsPercent: {
|
|
229
|
+
env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
|
|
230
|
+
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
231
|
+
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
165
232
|
},
|
|
166
|
-
...pickConfigMappings(p2pConfigMappings, ['
|
|
233
|
+
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
167
234
|
};
|
|
168
235
|
|
|
169
236
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -171,8 +238,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
171
238
|
...sequencerConfigMappings,
|
|
172
239
|
...keyStoreConfigMappings,
|
|
173
240
|
...l1ReaderConfigMappings,
|
|
174
|
-
...
|
|
175
|
-
...
|
|
241
|
+
...sequencerTxSenderConfigMappings,
|
|
242
|
+
...sequencerPublisherConfigMappings,
|
|
176
243
|
...chainConfigMappings,
|
|
177
244
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
178
245
|
};
|