@aztec/sequencer-client 3.0.3 → 3.9.9-nightly.20260312

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 (93) hide show
  1. package/dest/client/sequencer-client.d.ts +32 -15
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +116 -27
  4. package/dest/config.d.ts +29 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +103 -40
  7. package/dest/global_variable_builder/global_builder.d.ts +17 -11
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +48 -39
  10. package/dest/index.d.ts +2 -3
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -2
  13. package/dest/publisher/config.d.ts +33 -19
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +102 -43
  16. package/dest/publisher/sequencer-publisher-factory.d.ts +13 -5
  17. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  18. package/dest/publisher/sequencer-publisher-factory.js +14 -3
  19. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  20. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  21. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  22. package/dest/publisher/sequencer-publisher.d.ts +58 -45
  23. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher.js +628 -139
  25. package/dest/sequencer/checkpoint_proposal_job.d.ts +100 -0
  26. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  27. package/dest/sequencer/checkpoint_proposal_job.js +1234 -0
  28. package/dest/sequencer/checkpoint_voter.d.ts +35 -0
  29. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  30. package/dest/sequencer/checkpoint_voter.js +109 -0
  31. package/dest/sequencer/events.d.ts +46 -0
  32. package/dest/sequencer/events.d.ts.map +1 -0
  33. package/dest/sequencer/events.js +1 -0
  34. package/dest/sequencer/index.d.ts +4 -2
  35. package/dest/sequencer/index.d.ts.map +1 -1
  36. package/dest/sequencer/index.js +3 -1
  37. package/dest/sequencer/metrics.d.ts +37 -5
  38. package/dest/sequencer/metrics.d.ts.map +1 -1
  39. package/dest/sequencer/metrics.js +216 -72
  40. package/dest/sequencer/sequencer.d.ts +122 -131
  41. package/dest/sequencer/sequencer.d.ts.map +1 -1
  42. package/dest/sequencer/sequencer.js +705 -635
  43. package/dest/sequencer/timetable.d.ts +54 -16
  44. package/dest/sequencer/timetable.d.ts.map +1 -1
  45. package/dest/sequencer/timetable.js +147 -62
  46. package/dest/sequencer/types.d.ts +3 -0
  47. package/dest/sequencer/types.d.ts.map +1 -0
  48. package/dest/sequencer/types.js +1 -0
  49. package/dest/sequencer/utils.d.ts +14 -8
  50. package/dest/sequencer/utils.d.ts.map +1 -1
  51. package/dest/sequencer/utils.js +7 -4
  52. package/dest/test/index.d.ts +5 -6
  53. package/dest/test/index.d.ts.map +1 -1
  54. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  55. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  56. package/dest/test/mock_checkpoint_builder.js +233 -0
  57. package/dest/test/utils.d.ts +53 -0
  58. package/dest/test/utils.d.ts.map +1 -0
  59. package/dest/test/utils.js +104 -0
  60. package/package.json +30 -28
  61. package/src/client/sequencer-client.ts +154 -45
  62. package/src/config.ts +119 -45
  63. package/src/global_variable_builder/global_builder.ts +57 -51
  64. package/src/index.ts +1 -7
  65. package/src/publisher/config.ts +115 -46
  66. package/src/publisher/sequencer-publisher-factory.ts +26 -9
  67. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  68. package/src/publisher/sequencer-publisher.ts +334 -176
  69. package/src/sequencer/README.md +531 -0
  70. package/src/sequencer/checkpoint_proposal_job.ts +950 -0
  71. package/src/sequencer/checkpoint_voter.ts +130 -0
  72. package/src/sequencer/events.ts +27 -0
  73. package/src/sequencer/index.ts +3 -1
  74. package/src/sequencer/metrics.ts +267 -81
  75. package/src/sequencer/sequencer.ts +444 -834
  76. package/src/sequencer/timetable.ts +178 -83
  77. package/src/sequencer/types.ts +6 -0
  78. package/src/sequencer/utils.ts +18 -9
  79. package/src/test/index.ts +4 -5
  80. package/src/test/mock_checkpoint_builder.ts +325 -0
  81. package/src/test/utils.ts +167 -0
  82. package/dest/sequencer/block_builder.d.ts +0 -28
  83. package/dest/sequencer/block_builder.d.ts.map +0 -1
  84. package/dest/sequencer/block_builder.js +0 -127
  85. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  86. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  87. package/dest/tx_validator/nullifier_cache.js +0 -24
  88. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  89. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  90. package/dest/tx_validator/tx_validator_factory.js +0 -53
  91. package/src/sequencer/block_builder.ts +0 -214
  92. package/src/tx_validator/nullifier_cache.ts +0 -30
  93. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -8,8 +8,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
8
8
  import type { EthAddress } from '@aztec/foundation/eth-address';
9
9
  import { createLogger } from '@aztec/foundation/log';
10
10
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
11
12
  import { GasFees } from '@aztec/stdlib/gas';
12
- import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
13
+ import type {
14
+ CheckpointGlobalVariables,
15
+ GlobalVariableBuilder as GlobalVariableBuilderInterface,
16
+ } from '@aztec/stdlib/tx';
13
17
  import { GlobalVariables } from '@aztec/stdlib/tx';
14
18
 
15
19
  import { createPublicClient, fallback, http } from 'viem';
@@ -19,26 +23,37 @@ import { createPublicClient, fallback, http } from 'viem';
19
23
  */
20
24
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
21
25
  private log = createLogger('sequencer:global_variable_builder');
22
- private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
26
+ private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
23
27
  private currentL1BlockNumber: bigint | undefined = undefined;
24
28
 
25
29
  private readonly rollupContract: RollupContract;
26
30
  private readonly publicClient: ViemPublicClient;
27
31
  private readonly ethereumSlotDuration: number;
32
+ private readonly aztecSlotDuration: number;
33
+ private readonly l1GenesisTime: bigint;
28
34
 
29
- private chainId?: Fr;
30
- private version?: Fr;
35
+ private chainId: Fr;
36
+ private version: Fr;
31
37
 
32
- constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
38
+ constructor(
39
+ config: L1ReaderConfig &
40
+ Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
41
+ Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
42
+ ) {
33
43
  const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
34
44
 
35
45
  const chain = createEthereumChain(l1RpcUrls, chainId);
36
46
 
47
+ this.version = new Fr(config.rollupVersion);
48
+ this.chainId = new Fr(chainId);
49
+
37
50
  this.ethereumSlotDuration = config.ethereumSlotDuration;
51
+ this.aztecSlotDuration = config.slotDuration;
52
+ this.l1GenesisTime = config.l1GenesisTime;
38
53
 
39
54
  this.publicClient = createPublicClient({
40
55
  chain: chain.chainInfo,
41
- transport: fallback(chain.rpcUrls.map(url => http(url))),
56
+ transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
42
57
  pollingInterval: config.viemPollingIntervalMS,
43
58
  });
44
59
 
@@ -46,48 +61,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
46
61
  }
47
62
 
48
63
  /**
49
- * Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
50
- * @returns Base fees for the next block
64
+ * Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
65
+ * @returns Min fees for the next block
51
66
  */
52
- private async computeCurrentBaseFees(): Promise<GasFees> {
67
+ private async computeCurrentMinFees(): Promise<GasFees> {
53
68
  // Since this might be called in the middle of a slot where a block might have been published,
54
69
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
55
70
  // The timestamp of that last block will act as a lower bound for the next block.
56
71
 
57
- const lastBlock = await this.rollupContract.getCheckpoint(await this.rollupContract.getCheckpointNumber());
72
+ const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
58
73
  const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
59
- SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
74
+ SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
60
75
  );
61
76
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
62
77
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
63
78
 
64
- return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
79
+ return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
65
80
  }
66
81
 
67
- public async getCurrentBaseFees(): Promise<GasFees> {
82
+ public async getCurrentMinFees(): Promise<GasFees> {
68
83
  // Get the current block number
69
84
  const blockNumber = await this.publicClient.getBlockNumber();
70
85
 
71
- // If the L1 block number has changed then chain a new promise to get the current base fees
86
+ // If the L1 block number has changed then chain a new promise to get the current min fees
72
87
  if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
73
88
  this.currentL1BlockNumber = blockNumber;
74
- this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
75
- }
76
- return this.currentBaseFees;
77
- }
78
-
79
- public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
80
- if (!this.chainId) {
81
- this.chainId = new Fr(this.publicClient.chain.id);
82
- }
83
- if (!this.version) {
84
- this.version = new Fr(await this.rollupContract.getVersion());
89
+ this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
85
90
  }
86
- return { chainId: this.chainId, version: this.version };
91
+ return this.currentMinFees;
87
92
  }
88
93
 
89
94
  /**
90
- * Simple builder of global variables that use the minimum time possible.
95
+ * Simple builder of global variables.
91
96
  * @param blockNumber - The block number to build global variables for.
92
97
  * @param coinbase - The address to receive block reward.
93
98
  * @param feeRecipient - The address to receive fees.
@@ -98,34 +103,35 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
98
103
  blockNumber: BlockNumber,
99
104
  coinbase: EthAddress,
100
105
  feeRecipient: AztecAddress,
101
- slotNumber?: SlotNumber,
106
+ maybeSlot?: SlotNumber,
102
107
  ): Promise<GlobalVariables> {
103
- const { chainId, version } = await this.getGlobalConstantVariables();
104
-
105
- let slot: SlotNumber;
106
- if (slotNumber === undefined) {
107
- const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
108
- slot = await this.rollupContract.getSlotAt(ts);
109
- } else {
110
- slot = slotNumber;
111
- }
108
+ const slot: SlotNumber =
109
+ maybeSlot ??
110
+ (await this.rollupContract.getSlotAt(
111
+ BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
112
+ ));
113
+
114
+ const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
115
+ return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
116
+ }
112
117
 
113
- const timestamp = await this.rollupContract.getTimestampForSlot(slot);
118
+ /** Builds global variables that are constant throughout a checkpoint. */
119
+ public async buildCheckpointGlobalVariables(
120
+ coinbase: EthAddress,
121
+ feeRecipient: AztecAddress,
122
+ slotNumber: SlotNumber,
123
+ ): Promise<CheckpointGlobalVariables> {
124
+ const { chainId, version } = this;
114
125
 
115
- // We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
116
- const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
126
+ const timestamp = getTimestampForSlot(slotNumber, {
127
+ slotDuration: this.aztecSlotDuration,
128
+ l1GenesisTime: this.l1GenesisTime,
129
+ });
117
130
 
118
- const globalVariables = new GlobalVariables(
119
- chainId,
120
- version,
121
- blockNumber,
122
- slot,
123
- timestamp,
124
- coinbase,
125
- feeRecipient,
126
- gasFees,
127
- );
131
+ // We can skip much of the logic in getCurrentMinFees since it we already check that we are not within a slot elsewhere.
132
+ // TODO(palla/mbps): Can we use a cached value here?
133
+ const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
128
134
 
129
- return globalVariables;
135
+ return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
130
136
  }
131
137
  }
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,34 +1,47 @@
1
- import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client/config';
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
+ /** Configuration of the transaction publisher. */
15
8
  export type TxSenderConfig = L1ReaderConfig & {
16
- /**
17
- * The private key to be used by the publisher.
18
- */
9
+ /** The private key to be used by the publisher. */
19
10
  publisherPrivateKeys?: SecretValue<`0x${string}`>[];
20
11
 
21
- /**
22
- * Publisher addresses to be used with a remote signer
23
- */
12
+ /** Publisher addresses to be used with a remote signer */
24
13
  publisherAddresses?: EthAddress[];
25
14
  };
26
15
 
27
- /**
28
- * Configuration of the L1Publisher.
29
- */
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. */
30
43
  export type PublisherConfig = L1TxUtilsConfig &
31
- BlobSinkConfig & {
44
+ BlobClientConfig & {
32
45
  /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
33
46
  publisherAllowInvalidStates?: boolean;
34
47
  /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
@@ -37,35 +50,76 @@ export type PublisherConfig = L1TxUtilsConfig &
37
50
  publisherForwarderAddress?: EthAddress;
38
51
  };
39
52
 
40
- export const getTxSenderConfigMappings: (
41
- scope: 'PROVER' | 'SEQ',
42
- ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
53
+ export type ProverPublisherConfig = L1TxUtilsConfig &
54
+ BlobClientConfig & {
55
+ fishermanMode?: boolean;
56
+ proverPublisherAllowInvalidStates?: boolean;
57
+ proverPublisherForwarderAddress?: EthAddress;
58
+ };
59
+
60
+ export type SequencerPublisherConfig = L1TxUtilsConfig &
61
+ BlobClientConfig & {
62
+ fishermanMode?: boolean;
63
+ sequencerPublisherAllowInvalidStates?: boolean;
64
+ sequencerPublisherForwarderAddress?: EthAddress;
65
+ };
66
+
67
+ export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
68
+ return {
69
+ ...config,
70
+ publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
71
+ publisherForwarderAddress: config.proverPublisherForwarderAddress,
72
+ };
73
+ }
74
+
75
+ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
76
+ return {
77
+ ...config,
78
+ publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
79
+ publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
80
+ };
81
+ }
82
+
83
+ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
43
84
  ...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.',
85
+ proverPublisherPrivateKeys: {
86
+ env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
87
+ description: 'The private keys to be used by the prover publisher.',
47
88
  parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
48
89
  defaultValue: [],
49
- fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
90
+ fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
50
91
  },
51
- publisherAddresses: {
52
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
92
+ proverPublisherAddresses: {
93
+ env: `PROVER_PUBLISHER_ADDRESSES`,
53
94
  description: 'The addresses of the publishers to use with remote signers',
54
95
  parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
55
96
  defaultValue: [],
56
97
  },
57
- });
98
+ };
58
99
 
59
- export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
60
- return getConfigFromMappings(getTxSenderConfigMappings(scope));
61
- }
100
+ export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
101
+ ...l1ReaderConfigMappings,
102
+ sequencerPublisherPrivateKeys: {
103
+ env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
104
+ description: 'The private keys to be used by the sequencer publisher.',
105
+ parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
106
+ defaultValue: [],
107
+ fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
108
+ },
109
+ sequencerPublisherAddresses: {
110
+ env: `SEQ_PUBLISHER_ADDRESSES`,
111
+ description: 'The addresses of the publishers to use with remote signers',
112
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
113
+ defaultValue: [],
114
+ },
115
+ };
62
116
 
63
- export const getPublisherConfigMappings: (
64
- scope: 'PROVER' | 'SEQ',
65
- ) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
66
- publisherAllowInvalidStates: {
117
+ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
118
+ ...l1TxUtilsConfigMappings,
119
+ ...blobClientConfigMapping,
120
+ sequencerPublisherAllowInvalidStates: {
121
+ env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
67
122
  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
123
  ...booleanConfigHelper(true),
70
124
  },
71
125
  fishermanMode: {
@@ -74,15 +128,30 @@ export const getPublisherConfigMappings: (
74
128
  'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
75
129
  ...booleanConfigHelper(false),
76
130
  },
77
- publisherForwarderAddress: {
78
- env: scope === `PROVER` ? `PROVER_PUBLISHER_FORWARDER_ADDRESS` : `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
131
+ sequencerPublisherForwarderAddress: {
132
+ env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
79
133
  description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
80
134
  parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
81
135
  },
82
- ...l1TxUtilsConfigMappings,
83
- ...blobSinkConfigMapping,
84
- });
136
+ };
85
137
 
86
- export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
87
- return getConfigFromMappings(getPublisherConfigMappings(scope));
88
- }
138
+ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
139
+ ...l1TxUtilsConfigMappings,
140
+ ...blobClientConfigMapping,
141
+ proverPublisherAllowInvalidStates: {
142
+ env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
143
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
144
+ ...booleanConfigHelper(true),
145
+ },
146
+ fishermanMode: {
147
+ env: 'FISHERMAN_MODE',
148
+ description:
149
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
150
+ ...booleanConfigHelper(false),
151
+ },
152
+ proverPublisherForwarderAddress: {
153
+ env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
154
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
155
+ parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
156
+ },
157
+ };
@@ -1,9 +1,9 @@
1
1
  import { EthAddress } from '@aztec/aztec.js/addresses';
2
2
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
3
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
4
4
  import type { EpochCache } from '@aztec/epoch-cache';
5
5
  import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
- import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
6
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
7
7
  import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
8
8
  import { SlotNumber } from '@aztec/foundation/branded-types';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
@@ -26,14 +26,16 @@ export class SequencerPublisherFactory {
26
26
  /** Stores the last slot in which every action was carried out by a publisher */
27
27
  private lastActions: Partial<Record<Action, SlotNumber>> = {};
28
28
 
29
+ private nodeKeyStore: NodeKeystoreAdapter;
30
+
29
31
  private logger: Logger;
30
32
 
31
33
  constructor(
32
34
  private sequencerConfig: SequencerClientConfig,
33
35
  private deps: {
34
36
  telemetry: TelemetryClient;
35
- publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
36
- blobSinkClient?: BlobSinkClientInterface;
37
+ publisherManager: PublisherManager<L1TxUtils>;
38
+ blobClient: BlobClientInterface;
37
39
  dateProvider: DateProvider;
38
40
  epochCache: EpochCache;
39
41
  rollupContract: RollupContract;
@@ -45,7 +47,17 @@ export class SequencerPublisherFactory {
45
47
  ) {
46
48
  this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
47
49
  this.logger = deps.logger ?? createLogger('sequencer');
50
+ this.nodeKeyStore = this.deps.nodeKeyStore;
51
+ }
52
+
53
+ /**
54
+ * Updates the node keystore adapter used for publisher lookups.
55
+ * Called when the keystore is reloaded at runtime to reflect new validator-publisher mappings.
56
+ */
57
+ public updateNodeKeyStore(adapter: NodeKeystoreAdapter): void {
58
+ this.nodeKeyStore = adapter;
48
59
  }
60
+
49
61
  /**
50
62
  * Creates a new SequencerPublisher instance.
51
63
  * @param _validatorAddress - The address of the validator that will be using the publisher.
@@ -54,17 +66,17 @@ export class SequencerPublisherFactory {
54
66
  public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
55
67
  // If we have been given an attestor address we must only allow publishers permitted for that attestor
56
68
 
57
- const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
58
- const filter: PublisherFilter<L1TxUtilsWithBlobs> = !validatorAddress
69
+ const allowedPublishers = !validatorAddress ? [] : this.nodeKeyStore.getPublisherAddresses(validatorAddress);
70
+ const filter: PublisherFilter<L1TxUtils> = !validatorAddress
59
71
  ? () => true
60
- : (utils: L1TxUtilsWithBlobs) => {
72
+ : (utils: L1TxUtils) => {
61
73
  const publisherAddress = utils.getSenderAddress();
62
74
  return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
63
75
  };
64
76
 
65
77
  const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
66
78
  const attestorAddress =
67
- validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
79
+ validatorAddress ?? this.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
68
80
 
69
81
  const rollup = this.deps.rollupContract;
70
82
  const slashingProposerContract = await rollup.getSlashingProposer();
@@ -72,7 +84,7 @@ export class SequencerPublisherFactory {
72
84
  const publisher = new SequencerPublisher(this.sequencerConfig, {
73
85
  l1TxUtils: l1Publisher,
74
86
  telemetry: this.deps.telemetry,
75
- blobSinkClient: this.deps.blobSinkClient,
87
+ blobClient: this.deps.blobClient,
76
88
  rollupContract: this.deps.rollupContract,
77
89
  epochCache: this.deps.epochCache,
78
90
  governanceProposerContract: this.deps.governanceProposerContract,
@@ -89,4 +101,9 @@ export class SequencerPublisherFactory {
89
101
  publisher,
90
102
  };
91
103
  }
104
+
105
+ /** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
106
+ public interruptAll(): void {
107
+ this.deps.publisherManager.interrupt();
108
+ }
92
109
  }
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
- import type { L1PublishBlockStats, L1PublishStats } from '@aztec/stdlib/stats';
2
+ import type { L1PublishCheckpointStats, L1PublishStats } from '@aztec/stdlib/stats';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -7,7 +7,7 @@ import {
7
7
  Metrics,
8
8
  type TelemetryClient,
9
9
  type UpDownCounter,
10
- ValueType,
10
+ createUpDownCounterWithDefault,
11
11
  } from '@aztec/telemetry-client';
12
12
 
13
13
  import { formatEther } from 'viem/utils';
@@ -40,88 +40,36 @@ export class SequencerPublisherMetrics {
40
40
  ) {
41
41
  const meter = client.getMeter(name);
42
42
 
43
- this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE, {
44
- description: 'The gas price used for transactions',
45
- unit: 'gwei',
46
- valueType: ValueType.DOUBLE,
47
- });
43
+ this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
48
44
 
49
- this.txCount = meter.createUpDownCounter(Metrics.L1_PUBLISHER_TX_COUNT, {
50
- description: 'The number of transactions processed',
45
+ this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
46
+ [Attributes.L1_TX_TYPE]: ['process'],
47
+ [Attributes.OK]: [true, false],
51
48
  });
52
49
 
53
- this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION, {
54
- description: 'The duration of transaction processing',
55
- unit: 'ms',
56
- valueType: ValueType.INT,
57
- });
50
+ this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
58
51
 
59
- this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS, {
60
- description: 'The gas consumed by transactions',
61
- unit: 'gas',
62
- valueType: ValueType.INT,
63
- });
52
+ this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
64
53
 
65
- this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE, {
66
- description: 'The size of the calldata in transactions',
67
- unit: 'By',
68
- valueType: ValueType.INT,
69
- });
54
+ this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
70
55
 
71
- this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS, {
72
- description: 'The gas consumed by the calldata in transactions',
73
- unit: 'gas',
74
- valueType: ValueType.INT,
75
- });
56
+ this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
76
57
 
77
- this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED, {
78
- description: 'The amount of blob gas used in transactions',
79
- unit: 'gas',
80
- valueType: ValueType.INT,
81
- });
58
+ this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
82
59
 
83
- this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST, {
84
- description: 'The gas cost of blobs in transactions',
85
- unit: 'gwei',
86
- valueType: ValueType.INT,
87
- });
60
+ this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
88
61
 
89
- this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT, {
90
- description: 'Number of blobs in L1 transactions',
91
- unit: 'blobs',
92
- valueType: ValueType.INT,
93
- });
62
+ this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT);
94
63
 
95
- this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS, {
96
- description: 'Number of L1 blocks between blob tx submission and inclusion',
97
- unit: 'blocks',
98
- valueType: ValueType.INT,
99
- });
64
+ this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
100
65
 
101
- this.blobTxSuccessCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS, {
102
- description: 'Number of successful L1 transactions with blobs',
103
- });
66
+ this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
104
67
 
105
- this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
106
- description: 'Number of failed L1 transactions with blobs',
107
- });
68
+ this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
108
69
 
109
- this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
110
- description: 'How much L1 tx costs',
111
- unit: 'eth',
112
- valueType: ValueType.DOUBLE,
113
- advice: {
114
- explicitBucketBoundaries: [
115
- 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
116
- ],
117
- },
118
- });
70
+ this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
119
71
 
120
- this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
121
- unit: 'eth',
122
- description: 'The balance of the sender address',
123
- valueType: ValueType.DOUBLE,
124
- });
72
+ this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
125
73
  }
126
74
 
127
75
  recordFailedTx(txType: L1TxType) {
@@ -135,7 +83,7 @@ export class SequencerPublisherMetrics {
135
83
  }
136
84
  }
137
85
 
138
- recordProcessBlockTx(durationMs: number, stats: L1PublishBlockStats) {
86
+ recordProcessBlockTx(durationMs: number, stats: L1PublishCheckpointStats) {
139
87
  this.recordTx('process', durationMs, stats);
140
88
 
141
89
  if (stats.blobCount && stats.blobCount > 0) {