@aztec/sequencer-client 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891

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 (119) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +21 -16
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +75 -28
  5. package/dest/config.d.ts +35 -9
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +113 -42
  8. package/dest/global_variable_builder/global_builder.d.ts +20 -16
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +54 -40
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +2 -3
  13. package/dest/index.d.ts.map +1 -1
  14. package/dest/index.js +1 -2
  15. package/dest/publisher/config.d.ts +43 -20
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +109 -34
  18. package/dest/publisher/index.d.ts +2 -1
  19. package/dest/publisher/index.d.ts.map +1 -1
  20. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  21. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  24. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  26. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  27. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  28. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  29. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  30. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  31. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  32. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
  33. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  34. package/dest/publisher/sequencer-publisher-factory.js +28 -3
  35. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  36. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  37. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  38. package/dest/publisher/sequencer-publisher.d.ts +103 -69
  39. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  40. package/dest/publisher/sequencer-publisher.js +999 -190
  41. package/dest/sequencer/checkpoint_proposal_job.d.ts +108 -0
  42. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  43. package/dest/sequencer/checkpoint_proposal_job.js +1289 -0
  44. package/dest/sequencer/checkpoint_voter.d.ts +35 -0
  45. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  46. package/dest/sequencer/checkpoint_voter.js +109 -0
  47. package/dest/sequencer/config.d.ts +3 -2
  48. package/dest/sequencer/config.d.ts.map +1 -1
  49. package/dest/sequencer/errors.d.ts +1 -1
  50. package/dest/sequencer/errors.d.ts.map +1 -1
  51. package/dest/sequencer/events.d.ts +47 -0
  52. package/dest/sequencer/events.d.ts.map +1 -0
  53. package/dest/sequencer/events.js +1 -0
  54. package/dest/sequencer/index.d.ts +4 -2
  55. package/dest/sequencer/index.d.ts.map +1 -1
  56. package/dest/sequencer/index.js +3 -1
  57. package/dest/sequencer/metrics.d.ts +48 -3
  58. package/dest/sequencer/metrics.d.ts.map +1 -1
  59. package/dest/sequencer/metrics.js +243 -50
  60. package/dest/sequencer/sequencer.d.ts +127 -144
  61. package/dest/sequencer/sequencer.d.ts.map +1 -1
  62. package/dest/sequencer/sequencer.js +770 -545
  63. package/dest/sequencer/timetable.d.ts +54 -16
  64. package/dest/sequencer/timetable.d.ts.map +1 -1
  65. package/dest/sequencer/timetable.js +147 -62
  66. package/dest/sequencer/types.d.ts +3 -0
  67. package/dest/sequencer/types.d.ts.map +1 -0
  68. package/dest/sequencer/types.js +1 -0
  69. package/dest/sequencer/utils.d.ts +14 -8
  70. package/dest/sequencer/utils.d.ts.map +1 -1
  71. package/dest/sequencer/utils.js +7 -4
  72. package/dest/test/index.d.ts +6 -7
  73. package/dest/test/index.d.ts.map +1 -1
  74. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  75. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  76. package/dest/test/mock_checkpoint_builder.js +231 -0
  77. package/dest/test/utils.d.ts +53 -0
  78. package/dest/test/utils.d.ts.map +1 -0
  79. package/dest/test/utils.js +104 -0
  80. package/package.json +32 -30
  81. package/src/client/sequencer-client.ts +100 -52
  82. package/src/config.ts +132 -51
  83. package/src/global_variable_builder/global_builder.ts +69 -60
  84. package/src/index.ts +1 -7
  85. package/src/publisher/config.ts +139 -50
  86. package/src/publisher/index.ts +3 -0
  87. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  88. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  89. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  90. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  91. package/src/publisher/sequencer-publisher-factory.ts +45 -11
  92. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  93. package/src/publisher/sequencer-publisher.ts +717 -248
  94. package/src/sequencer/README.md +531 -0
  95. package/src/sequencer/checkpoint_proposal_job.ts +1049 -0
  96. package/src/sequencer/checkpoint_voter.ts +130 -0
  97. package/src/sequencer/config.ts +2 -1
  98. package/src/sequencer/events.ts +27 -0
  99. package/src/sequencer/index.ts +3 -1
  100. package/src/sequencer/metrics.ts +310 -61
  101. package/src/sequencer/sequencer.ts +541 -735
  102. package/src/sequencer/timetable.ts +178 -83
  103. package/src/sequencer/types.ts +6 -0
  104. package/src/sequencer/utils.ts +18 -9
  105. package/src/test/index.ts +5 -6
  106. package/src/test/mock_checkpoint_builder.ts +323 -0
  107. package/src/test/utils.ts +167 -0
  108. package/dest/sequencer/block_builder.d.ts +0 -27
  109. package/dest/sequencer/block_builder.d.ts.map +0 -1
  110. package/dest/sequencer/block_builder.js +0 -130
  111. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  112. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  113. package/dest/tx_validator/nullifier_cache.js +0 -24
  114. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  115. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  116. package/dest/tx_validator/tx_validator_factory.js +0 -53
  117. package/src/sequencer/block_builder.ts +0 -218
  118. package/src/tx_validator/nullifier_cache.ts +0 -30
  119. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -1,45 +1,60 @@
1
- import {
2
- type L1ContractsConfig,
3
- type L1ReaderConfig,
4
- RollupContract,
5
- type ViemPublicClient,
6
- createEthereumChain,
7
- } from '@aztec/ethereum';
1
+ import { createEthereumChain } from '@aztec/ethereum/chain';
2
+ import { makeL1HttpTransport } from '@aztec/ethereum/client';
3
+ import type { L1ContractsConfig } from '@aztec/ethereum/config';
4
+ import { RollupContract } from '@aztec/ethereum/contracts';
5
+ import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
6
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
7
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
8
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
9
  import type { EthAddress } from '@aztec/foundation/eth-address';
9
- import { Fr } from '@aztec/foundation/fields';
10
10
  import { createLogger } from '@aztec/foundation/log';
11
11
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
12
+ import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
12
13
  import { GasFees } from '@aztec/stdlib/gas';
13
- import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
14
+ import type {
15
+ CheckpointGlobalVariables,
16
+ GlobalVariableBuilder as GlobalVariableBuilderInterface,
17
+ } from '@aztec/stdlib/tx';
14
18
  import { GlobalVariables } from '@aztec/stdlib/tx';
15
19
 
16
- import { createPublicClient, fallback, http } from 'viem';
20
+ import { createPublicClient } from 'viem';
17
21
 
18
22
  /**
19
23
  * Simple global variables builder.
20
24
  */
21
25
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
22
26
  private log = createLogger('sequencer:global_variable_builder');
23
- private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
27
+ private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
24
28
  private currentL1BlockNumber: bigint | undefined = undefined;
25
29
 
26
30
  private readonly rollupContract: RollupContract;
27
31
  private readonly publicClient: ViemPublicClient;
28
32
  private readonly ethereumSlotDuration: number;
33
+ private readonly aztecSlotDuration: number;
34
+ private readonly l1GenesisTime: bigint;
29
35
 
30
- private chainId?: Fr;
31
- private version?: Fr;
36
+ private chainId: Fr;
37
+ private version: Fr;
32
38
 
33
- constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
39
+ constructor(
40
+ config: L1ReaderConfig &
41
+ Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
42
+ Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
43
+ ) {
34
44
  const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
35
45
 
36
46
  const chain = createEthereumChain(l1RpcUrls, chainId);
37
47
 
48
+ this.version = new Fr(config.rollupVersion);
49
+ this.chainId = new Fr(chainId);
50
+
38
51
  this.ethereumSlotDuration = config.ethereumSlotDuration;
52
+ this.aztecSlotDuration = config.slotDuration;
53
+ this.l1GenesisTime = config.l1GenesisTime;
39
54
 
40
55
  this.publicClient = createPublicClient({
41
56
  chain: chain.chainInfo,
42
- transport: fallback(chain.rpcUrls.map(url => http(url))),
57
+ transport: makeL1HttpTransport(chain.rpcUrls, { timeout: config.l1HttpTimeoutMS }),
43
58
  pollingInterval: config.viemPollingIntervalMS,
44
59
  });
45
60
 
@@ -47,46 +62,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
47
62
  }
48
63
 
49
64
  /**
50
- * Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
51
- * @returns Base fees for the next block
65
+ * Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
66
+ * @returns Min fees for the next block
52
67
  */
53
- private async computeCurrentBaseFees(): Promise<GasFees> {
68
+ private async computeCurrentMinFees(): Promise<GasFees> {
54
69
  // Since this might be called in the middle of a slot where a block might have been published,
55
70
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
56
71
  // The timestamp of that last block will act as a lower bound for the next block.
57
72
 
58
- const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
59
- const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
73
+ const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
74
+ const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
75
+ SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
76
+ );
60
77
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
61
78
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
62
79
 
63
- return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
80
+ return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
64
81
  }
65
82
 
66
- public async getCurrentBaseFees(): Promise<GasFees> {
83
+ public async getCurrentMinFees(): Promise<GasFees> {
67
84
  // Get the current block number
68
85
  const blockNumber = await this.publicClient.getBlockNumber();
69
86
 
70
- // If the L1 block number has changed then chain a new promise to get the current base fees
87
+ // If the L1 block number has changed then chain a new promise to get the current min fees
71
88
  if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
72
89
  this.currentL1BlockNumber = blockNumber;
73
- this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
90
+ this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
74
91
  }
75
- return this.currentBaseFees;
76
- }
77
-
78
- public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
79
- if (!this.chainId) {
80
- this.chainId = new Fr(this.publicClient.chain.id);
81
- }
82
- if (!this.version) {
83
- this.version = new Fr(await this.rollupContract.getVersion());
84
- }
85
- return { chainId: this.chainId, version: this.version };
92
+ return this.currentMinFees;
86
93
  }
87
94
 
88
95
  /**
89
- * Simple builder of global variables that use the minimum time possible.
96
+ * Simple builder of global variables.
90
97
  * @param blockNumber - The block number to build global variables for.
91
98
  * @param coinbase - The address to receive block reward.
92
99
  * @param feeRecipient - The address to receive fees.
@@ -94,36 +101,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
94
101
  * @returns The global variables for the given block number.
95
102
  */
96
103
  public async buildGlobalVariables(
97
- blockNumber: number,
104
+ blockNumber: BlockNumber,
98
105
  coinbase: EthAddress,
99
106
  feeRecipient: AztecAddress,
100
- slotNumber?: bigint,
107
+ maybeSlot?: SlotNumber,
101
108
  ): Promise<GlobalVariables> {
102
- const { chainId, version } = await this.getGlobalConstantVariables();
103
-
104
- if (slotNumber === undefined) {
105
- const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
106
- slotNumber = await this.rollupContract.getSlotAt(ts);
107
- }
108
-
109
- const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
109
+ const slot: SlotNumber =
110
+ maybeSlot ??
111
+ (await this.rollupContract.getSlotAt(
112
+ BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
113
+ ));
114
+
115
+ const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
116
+ return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
117
+ }
110
118
 
111
- const slotFr = new Fr(slotNumber);
119
+ /** Builds global variables that are constant throughout a checkpoint. */
120
+ public async buildCheckpointGlobalVariables(
121
+ coinbase: EthAddress,
122
+ feeRecipient: AztecAddress,
123
+ slotNumber: SlotNumber,
124
+ ): Promise<CheckpointGlobalVariables> {
125
+ const { chainId, version } = this;
112
126
 
113
- // We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
114
- const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
127
+ const timestamp = getTimestampForSlot(slotNumber, {
128
+ slotDuration: this.aztecSlotDuration,
129
+ l1GenesisTime: this.l1GenesisTime,
130
+ });
115
131
 
116
- const globalVariables = new GlobalVariables(
117
- chainId,
118
- version,
119
- blockNumber,
120
- slotFr,
121
- timestamp,
122
- coinbase,
123
- feeRecipient,
124
- gasFees,
125
- );
132
+ // We can skip much of the logic in getCurrentMinFees since it we already check that we are not within a slot elsewhere.
133
+ // TODO(palla/mbps): Can we use a cached value here?
134
+ const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
126
135
 
127
- return globalVariables;
136
+ return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
128
137
  }
129
138
  }
package/src/index.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  export * from './client/index.js';
2
2
  export * from './config.js';
3
3
  export * from './publisher/index.js';
4
- export {
5
- FullNodeBlockBuilder as BlockBuilder,
6
- Sequencer,
7
- SequencerState,
8
- type SequencerEvents,
9
- } from './sequencer/index.js';
10
- export * from './tx_validator/tx_validator_factory.js';
4
+ export { Sequencer, SequencerState, type SequencerEvents } from './sequencer/index.js';
11
5
 
12
6
  // Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
13
7
  // ISSUE(#9832)
@@ -1,77 +1,166 @@
1
- import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
2
- import {
3
- type L1ReaderConfig,
4
- type L1TxUtilsConfig,
5
- l1ReaderConfigMappings,
6
- l1TxUtilsConfigMappings,
7
- } from '@aztec/ethereum';
8
- import {
9
- type ConfigMappingsType,
10
- SecretValue,
11
- booleanConfigHelper,
12
- getConfigFromMappings,
13
- } from '@aztec/foundation/config';
1
+ import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
2
+ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
3
+ import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
4
+ import { type ConfigMappingsType, SecretValue, booleanConfigHelper } from '@aztec/foundation/config';
14
5
  import { EthAddress } from '@aztec/foundation/eth-address';
15
6
 
16
- /**
17
- * The configuration of the rollup transaction publisher.
18
- */
7
+ /** Configuration of the transaction publisher. */
19
8
  export type TxSenderConfig = L1ReaderConfig & {
20
- /**
21
- * The private key to be used by the publisher.
22
- */
9
+ /** The private key to be used by the publisher. */
23
10
  publisherPrivateKeys?: SecretValue<`0x${string}`>[];
24
11
 
25
- /**
26
- * Publisher addresses to be used with a remote signer
27
- */
12
+ /** Publisher addresses to be used with a remote signer */
28
13
  publisherAddresses?: EthAddress[];
29
14
  };
30
15
 
31
- /**
32
- * Configuration of the L1Publisher.
33
- */
16
+ export type ProverTxSenderConfig = L1ReaderConfig & {
17
+ proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
18
+ proverPublisherAddresses?: EthAddress[];
19
+ };
20
+
21
+ export type SequencerTxSenderConfig = L1ReaderConfig & {
22
+ sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
23
+ sequencerPublisherAddresses?: EthAddress[];
24
+ };
25
+
26
+ export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
27
+ return {
28
+ ...config,
29
+ publisherPrivateKeys: config.proverPublisherPrivateKeys,
30
+ publisherAddresses: config.proverPublisherAddresses,
31
+ };
32
+ }
33
+
34
+ export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
35
+ return {
36
+ ...config,
37
+ publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
38
+ publisherAddresses: config.sequencerPublisherAddresses,
39
+ };
40
+ }
41
+
42
+ /** Configuration of the L1Publisher. */
34
43
  export type PublisherConfig = L1TxUtilsConfig &
35
- BlobSinkConfig & {
44
+ BlobClientConfig & {
36
45
  /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
37
46
  publisherAllowInvalidStates?: boolean;
47
+ /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
48
+ fishermanMode?: boolean;
49
+ /** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
50
+ publisherForwarderAddress?: EthAddress;
51
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
52
+ l1TxFailedStore?: string;
53
+ };
54
+
55
+ export type ProverPublisherConfig = L1TxUtilsConfig &
56
+ BlobClientConfig & {
57
+ fishermanMode?: boolean;
58
+ proverPublisherAllowInvalidStates?: boolean;
59
+ proverPublisherForwarderAddress?: EthAddress;
38
60
  };
39
61
 
40
- export const getTxSenderConfigMappings: (
41
- scope: 'PROVER' | 'SEQ',
42
- ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
62
+ export type SequencerPublisherConfig = L1TxUtilsConfig &
63
+ BlobClientConfig & {
64
+ fishermanMode?: boolean;
65
+ sequencerPublisherAllowInvalidStates?: boolean;
66
+ sequencerPublisherForwarderAddress?: EthAddress;
67
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
68
+ l1TxFailedStore?: string;
69
+ };
70
+
71
+ export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
72
+ return {
73
+ ...config,
74
+ publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
75
+ publisherForwarderAddress: config.proverPublisherForwarderAddress,
76
+ };
77
+ }
78
+
79
+ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
80
+ return {
81
+ ...config,
82
+ publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
83
+ publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
84
+ l1TxFailedStore: config.l1TxFailedStore,
85
+ };
86
+ }
87
+
88
+ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
43
89
  ...l1ReaderConfigMappings,
44
- publisherPrivateKeys: {
45
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
46
- description: 'The private keys to be used by the publisher.',
90
+ proverPublisherPrivateKeys: {
91
+ env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
92
+ description: 'The private keys to be used by the prover publisher.',
47
93
  parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
48
94
  defaultValue: [],
49
- fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
95
+ fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
50
96
  },
51
- publisherAddresses: {
52
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
97
+ proverPublisherAddresses: {
98
+ env: `PROVER_PUBLISHER_ADDRESSES`,
53
99
  description: 'The addresses of the publishers to use with remote signers',
54
100
  parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
55
101
  defaultValue: [],
56
102
  },
57
- });
103
+ };
58
104
 
59
- export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
60
- return getConfigFromMappings(getTxSenderConfigMappings(scope));
61
- }
105
+ export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
106
+ ...l1ReaderConfigMappings,
107
+ sequencerPublisherPrivateKeys: {
108
+ env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
109
+ description: 'The private keys to be used by the sequencer publisher.',
110
+ parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
111
+ defaultValue: [],
112
+ fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
113
+ },
114
+ sequencerPublisherAddresses: {
115
+ env: `SEQ_PUBLISHER_ADDRESSES`,
116
+ description: 'The addresses of the publishers to use with remote signers',
117
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
118
+ defaultValue: [],
119
+ },
120
+ };
62
121
 
63
- export const getPublisherConfigMappings: (
64
- scope: 'PROVER' | 'SEQ',
65
- ) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
66
- publisherAllowInvalidStates: {
122
+ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
123
+ ...l1TxUtilsConfigMappings,
124
+ ...blobClientConfigMapping,
125
+ sequencerPublisherAllowInvalidStates: {
126
+ env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
67
127
  description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
68
- env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
69
128
  ...booleanConfigHelper(true),
70
129
  },
71
- ...l1TxUtilsConfigMappings,
72
- ...blobSinkConfigMapping,
73
- });
130
+ fishermanMode: {
131
+ env: 'FISHERMAN_MODE',
132
+ description:
133
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
134
+ ...booleanConfigHelper(false),
135
+ },
136
+ sequencerPublisherForwarderAddress: {
137
+ env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
138
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
139
+ parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
140
+ },
141
+ l1TxFailedStore: {
142
+ env: 'L1_TX_FAILED_STORE',
143
+ description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
144
+ },
145
+ };
74
146
 
75
- export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
76
- return getConfigFromMappings(getPublisherConfigMappings(scope));
77
- }
147
+ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
148
+ ...l1TxUtilsConfigMappings,
149
+ ...blobClientConfigMapping,
150
+ proverPublisherAllowInvalidStates: {
151
+ env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
152
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
153
+ ...booleanConfigHelper(true),
154
+ },
155
+ fishermanMode: {
156
+ env: 'FISHERMAN_MODE',
157
+ description:
158
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
159
+ ...booleanConfigHelper(false),
160
+ },
161
+ proverPublisherForwarderAddress: {
162
+ env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
163
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
164
+ parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
165
+ },
166
+ };
@@ -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
+ }
@@ -0,0 +1,46 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import type { FileStore } from '@aztec/stdlib/file-store';
3
+
4
+ import type { FailedL1Tx, FailedL1TxUri, L1TxFailedStore } from './failed_tx_store.js';
5
+
6
+ /**
7
+ * L1TxFailedStore implementation using the FileStore abstraction.
8
+ * Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
9
+ */
10
+ export class FileStoreL1TxFailedStore implements L1TxFailedStore {
11
+ private readonly log: Logger;
12
+
13
+ constructor(
14
+ private readonly fileStore: FileStore,
15
+ logger?: Logger,
16
+ ) {
17
+ this.log = logger ?? createLogger('sequencer:l1-tx-failed-store');
18
+ }
19
+
20
+ public async saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri> {
21
+ const prefix = tx.receipt ? 'tx' : 'data';
22
+ const path = `${tx.failureType}/${prefix}-${tx.id}.json`;
23
+ const json = JSON.stringify(tx, null, 2);
24
+
25
+ const uri = await this.fileStore.save(path, Buffer.from(json), {
26
+ metadata: {
27
+ 'content-type': 'application/json',
28
+ actions: tx.context.actions.join(','),
29
+ 'failure-type': tx.failureType,
30
+ },
31
+ });
32
+
33
+ this.log.info(`Saved failed L1 tx to ${uri}`, {
34
+ id: tx.id,
35
+ failureType: tx.failureType,
36
+ actions: tx.context.actions.join(','),
37
+ });
38
+
39
+ return uri as FailedL1TxUri;
40
+ }
41
+
42
+ public async getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx> {
43
+ const data = await this.fileStore.read(uri);
44
+ return JSON.parse(data.toString()) as FailedL1Tx;
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './failed_tx_store.js';
2
+ export { createL1TxFailedStore } from './factory.js';
3
+ export { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';