@aztec/ethereum 1.2.1 → 2.0.0-nightly.20250813

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 (98) hide show
  1. package/dest/config.d.ts +22 -7
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +49 -14
  4. package/dest/contracts/empire_base.d.ts +12 -10
  5. package/dest/contracts/empire_base.d.ts.map +1 -1
  6. package/dest/contracts/empire_base.js +21 -16
  7. package/dest/contracts/governance.d.ts +4 -4
  8. package/dest/contracts/governance.js +2 -2
  9. package/dest/contracts/governance_proposer.d.ts +7 -7
  10. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  11. package/dest/contracts/governance_proposer.js +13 -13
  12. package/dest/contracts/gse.d.ts +29 -0
  13. package/dest/contracts/gse.d.ts.map +1 -0
  14. package/dest/contracts/gse.js +56 -0
  15. package/dest/contracts/index.d.ts +1 -0
  16. package/dest/contracts/index.d.ts.map +1 -1
  17. package/dest/contracts/index.js +1 -0
  18. package/dest/contracts/multicall.d.ts +3 -1
  19. package/dest/contracts/multicall.d.ts.map +1 -1
  20. package/dest/contracts/multicall.js +11 -2
  21. package/dest/contracts/registry.d.ts +1 -0
  22. package/dest/contracts/registry.d.ts.map +1 -1
  23. package/dest/contracts/registry.js +3 -0
  24. package/dest/contracts/rollup.d.ts +39 -5
  25. package/dest/contracts/rollup.d.ts.map +1 -1
  26. package/dest/contracts/rollup.js +92 -14
  27. package/dest/contracts/slashing_proposer.d.ts +21 -10
  28. package/dest/contracts/slashing_proposer.d.ts.map +1 -1
  29. package/dest/contracts/slashing_proposer.js +43 -23
  30. package/dest/deploy_l1_contracts.d.ts +11 -36664
  31. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  32. package/dest/deploy_l1_contracts.js +92 -177
  33. package/dest/index.d.ts +1 -1
  34. package/dest/index.d.ts.map +1 -1
  35. package/dest/index.js +1 -1
  36. package/dest/l1_artifacts.d.ts +51869 -0
  37. package/dest/l1_artifacts.d.ts.map +1 -0
  38. package/dest/l1_artifacts.js +141 -0
  39. package/dest/l1_tx_utils.d.ts +4 -2
  40. package/dest/l1_tx_utils.d.ts.map +1 -1
  41. package/dest/l1_tx_utils.js +46 -21
  42. package/dest/queries.d.ts +1 -8
  43. package/dest/queries.d.ts.map +1 -1
  44. package/dest/queries.js +20 -15
  45. package/dest/test/chain_monitor.d.ts +4 -2
  46. package/dest/test/chain_monitor.d.ts.map +1 -1
  47. package/dest/test/chain_monitor.js +12 -3
  48. package/dest/test/delayed_tx_utils.js +2 -2
  49. package/dest/{eth_cheat_codes.d.ts → test/eth_cheat_codes.d.ts} +8 -4
  50. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  51. package/dest/{eth_cheat_codes.js → test/eth_cheat_codes.js} +27 -11
  52. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  53. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  54. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  55. package/dest/test/index.d.ts +2 -0
  56. package/dest/test/index.d.ts.map +1 -1
  57. package/dest/test/index.js +2 -0
  58. package/dest/test/rollup_cheat_codes.d.ts +81 -0
  59. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  60. package/dest/test/rollup_cheat_codes.js +234 -0
  61. package/dest/test/start_anvil.d.ts +1 -0
  62. package/dest/test/start_anvil.d.ts.map +1 -1
  63. package/dest/test/start_anvil.js +6 -1
  64. package/dest/test/tx_delayer.d.ts +8 -1
  65. package/dest/test/tx_delayer.d.ts.map +1 -1
  66. package/dest/test/tx_delayer.js +51 -11
  67. package/dest/test/upgrade_utils.d.ts.map +1 -1
  68. package/dest/test/upgrade_utils.js +1 -1
  69. package/dest/utils.d.ts +1 -0
  70. package/dest/utils.d.ts.map +1 -1
  71. package/dest/utils.js +1 -1
  72. package/package.json +5 -5
  73. package/src/config.ts +62 -18
  74. package/src/contracts/empire_base.ts +28 -19
  75. package/src/contracts/governance.ts +2 -2
  76. package/src/contracts/governance_proposer.ts +23 -15
  77. package/src/contracts/gse.ts +73 -0
  78. package/src/contracts/index.ts +1 -0
  79. package/src/contracts/multicall.ts +8 -1
  80. package/src/contracts/registry.ts +4 -0
  81. package/src/contracts/rollup.ts +115 -9
  82. package/src/contracts/slashing_proposer.ts +55 -27
  83. package/src/deploy_l1_contracts.ts +151 -238
  84. package/src/index.ts +1 -1
  85. package/src/l1_artifacts.ts +216 -0
  86. package/src/l1_tx_utils.ts +52 -26
  87. package/src/queries.ts +20 -31
  88. package/src/test/chain_monitor.ts +9 -2
  89. package/src/test/delayed_tx_utils.ts +2 -2
  90. package/src/{eth_cheat_codes.ts → test/eth_cheat_codes.ts} +20 -14
  91. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  92. package/src/test/index.ts +2 -0
  93. package/src/test/rollup_cheat_codes.ts +257 -0
  94. package/src/test/start_anvil.ts +9 -1
  95. package/src/test/tx_delayer.ts +55 -9
  96. package/src/test/upgrade_utils.ts +1 -1
  97. package/src/utils.ts +1 -1
  98. package/dest/eth_cheat_codes.d.ts.map +0 -1
@@ -1,14 +1,17 @@
1
1
  import { InboxContract } from '@aztec/ethereum/contracts';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import { promiseWithResolvers } from '@aztec/foundation/promise';
4
+ import { DateProvider } from '@aztec/foundation/timer';
4
5
  import { EventEmitter } from 'events';
5
6
  /** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */ export class ChainMonitor extends EventEmitter {
6
7
  rollup;
8
+ dateProvider;
7
9
  logger;
8
10
  intervalMs;
9
11
  l1Client;
10
12
  inbox;
11
13
  handle;
14
+ // eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
12
15
  running;
13
16
  /** Current L1 block number */ l1BlockNumber;
14
17
  /** Current L2 block number */ l2BlockNumber;
@@ -16,8 +19,8 @@ import { EventEmitter } from 'events';
16
19
  /** L1 timestamp for the current L2 block */ l2BlockTimestamp;
17
20
  /** L1 timestamp for the proven L2 block */ l2ProvenBlockTimestamp;
18
21
  /** Total number of L2 messages pushed into the Inbox */ totalL2Messages;
19
- constructor(rollup, logger = createLogger('aztecjs:utils:chain_monitor'), intervalMs = 200){
20
- super(), this.rollup = rollup, this.logger = logger, this.intervalMs = intervalMs, this.running = new Set(), this.totalL2Messages = 0;
22
+ constructor(rollup, dateProvider = new DateProvider(), logger = createLogger('aztecjs:utils:chain_monitor'), intervalMs = 200){
23
+ super(), this.rollup = rollup, this.dateProvider = dateProvider, this.logger = logger, this.intervalMs = intervalMs, this.running = new Set(), this.totalL2Messages = 0;
21
24
  this.l1Client = rollup.client;
22
25
  }
23
26
  start() {
@@ -111,10 +114,16 @@ import { EventEmitter } from 'events';
111
114
  l1BlockNumber: newL1BlockNumber
112
115
  });
113
116
  }
117
+ const [l2SlotNumber, l2Epoch] = await Promise.all([
118
+ this.rollup.getSlotNumber(),
119
+ this.rollup.getCurrentEpoch()
120
+ ]);
114
121
  this.logger.info(msg, {
122
+ currentTimestamp: this.dateProvider.nowInSeconds(),
115
123
  l1Timestamp: timestamp,
116
124
  l1BlockNumber: this.l1BlockNumber,
117
- l2SlotNumber: await this.rollup.getSlotNumber(),
125
+ l2SlotNumber,
126
+ l2Epoch,
118
127
  l2BlockNumber: this.l2BlockNumber,
119
128
  l2ProvenBlockNumber: this.l2ProvenBlockNumber,
120
129
  totalL2Messages: this.totalL2Messages
@@ -3,7 +3,7 @@ import { withDelayer } from './tx_delayer.js';
3
3
  export class DelayedTxUtils extends L1TxUtilsWithBlobs {
4
4
  delayer;
5
5
  static fromL1TxUtils(l1TxUtils, ethereumSlotDuration) {
6
- const { client, delayer } = withDelayer(l1TxUtils.client, {
6
+ const { client, delayer } = withDelayer(l1TxUtils.client, l1TxUtils.dateProvider, {
7
7
  ethereumSlotDuration
8
8
  });
9
9
  const casted = l1TxUtils;
@@ -12,7 +12,7 @@ export class DelayedTxUtils extends L1TxUtilsWithBlobs {
12
12
  return casted;
13
13
  }
14
14
  enableDelayer(ethereumSlotDuration) {
15
- const { client, delayer } = withDelayer(this.client, {
15
+ const { client, delayer } = withDelayer(this.client, this.dateProvider, {
16
16
  ethereumSlotDuration
17
17
  });
18
18
  this.delayer = delayer;
@@ -79,12 +79,16 @@ export declare class EthCheatCodes {
79
79
  * Enable interval mining at the given interval (block time)
80
80
  * @param seconds - The interval to use between blocks
81
81
  */
82
- setIntervalMining(seconds: number): Promise<void>;
82
+ setIntervalMining(seconds: number, opts?: {
83
+ silent?: boolean;
84
+ }): Promise<void>;
83
85
  /**
84
86
  * Set the automine status of the underlying anvil chain
85
87
  * @param automine - The automine status to set
86
88
  */
87
- setAutomine(automine: boolean): Promise<void>;
89
+ setAutomine(automine: boolean, opts?: {
90
+ silent?: boolean;
91
+ }): Promise<void>;
88
92
  /**
89
93
  * Drop a transaction from the mempool
90
94
  * @param txHash - The transaction hash
@@ -94,7 +98,7 @@ export declare class EthCheatCodes {
94
98
  * Set the next block timestamp
95
99
  * @param timestamp - The timestamp to set the next block to
96
100
  */
97
- setNextBlockTimestamp(timestamp: number): Promise<void>;
101
+ setNextBlockTimestamp(timestamp: number | Date): Promise<void>;
98
102
  /**
99
103
  * Set the next block timestamp and mines the block.
100
104
  * Optionally resets interval mining so the next block is mined in `blockInterval` seconds from now.
@@ -184,6 +188,6 @@ export declare class EthCheatCodes {
184
188
  value?: number | bigint;
185
189
  })[][]): Promise<void>;
186
190
  traceTransaction(txHash: Hex): Promise<any>;
187
- private execWithPausedAnvil;
191
+ execWithPausedAnvil(fn: () => Promise<void>): Promise<void>;
188
192
  }
189
193
  //# sourceMappingURL=eth_cheat_codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,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C,KAAK,MAAM,EAAE,CAAC;IAKtE;;;;OAIG;IACU,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAKnE;;;;OAIG;IACU,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAK7D;;;OAGG;IACI,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,mBAAmB,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCzE"}
@@ -143,7 +143,7 @@ import { createPublicClient, fallback, http } from 'viem';
143
143
  /**
144
144
  * Enable interval mining at the given interval (block time)
145
145
  * @param seconds - The interval to use between blocks
146
- */ async setIntervalMining(seconds) {
146
+ */ async setIntervalMining(seconds, opts = {}) {
147
147
  try {
148
148
  await this.rpcCall('anvil_setIntervalMining', [
149
149
  seconds
@@ -151,12 +151,14 @@ import { createPublicClient, fallback, http } from 'viem';
151
151
  } catch (err) {
152
152
  throw new Error(`Error setting interval mining: ${err}`);
153
153
  }
154
- this.logger.warn(`Set L1 interval mining to ${seconds} seconds`);
154
+ if (!opts.silent) {
155
+ this.logger.warn(`Set L1 interval mining to ${seconds} seconds`);
156
+ }
155
157
  }
156
158
  /**
157
159
  * Set the automine status of the underlying anvil chain
158
160
  * @param automine - The automine status to set
159
- */ async setAutomine(automine) {
161
+ */ async setAutomine(automine, opts = {}) {
160
162
  try {
161
163
  await this.rpcCall('anvil_setAutomine', [
162
164
  automine
@@ -164,7 +166,9 @@ import { createPublicClient, fallback, http } from 'viem';
164
166
  } catch (err) {
165
167
  throw new Error(`Error setting automine: ${err}`);
166
168
  }
167
- this.logger.warn(`Set L1 automine to ${automine}`);
169
+ if (!opts.silent) {
170
+ this.logger.warn(`Set L1 automine to ${automine}`);
171
+ }
168
172
  }
169
173
  /**
170
174
  * Drop a transaction from the mempool
@@ -185,7 +189,7 @@ import { createPublicClient, fallback, http } from 'viem';
185
189
  */ async setNextBlockTimestamp(timestamp) {
186
190
  try {
187
191
  await this.rpcCall('evm_setNextBlockTimestamp', [
188
- timestamp
192
+ timestamp instanceof Date ? Math.floor(timestamp.getTime() / 1000) : timestamp
189
193
  ]);
190
194
  } catch (err) {
191
195
  throw new Error(`Error setting next block timestamp: ${err.message}`);
@@ -204,7 +208,9 @@ import { createPublicClient, fallback, http } from 'viem';
204
208
  if (opts.resetBlockInterval) {
205
209
  blockInterval = await this.getIntervalMining();
206
210
  if (blockInterval !== null) {
207
- await this.setIntervalMining(0);
211
+ await this.setIntervalMining(0, {
212
+ silent: true
213
+ });
208
214
  }
209
215
  }
210
216
  // Set the timestamp of the next block to be mined
@@ -220,7 +226,9 @@ import { createPublicClient, fallback, http } from 'viem';
220
226
  } finally{
221
227
  // Restore interval mining so the next block is mined in `blockInterval` seconds from this one
222
228
  if (opts.resetBlockInterval && blockInterval !== null && blockInterval > 0) {
223
- await this.setIntervalMining(blockInterval);
229
+ await this.setIntervalMining(blockInterval, {
230
+ silent: true
231
+ });
224
232
  }
225
233
  }
226
234
  if (!opts.silent) {
@@ -410,17 +418,23 @@ import { createPublicClient, fallback, http } from 'viem';
410
418
  ]);
411
419
  try {
412
420
  if (blockInterval !== null) {
413
- await this.setIntervalMining(0);
421
+ await this.setIntervalMining(0, {
422
+ silent: true
423
+ });
414
424
  }
415
425
  if (wasAutoMining) {
416
- await this.setAutomine(false);
426
+ await this.setAutomine(false, {
427
+ silent: true
428
+ });
417
429
  }
418
430
  await fn();
419
431
  } finally{
420
432
  try {
421
433
  // restore automine if necessary
422
434
  if (wasAutoMining) {
423
- await this.setAutomine(true);
435
+ await this.setAutomine(true, {
436
+ silent: true
437
+ });
424
438
  }
425
439
  } catch (err) {
426
440
  this.logger.warn(`Failed to reenable automining: ${err}`);
@@ -428,7 +442,9 @@ import { createPublicClient, fallback, http } from 'viem';
428
442
  try {
429
443
  // restore automine if necessary
430
444
  if (blockInterval !== null) {
431
- await this.setIntervalMining(blockInterval);
445
+ await this.setIntervalMining(blockInterval, {
446
+ silent: true
447
+ });
432
448
  }
433
449
  } catch (err) {
434
450
  this.logger.warn(`Failed to reenable interval mining: ${err}`);
@@ -1,4 +1,4 @@
1
- import { EthCheatCodes } from '../eth_cheat_codes.js';
1
+ import { EthCheatCodes } from './eth_cheat_codes.js';
2
2
  /**
3
3
  * A class that provides utility functions for interacting with ethereum (L1) dumping/loading state to/from a file.
4
4
  * It is separated to avoid importing fs in the main EthCheatCodes class, which might be used in the browser.
@@ -1 +1 @@
1
- {"version":3,"file":"eth_cheat_codes_with_state.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes_with_state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,aAAa;IACvD;;;OAGG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D;;;OAGG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS7D"}
1
+ {"version":3,"file":"eth_cheat_codes_with_state.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes_with_state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,aAAa;IACvD;;;OAGG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D;;;OAGG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS7D"}
@@ -1,5 +1,5 @@
1
1
  import fs from 'fs';
2
- import { EthCheatCodes } from '../eth_cheat_codes.js';
2
+ import { EthCheatCodes } from './eth_cheat_codes.js';
3
3
  /**
4
4
  * A class that provides utility functions for interacting with ethereum (L1) dumping/loading state to/from a file.
5
5
  * It is separated to avoid importing fs in the main EthCheatCodes class, which might be used in the browser.
@@ -1,7 +1,9 @@
1
1
  export * from './delayed_tx_utils.js';
2
+ export * from './eth_cheat_codes.js';
2
3
  export * from './eth_cheat_codes_with_state.js';
3
4
  export * from './start_anvil.js';
4
5
  export * from './tx_delayer.js';
5
6
  export * from './upgrade_utils.js';
6
7
  export * from './chain_monitor.js';
8
+ export * from './rollup_cheat_codes.js';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export * from './delayed_tx_utils.js';
2
+ export * from './eth_cheat_codes.js';
2
3
  export * from './eth_cheat_codes_with_state.js';
3
4
  export * from './start_anvil.js';
4
5
  export * from './tx_delayer.js';
5
6
  export * from './upgrade_utils.js';
6
7
  export * from './chain_monitor.js';
8
+ export * from './rollup_cheat_codes.js';
@@ -0,0 +1,81 @@
1
+ import { type ViemPublicClient } from '@aztec/ethereum';
2
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
3
+ import type { TestDateProvider } from '@aztec/foundation/timer';
4
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
5
+ import { type GetContractReturnType, type Hex } from 'viem';
6
+ import { EthCheatCodes } from './eth_cheat_codes.js';
7
+ /** Cheat codes for the L1 rollup contract. */
8
+ export declare class RollupCheatCodes {
9
+ private ethCheatCodes;
10
+ private client;
11
+ private rollup;
12
+ private logger;
13
+ constructor(ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>);
14
+ static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>): RollupCheatCodes;
15
+ /** Returns the current slot */
16
+ getSlot(): Promise<bigint>;
17
+ /** Returns the current epoch */
18
+ getEpoch(): Promise<bigint>;
19
+ /**
20
+ * Returns the pending and proven chain tips
21
+ * @returns The pending and proven chain tips
22
+ */
23
+ getTips(): Promise<{
24
+ /** The pending chain tip */ pending: bigint;
25
+ /** The proven chain tip */ proven: bigint;
26
+ }>;
27
+ /**
28
+ * Logs the current state of the rollup contract.
29
+ */
30
+ debugRollup(): Promise<void>;
31
+ /** Fetches the epoch and slot duration config from the rollup contract */
32
+ getConfig(): Promise<{
33
+ /** Epoch duration */ epochDuration: bigint;
34
+ /** Slot duration */ slotDuration: bigint;
35
+ }>;
36
+ /**
37
+ * Advances time to the beginning of the given epoch
38
+ * @param epoch - The epoch to advance to
39
+ * @param opts - Options
40
+ */
41
+ advanceToEpoch(epoch: bigint, opts?: {
42
+ /** Optional test date provider to update with the epoch timestamp */
43
+ updateDateProvider?: TestDateProvider;
44
+ }): Promise<bigint>;
45
+ /** Warps time in L1 until the next epoch */
46
+ advanceToNextEpoch(): Promise<void>;
47
+ /** Warps time in L1 until the beginning of the next slot. */
48
+ advanceToNextSlot(): Promise<bigint[]>;
49
+ /**
50
+ * Warps time in L1 equivalent to however many slots.
51
+ * @param howMany - The number of slots to advance.
52
+ */
53
+ advanceSlots(howMany: number): Promise<void>;
54
+ /**
55
+ * Marks the specified block (or latest if none) as proven
56
+ * @param maybeBlockNumber - The block number to mark as proven (defaults to latest pending)
57
+ */
58
+ markAsProven(maybeBlockNumber?: number | bigint): Promise<void>;
59
+ /**
60
+ * Executes an action impersonated as the owner of the Rollup contract.
61
+ * @param action - The action to execute
62
+ */
63
+ asOwner(action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>) => Promise<void>): Promise<void>;
64
+ /**
65
+ * Sets up the epoch.
66
+ */
67
+ setupEpoch(): Promise<void>;
68
+ /** Directly calls the L1 gas fee oracle. */
69
+ updateL1GasFeeOracle(): Promise<void>;
70
+ /**
71
+ * Bumps proving cost per mana.
72
+ * @param bumper - Callback to calculate the new proving cost per mana based on current value.
73
+ */
74
+ bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
75
+ /**
76
+ * Directly updates proving cost per mana.
77
+ * @param ethValue - The new proving cost per mana in ETH
78
+ */
79
+ setProvingCostPerMana(ethValue: bigint): Promise<void>;
80
+ }
81
+ //# sourceMappingURL=rollup_cheat_codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,gBAAg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AU/B,6DAA6D;IAChD,iBAAiB;IAQ9B;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM;IASzC;;;OAGG;IACI,YAAY,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;IAiCtD;;;OAGG;IACU,OAAO,CAClB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;IAQ1G;;OAEG;IACU,UAAU;IASvB,4CAA4C;IAC/B,oBAAoB;IAQjC;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM;IAMtE;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAOpD"}
@@ -0,0 +1,234 @@
1
+ import { RollupContract } from '@aztec/ethereum';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { createLogger } from '@aztec/foundation/log';
4
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
5
+ import { createPublicClient, fallback, getContract, hexToBigInt, http } from 'viem';
6
+ import { foundry } from 'viem/chains';
7
+ import { EthCheatCodes } from './eth_cheat_codes.js';
8
+ /** Cheat codes for the L1 rollup contract. */ export class RollupCheatCodes {
9
+ ethCheatCodes;
10
+ client;
11
+ rollup;
12
+ logger;
13
+ constructor(ethCheatCodes, addresses){
14
+ this.ethCheatCodes = ethCheatCodes;
15
+ this.logger = createLogger('aztecjs:cheat_codes');
16
+ this.client = createPublicClient({
17
+ chain: foundry,
18
+ transport: fallback(ethCheatCodes.rpcUrls.map((url)=>http(url)))
19
+ });
20
+ this.rollup = getContract({
21
+ abi: RollupAbi,
22
+ address: addresses.rollupAddress.toString(),
23
+ client: this.client
24
+ });
25
+ }
26
+ static create(rpcUrls, addresses) {
27
+ const ethCheatCodes = new EthCheatCodes(rpcUrls);
28
+ return new RollupCheatCodes(ethCheatCodes, addresses);
29
+ }
30
+ /** Returns the current slot */ async getSlot() {
31
+ const ts = BigInt((await this.client.getBlock()).timestamp);
32
+ return await this.rollup.read.getSlotAt([
33
+ ts
34
+ ]);
35
+ }
36
+ /** Returns the current epoch */ async getEpoch() {
37
+ const slotNumber = await this.getSlot();
38
+ return await this.rollup.read.getEpochAtSlot([
39
+ slotNumber
40
+ ]);
41
+ }
42
+ /**
43
+ * Returns the pending and proven chain tips
44
+ * @returns The pending and proven chain tips
45
+ */ async getTips() {
46
+ const res = await this.rollup.read.getTips();
47
+ return {
48
+ pending: res.pendingBlockNumber,
49
+ proven: res.provenBlockNumber
50
+ };
51
+ }
52
+ /**
53
+ * Logs the current state of the rollup contract.
54
+ */ async debugRollup() {
55
+ const rollup = new RollupContract(this.client, this.rollup.address);
56
+ const pendingNum = await rollup.getBlockNumber();
57
+ const provenNum = await rollup.getProvenBlockNumber();
58
+ const validators = await rollup.getAttesters();
59
+ const committee = await rollup.getCurrentEpochCommittee();
60
+ const archive = await rollup.archive();
61
+ const slot = await this.getSlot();
62
+ const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
63
+ this.logger.info(`Pending block num: ${pendingNum}`);
64
+ this.logger.info(`Proven block num: ${provenNum}`);
65
+ this.logger.info(`Validators: ${validators.map((v)=>v.toString()).join(', ')}`);
66
+ this.logger.info(`Committee: ${committee?.map((v)=>v.toString()).join(', ')}`);
67
+ this.logger.info(`Archive: ${archive}`);
68
+ this.logger.info(`Epoch num: ${epochNum}`);
69
+ this.logger.info(`Slot: ${slot}`);
70
+ }
71
+ /** Fetches the epoch and slot duration config from the rollup contract */ async getConfig() {
72
+ const [epochDuration, slotDuration] = await Promise.all([
73
+ this.rollup.read.getEpochDuration(),
74
+ this.rollup.read.getSlotDuration()
75
+ ]);
76
+ return {
77
+ epochDuration,
78
+ slotDuration
79
+ };
80
+ }
81
+ /**
82
+ * Advances time to the beginning of the given epoch
83
+ * @param epoch - The epoch to advance to
84
+ * @param opts - Options
85
+ */ async advanceToEpoch(epoch, opts = {}) {
86
+ const { epochDuration: slotsInEpoch } = await this.getConfig();
87
+ const timestamp = await this.rollup.read.getTimestampForSlot([
88
+ epoch * slotsInEpoch
89
+ ]);
90
+ try {
91
+ await this.ethCheatCodes.warp(Number(timestamp), {
92
+ ...opts,
93
+ silent: true,
94
+ resetBlockInterval: true
95
+ });
96
+ this.logger.warn(`Warped to epoch ${epoch}`);
97
+ } catch (err) {
98
+ this.logger.warn(`Warp to epoch ${epoch} failed: ${err}`);
99
+ }
100
+ return timestamp;
101
+ }
102
+ /** Warps time in L1 until the next epoch */ async advanceToNextEpoch() {
103
+ const slot = await this.getSlot();
104
+ const { epochDuration, slotDuration } = await this.getConfig();
105
+ const slotsUntilNextEpoch = epochDuration - slot % epochDuration + 1n;
106
+ const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
107
+ const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
108
+ await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
109
+ silent: true,
110
+ resetBlockInterval: true
111
+ });
112
+ this.logger.warn(`Advanced to next epoch`);
113
+ }
114
+ /** Warps time in L1 until the beginning of the next slot. */ async advanceToNextSlot() {
115
+ const currentSlot = await this.getSlot();
116
+ const timestamp = await this.rollup.read.getTimestampForSlot([
117
+ currentSlot + 1n
118
+ ]);
119
+ await this.ethCheatCodes.warp(Number(timestamp), {
120
+ silent: true,
121
+ resetBlockInterval: true
122
+ });
123
+ this.logger.warn(`Advanced to slot ${currentSlot + 1n}`);
124
+ return [
125
+ timestamp,
126
+ currentSlot + 1n
127
+ ];
128
+ }
129
+ /**
130
+ * Warps time in L1 equivalent to however many slots.
131
+ * @param howMany - The number of slots to advance.
132
+ */ async advanceSlots(howMany) {
133
+ const l1Timestamp = (await this.client.getBlock()).timestamp;
134
+ const slotDuration = await this.rollup.read.getSlotDuration();
135
+ const timeToWarp = BigInt(howMany) * slotDuration;
136
+ await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, {
137
+ silent: true,
138
+ resetBlockInterval: true
139
+ });
140
+ const [slot, epoch] = await Promise.all([
141
+ this.getSlot(),
142
+ this.getEpoch()
143
+ ]);
144
+ this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
145
+ }
146
+ /**
147
+ * Marks the specified block (or latest if none) as proven
148
+ * @param maybeBlockNumber - The block number to mark as proven (defaults to latest pending)
149
+ */ markAsProven(maybeBlockNumber) {
150
+ return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
151
+ const tipsBefore = await this.getTips();
152
+ const { pending, proven } = tipsBefore;
153
+ let blockNumber = maybeBlockNumber;
154
+ if (blockNumber === undefined || blockNumber > pending) {
155
+ blockNumber = pending;
156
+ }
157
+ if (blockNumber <= proven) {
158
+ this.logger.debug(`Block ${blockNumber} is already proven`);
159
+ return;
160
+ }
161
+ // @note @LHerskind this is heavily dependent on the storage layout and size of values
162
+ // The rollupStore is a struct and if the size of elements or the struct changes, this can break
163
+ const provenBlockNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
164
+ // Need to pack it as a single 32 byte word
165
+ const newValue = BigInt(tipsBefore.pending) << 128n | BigInt(blockNumber);
166
+ await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenBlockNumberSlot, newValue);
167
+ const tipsAfter = await this.getTips();
168
+ if (tipsAfter.pending < tipsAfter.proven) {
169
+ throw new Error('Overwrote pending tip to a block in the past');
170
+ }
171
+ this.logger.info(`Proven tip moved: ${tipsBefore.proven} -> ${tipsAfter.proven}. Pending tip: ${tipsAfter.pending}.`);
172
+ });
173
+ }
174
+ /**
175
+ * Executes an action impersonated as the owner of the Rollup contract.
176
+ * @param action - The action to execute
177
+ */ async asOwner(action) {
178
+ const owner = await this.rollup.read.owner();
179
+ await this.ethCheatCodes.startImpersonating(owner);
180
+ await action(owner, this.rollup);
181
+ await this.ethCheatCodes.stopImpersonating(owner);
182
+ }
183
+ /**
184
+ * Sets up the epoch.
185
+ */ async setupEpoch() {
186
+ // Doesn't need to be done as owner, but the functionality is here...
187
+ await this.asOwner(async (account, rollup)=>{
188
+ const hash = await rollup.write.setupEpoch({
189
+ account
190
+ });
191
+ await this.client.waitForTransactionReceipt({
192
+ hash
193
+ });
194
+ this.logger.warn(`Setup epoch`);
195
+ });
196
+ }
197
+ /** Directly calls the L1 gas fee oracle. */ async updateL1GasFeeOracle() {
198
+ await this.asOwner(async (account, rollup)=>{
199
+ const hash = await rollup.write.updateL1GasFeeOracle({
200
+ account,
201
+ chain: this.client.chain
202
+ });
203
+ await this.client.waitForTransactionReceipt({
204
+ hash
205
+ });
206
+ this.logger.warn(`Updated L1 gas fee oracle`);
207
+ });
208
+ }
209
+ /**
210
+ * Bumps proving cost per mana.
211
+ * @param bumper - Callback to calculate the new proving cost per mana based on current value.
212
+ */ async bumpProvingCostPerMana(bumper) {
213
+ const currentCost = await this.rollup.read.getProvingCostPerManaInEth();
214
+ const newCost = bumper(currentCost);
215
+ await this.setProvingCostPerMana(newCost);
216
+ }
217
+ /**
218
+ * Directly updates proving cost per mana.
219
+ * @param ethValue - The new proving cost per mana in ETH
220
+ */ async setProvingCostPerMana(ethValue) {
221
+ await this.asOwner(async (account, rollup)=>{
222
+ const hash = await rollup.write.setProvingCostPerMana([
223
+ ethValue
224
+ ], {
225
+ account,
226
+ chain: this.client.chain
227
+ });
228
+ await this.client.waitForTransactionReceipt({
229
+ hash
230
+ });
231
+ this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
232
+ });
233
+ }
234
+ }
@@ -5,6 +5,7 @@ import { type Anvil } from '@viem/anvil';
5
5
  export declare function startAnvil(opts?: {
6
6
  port?: number;
7
7
  l1BlockTime?: number;
8
+ log?: boolean;
8
9
  captureMethodCalls?: boolean;
9
10
  accounts?: number;
10
11
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,aAAa,CAAC;AAGtD;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAyC9F"}
1
+ {"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,aAAa,CAAC;AAGtD;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CA+C9F"}
@@ -1,3 +1,4 @@
1
+ import { createLogger } from '@aztec/foundation/log';
1
2
  import { makeBackoff, retry } from '@aztec/foundation/retry';
2
3
  import { fileURLToPath } from '@aztec/foundation/url';
3
4
  import { createAnvil } from '@viem/anvil';
@@ -6,6 +7,7 @@ import { dirname, resolve } from 'path';
6
7
  * Ensures there's a running Anvil instance and returns the RPC URL.
7
8
  */ export async function startAnvil(opts = {}) {
8
9
  const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
10
+ const logger = opts.log ? createLogger('ethereum:anvil') : undefined;
9
11
  const methodCalls = opts.captureMethodCalls ? [] : undefined;
10
12
  let port;
11
13
  // Start anvil.
@@ -21,13 +23,16 @@ import { dirname, resolve } from 'path';
21
23
  });
22
24
  // Listen to the anvil output to get the port.
23
25
  const removeHandler = anvil.on('message', (message)=>{
26
+ logger?.debug(message.trim());
24
27
  methodCalls?.push(...message.match(/eth_[^\s]+/g) || []);
25
28
  if (port === undefined && message.includes('Listening on')) {
26
29
  port = parseInt(message.match(/Listening on ([^:]+):(\d+)/)[2]);
27
30
  }
28
31
  });
29
32
  await anvil.start();
30
- removeHandler();
33
+ if (!logger && !opts.captureMethodCalls) {
34
+ removeHandler();
35
+ }
31
36
  return anvil;
32
37
  }, 'Start anvil', makeBackoff([
33
38
  5,
@@ -1,4 +1,5 @@
1
1
  import { type Logger } from '@aztec/foundation/log';
2
+ import type { DateProvider } from '@aztec/foundation/timer';
2
3
  import { type Client, type Hex } from 'viem';
3
4
  import { type ViemClient } from '../types.js';
4
5
  export declare function waitUntilBlock<T extends Client>(client: T, blockNumber: number | bigint, logger?: Logger): Promise<boolean>;
@@ -14,13 +15,19 @@ export interface Delayer {
14
15
  pauseNextTxUntilTimestamp(l1Timestamp: number | bigint | undefined): void;
15
16
  /** Delays the next tx to be sent indefinitely. */
16
17
  cancelNextTx(): void;
18
+ /**
19
+ * Sets max inclusion time into slot. If more than this many seconds have passed
20
+ * since the last L1 block was mined, then any tx will not be mined in the current
21
+ * L1 slot but will be deferred for the next one.
22
+ */
23
+ setMaxInclusionTimeIntoSlot(seconds: number | bigint | undefined): void;
17
24
  }
18
25
  /**
19
26
  * Returns a new client (without modifying the one passed in) with an injected tx delayer.
20
27
  * The delayer can be used to hold off the next tx to be sent until a given block number.
21
28
  * TODO(#10824): This doesn't play along well with blob txs for some reason.
22
29
  */
23
- export declare function withDelayer<T extends ViemClient>(client: T, opts: {
30
+ export declare function withDelayer<T extends ViemClient>(client: T, dateProvider: DateProvider, opts: {
24
31
  ethereumSlotDuration: bigint | number;
25
32
  }): {
26
33
  client: T;