@aztec/sequencer-client 0.0.1-commit.e558bd1c → 0.0.1-commit.e588bc7e5
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 +15 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +60 -26
- package/dest/config.d.ts +26 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +47 -28
- package/dest/global_variable_builder/global_builder.d.ts +15 -11
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +29 -25
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -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 +76 -30
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +396 -71
- package/dest/sequencer/checkpoint_proposal_job.d.ts +33 -8
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +345 -172
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/events.d.ts +2 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +21 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +97 -15
- package/dest/sequencer/sequencer.d.ts +40 -17
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +145 -91
- 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 +11 -11
- 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 +27 -28
- package/src/client/sequencer-client.ts +76 -23
- package/src/config.ts +65 -38
- package/src/global_variable_builder/global_builder.ts +38 -27
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +153 -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 +442 -95
- package/src/sequencer/checkpoint_proposal_job.ts +454 -178
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +1 -1
- package/src/sequencer/metrics.ts +106 -18
- package/src/sequencer/sequencer.ts +208 -107
- 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 +63 -49
- 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,8 +19,8 @@ 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 type
|
|
22
|
-
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';
|
|
23
24
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
24
25
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
25
26
|
|
|
@@ -28,11 +29,12 @@ import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
|
28
29
|
*/
|
|
29
30
|
export class SequencerClient {
|
|
30
31
|
constructor(
|
|
31
|
-
protected publisherManager: PublisherManager<
|
|
32
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
32
33
|
protected sequencer: Sequencer,
|
|
33
34
|
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
34
35
|
protected validatorClient?: ValidatorClient,
|
|
35
36
|
private l1Metrics?: L1Metrics,
|
|
37
|
+
private delayer_?: Delayer,
|
|
36
38
|
) {}
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -62,8 +64,10 @@ export class SequencerClient {
|
|
|
62
64
|
blobClient: BlobClientInterface;
|
|
63
65
|
dateProvider: DateProvider;
|
|
64
66
|
epochCache?: EpochCache;
|
|
65
|
-
l1TxUtils:
|
|
67
|
+
l1TxUtils: L1TxUtils[];
|
|
68
|
+
funderL1TxUtils?: L1TxUtils;
|
|
66
69
|
nodeKeyStore: KeystoreManager;
|
|
70
|
+
globalVariableBuilder: GlobalVariableBuilder;
|
|
67
71
|
},
|
|
68
72
|
) {
|
|
69
73
|
const {
|
|
@@ -85,12 +89,14 @@ export class SequencerClient {
|
|
|
85
89
|
publicClient,
|
|
86
90
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
87
91
|
);
|
|
88
|
-
const publisherManager = new PublisherManager(l1TxUtils, config,
|
|
92
|
+
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
|
|
93
|
+
bindings: log.getBindings(),
|
|
94
|
+
funder: deps.funderL1TxUtils,
|
|
95
|
+
});
|
|
89
96
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
90
|
-
const [l1GenesisTime, slotDuration,
|
|
97
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
91
98
|
rollupContract.getL1GenesisTime(),
|
|
92
99
|
rollupContract.getSlotDuration(),
|
|
93
|
-
rollupContract.getVersion(),
|
|
94
100
|
rollupContract.getManaLimit().then(Number),
|
|
95
101
|
] as const);
|
|
96
102
|
|
|
@@ -107,6 +113,7 @@ export class SequencerClient {
|
|
|
107
113
|
l1ChainId: chainId,
|
|
108
114
|
viemPollingIntervalMS: config.viemPollingIntervalMS,
|
|
109
115
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
116
|
+
enableProposerPipelining: config.enableProposerPipelining,
|
|
110
117
|
},
|
|
111
118
|
{ dateProvider: deps.dateProvider },
|
|
112
119
|
));
|
|
@@ -132,17 +139,8 @@ export class SequencerClient {
|
|
|
132
139
|
});
|
|
133
140
|
|
|
134
141
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
135
|
-
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
|
|
136
142
|
|
|
137
|
-
const globalsBuilder =
|
|
138
|
-
|
|
139
|
-
let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
|
|
140
|
-
if (sequencerManaLimit > rollupManaLimit) {
|
|
141
|
-
log.warn(
|
|
142
|
-
`Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
|
|
143
|
-
);
|
|
144
|
-
sequencerManaLimit = rollupManaLimit;
|
|
145
|
-
}
|
|
143
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
146
144
|
|
|
147
145
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
148
146
|
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
@@ -152,6 +150,10 @@ export class SequencerClient {
|
|
|
152
150
|
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
153
151
|
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
154
152
|
|
|
153
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
154
|
+
|
|
155
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
|
|
156
|
+
|
|
155
157
|
const sequencer = new Sequencer(
|
|
156
158
|
publisherFactory,
|
|
157
159
|
validatorClient,
|
|
@@ -166,14 +168,17 @@ export class SequencerClient {
|
|
|
166
168
|
deps.dateProvider,
|
|
167
169
|
epochCache,
|
|
168
170
|
rollupContract,
|
|
169
|
-
{ ...config, l1PublishingTime, maxL2BlockGas
|
|
171
|
+
{ ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
|
|
170
172
|
telemetryClient,
|
|
171
173
|
log,
|
|
172
174
|
);
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
sequencer.init();
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
179
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
180
|
+
|
|
181
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
/**
|
|
@@ -191,7 +196,7 @@ export class SequencerClient {
|
|
|
191
196
|
await this.validatorClient?.start();
|
|
192
197
|
this.sequencer.start();
|
|
193
198
|
this.l1Metrics?.start();
|
|
194
|
-
await this.publisherManager.
|
|
199
|
+
await this.publisherManager.start();
|
|
195
200
|
}
|
|
196
201
|
|
|
197
202
|
/**
|
|
@@ -200,7 +205,7 @@ export class SequencerClient {
|
|
|
200
205
|
public async stop() {
|
|
201
206
|
await this.sequencer.stop();
|
|
202
207
|
await this.validatorClient?.stop();
|
|
203
|
-
this.publisherManager.
|
|
208
|
+
await this.publisherManager.stop();
|
|
204
209
|
this.l1Metrics?.stop();
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -208,6 +213,16 @@ export class SequencerClient {
|
|
|
208
213
|
return this.sequencer;
|
|
209
214
|
}
|
|
210
215
|
|
|
216
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
217
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
218
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
222
|
+
getDelayer(): Delayer | undefined {
|
|
223
|
+
return this.delayer_;
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
get validatorAddresses(): EthAddress[] | undefined {
|
|
212
227
|
return this.sequencer.getValidatorAddresses();
|
|
213
228
|
}
|
|
@@ -216,3 +231,41 @@ export class SequencerClient {
|
|
|
216
231
|
return this.sequencer.maxL2BlockGas;
|
|
217
232
|
}
|
|
218
233
|
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
237
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
238
|
+
*/
|
|
239
|
+
function capPerBlockLimits(
|
|
240
|
+
config: SequencerClientConfig,
|
|
241
|
+
rollupManaLimit: number,
|
|
242
|
+
log: ReturnType<typeof createLogger>,
|
|
243
|
+
): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
|
|
244
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
245
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
246
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
247
|
+
maxL2BlockGas = rollupManaLimit;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
251
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
252
|
+
log.warn(
|
|
253
|
+
`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
|
|
254
|
+
);
|
|
255
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
259
|
+
if (
|
|
260
|
+
maxTxsPerBlock !== undefined &&
|
|
261
|
+
config.maxTxsPerCheckpoint !== undefined &&
|
|
262
|
+
maxTxsPerBlock > config.maxTxsPerCheckpoint
|
|
263
|
+
) {
|
|
264
|
+
log.warn(
|
|
265
|
+
`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
266
|
+
);
|
|
267
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
|
|
271
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -11,59 +11,67 @@ 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 PipelineConfig,
|
|
17
|
+
type SequencerConfig,
|
|
18
|
+
chainConfigMappings,
|
|
19
|
+
pipelineConfigMappings,
|
|
20
|
+
sharedSequencerConfigMappings,
|
|
21
|
+
} from '@aztec/stdlib/config';
|
|
15
22
|
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
23
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
16
24
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
17
25
|
|
|
18
26
|
import {
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
type SequencerPublisherConfig,
|
|
28
|
+
type SequencerTxSenderConfig,
|
|
29
|
+
sequencerPublisherConfigMappings,
|
|
30
|
+
sequencerTxSenderConfigMappings,
|
|
23
31
|
} from './publisher/config.js';
|
|
24
32
|
|
|
25
33
|
export * from './publisher/config.js';
|
|
26
34
|
export type { SequencerConfig };
|
|
27
35
|
|
|
28
|
-
export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
|
|
29
|
-
|
|
30
36
|
/**
|
|
31
37
|
* Default values for SequencerConfig.
|
|
32
38
|
* Centralized location for all sequencer configuration defaults.
|
|
33
39
|
*/
|
|
34
|
-
export const DefaultSequencerConfig
|
|
40
|
+
export const DefaultSequencerConfig = {
|
|
35
41
|
sequencerPollingIntervalMS: 500,
|
|
36
|
-
maxTxsPerBlock: 32,
|
|
37
42
|
minTxsPerBlock: 1,
|
|
38
43
|
buildCheckpointIfEmpty: false,
|
|
39
44
|
publishTxsWithProposals: false,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
maxBlockSizeInBytes: 1024 * 1024,
|
|
45
|
+
perBlockAllocationMultiplier: 1.2,
|
|
46
|
+
redistributeCheckpointBudget: true,
|
|
43
47
|
enforceTimeTable: true,
|
|
44
|
-
attestationPropagationTime:
|
|
48
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
45
49
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
50
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
51
|
skipCollectingAttestations: false,
|
|
48
52
|
skipInvalidateBlockAsProposer: false,
|
|
49
53
|
broadcastInvalidBlockProposal: false,
|
|
50
54
|
injectFakeAttestation: false,
|
|
55
|
+
injectHighSValueAttestation: false,
|
|
56
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
51
57
|
fishermanMode: false,
|
|
52
58
|
shuffleAttestationOrdering: false,
|
|
53
59
|
skipPushProposedBlocksToArchiver: false,
|
|
54
|
-
|
|
60
|
+
skipPublishingCheckpointsPercent: 0,
|
|
61
|
+
} satisfies ResolvedSequencerConfig;
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
64
|
* Configuration settings for the SequencerClient.
|
|
58
65
|
*/
|
|
59
|
-
export type SequencerClientConfig =
|
|
66
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
60
67
|
KeyStoreConfig &
|
|
61
68
|
ValidatorClientConfig &
|
|
62
|
-
|
|
69
|
+
SequencerTxSenderConfig &
|
|
63
70
|
SequencerConfig &
|
|
64
71
|
L1ReaderConfig &
|
|
65
72
|
ChainConfig &
|
|
66
|
-
|
|
73
|
+
PipelineConfig &
|
|
74
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
67
75
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
68
76
|
|
|
69
77
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
@@ -72,10 +80,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
72
80
|
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
73
81
|
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
74
82
|
},
|
|
75
|
-
|
|
76
|
-
env: '
|
|
77
|
-
description: 'The maximum number of txs
|
|
78
|
-
|
|
83
|
+
maxTxsPerCheckpoint: {
|
|
84
|
+
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
85
|
+
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
86
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
79
87
|
},
|
|
80
88
|
minTxsPerBlock: {
|
|
81
89
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -94,12 +102,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
94
102
|
maxL2BlockGas: {
|
|
95
103
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
96
104
|
description: 'The maximum L2 block gas.',
|
|
97
|
-
|
|
105
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
98
106
|
},
|
|
99
107
|
maxDABlockGas: {
|
|
100
108
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
101
109
|
description: 'The maximum DA block gas.',
|
|
102
|
-
|
|
110
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
111
|
+
},
|
|
112
|
+
perBlockAllocationMultiplier: {
|
|
113
|
+
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
114
|
+
description:
|
|
115
|
+
'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
|
|
116
|
+
' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
117
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
|
|
118
|
+
},
|
|
119
|
+
redistributeCheckpointBudget: {
|
|
120
|
+
env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
|
|
121
|
+
description:
|
|
122
|
+
'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
|
|
123
|
+
...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget),
|
|
103
124
|
},
|
|
104
125
|
coinbase: {
|
|
105
126
|
env: 'COINBASE',
|
|
@@ -119,11 +140,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
119
140
|
env: 'ACVM_BINARY_PATH',
|
|
120
141
|
description: 'The path to the ACVM binary',
|
|
121
142
|
},
|
|
122
|
-
maxBlockSizeInBytes: {
|
|
123
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
124
|
-
description: 'Max block size',
|
|
125
|
-
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
126
|
-
},
|
|
127
143
|
enforceTimeTable: {
|
|
128
144
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
129
145
|
description: 'Whether to enforce the time table when building blocks',
|
|
@@ -181,6 +197,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
181
197
|
description: 'Inject a fake attestation (for testing only)',
|
|
182
198
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
183
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
|
+
},
|
|
184
208
|
fishermanMode: {
|
|
185
209
|
env: 'FISHERMAN_MODE',
|
|
186
210
|
description:
|
|
@@ -191,13 +215,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
191
215
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
192
216
|
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
193
217
|
},
|
|
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
|
-
},
|
|
218
|
+
...sharedSequencerConfigMappings,
|
|
201
219
|
buildCheckpointIfEmpty: {
|
|
202
220
|
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
203
221
|
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
@@ -207,7 +225,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
207
225
|
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
208
226
|
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
209
227
|
},
|
|
210
|
-
|
|
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']),
|
|
211
237
|
};
|
|
212
238
|
|
|
213
239
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -215,9 +241,10 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
215
241
|
...sequencerConfigMappings,
|
|
216
242
|
...keyStoreConfigMappings,
|
|
217
243
|
...l1ReaderConfigMappings,
|
|
218
|
-
...
|
|
219
|
-
...
|
|
244
|
+
...sequencerTxSenderConfigMappings,
|
|
245
|
+
...sequencerPublisherConfigMappings,
|
|
220
246
|
...chainConfigMappings,
|
|
247
|
+
...pipelineConfigMappings,
|
|
221
248
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
222
249
|
};
|
|
223
250
|
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
-
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
1
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
-
import type {
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
5
3
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
6
4
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
10
|
+
import { type L1RollupConstants, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
12
11
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
13
12
|
import type {
|
|
13
|
+
BuildCheckpointGlobalVariablesOpts,
|
|
14
14
|
CheckpointGlobalVariables,
|
|
15
15
|
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
16
|
} from '@aztec/stdlib/tx';
|
|
17
17
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
20
|
+
export type GlobalVariableBuilderConfig = {
|
|
21
|
+
l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
|
|
22
|
+
ethereumSlotDuration: number;
|
|
23
|
+
rollupVersion: bigint;
|
|
24
|
+
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Simple global variables builder.
|
|
@@ -27,7 +32,6 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
27
32
|
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
28
33
|
|
|
29
34
|
private readonly rollupContract: RollupContract;
|
|
30
|
-
private readonly publicClient: ViemPublicClient;
|
|
31
35
|
private readonly ethereumSlotDuration: number;
|
|
32
36
|
private readonly aztecSlotDuration: number;
|
|
33
37
|
private readonly l1GenesisTime: bigint;
|
|
@@ -36,28 +40,18 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
36
40
|
private version: Fr;
|
|
37
41
|
|
|
38
42
|
constructor(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
private readonly dateProvider: DateProvider,
|
|
44
|
+
private readonly publicClient: ViemPublicClient,
|
|
45
|
+
config: GlobalVariableBuilderConfig,
|
|
42
46
|
) {
|
|
43
|
-
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
44
|
-
|
|
45
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
46
|
-
|
|
47
47
|
this.version = new Fr(config.rollupVersion);
|
|
48
|
-
this.chainId = new Fr(
|
|
48
|
+
this.chainId = new Fr(this.publicClient.chain!.id);
|
|
49
49
|
|
|
50
50
|
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
51
|
this.aztecSlotDuration = config.slotDuration;
|
|
52
52
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
53
53
|
|
|
54
|
-
this.
|
|
55
|
-
chain: chain.chainInfo,
|
|
56
|
-
transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
|
|
57
|
-
pollingInterval: config.viemPollingIntervalMS,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
54
|
+
this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
/**
|
|
@@ -73,7 +67,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
73
67
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
74
68
|
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
75
69
|
);
|
|
76
|
-
const nextEthTimestamp =
|
|
70
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
71
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
72
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
73
|
+
});
|
|
77
74
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
78
75
|
|
|
79
76
|
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
@@ -108,7 +105,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
108
105
|
const slot: SlotNumber =
|
|
109
106
|
maybeSlot ??
|
|
110
107
|
(await this.rollupContract.getSlotAt(
|
|
111
|
-
|
|
108
|
+
getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
109
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
110
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
111
|
+
}),
|
|
112
112
|
));
|
|
113
113
|
|
|
114
114
|
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
@@ -120,7 +120,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
120
|
coinbase: EthAddress,
|
|
121
121
|
feeRecipient: AztecAddress,
|
|
122
122
|
slotNumber: SlotNumber,
|
|
123
|
-
|
|
123
|
+
opts?: BuildCheckpointGlobalVariablesOpts,
|
|
124
|
+
): Promise<CheckpointGlobalVariables> {
|
|
124
125
|
const { chainId, version } = this;
|
|
125
126
|
|
|
126
127
|
const timestamp = getTimestampForSlot(slotNumber, {
|
|
@@ -128,9 +129,19 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
128
129
|
l1GenesisTime: this.l1GenesisTime,
|
|
129
130
|
});
|
|
130
131
|
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
const
|
|
132
|
+
// When pipelining, force the proposed checkpoint number and fee header to the parent so that
|
|
133
|
+
// the fee computation matches what L1 will see when the previous pipelined checkpoint has landed.
|
|
134
|
+
const pendingNumberOverride = await this.rollupContract.makePendingCheckpointNumberOverride(
|
|
135
|
+
opts?.forcePendingCheckpointNumber,
|
|
136
|
+
);
|
|
137
|
+
const feeHeaderOverride = opts?.forceProposedFeeHeader
|
|
138
|
+
? await this.rollupContract.makeFeeHeaderOverride(
|
|
139
|
+
opts.forceProposedFeeHeader.checkpointNumber,
|
|
140
|
+
opts.forceProposedFeeHeader.feeHeader,
|
|
141
|
+
)
|
|
142
|
+
: [];
|
|
143
|
+
const stateOverride = RollupContract.mergeStateOverrides(pendingNumberOverride, feeHeaderOverride);
|
|
144
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
134
145
|
|
|
135
146
|
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
136
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GlobalVariableBuilder } from './global_builder.js';
|
|
1
|
+
export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';
|