@aztec/ethereum 3.0.0-nightly.20251003 → 3.0.0-nightly.20251004

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 (37) hide show
  1. package/dest/config.js +1 -1
  2. package/dest/contracts/multicall.d.ts +2 -2
  3. package/dest/contracts/multicall.d.ts.map +1 -1
  4. package/dest/contracts/rollup.d.ts +1 -1
  5. package/dest/contracts/rollup.d.ts.map +1 -1
  6. package/dest/contracts/rollup.js +1 -1
  7. package/dest/deploy_l1_contracts.d.ts +2 -2
  8. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  9. package/dest/l1_tx_utils/config.d.ts +10 -7
  10. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  11. package/dest/l1_tx_utils/config.js +12 -6
  12. package/dest/l1_tx_utils/l1_tx_utils.d.ts +16 -4
  13. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  14. package/dest/l1_tx_utils/l1_tx_utils.js +259 -129
  15. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +2 -2
  16. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  17. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +10 -20
  18. package/dest/l1_tx_utils/types.d.ts +11 -2
  19. package/dest/l1_tx_utils/types.d.ts.map +1 -1
  20. package/dest/l1_tx_utils/types.js +17 -0
  21. package/dest/publisher_manager.d.ts.map +1 -1
  22. package/dest/publisher_manager.js +16 -6
  23. package/dest/test/eth_cheat_codes.d.ts +18 -1
  24. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  25. package/dest/test/eth_cheat_codes.js +101 -22
  26. package/package.json +5 -5
  27. package/src/config.ts +1 -1
  28. package/src/contracts/multicall.ts +3 -6
  29. package/src/contracts/rollup.ts +2 -2
  30. package/src/deploy_l1_contracts.ts +2 -2
  31. package/src/l1_tx_utils/README.md +177 -0
  32. package/src/l1_tx_utils/config.ts +24 -13
  33. package/src/l1_tx_utils/l1_tx_utils.ts +282 -158
  34. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +23 -19
  35. package/src/l1_tx_utils/types.ts +20 -2
  36. package/src/publisher_manager.ts +24 -5
  37. package/src/test/eth_cheat_codes.ts +120 -20
@@ -1,4 +1,4 @@
1
- import { times } from '@aztec/foundation/collection';
1
+ import { getKeys, merge, pick, times } from '@aztec/foundation/collection';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import { makeBackoff, retry } from '@aztec/foundation/retry';
4
4
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
@@ -20,10 +20,7 @@ export class ReadOnlyL1TxUtils {
20
20
  this.dateProvider = dateProvider;
21
21
  this.debugMaxGasLimit = debugMaxGasLimit;
22
22
  this.interrupted = false;
23
- this.config = {
24
- ...defaultL1TxUtilsConfig,
25
- ...config || {}
26
- };
23
+ this.config = merge(defaultL1TxUtilsConfig, pick(config || {}, ...getKeys(l1TxUtilsConfigMappings)));
27
24
  }
28
25
  interrupt() {
29
26
  this.interrupted = true;
@@ -39,11 +36,8 @@ export class ReadOnlyL1TxUtils {
39
36
  }
40
37
  /**
41
38
  * Gets the current gas price with bounds checking
42
- */ async getGasPrice(_gasConfig, isBlobTx = false, attempt = 0, previousGasPrice) {
43
- const gasConfig = {
44
- ...this.config,
45
- ..._gasConfig
46
- };
39
+ */ async getGasPrice(gasConfigOverrides, isBlobTx = false, attempt = 0, previousGasPrice) {
40
+ const gasConfig = merge(this.config, gasConfigOverrides);
47
41
  const block = await this.client.getBlock({
48
42
  blockTag: 'latest'
49
43
  });
@@ -53,9 +47,6 @@ export class ReadOnlyL1TxUtils {
53
47
  if (isBlobTx) {
54
48
  try {
55
49
  blobBaseFee = await retry(()=>this.client.getBlobBaseFee(), 'Getting L1 blob base fee', makeBackoff(times(2, ()=>1)), this.logger, true);
56
- this.logger?.debug('L1 Blob base fee:', {
57
- blobBaseFee: formatGwei(blobBaseFee)
58
- });
59
50
  } catch {
60
51
  this.logger?.warn('Failed to get L1 blob base fee', attempt);
61
52
  }
@@ -120,14 +111,13 @@ export class ReadOnlyL1TxUtils {
120
111
  // use max between current network values and min required values
121
112
  maxFeePerBlobGas = maxFeePerBlobGas > minBlobFee ? maxFeePerBlobGas : minBlobFee;
122
113
  }
123
- this.logger?.debug(`Computed L1 gas price`, {
114
+ this.logger?.trace(`Computed L1 gas price max fee ${formatGwei(maxFeePerGas)} and max priority fee ${formatGwei(maxPriorityFeePerGas)}`, {
124
115
  attempt,
125
116
  baseFee: formatGwei(baseFee),
126
117
  maxFeePerGas: formatGwei(maxFeePerGas),
127
118
  maxPriorityFeePerGas: formatGwei(maxPriorityFeePerGas),
128
- ...maxFeePerBlobGas && {
129
- maxFeePerBlobGas: formatGwei(maxFeePerBlobGas)
130
- }
119
+ blobBaseFee: formatGwei(blobBaseFee),
120
+ maxFeePerBlobGas: formatGwei(maxFeePerBlobGas)
131
121
  });
132
122
  return {
133
123
  maxFeePerGas,
@@ -155,14 +145,14 @@ export class ReadOnlyL1TxUtils {
155
145
  maxFeePerBlobGas: gasPrice.maxFeePerBlobGas,
156
146
  gas: LARGE_GAS_LIMIT
157
147
  });
158
- this.logger?.debug(`L1 gas used in estimateGas by blob tx: ${initialEstimate}`);
148
+ this.logger?.trace(`Estimated gas for blob tx: ${initialEstimate}`);
159
149
  } else {
160
150
  initialEstimate = await this.client.estimateGas({
161
151
  account,
162
152
  ...request,
163
153
  gas: LARGE_GAS_LIMIT
164
154
  });
165
- this.logger?.debug(`L1 gas used in estimateGas by non-blob tx: ${initialEstimate}`);
155
+ this.logger?.trace(`Estimated gas for non-blob tx: ${initialEstimate}`);
166
156
  }
167
157
  // Add buffer based on either fixed amount or percentage
168
158
  const withBuffer = this.bumpGasLimit(initialEstimate, gasConfig);
@@ -294,7 +284,7 @@ export class ReadOnlyL1TxUtils {
294
284
  };
295
285
  const bumpedGasLimit = gasLimit + gasLimit * BigInt((gasConfig?.gasLimitBufferPercentage || 0) * 1_00) / 100_00n;
296
286
  const cleanGasConfig = pickBy(gasConfig, (_, key)=>key in l1TxUtilsConfigMappings);
297
- this.logger?.debug('Bumping gas limit', {
287
+ this.logger?.trace(`Bumping gas limit from ${gasLimit} to ${bumpedGasLimit}`, {
298
288
  gasLimit,
299
289
  gasConfig: cleanGasConfig,
300
290
  bumpedGasLimit
@@ -9,7 +9,7 @@ export interface L1TxRequest {
9
9
  value?: bigint;
10
10
  abi?: Abi;
11
11
  }
12
- export type L1GasConfig = Partial<L1TxUtilsConfig> & {
12
+ export type L1TxConfig = Partial<L1TxUtilsConfig> & {
13
13
  gasLimit?: bigint;
14
14
  txTimeoutAt?: Date;
15
15
  };
@@ -41,17 +41,26 @@ export declare enum TxUtilsState {
41
41
  NOT_MINED = 4,
42
42
  MINED = 5
43
43
  }
44
+ export declare const TerminalTxUtilsState: TxUtilsState[];
44
45
  export type L1TxState = {
45
46
  txHashes: Hex[];
46
47
  cancelTxHashes: Hex[];
47
48
  gasLimit: bigint;
48
49
  gasPrice: GasPrice;
49
- txConfig: L1GasConfig;
50
+ txConfigOverrides: L1TxConfig;
50
51
  request: L1TxRequest;
51
52
  status: TxUtilsState;
52
53
  nonce: number;
54
+ sentAtL1Ts: Date;
55
+ lastSentAtL1Ts: Date;
53
56
  receipt?: TransactionReceipt;
54
57
  blobInputs: L1BlobInputs | undefined;
55
58
  };
56
59
  export type SigningCallback = (transaction: TransactionSerializable, signingAddress: EthAddress) => Promise<ViemTransactionSignature>;
60
+ export declare class UnknownMinedTxError extends Error {
61
+ constructor(nonce: number, account: string);
62
+ }
63
+ export declare class DroppedTransactionError extends Error {
64
+ constructor(nonce: number, account: string);
65
+ }
57
66
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,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K;gBAChC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI3C;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI3C"}
@@ -7,3 +7,20 @@ export var TxUtilsState = /*#__PURE__*/ function(TxUtilsState) {
7
7
  TxUtilsState[TxUtilsState["MINED"] = 5] = "MINED";
8
8
  return TxUtilsState;
9
9
  }({});
10
+ export const TerminalTxUtilsState = [
11
+ 0,
12
+ 5,
13
+ 4
14
+ ];
15
+ export class UnknownMinedTxError extends Error {
16
+ constructor(nonce, account){
17
+ super(`Nonce ${nonce} from account ${account} is MINED but not by one of our expected transactions`);
18
+ this.name = 'UnknownMinedTxError';
19
+ }
20
+ }
21
+ export class DroppedTransactionError extends Error {
22
+ constructor(nonce, account){
23
+ super(`Transaction with nonce ${nonce} from account ${account} was dropped from the mempool`);
24
+ this.name = 'DroppedTransactionError';
25
+ }
26
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"publisher_manager.d.ts","sourceRoot":"","sources":["../src/publisher_manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAgB,MAAM,wBAAwB,CAAC;AAKjE,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,SAAS,IAAI,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;AAEzF,qBAAa,gBAAgB,CAAC,SAAS,SAAS,SAAS,GAAG,SAAS;IAKjE,OAAO,CAAC,UAAU;IAJpB,OAAO,CAAC,GAAG,CAAoC;IAC/C,OAAO,CAAC,MAAM,CAA4C;gBAGhD,UAAU,EAAE,SAAS,EAAE,EAC/B,MAAM,EAAE;QAAE,2BAA2B,CAAC,EAAE,OAAO,CAAA;KAAE;IAatC,qBAAqB,CAAC,MAAM,GAAE,eAAe,CAAC,SAAS,CAAc,GAAG,OAAO,CAAC,SAAS,CAAC;IAyChG,SAAS;CAGjB"}
1
+ {"version":3,"file":"publisher_manager.d.ts","sourceRoot":"","sources":["../src/publisher_manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAgB,MAAM,wBAAwB,CAAC;AAwBjE,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,SAAS,IAAI,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;AAEzF,qBAAa,gBAAgB,CAAC,SAAS,SAAS,SAAS,GAAG,SAAS;IAKjE,OAAO,CAAC,UAAU;IAJpB,OAAO,CAAC,GAAG,CAAoC;IAC/C,OAAO,CAAC,MAAM,CAA4C;gBAGhD,UAAU,EAAE,SAAS,EAAE,EAC/B,MAAM,EAAE;QAAE,2BAA2B,CAAC,EAAE,OAAO,CAAA;KAAE;IAatC,qBAAqB,CAAC,MAAM,GAAE,eAAe,CAAC,SAAS,CAAc,GAAG,OAAO,CAAC,SAAS,CAAC;IAyChG,SAAS;CAGjB"}
@@ -1,16 +1,26 @@
1
1
  import { pick } from '@aztec/foundation/collection';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import { TxUtilsState } from './l1_tx_utils/index.js';
4
+ // Defines the order in which we prioritise publishers based on their state (first is better)
4
5
  const sortOrder = [
6
+ // Always prefer sending from idle publishers
5
7
  TxUtilsState.IDLE,
6
- TxUtilsState.MINED
8
+ // Then from publishers that have sent a tx and it got mined
9
+ TxUtilsState.MINED,
10
+ // Then from publishers that have sent a tx but it's in-flight
11
+ TxUtilsState.SPEED_UP,
12
+ TxUtilsState.SENT,
13
+ // We leave cancelled and not-mined states for last, since these represent failures to mines and could be problematic
14
+ TxUtilsState.CANCELLED,
15
+ TxUtilsState.NOT_MINED
7
16
  ];
8
- const invalidStates = [
17
+ // Which states represent a busy publisher that we should avoid if possible
18
+ const busyStates = [
9
19
  TxUtilsState.SENT,
10
20
  TxUtilsState.SPEED_UP,
11
21
  TxUtilsState.CANCELLED,
12
22
  TxUtilsState.NOT_MINED
13
- ]; // Cancelled and not mined are states that can be handled by a later iteration
23
+ ];
14
24
  export class PublisherManager {
15
25
  publishers;
16
26
  log;
@@ -25,13 +35,13 @@ export class PublisherManager {
25
35
  // Finds and prioritises available publishers based on
26
36
  // 1. Validity as per the provided filter function
27
37
  // 2. Validity based on the state the publisher is in
28
- // 3. Priority based on state as defined bu sortOrder
38
+ // 3. Priority based on state as defined by sortOrder
29
39
  // 4. Then priority based on highest balance
30
40
  // 5. Then priority based on least recently used
31
41
  async getAvailablePublisher(filter = ()=>true) {
32
42
  // Extract the valid publishers
33
- let validPublishers = this.publishers.filter((pub)=>!invalidStates.includes(pub.state) && filter(pub));
34
- // If none found but we allow invalid states, try again including them
43
+ let validPublishers = this.publishers.filter((pub)=>!busyStates.includes(pub.state) && filter(pub));
44
+ // If none found but we allow invalid (busy) states, try again including them
35
45
  if (validPublishers.length === 0 && this.config.publisherAllowInvalidStates) {
36
46
  this.log.warn(`No valid publishers found. Trying again including invalid states.`);
37
47
  validPublishers = this.publishers.filter((pub)=>filter(pub));
@@ -1,6 +1,6 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import type { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
3
- import { type Hex } from 'viem';
3
+ import { type Hex, type Transaction } from 'viem';
4
4
  import type { ViemPublicClient } from '../types.js';
5
5
  /**
6
6
  * A class that provides utility functions for interacting with ethereum (L1).
@@ -33,6 +33,7 @@ export declare class EthCheatCodes {
33
33
  */
34
34
  logger?: import("@aztec/foundation/log").Logger);
35
35
  rpcCall(method: string, params: any[]): Promise<any>;
36
+ private doRpcCall;
36
37
  /**
37
38
  * Get the auto mine status of the underlying chain
38
39
  * @returns True if automine is on, false otherwise
@@ -199,6 +200,22 @@ export declare class EthCheatCodes {
199
200
  value?: number | bigint;
200
201
  })[][]): Promise<void>;
201
202
  traceTransaction(txHash: Hex): Promise<any>;
203
+ getTxPoolStatus(): Promise<{
204
+ pending: number;
205
+ queued: number;
206
+ }>;
207
+ getTxPoolContents(): Promise<TxPoolTransaction[]>;
208
+ /**
209
+ * Mines an empty block by temporarily removing all pending transactions from the mempool,
210
+ * mining a block, and then re-adding the transactions back to the pool.
211
+ */
212
+ mineEmptyBlock(blockCount?: number): Promise<void>;
202
213
  execWithPausedAnvil<T>(fn: () => Promise<T>): Promise<T>;
214
+ syncDateProvider(): Promise<void>;
203
215
  }
216
+ type TxPoolState = 'pending' | 'queued';
217
+ export type TxPoolTransaction = Transaction & {
218
+ poolState: TxPoolState;
219
+ };
220
+ export {};
204
221
  //# sourceMappingURL=eth_cheat_codes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,MAAM,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,qBAAa,aAAa;IAGtB;;OAEG;IACI,OAAO,EAAE,MAAM,EAAE;IACxB;;OAEG;IACI,YAAY,EAAE,YAAY,GAAG,gBAAgB;IACpD;;OAEG;IACI,MAAM;IAbf,SAAgB,YAAY,EAAE,gBAAgB,CAAC;;IAE7C;;OAEG;IACI,OAAO,EAAE,MAAM,EAAE;IACxB;;OAEG;IACI,YAAY,EAAE,YAAY,GAAG,gBAAgB;IACpD;;OAEG;IACI,MAAM,yCAAuC;IAOhD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;IAS3C;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAU7C;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAK3C;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAKvC;;;OAGG;IACU,SAAS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,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C;;;OAGG;IACI,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBlD;;;;;OAKG;IACU,oBAAoB,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,CAAC,GAAG,GAAG;QAAE,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,GAAG,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,EAAE,EAAO,GAClH,OAAO,CAAC,IAAI,CAAC;IAaT,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrC,eAAe,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAK/D,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAK9D;;;OAGG;IACU,cAAc,CAAC,UAAU,GAAE,MAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDrD,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAiCxD,gBAAgB;CAM9B;AAED,KAAK,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAOxC,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC"}
@@ -2,7 +2,8 @@ import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
2
2
  import { keccak256 } from '@aztec/foundation/crypto';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
  import { createLogger } from '@aztec/foundation/log';
5
- import { createPublicClient, fallback, http } from 'viem';
5
+ import { pluralize } from '@aztec/foundation/string';
6
+ import { createPublicClient, fallback, hexToNumber, http } from 'viem';
6
7
  /**
7
8
  * A class that provides utility functions for interacting with ethereum (L1).
8
9
  */ export class EthCheatCodes {
@@ -24,9 +25,11 @@ import { createPublicClient, fallback, http } from 'viem';
24
25
  transport: fallback(this.rpcUrls.map((url)=>http(url)))
25
26
  });
26
27
  }
27
- async rpcCall(method, params) {
28
- const paramsString = jsonStringify(params);
29
- this.logger.debug(`Calling ${method} with params: ${paramsString} on ${this.rpcUrls.join(', ')}`);
28
+ rpcCall(method, params) {
29
+ this.logger.debug(`Calling ${method} with params: ${jsonStringify(params)} on ${this.rpcUrls.join(', ')}`);
30
+ return this.doRpcCall(method, params);
31
+ }
32
+ async doRpcCall(method, params) {
30
33
  return await this.publicClient.transport.request({
31
34
  method,
32
35
  params
@@ -37,7 +40,7 @@ import { createPublicClient, fallback, http } from 'viem';
37
40
  * @returns True if automine is on, false otherwise
38
41
  */ async isAutoMining() {
39
42
  try {
40
- const res = await this.rpcCall('anvil_getAutomine', []);
43
+ const res = await this.doRpcCall('anvil_getAutomine', []);
41
44
  return res;
42
45
  } catch (err) {
43
46
  this.logger.error(`Calling "anvil_getAutomine" failed with:`, err);
@@ -48,21 +51,21 @@ import { createPublicClient, fallback, http } from 'viem';
48
51
  * Get the current blocknumber
49
52
  * @returns The current block number
50
53
  */ async blockNumber() {
51
- const res = await this.rpcCall('eth_blockNumber', []);
54
+ const res = await this.doRpcCall('eth_blockNumber', []);
52
55
  return parseInt(res, 16);
53
56
  }
54
57
  /**
55
58
  * Get the current chainId
56
59
  * @returns The current chainId
57
60
  */ async chainId() {
58
- const res = await this.rpcCall('eth_chainId', []);
61
+ const res = await this.doRpcCall('eth_chainId', []);
59
62
  return parseInt(res, 16);
60
63
  }
61
64
  /**
62
65
  * Get the current timestamp
63
66
  * @returns The current timestamp
64
67
  */ async timestamp() {
65
- const res = await this.rpcCall('eth_getBlockByNumber', [
68
+ const res = await this.doRpcCall('eth_getBlockByNumber', [
66
69
  'latest',
67
70
  true
68
71
  ]);
@@ -77,7 +80,7 @@ import { createPublicClient, fallback, http } from 'viem';
77
80
  }
78
81
  async doMine(numberOfBlocks = 1) {
79
82
  try {
80
- await this.rpcCall('hardhat_mine', [
83
+ await this.doRpcCall('hardhat_mine', [
81
84
  numberOfBlocks
82
85
  ]);
83
86
  } catch (err) {
@@ -88,7 +91,8 @@ import { createPublicClient, fallback, http } from 'viem';
88
91
  * Mines a single block with evm_mine
89
92
  */ async evmMine() {
90
93
  try {
91
- await this.rpcCall('evm_mine', []);
94
+ await this.doRpcCall('evm_mine', []);
95
+ this.logger.warn(`Mined 1 L1 block with evm_mine`);
92
96
  } catch (err) {
93
97
  throw new Error(`Error mining: ${err}`);
94
98
  }
@@ -109,7 +113,7 @@ import { createPublicClient, fallback, http } from 'viem';
109
113
  this.logger.warn(`Set balance for ${account} to ${balance}`);
110
114
  }
111
115
  async getBalance(account) {
112
- const res = await this.rpcCall('eth_getBalance', [
116
+ const res = await this.doRpcCall('eth_getBalance', [
113
117
  account.toString(),
114
118
  'latest'
115
119
  ]);
@@ -146,7 +150,7 @@ import { createPublicClient, fallback, http } from 'viem';
146
150
  * @param seconds - The interval to use between blocks
147
151
  */ getIntervalMining() {
148
152
  try {
149
- return this.rpcCall('anvil_getIntervalMining', []);
153
+ return this.doRpcCall('anvil_getIntervalMining', []);
150
154
  } catch (err) {
151
155
  throw new Error(`Error getting interval mining: ${err}`);
152
156
  }
@@ -341,31 +345,28 @@ import { createPublicClient, fallback, http } from 'viem';
341
345
  * @param contract - The contract address
342
346
  * @returns The bytecode for the contract
343
347
  */ async getBytecode(contract) {
344
- const res = await this.rpcCall('eth_getCode', [
348
+ return await this.doRpcCall('eth_getCode', [
345
349
  contract.toString(),
346
350
  'latest'
347
351
  ]);
348
- return res;
349
352
  }
350
353
  /**
351
354
  * Get the raw transaction object for a given transaction hash
352
355
  * @param txHash - The transaction hash
353
356
  * @returns The raw transaction
354
357
  */ async getRawTransaction(txHash) {
355
- const res = await this.rpcCall('debug_getRawTransaction', [
358
+ return await this.doRpcCall('debug_getRawTransaction', [
356
359
  txHash
357
360
  ]);
358
- return res;
359
361
  }
360
362
  /**
361
363
  * Get the trace for a given transaction hash
362
364
  * @param txHash - The transaction hash
363
365
  * @returns The trace
364
366
  */ async debugTraceTransaction(txHash) {
365
- const res = await this.rpcCall('debug_traceTransaction', [
367
+ return await this.doRpcCall('debug_traceTransaction', [
366
368
  txHash
367
369
  ]);
368
- return res;
369
370
  }
370
371
  /**
371
372
  * Triggers a reorg of the given depth, removing those blocks from the chain.
@@ -381,9 +382,6 @@ import { createPublicClient, fallback, http } from 'viem';
381
382
  * Causes Anvil to reorg until the given block number is the new tip
382
383
  * @param blockNumber - The block number that's going to be the new tip
383
384
  */ reorgTo(blockNumber) {
384
- this.logger.info('reorgTo', {
385
- blockNumber
386
- });
387
385
  if (blockNumber <= 0) {
388
386
  throw new Error(`Can't reorg to block before genesis: ${blockNumber}`);
389
387
  }
@@ -397,6 +395,7 @@ import { createPublicClient, fallback, http } from 'viem';
397
395
  await this.rpcCall('anvil_rollback', [
398
396
  depth
399
397
  ]);
398
+ this.logger.warn(`Reorged L1 chain to block number ${blockNumber} (depth ${depth})`);
400
399
  });
401
400
  }
402
401
  /**
@@ -426,10 +425,68 @@ import { createPublicClient, fallback, http } from 'viem';
426
425
  });
427
426
  }
428
427
  traceTransaction(txHash) {
429
- return this.rpcCall('trace_transaction', [
428
+ return this.doRpcCall('trace_transaction', [
430
429
  txHash
431
430
  ]);
432
431
  }
432
+ async getTxPoolStatus() {
433
+ const { pending, queued } = await this.doRpcCall('txpool_status', []);
434
+ return {
435
+ pending: hexToNumber(pending),
436
+ queued: hexToNumber(queued)
437
+ };
438
+ }
439
+ async getTxPoolContents() {
440
+ const txpoolContent = await this.doRpcCall('txpool_content', []);
441
+ return mapTxPoolContent(txpoolContent);
442
+ }
443
+ /**
444
+ * Mines an empty block by temporarily removing all pending transactions from the mempool,
445
+ * mining a block, and then re-adding the transactions back to the pool.
446
+ */ async mineEmptyBlock(blockCount = 1) {
447
+ await this.execWithPausedAnvil(async ()=>{
448
+ // Get all pending and queued transactions from the pool
449
+ const txs = await this.getTxPoolContents();
450
+ this.logger.debug(`Found ${txs.length} transactions in pool`);
451
+ // Get raw transactions before dropping them
452
+ const rawTxs = [];
453
+ for (const tx of txs){
454
+ try {
455
+ const rawTx = await this.doRpcCall('debug_getRawTransaction', [
456
+ tx.hash
457
+ ]);
458
+ if (rawTx) {
459
+ rawTxs.push(rawTx);
460
+ this.logger.debug(`Got raw tx for ${tx.hash}`);
461
+ } else {
462
+ this.logger.warn(`No raw tx found for ${tx.hash}`);
463
+ }
464
+ } catch {
465
+ this.logger.warn(`Failed to get raw transaction for ${tx.hash}`);
466
+ }
467
+ }
468
+ this.logger.debug(`Retrieved ${rawTxs.length} raw transactions`);
469
+ // Drop all transactions from the mempool
470
+ await this.doRpcCall('anvil_dropAllTransactions', []);
471
+ // Mine an empty block
472
+ await this.doMine(blockCount);
473
+ // Re-add the transactions to the pool
474
+ for (const rawTx of rawTxs){
475
+ try {
476
+ const txHash = await this.doRpcCall('eth_sendRawTransaction', [
477
+ rawTx
478
+ ]);
479
+ this.logger.debug(`Re-added transaction ${txHash}`);
480
+ } catch (err) {
481
+ this.logger.warn(`Failed to re-add transaction: ${err}`);
482
+ }
483
+ }
484
+ if (rawTxs.length !== txs.length) {
485
+ this.logger.warn(`Failed to add all txs back: had ${txs.length} but re-added ${rawTxs.length}`);
486
+ }
487
+ });
488
+ this.logger.warn(`Mined ${blockCount} empty L1 ${pluralize('block', blockCount)}`);
489
+ }
433
490
  async execWithPausedAnvil(fn) {
434
491
  const [blockInterval, wasAutoMining] = await Promise.all([
435
492
  this.getIntervalMining(),
@@ -470,4 +527,26 @@ import { createPublicClient, fallback, http } from 'viem';
470
527
  }
471
528
  }
472
529
  }
530
+ async syncDateProvider() {
531
+ const timestamp = await this.timestamp();
532
+ if ('setTime' in this.dateProvider) {
533
+ this.dateProvider.setTime(timestamp * 1000);
534
+ }
535
+ }
536
+ }
537
+ function mapTxPoolContent(content) {
538
+ const result = [];
539
+ const processPool = (pool, poolState)=>{
540
+ for (const txsByNonce of Object.values(pool)){
541
+ for (const tx of Object.values(txsByNonce)){
542
+ result.push({
543
+ ...tx,
544
+ poolState
545
+ });
546
+ }
547
+ }
548
+ };
549
+ processPool(content.pending, 'pending');
550
+ processPool(content.queued, 'queued');
551
+ return result;
473
552
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/ethereum",
3
- "version": "3.0.0-nightly.20251003",
3
+ "version": "3.0.0-nightly.20251004",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -31,10 +31,10 @@
31
31
  "../package.common.json"
32
32
  ],
33
33
  "dependencies": {
34
- "@aztec/blob-lib": "3.0.0-nightly.20251003",
35
- "@aztec/constants": "3.0.0-nightly.20251003",
36
- "@aztec/foundation": "3.0.0-nightly.20251003",
37
- "@aztec/l1-artifacts": "3.0.0-nightly.20251003",
34
+ "@aztec/blob-lib": "3.0.0-nightly.20251004",
35
+ "@aztec/constants": "3.0.0-nightly.20251004",
36
+ "@aztec/foundation": "3.0.0-nightly.20251004",
37
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251004",
38
38
  "@viem/anvil": "^0.0.10",
39
39
  "dotenv": "^16.0.3",
40
40
  "lodash.chunk": "^4.2.0",
package/src/config.ts CHANGED
@@ -212,7 +212,7 @@ const LocalEntryQueueConfig = {
212
212
  bootstrapFlushSize: 0n,
213
213
  normalFlushSizeMin: 48n,
214
214
  normalFlushSizeQuotient: 2n,
215
- maxQueueFlushSize: 32n,
215
+ maxQueueFlushSize: 48n,
216
216
  };
217
217
 
218
218
  const StagingPublicEntryQueueConfig = {
@@ -4,7 +4,7 @@ import type { Logger } from '@aztec/foundation/log';
4
4
 
5
5
  import { type EncodeFunctionDataParameters, type Hex, encodeFunctionData, multicall3Abi } from 'viem';
6
6
 
7
- import type { L1BlobInputs, L1GasConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
7
+ import type { L1BlobInputs, L1TxConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
8
8
  import type { ExtendedViemWalletClient } from '../types.js';
9
9
  import { FormattedViemError, formatViemError } from '../utils.js';
10
10
  import { RollupContract } from './rollup.js';
@@ -15,7 +15,7 @@ export class Multicall3 {
15
15
  static async forward(
16
16
  requests: L1TxRequest[],
17
17
  l1TxUtils: L1TxUtils,
18
- gasConfig: L1GasConfig | undefined,
18
+ gasConfig: L1TxConfig | undefined,
19
19
  blobConfig: L1BlobInputs | undefined,
20
20
  rollupAddress: Hex,
21
21
  logger: Logger,
@@ -37,10 +37,7 @@ export class Multicall3 {
37
37
 
38
38
  try {
39
39
  const { receipt, state } = await l1TxUtils.sendAndMonitorTransaction(
40
- {
41
- to: MULTI_CALL_3_ADDRESS,
42
- data: encodedForwarderData,
43
- },
40
+ { to: MULTI_CALL_3_ADDRESS, data: encodedForwarderData },
44
41
  gasConfig,
45
42
  blobConfig,
46
43
  );
@@ -425,8 +425,8 @@ export class RollupContract {
425
425
  return result;
426
426
  }
427
427
 
428
- getBlock(blockNumber: bigint) {
429
- return this.rollup.read.getBlock([blockNumber]);
428
+ getBlock(blockNumber: bigint | number) {
429
+ return this.rollup.read.getBlock([BigInt(blockNumber)]);
430
430
  }
431
431
 
432
432
  getTips() {
@@ -64,7 +64,7 @@ import {
64
64
  import type { L1ContractAddresses } from './l1_contract_addresses.js';
65
65
  import {
66
66
  type GasPrice,
67
- type L1GasConfig,
67
+ type L1TxConfig,
68
68
  type L1TxRequest,
69
69
  L1TxUtils,
70
70
  type L1TxUtilsConfig,
@@ -1556,7 +1556,7 @@ export class L1Deployer {
1556
1556
 
1557
1557
  sendTransaction(
1558
1558
  tx: L1TxRequest,
1559
- options?: L1GasConfig,
1559
+ options?: L1TxConfig,
1560
1560
  ): Promise<{ txHash: Hex; gasLimit: bigint; gasPrice: GasPrice }> {
1561
1561
  return this.l1TxUtils.sendTransaction(tx, options).then(({ txHash, state }) => ({
1562
1562
  txHash,