@aztec/node-lib 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.
@@ -134,22 +134,30 @@ import { createLogger } from '@aztec/foundation/log';
134
134
  * Deletes a specific state and its associated blobs.
135
135
  * @param account - The sender account address
136
136
  * @param stateId - The state ID to delete
137
- */ async deleteState(account, stateId) {
138
- const key = this.makeKey(account, stateId);
139
- await this.states.delete(key);
140
- await this.blobs.delete(key);
141
- this.log.debug(`Deleted state ${stateId} for account ${account}`);
137
+ */ async deleteState(account, ...stateIds) {
138
+ if (stateIds.length === 0) {
139
+ return;
140
+ }
141
+ await this.store.transactionAsync(async ()=>{
142
+ for (const stateId of stateIds){
143
+ const key = this.makeKey(account, stateId);
144
+ await this.states.delete(key);
145
+ await this.blobs.delete(key);
146
+ }
147
+ });
142
148
  }
143
149
  /**
144
150
  * Clears all transaction states for a specific account.
145
151
  * @param account - The sender account address
146
152
  */ async clearStates(account) {
147
- const states = await this.loadStates(account);
148
- for (const state of states){
149
- await this.deleteState(account, state.id);
150
- }
151
- await this.stateIdCounter.delete(account);
152
- this.log.info(`Cleared all tx states for account ${account}`);
153
+ await this.store.transactionAsync(async ()=>{
154
+ const states = await this.loadStates(account);
155
+ for (const state of states){
156
+ await this.deleteState(account, state.id);
157
+ }
158
+ await this.stateIdCounter.delete(account);
159
+ this.log.info(`Cleared all tx states for account ${account}`);
160
+ });
153
161
  }
154
162
  /**
155
163
  * Gets all accounts that have stored states.
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@aztec/node-lib",
3
- "version": "0.0.1-commit.b655e406",
3
+ "version": "0.0.1-commit.b6e433891",
4
4
  "type": "module",
5
+ "typedocOptions": {
6
+ "entryPoints": [
7
+ "./src/actions/index.ts",
8
+ "./src/config/index.ts",
9
+ "./src/factories/index.ts"
10
+ ],
11
+ "name": "Node Library",
12
+ "tsconfig": "./tsconfig.json"
13
+ },
5
14
  "exports": {
6
15
  "./actions": "./dest/actions/index.js",
7
16
  "./config": "./dest/config/index.js",
@@ -13,8 +22,8 @@
13
22
  "../package.common.json"
14
23
  ],
15
24
  "scripts": {
16
- "build": "yarn clean && tsc -b",
17
- "build:dev": "tsc -b --watch",
25
+ "build": "yarn clean && ../scripts/tsc.sh",
26
+ "build:dev": "../scripts/tsc.sh --watch",
18
27
  "clean": "rm -rf ./dest .tsbuildinfo",
19
28
  "bb": "node --no-warnings ./dest/bb/index.js",
20
29
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
@@ -57,35 +66,37 @@
57
66
  ]
58
67
  },
59
68
  "dependencies": {
60
- "@aztec/archiver": "0.0.1-commit.b655e406",
61
- "@aztec/bb-prover": "0.0.1-commit.b655e406",
62
- "@aztec/blob-sink": "0.0.1-commit.b655e406",
63
- "@aztec/constants": "0.0.1-commit.b655e406",
64
- "@aztec/epoch-cache": "0.0.1-commit.b655e406",
65
- "@aztec/ethereum": "0.0.1-commit.b655e406",
66
- "@aztec/foundation": "0.0.1-commit.b655e406",
67
- "@aztec/kv-store": "0.0.1-commit.b655e406",
68
- "@aztec/merkle-tree": "0.0.1-commit.b655e406",
69
- "@aztec/p2p": "0.0.1-commit.b655e406",
70
- "@aztec/protocol-contracts": "0.0.1-commit.b655e406",
71
- "@aztec/prover-client": "0.0.1-commit.b655e406",
72
- "@aztec/sequencer-client": "0.0.1-commit.b655e406",
73
- "@aztec/simulator": "0.0.1-commit.b655e406",
74
- "@aztec/stdlib": "0.0.1-commit.b655e406",
75
- "@aztec/telemetry-client": "0.0.1-commit.b655e406",
76
- "@aztec/validator-client": "0.0.1-commit.b655e406",
77
- "@aztec/world-state": "0.0.1-commit.b655e406",
69
+ "@aztec/archiver": "0.0.1-commit.b6e433891",
70
+ "@aztec/bb-prover": "0.0.1-commit.b6e433891",
71
+ "@aztec/blob-client": "0.0.1-commit.b6e433891",
72
+ "@aztec/constants": "0.0.1-commit.b6e433891",
73
+ "@aztec/epoch-cache": "0.0.1-commit.b6e433891",
74
+ "@aztec/ethereum": "0.0.1-commit.b6e433891",
75
+ "@aztec/foundation": "0.0.1-commit.b6e433891",
76
+ "@aztec/kv-store": "0.0.1-commit.b6e433891",
77
+ "@aztec/p2p": "0.0.1-commit.b6e433891",
78
+ "@aztec/protocol-contracts": "0.0.1-commit.b6e433891",
79
+ "@aztec/prover-client": "0.0.1-commit.b6e433891",
80
+ "@aztec/sequencer-client": "0.0.1-commit.b6e433891",
81
+ "@aztec/simulator": "0.0.1-commit.b6e433891",
82
+ "@aztec/stdlib": "0.0.1-commit.b6e433891",
83
+ "@aztec/telemetry-client": "0.0.1-commit.b6e433891",
84
+ "@aztec/validator-client": "0.0.1-commit.b6e433891",
85
+ "@aztec/world-state": "0.0.1-commit.b6e433891",
78
86
  "tslib": "^2.4.0"
79
87
  },
80
88
  "devDependencies": {
81
- "@aztec/blob-lib": "0.0.1-commit.b655e406",
89
+ "@aztec/blob-lib": "0.0.1-commit.b6e433891",
90
+ "@aztec/node-keystore": "0.0.1-commit.b6e433891",
82
91
  "@jest/globals": "^30.0.0",
83
92
  "@types/jest": "^30.0.0",
84
93
  "@types/node": "^22.15.17",
94
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
85
95
  "jest": "^30.0.0",
86
96
  "jest-mock-extended": "^4.0.0",
87
97
  "ts-node": "^10.9.1",
88
- "typescript": "^5.3.3"
98
+ "typescript": "^5.3.3",
99
+ "viem": "npm:@aztec/viem@2.38.2"
89
100
  },
90
101
  "files": [
91
102
  "dest",
@@ -7,13 +7,13 @@ export async function buildSnapshotMetadata(
7
7
  archiver: Archiver,
8
8
  config: UploadSnapshotConfig,
9
9
  ): Promise<UploadSnapshotMetadata> {
10
- const [rollupAddress, l1BlockNumber, { latest }] = await Promise.all([
10
+ const [rollupAddress, l1BlockNumber, tips] = await Promise.all([
11
11
  archiver.getRollupAddress(),
12
12
  archiver.getL1BlockNumber(),
13
13
  archiver.getL2Tips(),
14
14
  ] as const);
15
15
 
16
- const { number: l2BlockNumber, hash: l2BlockHash } = latest;
16
+ const { number: l2BlockNumber, hash: l2BlockHash } = tips.proposed;
17
17
  if (!l2BlockHash) {
18
18
  throw new Error(`Failed to get L2 block hash from archiver.`);
19
19
  }
@@ -1,14 +1,15 @@
1
1
  import { ARCHIVER_DB_VERSION, ARCHIVER_STORE_NAME, type ArchiverConfig, createArchiverStore } from '@aztec/archiver';
2
2
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
3
- import { type EthereumClientConfig, getPublicClient } from '@aztec/ethereum';
3
+ import { type EthereumClientConfig, getPublicClient } from '@aztec/ethereum/client';
4
+ import type { L1ContractsConfig } from '@aztec/ethereum/config';
4
5
  import type { EthAddress } from '@aztec/foundation/eth-address';
5
6
  import { tryRmDir } from '@aztec/foundation/fs';
6
7
  import type { Logger } from '@aztec/foundation/log';
7
- import type { DataStoreConfig } from '@aztec/kv-store/config';
8
8
  import { P2P_STORE_NAME } from '@aztec/p2p';
9
9
  import type { ChainConfig } from '@aztec/stdlib/config';
10
- import { DatabaseVersionManager } from '@aztec/stdlib/database-version';
10
+ import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
11
11
  import { type ReadOnlyFileStore, createReadOnlyFileStore } from '@aztec/stdlib/file-store';
12
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
12
13
  import {
13
14
  type SnapshotMetadata,
14
15
  type SnapshotsIndexMetadata,
@@ -28,8 +29,10 @@ const MIN_L1_BLOCKS_TO_TRIGGER_REPLACE = 86400 / 2 / 12;
28
29
 
29
30
  type SnapshotSyncConfig = Pick<SharedNodeConfig, 'syncMode'> &
30
31
  Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
32
+ Pick<L1ContractsConfig, 'aztecEpochDuration'> &
31
33
  Pick<ArchiverConfig, 'archiverStoreMapSizeKb' | 'maxLogs'> &
32
- Required<DataStoreConfig> &
34
+ DataStoreConfig &
35
+ Required<Pick<DataStoreConfig, 'l1Contracts'>> &
33
36
  EthereumClientConfig & {
34
37
  snapshotsUrls?: string[];
35
38
  minL1BlocksToTriggerReplace?: number;
@@ -64,7 +67,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
64
67
  try {
65
68
  [archiverL1BlockNumber, archiverL2BlockNumber] = await Promise.all([
66
69
  archiverStore.getSynchPoint().then(s => s.blocksSynchedTo),
67
- archiverStore.getSynchedL2BlockNumber(),
70
+ archiverStore.getLatestBlockNumber(),
68
71
  ] as const);
69
72
  } finally {
70
73
  log.verbose(`Closing temporary archiver data store`, { archiverL1BlockNumber, archiverL2BlockNumber });
@@ -80,7 +83,11 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
80
83
  }
81
84
 
82
85
  const currentL1BlockNumber = await getPublicClient(config).getBlockNumber();
83
- if (archiverL1BlockNumber && currentL1BlockNumber - archiverL1BlockNumber < minL1BlocksToTriggerReplace) {
86
+ if (
87
+ archiverL1BlockNumber &&
88
+ currentL1BlockNumber >= archiverL1BlockNumber &&
89
+ currentL1BlockNumber - archiverL1BlockNumber < minL1BlocksToTriggerReplace
90
+ ) {
84
91
  log.verbose(
85
92
  `Skipping snapshot sync as archiver is less than ${
86
93
  currentL1BlockNumber - archiverL1BlockNumber
@@ -163,7 +170,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
163
170
  }
164
171
 
165
172
  if (snapshotCandidates.length === 0) {
166
- log.verbose(`No valid snapshots found from any URL. Skipping snapshot sync.`, { ...indexMetadata, snapshotsUrls });
173
+ log.verbose(`No valid snapshots found from any URL, skipping snapshot sync`, { ...indexMetadata, snapshotsUrls });
167
174
  return false;
168
175
  }
169
176
 
@@ -190,7 +197,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
190
197
  });
191
198
  return true;
192
199
  } catch (err) {
193
- log.error(`Failed to download snapshot from ${url}. Trying next candidate.`, err, {
200
+ log.error(`Failed to download snapshot from ${url}, trying next candidate`, err, {
194
201
  snapshot,
195
202
  snapshotsUrl: url,
196
203
  });
@@ -198,7 +205,7 @@ export async function trySnapshotSync(config: SnapshotSyncConfig, log: Logger) {
198
205
  }
199
206
  }
200
207
 
201
- log.error(`Failed to download snapshot from all URLs.`, { snapshotsUrls });
208
+ log.error(`Failed to download snapshot from all URLs`, { snapshotsUrls });
202
209
  return false;
203
210
  }
204
211
 
@@ -1,10 +1,10 @@
1
1
  import { ARCHIVER_DB_VERSION, type Archiver } from '@aztec/archiver';
2
2
  import { tryRmDir } from '@aztec/foundation/fs';
3
3
  import type { Logger } from '@aztec/foundation/log';
4
- import type { DataStoreConfig } from '@aztec/kv-store/config';
5
4
  import type { ChainConfig } from '@aztec/stdlib/config';
6
5
  import { createFileStore } from '@aztec/stdlib/file-store';
7
6
  import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
7
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
8
8
  import { uploadSnapshotToIndex } from '@aztec/stdlib/snapshots';
9
9
  import { WORLD_STATE_DB_VERSION } from '@aztec/world-state';
10
10
 
@@ -5,18 +5,22 @@ export type SharedNodeConfig = {
5
5
  testAccounts: boolean;
6
6
  /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
7
7
  sponsoredFPC: boolean;
8
+ /** Additional addresses to prefund with fee juice at genesis */
9
+ prefundAddresses: string[];
8
10
  /** Sync mode: full to always sync via L1, snapshot to download a snapshot if there is no local data, force-snapshot to download even if there is local data. */
9
11
  syncMode: 'full' | 'snapshot' | 'force-snapshot';
10
12
  /** Base URLs for snapshots index. Index file will be searched at `SNAPSHOTS_BASE_URL/aztec-L1_CHAIN_ID-VERSION-ROLLUP_ADDRESS/index.json` */
11
13
  snapshotsUrls?: string[];
12
-
13
- /** Auto update mode: disabled - to completely ignore remote signals to update the node. enabled - to respect the signals (potentially shutting this node down). log - check for updates but log a warning instead of applying them*/
14
- autoUpdate?: 'disabled' | 'notify' | 'config' | 'config-and-version';
15
- /** The base URL against which to check for updates */
16
- autoUpdateUrl?: string;
17
-
18
14
  /** URL of the Web3Signer instance */
19
15
  web3SignerUrl?: string;
16
+ /** Whether to run in fisherman mode */
17
+ fishermanMode?: boolean;
18
+
19
+ /** Force verification of tx Chonk proofs. Only used for testnet */
20
+ debugForceTxProofVerification: boolean;
21
+
22
+ /** Check if the node version matches the latest version for the network */
23
+ enableVersionCheck: boolean;
20
24
  };
21
25
 
22
26
  export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
@@ -30,6 +34,16 @@ export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
30
34
  description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
31
35
  ...booleanConfigHelper(false),
32
36
  },
37
+ prefundAddresses: {
38
+ env: 'PREFUND_ADDRESSES',
39
+ description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
40
+ parseEnv: (val: string) =>
41
+ val
42
+ .split(',')
43
+ .map(a => a.trim())
44
+ .filter(a => a.length > 0),
45
+ defaultValue: [],
46
+ },
33
47
  syncMode: {
34
48
  env: 'SYNC_MODE',
35
49
  description:
@@ -47,18 +61,25 @@ export const sharedNodeConfigMappings: ConfigMappingsType<SharedNodeConfig> = {
47
61
  fallback: ['SYNC_SNAPSHOTS_URL'],
48
62
  defaultValue: [],
49
63
  },
50
- autoUpdate: {
51
- env: 'AUTO_UPDATE',
52
- description: 'The auto update mode for this node',
53
- defaultValue: 'disabled',
54
- },
55
- autoUpdateUrl: {
56
- env: 'AUTO_UPDATE_URL',
57
- description: 'Base URL to check for updates',
58
- },
59
64
  web3SignerUrl: {
60
65
  env: 'WEB3_SIGNER_URL',
61
66
  description: 'URL of the Web3Signer instance',
62
67
  parseEnv: (val: string) => val.trim(),
63
68
  },
69
+ fishermanMode: {
70
+ env: 'FISHERMAN_MODE',
71
+ description: 'Whether to run in fisherman mode.',
72
+ ...booleanConfigHelper(false),
73
+ },
74
+ debugForceTxProofVerification: {
75
+ env: 'DEBUG_FORCE_TX_PROOF_VERIFICATION',
76
+ description: 'Whether to force tx proof verification. Only has an effect if real proving is turned off',
77
+ ...booleanConfigHelper(false),
78
+ },
79
+
80
+ enableVersionCheck: {
81
+ env: 'ENABLE_VERSION_CHECK',
82
+ description: 'Check if the node is running the latest version and is following the latest rollup',
83
+ ...booleanConfigHelper(true),
84
+ },
64
85
  };
@@ -1,17 +1,15 @@
1
- import {
2
- createL1TxUtilsFromEthSigner as createL1TxUtilsFromEthSignerBase,
3
- createL1TxUtilsFromViemWallet as createL1TxUtilsFromViemWalletBase,
4
- } from '@aztec/ethereum';
5
- import type { EthSigner, ExtendedViemWalletClient, L1TxUtilsConfig, ViemClient } from '@aztec/ethereum';
6
- import {
7
- createL1TxUtilsWithBlobsFromEthSigner as createL1TxUtilsWithBlobsFromEthSignerBase,
8
- createL1TxUtilsWithBlobsFromViemWallet as createL1TxUtilsWithBlobsFromViemWalletBase,
9
- } from '@aztec/ethereum/l1-tx-utils-with-blobs';
1
+ import type { BlobKzgInstance } from '@aztec/blob-lib/types';
2
+ import type { EthSigner } from '@aztec/ethereum/eth-signer';
3
+ import { createDelayer, createL1TxUtils as createL1TxUtilsBase } from '@aztec/ethereum/l1-tx-utils';
4
+ import type { L1TxUtilsConfig } from '@aztec/ethereum/l1-tx-utils';
5
+ import { createForwarderL1TxUtils as createForwarderL1TxUtilsBase } from '@aztec/ethereum/l1-tx-utils-with-blobs';
6
+ import type { ExtendedViemWalletClient, ViemClient } from '@aztec/ethereum/types';
10
7
  import { omit } from '@aztec/foundation/collection';
8
+ import type { EthAddress } from '@aztec/foundation/eth-address';
11
9
  import { createLogger } from '@aztec/foundation/log';
12
10
  import type { DateProvider } from '@aztec/foundation/timer';
13
- import type { DataStoreConfig } from '@aztec/kv-store/config';
14
11
  import { createStore } from '@aztec/kv-store/lmdb-v2';
12
+ import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
15
13
  import type { TelemetryClient } from '@aztec/telemetry-client';
16
14
 
17
15
  import type { L1TxScope } from '../metrics/l1_tx_metrics.js';
@@ -21,14 +19,15 @@ import { L1TxStore } from '../stores/l1_tx_store.js';
21
19
  const L1_TX_STORE_NAME = 'l1-tx-utils';
22
20
 
23
21
  /**
24
- * Creates shared dependencies (logger, store, metrics) for L1TxUtils instances.
22
+ * Creates shared dependencies (logger, store, metrics, delayer) for L1TxUtils instances.
23
+ * When enableDelayer is set in config, a single shared delayer is created and passed to all instances.
25
24
  */
26
25
  async function createSharedDeps(
27
- config: DataStoreConfig & { scope?: L1TxScope },
26
+ config: DataStoreConfig & Partial<L1TxUtilsConfig> & { scope?: L1TxScope },
28
27
  deps: {
29
28
  telemetry: TelemetryClient;
30
29
  logger?: ReturnType<typeof createLogger>;
31
- dateProvider?: DateProvider;
30
+ dateProvider: DateProvider;
32
31
  },
33
32
  ) {
34
33
  const logger = deps.logger ?? createLogger('l1-tx-utils');
@@ -36,87 +35,122 @@ async function createSharedDeps(
36
35
  // Note that we do NOT bind them to the rollup address, since we still need to
37
36
  // monitor and cancel txs for previous rollups to free up our nonces.
38
37
  const noRollupConfig = omit(config, 'l1Contracts');
39
- const kvStore = await createStore(L1_TX_STORE_NAME, L1TxStore.SCHEMA_VERSION, noRollupConfig, logger);
38
+ const kvStore = await createStore(L1_TX_STORE_NAME, L1TxStore.SCHEMA_VERSION, noRollupConfig, logger.getBindings());
40
39
  const store = new L1TxStore(kvStore, logger);
41
40
 
42
41
  const meter = deps.telemetry.getMeter('L1TxUtils');
43
42
  const metrics = new L1TxMetrics(meter, config.scope ?? 'other', logger);
44
43
 
45
- return { logger, store, metrics, dateProvider: deps.dateProvider };
44
+ // Create a single shared delayer for all L1TxUtils instances in this group
45
+ const delayer =
46
+ config.enableDelayer && config.ethereumSlotDuration !== undefined
47
+ ? createDelayer(deps.dateProvider, { ethereumSlotDuration: config.ethereumSlotDuration }, logger.getBindings())
48
+ : undefined;
49
+
50
+ return { logger, store, metrics, dateProvider: deps.dateProvider, delayer };
46
51
  }
47
52
 
48
53
  /**
49
- * Creates L1TxUtils with blobs from multiple Viem wallets, sharing store and metrics.
54
+ * Creates L1TxUtils from multiple Viem wallet clients, sharing store, metrics, and delayer.
55
+ * When kzg is provided in deps, blob support is enabled.
50
56
  */
51
- export async function createL1TxUtilsWithBlobsFromViemWallet(
57
+ export async function createL1TxUtilsFromWallets(
52
58
  clients: ExtendedViemWalletClient[],
53
59
  config: DataStoreConfig & Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean; scope?: L1TxScope },
54
60
  deps: {
55
61
  telemetry: TelemetryClient;
56
62
  logger?: ReturnType<typeof createLogger>;
57
- dateProvider?: DateProvider;
63
+ dateProvider: DateProvider;
64
+ kzg?: BlobKzgInstance;
58
65
  },
59
66
  ) {
60
67
  const sharedDeps = await createSharedDeps(config, deps);
61
68
 
62
- return clients.map(client =>
63
- createL1TxUtilsWithBlobsFromViemWalletBase(client, sharedDeps, config, config.debugMaxGasLimit),
64
- );
69
+ return clients.map(client => createL1TxUtilsBase(client, { ...sharedDeps, kzg: deps.kzg }, config));
65
70
  }
66
71
 
67
72
  /**
68
- * Creates L1TxUtils with blobs from multiple EthSigners, sharing store and metrics.
73
+ * Creates L1TxUtils from multiple EthSigners, sharing store, metrics, and delayer.
74
+ * When kzg is provided in deps, blob support is enabled.
75
+ * Deduplicates signers by address to avoid creating multiple instances for the same publisher.
69
76
  */
70
- export async function createL1TxUtilsWithBlobsFromEthSigner(
77
+ export async function createL1TxUtilsFromSigners(
71
78
  client: ViemClient,
72
79
  signers: EthSigner[],
73
80
  config: DataStoreConfig & Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean; scope?: L1TxScope },
74
81
  deps: {
75
82
  telemetry: TelemetryClient;
76
83
  logger?: ReturnType<typeof createLogger>;
77
- dateProvider?: DateProvider;
84
+ dateProvider: DateProvider;
85
+ kzg?: BlobKzgInstance;
78
86
  },
79
87
  ) {
80
88
  const sharedDeps = await createSharedDeps(config, deps);
81
89
 
82
- return signers.map(signer =>
83
- createL1TxUtilsWithBlobsFromEthSignerBase(client, signer, sharedDeps, config, config.debugMaxGasLimit),
84
- );
90
+ // Deduplicate signers by address to avoid creating multiple L1TxUtils instances
91
+ // for the same publisher address (e.g., when multiple attesters share the same publisher key)
92
+ const signersByAddress = new Map<string, EthSigner>();
93
+ for (const signer of signers) {
94
+ const addressKey = signer.address.toString().toLowerCase();
95
+ if (!signersByAddress.has(addressKey)) {
96
+ signersByAddress.set(addressKey, signer);
97
+ }
98
+ }
99
+
100
+ const uniqueSigners = Array.from(signersByAddress.values());
101
+
102
+ if (uniqueSigners.length < signers.length) {
103
+ sharedDeps.logger.info(
104
+ `Deduplicated ${signers.length} signers to ${uniqueSigners.length} unique publisher addresses`,
105
+ );
106
+ }
107
+
108
+ return uniqueSigners.map(signer => createL1TxUtilsBase({ client, signer }, { ...sharedDeps, kzg: deps.kzg }, config));
85
109
  }
86
110
 
87
111
  /**
88
- * Creates L1TxUtils (without blobs) from multiple Viem wallets, sharing store and metrics.
112
+ * Creates ForwarderL1TxUtils from multiple Viem wallet clients, sharing store, metrics, and delayer.
113
+ * Wraps all transactions through a forwarder contract for testing purposes.
114
+ * When kzg is provided in deps, blob support is enabled.
89
115
  */
90
- export async function createL1TxUtilsFromViemWalletWithStore(
116
+ export async function createForwarderL1TxUtilsFromWallets(
91
117
  clients: ExtendedViemWalletClient[],
118
+ forwarderAddress: EthAddress,
92
119
  config: DataStoreConfig & Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean; scope?: L1TxScope },
93
120
  deps: {
94
121
  telemetry: TelemetryClient;
95
122
  logger?: ReturnType<typeof createLogger>;
96
- dateProvider?: DateProvider;
97
- scope?: L1TxScope;
123
+ dateProvider: DateProvider;
124
+ kzg?: BlobKzgInstance;
98
125
  },
99
126
  ) {
100
127
  const sharedDeps = await createSharedDeps(config, deps);
101
128
 
102
- return clients.map(client => createL1TxUtilsFromViemWalletBase(client, sharedDeps, config));
129
+ return clients.map(client =>
130
+ createForwarderL1TxUtilsBase(client, forwarderAddress, { ...sharedDeps, kzg: deps.kzg }, config),
131
+ );
103
132
  }
104
133
 
105
134
  /**
106
- * Creates L1TxUtils (without blobs) from multiple EthSigners, sharing store and metrics.
135
+ * Creates ForwarderL1TxUtils from multiple EthSigners, sharing store, metrics, and delayer.
136
+ * Wraps all transactions through a forwarder contract for testing purposes.
137
+ * When kzg is provided in deps, blob support is enabled.
107
138
  */
108
- export async function createL1TxUtilsFromEthSignerWithStore(
139
+ export async function createForwarderL1TxUtilsFromSigners(
109
140
  client: ViemClient,
110
141
  signers: EthSigner[],
142
+ forwarderAddress: EthAddress,
111
143
  config: DataStoreConfig & Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean; scope?: L1TxScope },
112
144
  deps: {
113
145
  telemetry: TelemetryClient;
114
146
  logger?: ReturnType<typeof createLogger>;
115
- dateProvider?: DateProvider;
116
- scope?: L1TxScope;
147
+ dateProvider: DateProvider;
148
+ kzg?: BlobKzgInstance;
117
149
  },
118
150
  ) {
119
151
  const sharedDeps = await createSharedDeps(config, deps);
120
152
 
121
- return signers.map(signer => createL1TxUtilsFromEthSignerBase(client, signer, sharedDeps, config));
153
+ return signers.map(signer =>
154
+ createForwarderL1TxUtilsBase({ client, signer }, forwarderAddress, { ...sharedDeps, kzg: deps.kzg }, config),
155
+ );
122
156
  }
@@ -1,5 +1,5 @@
1
- import type { IL1TxMetrics, L1TxState } from '@aztec/ethereum';
2
- import { TxUtilsState } from '@aztec/ethereum';
1
+ import type { IL1TxMetrics, L1TxState } from '@aztec/ethereum/l1-tx-utils';
2
+ import { TxUtilsState } from '@aztec/ethereum/l1-tx-utils';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import {
5
5
  Attributes,
@@ -7,7 +7,7 @@ import {
7
7
  type Meter,
8
8
  Metrics,
9
9
  type UpDownCounter,
10
- ValueType,
10
+ createUpDownCounterWithDefault,
11
11
  } from '@aztec/telemetry-client';
12
12
 
13
13
  export type L1TxScope = 'sequencer' | 'prover' | 'other';
@@ -38,55 +38,24 @@ export class L1TxMetrics implements IL1TxMetrics {
38
38
  private scope: L1TxScope = 'other',
39
39
  private logger = createLogger('l1-tx-utils:metrics'),
40
40
  ) {
41
- this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION, {
42
- description: 'Time from initial tx send until mined',
43
- unit: 's',
44
- valueType: ValueType.INT,
45
- });
41
+ this.txMinedDuration = this.meter.createHistogram(Metrics.L1_TX_MINED_DURATION);
46
42
 
47
- this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED, {
48
- description: 'Number of tx attempts (including speed-ups) until mined',
49
- unit: 'attempts',
50
- valueType: ValueType.INT,
51
- });
43
+ this.txAttemptsUntilMined = this.meter.createHistogram(Metrics.L1_TX_ATTEMPTS_UNTIL_MINED);
52
44
 
53
- this.txMinedCount = this.meter.createUpDownCounter(Metrics.L1_TX_MINED_COUNT, {
54
- description: 'Count of transactions successfully mined',
55
- valueType: ValueType.INT,
56
- });
45
+ const scopeAttributes = [{ [Attributes.L1_TX_SCOPE]: this.scope }];
46
+ this.txMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_MINED_COUNT, scopeAttributes);
57
47
 
58
- this.txRevertedCount = this.meter.createUpDownCounter(Metrics.L1_TX_REVERTED_COUNT, {
59
- description: 'Count of transactions that reverted',
60
- valueType: ValueType.INT,
61
- });
48
+ this.txRevertedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_REVERTED_COUNT, scopeAttributes);
62
49
 
63
- this.txCancelledCount = this.meter.createUpDownCounter(Metrics.L1_TX_CANCELLED_COUNT, {
64
- description: 'Count of transactions cancelled',
65
- valueType: ValueType.INT,
66
- });
50
+ this.txCancelledCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_CANCELLED_COUNT, scopeAttributes);
67
51
 
68
- this.txNotMinedCount = this.meter.createUpDownCounter(Metrics.L1_TX_NOT_MINED_COUNT, {
69
- description: 'Count of transactions not mined (timed out)',
70
- valueType: ValueType.INT,
71
- });
52
+ this.txNotMinedCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_TX_NOT_MINED_COUNT, scopeAttributes);
72
53
 
73
- this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE, {
74
- description: 'Max priority fee per gas at tx end state (in wei)',
75
- unit: 'wei',
76
- valueType: ValueType.INT,
77
- });
54
+ this.maxPriorityFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_PRIORITY_FEE);
78
55
 
79
- this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE, {
80
- description: 'Max fee per gas at tx end state (in wei)',
81
- unit: 'wei',
82
- valueType: ValueType.INT,
83
- });
56
+ this.maxFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_MAX_FEE);
84
57
 
85
- this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE, {
86
- description: 'Max fee per blob gas at tx end state (in wei)',
87
- unit: 'wei',
88
- valueType: ValueType.INT,
89
- });
58
+ this.blobFeeHistogram = this.meter.createHistogram(Metrics.L1_TX_BLOB_FEE);
90
59
  }
91
60
 
92
61
  /**
@@ -1,4 +1,4 @@
1
- import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum';
1
+ import type { IL1TxStore, L1BlobInputs, L1TxConfig, L1TxState } from '@aztec/ethereum/l1-tx-utils';
2
2
  import { jsonStringify } from '@aztec/foundation/json-rpc';
3
3
  import type { Logger } from '@aztec/foundation/log';
4
4
  import { createLogger } from '@aztec/foundation/log';
@@ -231,11 +231,18 @@ export class L1TxStore implements IL1TxStore {
231
231
  * @param account - The sender account address
232
232
  * @param stateId - The state ID to delete
233
233
  */
234
- public async deleteState(account: string, stateId: number): Promise<void> {
235
- const key = this.makeKey(account, stateId);
236
- await this.states.delete(key);
237
- await this.blobs.delete(key);
238
- this.log.debug(`Deleted state ${stateId} for account ${account}`);
234
+ public async deleteState(account: string, ...stateIds: number[]): Promise<void> {
235
+ if (stateIds.length === 0) {
236
+ return;
237
+ }
238
+
239
+ await this.store.transactionAsync(async () => {
240
+ for (const stateId of stateIds) {
241
+ const key = this.makeKey(account, stateId);
242
+ await this.states.delete(key);
243
+ await this.blobs.delete(key);
244
+ }
245
+ });
239
246
  }
240
247
 
241
248
  /**
@@ -243,14 +250,16 @@ export class L1TxStore implements IL1TxStore {
243
250
  * @param account - The sender account address
244
251
  */
245
252
  public async clearStates(account: string): Promise<void> {
246
- const states = await this.loadStates(account);
253
+ await this.store.transactionAsync(async () => {
254
+ const states = await this.loadStates(account);
247
255
 
248
- for (const state of states) {
249
- await this.deleteState(account, state.id);
250
- }
256
+ for (const state of states) {
257
+ await this.deleteState(account, state.id);
258
+ }
251
259
 
252
- await this.stateIdCounter.delete(account);
253
- this.log.info(`Cleared all tx states for account ${account}`);
260
+ await this.stateIdCounter.delete(account);
261
+ this.log.info(`Cleared all tx states for account ${account}`);
262
+ });
254
263
  }
255
264
 
256
265
  /**