@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.017a351

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 (285) 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 +28 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +73 -3
  8. package/dest/config.d.ts +70 -23
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +151 -34
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/chain_state_override.d.ts +78 -0
  13. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  14. package/dest/contracts/chain_state_override.js +137 -0
  15. package/dest/contracts/empire_base.d.ts +25 -8
  16. package/dest/contracts/empire_base.d.ts.map +1 -1
  17. package/dest/contracts/empire_base.js +75 -2
  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 +105 -0
  25. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  26. package/dest/contracts/fee_asset_price_oracle.js +656 -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 +131 -43
  31. package/dest/contracts/governance.d.ts.map +1 -1
  32. package/dest/contracts/governance.js +281 -87
  33. package/dest/contracts/governance_proposer.d.ts +49 -13
  34. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  35. package/dest/contracts/governance_proposer.js +483 -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 +85 -0
  42. package/dest/contracts/index.d.ts +11 -2
  43. package/dest/contracts/index.d.ts.map +1 -1
  44. package/dest/contracts/index.js +10 -1
  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 +136 -0
  49. package/dest/contracts/multicall.d.ts.map +1 -0
  50. package/dest/contracts/multicall.js +264 -0
  51. package/dest/contracts/outbox.d.ts +64 -0
  52. package/dest/contracts/outbox.d.ts.map +1 -0
  53. package/dest/contracts/outbox.js +113 -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 +5526 -52
  58. package/dest/contracts/rollup.d.ts.map +1 -1
  59. package/dest/contracts/rollup.js +1446 -118
  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/slashing_proposer.d.ts +133 -15
  64. package/dest/contracts/slashing_proposer.d.ts.map +1 -1
  65. package/dest/contracts/slashing_proposer.js +293 -22
  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 +256 -0
  70. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  71. package/dest/deploy_aztec_l1_contracts.js +411 -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 +79270 -0
  88. package/dest/l1_artifacts.d.ts.map +1 -0
  89. package/dest/l1_artifacts.js +151 -0
  90. package/dest/l1_contract_addresses.d.ts +61 -45
  91. package/dest/l1_contract_addresses.d.ts.map +1 -1
  92. package/dest/l1_contract_addresses.js +99 -76
  93. package/dest/l1_reader.d.ts +8 -6
  94. package/dest/l1_reader.d.ts.map +1 -1
  95. package/dest/l1_reader.js +20 -12
  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 +113 -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 +658 -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 +328 -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 +58 -0
  142. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  143. package/dest/l1_tx_utils/tx_delayer.js +223 -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 +30 -0
  154. package/dest/publisher_manager.d.ts.map +1 -0
  155. package/dest/publisher_manager.js +162 -0
  156. package/dest/queries.d.ts +17 -4
  157. package/dest/queries.d.ts.map +1 -1
  158. package/dest/queries.js +120 -12
  159. package/dest/test/chain_monitor.d.ts +95 -0
  160. package/dest/test/chain_monitor.d.ts.map +1 -0
  161. package/dest/test/chain_monitor.js +249 -0
  162. package/dest/test/eth_cheat_codes.d.ts +237 -0
  163. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  164. package/dest/test/eth_cheat_codes.js +573 -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 +118 -0
  172. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  173. package/dest/test/rollup_cheat_codes.js +344 -0
  174. package/dest/test/start_anvil.d.ts +30 -2
  175. package/dest/test/start_anvil.d.ts.map +1 -1
  176. package/dest/test/start_anvil.js +147 -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 +25 -4
  184. package/dest/utils.d.ts.map +1 -1
  185. package/dest/utils.js +142 -91
  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 +52 -26
  190. package/src/account.ts +5 -0
  191. package/src/client.ts +107 -5
  192. package/src/config.ts +218 -43
  193. package/src/contracts/README.md +157 -0
  194. package/src/contracts/chain_state_override.ts +200 -0
  195. package/src/contracts/empire_base.ts +77 -7
  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 +285 -0
  199. package/src/contracts/fee_juice.ts +29 -15
  200. package/src/contracts/governance.ts +343 -74
  201. package/src/contracts/governance_proposer.ts +128 -25
  202. package/src/contracts/gse.ts +88 -0
  203. package/src/contracts/inbox.ts +123 -0
  204. package/src/contracts/index.ts +10 -1
  205. package/src/contracts/log.ts +13 -0
  206. package/src/contracts/multicall.ts +296 -0
  207. package/src/contracts/outbox.ts +132 -0
  208. package/src/contracts/registry.ts +81 -26
  209. package/src/contracts/rollup.ts +1246 -90
  210. package/src/contracts/slasher_contract.ts +89 -0
  211. package/src/contracts/slashing_proposer.ts +296 -27
  212. package/src/contracts/utils.ts +14 -0
  213. package/src/deploy_aztec_l1_contracts.ts +646 -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 +231 -0
  220. package/src/l1_contract_addresses.ts +121 -80
  221. package/src/l1_reader.ts +31 -16
  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 +789 -0
  236. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +424 -0
  237. package/src/l1_tx_utils/signer.ts +28 -0
  238. package/src/l1_tx_utils/tx_delayer.ts +303 -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 +203 -0
  243. package/src/queries.ts +149 -17
  244. package/src/test/chain_monitor.ts +307 -0
  245. package/src/test/eth_cheat_codes.ts +600 -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 +388 -0
  249. package/src/test/start_anvil.ts +189 -22
  250. package/src/test/upgrade_utils.ts +30 -21
  251. package/src/types.ts +71 -7
  252. package/src/utils.ts +164 -96
  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/deploy_l1_contracts.d.ts +0 -21210
  258. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  259. package/dest/deploy_l1_contracts.js +0 -687
  260. package/dest/eth_cheat_codes.d.ts +0 -147
  261. package/dest/eth_cheat_codes.d.ts.map +0 -1
  262. package/dest/eth_cheat_codes.js +0 -303
  263. package/dest/index.d.ts +0 -14
  264. package/dest/index.d.ts.map +0 -1
  265. package/dest/index.js +0 -13
  266. package/dest/l1_tx_utils.d.ts +0 -192
  267. package/dest/l1_tx_utils.d.ts.map +0 -1
  268. package/dest/l1_tx_utils.js +0 -641
  269. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  270. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  271. package/dest/l1_tx_utils_with_blobs.js +0 -64
  272. package/dest/test/delayed_tx_utils.d.ts +0 -8
  273. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  274. package/dest/test/delayed_tx_utils.js +0 -21
  275. package/dest/test/tx_delayer.d.ts +0 -25
  276. package/dest/test/tx_delayer.d.ts.map +0 -1
  277. package/dest/test/tx_delayer.js +0 -116
  278. package/src/contracts/forwarder.ts +0 -132
  279. package/src/deploy_l1_contracts.ts +0 -948
  280. package/src/eth_cheat_codes.ts +0 -314
  281. package/src/index.ts +0 -13
  282. package/src/l1_tx_utils.ts +0 -847
  283. package/src/l1_tx_utils_with_blobs.ts +0 -86
  284. package/src/test/delayed_tx_utils.ts +0 -24
  285. package/src/test/tx_delayer.ts +0 -163
@@ -0,0 +1,44 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { ViemClient } from '../types.js';
3
+ /**
4
+ * Typescript wrapper around the Slasher contract.
5
+ */
6
+ export declare class SlasherContract {
7
+ private readonly client;
8
+ private readonly address;
9
+ private readonly log;
10
+ private contract;
11
+ constructor(client: ViemClient, address: EthAddress, log?: import("@aztec/foundation/log").Logger);
12
+ /**
13
+ * Checks if a slash payload is vetoed.
14
+ * @param payloadAddress - The address of the payload to check
15
+ * @returns True if the payload is vetoed, false otherwise
16
+ */
17
+ isPayloadVetoed(payloadAddress: EthAddress): Promise<boolean>;
18
+ /**
19
+ * Checks if slashing is currently enabled. Slashing can be disabled by the vetoer.
20
+ * @returns True if slashing is enabled, false otherwise
21
+ */
22
+ isSlashingEnabled(): Promise<boolean>;
23
+ /**
24
+ * Gets the current vetoer address.
25
+ * @returns The vetoer address
26
+ */
27
+ getVetoer(): Promise<EthAddress>;
28
+ /**
29
+ * Gets the disable duration by the vetoer.
30
+ * @returns The disable duration in seconds
31
+ */
32
+ getSlashingDisableDuration(): Promise<number>;
33
+ /**
34
+ * Gets the current governance address.
35
+ * @returns The governance address
36
+ */
37
+ getGovernance(): Promise<EthAddress>;
38
+ /**
39
+ * Gets the current proposer address.
40
+ * @returns The proposer address
41
+ */
42
+ getProposer(): Promise<EthAddress>;
43
+ }
44
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhc2hlcl9jb250cmFjdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0cy9zbGFzaGVyX2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQU0zRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFFOUM7O0dBRUc7QUFDSCxxQkFBYSxlQUFlO0lBSXhCLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTTtJQUN2QixPQUFPLENBQUMsUUFBUSxDQUFDLE9BQU87SUFDeEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBTHRCLE9BQU8sQ0FBQyxRQUFRLENBQXVEO0lBRXZFLFlBQ21CLE1B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,IAAI,OAAO,CAAC,OAAO,CAAC,CAOjD;IAED;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAG5C;IAED;;;OAGG;IACU,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC,CAGzD;IAED;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,CAGhD;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAG9C;CACF"}
@@ -0,0 +1,75 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
4
+ import { getContract } from 'viem';
5
+ /**
6
+ * Typescript wrapper around the Slasher contract.
7
+ */ export class SlasherContract {
8
+ client;
9
+ address;
10
+ log;
11
+ contract;
12
+ constructor(client, address, log = createLogger('slasher-contract')){
13
+ this.client = client;
14
+ this.address = address;
15
+ this.log = log;
16
+ this.contract = getContract({
17
+ address: this.address.toString(),
18
+ abi: SlasherAbi,
19
+ client: this.client
20
+ });
21
+ }
22
+ /**
23
+ * Checks if a slash payload is vetoed.
24
+ * @param payloadAddress - The address of the payload to check
25
+ * @returns True if the payload is vetoed, false otherwise
26
+ */ async isPayloadVetoed(payloadAddress) {
27
+ try {
28
+ return await this.contract.read.vetoedPayloads([
29
+ payloadAddress.toString()
30
+ ]);
31
+ } catch (error) {
32
+ this.log.error(`Error checking if payload ${payloadAddress} is vetoed`, error);
33
+ throw error;
34
+ }
35
+ }
36
+ /**
37
+ * Checks if slashing is currently enabled. Slashing can be disabled by the vetoer.
38
+ * @returns True if slashing is enabled, false otherwise
39
+ */ async isSlashingEnabled() {
40
+ try {
41
+ return await this.contract.read.isSlashingEnabled();
42
+ } catch (error) {
43
+ this.log.error(`Error checking if slashing is enabled`, error);
44
+ throw error;
45
+ }
46
+ }
47
+ /**
48
+ * Gets the current vetoer address.
49
+ * @returns The vetoer address
50
+ */ async getVetoer() {
51
+ const vetoer = await this.contract.read.VETOER();
52
+ return EthAddress.fromString(vetoer);
53
+ }
54
+ /**
55
+ * Gets the disable duration by the vetoer.
56
+ * @returns The disable duration in seconds
57
+ */ async getSlashingDisableDuration() {
58
+ const duration = await this.contract.read.SLASHING_DISABLE_DURATION();
59
+ return Number(duration);
60
+ }
61
+ /**
62
+ * Gets the current governance address.
63
+ * @returns The governance address
64
+ */ async getGovernance() {
65
+ const governance = await this.contract.read.GOVERNANCE();
66
+ return EthAddress.fromString(governance);
67
+ }
68
+ /**
69
+ * Gets the current proposer address.
70
+ * @returns The proposer address
71
+ */ async getProposer() {
72
+ const proposer = await this.contract.read.PROPOSER();
73
+ return EthAddress.fromString(proposer);
74
+ }
75
+ }
@@ -1,21 +1,139 @@
1
+ import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
+ import { SlotNumber } from '@aztec/foundation/branded-types';
4
+ import { Buffer32 } from '@aztec/foundation/buffer';
1
5
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { type Hex } from 'viem';
3
- import type { L1TxRequest } from '../l1_tx_utils.js';
4
- import type { ViemPublicClient } from '../types.js';
5
- import { type IEmpireBase } from './empire_base.js';
6
- export declare class SlashingProposerContract implements IEmpireBase {
7
- readonly client: ViemPublicClient;
8
- private readonly proposer;
9
- constructor(client: ViemPublicClient, address: Hex);
6
+ import { type Hex, type Log, type TypedDataDefinition } from 'viem';
7
+ /**
8
+ * Wrapper around the SlashingProposer contract that provides
9
+ * a TypeScript interface for interacting with the consensus-based slashing system.
10
+ */
11
+ export declare class SlashingProposerContract {
12
+ readonly client: ViemClient;
13
+ private readonly contract;
14
+ constructor(client: ViemClient, address: Hex | EthAddress);
10
15
  get address(): EthAddress;
11
16
  getQuorumSize(): Promise<bigint>;
12
17
  getRoundSize(): Promise<bigint>;
13
- computeRound(slot: bigint): Promise<bigint>;
14
- getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
15
- lastVote: bigint;
16
- leader: Hex;
17
- executed: boolean;
18
+ getCommitteeSize(): Promise<bigint>;
19
+ getRoundSizeInEpochs(): Promise<bigint>;
20
+ getLifetimeInRounds(): Promise<bigint>;
21
+ getExecutionDelayInRounds(): Promise<bigint>;
22
+ getSlashingAmounts(): Promise<[bigint, bigint, bigint]>;
23
+ getSlashOffsetInRounds(): Promise<bigint>;
24
+ getCurrentRound(): Promise<bigint>;
25
+ /**
26
+ * Get round information
27
+ * @param round - The round number to query
28
+ * @returns Round status information
29
+ */
30
+ getRound(round: bigint): Promise<{
31
+ isExecuted: boolean;
32
+ voteCount: bigint;
18
33
  }>;
19
- createVoteRequest(payload: Hex): L1TxRequest;
34
+ /**
35
+ * Check if a round is ready to execute at a given slot
36
+ * @param round - The round number to check
37
+ * @param slot - The slot number to check at
38
+ * @returns Whether the round is ready to execute
39
+ */
40
+ isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean>;
41
+ /** Returns the slash actions and payload address for a given round (zero if no slash actions) */
42
+ getPayload(round: bigint): Promise<{
43
+ actions: {
44
+ slashAmount: bigint;
45
+ validator: EthAddress;
46
+ }[];
47
+ address: EthAddress;
48
+ }>;
49
+ /** Returns the slash actions to be executed for a given round based on votes */
50
+ getTally(round: bigint): Promise<{
51
+ actions: {
52
+ slashAmount: bigint;
53
+ validator: EthAddress;
54
+ }[];
55
+ committees: EthAddress[][];
56
+ }>;
57
+ private mapSlashActions;
58
+ /** Tries to extract a VoteCast event from the given logs. */
59
+ tryExtractVoteCastEvent(logs: Log[]): {
60
+ eventName: "VoteCast";
61
+ args: {
62
+ proposer: `0x${string}`;
63
+ round: bigint;
64
+ slot: bigint;
65
+ };
66
+ } | undefined;
67
+ /** Tries to extract a RoundExecuted event from the given logs. */
68
+ tryExtractRoundExecutedEvent(logs: Log[]): {
69
+ eventName: "RoundExecuted";
70
+ args: {
71
+ round: bigint;
72
+ slashCount: bigint;
73
+ };
74
+ } | undefined;
75
+ /**
76
+ * Create a transaction to vote for slashing offenses
77
+ * @param votes - The encoded votes for slashing
78
+ * @param slot - The slot number for the vote
79
+ * @param signer - The signer to produce the signature
80
+ * @returns L1 transaction request
81
+ */
82
+ buildVoteRequestFromSigner(votes: Hex, slot: SlotNumber, signer: (msg: TypedDataDefinition) => Promise<Hex>): Promise<L1TxRequest>;
83
+ /** Returns the typed data definition to EIP712-sign for voting */
84
+ buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition;
85
+ /** Gets the digest to sign for voting directly from the contract */
86
+ getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32>;
87
+ /**
88
+ * Create a transaction to vote for slashing offenses
89
+ * @param votes - The encoded votes for slashing
90
+ * @param signature - The signature from the current proposer
91
+ * @returns L1 transaction request
92
+ */
93
+ buildVoteRequestWithSignature(votes: Hex, signature: {
94
+ v: number;
95
+ r: Hex;
96
+ s: Hex;
97
+ }): L1TxRequest;
98
+ /**
99
+ * Create a transaction to execute a slashing round
100
+ * @param round - The round number to execute
101
+ * @param committees - The committees for each epoch in the round
102
+ * @returns L1 transaction request
103
+ */
104
+ buildExecuteRoundRequest(round: bigint, committees: EthAddress[][]): L1TxRequest;
105
+ /** Returns the last vote emitted for a given round */
106
+ getLastVote(round: bigint): Promise<{
107
+ validator: EthAddress;
108
+ slashAmount: bigint;
109
+ }[]>;
110
+ /**
111
+ * Listen for VoteCast events
112
+ * @param callback - Callback function to handle vote cast events
113
+ * @returns Unwatch function
114
+ */
115
+ listenToVoteCast(callback: (args: {
116
+ round: bigint;
117
+ proposer: string;
118
+ }) => void): () => void;
119
+ /**
120
+ * Listen for RoundExecuted events
121
+ * @param callback - Callback function to handle round executed events
122
+ * @returns Unwatch function
123
+ */
124
+ listenToRoundExecuted(callback: (args: {
125
+ round: bigint;
126
+ slashCount: bigint;
127
+ l1BlockHash: Hex;
128
+ }) => void): () => void;
20
129
  }
21
- //# sourceMappingURL=slashing_proposer.d.ts.map
130
+ /**
131
+ * Decodes a Buffer containing slash votes back into an array of numbers.
132
+ * Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
133
+ * @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
134
+ * do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
135
+ * @param buffer - The Buffer containing encoded slash votes
136
+ * @returns An array of numbers representing the slash votes
137
+ */
138
+ export declare function decodeSlashConsensusVotes(buffer: Buffer): number[];
139
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhc2hpbmdfcHJvcG9zZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdHMvc2xhc2hpbmdfcHJvcG9zZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFeEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzdELE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFNM0QsT0FBTyxFQUVMLEtBQUssR0FBRyxFQUNSLEtBQUssR0FBRyxFQUNSLEtBQUssbUJBQW1CLEVBR3pCLE1BQU0sTUFBTSxDQUFDO0FBRWQ7OztHQUdHO0FBQ0gscUJBQWEsd0JBQXdCO2FBSWpCLE1BQU0sRUFBRSxVQUFVO0lBSHBDLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFnRTtJQUV6RixZQUNrQixNQUFNLEVBQUUsVUFBVSxFQUNsQyxPQUFPLEVBQUUsR0FBRyxHQUFHLFVBQVUsRUFPMUI7S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AAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,GAChF,MAAM,IAAI,CAcZ;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAelE"}
@@ -1,47 +1,318 @@
1
+ import { mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
2
+ import { Buffer32 } from '@aztec/foundation/buffer';
1
3
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { SlashingProposerAbi } from '@aztec/l1-artifacts';
3
- import { getContract } from 'viem';
4
- import { encodeVote } from './empire_base.js';
5
- export class SlashingProposerContract {
4
+ import { Signature } from '@aztec/foundation/eth-signature';
5
+ import { hexToBuffer } from '@aztec/foundation/string';
6
+ import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
7
+ import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
8
+ import { encodeFunctionData, getContract } from 'viem';
9
+ /**
10
+ * Wrapper around the SlashingProposer contract that provides
11
+ * a TypeScript interface for interacting with the consensus-based slashing system.
12
+ */ export class SlashingProposerContract {
6
13
  client;
7
- proposer;
14
+ contract;
8
15
  constructor(client, address){
9
16
  this.client = client;
10
- this.proposer = getContract({
11
- address,
17
+ this.contract = getContract({
18
+ address: typeof address === 'string' ? address : address.toString(),
12
19
  abi: SlashingProposerAbi,
13
20
  client
14
21
  });
15
22
  }
16
23
  get address() {
17
- return EthAddress.fromString(this.proposer.address);
24
+ return EthAddress.fromString(this.contract.address);
18
25
  }
19
26
  getQuorumSize() {
20
- return this.proposer.read.N();
27
+ return this.contract.read.QUORUM();
21
28
  }
22
29
  getRoundSize() {
23
- return this.proposer.read.M();
30
+ return this.contract.read.ROUND_SIZE();
24
31
  }
25
- computeRound(slot) {
26
- return this.proposer.read.computeRound([
27
- slot
32
+ getCommitteeSize() {
33
+ return this.contract.read.COMMITTEE_SIZE();
34
+ }
35
+ getRoundSizeInEpochs() {
36
+ return this.contract.read.ROUND_SIZE_IN_EPOCHS();
37
+ }
38
+ getLifetimeInRounds() {
39
+ return this.contract.read.LIFETIME_IN_ROUNDS();
40
+ }
41
+ getExecutionDelayInRounds() {
42
+ return this.contract.read.EXECUTION_DELAY_IN_ROUNDS();
43
+ }
44
+ getSlashingAmounts() {
45
+ return Promise.all([
46
+ this.contract.read.SLASH_AMOUNT_SMALL(),
47
+ this.contract.read.SLASH_AMOUNT_MEDIUM(),
48
+ this.contract.read.SLASH_AMOUNT_LARGE()
49
+ ]);
50
+ }
51
+ getSlashOffsetInRounds() {
52
+ return this.contract.read.SLASH_OFFSET_IN_ROUNDS();
53
+ }
54
+ getCurrentRound() {
55
+ return this.contract.read.getCurrentRound();
56
+ }
57
+ /**
58
+ * Get round information
59
+ * @param round - The round number to query
60
+ * @returns Round status information
61
+ */ async getRound(round) {
62
+ const [isExecuted, voteCount] = await this.contract.read.getRound([
63
+ round
64
+ ]);
65
+ return {
66
+ isExecuted,
67
+ voteCount
68
+ };
69
+ }
70
+ /**
71
+ * Check if a round is ready to execute at a given slot
72
+ * @param round - The round number to check
73
+ * @param slot - The slot number to check at
74
+ * @returns Whether the round is ready to execute
75
+ */ async isRoundReadyToExecute(round, slot) {
76
+ return await this.contract.read.isRoundReadyToExecute([
77
+ round,
78
+ BigInt(slot)
28
79
  ]);
29
80
  }
30
- async getRoundInfo(rollupAddress, round) {
31
- const roundInfo = await this.proposer.read.rounds([
32
- rollupAddress,
81
+ /** Returns the slash actions and payload address for a given round (zero if no slash actions) */ async getPayload(round) {
82
+ const { result: committees } = await this.contract.simulate.getSlashTargetCommittees([
33
83
  round
34
84
  ]);
85
+ const tally = await this.contract.read.getTally([
86
+ round,
87
+ committees
88
+ ]);
89
+ const address = await this.contract.read.getPayloadAddress([
90
+ round,
91
+ tally
92
+ ]);
93
+ const actions = this.mapSlashActions(tally);
35
94
  return {
36
- lastVote: roundInfo[0],
37
- leader: roundInfo[1],
38
- executed: roundInfo[2]
95
+ actions,
96
+ address: EthAddress.fromString(address)
39
97
  };
40
98
  }
41
- createVoteRequest(payload) {
99
+ /** Returns the slash actions to be executed for a given round based on votes */ async getTally(round) {
100
+ const { result: committees } = await this.contract.simulate.getSlashTargetCommittees([
101
+ round
102
+ ]);
103
+ const tally = await this.contract.read.getTally([
104
+ round,
105
+ committees
106
+ ]);
42
107
  return {
43
- to: this.address.toString(),
44
- data: encodeVote(payload)
108
+ actions: this.mapSlashActions(tally),
109
+ committees: committees.map((c)=>c.map(EthAddress.fromString))
45
110
  };
46
111
  }
112
+ mapSlashActions(actions) {
113
+ return actions.map(({ validator, slashAmount })=>({
114
+ validator: EthAddress.fromString(validator),
115
+ slashAmount
116
+ }));
117
+ }
118
+ /** Tries to extract a VoteCast event from the given logs. */ tryExtractVoteCastEvent(logs) {
119
+ return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'VoteCast');
120
+ }
121
+ /** Tries to extract a RoundExecuted event from the given logs. */ tryExtractRoundExecutedEvent(logs) {
122
+ return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'RoundExecuted');
123
+ }
124
+ /**
125
+ * Create a transaction to vote for slashing offenses
126
+ * @param votes - The encoded votes for slashing
127
+ * @param slot - The slot number for the vote
128
+ * @param signer - The signer to produce the signature
129
+ * @returns L1 transaction request
130
+ */ async buildVoteRequestFromSigner(votes, slot, signer) {
131
+ const typedData = this.buildVoteTypedData(votes, slot);
132
+ const signature = Signature.fromString(await signer(typedData));
133
+ return {
134
+ to: this.contract.address,
135
+ abi: SlashingProposerAbi,
136
+ data: encodeFunctionData({
137
+ abi: SlashingProposerAbi,
138
+ functionName: 'vote',
139
+ args: [
140
+ votes,
141
+ signature.toViemSignature()
142
+ ]
143
+ })
144
+ };
145
+ }
146
+ /** Returns the typed data definition to EIP712-sign for voting */ buildVoteTypedData(votes, slot) {
147
+ const domain = {
148
+ name: 'SlashingProposer',
149
+ version: '1',
150
+ chainId: this.client.chain.id,
151
+ verifyingContract: this.contract.address
152
+ };
153
+ const types = {
154
+ EIP712Domain: [
155
+ {
156
+ name: 'name',
157
+ type: 'string'
158
+ },
159
+ {
160
+ name: 'version',
161
+ type: 'string'
162
+ },
163
+ {
164
+ name: 'chainId',
165
+ type: 'uint256'
166
+ },
167
+ {
168
+ name: 'verifyingContract',
169
+ type: 'address'
170
+ }
171
+ ],
172
+ Vote: [
173
+ {
174
+ name: 'votes',
175
+ type: 'bytes'
176
+ },
177
+ {
178
+ name: 'slot',
179
+ type: 'uint256'
180
+ }
181
+ ]
182
+ };
183
+ return {
184
+ domain,
185
+ types,
186
+ primaryType: 'Vote',
187
+ message: {
188
+ votes,
189
+ slot: BigInt(slot)
190
+ }
191
+ };
192
+ }
193
+ /** Gets the digest to sign for voting directly from the contract */ async getVoteDataDigest(votes, slot) {
194
+ return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([
195
+ votes,
196
+ BigInt(slot)
197
+ ]));
198
+ }
199
+ /**
200
+ * Create a transaction to vote for slashing offenses
201
+ * @param votes - The encoded votes for slashing
202
+ * @param signature - The signature from the current proposer
203
+ * @returns L1 transaction request
204
+ */ buildVoteRequestWithSignature(votes, signature) {
205
+ return {
206
+ to: this.contract.address,
207
+ abi: SlashingProposerAbi,
208
+ data: encodeFunctionData({
209
+ abi: SlashingProposerAbi,
210
+ functionName: 'vote',
211
+ args: [
212
+ votes,
213
+ signature
214
+ ]
215
+ })
216
+ };
217
+ }
218
+ /**
219
+ * Create a transaction to execute a slashing round
220
+ * @param round - The round number to execute
221
+ * @param committees - The committees for each epoch in the round
222
+ * @returns L1 transaction request
223
+ */ buildExecuteRoundRequest(round, committees) {
224
+ return {
225
+ to: this.contract.address,
226
+ abi: mergeAbis([
227
+ SlashingProposerAbi,
228
+ SlasherAbi
229
+ ]),
230
+ data: encodeFunctionData({
231
+ abi: SlashingProposerAbi,
232
+ functionName: 'executeRound',
233
+ args: [
234
+ round,
235
+ committees.map((c)=>c.map((addr)=>addr.toString()))
236
+ ]
237
+ })
238
+ };
239
+ }
240
+ /** Returns the last vote emitted for a given round */ async getLastVote(round) {
241
+ const { voteCount } = await this.getRound(round);
242
+ const validators = (await this.contract.simulate.getSlashTargetCommittees([
243
+ round
244
+ ])).result.flat();
245
+ const vote = await this.contract.read.getVotes([
246
+ round,
247
+ voteCount - 1n
248
+ ]);
249
+ const decoded = decodeSlashConsensusVotes(hexToBuffer(vote));
250
+ const slashAmounts = await this.getSlashingAmounts();
251
+ return decoded.map((units, i)=>({
252
+ validator: EthAddress.fromString(validators[i]),
253
+ slashAmount: slashAmounts[units - 1] ?? 0n
254
+ })).filter((v)=>v.slashAmount > 0n);
255
+ }
256
+ /**
257
+ * Listen for VoteCast events
258
+ * @param callback - Callback function to handle vote cast events
259
+ * @returns Unwatch function
260
+ */ listenToVoteCast(callback) {
261
+ return this.contract.watchEvent.VoteCast({}, {
262
+ onLogs: (logs)=>{
263
+ for (const log of logs){
264
+ const { round, proposer } = log.args;
265
+ if (round !== undefined && proposer) {
266
+ callback({
267
+ round,
268
+ proposer
269
+ });
270
+ }
271
+ }
272
+ }
273
+ });
274
+ }
275
+ /**
276
+ * Listen for RoundExecuted events
277
+ * @param callback - Callback function to handle round executed events
278
+ * @returns Unwatch function
279
+ */ listenToRoundExecuted(callback) {
280
+ return this.contract.watchEvent.RoundExecuted({}, {
281
+ onLogs: (logs)=>{
282
+ for (const log of logs){
283
+ const { round, slashCount } = log.args;
284
+ if (round !== undefined && slashCount !== undefined) {
285
+ callback({
286
+ round,
287
+ slashCount,
288
+ l1BlockHash: log.blockHash
289
+ });
290
+ }
291
+ }
292
+ }
293
+ });
294
+ }
295
+ }
296
+ /**
297
+ * Decodes a Buffer containing slash votes back into an array of numbers.
298
+ * Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
299
+ * @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
300
+ * do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
301
+ * @param buffer - The Buffer containing encoded slash votes
302
+ * @returns An array of numbers representing the slash votes
303
+ */ export function decodeSlashConsensusVotes(buffer) {
304
+ const votes = [];
305
+ for(let i = 0; i < buffer.length; i++){
306
+ const voteByte = buffer.readUInt8(i);
307
+ // Decode votes from Solidity's bit order (LSB to MSB)
308
+ // Bits 0-1: validator at index i*4
309
+ // Bits 2-3: validator at index i*4+1
310
+ // Bits 4-5: validator at index i*4+2
311
+ // Bits 6-7: validator at index i*4+3
312
+ votes.push(voteByte >> 0 & 0x03);
313
+ votes.push(voteByte >> 2 & 0x03);
314
+ votes.push(voteByte >> 4 & 0x03);
315
+ votes.push(voteByte >> 6 & 0x03);
316
+ }
317
+ return votes;
47
318
  }
@@ -0,0 +1,3 @@
1
+ import type { ViemClient } from '../types.js';
2
+ export declare function checkBlockTag(block: bigint | undefined, publicClient: ViemClient): Promise<void>;
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdHMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBSzlDLHdCQUFzQixhQUFhLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQUUsWUFBWSxFQUFFLFVBQVUsaUJBUXRGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/contracts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,UAAU,iBAQtF"}
@@ -0,0 +1,11 @@
1
+ import { BlockTagTooOldError } from './errors.js';
2
+ const L1_NON_ARCHIVE_BLOCK_HISTORY_LENGTH = 128n;
3
+ export async function checkBlockTag(block, publicClient) {
4
+ if (block === undefined) {
5
+ return;
6
+ }
7
+ const latestBlock = await publicClient.getBlockNumber();
8
+ if (block < latestBlock - L1_NON_ARCHIVE_BLOCK_HISTORY_LENGTH) {
9
+ throw new BlockTagTooOldError(block, latestBlock);
10
+ }
11
+ }