@aztec-labs/ethereum 6.0.0-nightly.20260829

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 (272) hide show
  1. package/README.md +3 -0
  2. package/dest/account.d.ts +2 -0
  3. package/dest/account.d.ts.map +1 -0
  4. package/dest/account.js +4 -0
  5. package/dest/chain.d.ts +25 -0
  6. package/dest/chain.d.ts.map +1 -0
  7. package/dest/chain.js +53 -0
  8. package/dest/client.d.ts +42 -0
  9. package/dest/client.d.ts.map +1 -0
  10. package/dest/client.js +104 -0
  11. package/dest/config.d.ts +103 -0
  12. package/dest/config.d.ts.map +1 -0
  13. package/dest/config.js +233 -0
  14. package/dest/constants.d.ts +4 -0
  15. package/dest/constants.d.ts.map +1 -0
  16. package/dest/constants.js +2 -0
  17. package/dest/contracts/chain_state_override.d.ts +81 -0
  18. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  19. package/dest/contracts/chain_state_override.js +139 -0
  20. package/dest/contracts/empire_base.d.ts +30 -0
  21. package/dest/contracts/empire_base.d.ts.map +1 -0
  22. package/dest/contracts/empire_base.js +84 -0
  23. package/dest/contracts/errors.d.ts +7 -0
  24. package/dest/contracts/errors.d.ts.map +1 -0
  25. package/dest/contracts/errors.js +12 -0
  26. package/dest/contracts/fee_asset_handler.d.ts +20 -0
  27. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  28. package/dest/contracts/fee_asset_handler.js +59 -0
  29. package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
  30. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  31. package/dest/contracts/fee_asset_price_oracle.js +656 -0
  32. package/dest/contracts/fee_juice.d.ts +14 -0
  33. package/dest/contracts/fee_juice.d.ts.map +1 -0
  34. package/dest/contracts/fee_juice.js +59 -0
  35. package/dest/contracts/governance.d.ts +192 -0
  36. package/dest/contracts/governance.d.ts.map +1 -0
  37. package/dest/contracts/governance.js +471 -0
  38. package/dest/contracts/governance_proposer.d.ts +63 -0
  39. package/dest/contracts/governance_proposer.d.ts.map +1 -0
  40. package/dest/contracts/governance_proposer.js +536 -0
  41. package/dest/contracts/gse.d.ts +38 -0
  42. package/dest/contracts/gse.d.ts.map +1 -0
  43. package/dest/contracts/gse.js +81 -0
  44. package/dest/contracts/inbox.d.ts +94 -0
  45. package/dest/contracts/inbox.d.ts.map +1 -0
  46. package/dest/contracts/inbox.js +141 -0
  47. package/dest/contracts/index.d.ts +18 -0
  48. package/dest/contracts/index.d.ts.map +1 -0
  49. package/dest/contracts/index.js +17 -0
  50. package/dest/contracts/log.d.ts +13 -0
  51. package/dest/contracts/log.d.ts.map +1 -0
  52. package/dest/contracts/log.js +1 -0
  53. package/dest/contracts/multicall.d.ts +138 -0
  54. package/dest/contracts/multicall.d.ts.map +1 -0
  55. package/dest/contracts/multicall.js +266 -0
  56. package/dest/contracts/outbox.d.ts +64 -0
  57. package/dest/contracts/outbox.d.ts.map +1 -0
  58. package/dest/contracts/outbox.js +113 -0
  59. package/dest/contracts/registry.d.ts +31 -0
  60. package/dest/contracts/registry.d.ts.map +1 -0
  61. package/dest/contracts/registry.js +142 -0
  62. package/dest/contracts/rollup.d.ts +5836 -0
  63. package/dest/contracts/rollup.d.ts.map +1 -0
  64. package/dest/contracts/rollup.js +1612 -0
  65. package/dest/contracts/slasher_contract.d.ts +44 -0
  66. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  67. package/dest/contracts/slasher_contract.js +75 -0
  68. package/dest/contracts/slashing_proposer.d.ts +174 -0
  69. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  70. package/dest/contracts/slashing_proposer.js +755 -0
  71. package/dest/contracts/utils.d.ts +3 -0
  72. package/dest/contracts/utils.d.ts.map +1 -0
  73. package/dest/contracts/utils.js +11 -0
  74. package/dest/contracts/watch_event.d.ts +36 -0
  75. package/dest/contracts/watch_event.d.ts.map +1 -0
  76. package/dest/contracts/watch_event.js +66 -0
  77. package/dest/deploy_aztec_l1_contracts.d.ts +267 -0
  78. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  79. package/dest/deploy_aztec_l1_contracts.js +424 -0
  80. package/dest/deploy_l1_contract.d.ts +68 -0
  81. package/dest/deploy_l1_contract.d.ts.map +1 -0
  82. package/dest/deploy_l1_contract.js +312 -0
  83. package/dest/eth-signer/eth-signer.d.ts +21 -0
  84. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  85. package/dest/eth-signer/eth-signer.js +5 -0
  86. package/dest/eth-signer/index.d.ts +2 -0
  87. package/dest/eth-signer/index.d.ts.map +1 -0
  88. package/dest/eth-signer/index.js +1 -0
  89. package/dest/forwarder_proxy.d.ts +32 -0
  90. package/dest/forwarder_proxy.d.ts.map +1 -0
  91. package/dest/forwarder_proxy.js +93 -0
  92. package/dest/foundry_binary.d.ts +13 -0
  93. package/dest/foundry_binary.d.ts.map +1 -0
  94. package/dest/foundry_binary.js +52 -0
  95. package/dest/l1_artifacts.d.ts +81896 -0
  96. package/dest/l1_artifacts.d.ts.map +1 -0
  97. package/dest/l1_artifacts.js +151 -0
  98. package/dest/l1_contract_addresses.d.ts +73 -0
  99. package/dest/l1_contract_addresses.d.ts.map +1 -0
  100. package/dest/l1_contract_addresses.js +120 -0
  101. package/dest/l1_reader.d.ts +18 -0
  102. package/dest/l1_reader.d.ts.map +1 -0
  103. package/dest/l1_reader.js +35 -0
  104. package/dest/l1_tx_utils/config.d.ts +65 -0
  105. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  106. package/dest/l1_tx_utils/config.js +109 -0
  107. package/dest/l1_tx_utils/constants.d.ts +12 -0
  108. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  109. package/dest/l1_tx_utils/constants.js +39 -0
  110. package/dest/l1_tx_utils/factory.d.ts +32 -0
  111. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  112. package/dest/l1_tx_utils/factory.js +22 -0
  113. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  114. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  115. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  116. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  117. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  118. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  119. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  120. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  121. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  122. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  123. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  124. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  125. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  126. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  127. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
  128. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  129. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  130. package/dest/l1_tx_utils/index-blobs.js +2 -0
  131. package/dest/l1_tx_utils/index.d.ts +13 -0
  132. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  133. package/dest/l1_tx_utils/index.js +13 -0
  134. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  135. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  136. package/dest/l1_tx_utils/interfaces.js +4 -0
  137. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +252 -0
  138. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  139. package/dest/l1_tx_utils/l1_fee_analyzer.js +568 -0
  140. package/dest/l1_tx_utils/l1_tx_utils.d.ts +113 -0
  141. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  142. package/dest/l1_tx_utils/l1_tx_utils.js +720 -0
  143. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
  144. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  145. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +357 -0
  146. package/dest/l1_tx_utils/signer.d.ts +4 -0
  147. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  148. package/dest/l1_tx_utils/signer.js +16 -0
  149. package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
  150. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  151. package/dest/l1_tx_utils/tx_delayer.js +223 -0
  152. package/dest/l1_tx_utils/types.d.ts +93 -0
  153. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  154. package/dest/l1_tx_utils/types.js +36 -0
  155. package/dest/l1_tx_utils/utils.d.ts +4 -0
  156. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  157. package/dest/l1_tx_utils/utils.js +14 -0
  158. package/dest/l1_types.d.ts +6 -0
  159. package/dest/l1_types.d.ts.map +1 -0
  160. package/dest/l1_types.js +1 -0
  161. package/dest/publisher_manager.d.ts +42 -0
  162. package/dest/publisher_manager.d.ts.map +1 -0
  163. package/dest/publisher_manager.js +199 -0
  164. package/dest/queries.d.ts +25 -0
  165. package/dest/queries.d.ts.map +1 -0
  166. package/dest/queries.js +144 -0
  167. package/dest/test/blob_kzg_warmup.d.ts +19 -0
  168. package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
  169. package/dest/test/blob_kzg_warmup.js +64 -0
  170. package/dest/test/chain_monitor.d.ts +126 -0
  171. package/dest/test/chain_monitor.d.ts.map +1 -0
  172. package/dest/test/chain_monitor.js +314 -0
  173. package/dest/test/eth_cheat_codes.d.ts +260 -0
  174. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  175. package/dest/test/eth_cheat_codes.js +608 -0
  176. package/dest/test/eth_cheat_codes_with_state.d.ts +18 -0
  177. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -0
  178. package/dest/test/eth_cheat_codes_with_state.js +34 -0
  179. package/dest/test/index.d.ts +8 -0
  180. package/dest/test/index.d.ts.map +1 -0
  181. package/dest/test/index.js +7 -0
  182. package/dest/test/recording_rpc_server.d.ts +18 -0
  183. package/dest/test/recording_rpc_server.d.ts.map +1 -0
  184. package/dest/test/recording_rpc_server.js +68 -0
  185. package/dest/test/rollup_cheat_codes.d.ts +142 -0
  186. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  187. package/dest/test/rollup_cheat_codes.js +338 -0
  188. package/dest/test/start_anvil.d.ts +40 -0
  189. package/dest/test/start_anvil.d.ts.map +1 -0
  190. package/dest/test/start_anvil.js +210 -0
  191. package/dest/test/upgrade_utils.d.ts +12 -0
  192. package/dest/test/upgrade_utils.d.ts.map +1 -0
  193. package/dest/test/upgrade_utils.js +111 -0
  194. package/dest/types.d.ts +68 -0
  195. package/dest/types.d.ts.map +1 -0
  196. package/dest/types.js +3 -0
  197. package/dest/utils.d.ts +45 -0
  198. package/dest/utils.d.ts.map +1 -0
  199. package/dest/utils.js +260 -0
  200. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  201. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  202. package/dest/zkPassportVerifierAddress.js +11 -0
  203. package/package.json +122 -0
  204. package/src/account.ts +5 -0
  205. package/src/chain.ts +71 -0
  206. package/src/client.ts +165 -0
  207. package/src/config.ts +342 -0
  208. package/src/constants.ts +4 -0
  209. package/src/contracts/README.md +157 -0
  210. package/src/contracts/chain_state_override.ts +203 -0
  211. package/src/contracts/empire_base.ts +89 -0
  212. package/src/contracts/errors.ts +13 -0
  213. package/src/contracts/fee_asset_handler.ts +66 -0
  214. package/src/contracts/fee_asset_price_oracle.ts +284 -0
  215. package/src/contracts/fee_juice.ts +57 -0
  216. package/src/contracts/governance.ts +597 -0
  217. package/src/contracts/governance_proposer.ts +181 -0
  218. package/src/contracts/gse.ts +105 -0
  219. package/src/contracts/inbox.ts +223 -0
  220. package/src/contracts/index.ts +17 -0
  221. package/src/contracts/log.ts +13 -0
  222. package/src/contracts/multicall.ts +298 -0
  223. package/src/contracts/outbox.ts +132 -0
  224. package/src/contracts/registry.ts +161 -0
  225. package/src/contracts/rollup.ts +1502 -0
  226. package/src/contracts/slasher_contract.ts +89 -0
  227. package/src/contracts/slashing_proposer.ts +397 -0
  228. package/src/contracts/utils.ts +14 -0
  229. package/src/contracts/watch_event.ts +109 -0
  230. package/src/deploy_aztec_l1_contracts.ts +663 -0
  231. package/src/deploy_l1_contract.ts +361 -0
  232. package/src/eth-signer/eth-signer.ts +24 -0
  233. package/src/eth-signer/index.ts +1 -0
  234. package/src/forwarder_proxy.ts +107 -0
  235. package/src/foundry_binary.ts +57 -0
  236. package/src/l1_artifacts.ts +231 -0
  237. package/src/l1_contract_addresses.ts +149 -0
  238. package/src/l1_reader.ts +57 -0
  239. package/src/l1_tx_utils/README.md +177 -0
  240. package/src/l1_tx_utils/config.ts +181 -0
  241. package/src/l1_tx_utils/constants.ts +29 -0
  242. package/src/l1_tx_utils/factory.ts +64 -0
  243. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  244. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +162 -0
  245. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +244 -0
  246. package/src/l1_tx_utils/fee-strategies/types.ts +55 -0
  247. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +107 -0
  248. package/src/l1_tx_utils/index-blobs.ts +2 -0
  249. package/src/l1_tx_utils/index.ts +15 -0
  250. package/src/l1_tx_utils/interfaces.ts +86 -0
  251. package/src/l1_tx_utils/l1_fee_analyzer.ts +874 -0
  252. package/src/l1_tx_utils/l1_tx_utils.ts +840 -0
  253. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +459 -0
  254. package/src/l1_tx_utils/signer.ts +27 -0
  255. package/src/l1_tx_utils/tx_delayer.ts +302 -0
  256. package/src/l1_tx_utils/types.ts +116 -0
  257. package/src/l1_tx_utils/utils.ts +15 -0
  258. package/src/l1_types.ts +6 -0
  259. package/src/publisher_manager.ts +239 -0
  260. package/src/queries.ts +189 -0
  261. package/src/test/blob_kzg_warmup.ts +65 -0
  262. package/src/test/chain_monitor.ts +389 -0
  263. package/src/test/eth_cheat_codes.ts +624 -0
  264. package/src/test/eth_cheat_codes_with_state.ts +38 -0
  265. package/src/test/index.ts +7 -0
  266. package/src/test/recording_rpc_server.ts +69 -0
  267. package/src/test/rollup_cheat_codes.ts +398 -0
  268. package/src/test/start_anvil.ts +255 -0
  269. package/src/test/upgrade_utils.ts +109 -0
  270. package/src/types.ts +97 -0
  271. package/src/utils.ts +344 -0
  272. package/src/zkPassportVerifierAddress.ts +15 -0
@@ -0,0 +1,18 @@
1
+ /** A JSON-RPC endpoint that records the method of every request it receives. */
2
+ export type RecordingRpcServer = {
3
+ /** URL the server listens on. */
4
+ url: string;
5
+ /** Methods of the JSON-RPC requests received so far, in arrival order. */
6
+ methods: string[];
7
+ /** Stops the server. */
8
+ close: () => Promise<void>;
9
+ };
10
+ /**
11
+ * Starts a JSON-RPC server that records the method of every request it receives, so tests can assert on what a
12
+ * client actually put on the wire. Requests are forwarded to `forwardTo` when given; otherwise the server answers
13
+ * `eth_chainId` with the anvil chain id and rejects anything else.
14
+ */
15
+ export declare function startRecordingRpcServer(opts?: {
16
+ forwardTo?: string;
17
+ }): Promise<RecordingRpcServer>;
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjb3JkaW5nX3JwY19zZXJ2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3JlY29yZGluZ19ycGNfc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLGdGQUFnRjtBQUNoRixNQUFNLE1BQU0sa0JBQWtCLEdBQUc7SUFDL0IsaUNBQWlDO0lBQ2pDLEdBQUcsRUFBRSxNQUFNLENBQUM7SUFDWiwwRUFBMEU7SUFDMUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ2xCLHdCQUF3QjtJQUN4QixLQUFLLEVBQUUsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDNUIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBc0IsdUJBQXVCLENBQUMsSUFBSSxHQUFFO0lBQUUsU0FBUyxDQUFDLEVBQUUsTUFBTSxDQUFBO0NBQU8sR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FtRDVHIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recording_rpc_server.d.ts","sourceRoot":"","sources":["../../src/test/recording_rpc_server.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wBAAwB;IACxB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmD5G"}
@@ -0,0 +1,68 @@
1
+ import { createServer } from 'node:http';
2
+ /**
3
+ * Starts a JSON-RPC server that records the method of every request it receives, so tests can assert on what a
4
+ * client actually put on the wire. Requests are forwarded to `forwardTo` when given; otherwise the server answers
5
+ * `eth_chainId` with the anvil chain id and rejects anything else.
6
+ */ export async function startRecordingRpcServer(opts = {}) {
7
+ const methods = [];
8
+ const server = createServer((req, res)=>{
9
+ const chunks = [];
10
+ req.on('data', (chunk)=>chunks.push(Buffer.from(chunk)));
11
+ req.on('end', ()=>{
12
+ void (async ()=>{
13
+ const body = Buffer.concat(chunks).toString();
14
+ const parsed = body.length > 0 ? JSON.parse(body) : undefined;
15
+ const requests = Array.isArray(parsed) ? parsed : [
16
+ parsed
17
+ ];
18
+ for (const request of requests){
19
+ const method = request?.method;
20
+ if (typeof method === 'string') {
21
+ methods.push(method);
22
+ }
23
+ }
24
+ if (opts.forwardTo) {
25
+ const response = await fetch(opts.forwardTo, {
26
+ method: 'POST',
27
+ headers: {
28
+ 'content-type': 'application/json'
29
+ },
30
+ body
31
+ });
32
+ res.writeHead(response.status, {
33
+ 'content-type': 'application/json'
34
+ });
35
+ res.end(await response.text());
36
+ return;
37
+ }
38
+ const id = requests[0]?.id ?? 1;
39
+ const result = methods[methods.length - 1] === 'eth_chainId' ? {
40
+ jsonrpc: '2.0',
41
+ id,
42
+ result: '0x7a69'
43
+ } : {
44
+ jsonrpc: '2.0',
45
+ id,
46
+ error: {
47
+ code: -32601,
48
+ message: 'method not handled by test server'
49
+ }
50
+ };
51
+ res.writeHead(200, {
52
+ 'content-type': 'application/json'
53
+ });
54
+ res.end(JSON.stringify(result));
55
+ })();
56
+ });
57
+ });
58
+ await new Promise((resolve)=>server.listen(0, '127.0.0.1', resolve));
59
+ const address = server.address();
60
+ if (!address || typeof address === 'string') {
61
+ throw new Error('Expected recording RPC server to listen on a TCP port');
62
+ }
63
+ return {
64
+ url: `http://127.0.0.1:${address.port}`,
65
+ methods,
66
+ close: ()=>new Promise((resolve)=>server.close(()=>resolve()))
67
+ };
68
+ }
@@ -0,0 +1,142 @@
1
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
2
+ import type { L1ContractAddresses } from '@aztec-labs/ethereum/l1-contract-addresses';
3
+ import type { ViemPublicClient } from '@aztec-labs/ethereum/types';
4
+ import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec-labs/foundation/branded-types';
5
+ import type { DateProvider } from '@aztec-labs/foundation/timer';
6
+ import { type GetContractReturnType, type Hex } from 'viem';
7
+ import { EthCheatCodes } from './eth_cheat_codes.js';
8
+ /** Cheat codes for the L1 rollup contract. */
9
+ export declare class RollupCheatCodes {
10
+ private ethCheatCodes;
11
+ private client;
12
+ private rollup;
13
+ private logger;
14
+ constructor(ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>);
15
+ static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>, dateProvider: DateProvider): RollupCheatCodes;
16
+ /** Returns the current slot */
17
+ getSlot(): Promise<SlotNumber>;
18
+ /** Returns the slot number at a given timestamp. */
19
+ getSlotAt(timestamp: bigint): Promise<SlotNumber>;
20
+ /** Returns the timestamp for the start of a given slot. */
21
+ getTimestampForSlot(slot: SlotNumber): Promise<bigint>;
22
+ /** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
23
+ getSecondsUntilSlot(slot: SlotNumber): Promise<number>;
24
+ /** Returns the current epoch */
25
+ getEpoch(): Promise<EpochNumber>;
26
+ /**
27
+ * Returns the pending and proven chain tips
28
+ * @returns The pending and proven chain tips
29
+ */
30
+ getTips(): Promise<{
31
+ /** The pending chain tip */ pending: CheckpointNumber;
32
+ /** The proven chain tip */ proven: CheckpointNumber;
33
+ }>;
34
+ /**
35
+ * Logs the current state of the rollup contract.
36
+ */
37
+ debugRollup(): Promise<void>;
38
+ /** Fetches the epoch and slot duration config from the rollup contract */
39
+ getConfig(): Promise<{
40
+ /** Epoch duration */ epochDuration: bigint;
41
+ /** Slot duration */ slotDuration: number;
42
+ }>;
43
+ /**
44
+ * Advances time to the beginning of the given epoch
45
+ * @param epoch - The epoch to advance to
46
+ * @param opts - Options
47
+ */
48
+ advanceToEpoch(epoch: EpochNumber, opts?: {
49
+ /** Offset in seconds */
50
+ offset?: number;
51
+ }): Promise<bigint>;
52
+ /** Warps time in L1 until the next epoch */
53
+ advanceToNextEpoch(): Promise<void>;
54
+ /** Warps time in L1 until the beginning of the next slot. */
55
+ advanceToNextSlot(): Promise<(bigint | SlotNumber)[]>;
56
+ /**
57
+ * Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
58
+ * relative to the current L1 timestamp at call time and therefore races with real-time
59
+ * progression between query and warp, this lands at the slot regardless of latency.
60
+ *
61
+ * Throws if the requested slot is in the past relative to current L1 time (anvil cannot
62
+ * rewind).
63
+ */
64
+ advanceToSlot(slot: SlotNumber): Promise<bigint>;
65
+ /**
66
+ * Warps time in L1 equivalent to however many slots.
67
+ * @param howMany - The number of slots to advance.
68
+ */
69
+ advanceSlots(howMany: number): Promise<void>;
70
+ /**
71
+ * Marks the specified checkpoint (or latest if none) as proven
72
+ * @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
73
+ */
74
+ markAsProven(maybeCheckpointNumber?: CheckpointNumber): Promise<void>;
75
+ /**
76
+ * Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
77
+ * not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
78
+ */
79
+ waitForEpoch(epoch: EpochNumber, opts?: {
80
+ timeout?: number;
81
+ interval?: number;
82
+ }): Promise<void>;
83
+ /**
84
+ * Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
85
+ * warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
86
+ */
87
+ waitForSlot(slot: SlotNumber, opts?: {
88
+ timeout?: number;
89
+ interval?: number;
90
+ }): Promise<void>;
91
+ /**
92
+ * Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
93
+ * checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
94
+ * rather than a node, since a rollback lands on L1 first.
95
+ *
96
+ * A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
97
+ * replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
98
+ * empty state — hence the non-zero guard.
99
+ */
100
+ waitForCheckpointBelow(checkpoint: CheckpointNumber, opts?: {
101
+ timeout?: number;
102
+ interval?: number;
103
+ }): Promise<CheckpointNumber>;
104
+ insertOutbox(epoch: EpochNumber, numCheckpointsInEpoch: number, outHash: bigint): Promise<void>;
105
+ /**
106
+ * Executes an action impersonated as the owner of the Rollup contract.
107
+ * @param action - The action to execute
108
+ */
109
+ asOwner(action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>) => Promise<void>): Promise<void>;
110
+ /**
111
+ * Sets up the epoch.
112
+ */
113
+ setupEpoch(): Promise<void>;
114
+ /** Directly calls the L1 gas fee oracle. */
115
+ updateL1GasFeeOracle(): Promise<void>;
116
+ /**
117
+ * Bumps proving cost per mana.
118
+ * @param bumper - Callback to calculate the new proving cost per mana based on current value.
119
+ */
120
+ bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
121
+ /**
122
+ * Directly updates proving cost per mana. Throws if the on-chain tx reverts
123
+ * (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
124
+ * @param ethValue - The new proving cost per mana in ETH
125
+ */
126
+ setProvingCostPerMana(ethValue: bigint): Promise<void>;
127
+ /**
128
+ * Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
129
+ * by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
130
+ * successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
131
+ * land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
132
+ *
133
+ * @note This is tightly coupled to the `FeeStore` layout in
134
+ * l1-contracts/src/core/libraries/rollup/FeeLib.sol:
135
+ * slot + 0: CompressedFeeConfig config (uint256)
136
+ * slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
137
+ * slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
138
+ * If the struct layout changes, update the offset below.
139
+ */
140
+ clearProvingCostCooldown(): Promise<void>;
141
+ }
142
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwX2NoZWF0X2NvZGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiw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pC;CACF"}
@@ -0,0 +1,338 @@
1
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
2
+ import { OutboxContract, RollupContract } from '@aztec-labs/ethereum/contracts';
3
+ import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec-labs/foundation/branded-types';
4
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
5
+ import { createLogger } from '@aztec-labs/foundation/log';
6
+ import { retryUntil } from '@aztec-labs/foundation/retry';
7
+ import { createPublicClient, fallback, getContract, hexToBigInt, http, keccak256 } from 'viem';
8
+ import { EthCheatCodes } from './eth_cheat_codes.js';
9
+ /** Cheat codes for the L1 rollup contract. */ export class RollupCheatCodes {
10
+ ethCheatCodes;
11
+ client;
12
+ rollup;
13
+ logger;
14
+ constructor(ethCheatCodes, addresses){
15
+ this.ethCheatCodes = ethCheatCodes;
16
+ this.logger = createLogger('aztecjs:cheat_codes');
17
+ this.client = createPublicClient({
18
+ chain: ethCheatCodes.chain,
19
+ transport: fallback(ethCheatCodes.rpcUrls.map((url)=>http(url, {
20
+ batch: false
21
+ })))
22
+ });
23
+ this.rollup = getContract({
24
+ abi: RollupAbi,
25
+ address: addresses.rollupAddress.toString(),
26
+ client: this.client
27
+ });
28
+ }
29
+ static create(rpcUrls, addresses, dateProvider) {
30
+ const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
31
+ return new RollupCheatCodes(ethCheatCodes, addresses);
32
+ }
33
+ /** Returns the current slot */ async getSlot() {
34
+ const ts = BigInt((await this.client.getBlock()).timestamp);
35
+ return this.getSlotAt(ts);
36
+ }
37
+ /** Returns the slot number at a given timestamp. */ async getSlotAt(timestamp) {
38
+ return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
39
+ timestamp
40
+ ]));
41
+ }
42
+ /** Returns the timestamp for the start of a given slot. */ async getTimestampForSlot(slot) {
43
+ return await this.rollup.read.getTimestampForSlot([
44
+ BigInt(slot)
45
+ ]);
46
+ }
47
+ /** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */ async getSecondsUntilSlot(slot) {
48
+ const [currentTimestamp, targetTimestamp] = await Promise.all([
49
+ this.client.getBlock().then((b)=>BigInt(b.timestamp)),
50
+ this.rollup.read.getTimestampForSlot([
51
+ BigInt(slot)
52
+ ])
53
+ ]);
54
+ return Math.max(0, Number(targetTimestamp - currentTimestamp));
55
+ }
56
+ /** Returns the current epoch */ async getEpoch() {
57
+ const slotNumber = await this.getSlot();
58
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
59
+ BigInt(slotNumber)
60
+ ]));
61
+ }
62
+ /**
63
+ * Returns the pending and proven chain tips
64
+ * @returns The pending and proven chain tips
65
+ */ async getTips() {
66
+ const { pending, proven } = await this.rollup.read.getTips();
67
+ return {
68
+ pending: CheckpointNumber.fromBigInt(pending),
69
+ proven: CheckpointNumber.fromBigInt(proven)
70
+ };
71
+ }
72
+ /**
73
+ * Logs the current state of the rollup contract.
74
+ */ async debugRollup() {
75
+ const rollup = new RollupContract(this.client, this.rollup.address);
76
+ const pendingNum = await rollup.getCheckpointNumber();
77
+ const provenNum = await rollup.getProvenCheckpointNumber();
78
+ const validators = await rollup.getAttesters();
79
+ const committee = await rollup.getCurrentEpochCommittee();
80
+ const archive = await rollup.archive();
81
+ const slot = await this.getSlot();
82
+ const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
83
+ this.logger.info(`Pending checkpoint num: ${pendingNum}`);
84
+ this.logger.info(`Proven checkpoint num: ${provenNum}`);
85
+ this.logger.info(`Validators: ${validators.map((v)=>v.toString()).join(', ')}`);
86
+ this.logger.info(`Committee: ${committee?.map((v)=>v.toString()).join(', ')}`);
87
+ this.logger.info(`Archive: ${archive}`);
88
+ this.logger.info(`Epoch num: ${epochNum}`);
89
+ this.logger.info(`Slot: ${slot}`);
90
+ }
91
+ /** Fetches the epoch and slot duration config from the rollup contract */ async getConfig() {
92
+ const [epochDuration, slotDuration] = await Promise.all([
93
+ this.rollup.read.getEpochDuration(),
94
+ this.rollup.read.getSlotDuration()
95
+ ]);
96
+ return {
97
+ epochDuration,
98
+ slotDuration: Number(slotDuration)
99
+ };
100
+ }
101
+ /**
102
+ * Advances time to the beginning of the given epoch
103
+ * @param epoch - The epoch to advance to
104
+ * @param opts - Options
105
+ */ async advanceToEpoch(epoch, opts = {}) {
106
+ const { epochDuration: slotsInEpoch } = await this.getConfig();
107
+ const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
108
+ const timestamp = await this.rollup.read.getTimestampForSlot([
109
+ BigInt(slotNumber)
110
+ ]) + BigInt(opts.offset ?? 0);
111
+ try {
112
+ await this.ethCheatCodes.warp(Number(timestamp), {
113
+ ...opts,
114
+ silent: true,
115
+ resetBlockInterval: true
116
+ });
117
+ this.logger.warn(`Warped to epoch ${epoch}`, {
118
+ offset: opts.offset,
119
+ timestamp
120
+ });
121
+ } catch (err) {
122
+ this.logger.warn(`Warp to epoch ${epoch} failed: ${err}`);
123
+ }
124
+ return timestamp;
125
+ }
126
+ /** Warps time in L1 until the next epoch */ async advanceToNextEpoch() {
127
+ const slot = await this.getSlot();
128
+ const { epochDuration, slotDuration } = await this.getConfig();
129
+ const slotsUntilNextEpoch = epochDuration - BigInt(slot) % epochDuration + 1n;
130
+ const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
131
+ const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
132
+ await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
133
+ silent: true,
134
+ resetBlockInterval: true
135
+ });
136
+ this.logger.warn(`Advanced to next epoch`);
137
+ }
138
+ /** Warps time in L1 until the beginning of the next slot. */ async advanceToNextSlot() {
139
+ const currentSlot = await this.getSlot();
140
+ const nextSlot = SlotNumber(currentSlot + 1);
141
+ const timestamp = await this.rollup.read.getTimestampForSlot([
142
+ BigInt(nextSlot)
143
+ ]);
144
+ await this.ethCheatCodes.warp(Number(timestamp), {
145
+ silent: true,
146
+ resetBlockInterval: true
147
+ });
148
+ this.logger.warn(`Advanced to slot ${nextSlot}`);
149
+ return [
150
+ timestamp,
151
+ nextSlot
152
+ ];
153
+ }
154
+ /**
155
+ * Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
156
+ * relative to the current L1 timestamp at call time and therefore races with real-time
157
+ * progression between query and warp, this lands at the slot regardless of latency.
158
+ *
159
+ * Throws if the requested slot is in the past relative to current L1 time (anvil cannot
160
+ * rewind).
161
+ */ async advanceToSlot(slot) {
162
+ const timestamp = await this.rollup.read.getTimestampForSlot([
163
+ BigInt(slot)
164
+ ]);
165
+ await this.ethCheatCodes.warp(Number(timestamp), {
166
+ silent: true,
167
+ resetBlockInterval: true
168
+ });
169
+ this.logger.warn(`Advanced to slot ${slot}`, {
170
+ timestamp
171
+ });
172
+ return timestamp;
173
+ }
174
+ /**
175
+ * Warps time in L1 equivalent to however many slots.
176
+ * @param howMany - The number of slots to advance.
177
+ */ async advanceSlots(howMany) {
178
+ const l1Timestamp = (await this.client.getBlock()).timestamp;
179
+ const slotDuration = Number(await this.rollup.read.getSlotDuration());
180
+ const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
181
+ await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, {
182
+ silent: true,
183
+ resetBlockInterval: true
184
+ });
185
+ const [slot, epoch] = await Promise.all([
186
+ this.getSlot(),
187
+ this.getEpoch()
188
+ ]);
189
+ this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
190
+ }
191
+ /**
192
+ * Marks the specified checkpoint (or latest if none) as proven
193
+ * @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
194
+ */ markAsProven(maybeCheckpointNumber) {
195
+ return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
196
+ const tipsBefore = await this.getTips();
197
+ const { pending, proven } = tipsBefore;
198
+ let checkpointNumber = maybeCheckpointNumber;
199
+ if (checkpointNumber === undefined || checkpointNumber > pending) {
200
+ checkpointNumber = pending;
201
+ }
202
+ if (checkpointNumber <= proven) {
203
+ this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
204
+ return;
205
+ }
206
+ // @note @LHerskind this is heavily dependent on the storage layout and size of values
207
+ // The rollupStore is a struct and if the size of elements or the struct changes, this can break
208
+ const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
209
+ // Need to pack it as a single 32 byte word
210
+ const newValue = BigInt(tipsBefore.pending) << 128n | BigInt(checkpointNumber);
211
+ await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenCheckpointNumberSlot, newValue);
212
+ const tipsAfter = await this.getTips();
213
+ if (tipsAfter.pending < tipsAfter.proven) {
214
+ throw new Error('Overwrote pending tip to a checkpoint in the past');
215
+ }
216
+ this.logger.info(`Proven tip moved: ${tipsBefore.proven} -> ${tipsAfter.proven}. Pending tip: ${tipsAfter.pending}.`);
217
+ });
218
+ }
219
+ /**
220
+ * Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
221
+ * not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
222
+ */ async waitForEpoch(epoch, opts = {}) {
223
+ await retryUntil(async ()=>await this.getEpoch() >= epoch || undefined, `rollup epoch >= ${epoch}`, opts.timeout ?? 60, opts.interval ?? 1);
224
+ }
225
+ /**
226
+ * Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
227
+ * warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
228
+ */ async waitForSlot(slot, opts = {}) {
229
+ await retryUntil(async ()=>await this.getSlot() >= slot || undefined, `rollup slot >= ${slot}`, opts.timeout ?? 60, opts.interval ?? 1);
230
+ }
231
+ /**
232
+ * Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
233
+ * checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
234
+ * rather than a node, since a rollback lands on L1 first.
235
+ *
236
+ * A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
237
+ * replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
238
+ * empty state — hence the non-zero guard.
239
+ */ async waitForCheckpointBelow(checkpoint, opts = {}) {
240
+ return await retryUntil(async ()=>{
241
+ const { pending } = await this.getTips();
242
+ return pending > 0 && pending < checkpoint ? pending : undefined;
243
+ }, `rollup checkpoint in (0, ${checkpoint})`, opts.timeout ?? 60, opts.interval ?? 1);
244
+ }
245
+ insertOutbox(epoch, numCheckpointsInEpoch, outHash) {
246
+ return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
247
+ const outboxAddress = await this.rollup.read.getOutbox();
248
+ const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch, numCheckpointsInEpoch);
249
+ await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
250
+ this.logger.warn(`Advanced outbox to epoch ${epoch} numCheckpointsInEpoch ${numCheckpointsInEpoch} with out hash ${outHash}`);
251
+ });
252
+ }
253
+ /**
254
+ * Executes an action impersonated as the owner of the Rollup contract.
255
+ * @param action - The action to execute
256
+ */ async asOwner(action) {
257
+ const owner = await this.rollup.read.owner();
258
+ await this.ethCheatCodes.startImpersonating(owner);
259
+ await action(owner, this.rollup);
260
+ await this.ethCheatCodes.stopImpersonating(owner);
261
+ }
262
+ /**
263
+ * Sets up the epoch.
264
+ */ async setupEpoch() {
265
+ // Doesn't need to be done as owner, but the functionality is here...
266
+ await this.asOwner(async (account, rollup)=>{
267
+ const hash = await rollup.write.setupEpoch({
268
+ account
269
+ });
270
+ await this.client.waitForTransactionReceipt({
271
+ hash
272
+ });
273
+ this.logger.warn(`Setup epoch`);
274
+ });
275
+ }
276
+ /** Directly calls the L1 gas fee oracle. */ async updateL1GasFeeOracle() {
277
+ await this.asOwner(async (account, rollup)=>{
278
+ const hash = await rollup.write.updateL1GasFeeOracle({
279
+ account,
280
+ chain: this.client.chain
281
+ });
282
+ await this.client.waitForTransactionReceipt({
283
+ hash
284
+ });
285
+ this.logger.warn(`Updated L1 gas fee oracle`);
286
+ });
287
+ }
288
+ /**
289
+ * Bumps proving cost per mana.
290
+ * @param bumper - Callback to calculate the new proving cost per mana based on current value.
291
+ */ async bumpProvingCostPerMana(bumper) {
292
+ const currentCost = await this.rollup.read.getProvingCostPerManaInEth();
293
+ const newCost = bumper(currentCost);
294
+ await this.setProvingCostPerMana(newCost);
295
+ }
296
+ /**
297
+ * Directly updates proving cost per mana. Throws if the on-chain tx reverts
298
+ * (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
299
+ * @param ethValue - The new proving cost per mana in ETH
300
+ */ async setProvingCostPerMana(ethValue) {
301
+ await this.asOwner(async (account, rollup)=>{
302
+ const hash = await rollup.write.setProvingCostPerMana([
303
+ ethValue
304
+ ], {
305
+ account,
306
+ chain: this.client.chain,
307
+ gasLimit: 1000000n
308
+ });
309
+ const receipt = await this.client.waitForTransactionReceipt({
310
+ hash
311
+ });
312
+ if (receipt.status !== 'success') {
313
+ throw new Error(`setProvingCostPerMana(${ethValue}) reverted on L1 (tx ${hash}). ` + `Likely FeeLib rate-limit (30-day cooldown or 1.5x step cap); ` + `use clearProvingCostCooldown() between successive updates.`);
314
+ }
315
+ this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
316
+ });
317
+ }
318
+ /**
319
+ * Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
320
+ * by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
321
+ * successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
322
+ * land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
323
+ *
324
+ * @note This is tightly coupled to the `FeeStore` layout in
325
+ * l1-contracts/src/core/libraries/rollup/FeeLib.sol:
326
+ * slot + 0: CompressedFeeConfig config (uint256)
327
+ * slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
328
+ * slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
329
+ * If the struct layout changes, update the offset below.
330
+ */ async clearProvingCostCooldown() {
331
+ const feeStoreBaseSlot = hexToBigInt(keccak256(Buffer.from('aztec.fee.storage', 'utf-8')));
332
+ const provingCostLastUpdateSlot = feeStoreBaseSlot + 2n;
333
+ await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provingCostLastUpdateSlot, 0n, {
334
+ silent: true
335
+ });
336
+ this.logger.warn(`Cleared proving-cost update cooldown`);
337
+ }
338
+ }
@@ -0,0 +1,40 @@
1
+ import type { TestDateProvider } from '@aztec-labs/foundation/timer';
2
+ /** Minimal interface matching the @viem/anvil Anvil shape used by callers. */
3
+ export interface Anvil {
4
+ readonly port: number;
5
+ readonly host: string;
6
+ readonly status: 'listening' | 'idle';
7
+ stop(): Promise<void>;
8
+ }
9
+ /**
10
+ * Ensures there's a running Anvil instance and returns the RPC URL.
11
+ */
12
+ export declare function startAnvil(opts?: {
13
+ port?: number;
14
+ l1BlockTime?: number;
15
+ log?: boolean;
16
+ captureMethodCalls?: boolean;
17
+ accounts?: number;
18
+ chainId?: number;
19
+ /** The hardfork to use (e.g. 'cancun', 'latest'). */
20
+ hardfork?: string;
21
+ /**
22
+ * Number of slots per epoch used by anvil to compute the 'finalized' and 'safe' block tags.
23
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
24
+ * Defaults to 1 so the finalized block advances immediately, making tests that check
25
+ * L1-finality-based logic work without needing hundreds of mined blocks.
26
+ */
27
+ slotsInAnEpoch?: number;
28
+ /**
29
+ * If provided, the date provider will be synced to anvil's block time on every mined block.
30
+ * This keeps the dateProvider in lockstep with anvil's chain time, avoiding drift between
31
+ * the wall clock and the L1 chain when computing L1 slot timestamps.
32
+ */
33
+ dateProvider?: TestDateProvider;
34
+ }): Promise<{
35
+ anvil: Anvil;
36
+ methodCalls?: string[];
37
+ rpcUrl: string;
38
+ stop: () => Promise<void>;
39
+ }>;
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYW52aWwuZC50cyIsInNvdXJjZVJvb3Q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