@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.001888fc

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 (289) hide show
  1. package/dest/account.d.ts +2 -0
  2. package/dest/account.d.ts.map +1 -0
  3. package/dest/account.js +4 -0
  4. package/dest/chain.d.ts +1 -1
  5. package/dest/client.d.ts +14 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +27 -3
  8. package/dest/config.d.ts +70 -23
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +155 -34
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +27 -8
  13. package/dest/contracts/empire_base.d.ts.map +1 -1
  14. package/dest/contracts/empire_base.js +75 -2
  15. package/dest/contracts/empire_slashing_proposer.d.ts +69 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +216 -0
  18. package/dest/contracts/errors.d.ts +7 -0
  19. package/dest/contracts/errors.d.ts.map +1 -0
  20. package/dest/contracts/errors.js +12 -0
  21. package/dest/contracts/fee_asset_handler.d.ts +20 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +59 -0
  24. package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
  25. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  26. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  27. package/dest/contracts/fee_juice.d.ts +6 -7
  28. package/dest/contracts/fee_juice.d.ts.map +1 -1
  29. package/dest/contracts/fee_juice.js +27 -20
  30. package/dest/contracts/governance.d.ts +45 -32
  31. package/dest/contracts/governance.d.ts.map +1 -1
  32. package/dest/contracts/governance.js +98 -85
  33. package/dest/contracts/governance_proposer.d.ts +19 -13
  34. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  35. package/dest/contracts/governance_proposer.js +441 -26
  36. package/dest/contracts/gse.d.ts +32 -0
  37. package/dest/contracts/gse.d.ts.map +1 -0
  38. package/dest/contracts/gse.js +72 -0
  39. package/dest/contracts/inbox.d.ts +47 -0
  40. package/dest/contracts/inbox.d.ts.map +1 -0
  41. package/dest/contracts/inbox.js +80 -0
  42. package/dest/contracts/index.d.ts +12 -3
  43. package/dest/contracts/index.d.ts.map +1 -1
  44. package/dest/contracts/index.js +11 -2
  45. package/dest/contracts/log.d.ts +13 -0
  46. package/dest/contracts/log.d.ts.map +1 -0
  47. package/dest/contracts/log.js +1 -0
  48. package/dest/contracts/multicall.d.ts +21 -0
  49. package/dest/contracts/multicall.d.ts.map +1 -0
  50. package/dest/contracts/multicall.js +157 -0
  51. package/dest/contracts/outbox.d.ts +41 -0
  52. package/dest/contracts/outbox.d.ts.map +1 -0
  53. package/dest/contracts/outbox.js +86 -0
  54. package/dest/contracts/registry.d.ts +12 -5
  55. package/dest/contracts/registry.d.ts.map +1 -1
  56. package/dest/contracts/registry.js +74 -17
  57. package/dest/contracts/rollup.d.ts +311 -53
  58. package/dest/contracts/rollup.d.ts.map +1 -1
  59. package/dest/contracts/rollup.js +1180 -116
  60. package/dest/contracts/slasher_contract.d.ts +44 -0
  61. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  62. package/dest/contracts/slasher_contract.js +75 -0
  63. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  64. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  65. package/dest/contracts/tally_slashing_proposer.js +320 -0
  66. package/dest/contracts/utils.d.ts +3 -0
  67. package/dest/contracts/utils.d.ts.map +1 -0
  68. package/dest/contracts/utils.js +11 -0
  69. package/dest/deploy_aztec_l1_contracts.d.ts +259 -0
  70. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  71. package/dest/deploy_aztec_l1_contracts.js +413 -0
  72. package/dest/deploy_l1_contract.d.ts +68 -0
  73. package/dest/deploy_l1_contract.d.ts.map +1 -0
  74. package/dest/deploy_l1_contract.js +312 -0
  75. package/dest/eth-signer/eth-signer.d.ts +21 -0
  76. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  77. package/dest/eth-signer/eth-signer.js +5 -0
  78. package/dest/eth-signer/index.d.ts +2 -0
  79. package/dest/eth-signer/index.d.ts.map +1 -0
  80. package/dest/eth-signer/index.js +1 -0
  81. package/dest/forwarder_proxy.d.ts +32 -0
  82. package/dest/forwarder_proxy.d.ts.map +1 -0
  83. package/dest/forwarder_proxy.js +93 -0
  84. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  85. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  86. package/dest/generated/l1-contracts-defaults.js +30 -0
  87. package/dest/l1_artifacts.d.ts +81744 -0
  88. package/dest/l1_artifacts.d.ts.map +1 -0
  89. package/dest/l1_artifacts.js +166 -0
  90. package/dest/l1_contract_addresses.d.ts +24 -4
  91. package/dest/l1_contract_addresses.d.ts.map +1 -1
  92. package/dest/l1_contract_addresses.js +25 -21
  93. package/dest/l1_reader.d.ts +6 -2
  94. package/dest/l1_reader.d.ts.map +1 -1
  95. package/dest/l1_reader.js +20 -9
  96. package/dest/l1_tx_utils/config.d.ts +65 -0
  97. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/config.js +109 -0
  99. package/dest/l1_tx_utils/constants.d.ts +12 -0
  100. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/constants.js +39 -0
  102. package/dest/l1_tx_utils/factory.d.ts +32 -0
  103. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/factory.js +22 -0
  105. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  106. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  108. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  109. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  111. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  112. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  114. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  115. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  117. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  118. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
  120. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  121. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/index-blobs.js +2 -0
  123. package/dest/l1_tx_utils/index.d.ts +13 -0
  124. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/index.js +13 -0
  126. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  127. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/interfaces.js +4 -0
  129. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  130. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  132. package/dest/l1_tx_utils/l1_tx_utils.d.ts +105 -0
  133. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/l1_tx_utils.js +639 -0
  135. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
  136. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  137. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +327 -0
  138. package/dest/l1_tx_utils/signer.d.ts +4 -0
  139. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  140. package/dest/l1_tx_utils/signer.js +16 -0
  141. package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
  142. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  143. package/dest/l1_tx_utils/tx_delayer.js +221 -0
  144. package/dest/l1_tx_utils/types.d.ts +67 -0
  145. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  146. package/dest/l1_tx_utils/types.js +26 -0
  147. package/dest/l1_tx_utils/utils.d.ts +4 -0
  148. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  149. package/dest/l1_tx_utils/utils.js +14 -0
  150. package/dest/l1_types.d.ts +6 -0
  151. package/dest/l1_types.d.ts.map +1 -0
  152. package/dest/l1_types.js +1 -0
  153. package/dest/publisher_manager.d.ts +16 -0
  154. package/dest/publisher_manager.d.ts.map +1 -0
  155. package/dest/publisher_manager.js +88 -0
  156. package/dest/queries.d.ts +5 -3
  157. package/dest/queries.d.ts.map +1 -1
  158. package/dest/queries.js +61 -12
  159. package/dest/test/chain_monitor.d.ts +94 -0
  160. package/dest/test/chain_monitor.d.ts.map +1 -0
  161. package/dest/test/chain_monitor.js +244 -0
  162. package/dest/test/eth_cheat_codes.d.ts +229 -0
  163. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  164. package/dest/test/eth_cheat_codes.js +560 -0
  165. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  166. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  167. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  168. package/dest/test/index.d.ts +4 -3
  169. package/dest/test/index.d.ts.map +1 -1
  170. package/dest/test/index.js +3 -2
  171. package/dest/test/rollup_cheat_codes.d.ts +90 -0
  172. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  173. package/dest/test/rollup_cheat_codes.js +292 -0
  174. package/dest/test/start_anvil.d.ts +23 -2
  175. package/dest/test/start_anvil.d.ts.map +1 -1
  176. package/dest/test/start_anvil.js +133 -24
  177. package/dest/test/upgrade_utils.d.ts +6 -5
  178. package/dest/test/upgrade_utils.d.ts.map +1 -1
  179. package/dest/test/upgrade_utils.js +23 -16
  180. package/dest/types.d.ts +62 -8
  181. package/dest/types.d.ts.map +1 -1
  182. package/dest/types.js +3 -1
  183. package/dest/utils.d.ts +17 -3
  184. package/dest/utils.d.ts.map +1 -1
  185. package/dest/utils.js +111 -88
  186. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  187. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  188. package/dest/zkPassportVerifierAddress.js +11 -0
  189. package/package.json +51 -25
  190. package/src/account.ts +5 -0
  191. package/src/client.ts +51 -5
  192. package/src/config.ts +222 -43
  193. package/src/contracts/README.md +157 -0
  194. package/src/contracts/empire_base.ts +79 -7
  195. package/src/contracts/empire_slashing_proposer.ts +265 -0
  196. package/src/contracts/errors.ts +13 -0
  197. package/src/contracts/fee_asset_handler.ts +66 -0
  198. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  199. package/src/contracts/fee_juice.ts +29 -15
  200. package/src/contracts/governance.ts +90 -78
  201. package/src/contracts/governance_proposer.ts +81 -25
  202. package/src/contracts/gse.ts +88 -0
  203. package/src/contracts/inbox.ts +115 -0
  204. package/src/contracts/index.ts +11 -2
  205. package/src/contracts/log.ts +13 -0
  206. package/src/contracts/multicall.ts +158 -0
  207. package/src/contracts/outbox.ts +98 -0
  208. package/src/contracts/registry.ts +81 -26
  209. package/src/contracts/rollup.ts +940 -89
  210. package/src/contracts/slasher_contract.ts +89 -0
  211. package/src/contracts/tally_slashing_proposer.ts +322 -0
  212. package/src/contracts/utils.ts +14 -0
  213. package/src/deploy_aztec_l1_contracts.ts +650 -0
  214. package/src/deploy_l1_contract.ts +362 -0
  215. package/src/eth-signer/eth-signer.ts +25 -0
  216. package/src/eth-signer/index.ts +1 -0
  217. package/src/forwarder_proxy.ts +108 -0
  218. package/src/generated/l1-contracts-defaults.ts +32 -0
  219. package/src/l1_artifacts.ts +254 -0
  220. package/src/l1_contract_addresses.ts +49 -34
  221. package/src/l1_reader.ts +30 -10
  222. package/src/l1_tx_utils/README.md +177 -0
  223. package/src/l1_tx_utils/config.ts +181 -0
  224. package/src/l1_tx_utils/constants.ts +29 -0
  225. package/src/l1_tx_utils/factory.ts +64 -0
  226. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  227. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  228. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  229. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  230. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
  231. package/src/l1_tx_utils/index-blobs.ts +2 -0
  232. package/src/l1_tx_utils/index.ts +15 -0
  233. package/src/l1_tx_utils/interfaces.ts +86 -0
  234. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  235. package/src/l1_tx_utils/l1_tx_utils.ts +766 -0
  236. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +423 -0
  237. package/src/l1_tx_utils/signer.ts +28 -0
  238. package/src/l1_tx_utils/tx_delayer.ts +294 -0
  239. package/src/l1_tx_utils/types.ts +85 -0
  240. package/src/l1_tx_utils/utils.ts +16 -0
  241. package/src/l1_types.ts +6 -0
  242. package/src/publisher_manager.ts +108 -0
  243. package/src/queries.ts +82 -16
  244. package/src/test/chain_monitor.ts +302 -0
  245. package/src/test/eth_cheat_codes.ts +588 -0
  246. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  247. package/src/test/index.ts +3 -2
  248. package/src/test/rollup_cheat_codes.ts +330 -0
  249. package/src/test/start_anvil.ts +166 -22
  250. package/src/test/upgrade_utils.ts +30 -21
  251. package/src/types.ts +71 -7
  252. package/src/utils.ts +137 -93
  253. package/src/zkPassportVerifierAddress.ts +15 -0
  254. package/dest/contracts/forwarder.d.ts +0 -24
  255. package/dest/contracts/forwarder.d.ts.map +0 -1
  256. package/dest/contracts/forwarder.js +0 -101
  257. package/dest/contracts/slashing_proposer.d.ts +0 -21
  258. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  259. package/dest/contracts/slashing_proposer.js +0 -47
  260. package/dest/deploy_l1_contracts.d.ts +0 -21210
  261. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  262. package/dest/deploy_l1_contracts.js +0 -687
  263. package/dest/eth_cheat_codes.d.ts +0 -147
  264. package/dest/eth_cheat_codes.d.ts.map +0 -1
  265. package/dest/eth_cheat_codes.js +0 -303
  266. package/dest/index.d.ts +0 -14
  267. package/dest/index.d.ts.map +0 -1
  268. package/dest/index.js +0 -13
  269. package/dest/l1_tx_utils.d.ts +0 -192
  270. package/dest/l1_tx_utils.d.ts.map +0 -1
  271. package/dest/l1_tx_utils.js +0 -641
  272. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  273. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  274. package/dest/l1_tx_utils_with_blobs.js +0 -64
  275. package/dest/test/delayed_tx_utils.d.ts +0 -8
  276. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  277. package/dest/test/delayed_tx_utils.js +0 -21
  278. package/dest/test/tx_delayer.d.ts +0 -25
  279. package/dest/test/tx_delayer.d.ts.map +0 -1
  280. package/dest/test/tx_delayer.js +0 -116
  281. package/src/contracts/forwarder.ts +0 -132
  282. package/src/contracts/slashing_proposer.ts +0 -51
  283. package/src/deploy_l1_contracts.ts +0 -948
  284. package/src/eth_cheat_codes.ts +0 -314
  285. package/src/index.ts +0 -13
  286. package/src/l1_tx_utils.ts +0 -847
  287. package/src/l1_tx_utils_with_blobs.ts +0 -86
  288. package/src/test/delayed_tx_utils.ts +0 -24
  289. package/src/test/tx_delayer.ts +0 -163
@@ -1,64 +0,0 @@
1
- import { Blob } from '@aztec/blob-lib';
2
- import { formatGwei } from 'viem';
3
- import { L1TxUtils } from './l1_tx_utils.js';
4
- export class L1TxUtilsWithBlobs extends L1TxUtils {
5
- /**
6
- * Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
7
- * @param nonce - The nonce of the transaction to cancel
8
- * @param previousGasPrice - The gas price of the previous transaction
9
- * @param attempts - The number of attempts to cancel the transaction
10
- * @returns The hash of the cancellation transaction
11
- */ async attemptTxCancellation(nonce, isBlobTx = false, previousGasPrice, attempts = 0) {
12
- const account = this.walletClient.account;
13
- // Get gas price with higher priority fee for cancellation
14
- const cancelGasPrice = await this.getGasPrice({
15
- ...this.config,
16
- // Use high bump for cancellation to ensure it replaces the original tx
17
- priorityFeeRetryBumpPercentage: 150
18
- }, isBlobTx, attempts + 1, previousGasPrice);
19
- this.logger?.debug(`Attempting to cancel transaction with nonce ${nonce}`, {
20
- maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
21
- maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas)
22
- });
23
- const request = {
24
- to: account.address,
25
- value: 0n
26
- };
27
- // Send 0-value tx to self with higher gas price
28
- if (!isBlobTx) {
29
- const cancelTxHash = await this.walletClient.sendTransaction({
30
- ...request,
31
- nonce,
32
- gas: 21_000n,
33
- maxFeePerGas: cancelGasPrice.maxFeePerGas,
34
- maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas
35
- });
36
- const receipt = await this.monitorTransaction(request, cancelTxHash, {
37
- gasLimit: 21_000n
38
- }, undefined, undefined, true);
39
- return receipt.transactionHash;
40
- } else {
41
- const blobData = new Uint8Array(131072).fill(0);
42
- const kzg = Blob.getViemKzgInstance();
43
- const blobInputs = {
44
- blobs: [
45
- blobData
46
- ],
47
- kzg,
48
- maxFeePerBlobGas: cancelGasPrice.maxFeePerBlobGas
49
- };
50
- const cancelTxHash = await this.walletClient.sendTransaction({
51
- ...request,
52
- ...blobInputs,
53
- nonce,
54
- gas: 21_000n,
55
- maxFeePerGas: cancelGasPrice.maxFeePerGas,
56
- maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas
57
- });
58
- const receipt = await this.monitorTransaction(request, cancelTxHash, {
59
- gasLimit: 21_000n
60
- }, undefined, blobInputs, true);
61
- return receipt.transactionHash;
62
- }
63
- }
64
- }
@@ -1,8 +0,0 @@
1
- import { L1TxUtilsWithBlobs } from '../l1_tx_utils_with_blobs.js';
2
- import { type Delayer } from './tx_delayer.js';
3
- export declare class DelayedTxUtils extends L1TxUtilsWithBlobs {
4
- delayer: Delayer | undefined;
5
- static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number): DelayedTxUtils;
6
- enableDelayer(ethereumSlotDuration: number): void;
7
- }
8
- //# sourceMappingURL=delayed_tx_utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delayed_tx_utils.d.ts","sourceRoot":"","sources":["../../src/test/delayed_tx_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAE5D,qBAAa,cAAe,SAAQ,kBAAkB;IAC7C,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;WAEtB,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM;IAUhF,aAAa,CAAC,oBAAoB,EAAE,MAAM;CAOlD"}
@@ -1,21 +0,0 @@
1
- import { L1TxUtilsWithBlobs } from '../l1_tx_utils_with_blobs.js';
2
- import { withDelayer } from './tx_delayer.js';
3
- export class DelayedTxUtils extends L1TxUtilsWithBlobs {
4
- delayer;
5
- static fromL1TxUtils(l1TxUtils, ethereumSlotDuration) {
6
- const { client, delayer } = withDelayer(l1TxUtils.walletClient, {
7
- ethereumSlotDuration
8
- });
9
- const casted = l1TxUtils;
10
- casted.delayer = delayer;
11
- casted.walletClient = client;
12
- return casted;
13
- }
14
- enableDelayer(ethereumSlotDuration) {
15
- const { client, delayer } = withDelayer(this.walletClient, {
16
- ethereumSlotDuration
17
- });
18
- this.delayer = delayer;
19
- this.walletClient = client;
20
- }
21
- }
@@ -1,25 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import { type Client, type Hex } from 'viem';
3
- import type { ViemWalletClient } from '../types.js';
4
- export declare function waitUntilBlock<T extends Client>(client: T, blockNumber: number | bigint, logger?: Logger): Promise<boolean>;
5
- export declare function waitUntilL1Timestamp<T extends Client>(client: T, timestamp: number | bigint, logger?: Logger): Promise<boolean>;
6
- export interface Delayer {
7
- /** Returns the list of all txs (not just the delayed ones) sent through the attached client. */
8
- getTxs(): Hex[];
9
- /** Delays the next tx to be sent so it lands on the given L1 block number. */
10
- pauseNextTxUntilBlock(l1BlockNumber: number | bigint | undefined): void;
11
- /** Delays the next tx to be sent so it lands on the given timestamp. */
12
- pauseNextTxUntilTimestamp(l1Timestamp: number | bigint | undefined): void;
13
- }
14
- /**
15
- * Returns a new client (without modifying the one passed in) with an injected tx delayer.
16
- * The delayer can be used to hold off the next tx to be sent until a given block number.
17
- * TODO(#10824): This doesn't play along well with blob txs for some reason.
18
- */
19
- export declare function withDelayer<T extends ViemWalletClient>(client: T, opts: {
20
- ethereumSlotDuration: bigint | number;
21
- }): {
22
- client: T;
23
- delayer: Delayer;
24
- };
25
- //# sourceMappingURL=tx_delayer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tx_delayer.d.ts","sourceRoot":"","sources":["../../src/test/tx_delayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,GAAG,EAMT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,oBAgBxG;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,oBAuB5G;AAED,MAAM,WAAW,OAAO;IACtB,gGAAgG;IAChG,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,8EAA8E;IAC9E,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACxE,wEAAwE;IACxE,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC3E;AAwBD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,gBAAgB,EACpD,MAAM,EAAE,CAAC,EACT,IAAI,EAAE;IAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC9C;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA+DjC"}
@@ -1,116 +0,0 @@
1
- import { omit } from '@aztec/foundation/collection';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { retryUntil } from '@aztec/foundation/retry';
4
- import { inspect } from 'util';
5
- import { keccak256, parseTransaction, publicActions, walletActions } from 'viem';
6
- export function waitUntilBlock(client, blockNumber, logger) {
7
- const publicClient = 'getBlockNumber' in client && typeof client.getBlockNumber === 'function' ? client : client.extend(publicActions);
8
- return retryUntil(async ()=>{
9
- const currentBlockNumber = await publicClient.getBlockNumber({
10
- cacheTime: 0
11
- });
12
- logger?.debug(`Block number is ${currentBlockNumber} (waiting until ${blockNumber})`);
13
- return currentBlockNumber >= BigInt(blockNumber);
14
- }, `Wait until L1 block ${blockNumber}`, 120, 0.1);
15
- }
16
- export function waitUntilL1Timestamp(client, timestamp, logger) {
17
- const publicClient = 'getBlockNumber' in client && typeof client.getBlockNumber === 'function' ? client : client.extend(publicActions);
18
- let lastBlock = undefined;
19
- return retryUntil(async ()=>{
20
- const currentBlockNumber = await publicClient.getBlockNumber({
21
- cacheTime: 0
22
- });
23
- if (currentBlockNumber === lastBlock) {
24
- return false;
25
- }
26
- lastBlock = currentBlockNumber;
27
- const currentBlock = await publicClient.getBlock({
28
- includeTransactions: false,
29
- blockNumber: currentBlockNumber
30
- });
31
- const currentTs = currentBlock.timestamp;
32
- logger?.debug(`Block timstamp is ${currentTs} (waiting until ${timestamp})`);
33
- return currentTs >= BigInt(timestamp);
34
- }, `Wait until L1 timestamp ${timestamp}`, 120, 0.1);
35
- }
36
- class DelayerImpl {
37
- constructor(opts){
38
- this.ethereumSlotDuration = BigInt(opts.ethereumSlotDuration);
39
- }
40
- ethereumSlotDuration;
41
- nextWait = undefined;
42
- txs = [];
43
- getTxs() {
44
- return this.txs;
45
- }
46
- pauseNextTxUntilBlock(l1BlockNumber) {
47
- this.nextWait = {
48
- l1BlockNumber: BigInt(l1BlockNumber)
49
- };
50
- }
51
- pauseNextTxUntilTimestamp(l1Timestamp) {
52
- this.nextWait = {
53
- l1Timestamp: BigInt(l1Timestamp)
54
- };
55
- }
56
- }
57
- /**
58
- * Returns a new client (without modifying the one passed in) with an injected tx delayer.
59
- * The delayer can be used to hold off the next tx to be sent until a given block number.
60
- * TODO(#10824): This doesn't play along well with blob txs for some reason.
61
- */ export function withDelayer(client, opts) {
62
- const logger = createLogger('ethereum:tx_delayer');
63
- const delayer = new DelayerImpl(opts);
64
- const extended = client// Tweak sendRawTransaction so it uses the delay defined in the delayer.
65
- // Note that this will only work with local accounts (ie accounts for which we have the private key).
66
- // Transactions signed by the node will not be delayed since they use sendTransaction directly,
67
- // but we do not use them in our codebase at all.
68
- .extend((client)=>({
69
- async sendRawTransaction (...args) {
70
- if (delayer.nextWait !== undefined) {
71
- const waitUntil = delayer.nextWait;
72
- delayer.nextWait = undefined;
73
- const publicClient = client;
74
- const wait = 'l1BlockNumber' in waitUntil ? waitUntilBlock(publicClient, waitUntil.l1BlockNumber - 1n, logger) : waitUntilL1Timestamp(publicClient, waitUntil.l1Timestamp - delayer.ethereumSlotDuration, logger);
75
- // Compute the tx hash manually so we emulate sendRawTransaction response
76
- const { serializedTransaction } = args[0];
77
- const txHash = keccak256(serializedTransaction);
78
- logger.info(`Delaying tx ${txHash} until ${inspect(waitUntil)}`, {
79
- argsLen: args.length,
80
- ...omit(parseTransaction(serializedTransaction), 'data', 'sidecars')
81
- });
82
- // Do not await here so we can return the tx hash immediately as if it had been sent on the spot.
83
- // Instead, delay it so it lands on the desired block number or timestamp, assuming anvil will
84
- // mine it immediately.
85
- void wait.then(async ()=>{
86
- const clientTxHash = await client.sendRawTransaction(...args);
87
- if (clientTxHash !== txHash) {
88
- logger.error(`Tx hash returned by the client does not match computed one`, {
89
- clientTxHash,
90
- computedTxHash: txHash
91
- });
92
- }
93
- logger.info(`Sent previously delayed tx ${clientTxHash} to land on ${inspect(waitUntil)}`);
94
- delayer.txs.push(clientTxHash);
95
- }).catch((err)=>logger.error(`Error sending tx after delay`, err));
96
- return Promise.resolve(txHash);
97
- } else {
98
- const txHash = await client.sendRawTransaction(...args);
99
- logger.verbose(`Sent tx immediately ${txHash}`);
100
- delayer.txs.push(txHash);
101
- return txHash;
102
- }
103
- }
104
- }))// Re-extend with sendTransaction so it uses the modified sendRawTransaction.
105
- .extend((client)=>({
106
- sendTransaction: walletActions(client).sendTransaction
107
- }))// And with the actions that depend on the modified sendTransaction
108
- .extend((client)=>({
109
- writeContract: walletActions(client).writeContract,
110
- deployContract: walletActions(client).deployContract
111
- }));
112
- return {
113
- client: extended,
114
- delayer
115
- };
116
- }
@@ -1,132 +0,0 @@
1
- import { toHex } from '@aztec/foundation/bigint-buffer';
2
- import type { Logger } from '@aztec/foundation/log';
3
- import { ForwarderAbi, ForwarderBytecode } from '@aztec/l1-artifacts';
4
-
5
- import {
6
- type EncodeFunctionDataParameters,
7
- type GetContractReturnType,
8
- type Hex,
9
- encodeFunctionData,
10
- getContract,
11
- } from 'viem';
12
-
13
- import { deployL1Contract } from '../deploy_l1_contracts.js';
14
- import type { L1BlobInputs, L1GasConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
15
- import type { L1Clients, ViemPublicClient, ViemWalletClient } from '../types.js';
16
- import { RollupContract } from './rollup.js';
17
-
18
- export class ForwarderContract {
19
- private readonly forwarder: GetContractReturnType<typeof ForwarderAbi, ViemPublicClient>;
20
-
21
- constructor(public readonly client: L1Clients['publicClient'], address: Hex, public readonly rollupAddress: Hex) {
22
- this.forwarder = getContract({ address, abi: ForwarderAbi, client });
23
- }
24
-
25
- static async create(
26
- owner: Hex,
27
- walletClient: ViemWalletClient,
28
- publicClient: ViemPublicClient,
29
- logger: Logger,
30
- rollupAddress: Hex,
31
- ) {
32
- logger.info('Deploying forwarder contract');
33
-
34
- const { address, txHash } = await deployL1Contract(
35
- walletClient,
36
- publicClient,
37
- ForwarderAbi,
38
- ForwarderBytecode,
39
- [owner],
40
- owner,
41
- undefined,
42
- logger,
43
- );
44
-
45
- if (txHash) {
46
- await publicClient.waitForTransactionReceipt({ hash: txHash });
47
- }
48
-
49
- logger.info(`Forwarder contract deployed at ${address} with owner ${owner}`);
50
-
51
- return new ForwarderContract(publicClient, address.toString(), rollupAddress);
52
- }
53
-
54
- public getAddress() {
55
- return this.forwarder.address;
56
- }
57
-
58
- public async forward(
59
- requests: L1TxRequest[],
60
- l1TxUtils: L1TxUtils,
61
- gasConfig: L1GasConfig | undefined,
62
- blobConfig: L1BlobInputs | undefined,
63
- logger: Logger,
64
- ) {
65
- requests = requests.filter(request => request.to !== null);
66
- const toArgs = requests.map(request => request.to!);
67
- const dataArgs = requests.map(request => request.data!);
68
- const forwarderFunctionData: EncodeFunctionDataParameters<typeof ForwarderAbi, 'forward'> = {
69
- abi: ForwarderAbi,
70
- functionName: 'forward',
71
- args: [toArgs, dataArgs],
72
- };
73
- const encodedForwarderData = encodeFunctionData(forwarderFunctionData);
74
-
75
- const { receipt, gasPrice } = await l1TxUtils.sendAndMonitorTransaction(
76
- {
77
- to: this.forwarder.address,
78
- data: encodedForwarderData,
79
- },
80
- gasConfig,
81
- blobConfig,
82
- );
83
-
84
- if (receipt.status === 'success') {
85
- const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
86
- return { receipt, gasPrice, stats };
87
- } else {
88
- logger.error('Forwarder transaction failed', undefined, { receipt });
89
-
90
- const args = {
91
- ...forwarderFunctionData,
92
- address: this.forwarder.address,
93
- };
94
-
95
- let errorMsg: string | undefined;
96
-
97
- if (blobConfig) {
98
- const maxFeePerBlobGas = blobConfig.maxFeePerBlobGas ?? gasPrice.maxFeePerBlobGas;
99
- if (maxFeePerBlobGas === undefined) {
100
- errorMsg = 'maxFeePerBlobGas is required to get the error message';
101
- } else {
102
- logger.debug('Trying to get error from reverted tx with blob config');
103
- errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(
104
- encodedForwarderData,
105
- args,
106
- {
107
- blobs: blobConfig.blobs,
108
- kzg: blobConfig.kzg,
109
- maxFeePerBlobGas,
110
- },
111
- [
112
- {
113
- address: this.rollupAddress,
114
- stateDiff: [
115
- {
116
- slot: toHex(RollupContract.checkBlobStorageSlot, true),
117
- value: toHex(0n, true),
118
- },
119
- ],
120
- },
121
- ],
122
- );
123
- }
124
- } else {
125
- logger.debug('Trying to get error from reverted tx without blob config');
126
- errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedForwarderData, args, undefined, []);
127
- }
128
-
129
- return { receipt, gasPrice, errorMsg };
130
- }
131
- }
132
- }
@@ -1,51 +0,0 @@
1
- import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { SlashingProposerAbi } from '@aztec/l1-artifacts';
3
-
4
- import { type GetContractReturnType, type Hex, getContract } from 'viem';
5
-
6
- import type { L1TxRequest } from '../l1_tx_utils.js';
7
- import type { ViemPublicClient } from '../types.js';
8
- import { type IEmpireBase, encodeVote } from './empire_base.js';
9
-
10
- export class SlashingProposerContract implements IEmpireBase {
11
- private readonly proposer: GetContractReturnType<typeof SlashingProposerAbi, ViemPublicClient>;
12
-
13
- constructor(public readonly client: ViemPublicClient, address: Hex) {
14
- this.proposer = getContract({ address, abi: SlashingProposerAbi, client });
15
- }
16
-
17
- public get address() {
18
- return EthAddress.fromString(this.proposer.address);
19
- }
20
-
21
- public getQuorumSize() {
22
- return this.proposer.read.N();
23
- }
24
-
25
- public getRoundSize() {
26
- return this.proposer.read.M();
27
- }
28
-
29
- public computeRound(slot: bigint): Promise<bigint> {
30
- return this.proposer.read.computeRound([slot]);
31
- }
32
-
33
- public async getRoundInfo(
34
- rollupAddress: Hex,
35
- round: bigint,
36
- ): Promise<{ lastVote: bigint; leader: Hex; executed: boolean }> {
37
- const roundInfo = await this.proposer.read.rounds([rollupAddress, round]);
38
- return {
39
- lastVote: roundInfo[0],
40
- leader: roundInfo[1],
41
- executed: roundInfo[2],
42
- };
43
- }
44
-
45
- public createVoteRequest(payload: Hex): L1TxRequest {
46
- return {
47
- to: this.address.toString(),
48
- data: encodeVote(payload),
49
- };
50
- }
51
- }