@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (240) hide show
  1. package/dest/account.d.ts +1 -1
  2. package/dest/chain.d.ts +1 -1
  3. package/dest/client.d.ts +25 -3
  4. package/dest/client.d.ts.map +1 -1
  5. package/dest/client.js +60 -4
  6. package/dest/config.d.ts +48 -73
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +120 -386
  9. package/dest/constants.d.ts +1 -1
  10. package/dest/contracts/chain_state_override.d.ts +78 -0
  11. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  12. package/dest/contracts/chain_state_override.js +137 -0
  13. package/dest/contracts/empire_base.d.ts +7 -5
  14. package/dest/contracts/empire_base.d.ts.map +1 -1
  15. package/dest/contracts/empire_base.js +1 -1
  16. package/dest/contracts/errors.d.ts +1 -1
  17. package/dest/contracts/errors.d.ts.map +1 -1
  18. package/dest/contracts/fee_asset_handler.d.ts +6 -5
  19. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  20. package/dest/contracts/fee_asset_handler.js +11 -9
  21. package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
  22. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_price_oracle.js +656 -0
  24. package/dest/contracts/fee_juice.d.ts +1 -1
  25. package/dest/contracts/fee_juice.d.ts.map +1 -1
  26. package/dest/contracts/governance.d.ts +113 -36
  27. package/dest/contracts/governance.d.ts.map +1 -1
  28. package/dest/contracts/governance.js +207 -16
  29. package/dest/contracts/governance_proposer.d.ts +38 -4
  30. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  31. package/dest/contracts/governance_proposer.js +455 -12
  32. package/dest/contracts/gse.d.ts +4 -2
  33. package/dest/contracts/gse.d.ts.map +1 -1
  34. package/dest/contracts/gse.js +2 -2
  35. package/dest/contracts/inbox.d.ts +24 -3
  36. package/dest/contracts/inbox.d.ts.map +1 -1
  37. package/dest/contracts/inbox.js +42 -2
  38. package/dest/contracts/index.d.ts +6 -3
  39. package/dest/contracts/index.d.ts.map +1 -1
  40. package/dest/contracts/index.js +5 -2
  41. package/dest/contracts/log.d.ts +13 -0
  42. package/dest/contracts/log.d.ts.map +1 -0
  43. package/dest/contracts/log.js +1 -0
  44. package/dest/contracts/multicall.d.ts +130 -13
  45. package/dest/contracts/multicall.d.ts.map +1 -1
  46. package/dest/contracts/multicall.js +203 -93
  47. package/dest/contracts/outbox.d.ts +64 -0
  48. package/dest/contracts/outbox.d.ts.map +1 -0
  49. package/dest/contracts/outbox.js +113 -0
  50. package/dest/contracts/registry.d.ts +3 -1
  51. package/dest/contracts/registry.d.ts.map +1 -1
  52. package/dest/contracts/registry.js +30 -1
  53. package/dest/contracts/rollup.d.ts +5591 -131
  54. package/dest/contracts/rollup.d.ts.map +1 -1
  55. package/dest/contracts/rollup.js +1125 -232
  56. package/dest/contracts/slasher_contract.d.ts +1 -1
  57. package/dest/contracts/slasher_contract.d.ts.map +1 -1
  58. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +11 -10
  59. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  60. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +21 -16
  61. package/dest/contracts/utils.d.ts +1 -1
  62. package/dest/deploy_aztec_l1_contracts.d.ts +267 -0
  63. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  64. package/dest/deploy_aztec_l1_contracts.js +417 -0
  65. package/dest/deploy_l1_contract.d.ts +68 -0
  66. package/dest/deploy_l1_contract.d.ts.map +1 -0
  67. package/dest/deploy_l1_contract.js +312 -0
  68. package/dest/eth-signer/eth-signer.d.ts +1 -1
  69. package/dest/eth-signer/index.d.ts +1 -1
  70. package/dest/forwarder_proxy.d.ts +32 -0
  71. package/dest/forwarder_proxy.d.ts.map +1 -0
  72. package/dest/forwarder_proxy.js +93 -0
  73. package/dest/l1_artifacts.d.ts +21007 -16779
  74. package/dest/l1_artifacts.d.ts.map +1 -1
  75. package/dest/l1_artifacts.js +9 -24
  76. package/dest/l1_contract_addresses.d.ts +61 -65
  77. package/dest/l1_contract_addresses.d.ts.map +1 -1
  78. package/dest/l1_contract_addresses.js +99 -80
  79. package/dest/l1_reader.d.ts +7 -5
  80. package/dest/l1_reader.d.ts.map +1 -1
  81. package/dest/l1_reader.js +15 -7
  82. package/dest/l1_tx_utils/config.d.ts +11 -5
  83. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  84. package/dest/l1_tx_utils/config.js +46 -10
  85. package/dest/l1_tx_utils/constants.d.ts +8 -2
  86. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  87. package/dest/l1_tx_utils/constants.js +27 -2
  88. package/dest/l1_tx_utils/factory.d.ts +18 -10
  89. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  90. package/dest/l1_tx_utils/factory.js +17 -7
  91. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  92. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  93. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  94. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  95. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  96. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  97. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  98. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  99. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  100. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  101. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  102. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  103. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  104. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  105. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
  106. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  107. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  108. package/dest/l1_tx_utils/index-blobs.js +2 -0
  109. package/dest/l1_tx_utils/index.d.ts +4 -1
  110. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  111. package/dest/l1_tx_utils/index.js +3 -0
  112. package/dest/l1_tx_utils/interfaces.d.ts +2 -2
  113. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
  114. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +252 -0
  115. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/l1_fee_analyzer.js +568 -0
  117. package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -8
  118. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  119. package/dest/l1_tx_utils/l1_tx_utils.js +202 -92
  120. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -30
  121. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  122. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +65 -168
  123. package/dest/l1_tx_utils/signer.d.ts +1 -1
  124. package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
  125. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  126. package/dest/{test → l1_tx_utils}/tx_delayer.js +70 -39
  127. package/dest/l1_tx_utils/types.d.ts +27 -1
  128. package/dest/l1_tx_utils/types.d.ts.map +1 -1
  129. package/dest/l1_tx_utils/types.js +10 -0
  130. package/dest/l1_tx_utils/utils.d.ts +1 -1
  131. package/dest/l1_types.d.ts +1 -1
  132. package/dest/publisher_manager.d.ts +34 -7
  133. package/dest/publisher_manager.d.ts.map +1 -1
  134. package/dest/publisher_manager.js +119 -8
  135. package/dest/queries.d.ts +14 -3
  136. package/dest/queries.d.ts.map +1 -1
  137. package/dest/queries.js +84 -9
  138. package/dest/test/blob_kzg_warmup.d.ts +19 -0
  139. package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
  140. package/dest/test/blob_kzg_warmup.js +64 -0
  141. package/dest/test/chain_monitor.d.ts +80 -26
  142. package/dest/test/chain_monitor.d.ts.map +1 -1
  143. package/dest/test/chain_monitor.js +137 -39
  144. package/dest/test/eth_cheat_codes.d.ts +47 -8
  145. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  146. package/dest/test/eth_cheat_codes.js +100 -44
  147. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  148. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  149. package/dest/test/index.d.ts +2 -3
  150. package/dest/test/index.d.ts.map +1 -1
  151. package/dest/test/index.js +1 -2
  152. package/dest/test/rollup_cheat_codes.d.ts +75 -14
  153. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  154. package/dest/test/rollup_cheat_codes.js +145 -42
  155. package/dest/test/start_anvil.d.ts +25 -2
  156. package/dest/test/start_anvil.d.ts.map +1 -1
  157. package/dest/test/start_anvil.js +143 -28
  158. package/dest/test/upgrade_utils.d.ts +1 -1
  159. package/dest/test/upgrade_utils.js +2 -2
  160. package/dest/types.d.ts +57 -2
  161. package/dest/types.d.ts.map +1 -1
  162. package/dest/utils.d.ts +24 -4
  163. package/dest/utils.d.ts.map +1 -1
  164. package/dest/utils.js +112 -16
  165. package/dest/zkPassportVerifierAddress.d.ts +1 -1
  166. package/package.json +34 -17
  167. package/src/client.ts +66 -2
  168. package/src/config.ts +162 -470
  169. package/src/contracts/README.md +157 -0
  170. package/src/contracts/chain_state_override.ts +200 -0
  171. package/src/contracts/empire_base.ts +6 -5
  172. package/src/contracts/fee_asset_handler.ts +10 -7
  173. package/src/contracts/fee_asset_price_oracle.ts +285 -0
  174. package/src/contracts/governance.ts +279 -13
  175. package/src/contracts/governance_proposer.ts +74 -7
  176. package/src/contracts/gse.ts +7 -2
  177. package/src/contracts/inbox.ts +64 -4
  178. package/src/contracts/index.ts +5 -2
  179. package/src/contracts/log.ts +13 -0
  180. package/src/contracts/multicall.ts +247 -103
  181. package/src/contracts/outbox.ts +132 -0
  182. package/src/contracts/registry.ts +31 -1
  183. package/src/contracts/rollup.ts +830 -194
  184. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +26 -21
  185. package/src/deploy_aztec_l1_contracts.ts +652 -0
  186. package/src/deploy_l1_contract.ts +362 -0
  187. package/src/forwarder_proxy.ts +108 -0
  188. package/src/l1_artifacts.ts +12 -35
  189. package/src/l1_contract_addresses.ts +120 -92
  190. package/src/l1_reader.ts +25 -10
  191. package/src/l1_tx_utils/config.ts +55 -14
  192. package/src/l1_tx_utils/constants.ts +13 -2
  193. package/src/l1_tx_utils/factory.ts +31 -31
  194. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  195. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  196. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  197. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  198. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
  199. package/src/l1_tx_utils/index-blobs.ts +2 -0
  200. package/src/l1_tx_utils/index.ts +3 -0
  201. package/src/l1_tx_utils/interfaces.ts +1 -1
  202. package/src/l1_tx_utils/l1_fee_analyzer.ts +875 -0
  203. package/src/l1_tx_utils/l1_tx_utils.ts +194 -72
  204. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +79 -214
  205. package/src/{test → l1_tx_utils}/tx_delayer.ts +97 -58
  206. package/src/l1_tx_utils/types.ts +32 -0
  207. package/src/publisher_manager.ts +145 -12
  208. package/src/queries.ts +93 -10
  209. package/src/test/blob_kzg_warmup.ts +65 -0
  210. package/src/test/chain_monitor.ts +198 -51
  211. package/src/test/eth_cheat_codes.ts +91 -48
  212. package/src/test/index.ts +1 -2
  213. package/src/test/rollup_cheat_codes.ts +174 -45
  214. package/src/test/start_anvil.ts +179 -27
  215. package/src/test/upgrade_utils.ts +2 -2
  216. package/src/types.ts +62 -0
  217. package/src/utils.ts +128 -19
  218. package/dest/contracts/empire_slashing_proposer.d.ts +0 -65
  219. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  220. package/dest/contracts/empire_slashing_proposer.js +0 -194
  221. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  222. package/dest/deploy_l1_contracts.d.ts +0 -226
  223. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  224. package/dest/deploy_l1_contracts.js +0 -1473
  225. package/dest/index.d.ts +0 -18
  226. package/dest/index.d.ts.map +0 -1
  227. package/dest/index.js +0 -17
  228. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  229. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  230. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  231. package/dest/test/delayed_tx_utils.d.ts +0 -13
  232. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  233. package/dest/test/delayed_tx_utils.js +0 -28
  234. package/dest/test/tx_delayer.d.ts +0 -36
  235. package/dest/test/tx_delayer.d.ts.map +0 -1
  236. package/src/contracts/empire_slashing_proposer.ts +0 -259
  237. package/src/deploy_l1_contracts.ts +0 -1849
  238. package/src/index.ts +0 -17
  239. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  240. package/src/test/delayed_tx_utils.ts +0 -52
@@ -1,4 +1,5 @@
1
1
  import type { BlobKzgInstance } from '@aztec/blob-lib/types';
2
+ import { TimeoutError } from '@aztec/foundation/error';
2
3
  import { EthAddress } from '@aztec/foundation/eth-address';
3
4
  import type { ViemTransactionSignature } from '@aztec/foundation/eth-signature';
4
5
  import type { Abi, Address, Hex, TransactionReceipt, TransactionSerializable } from 'viem';
@@ -48,6 +49,12 @@ export type L1TxState = {
48
49
  cancelTxHashes: Hex[];
49
50
  gasLimit: bigint;
50
51
  gasPrice: GasPrice;
52
+ /**
53
+ * Prices used for each attempt (initial send followed by each speed-up), in order. Always set on
54
+ * newly sent txs; optional because states restored from the state store predate the field.
55
+ * In-memory only — not persisted by the state store.
56
+ */
57
+ gasPriceHistory?: GasPrice[];
51
58
  txConfigOverrides: L1TxConfig;
52
59
  request: L1TxRequest;
53
60
  status: TxUtilsState;
@@ -64,4 +71,23 @@ export declare class UnknownMinedTxError extends Error {
64
71
  export declare class DroppedTransactionError extends Error {
65
72
  constructor(nonce: number, account: string);
66
73
  }
67
- //# sourceMappingURL=types.d.ts.map
74
+ /** Snapshot of what a timed-out L1 tx tried to pay, taken when the timeout is raised. */
75
+ export type TimedOutTxState = {
76
+ /** Prices used across the initial send and each speed-up, in order (undefined only for restored states). */
77
+ gasPriceHistory?: GasPrice[];
78
+ /** The last price the tx was sent at before timing out. */
79
+ finalGasPrice: GasPrice;
80
+ /** Number of send attempts (initial + speed-ups). */
81
+ attempts: number;
82
+ nonce: number;
83
+ gasLimit: bigint;
84
+ };
85
+ /**
86
+ * Thrown by sendAndMonitorTransaction when a tx times out. Subclasses TimeoutError so existing
87
+ * `instanceof TimeoutError` checks keep working, while carrying the gas-price ladder for diagnostics.
88
+ */
89
+ export declare class L1TxTimeoutError extends TimeoutError {
90
+ readonly txState: TimedOutTxState;
91
+ constructor(message: string, txState: TimedOutTxState);
92
+ }
93
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMV90eF91dGlscy90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUM3RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0se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E,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,cAAc,EAAE,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,UAAU,EAAE,YAAY,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,WAAW,EAAE,uBAAuB,EACpC,cAAc,EAAE,UAAU,KACvB,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAEvC,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAGzC;CACF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAGzC;CACF;AAED,yFAAyF;AACzF,MAAM,MAAM,eAAe,GAAG;IAC5B,4GAA4G;IAC5G,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,2DAA2D;IAC3D,aAAa,EAAE,QAAQ,CAAC;IACxB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;aAG9B,OAAO,EAAE,eAAe;IAF1C,YACE,OAAO,EAAE,MAAM,EACC,OAAO,EAAE,eAAe,EAGzC;CACF"}
@@ -1,3 +1,4 @@
1
+ import { TimeoutError } from '@aztec/foundation/error';
1
2
  export var TxUtilsState = /*#__PURE__*/ function(TxUtilsState) {
2
3
  TxUtilsState[TxUtilsState["IDLE"] = 0] = "IDLE";
3
4
  TxUtilsState[TxUtilsState["SENT"] = 1] = "SENT";
@@ -24,3 +25,12 @@ export class DroppedTransactionError extends Error {
24
25
  this.name = 'DroppedTransactionError';
25
26
  }
26
27
  }
28
+ /**
29
+ * Thrown by sendAndMonitorTransaction when a tx times out. Subclasses TimeoutError so existing
30
+ * `instanceof TimeoutError` checks keep working, while carrying the gas-price ladder for diagnostics.
31
+ */ export class L1TxTimeoutError extends TimeoutError {
32
+ txState;
33
+ constructor(message, txState){
34
+ super(message), this.txState = txState;
35
+ }
36
+ }
@@ -1,4 +1,4 @@
1
1
  import type { ContractFunctionExecutionError } from 'viem';
2
2
  export declare function tryGetCustomErrorNameContractFunction(err: ContractFunctionExecutionError): string;
3
3
  export declare function getCalldataGasUsage(data: Uint8Array): number;
4
- //# sourceMappingURL=utils.d.ts.map
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMV90eF91dGlscy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssRUFBRSw4QkFBOEIsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUUzRCx3QkFBZ0IscUNBQXFDLENBQUMsR0FBRyxFQUFFLDhCQUE4QixVQUV4RjtBQU9ELHdCQUFnQixtQkFBbUIsQ0FBQyxJQUFJLEVBQUUsVUFBVSxVQUVuRCJ9
@@ -3,4 +3,4 @@ export type L1BlockId = {
3
3
  l1BlockNumber: bigint;
4
4
  l1BlockHash: Buffer32;
5
5
  };
6
- //# sourceMappingURL=l1_types.d.ts.map
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfdHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9sMV90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV6RCxNQUFNLE1BQU0sU0FBUyxHQUFHO0lBQ3RCLGFBQWEsRUFBRSxNQUFNLENBQUM7SUFDdEIsV0FBVyxFQUFFLFFBQVEsQ0FBQztDQUN2QixDQUFDIn0=
@@ -1,15 +1,42 @@
1
+ import { type LoggerBindings } from '@aztec/foundation/log';
2
+ import { RunningPromise } from '@aztec/foundation/running-promise';
1
3
  import { L1TxUtils } from './l1_tx_utils/index.js';
2
4
  export type PublisherFilter<UtilsType extends L1TxUtils> = (utils: UtilsType) => boolean;
5
+ /** Config accepted by PublisherManager. */
6
+ type PublisherManagerConfig = {
7
+ publisherAllowInvalidStates?: boolean;
8
+ publisherFundingThreshold?: bigint;
9
+ publisherFundingAmount?: bigint;
10
+ };
3
11
  export declare class PublisherManager<UtilsType extends L1TxUtils = L1TxUtils> {
4
- private publishers;
12
+ protected publishers: UtilsType[];
5
13
  private log;
6
14
  private config;
7
- constructor(publishers: UtilsType[], config: {
8
- publisherAllowInvalidStates?: boolean;
15
+ private static readonly FUNDING_CHECK_INTERVAL_MS;
16
+ protected funder?: UtilsType;
17
+ protected readonly fundingPromise?: RunningPromise;
18
+ private started;
19
+ constructor(publishers: UtilsType[], config: PublisherManagerConfig, opts?: {
20
+ bindings?: LoggerBindings;
21
+ funder?: UtilsType;
9
22
  });
10
- /** Loads the state of all publishers and resumes monitoring any pending txs */
11
- loadState(): Promise<void>;
23
+ /**
24
+ * Clears any interrupted flag left by a previous {@link stop} so publishing works again after a restart,
25
+ * loads the state of all publishers and the funder, and starts periodic funding checks. Idempotent: a
26
+ * start while already started is a no-op, so it never re-runs `loadStateAndResumeMonitoring` (which
27
+ * would spawn a duplicate background monitor per pending nonce). Lifecycle calls are expected to be
28
+ * serialized by the caller.
29
+ */
30
+ start(): Promise<void>;
31
+ /**
32
+ * Stops the funding loop, interrupts all publishers so no further L1 txs are sent, and waits (bounded)
33
+ * for their in-flight tx monitor loops to wind down. Idempotent, and the manager may be restarted
34
+ * afterwards via {@link start}, which clears the interrupted flag.
35
+ */
36
+ stop(): Promise<void>;
12
37
  getAvailablePublisher(filter?: PublisherFilter<UtilsType>): Promise<UtilsType>;
13
- interrupt(): void;
38
+ private triggerFundingIfNeeded;
39
+ private fundPublishers;
14
40
  }
15
- //# sourceMappingURL=publisher_manager.d.ts.map
41
+ export {};
42
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGlzaGVyX21hbmFnZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wdWJsaXNoZXJfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDdkYsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBR25FLE9BQU8sRUFBRSxTQUFTLEVBQWdCLE1BQU0sd0JBQXdCLENBQUM7QUF3QmpFLE1BQU0sTUFBTSxlQUFlLENBQUMsU0FBUyxTQUFTLFNBQVMsSUFBSSxDQUFDLEtBQUssRUFBRSxTQUFTLEtBQUssT0FBTyxDQUFDO0FBRXpGLDJDQUEyQztBQUMzQyxLQUFLLHNCQUFzQixHQUFHO0lBQzVCLDJCQUEyQixDQUFDLEVBQUUsT0FBTyxDQUFDO0lBQ3RDLHlCQUF5QixDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ25DLHNCQUFzQixDQUFDLEVBQUUsTUFBTSxDQUFDO0NBQ2pDLENBQUM7QUFFRixxQkFBYSxnQkFBZ0IsQ0FBQyxTQUFTLFNBQVMsU0FBUyxHQUFHLFNBQVM7SUFTakUsU0FBUyxDQUFDLFVBQVUsRUFBRSxTQUFTLEVBQUU7SUFSbkMsT0FBTyxDQUFDLEdBQUcsQ0FBUztJQUNwQixPQUFPLENBQUMsTUFBTSxDQUF5QjtJQUN2QyxPQUFPLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyx5QkFBeUIsQ0FBaUI7SU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BzD;IAED;;;;;;OAMG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBlC;IAED;;;;OAIG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAWjC;IAQY,qBAAqB,CAAC,MAAM,GAAE,eAAe,CAAC,SAAS,CAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAwDtG;YAGa,sBAAsB;YAqCtB,cAAc;CAU7B"}
@@ -1,5 +1,7 @@
1
1
  import { pick } from '@aztec/foundation/collection';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { RunningPromise } from '@aztec/foundation/running-promise';
4
+ import { Multicall3 } from './contracts/multicall.js';
3
5
  import { TxUtilsState } from './l1_tx_utils/index.js';
4
6
  // Defines the order in which we prioritise publishers based on their state (first is better)
5
7
  const sortOrder = [
@@ -25,15 +27,72 @@ export class PublisherManager {
25
27
  publishers;
26
28
  log;
27
29
  config;
28
- constructor(publishers, config){
30
+ static FUNDING_CHECK_INTERVAL_MS = 2 * 60 * 1000;
31
+ funder;
32
+ fundingPromise;
33
+ started;
34
+ constructor(publishers, config, opts){
29
35
  this.publishers = publishers;
30
- this.log = createLogger('publisher:manager');
36
+ this.started = false;
37
+ this.funder = opts?.funder;
38
+ this.log = createLogger('publisher:manager', opts?.bindings);
31
39
  this.log.info(`PublisherManager initialized with ${publishers.length} publishers.`);
32
40
  this.publishers = publishers;
33
- this.config = pick(config, 'publisherAllowInvalidStates');
41
+ this.config = pick(config, 'publisherAllowInvalidStates', 'publisherFundingThreshold', 'publisherFundingAmount');
42
+ const hasThreshold = this.config.publisherFundingThreshold !== undefined;
43
+ const hasAmount = this.config.publisherFundingAmount !== undefined;
44
+ if (hasThreshold !== hasAmount) {
45
+ this.log.warn(`Incomplete funding config: both publisherFundingThreshold and publisherFundingAmount must be set`);
46
+ }
47
+ if (this.funder) {
48
+ const funderAddress = this.funder.getSenderAddress();
49
+ if (publishers.some((p)=>p.getSenderAddress().equals(funderAddress))) {
50
+ this.log.error(`Funding account ${funderAddress} is also a publisher, disabling funding to avoid self-funding`);
51
+ this.funder = undefined;
52
+ }
53
+ }
54
+ if (this.funder && hasThreshold && hasAmount) {
55
+ this.fundingPromise = new RunningPromise(()=>this.triggerFundingIfNeeded(), this.log, PublisherManager.FUNDING_CHECK_INTERVAL_MS);
56
+ }
34
57
  }
35
- /** Loads the state of all publishers and resumes monitoring any pending txs */ async loadState() {
36
- await Promise.all(this.publishers.map((pub)=>pub.loadStateAndResumeMonitoring()));
58
+ /**
59
+ * Clears any interrupted flag left by a previous {@link stop} so publishing works again after a restart,
60
+ * loads the state of all publishers and the funder, and starts periodic funding checks. Idempotent: a
61
+ * start while already started is a no-op, so it never re-runs `loadStateAndResumeMonitoring` (which
62
+ * would spawn a duplicate background monitor per pending nonce). Lifecycle calls are expected to be
63
+ * serialized by the caller.
64
+ */ async start() {
65
+ if (this.started) {
66
+ this.log.debug('PublisherManager already started, ignoring start');
67
+ return;
68
+ }
69
+ // Clear the interrupted flag set by a previous stop() so a restarted manager can publish again.
70
+ // On a first start this is a no-op (the flag is already clear).
71
+ this.publishers.forEach((pub)=>pub.restart());
72
+ this.funder?.restart();
73
+ await Promise.all([
74
+ ...this.publishers.map((pub)=>pub.loadStateAndResumeMonitoring()),
75
+ this.funder?.loadStateAndResumeMonitoring()
76
+ ]);
77
+ this.fundingPromise?.start();
78
+ // Marked started only once fully up, so a start that failed to load state can be retried.
79
+ this.started = true;
80
+ }
81
+ /**
82
+ * Stops the funding loop, interrupts all publishers so no further L1 txs are sent, and waits (bounded)
83
+ * for their in-flight tx monitor loops to wind down. Idempotent, and the manager may be restarted
84
+ * afterwards via {@link start}, which clears the interrupted flag.
85
+ */ async stop() {
86
+ this.started = false;
87
+ await this.fundingPromise?.stop();
88
+ this.publishers.forEach((pub)=>pub.interrupt());
89
+ this.funder?.interrupt();
90
+ // Wait for in-flight tx monitor loops to observe the interrupt, so no L1 requests are still
91
+ // being issued after shutdown (e.g. against an anvil instance a test is about to tear down).
92
+ await Promise.all([
93
+ ...this.publishers.map((pub)=>pub.waitMonitoringStopped()),
94
+ this.funder?.waitMonitoringStopped()
95
+ ]);
37
96
  }
38
97
  // Finds and prioritises available publishers based on
39
98
  // 1. Validity as per the provided filter function
@@ -67,8 +126,16 @@ export class PublisherManager {
67
126
  publisher: pub
68
127
  };
69
128
  }));
129
+ // Discount unfunded publishers: a publisher with no ETH cannot send a tx, so it must never win
130
+ // selection regardless of how favourable its state or last-used time is. Fall back to the full
131
+ // set only if every candidate is unfunded, so behaviour is no worse than before.
132
+ let fundedPublishers = publishersWithBalance.filter((p)=>p.balance > 0n);
133
+ if (fundedPublishers.length === 0) {
134
+ this.log.warn(`All candidate publishers have zero balance; selecting from unfunded publishers.`);
135
+ fundedPublishers = publishersWithBalance;
136
+ }
70
137
  // Sort based on state, then balance, then time since last use
71
- const sortedPublishers = publishersWithBalance.sort((a, b)=>{
138
+ const sortedPublishers = fundedPublishers.sort((a, b)=>{
72
139
  const stateComparison = sortOrder.indexOf(a.publisher.state) - sortOrder.indexOf(b.publisher.state);
73
140
  if (stateComparison !== 0) {
74
141
  return stateComparison;
@@ -82,7 +149,51 @@ export class PublisherManager {
82
149
  });
83
150
  return sortedPublishers[0].publisher;
84
151
  }
85
- interrupt() {
86
- this.publishers.forEach((pub)=>pub.interrupt());
152
+ /** Check all publisher balances and fund those below threshold. */ async triggerFundingIfNeeded() {
153
+ const { funder, config } = this;
154
+ if (!funder || config.publisherFundingThreshold === undefined || config.publisherFundingAmount === undefined) {
155
+ return;
156
+ }
157
+ const allBalances = await Promise.all(this.publishers.map(async (pub)=>({
158
+ balance: await pub.getSenderBalance(),
159
+ publisher: pub
160
+ })));
161
+ const lowBalance = allBalances.filter((p)=>p.balance < config.publisherFundingThreshold);
162
+ if (lowBalance.length === 0) {
163
+ return;
164
+ }
165
+ const fundingAmount = config.publisherFundingAmount;
166
+ const funderBalance = await funder.getSenderBalance();
167
+ if (funderBalance < 10n * fundingAmount) {
168
+ this.log.warn(`Funding account balance is low`, {
169
+ funderBalance,
170
+ threshold: 10n * fundingAmount
171
+ });
172
+ }
173
+ const affordableCount = Number(funderBalance / fundingAmount);
174
+ if (affordableCount === 0) {
175
+ this.log.error(`Funding account balance too low to fund any publisher`, {
176
+ funderBalance,
177
+ fundingAmount
178
+ });
179
+ return;
180
+ }
181
+ if (affordableCount < lowBalance.length) {
182
+ this.log.warn(`Funder can only afford ${affordableCount}/${lowBalance.length} publishers`, {
183
+ funderBalance,
184
+ fundingAmount
185
+ });
186
+ }
187
+ const toFund = lowBalance.slice(0, affordableCount).map((p)=>p.publisher);
188
+ await this.fundPublishers(toFund);
189
+ }
190
+ /** Fund publishers via a single Multicall3 aggregate3Value transaction. */ async fundPublishers(publishers) {
191
+ const fundingAmount = this.config.publisherFundingAmount;
192
+ const calls = publishers.map((pub)=>({
193
+ to: pub.getSenderAddress().toString(),
194
+ value: fundingAmount
195
+ }));
196
+ await Multicall3.forwardValue(calls, this.funder, this.log);
197
+ this.log.info(`Funded ${publishers.length} publishers`);
87
198
  }
88
199
  }
package/dest/queries.d.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import type { L1ContractsConfig } from './config.js';
3
- import type { ViemPublicClient } from './types.js';
2
+ import { type Block } from 'viem';
3
+ import { type L1ContractsConfig } from './config.js';
4
+ import type { ViemClient, ViemPublicClient } from './types.js';
5
+ /**
6
+ * Returns the L1 finalized block, or `undefined` if the chain does not yet have one
7
+ * (common on freshly started devnets). Rethrows any other RPC error.
8
+ */
9
+ export declare function getFinalizedL1Block(client: ViemClient): Promise<Block<bigint, false, 'finalized'> | undefined>;
10
+ /**
11
+ * Returns true if the error originates from an RPC call that failed because
12
+ * the "finalized" (or "safe") block tag is not yet available on the chain.
13
+ */
14
+ export declare function isFinalizedBlockTagNotFoundError(err: unknown): boolean;
4
15
  /** Reads the L1ContractsConfig from L1 contracts. */
5
16
  export declare function getL1ContractsConfig(publicClient: ViemPublicClient, addresses: {
6
17
  governanceAddress: EthAddress;
@@ -11,4 +22,4 @@ export declare function getL1ContractsConfig(publicClient: ViemPublicClient, add
11
22
  rollupVersion: number;
12
23
  genesisArchiveTreeRoot: `0x${string}`;
13
24
  }>;
14
- //# sourceMappingURL=queries.d.ts.map
25
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVlcmllcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3F1ZXJpZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE9BQU8sRUFBYSxLQUFLLEtBQUssRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUU3QyxPQUFPLEVBQTRCLEtBQUssaUJBQWlCLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFLL0UsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGdCQUFnQixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRS9EOzs7R0FHRztBQUNILHdCQUFzQixtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsVUFBVSxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUMsTUFBTSxFQUFFLEtBQUssRUFBRSxXQUFXLENBQUMsR0FBRyxTQUFTLENBQUMsQ0FTcEg7QUFtQkQ7OztHQUdHO0FBQ0gsd0JBQWdCLGdDQUFnQyxDQUFDLEdBQUcsRUFBRSxPQUFPLEdBQUcsT0FBTyxDQWtCdEU7QUFVRCxxREFBcUQ7QUFDckQsd0JBQXNCLG9CQUFvQixDQUN4QyxZQUFZLEVBQUUsZ0JBQWdCLEVBQzlCLFNBQVMsRUFBRTtJQUFFLGlCQUFpQixFQUFFLFVBQVUsQ0FBQztJQUFDLGFBQWEsQ0FBQyxFQUFFLFVBQVUsQ0FBQTtDQUFFLEdBQ3ZFLE9BQU8sQ0FDUixJQUFJLENBQUMsaUJBQWlCLEVBQUUsc0JBQXNCLENBQUMsR0FBRztJQUNoRCxZQUFZLEVBQUUsTUFBTSxDQUFDO0lBQ3JCLGFBQWEsRUFBRSxNQUFNLENBQUM7SUFDdEIsYUFBYSxFQUFFLE1BQU0sQ0FBQztJQUN0QixzQkFBc0IsRUFBRSxLQUFLLE1BQU0sRUFBRSxDQUFDO0NBQ3ZDLENBQ0YsQ0E2R0EifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,qDAAqD;AACrD,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE;IAAE,iBAAiB,EAAE,UAAU,CAAC;IAAC,aAAa,CAAC,EAAE,UAAU,CAAA;CAAE,GACvE,OAAO,CACR,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,GAAG;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,KAAK,MAAM,EAAE,CAAC;CACvC,CACF,CA6FA"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAK/E,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC,CASpH;AAmBD;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAkBtE;AAUD,qDAAqD;AACrD,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE;IAAE,iBAAiB,EAAE,UAAU,CAAC;IAAC,aAAa,CAAC,EAAE,UAAU,CAAA;CAAE,GACvE,OAAO,CACR,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,GAAG;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,KAAK,MAAM,EAAE,CAAC;CACvC,CACF,CA6GA"}
package/dest/queries.js CHANGED
@@ -1,7 +1,68 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { BaseError } from 'viem';
3
+ import { DefaultL1ContractsConfig } from './config.js';
2
4
  import { ReadOnlyGovernanceContract } from './contracts/governance.js';
3
5
  import { GovernanceProposerContract } from './contracts/governance_proposer.js';
6
+ import { InboxContract } from './contracts/inbox.js';
4
7
  import { RollupContract } from './contracts/rollup.js';
8
+ /**
9
+ * Returns the L1 finalized block, or `undefined` if the chain does not yet have one
10
+ * (common on freshly started devnets). Rethrows any other RPC error.
11
+ */ export async function getFinalizedL1Block(client) {
12
+ try {
13
+ return await client.getBlock({
14
+ blockTag: 'finalized',
15
+ includeTransactions: false
16
+ });
17
+ } catch (err) {
18
+ if (isFinalizedBlockTagNotFoundError(err)) {
19
+ return undefined;
20
+ }
21
+ throw err;
22
+ }
23
+ }
24
+ // Error messages returned by popular Ethereum execution clients when
25
+ // eth_getBlockByNumber / eth_call is called with blockTag "finalized" or
26
+ // "safe" and no such block has been produced yet:
27
+ //
28
+ // geth "finalized block not found"
29
+ // "safe block not found"
30
+ // reth "block not found: finalized"
31
+ // "block not found: safe"
32
+ // nethermind "Unknown block error" (same for both tags)
33
+ // besu "Unknown block"
34
+ // erigon 'block "finalized" not available (head block: N)'
35
+ // 'block "safe" not available (head block: N)'
36
+ //
37
+ // A combined regex covers all five:
38
+ const FINALIZED_BLOCK_TAG_NOT_FOUND_MESSAGE_RE = /(finalized|safe) block not found|block not found: (finalized|safe)|unknown block|block "(finalized|safe)" not available/i;
39
+ /**
40
+ * Returns true if the error originates from an RPC call that failed because
41
+ * the "finalized" (or "safe") block tag is not yet available on the chain.
42
+ */ export function isFinalizedBlockTagNotFoundError(err) {
43
+ if (!err) {
44
+ return false;
45
+ }
46
+ if (err instanceof BaseError) {
47
+ const hit = err.walk((e)=>matchesFinalizedBlockTagNotFound(e));
48
+ if (hit) {
49
+ return true;
50
+ }
51
+ }
52
+ for(let cur = err, i = 0; cur && i < 10; cur = cur.cause, i++){
53
+ if (matchesFinalizedBlockTagNotFound(cur)) {
54
+ return true;
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+ function matchesFinalizedBlockTagNotFound(e) {
60
+ if (!e) {
61
+ return false;
62
+ }
63
+ const text = `${e.details ?? ''} ${e.message ?? ''} ${e.shortMessage ?? ''}`;
64
+ return FINALIZED_BLOCK_TAG_NOT_FOUND_MESSAGE_RE.test(text);
65
+ }
5
66
  /** Reads the L1ContractsConfig from L1 contracts. */ export async function getL1ContractsConfig(publicClient, addresses) {
6
67
  const governance = new ReadOnlyGovernanceContract(addresses.governanceAddress.toString(), publicClient);
7
68
  const governanceProposerAddress = await governance.getGovernanceProposerAddress();
@@ -10,14 +71,18 @@ import { RollupContract } from './contracts/rollup.js';
10
71
  const rollup = new RollupContract(publicClient, rollupAddress.toString());
11
72
  const slasherProposer = await rollup.getSlashingProposer();
12
73
  const slasher = await rollup.getSlasherContract();
13
- const [l1StartBlock, l1GenesisTime, aztecEpochDuration, aztecSlotDuration, aztecProofSubmissionEpochs, aztecTargetCommitteeSize, lagInEpochs, activationThreshold, ejectionThreshold, localEjectionThreshold, governanceProposerQuorum, governanceProposerRoundSize, slashingQuorum, slashingRoundSize, slashingLifetimeInRounds, slashingExecutionDelayInRounds, slashingOffsetInRounds, slashingAmounts, slashingVetoer, slashingDisableDuration, manaTarget, provingCostPerMana, rollupVersion, genesisArchiveTreeRoot, exitDelay] = await Promise.all([
74
+ const rollupAddresses = await rollup.getRollupAddresses();
75
+ const inboxContract = new InboxContract(publicClient, rollupAddresses.inboxAddress.toString());
76
+ const [l1StartBlock, l1GenesisTime, aztecEpochDuration, aztecSlotDuration, aztecProofSubmissionEpochs, aztecTargetCommitteeSize, lagInEpochsForValidatorSet, lagInEpochsForRandao, inboxLag, activationThreshold, ejectionThreshold, localEjectionThreshold, governanceProposerQuorum, governanceProposerRoundSize, slashingQuorum, slashingRoundSize, slashingLifetimeInRounds, slashingExecutionDelayInRounds, slashingOffsetInRounds, slashingAmounts, slashingVetoer, slashingDisableDuration, manaTarget, provingCostPerMana, rollupVersion, genesisArchiveTreeRoot, exitDelay] = await Promise.all([
14
77
  rollup.getL1StartBlock(),
15
78
  rollup.getL1GenesisTime(),
16
79
  rollup.getEpochDuration(),
17
80
  rollup.getSlotDuration(),
18
81
  rollup.getProofSubmissionEpochs(),
19
82
  rollup.getTargetCommitteeSize(),
20
- rollup.getLagInEpochs(),
83
+ rollup.getLagInEpochsForValidatorSet(),
84
+ rollup.getLagInEpochsForRandao(),
85
+ inboxContract.getLag(),
21
86
  rollup.getActivationThreshold(),
22
87
  rollup.getEjectionThreshold(),
23
88
  rollup.getLocalEjectionThreshold(),
@@ -27,8 +92,8 @@ import { RollupContract } from './contracts/rollup.js';
27
92
  slasherProposer?.getRoundSize() ?? 0n,
28
93
  slasherProposer?.getLifetimeInRounds() ?? 0n,
29
94
  slasherProposer?.getExecutionDelayInRounds() ?? 0n,
30
- slasherProposer?.type === 'tally' ? slasherProposer.getSlashOffsetInRounds() : 0n,
31
- slasherProposer?.type === 'tally' ? slasherProposer.getSlashingAmounts() : [
95
+ slasherProposer?.getSlashOffsetInRounds() ?? 0n,
96
+ slasherProposer?.getSlashingAmounts() ?? [
32
97
  0n,
33
98
  0n,
34
99
  0n
@@ -48,14 +113,17 @@ import { RollupContract } from './contracts/rollup.js';
48
113
  aztecSlotDuration: Number(aztecSlotDuration),
49
114
  aztecProofSubmissionEpochs: Number(aztecProofSubmissionEpochs),
50
115
  aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
51
- lagInEpochs: Number(lagInEpochs),
116
+ lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
117
+ lagInEpochsForRandao: Number(lagInEpochsForRandao),
118
+ inboxLag: Number(inboxLag),
52
119
  governanceProposerQuorum: Number(governanceProposerQuorum),
53
120
  governanceProposerRoundSize: Number(governanceProposerRoundSize),
121
+ governanceVotingDuration: DefaultL1ContractsConfig.governanceVotingDuration,
54
122
  activationThreshold,
55
123
  ejectionThreshold,
56
124
  localEjectionThreshold,
57
125
  slashingQuorum: Number(slashingQuorum),
58
- slashingRoundSizeInEpochs: Number(slashingRoundSize / aztecEpochDuration),
126
+ slashingRoundSizeInEpochs: Number(Number(slashingRoundSize) / aztecEpochDuration),
59
127
  slashingLifetimeInRounds: Number(slashingLifetimeInRounds),
60
128
  slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
61
129
  slashingVetoer,
@@ -63,12 +131,19 @@ import { RollupContract } from './contracts/rollup.js';
63
131
  manaTarget,
64
132
  provingCostPerMana: provingCostPerMana,
65
133
  rollupVersion: Number(rollupVersion),
66
- genesisArchiveTreeRoot,
134
+ genesisArchiveTreeRoot: genesisArchiveTreeRoot.toString(),
67
135
  exitDelaySeconds: Number(exitDelay),
68
- slasherFlavor: slasherProposer?.type ?? 'tally',
136
+ slasherEnabled: !!slasherProposer,
69
137
  slashingOffsetInRounds: Number(slashingOffsetInRounds),
70
138
  slashAmountSmall: slashingAmounts[0],
71
139
  slashAmountMedium: slashingAmounts[1],
72
- slashAmountLarge: slashingAmounts[2]
140
+ slashAmountLarge: slashingAmounts[2],
141
+ initialEthPerFeeAsset: DefaultL1ContractsConfig.initialEthPerFeeAsset,
142
+ // Not exposed by the rollup contract; fall back to defaults like the other non-on-chain fields above.
143
+ entryQueueBootstrapValidatorSetSize: DefaultL1ContractsConfig.entryQueueBootstrapValidatorSetSize,
144
+ entryQueueBootstrapFlushSize: DefaultL1ContractsConfig.entryQueueBootstrapFlushSize,
145
+ entryQueueFlushSizeMin: DefaultL1ContractsConfig.entryQueueFlushSizeMin,
146
+ entryQueueFlushSizeQuotient: DefaultL1ContractsConfig.entryQueueFlushSizeQuotient,
147
+ entryQueueMaxFlushSize: DefaultL1ContractsConfig.entryQueueMaxFlushSize
73
148
  };
74
149
  }
@@ -0,0 +1,19 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ import type { ExtendedViemWalletClient } from '../types.js';
3
+ /**
4
+ * Warms both KZG trusted setups in parallel for tests against a local anvil:
5
+ * - anvil's own setup, loaded lazily when it first validates a blob sidecar in `eth_sendRawTransaction`
6
+ * - our `@crate-crypto/node-eth-kzg` singleton (`getKzg()`, a ~2.2s synchronous precomp build)
7
+ *
8
+ * Without this, the first checkpoint publish pays both serially (~4.4s). The recipe does all RPC round
9
+ * trips up front, fires a single bare raw send carrying a fake (garbage) blob sidecar that anvil rejects
10
+ * after loading its trusted setup, yields once to flush the socket write, then synchronously builds our
11
+ * own precomp tables while anvil warms in parallel. The fake tx is rejected at admission, so it never
12
+ * enters the pool, mines no block, and burns no nonce — sending it from the passed client is harmless.
13
+ *
14
+ * Best-effort: any failure is debug-logged and swallowed, leaving lazy init as the fallback. Never throws.
15
+ *
16
+ * @param l1Client - The L1 client whose account sends the (rejected) warm-up blob tx.
17
+ */
18
+ export declare function warmBlobKzg(l1Client: ExtendedViemWalletClient, logger?: Logger): Promise<void>;
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvYl9remdfd2FybXVwLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9ibG9iX2t6Z193YXJtdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFFNUQ7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCx3QkFBc0IsV0FBVyxDQUFDLFFBQVEsRUFBRSx3QkFBd0IsRUFBRSxNQUFNLENBQUMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTRDcEcifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob_kzg_warmup.d.ts","sourceRoot":"","sources":["../../src/test/blob_kzg_warmup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CpG"}
@@ -0,0 +1,64 @@
1
+ import { getBytesPerBlob, getBytesPerCommitment, getKzg } from '@aztec/blob-lib';
2
+ /**
3
+ * Warms both KZG trusted setups in parallel for tests against a local anvil:
4
+ * - anvil's own setup, loaded lazily when it first validates a blob sidecar in `eth_sendRawTransaction`
5
+ * - our `@crate-crypto/node-eth-kzg` singleton (`getKzg()`, a ~2.2s synchronous precomp build)
6
+ *
7
+ * Without this, the first checkpoint publish pays both serially (~4.4s). The recipe does all RPC round
8
+ * trips up front, fires a single bare raw send carrying a fake (garbage) blob sidecar that anvil rejects
9
+ * after loading its trusted setup, yields once to flush the socket write, then synchronously builds our
10
+ * own precomp tables while anvil warms in parallel. The fake tx is rejected at admission, so it never
11
+ * enters the pool, mines no block, and burns no nonce — sending it from the passed client is harmless.
12
+ *
13
+ * Best-effort: any failure is debug-logged and swallowed, leaving lazy init as the fallback. Never throws.
14
+ *
15
+ * @param l1Client - The L1 client whose account sends the (rejected) warm-up blob tx.
16
+ */ export async function warmBlobKzg(l1Client, logger) {
17
+ try {
18
+ // A pure-JS fake kzg: returns deterministic garbage of the correct lengths (commitment and proof are
19
+ // both 48 bytes). It makes viem build a syntactically valid sidecar without initializing any native
20
+ // module, so anvil loads its trusted setup to validate the (invalid) proof and then rejects the tx.
21
+ const fakeKzg = {
22
+ blobToKzgCommitment: ()=>{
23
+ const commitment = new Uint8Array(getBytesPerCommitment());
24
+ commitment.fill(0xab);
25
+ commitment[0] = 0xc0;
26
+ return commitment;
27
+ },
28
+ computeBlobKzgProof: ()=>{
29
+ const proof = new Uint8Array(getBytesPerCommitment());
30
+ proof.fill(0xcd);
31
+ proof[0] = 0xc0;
32
+ return proof;
33
+ }
34
+ };
35
+ // All RPC round trips (nonce, fees, gas) happen here, so only a single socket write remains to flush.
36
+ const prepared = await l1Client.prepareTransactionRequest({
37
+ blobs: [
38
+ new Uint8Array(getBytesPerBlob())
39
+ ],
40
+ kzg: fakeKzg,
41
+ to: '0x0000000000000000000000000000000000000000',
42
+ value: 0n,
43
+ maxFeePerBlobGas: 1_000_000_000_000n
44
+ });
45
+ const serialized = await l1Client.signTransaction(prepared);
46
+ // Fire the raw send without awaiting and swallow the expected rejection.
47
+ const sent = l1Client.request({
48
+ method: 'eth_sendRawTransaction',
49
+ params: [
50
+ serialized
51
+ ]
52
+ }).catch(()=>{});
53
+ // Flush the single socket write so anvil receives the tx and starts loading its trusted setup in its
54
+ // own process before we block the event loop below.
55
+ await new Promise((resolve)=>setImmediate(resolve));
56
+ // Synchronously build our precomp tables (~2.2s, event-loop-blocking); anvil warms in parallel.
57
+ getKzg();
58
+ await sent;
59
+ } catch (err) {
60
+ logger?.debug('Failed to warm blob KZG; falling back to lazy init', {
61
+ err
62
+ });
63
+ }
64
+ }