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

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 (165) hide show
  1. package/README.md +281 -21
  2. package/dest/client/index.d.ts +1 -1
  3. package/dest/client/sequencer-client.d.ts +41 -18
  4. package/dest/client/sequencer-client.d.ts.map +1 -1
  5. package/dest/client/sequencer-client.js +88 -42
  6. package/dest/config.d.ts +41 -8
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +153 -53
  9. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  10. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  11. package/dest/global_variable_builder/fee_predictor.js +138 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  13. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  14. package/dest/global_variable_builder/fee_provider.js +80 -0
  15. package/dest/global_variable_builder/global_builder.d.ts +20 -29
  16. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  17. package/dest/global_variable_builder/global_builder.js +28 -72
  18. package/dest/global_variable_builder/index.d.ts +4 -2
  19. package/dest/global_variable_builder/index.d.ts.map +1 -1
  20. package/dest/global_variable_builder/index.js +2 -0
  21. package/dest/index.d.ts +2 -3
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +1 -2
  24. package/dest/publisher/config.d.ts +59 -20
  25. package/dest/publisher/config.d.ts.map +1 -1
  26. package/dest/publisher/config.js +134 -34
  27. package/dest/publisher/index.d.ts +2 -1
  28. package/dest/publisher/index.d.ts.map +1 -1
  29. package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
  30. package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
  31. package/dest/publisher/l1_to_l2_messaging.js +70 -0
  32. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  33. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  34. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  35. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +98 -0
  36. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  37. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -0
  38. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  39. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  40. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +36 -0
  41. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  42. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  43. package/dest/publisher/l1_tx_failed_store/index.js +3 -0
  44. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  45. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  46. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  47. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
  48. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  49. package/dest/publisher/sequencer-publisher-factory.js +28 -4
  50. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  51. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  52. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  53. package/dest/publisher/sequencer-publisher.d.ts +164 -96
  54. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  55. package/dest/publisher/sequencer-publisher.js +1305 -416
  56. package/dest/publisher/write_json.d.ts +11 -0
  57. package/dest/publisher/write_json.d.ts.map +1 -0
  58. package/dest/publisher/write_json.js +57 -0
  59. package/dest/sequencer/automine/automine_factory.d.ts +56 -0
  60. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  61. package/dest/sequencer/automine/automine_factory.js +85 -0
  62. package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
  63. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  64. package/dest/sequencer/automine/automine_sequencer.js +690 -0
  65. package/dest/sequencer/automine/index.d.ts +3 -0
  66. package/dest/sequencer/automine/index.d.ts.map +1 -0
  67. package/dest/sequencer/automine/index.js +2 -0
  68. package/dest/sequencer/checkpoint_proposal_job.d.ts +158 -0
  69. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  70. package/dest/sequencer/checkpoint_proposal_job.js +1801 -0
  71. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  72. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  73. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  74. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  75. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  76. package/dest/sequencer/checkpoint_voter.js +106 -0
  77. package/dest/sequencer/config.d.ts +3 -2
  78. package/dest/sequencer/config.d.ts.map +1 -1
  79. package/dest/sequencer/errors.d.ts +1 -1
  80. package/dest/sequencer/errors.d.ts.map +1 -1
  81. package/dest/sequencer/events.d.ts +103 -0
  82. package/dest/sequencer/events.d.ts.map +1 -0
  83. package/dest/sequencer/events.js +1 -0
  84. package/dest/sequencer/index.d.ts +4 -2
  85. package/dest/sequencer/index.d.ts.map +1 -1
  86. package/dest/sequencer/index.js +3 -1
  87. package/dest/sequencer/metrics.d.ts +48 -4
  88. package/dest/sequencer/metrics.d.ts.map +1 -1
  89. package/dest/sequencer/metrics.js +257 -50
  90. package/dest/sequencer/requests_tracker.d.ts +22 -0
  91. package/dest/sequencer/requests_tracker.d.ts.map +1 -0
  92. package/dest/sequencer/requests_tracker.js +33 -0
  93. package/dest/sequencer/sequencer.d.ts +253 -148
  94. package/dest/sequencer/sequencer.d.ts.map +1 -1
  95. package/dest/sequencer/sequencer.js +1208 -598
  96. package/dest/sequencer/types.d.ts +3 -0
  97. package/dest/sequencer/types.d.ts.map +1 -0
  98. package/dest/sequencer/types.js +1 -0
  99. package/dest/sequencer/utils.d.ts +14 -8
  100. package/dest/sequencer/utils.d.ts.map +1 -1
  101. package/dest/sequencer/utils.js +7 -4
  102. package/dest/test/index.d.ts +8 -9
  103. package/dest/test/index.d.ts.map +1 -1
  104. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  105. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  106. package/dest/test/mock_checkpoint_builder.js +231 -0
  107. package/dest/test/utils.d.ts +67 -0
  108. package/dest/test/utils.d.ts.map +1 -0
  109. package/dest/test/utils.js +122 -0
  110. package/package.json +34 -30
  111. package/src/client/sequencer-client.ts +118 -66
  112. package/src/config.ts +181 -62
  113. package/src/global_variable_builder/README.md +44 -0
  114. package/src/global_variable_builder/fee_predictor.ts +182 -0
  115. package/src/global_variable_builder/fee_provider.ts +97 -0
  116. package/src/global_variable_builder/global_builder.ts +45 -106
  117. package/src/global_variable_builder/index.ts +3 -1
  118. package/src/index.ts +1 -7
  119. package/src/publisher/config.ts +190 -46
  120. package/src/publisher/index.ts +3 -0
  121. package/src/publisher/l1_to_l2_messaging.ts +85 -0
  122. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  123. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
  124. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
  125. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  126. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  127. package/src/publisher/sequencer-publisher-factory.ts +45 -14
  128. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  129. package/src/publisher/sequencer-publisher.ts +1109 -538
  130. package/src/publisher/write_json.ts +78 -0
  131. package/src/sequencer/README.md +243 -0
  132. package/src/sequencer/automine/README.md +60 -0
  133. package/src/sequencer/automine/automine_factory.ts +152 -0
  134. package/src/sequencer/automine/automine_sequencer.ts +796 -0
  135. package/src/sequencer/automine/index.ts +6 -0
  136. package/src/sequencer/checkpoint_proposal_job.ts +1652 -0
  137. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  138. package/src/sequencer/checkpoint_voter.ts +119 -0
  139. package/src/sequencer/config.ts +2 -1
  140. package/src/sequencer/events.ts +88 -0
  141. package/src/sequencer/index.ts +3 -1
  142. package/src/sequencer/metrics.ts +330 -62
  143. package/src/sequencer/requests_tracker.ts +43 -0
  144. package/src/sequencer/sequencer.ts +1033 -777
  145. package/src/sequencer/types.ts +6 -0
  146. package/src/sequencer/utils.ts +18 -9
  147. package/src/test/index.ts +7 -8
  148. package/src/test/mock_checkpoint_builder.ts +323 -0
  149. package/src/test/utils.ts +218 -0
  150. package/dest/sequencer/block_builder.d.ts +0 -27
  151. package/dest/sequencer/block_builder.d.ts.map +0 -1
  152. package/dest/sequencer/block_builder.js +0 -130
  153. package/dest/sequencer/timetable.d.ts +0 -50
  154. package/dest/sequencer/timetable.d.ts.map +0 -1
  155. package/dest/sequencer/timetable.js +0 -137
  156. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  157. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  158. package/dest/tx_validator/nullifier_cache.js +0 -24
  159. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  160. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  161. package/dest/tx_validator/tx_validator_factory.js +0 -53
  162. package/src/sequencer/block_builder.ts +0 -218
  163. package/src/sequencer/timetable.ts +0 -188
  164. package/src/tx_validator/nullifier_cache.ts +0 -30
  165. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -1,129 +1,68 @@
1
1
  import {
2
- type L1ContractsConfig,
3
- type L1ReaderConfig,
4
2
  RollupContract,
5
- type ViemPublicClient,
6
- createEthereumChain,
7
- } from '@aztec/ethereum';
3
+ type SimulationOverridesPlan,
4
+ buildSimulationOverridesStateOverride,
5
+ } from '@aztec/ethereum/contracts';
6
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
7
+ import type { 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
- import { createLogger } from '@aztec/foundation/log';
11
10
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
12
12
  import { GasFees } from '@aztec/stdlib/gas';
13
- import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
14
- import { GlobalVariables } from '@aztec/stdlib/tx';
15
-
16
- import { createPublicClient, fallback, http } from 'viem';
13
+ import type {
14
+ CheckpointGlobalVariables,
15
+ GlobalVariableBuilder as GlobalVariableBuilderInterface,
16
+ } from '@aztec/stdlib/tx';
17
+
18
+ /** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
19
+ export type GlobalVariableBuilderConfig = {
20
+ rollupAddress: EthAddress;
21
+ ethereumSlotDuration: number;
22
+ rollupVersion: bigint;
23
+ } & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
17
24
 
18
25
  /**
19
26
  * Simple global variables builder.
20
27
  */
21
28
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
22
- private log = createLogger('sequencer:global_variable_builder');
23
- private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
24
- private currentL1BlockNumber: bigint | undefined = undefined;
25
-
26
29
  private readonly rollupContract: RollupContract;
27
- private readonly publicClient: ViemPublicClient;
28
- private readonly ethereumSlotDuration: number;
29
-
30
- private chainId?: Fr;
31
- private version?: Fr;
32
-
33
- constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
34
- const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
35
-
36
- const chain = createEthereumChain(l1RpcUrls, chainId);
30
+ private readonly aztecSlotDuration: number;
31
+ private readonly l1GenesisTime: bigint;
37
32
 
38
- this.ethereumSlotDuration = config.ethereumSlotDuration;
33
+ private chainId: Fr;
34
+ private version: Fr;
39
35
 
40
- this.publicClient = createPublicClient({
41
- chain: chain.chainInfo,
42
- transport: fallback(chain.rpcUrls.map(url => http(url))),
43
- pollingInterval: config.viemPollingIntervalMS,
44
- });
45
-
46
- this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
47
- }
36
+ constructor(
37
+ private readonly publicClient: ViemPublicClient,
38
+ config: GlobalVariableBuilderConfig,
39
+ ) {
40
+ this.version = new Fr(config.rollupVersion);
41
+ this.chainId = new Fr(this.publicClient.chain!.id);
48
42
 
49
- /**
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
52
- */
53
- private async computeCurrentBaseFees(): Promise<GasFees> {
54
- // Since this might be called in the middle of a slot where a block might have been published,
55
- // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
56
- // The timestamp of that last block will act as a lower bound for the next block.
43
+ this.aztecSlotDuration = config.slotDuration;
44
+ this.l1GenesisTime = config.l1GenesisTime;
57
45
 
58
- const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
59
- const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
60
- const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
61
- const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
62
-
63
- return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
46
+ this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
64
47
  }
65
48
 
66
- public async getCurrentBaseFees(): Promise<GasFees> {
67
- // Get the current block number
68
- const blockNumber = await this.publicClient.getBlockNumber();
69
-
70
- // If the L1 block number has changed then chain a new promise to get the current base fees
71
- if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
72
- this.currentL1BlockNumber = blockNumber;
73
- this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
74
- }
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 };
86
- }
87
-
88
- /**
89
- * Simple builder of global variables that use the minimum time possible.
90
- * @param blockNumber - The block number to build global variables for.
91
- * @param coinbase - The address to receive block reward.
92
- * @param feeRecipient - The address to receive fees.
93
- * @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
94
- * @returns The global variables for the given block number.
95
- */
96
- public async buildGlobalVariables(
97
- blockNumber: number,
49
+ /** Builds global variables that are constant throughout a checkpoint. */
50
+ public async buildCheckpointGlobalVariables(
98
51
  coinbase: EthAddress,
99
52
  feeRecipient: AztecAddress,
100
- slotNumber?: bigint,
101
- ): 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);
110
-
111
- const slotFr = new Fr(slotNumber);
112
-
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));
53
+ slotNumber: SlotNumber,
54
+ simulationOverridesPlan?: SimulationOverridesPlan,
55
+ ): Promise<CheckpointGlobalVariables> {
56
+ const { chainId, version } = this;
57
+
58
+ const timestamp = getTimestampForSlot(slotNumber, {
59
+ slotDuration: this.aztecSlotDuration,
60
+ l1GenesisTime: this.l1GenesisTime,
61
+ });
115
62
 
116
- const globalVariables = new GlobalVariables(
117
- chainId,
118
- version,
119
- blockNumber,
120
- slotFr,
121
- timestamp,
122
- coinbase,
123
- feeRecipient,
124
- gasFees,
125
- );
63
+ const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
64
+ const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
126
65
 
127
- return globalVariables;
66
+ return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
128
67
  }
129
68
  }
@@ -1 +1,3 @@
1
- export { GlobalVariableBuilder } from './global_builder.js';
1
+ export { FeeProviderImpl } from './fee_provider.js';
2
+ export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';
3
+ export { FeePredictor } from './fee_predictor.js';
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,221 @@
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';
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';
8
4
  import {
9
5
  type ConfigMappingsType,
10
6
  SecretValue,
11
7
  booleanConfigHelper,
12
- getConfigFromMappings,
8
+ numberConfigHelper,
13
9
  } from '@aztec/foundation/config';
14
10
  import { EthAddress } from '@aztec/foundation/eth-address';
15
11
 
16
- /**
17
- * The configuration of the rollup transaction publisher.
18
- */
12
+ import { parseEther } from 'viem';
13
+
14
+ /** Configuration of the transaction publisher. */
19
15
  export type TxSenderConfig = L1ReaderConfig & {
20
- /**
21
- * The private key to be used by the publisher.
22
- */
16
+ /** The private key to be used by the publisher. */
23
17
  publisherPrivateKeys?: SecretValue<`0x${string}`>[];
24
18
 
25
- /**
26
- * Publisher addresses to be used with a remote signer
27
- */
19
+ /** Publisher addresses to be used with a remote signer */
28
20
  publisherAddresses?: EthAddress[];
29
21
  };
30
22
 
31
- /**
32
- * Configuration of the L1Publisher.
33
- */
23
+ export type ProverTxSenderConfig = L1ReaderConfig & {
24
+ proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
25
+ proverPublisherAddresses?: EthAddress[];
26
+ };
27
+
28
+ export type SequencerTxSenderConfig = L1ReaderConfig & {
29
+ sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
30
+ sequencerPublisherAddresses?: EthAddress[];
31
+ };
32
+
33
+ export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
34
+ return {
35
+ ...config,
36
+ publisherPrivateKeys: config.proverPublisherPrivateKeys,
37
+ publisherAddresses: config.proverPublisherAddresses,
38
+ };
39
+ }
40
+
41
+ export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
42
+ return {
43
+ ...config,
44
+ publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
45
+ publisherAddresses: config.sequencerPublisherAddresses,
46
+ };
47
+ }
48
+
49
+ /** Configuration of the L1Publisher. */
34
50
  export type PublisherConfig = L1TxUtilsConfig &
35
- BlobSinkConfig & {
51
+ BlobClientConfig & {
36
52
  /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
37
53
  publisherAllowInvalidStates?: boolean;
54
+ /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
55
+ fishermanMode?: boolean;
56
+ /** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
57
+ publisherForwarderAddress?: EthAddress;
58
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
59
+ l1TxFailedStore?: string;
60
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
61
+ publisherFundingThreshold?: bigint;
62
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
63
+ publisherFundingAmount?: bigint;
64
+ };
65
+
66
+ /** Shared config mappings for publisher funding, used by both sequencer and prover publisher configs. */
67
+ const publisherFundingConfigMappings = {
68
+ publisherFundingThreshold: {
69
+ env: 'PUBLISHER_FUNDING_THRESHOLD' as const,
70
+ description:
71
+ 'Min ETH balance below which a publisher gets funded. Specified in ether (e.g. 0.1). Unset = funding disabled.',
72
+ parseEnv: (val: string) => parseEther(val),
73
+ },
74
+ publisherFundingAmount: {
75
+ env: 'PUBLISHER_FUNDING_AMOUNT' as const,
76
+ description:
77
+ 'Amount of ETH to send when funding a publisher. Specified in ether (e.g. 0.5). Unset = funding disabled.',
78
+ parseEnv: (val: string) => parseEther(val),
79
+ },
80
+ };
81
+
82
+ export type ProverPublisherConfig = L1TxUtilsConfig &
83
+ BlobClientConfig & {
84
+ fishermanMode?: boolean;
85
+ proverPublisherAllowInvalidStates?: boolean;
86
+ proverPublisherForwarderAddress?: EthAddress;
87
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
88
+ publisherFundingThreshold?: bigint;
89
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
90
+ publisherFundingAmount?: bigint;
91
+ };
92
+
93
+ export type SequencerPublisherConfig = L1TxUtilsConfig &
94
+ BlobClientConfig & {
95
+ fishermanMode?: boolean;
96
+ sequencerPublisherAllowInvalidStates?: boolean;
97
+ sequencerPublisherForwarderAddress?: EthAddress;
98
+ /** How long to wait for the previous L1 block before sending scheduled publisher txs anyway. */
99
+ sequencerPublisherPreviousL1BlockWaitTimeoutMs: number;
100
+ /** Poll interval while waiting for the previous L1 block before scheduled publisher txs. */
101
+ sequencerPublisherPreviousL1BlockWaitPollIntervalMs: number;
102
+ /** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
103
+ l1TxFailedStore?: string;
104
+ /** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
105
+ publisherFundingThreshold?: bigint;
106
+ /** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
107
+ publisherFundingAmount?: bigint;
38
108
  };
39
109
 
40
- export const getTxSenderConfigMappings: (
41
- scope: 'PROVER' | 'SEQ',
42
- ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
110
+ export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
111
+ return {
112
+ ...config,
113
+ publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
114
+ publisherForwarderAddress: config.proverPublisherForwarderAddress,
115
+ };
116
+ }
117
+
118
+ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
119
+ return {
120
+ ...config,
121
+ publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
122
+ publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
123
+ l1TxFailedStore: config.l1TxFailedStore,
124
+ };
125
+ }
126
+
127
+ export const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig> = {
43
128
  ...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.',
47
- parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
129
+ proverPublisherPrivateKeys: {
130
+ env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
131
+ description: 'The private keys to be used by the prover publisher.',
132
+ parseEnv: (val: string) =>
133
+ val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
48
134
  defaultValue: [],
49
- fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
135
+ fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
50
136
  },
51
- publisherAddresses: {
52
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
137
+ proverPublisherAddresses: {
138
+ env: `PROVER_PUBLISHER_ADDRESSES`,
53
139
  description: 'The addresses of the publishers to use with remote signers',
54
140
  parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
55
141
  defaultValue: [],
56
142
  },
57
- });
143
+ };
58
144
 
59
- export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
60
- return getConfigFromMappings(getTxSenderConfigMappings(scope));
61
- }
145
+ export const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig> = {
146
+ ...l1ReaderConfigMappings,
147
+ sequencerPublisherPrivateKeys: {
148
+ env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
149
+ description: 'The private keys to be used by the sequencer publisher.',
150
+ parseEnv: (val: string) =>
151
+ val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
152
+ defaultValue: [],
153
+ fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
154
+ },
155
+ sequencerPublisherAddresses: {
156
+ env: `SEQ_PUBLISHER_ADDRESSES`,
157
+ description: 'The addresses of the publishers to use with remote signers',
158
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
159
+ defaultValue: [],
160
+ },
161
+ };
62
162
 
63
- export const getPublisherConfigMappings: (
64
- scope: 'PROVER' | 'SEQ',
65
- ) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
66
- publisherAllowInvalidStates: {
163
+ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
164
+ ...l1TxUtilsConfigMappings,
165
+ ...blobClientConfigMapping,
166
+ sequencerPublisherAllowInvalidStates: {
167
+ env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
67
168
  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
169
  ...booleanConfigHelper(true),
70
170
  },
71
- ...l1TxUtilsConfigMappings,
72
- ...blobSinkConfigMapping,
73
- });
171
+ fishermanMode: {
172
+ env: 'FISHERMAN_MODE',
173
+ description:
174
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
175
+ ...booleanConfigHelper(false),
176
+ },
177
+ sequencerPublisherForwarderAddress: {
178
+ env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
179
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
180
+ parseEnv: (val: string) => EthAddress.fromString(val),
181
+ },
182
+ sequencerPublisherPreviousL1BlockWaitTimeoutMs: {
183
+ env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_TIMEOUT_MS`,
184
+ description:
185
+ 'How long to wait for the previous L1 block before sending scheduled publisher txs anyway, in milliseconds.',
186
+ ...numberConfigHelper(8_000),
187
+ },
188
+ sequencerPublisherPreviousL1BlockWaitPollIntervalMs: {
189
+ env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_POLL_INTERVAL_MS`,
190
+ description:
191
+ 'Poll interval while waiting for the previous L1 block before scheduled publisher txs, in milliseconds.',
192
+ ...numberConfigHelper(500),
193
+ },
194
+ l1TxFailedStore: {
195
+ env: 'L1_TX_FAILED_STORE',
196
+ description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
197
+ },
198
+ ...publisherFundingConfigMappings,
199
+ };
74
200
 
75
- export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
76
- return getConfigFromMappings(getPublisherConfigMappings(scope));
77
- }
201
+ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
202
+ ...l1TxUtilsConfigMappings,
203
+ ...blobClientConfigMapping,
204
+ proverPublisherAllowInvalidStates: {
205
+ env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
206
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
207
+ ...booleanConfigHelper(true),
208
+ },
209
+ fishermanMode: {
210
+ env: 'FISHERMAN_MODE',
211
+ description:
212
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
213
+ ...booleanConfigHelper(false),
214
+ },
215
+ proverPublisherForwarderAddress: {
216
+ env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
217
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
218
+ parseEnv: (val: string) => EthAddress.fromString(val),
219
+ },
220
+ ...publisherFundingConfigMappings,
221
+ };
@@ -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,85 @@
1
+ import { RollupContract } from '@aztec/ethereum/contracts';
2
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
3
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { tryJsonStringify } from '@aztec/foundation/json-rpc';
6
+ import { createLogger } from '@aztec/foundation/log';
7
+ import { InboxAbi } from '@aztec/l1-artifacts';
8
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
+
10
+ import { decodeEventLog, getContract } from 'viem';
11
+
12
+ /**
13
+ * Sends an L1-to-L2 message via the Inbox contract and returns its hash and global leaf index.
14
+ * Test helper copied from the end-to-end fixtures so this integration test can live in sequencer-client.
15
+ */
16
+ export async function sendL1ToL2Message(
17
+ message: { recipient: AztecAddress; content: Fr; secretHash: Fr },
18
+ ctx: {
19
+ l1Client: ExtendedViemWalletClient;
20
+ l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress' | 'rollupAddress'>;
21
+ },
22
+ ) {
23
+ const logger = createLogger('sequencer-client:l1_to_l2_messaging');
24
+ const inbox = getContract({
25
+ address: ctx.l1ContractAddresses.inboxAddress.toString(),
26
+ abi: InboxAbi,
27
+ client: ctx.l1Client,
28
+ });
29
+
30
+ const { recipient, content, secretHash } = message;
31
+
32
+ const version = await new RollupContract(ctx.l1Client, ctx.l1ContractAddresses.rollupAddress.toString()).getVersion();
33
+
34
+ // We inject the message to Inbox
35
+ const txHash = await inbox.write.sendL2Message(
36
+ [{ actor: recipient.toString(), version: BigInt(version) }, content.toString(), secretHash.toString()],
37
+ {
38
+ gas: 1_000_000n,
39
+ },
40
+ );
41
+ logger.info(`L1 to L2 message sent in tx ${txHash}`);
42
+
43
+ // We check that the message was correctly injected by checking the emitted event
44
+ const txReceipt = await ctx.l1Client.waitForTransactionReceipt({ hash: txHash });
45
+
46
+ if (txReceipt.status !== 'success') {
47
+ throw new Error(`L1 to L2 message failed to be sent in tx ${txHash}. Status: ${txReceipt.status}`);
48
+ }
49
+
50
+ logger.info(`L1 to L2 message receipt retrieved for tx ${txReceipt.transactionHash}`, txReceipt);
51
+
52
+ if (txReceipt.transactionHash !== txHash) {
53
+ throw new Error(`Receipt transaction hash mismatch: ${txReceipt.transactionHash} !== ${txHash}`);
54
+ }
55
+
56
+ // Filter for MessageSent events from the Inbox contract by trying to decode each log
57
+ const messageSentLogs = txReceipt.logs
58
+ .filter(log => log.address.toLowerCase() === ctx.l1ContractAddresses.inboxAddress.toString().toLowerCase())
59
+ .map(log => {
60
+ try {
61
+ const decoded = decodeEventLog({
62
+ abi: InboxAbi,
63
+ data: log.data,
64
+ topics: log.topics,
65
+ });
66
+ return { log, decoded };
67
+ } catch {
68
+ return null; // Not a decodable event from this ABI
69
+ }
70
+ })
71
+ .filter((item): item is { log: any; decoded: any } => item !== null && item.decoded.eventName === 'MessageSent');
72
+
73
+ if (messageSentLogs.length !== 1) {
74
+ throw new Error(
75
+ `Wrong number of MessageSent logs found in ${txHash} transaction (got ${messageSentLogs.length} expected 1)\n${tryJsonStringify(messageSentLogs.map(item => item.log))}`,
76
+ );
77
+ }
78
+
79
+ // We already have the decoded event
80
+ const topics = messageSentLogs[0].decoded;
81
+ const receivedMsgHash = topics.args.hash;
82
+ const receivedGlobalLeafIndex = topics.args.index;
83
+
84
+ return { msgHash: Fr.fromHexString(receivedMsgHash), globalLeafIndex: new Fr(receivedGlobalLeafIndex), txReceipt };
85
+ }
@@ -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
+ }