@aztec/sequencer-client 0.0.1-commit.23b0eb0 → 0.0.1-commit.2448fdb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dest/client/sequencer-client.d.ts +16 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +56 -23
  4. package/dest/config.d.ts +25 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +46 -28
  7. package/dest/global_variable_builder/global_builder.d.ts +14 -10
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +22 -21
  10. package/dest/global_variable_builder/index.d.ts +2 -2
  11. package/dest/global_variable_builder/index.d.ts.map +1 -1
  12. package/dest/publisher/config.d.ts +31 -17
  13. package/dest/publisher/config.d.ts.map +1 -1
  14. package/dest/publisher/config.js +101 -42
  15. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  16. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  17. package/dest/publisher/sequencer-publisher-factory.js +13 -2
  18. package/dest/publisher/sequencer-publisher.d.ts +29 -13
  19. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  20. package/dest/publisher/sequencer-publisher.js +106 -57
  21. package/dest/sequencer/checkpoint_proposal_job.d.ts +6 -4
  22. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  23. package/dest/sequencer/checkpoint_proposal_job.js +139 -80
  24. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  25. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  26. package/dest/sequencer/checkpoint_voter.js +2 -5
  27. package/dest/sequencer/metrics.d.ts +17 -5
  28. package/dest/sequencer/metrics.d.ts.map +1 -1
  29. package/dest/sequencer/metrics.js +86 -15
  30. package/dest/sequencer/sequencer.d.ts +27 -13
  31. package/dest/sequencer/sequencer.d.ts.map +1 -1
  32. package/dest/sequencer/sequencer.js +42 -42
  33. package/dest/sequencer/timetable.d.ts +4 -6
  34. package/dest/sequencer/timetable.d.ts.map +1 -1
  35. package/dest/sequencer/timetable.js +7 -11
  36. package/dest/sequencer/types.d.ts +2 -2
  37. package/dest/sequencer/types.d.ts.map +1 -1
  38. package/dest/test/index.d.ts +3 -5
  39. package/dest/test/index.d.ts.map +1 -1
  40. package/dest/test/mock_checkpoint_builder.d.ts +11 -11
  41. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  42. package/dest/test/mock_checkpoint_builder.js +47 -34
  43. package/dest/test/utils.d.ts +3 -3
  44. package/dest/test/utils.d.ts.map +1 -1
  45. package/dest/test/utils.js +5 -4
  46. package/package.json +28 -28
  47. package/src/client/sequencer-client.ts +78 -21
  48. package/src/config.ts +61 -38
  49. package/src/global_variable_builder/global_builder.ts +23 -24
  50. package/src/global_variable_builder/index.ts +1 -1
  51. package/src/publisher/config.ts +112 -43
  52. package/src/publisher/sequencer-publisher-factory.ts +23 -6
  53. package/src/publisher/sequencer-publisher.ts +123 -71
  54. package/src/sequencer/checkpoint_proposal_job.ts +213 -109
  55. package/src/sequencer/checkpoint_voter.ts +1 -12
  56. package/src/sequencer/metrics.ts +92 -18
  57. package/src/sequencer/sequencer.ts +53 -48
  58. package/src/sequencer/timetable.ts +13 -12
  59. package/src/sequencer/types.ts +1 -1
  60. package/src/test/index.ts +2 -4
  61. package/src/test/mock_checkpoint_builder.ts +65 -49
  62. 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 { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
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 { SequencerClientConfig } from '../config.js';
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<L1TxUtilsWithBlobs>,
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,9 @@ export class SequencerClient {
62
64
  blobClient: BlobClientInterface;
63
65
  dateProvider: DateProvider;
64
66
  epochCache?: EpochCache;
65
- l1TxUtils: L1TxUtilsWithBlobs[];
67
+ l1TxUtils: L1TxUtils[];
66
68
  nodeKeyStore: KeystoreManager;
69
+ globalVariableBuilder: GlobalVariableBuilder;
67
70
  },
68
71
  ) {
69
72
  const {
@@ -85,12 +88,15 @@ export class SequencerClient {
85
88
  publicClient,
86
89
  l1TxUtils.map(x => x.getSenderAddress()),
87
90
  );
88
- const publisherManager = new PublisherManager(l1TxUtils, config, log.getBindings());
91
+ const publisherManager = new PublisherManager(
92
+ l1TxUtils,
93
+ getPublisherConfigFromSequencerConfig(config),
94
+ log.getBindings(),
95
+ );
89
96
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
90
- const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
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
 
@@ -132,17 +138,8 @@ export class SequencerClient {
132
138
  });
133
139
 
134
140
  const ethereumSlotDuration = config.ethereumSlotDuration;
135
- const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
136
-
137
- const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
138
141
 
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
- }
142
+ const globalsBuilder = deps.globalVariableBuilder;
146
143
 
147
144
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
148
145
  // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
@@ -152,6 +149,10 @@ export class SequencerClient {
152
149
  const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
153
150
  const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
154
151
 
152
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
153
+
154
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
155
+
155
156
  const sequencer = new Sequencer(
156
157
  publisherFactory,
157
158
  validatorClient,
@@ -166,14 +167,17 @@ export class SequencerClient {
166
167
  deps.dateProvider,
167
168
  epochCache,
168
169
  rollupContract,
169
- { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
170
+ { ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
170
171
  telemetryClient,
171
172
  log,
172
173
  );
173
174
 
174
- await sequencer.init();
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;
175
179
 
176
- return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
180
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
177
181
  }
178
182
 
179
183
  /**
@@ -204,10 +208,25 @@ export class SequencerClient {
204
208
  this.l1Metrics?.stop();
205
209
  }
206
210
 
211
+ /** Triggers an immediate run of the sequencer, bypassing the polling interval. */
212
+ public trigger() {
213
+ return this.sequencer.trigger();
214
+ }
215
+
207
216
  public getSequencer(): Sequencer {
208
217
  return this.sequencer;
209
218
  }
210
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
+
211
230
  get validatorAddresses(): EthAddress[] | undefined {
212
231
  return this.sequencer.getValidatorAddresses();
213
232
  }
@@ -216,3 +235,41 @@ export class SequencerClient {
216
235
  return this.sequencer.maxL2BlockGas;
217
236
  }
218
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
@@ -11,59 +11,64 @@ import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
12
12
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
- import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
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 PublisherConfig,
20
- type TxSenderConfig,
21
- getPublisherConfigMappings,
22
- getTxSenderConfigMappings,
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: ResolvedSequencerConfig = {
38
+ export const DefaultSequencerConfig = {
35
39
  sequencerPollingIntervalMS: 500,
36
- maxTxsPerBlock: 32,
37
40
  minTxsPerBlock: 1,
38
41
  buildCheckpointIfEmpty: false,
39
42
  publishTxsWithProposals: false,
40
- maxL2BlockGas: 10e9,
41
- maxDABlockGas: 10e9,
42
- maxBlockSizeInBytes: 1024 * 1024,
43
+ perBlockAllocationMultiplier: 1.2,
44
+ redistributeCheckpointBudget: true,
43
45
  enforceTimeTable: true,
44
- attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
46
+ attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
45
47
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
46
48
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
47
49
  skipCollectingAttestations: false,
48
50
  skipInvalidateBlockAsProposer: false,
49
51
  broadcastInvalidBlockProposal: false,
50
52
  injectFakeAttestation: false,
53
+ injectHighSValueAttestation: false,
54
+ injectUnrecoverableSignatureAttestation: false,
51
55
  fishermanMode: false,
52
56
  shuffleAttestationOrdering: false,
53
57
  skipPushProposedBlocksToArchiver: false,
54
- };
58
+ skipPublishingCheckpointsPercent: 0,
59
+ } satisfies ResolvedSequencerConfig;
55
60
 
56
61
  /**
57
62
  * Configuration settings for the SequencerClient.
58
63
  */
59
- export type SequencerClientConfig = PublisherConfig &
64
+ export type SequencerClientConfig = SequencerPublisherConfig &
60
65
  KeyStoreConfig &
61
66
  ValidatorClientConfig &
62
- TxSenderConfig &
67
+ SequencerTxSenderConfig &
63
68
  SequencerConfig &
64
69
  L1ReaderConfig &
65
70
  ChainConfig &
66
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
71
+ Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
67
72
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
68
73
 
69
74
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
@@ -72,10 +77,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
72
77
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
73
78
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
74
79
  },
75
- maxTxsPerBlock: {
76
- env: 'SEQ_MAX_TX_PER_BLOCK',
77
- description: 'The maximum number of txs to include in a block.',
78
- ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
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),
79
84
  },
80
85
  minTxsPerBlock: {
81
86
  env: 'SEQ_MIN_TX_PER_BLOCK',
@@ -94,12 +99,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
94
99
  maxL2BlockGas: {
95
100
  env: 'SEQ_MAX_L2_BLOCK_GAS',
96
101
  description: 'The maximum L2 block gas.',
97
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
102
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
98
103
  },
99
104
  maxDABlockGas: {
100
105
  env: 'SEQ_MAX_DA_BLOCK_GAS',
101
106
  description: 'The maximum DA block gas.',
102
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
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),
103
121
  },
104
122
  coinbase: {
105
123
  env: 'COINBASE',
@@ -119,11 +137,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
119
137
  env: 'ACVM_BINARY_PATH',
120
138
  description: 'The path to the ACVM binary',
121
139
  },
122
- maxBlockSizeInBytes: {
123
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
124
- description: 'Max block size',
125
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
126
- },
127
140
  enforceTimeTable: {
128
141
  env: 'SEQ_ENFORCE_TIME_TABLE',
129
142
  description: 'Whether to enforce the time table when building blocks',
@@ -181,6 +194,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
181
194
  description: 'Inject a fake attestation (for testing only)',
182
195
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
183
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),
204
+ },
184
205
  fishermanMode: {
185
206
  env: 'FISHERMAN_MODE',
186
207
  description:
@@ -191,13 +212,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
191
212
  description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
192
213
  ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
193
214
  },
194
- blockDurationMs: {
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
- },
215
+ ...sharedSequencerConfigMappings,
201
216
  buildCheckpointIfEmpty: {
202
217
  env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
203
218
  description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
@@ -207,7 +222,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
207
222
  description: 'Skip pushing proposed blocks to archiver (default: true)',
208
223
  ...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
209
224
  },
210
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
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),
232
+ },
233
+ ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
211
234
  };
212
235
 
213
236
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
@@ -215,8 +238,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
215
238
  ...sequencerConfigMappings,
216
239
  ...keyStoreConfigMappings,
217
240
  ...l1ReaderConfigMappings,
218
- ...getTxSenderConfigMappings('SEQ'),
219
- ...getPublisherConfigMappings('SEQ'),
241
+ ...sequencerTxSenderConfigMappings,
242
+ ...sequencerPublisherConfigMappings,
220
243
  ...chainConfigMappings,
221
244
  ...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
222
245
  };
@@ -1,14 +1,13 @@
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 { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
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 {
14
13
  CheckpointGlobalVariables,
@@ -16,7 +15,12 @@ import type {
16
15
  } from '@aztec/stdlib/tx';
17
16
  import { GlobalVariables } from '@aztec/stdlib/tx';
18
17
 
19
- import { createPublicClient, fallback, http } from 'viem';
18
+ /** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
19
+ export type GlobalVariableBuilderConfig = {
20
+ l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
21
+ ethereumSlotDuration: number;
22
+ rollupVersion: bigint;
23
+ } & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
20
24
 
21
25
  /**
22
26
  * Simple global variables builder.
@@ -27,7 +31,6 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
27
31
  private currentL1BlockNumber: bigint | undefined = undefined;
28
32
 
29
33
  private readonly rollupContract: RollupContract;
30
- private readonly publicClient: ViemPublicClient;
31
34
  private readonly ethereumSlotDuration: number;
32
35
  private readonly aztecSlotDuration: number;
33
36
  private readonly l1GenesisTime: bigint;
@@ -36,28 +39,18 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
36
39
  private version: Fr;
37
40
 
38
41
  constructor(
39
- config: L1ReaderConfig &
40
- Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
41
- Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
42
+ private readonly dateProvider: DateProvider,
43
+ private readonly publicClient: ViemPublicClient,
44
+ config: GlobalVariableBuilderConfig,
42
45
  ) {
43
- const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
44
-
45
- const chain = createEthereumChain(l1RpcUrls, chainId);
46
-
47
46
  this.version = new Fr(config.rollupVersion);
48
- this.chainId = new Fr(chainId);
47
+ this.chainId = new Fr(this.publicClient.chain!.id);
49
48
 
50
49
  this.ethereumSlotDuration = config.ethereumSlotDuration;
51
50
  this.aztecSlotDuration = config.slotDuration;
52
51
  this.l1GenesisTime = config.l1GenesisTime;
53
52
 
54
- this.publicClient = createPublicClient({
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);
53
+ this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
61
54
  }
62
55
 
63
56
  /**
@@ -73,7 +66,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
73
66
  const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
74
67
  SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
75
68
  );
76
- const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
69
+ const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
70
+ l1GenesisTime: this.l1GenesisTime,
71
+ ethereumSlotDuration: this.ethereumSlotDuration,
72
+ });
77
73
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
78
74
 
79
75
  return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
@@ -108,7 +104,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
108
104
  const slot: SlotNumber =
109
105
  maybeSlot ??
110
106
  (await this.rollupContract.getSlotAt(
111
- BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
107
+ getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
108
+ l1GenesisTime: this.l1GenesisTime,
109
+ ethereumSlotDuration: this.ethereumSlotDuration,
110
+ }),
112
111
  ));
113
112
 
114
113
  const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
@@ -120,7 +119,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
120
119
  coinbase: EthAddress,
121
120
  feeRecipient: AztecAddress,
122
121
  slotNumber: SlotNumber,
123
- ): Promise<CheckpointGlobalVariables & { timestamp: bigint }> {
122
+ ): Promise<CheckpointGlobalVariables> {
124
123
  const { chainId, version } = this;
125
124
 
126
125
  const timestamp = getTimestampForSlot(slotNumber, {
@@ -1 +1 @@
1
- export { GlobalVariableBuilder } from './global_builder.js';
1
+ export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';