@aztec/sequencer-client 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949

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 (80) hide show
  1. package/dest/client/sequencer-client.d.ts +15 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +60 -26
  4. package/dest/config.d.ts +26 -7
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +47 -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 +47 -17
  13. package/dest/publisher/config.d.ts.map +1 -1
  14. package/dest/publisher/config.js +121 -42
  15. package/dest/publisher/index.d.ts +2 -1
  16. package/dest/publisher/index.d.ts.map +1 -1
  17. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  20. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  23. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  26. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  28. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  29. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  30. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  31. package/dest/publisher/sequencer-publisher-factory.js +27 -2
  32. package/dest/publisher/sequencer-publisher.d.ts +33 -10
  33. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  34. package/dest/publisher/sequencer-publisher.js +371 -57
  35. package/dest/sequencer/checkpoint_proposal_job.d.ts +39 -10
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  37. package/dest/sequencer/checkpoint_proposal_job.js +287 -167
  38. package/dest/sequencer/events.d.ts +2 -1
  39. package/dest/sequencer/events.d.ts.map +1 -1
  40. package/dest/sequencer/metrics.d.ts +21 -5
  41. package/dest/sequencer/metrics.d.ts.map +1 -1
  42. package/dest/sequencer/metrics.js +97 -15
  43. package/dest/sequencer/sequencer.d.ts +30 -15
  44. package/dest/sequencer/sequencer.d.ts.map +1 -1
  45. package/dest/sequencer/sequencer.js +95 -82
  46. package/dest/sequencer/timetable.d.ts +4 -6
  47. package/dest/sequencer/timetable.d.ts.map +1 -1
  48. package/dest/sequencer/timetable.js +7 -11
  49. package/dest/sequencer/types.d.ts +2 -2
  50. package/dest/sequencer/types.d.ts.map +1 -1
  51. package/dest/test/index.d.ts +3 -5
  52. package/dest/test/index.d.ts.map +1 -1
  53. package/dest/test/mock_checkpoint_builder.d.ts +12 -12
  54. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  55. package/dest/test/mock_checkpoint_builder.js +45 -36
  56. package/dest/test/utils.d.ts +3 -3
  57. package/dest/test/utils.d.ts.map +1 -1
  58. package/dest/test/utils.js +5 -4
  59. package/package.json +27 -28
  60. package/src/client/sequencer-client.ts +76 -23
  61. package/src/config.ts +65 -38
  62. package/src/global_variable_builder/global_builder.ts +23 -24
  63. package/src/global_variable_builder/index.ts +1 -1
  64. package/src/publisher/config.ts +153 -43
  65. package/src/publisher/index.ts +3 -0
  66. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  67. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  68. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  69. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  70. package/src/publisher/sequencer-publisher-factory.ts +38 -6
  71. package/src/publisher/sequencer-publisher.ts +371 -70
  72. package/src/sequencer/checkpoint_proposal_job.ts +392 -193
  73. package/src/sequencer/events.ts +1 -1
  74. package/src/sequencer/metrics.ts +106 -18
  75. package/src/sequencer/sequencer.ts +131 -94
  76. package/src/sequencer/timetable.ts +13 -12
  77. package/src/sequencer/types.ts +1 -1
  78. package/src/test/index.ts +2 -4
  79. package/src/test/mock_checkpoint_builder.ts +65 -53
  80. package/src/test/utils.ts +5 -2
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 { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
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 PublisherConfig,
20
- type TxSenderConfig,
21
- getPublisherConfigMappings,
22
- getTxSenderConfigMappings,
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: ResolvedSequencerConfig = {
40
+ export const DefaultSequencerConfig = {
35
41
  sequencerPollingIntervalMS: 500,
36
- maxTxsPerBlock: 32,
37
42
  minTxsPerBlock: 1,
38
43
  buildCheckpointIfEmpty: false,
39
44
  publishTxsWithProposals: false,
40
- maxL2BlockGas: 10e9,
41
- maxDABlockGas: 10e9,
42
- maxBlockSizeInBytes: 1024 * 1024,
45
+ perBlockAllocationMultiplier: 1.2,
46
+ redistributeCheckpointBudget: true,
43
47
  enforceTimeTable: true,
44
- attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
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 = PublisherConfig &
66
+ export type SequencerClientConfig = SequencerPublisherConfig &
60
67
  KeyStoreConfig &
61
68
  ValidatorClientConfig &
62
- TxSenderConfig &
69
+ SequencerTxSenderConfig &
63
70
  SequencerConfig &
64
71
  L1ReaderConfig &
65
72
  ChainConfig &
66
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
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
- maxTxsPerBlock: {
76
- env: 'SEQ_MAX_TX_PER_BLOCK',
77
- description: 'The maximum number of txs to include in a block.',
78
- ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
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
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
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
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
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
- 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
- },
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
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
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
- ...getTxSenderConfigMappings('SEQ'),
219
- ...getPublisherConfigMappings('SEQ'),
244
+ ...sequencerTxSenderConfigMappings,
245
+ ...sequencerPublisherConfigMappings,
220
246
  ...chainConfigMappings,
247
+ ...pipelineConfigMappings,
221
248
  ...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
222
249
  };
223
250
 
@@ -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';
@@ -1,32 +1,47 @@
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
+ import { parseEther } from 'viem';
8
+
9
+ /** Configuration of the transaction publisher. */
15
10
  export type TxSenderConfig = L1ReaderConfig & {
16
- /**
17
- * The private key to be used by the publisher.
18
- */
11
+ /** The private key to be used by the publisher. */
19
12
  publisherPrivateKeys?: SecretValue<`0x${string}`>[];
20
13
 
21
- /**
22
- * Publisher addresses to be used with a remote signer
23
- */
14
+ /** Publisher addresses to be used with a remote signer */
24
15
  publisherAddresses?: EthAddress[];
25
16
  };
26
17
 
27
- /**
28
- * Configuration of the L1Publisher.
29
- */
18
+ export type ProverTxSenderConfig = L1ReaderConfig & {
19
+ proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
20
+ proverPublisherAddresses?: EthAddress[];
21
+ };
22
+
23
+ export type SequencerTxSenderConfig = L1ReaderConfig & {
24
+ sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
25
+ sequencerPublisherAddresses?: EthAddress[];
26
+ };
27
+
28
+ export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
29
+ return {
30
+ ...config,
31
+ publisherPrivateKeys: config.proverPublisherPrivateKeys,
32
+ publisherAddresses: config.proverPublisherAddresses,
33
+ };
34
+ }
35
+
36
+ export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
37
+ return {
38
+ ...config,
39
+ publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
40
+ publisherAddresses: config.sequencerPublisherAddresses,
41
+ };
42
+ }
43
+
44
+ /** Configuration of the L1Publisher. */
30
45
  export type PublisherConfig = L1TxUtilsConfig &
31
46
  BlobClientConfig & {
32
47
  /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
@@ -35,37 +50,111 @@ export type PublisherConfig = L1TxUtilsConfig &
35
50
  fishermanMode?: boolean;
36
51
  /** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
37
52
  publisherForwarderAddress?: EthAddress;
53
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
54
+ l1TxFailedStore?: string;
55
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
56
+ publisherFundingThreshold?: bigint;
57
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
58
+ publisherFundingAmount?: bigint;
38
59
  };
39
60
 
40
- export const getTxSenderConfigMappings: (
41
- scope: 'PROVER' | 'SEQ',
42
- ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
61
+ /** Shared config mappings for publisher funding, used by both sequencer and prover publisher configs. */
62
+ const publisherFundingConfigMappings = {
63
+ publisherFundingThreshold: {
64
+ env: 'PUBLISHER_FUNDING_THRESHOLD' as const,
65
+ description:
66
+ 'Min ETH balance below which a publisher gets funded. Specified in ether (e.g. 0.1). Unset = funding disabled.',
67
+ parseEnv: (val: string) => parseEther(val),
68
+ },
69
+ publisherFundingAmount: {
70
+ env: 'PUBLISHER_FUNDING_AMOUNT' as const,
71
+ description:
72
+ 'Amount of ETH to send when funding a publisher. Specified in ether (e.g. 0.5). Unset = funding disabled.',
73
+ parseEnv: (val: string) => parseEther(val),
74
+ },
75
+ };
76
+
77
+ export type ProverPublisherConfig = L1TxUtilsConfig &
78
+ BlobClientConfig & {
79
+ fishermanMode?: boolean;
80
+ proverPublisherAllowInvalidStates?: boolean;
81
+ proverPublisherForwarderAddress?: EthAddress;
82
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
83
+ publisherFundingThreshold?: bigint;
84
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
85
+ publisherFundingAmount?: bigint;
86
+ };
87
+
88
+ export type SequencerPublisherConfig = L1TxUtilsConfig &
89
+ BlobClientConfig & {
90
+ fishermanMode?: boolean;
91
+ sequencerPublisherAllowInvalidStates?: boolean;
92
+ sequencerPublisherForwarderAddress?: EthAddress;
93
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
94
+ l1TxFailedStore?: string;
95
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
96
+ publisherFundingThreshold?: bigint;
97
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
98
+ publisherFundingAmount?: bigint;
99
+ };
100
+
101
+ export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
102
+ return {
103
+ ...config,
104
+ publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
105
+ publisherForwarderAddress: config.proverPublisherForwarderAddress,
106
+ };
107
+ }
108
+
109
+ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
110
+ return {
111
+ ...config,
112
+ publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
113
+ publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
114
+ l1TxFailedStore: config.l1TxFailedStore,
115
+ };
116
+ }
117
+
118
+ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
43
119
  ...l1ReaderConfigMappings,
44
- publisherPrivateKeys: {
45
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
46
- description: 'The private keys to be used by the publisher.',
120
+ proverPublisherPrivateKeys: {
121
+ env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
122
+ description: 'The private keys to be used by the prover publisher.',
47
123
  parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
48
124
  defaultValue: [],
49
- fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
125
+ fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
50
126
  },
51
- publisherAddresses: {
52
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
127
+ proverPublisherAddresses: {
128
+ env: `PROVER_PUBLISHER_ADDRESSES`,
53
129
  description: 'The addresses of the publishers to use with remote signers',
54
130
  parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
55
131
  defaultValue: [],
56
132
  },
57
- });
133
+ };
58
134
 
59
- export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
60
- return getConfigFromMappings(getTxSenderConfigMappings(scope));
61
- }
135
+ export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
136
+ ...l1ReaderConfigMappings,
137
+ sequencerPublisherPrivateKeys: {
138
+ env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
139
+ description: 'The private keys to be used by the sequencer publisher.',
140
+ parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
141
+ defaultValue: [],
142
+ fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
143
+ },
144
+ sequencerPublisherAddresses: {
145
+ env: `SEQ_PUBLISHER_ADDRESSES`,
146
+ description: 'The addresses of the publishers to use with remote signers',
147
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
148
+ defaultValue: [],
149
+ },
150
+ };
62
151
 
63
- export const getPublisherConfigMappings: (
64
- scope: 'PROVER' | 'SEQ',
65
- ) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
66
- publisherAllowInvalidStates: {
152
+ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
153
+ ...l1TxUtilsConfigMappings,
154
+ ...blobClientConfigMapping,
155
+ sequencerPublisherAllowInvalidStates: {
156
+ env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
67
157
  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
158
  ...booleanConfigHelper(true),
70
159
  },
71
160
  fishermanMode: {
@@ -74,15 +163,36 @@ export const getPublisherConfigMappings: (
74
163
  'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
75
164
  ...booleanConfigHelper(false),
76
165
  },
77
- publisherForwarderAddress: {
78
- env: scope === `PROVER` ? `PROVER_PUBLISHER_FORWARDER_ADDRESS` : `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
166
+ sequencerPublisherForwarderAddress: {
167
+ env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
79
168
  description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
80
169
  parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
81
170
  },
171
+ l1TxFailedStore: {
172
+ env: 'L1_TX_FAILED_STORE',
173
+ description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
174
+ },
175
+ ...publisherFundingConfigMappings,
176
+ };
177
+
178
+ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
82
179
  ...l1TxUtilsConfigMappings,
83
180
  ...blobClientConfigMapping,
84
- });
85
-
86
- export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
87
- return getConfigFromMappings(getPublisherConfigMappings(scope));
88
- }
181
+ proverPublisherAllowInvalidStates: {
182
+ env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
183
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
184
+ ...booleanConfigHelper(true),
185
+ },
186
+ fishermanMode: {
187
+ env: 'FISHERMAN_MODE',
188
+ description:
189
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
190
+ ...booleanConfigHelper(false),
191
+ },
192
+ proverPublisherForwarderAddress: {
193
+ env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
194
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
195
+ parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
196
+ },
197
+ ...publisherFundingConfigMappings,
198
+ };
@@ -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
+ }
@@ -0,0 +1,55 @@
1
+ import type { Hex } from 'viem';
2
+
3
+ /** URI pointing to a stored failed L1 transaction. */
4
+ export type FailedL1TxUri = string & { __brand: 'FailedL1TxUri' };
5
+
6
+ /** A failed L1 transaction captured for debugging and replay. */
7
+ export type FailedL1Tx = {
8
+ /** Tx hash (for reverts) or keccak256(request.data) (for simulation/send failures). */
9
+ id: Hex;
10
+ /** Unix timestamp (ms) when failure occurred. */
11
+ timestamp: number;
12
+ /** Whether the failure was during simulation or after sending. */
13
+ failureType: 'simulation' | 'revert' | 'send-error';
14
+ /** The actual L1 transaction for replay (multicall-encoded for bundled txs). */
15
+ request: {
16
+ to: Hex;
17
+ data: Hex;
18
+ value?: string; // bigint as string
19
+ };
20
+ /** Raw blob data as hex for replay. */
21
+ blobData?: Hex[];
22
+ /** L1 block number at time of failure (simulation target or receipt block). */
23
+ l1BlockNumber: string; // bigint as string
24
+ /** Receipt info (present only for on-chain reverts). */
25
+ receipt?: {
26
+ transactionHash: Hex;
27
+ blockNumber: string; // bigint as string
28
+ gasUsed: string; // bigint as string
29
+ status: 'reverted';
30
+ };
31
+ /** Error information. */
32
+ error: {
33
+ message: string;
34
+ /** Decoded error name (e.g., 'Rollup__InvalidProposer'). */
35
+ name?: string;
36
+ };
37
+ /** Context metadata. */
38
+ context: {
39
+ /** Actions involved (e.g., ['propose', 'governance-signal']). */
40
+ actions: string[];
41
+ /** Individual request data for each action (metadata, not used for replay). */
42
+ requests?: Array<{ action: string; to: Hex; data: Hex }>;
43
+ checkpointNumber?: number;
44
+ slot?: number;
45
+ sender: Hex;
46
+ };
47
+ };
48
+
49
+ /** Store for failed L1 transactions for debugging purposes. */
50
+ export interface L1TxFailedStore {
51
+ /** Saves a failed transaction and returns its URI. */
52
+ saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri>;
53
+ /** Retrieves a failed transaction by its URI. */
54
+ getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx>;
55
+ }