@aztec/stdlib 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942

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 (267) hide show
  1. package/dest/abi/authorization_selector.d.ts +3 -6
  2. package/dest/abi/authorization_selector.d.ts.map +1 -1
  3. package/dest/abi/encoder.d.ts +1 -1
  4. package/dest/abi/encoder.d.ts.map +1 -1
  5. package/dest/abi/encoder.js +32 -6
  6. package/dest/abi/event_selector.d.ts +3 -6
  7. package/dest/abi/event_selector.d.ts.map +1 -1
  8. package/dest/abi/function_selector.d.ts +3 -6
  9. package/dest/abi/function_selector.d.ts.map +1 -1
  10. package/dest/abi/function_selector.js +1 -3
  11. package/dest/abi/note_selector.d.ts +3 -6
  12. package/dest/abi/note_selector.d.ts.map +1 -1
  13. package/dest/abi/note_selector.js +1 -3
  14. package/dest/abi/selector.d.ts +2 -2
  15. package/dest/abi/selector.d.ts.map +1 -1
  16. package/dest/abi/selector.js +1 -1
  17. package/dest/avm/avm.d.ts +300 -300
  18. package/dest/avm/revert_code.d.ts +8 -18
  19. package/dest/avm/revert_code.d.ts.map +1 -1
  20. package/dest/avm/revert_code.js +15 -30
  21. package/dest/aztec-address/index.d.ts +3 -6
  22. package/dest/aztec-address/index.d.ts.map +1 -1
  23. package/dest/aztec-address/index.js +2 -4
  24. package/dest/block/block_data.d.ts +8 -8
  25. package/dest/block/block_data.d.ts.map +1 -1
  26. package/dest/block/block_data.js +2 -2
  27. package/dest/block/block_hash.d.ts +11 -10
  28. package/dest/block/block_hash.d.ts.map +1 -1
  29. package/dest/block/block_hash.js +10 -9
  30. package/dest/block/l2_block_info.d.ts +6 -5
  31. package/dest/block/l2_block_info.d.ts.map +1 -1
  32. package/dest/block/l2_block_info.js +6 -5
  33. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  34. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  35. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  36. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  37. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  38. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  39. package/dest/config/chain-config.d.ts +1 -1
  40. package/dest/config/chain-config.d.ts.map +1 -1
  41. package/dest/config/chain-config.js +7 -1
  42. package/dest/config/sequencer-config.d.ts +2 -2
  43. package/dest/config/sequencer-config.d.ts.map +1 -1
  44. package/dest/config/sequencer-config.js +10 -3
  45. package/dest/contract/private_function.d.ts +1 -1
  46. package/dest/contract/private_function.d.ts.map +1 -1
  47. package/dest/contract/private_function.js +2 -4
  48. package/dest/gas/fee_math.d.ts +49 -0
  49. package/dest/gas/fee_math.d.ts.map +1 -0
  50. package/dest/gas/fee_math.js +80 -0
  51. package/dest/gas/gas_fees.d.ts +5 -1
  52. package/dest/gas/gas_fees.d.ts.map +1 -1
  53. package/dest/gas/gas_fees.js +10 -1
  54. package/dest/gas/gas_settings.d.ts +40 -3
  55. package/dest/gas/gas_settings.d.ts.map +1 -1
  56. package/dest/gas/gas_settings.js +50 -6
  57. package/dest/gas/index.d.ts +2 -1
  58. package/dest/gas/index.d.ts.map +1 -1
  59. package/dest/gas/index.js +1 -0
  60. package/dest/ha-signing/config.d.ts +6 -6
  61. package/dest/ha-signing/config.d.ts.map +1 -1
  62. package/dest/ha-signing/config.js +4 -3
  63. package/dest/ha-signing/index.d.ts +2 -2
  64. package/dest/ha-signing/index.d.ts.map +1 -1
  65. package/dest/ha-signing/index.js +1 -1
  66. package/dest/ha-signing/local_config.js +1 -1
  67. package/dest/ha-signing/types.d.ts +37 -32
  68. package/dest/ha-signing/types.d.ts.map +1 -1
  69. package/dest/ha-signing/types.js +13 -6
  70. package/dest/hash/hash.d.ts +16 -1
  71. package/dest/hash/hash.d.ts.map +1 -1
  72. package/dest/hash/hash.js +32 -0
  73. package/dest/interfaces/archiver.d.ts +11 -1
  74. package/dest/interfaces/archiver.d.ts.map +1 -1
  75. package/dest/interfaces/archiver.js +3 -1
  76. package/dest/interfaces/aztec-node-admin.d.ts +9 -14
  77. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  78. package/dest/interfaces/aztec-node-admin.js +3 -3
  79. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  80. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  81. package/dest/interfaces/aztec-node-debug.js +18 -0
  82. package/dest/interfaces/aztec-node.d.ts +10 -1
  83. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  84. package/dest/interfaces/aztec-node.js +2 -0
  85. package/dest/interfaces/client.d.ts +2 -1
  86. package/dest/interfaces/client.d.ts.map +1 -1
  87. package/dest/interfaces/client.js +1 -0
  88. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  89. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  90. package/dest/interfaces/prover-client.d.ts +1 -1
  91. package/dest/interfaces/prover-client.d.ts.map +1 -1
  92. package/dest/interfaces/prover-client.js +0 -3
  93. package/dest/interfaces/slasher.d.ts +1 -10
  94. package/dest/interfaces/slasher.d.ts.map +1 -1
  95. package/dest/interfaces/slasher.js +0 -2
  96. package/dest/interfaces/validator.d.ts +14 -17
  97. package/dest/interfaces/validator.d.ts.map +1 -1
  98. package/dest/l1-contracts/index.d.ts +2 -2
  99. package/dest/l1-contracts/index.d.ts.map +1 -1
  100. package/dest/l1-contracts/index.js +1 -1
  101. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  102. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  103. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  104. package/dest/logs/log_id.d.ts +1 -1
  105. package/dest/logs/log_id.d.ts.map +1 -1
  106. package/dest/logs/log_id.js +1 -2
  107. package/dest/logs/siloed_tag.d.ts +5 -7
  108. package/dest/logs/siloed_tag.d.ts.map +1 -1
  109. package/dest/logs/siloed_tag.js +4 -0
  110. package/dest/logs/tag.d.ts +5 -6
  111. package/dest/logs/tag.d.ts.map +1 -1
  112. package/dest/logs/tag.js +4 -0
  113. package/dest/p2p/block_proposal.d.ts +6 -8
  114. package/dest/p2p/block_proposal.d.ts.map +1 -1
  115. package/dest/p2p/block_proposal.js +4 -9
  116. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  117. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  118. package/dest/p2p/checkpoint_attestation.js +2 -7
  119. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  120. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  121. package/dest/p2p/checkpoint_proposal.js +5 -24
  122. package/dest/p2p/gossipable.d.ts +4 -4
  123. package/dest/p2p/gossipable.d.ts.map +1 -1
  124. package/dest/rollup/block_headers_hash.d.ts +1 -1
  125. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  126. package/dest/rollup/block_headers_hash.js +8 -2
  127. package/dest/slashing/index.d.ts +2 -3
  128. package/dest/slashing/index.d.ts.map +1 -1
  129. package/dest/slashing/index.js +1 -2
  130. package/dest/slashing/serialization.d.ts +2 -6
  131. package/dest/slashing/serialization.d.ts.map +1 -1
  132. package/dest/slashing/serialization.js +0 -60
  133. package/dest/slashing/types.d.ts +4 -90
  134. package/dest/slashing/types.d.ts.map +1 -1
  135. package/dest/slashing/types.js +0 -14
  136. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  137. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  138. package/dest/slashing/{tally.js → votes.js} +1 -1
  139. package/dest/tests/factories.d.ts +2 -7
  140. package/dest/tests/factories.d.ts.map +1 -1
  141. package/dest/tests/factories.js +2 -8
  142. package/dest/tests/mocks.d.ts +1 -1
  143. package/dest/tests/mocks.d.ts.map +1 -1
  144. package/dest/tests/mocks.js +14 -19
  145. package/dest/timetable/index.d.ts +51 -1
  146. package/dest/timetable/index.d.ts.map +1 -1
  147. package/dest/timetable/index.js +204 -14
  148. package/dest/trees/nullifier_leaf.d.ts +2 -1
  149. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  150. package/dest/trees/nullifier_leaf.js +3 -0
  151. package/dest/tx/block_header.d.ts +2 -2
  152. package/dest/tx/block_header.d.ts.map +1 -1
  153. package/dest/tx/block_header.js +1 -1
  154. package/dest/tx/fee_provider.d.ts +10 -0
  155. package/dest/tx/fee_provider.d.ts.map +1 -0
  156. package/dest/tx/fee_provider.js +1 -0
  157. package/dest/tx/global_variable_builder.d.ts +3 -16
  158. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  159. package/dest/tx/index.d.ts +2 -1
  160. package/dest/tx/index.d.ts.map +1 -1
  161. package/dest/tx/index.js +1 -0
  162. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  163. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  164. package/dest/tx/indexed_tx_effect.js +1 -2
  165. package/dest/tx/simulated_tx.d.ts +4 -4
  166. package/dest/tx/simulated_tx.d.ts.map +1 -1
  167. package/dest/tx/simulated_tx.js +3 -3
  168. package/dest/tx/tx.d.ts +3 -3
  169. package/dest/tx/tx.d.ts.map +1 -1
  170. package/dest/tx/tx_receipt.d.ts +8 -4
  171. package/dest/tx/tx_receipt.d.ts.map +1 -1
  172. package/dest/tx/tx_receipt.js +8 -15
  173. package/dest/types/shared.d.ts +1 -10
  174. package/dest/types/shared.d.ts.map +1 -1
  175. package/dest/types/shared.js +0 -9
  176. package/dest/vks/verification_key.d.ts +2 -137
  177. package/dest/vks/verification_key.d.ts.map +1 -1
  178. package/dest/vks/verification_key.js +5 -126
  179. package/dest/world-state/genesis_data.d.ts +11 -0
  180. package/dest/world-state/genesis_data.d.ts.map +1 -0
  181. package/dest/world-state/genesis_data.js +4 -0
  182. package/dest/world-state/index.d.ts +2 -1
  183. package/dest/world-state/index.d.ts.map +1 -1
  184. package/dest/world-state/index.js +1 -0
  185. package/dest/world-state/world_state_revision.d.ts +8 -1
  186. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  187. package/dest/world-state/world_state_revision.js +7 -1
  188. package/package.json +8 -8
  189. package/src/abi/authorization_selector.ts +2 -8
  190. package/src/abi/encoder.ts +42 -6
  191. package/src/abi/event_selector.ts +2 -8
  192. package/src/abi/function_selector.ts +3 -12
  193. package/src/abi/note_selector.ts +3 -12
  194. package/src/abi/selector.ts +1 -1
  195. package/src/avm/revert_code.ts +25 -39
  196. package/src/aztec-address/index.ts +4 -10
  197. package/src/block/block_data.ts +3 -4
  198. package/src/block/block_hash.ts +21 -14
  199. package/src/block/l2_block_info.ts +8 -6
  200. package/src/block/l2_block_stream/interfaces.ts +6 -2
  201. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  202. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  203. package/src/config/chain-config.ts +7 -1
  204. package/src/config/sequencer-config.ts +14 -4
  205. package/src/contract/private_function.ts +3 -1
  206. package/src/gas/README.md +31 -0
  207. package/src/gas/fee_math.ts +120 -0
  208. package/src/gas/gas_fees.ts +17 -4
  209. package/src/gas/gas_settings.ts +65 -12
  210. package/src/gas/index.ts +1 -0
  211. package/src/ha-signing/config.ts +5 -2
  212. package/src/ha-signing/index.ts +3 -1
  213. package/src/ha-signing/local_config.ts +1 -1
  214. package/src/ha-signing/types.ts +48 -34
  215. package/src/hash/hash.ts +27 -0
  216. package/src/interfaces/archiver.ts +8 -0
  217. package/src/interfaces/aztec-node-admin.ts +5 -7
  218. package/src/interfaces/aztec-node-debug.ts +40 -0
  219. package/src/interfaces/aztec-node.ts +15 -0
  220. package/src/interfaces/client.ts +1 -0
  221. package/src/interfaces/merkle_tree_operations.ts +3 -2
  222. package/src/interfaces/prover-client.ts +2 -5
  223. package/src/interfaces/slasher.ts +0 -6
  224. package/src/interfaces/validator.ts +15 -8
  225. package/src/l1-contracts/index.ts +1 -1
  226. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  227. package/src/logs/log_id.ts +1 -2
  228. package/src/logs/siloed_tag.ts +8 -9
  229. package/src/logs/tag.ts +8 -8
  230. package/src/p2p/block_proposal.ts +13 -9
  231. package/src/p2p/checkpoint_attestation.ts +5 -9
  232. package/src/p2p/checkpoint_proposal.ts +21 -36
  233. package/src/p2p/gossipable.ts +4 -4
  234. package/src/rollup/block_headers_hash.ts +11 -2
  235. package/src/slashing/index.ts +1 -2
  236. package/src/slashing/serialization.ts +1 -81
  237. package/src/slashing/types.ts +3 -35
  238. package/src/slashing/{tally.ts → votes.ts} +1 -1
  239. package/src/tests/factories.ts +2 -10
  240. package/src/tests/mocks.ts +16 -12
  241. package/src/timetable/index.ts +293 -13
  242. package/src/trees/nullifier_leaf.ts +4 -0
  243. package/src/tx/block_header.ts +2 -2
  244. package/src/tx/fee_provider.ts +10 -0
  245. package/src/tx/global_variable_builder.ts +2 -18
  246. package/src/tx/index.ts +1 -0
  247. package/src/tx/indexed_tx_effect.ts +1 -2
  248. package/src/tx/simulated_tx.ts +6 -2
  249. package/src/tx/tx.ts +2 -2
  250. package/src/tx/tx_receipt.ts +11 -14
  251. package/src/types/shared.ts +0 -10
  252. package/src/vks/verification_key.ts +5 -184
  253. package/src/world-state/genesis_data.ts +15 -0
  254. package/src/world-state/index.ts +1 -0
  255. package/src/world-state/world_state_revision.ts +9 -1
  256. package/dest/abi/mocked_keys.d.ts +0 -2
  257. package/dest/abi/mocked_keys.d.ts.map +0 -1
  258. package/dest/abi/mocked_keys.js +0 -1
  259. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  260. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  261. package/dest/l1-contracts/slash_factory.js +0 -158
  262. package/dest/slashing/empire.d.ts +0 -31
  263. package/dest/slashing/empire.d.ts.map +0 -1
  264. package/dest/slashing/empire.js +0 -87
  265. package/src/abi/mocked_keys.ts +0 -2
  266. package/src/l1-contracts/slash_factory.ts +0 -180
  267. package/src/slashing/empire.ts +0 -104
@@ -0,0 +1,120 @@
1
+ /**
2
+ * TypeScript port of fee computation logic from FeeLib.sol.
3
+ * Used to predict worst-case min fees over a future window of L2 slots.
4
+ */
5
+
6
+ // Constants matching FeeLib.sol
7
+ export const MINIMUM_CONGESTION_MULTIPLIER = 1_000_000_000n;
8
+ export const L1_GAS_PER_CHECKPOINT_PROPOSED = 300_000n;
9
+ export const L1_GAS_PER_EPOCH_VERIFIED = 3_600_000n;
10
+ export const BLOBS_PER_CHECKPOINT = 3n;
11
+ export const BLOB_GAS_PER_BLOB = 2n ** 17n;
12
+ export const MAGIC_CONGESTION_VALUE_MULTIPLIER = 854_700_854n;
13
+ export const MAGIC_CONGESTION_VALUE_DIVISOR = 100_000_000n;
14
+ export const ETH_PER_FEE_ASSET_PRECISION = 1_000_000_000_000n;
15
+ export const MIN_ETH_PER_FEE_ASSET = 100n;
16
+
17
+ /** Number of L2 slots of lag before new oracle values activate. Defines the prediction window. */
18
+ export const FEE_ORACLE_LAG = 2;
19
+
20
+ /** Expected mana usage per checkpoint for fee prediction. */
21
+ export enum ManaUsageEstimate {
22
+ /** No usage — fees decrease as congestion drains. */
23
+ None = 'none',
24
+ /** Target usage — congestion stays roughly flat (steady state). */
25
+ Target = 'target',
26
+ /** Limit usage (2x target) — worst case, congestion grows maximally. */
27
+ Limit = 'limit',
28
+ }
29
+
30
+ /** Parameters for computing the mana min fee at a given point in time. */
31
+ export type ManaMinFeeParams = {
32
+ l1BaseFee: bigint;
33
+ l1BlobFee: bigint;
34
+ manaTarget: bigint;
35
+ epochDuration: bigint;
36
+ provingCostPerManaEth: bigint;
37
+ excessMana: bigint;
38
+ ethPerFeeAsset: bigint;
39
+ };
40
+
41
+ /**
42
+ * Taylor series approximation of `factor * e^(numerator/denominator)`.
43
+ * Direct port of FeeLib.sol fakeExponential (EIP-4844 style).
44
+ */
45
+ export function fakeExponential(factor: bigint, numerator: bigint, denominator: bigint): bigint {
46
+ let i = 1n;
47
+ let output = 0n;
48
+ let numeratorAccumulator = factor * denominator;
49
+ while (numeratorAccumulator > 0n) {
50
+ output += numeratorAccumulator;
51
+ numeratorAccumulator = (numeratorAccumulator * numerator) / (denominator * i);
52
+ i += 1n;
53
+ }
54
+ return output / denominator;
55
+ }
56
+
57
+ /** Computes excess mana for the next checkpoint, clamped to zero. */
58
+ export function computeExcessMana(prevExcessMana: bigint, prevManaUsed: bigint, manaTarget: bigint): bigint {
59
+ const sum = prevExcessMana + prevManaUsed;
60
+ return sum > manaTarget ? sum - manaTarget : 0n;
61
+ }
62
+
63
+ /** Computes the congestion multiplier from excess mana (1e9 = no congestion). */
64
+ export function computeCongestionMultiplier(excessMana: bigint, manaTarget: bigint): bigint {
65
+ const denominator = (manaTarget * MAGIC_CONGESTION_VALUE_MULTIPLIER) / MAGIC_CONGESTION_VALUE_DIVISOR;
66
+ const cappedNumerator = excessMana < denominator * 100n ? excessMana : denominator * 100n;
67
+ return fakeExponential(MINIMUM_CONGESTION_MULTIPLIER, cappedNumerator, denominator);
68
+ }
69
+
70
+ /** Ceiling division for positive bigints. */
71
+ function ceilDiv(a: bigint, b: bigint): bigint {
72
+ return (a + b - 1n) / b;
73
+ }
74
+
75
+ /** Converts an ETH value to fee asset value using ethPerFeeAsset (1e12 precision). */
76
+ function toFeeAsset(ethValue: bigint, ethPerFeeAsset: bigint): bigint {
77
+ if (ethPerFeeAsset === 0n) {
78
+ return 0n;
79
+ }
80
+ return ceilDiv(ethValue * ETH_PER_FEE_ASSET_PRECISION, ethPerFeeAsset);
81
+ }
82
+
83
+ /**
84
+ * Computes the full mana min fee (sequencer + prover + congestion) in fee asset terms.
85
+ * Mirrors FeeLib.getManaMinFeeComponentsAt + summedMinFee.
86
+ */
87
+ export function computeManaMinFee(params: ManaMinFeeParams): bigint {
88
+ const { l1BaseFee, l1BlobFee, manaTarget, epochDuration, provingCostPerManaEth, excessMana, ethPerFeeAsset } = params;
89
+
90
+ if (manaTarget === 0n) {
91
+ return 0n;
92
+ }
93
+
94
+ // Sequencer cost per mana (in ETH)
95
+ const ethUsed = L1_GAS_PER_CHECKPOINT_PROPOSED * l1BaseFee + BLOBS_PER_CHECKPOINT * BLOB_GAS_PER_BLOB * l1BlobFee;
96
+ const sequencerCostEth = ceilDiv(ethUsed, manaTarget);
97
+
98
+ // Prover cost per mana (in ETH): L1 verification gas + governance-set proving cost
99
+ const proverCostEth =
100
+ ceilDiv(ceilDiv(L1_GAS_PER_EPOCH_VERIFIED * l1BaseFee, epochDuration), manaTarget) + provingCostPerManaEth;
101
+
102
+ // Total base cost in ETH (congestion is computed on this)
103
+ const totalEth = sequencerCostEth + proverCostEth;
104
+
105
+ // Congestion multiplier and cost (in ETH)
106
+ const congestionMul = computeCongestionMultiplier(excessMana, manaTarget);
107
+ const congestionCostEth = (totalEth * congestionMul) / MINIMUM_CONGESTION_MULTIPLIER - totalEth;
108
+
109
+ // Convert all components to fee asset
110
+ const clampedEthPerFeeAsset = ethPerFeeAsset < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : ethPerFeeAsset;
111
+ const sequencerCost = toFeeAsset(sequencerCostEth, clampedEthPerFeeAsset);
112
+ const proverCost = toFeeAsset(proverCostEth, clampedEthPerFeeAsset);
113
+ const congestionCost = toFeeAsset(congestionCostEth, clampedEthPerFeeAsset);
114
+
115
+ const total = sequencerCost + proverCost + congestionCost;
116
+
117
+ // Cap at uint128 max (matching FeeLib.summedMinFee)
118
+ const UINT128_MAX = (1n << 128n) - 1n;
119
+ return total < UINT128_MAX ? total : UINT128_MAX;
120
+ }
@@ -15,6 +15,17 @@ import { z } from 'zod';
15
15
  import type { UInt128 } from '../types/shared.js';
16
16
  import type { GasDimensions } from './gas.js';
17
17
 
18
+ /**
19
+ * Multiplies a bigint by a non-integer scalar and returns the ceiling of the result.
20
+ * Avoids converting the bigint to Number (which loses precision above 2^53) by instead
21
+ * scaling the scalar into a bigint rational and performing ceiling division.
22
+ */
23
+ function bigintMulCeil(value: bigint, scalar: number): bigint {
24
+ const SCALE = 1_000_000_000_000n; // 1e12
25
+ const scaledScalar = BigInt(Math.round(scalar * 1e12));
26
+ return (value * scaledScalar + SCALE - 1n) / SCALE;
27
+ }
28
+
18
29
  /** Gas prices for each dimension. */
19
30
  export class GasFees {
20
31
  public readonly feePerDaGas: UInt128;
@@ -60,10 +71,7 @@ export class GasFees {
60
71
  const s = BigInt(scalar);
61
72
  return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
62
73
  } else {
63
- return new GasFees(
64
- BigInt(Math.ceil(Number(this.feePerDaGas) * scalar)),
65
- BigInt(Math.ceil(Number(this.feePerL2Gas) * scalar)),
66
- );
74
+ return new GasFees(bigintMulCeil(this.feePerDaGas, scalar), bigintMulCeil(this.feePerL2Gas, scalar));
67
75
  }
68
76
  }
69
77
 
@@ -126,3 +134,8 @@ export class GasFees {
126
134
  return `GasFees { feePerDaGas=${this.feePerDaGas} feePerL2Gas=${this.feePerL2Gas} }`;
127
135
  }
128
136
  }
137
+
138
+ /** Provides projected minimum gas fees for the next block. */
139
+ export interface BlockMinFeesProvider {
140
+ getCurrentMinFees(): Promise<GasFees>;
141
+ }
@@ -1,10 +1,4 @@
1
- import {
2
- DEFAULT_DA_GAS_LIMIT,
3
- DEFAULT_L2_GAS_LIMIT,
4
- DEFAULT_TEARDOWN_DA_GAS_LIMIT,
5
- DEFAULT_TEARDOWN_L2_GAS_LIMIT,
6
- GAS_SETTINGS_LENGTH,
7
- } from '@aztec/constants';
1
+ import { GAS_SETTINGS_LENGTH, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
8
2
  import { Fr } from '@aztec/foundation/curves/bn254';
9
3
  import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
10
4
  import type { FieldsOf } from '@aztec/foundation/types';
@@ -14,6 +8,21 @@ import { z } from 'zod';
14
8
  import { Gas, GasDimensions } from './gas.js';
15
9
  import { GasFees } from './gas_fees.js';
16
10
 
11
+ /** Approximate max DA gas limit. Arbitrary, assuming 4 blocks per checkpoint — users should use gas estimation. */
12
+ export const APPROXIMATE_MAX_DA_GAS_PER_BLOCK = Math.floor(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT / 4);
13
+ /** Fallback teardown L2 gas limit. Arbitrary — users should use gas estimation. */
14
+ export const FALLBACK_TEARDOWN_L2_GAS_LIMIT = Math.floor(MAX_PROCESSABLE_L2_GAS / 8);
15
+ /** Fallback teardown DA gas limit. Arbitrary — users should use gas estimation. */
16
+ export const FALLBACK_TEARDOWN_DA_GAS_LIMIT = Math.floor(APPROXIMATE_MAX_DA_GAS_PER_BLOCK / 2);
17
+
18
+ // For gas estimation, we use intentionally high limits above what the network can process,
19
+ // so the simulation runs without hitting gas caps. Since teardown gas is counted towards total,
20
+ // the total estimation limit is teardown + max processable.
21
+ export const GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT = MAX_PROCESSABLE_L2_GAS;
22
+ export const GAS_ESTIMATION_L2_GAS_LIMIT = GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT + MAX_PROCESSABLE_L2_GAS;
23
+ export const GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
24
+ export const GAS_ESTIMATION_DA_GAS_LIMIT = GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT + MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
25
+
17
26
  // docs:start:gas_settings_vars
18
27
  /** Gas usage and fees limits set by the transaction sender for different dimensions and phases. */
19
28
  export class GasSettings {
@@ -95,18 +104,62 @@ export class GasSettings {
95
104
  return new GasSettings(Gas.empty(), Gas.empty(), GasFees.empty(), GasFees.empty());
96
105
  }
97
106
 
98
- /** Default gas settings to use when user has not provided them. Requires explicit max fees per gas. */
99
- static default(overrides: {
107
+ /**
108
+ * Fills in gas limits high enough for transactions to be included in most cases.
109
+ * gasLimits is set to the maximum the protocol allows; since teardown gas is reserved
110
+ * from gasLimits during private execution (see gas_meter.nr), the effective gas available
111
+ * for app logic will be gasLimits - teardownGasLimits - privateOverhead.
112
+ * The DA gas limit is set to an approximate max per block assuming 4 blocks per checkpoint,
113
+ * since using the maximum per checkpoint would cause nodes to reject transactions.
114
+ * These values won't work if:
115
+ * - Teardown consumes more than the arbitrarily assigned fallback limits
116
+ * - The rest of the transaction consumes more than the remaining gas after teardown
117
+ * - The DA gas limit is too low for the transaction, while still within the checkpoint limit
118
+ */
119
+ static fallback(overrides: {
120
+ gasLimits?: Gas;
121
+ teardownGasLimits?: Gas;
122
+ maxFeesPerGas: GasFees;
123
+ maxPriorityFeesPerGas?: GasFees;
124
+ }) {
125
+ return GasSettings.from({
126
+ gasLimits: overrides.gasLimits ?? {
127
+ l2Gas: MAX_PROCESSABLE_L2_GAS,
128
+ daGas: APPROXIMATE_MAX_DA_GAS_PER_BLOCK,
129
+ },
130
+ teardownGasLimits: overrides.teardownGasLimits ?? {
131
+ l2Gas: FALLBACK_TEARDOWN_L2_GAS_LIMIT,
132
+ daGas: FALLBACK_TEARDOWN_DA_GAS_LIMIT,
133
+ },
134
+ maxFeesPerGas: overrides.maxFeesPerGas,
135
+ maxPriorityFeesPerGas: overrides.maxPriorityFeesPerGas ?? GasFees.empty(),
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Gas settings for simulation/estimation only.
141
+ * Since teardown gas is reserved upfront from gasLimits during private execution (see gas_meter.nr),
142
+ * the effective gas available for app logic is gasLimits - teardownGasLimits - privateOverhead.
143
+ * To ensure estimation never hits gas caps, we set both limits above what the protocol allows:
144
+ * teardown gets MAX_PROCESSABLE and gasLimits gets teardown + MAX_PROCESSABLE, so the full
145
+ * processable amount remains available for each phase independently. To be used in conjunction
146
+ * with skipTxValidation: true during public simulation, or the node would reject the transaction
147
+ * outright due to gas limits being above protocol max.
148
+ */
149
+ static forEstimation(overrides: {
100
150
  gasLimits?: Gas;
101
151
  teardownGasLimits?: Gas;
102
152
  maxFeesPerGas: GasFees;
103
153
  maxPriorityFeesPerGas?: GasFees;
104
154
  }) {
105
155
  return GasSettings.from({
106
- gasLimits: overrides.gasLimits ?? { l2Gas: DEFAULT_L2_GAS_LIMIT, daGas: DEFAULT_DA_GAS_LIMIT },
156
+ gasLimits: overrides.gasLimits ?? {
157
+ l2Gas: GAS_ESTIMATION_L2_GAS_LIMIT,
158
+ daGas: GAS_ESTIMATION_DA_GAS_LIMIT,
159
+ },
107
160
  teardownGasLimits: overrides.teardownGasLimits ?? {
108
- l2Gas: DEFAULT_TEARDOWN_L2_GAS_LIMIT,
109
- daGas: DEFAULT_TEARDOWN_DA_GAS_LIMIT,
161
+ l2Gas: GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
162
+ daGas: GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT,
110
163
  },
111
164
  maxFeesPerGas: overrides.maxFeesPerGas,
112
165
  maxPriorityFeesPerGas: overrides.maxPriorityFeesPerGas ?? GasFees.empty(),
package/src/gas/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './fee_math.js';
1
2
  export * from './gas.js';
2
3
  export * from './gas_fees.js';
3
4
  export * from './gas_settings.js';
@@ -1,11 +1,13 @@
1
1
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
2
  import {
3
3
  type ConfigMappingsType,
4
+ SecretValue,
4
5
  booleanConfigHelper,
5
6
  getConfigFromMappings,
6
7
  getDefaultConfig,
7
8
  numberConfigHelper,
8
9
  optionalNumberConfigHelper,
10
+ secretStringConfigHelper,
9
11
  } from '@aztec/foundation/config';
10
12
  import { EthAddress } from '@aztec/foundation/eth-address';
11
13
  import type { ZodFor } from '@aztec/foundation/schemas';
@@ -88,7 +90,7 @@ export interface ValidatorHASignerConfig extends BaseSignerConfig {
88
90
  * PostgreSQL connection string
89
91
  * Format: postgresql://user:password@host:port/database
90
92
  */
91
- databaseUrl?: string;
93
+ databaseUrl?: SecretValue<string>;
92
94
  /** Maximum number of clients in the pool (default: 10) */
93
95
  poolMaxCount?: number;
94
96
  /** Minimum number of clients in the pool (default: 0) */
@@ -110,6 +112,7 @@ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASign
110
112
  env: 'VALIDATOR_HA_DATABASE_URL',
111
113
  description:
112
114
  'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
115
+ ...secretStringConfigHelper(),
113
116
  },
114
117
  poolMaxCount: {
115
118
  env: 'VALIDATOR_HA_POOL_MAX',
@@ -148,7 +151,7 @@ export function getConfigEnvVars(): ValidatorHASignerConfig {
148
151
 
149
152
  export const ValidatorHASignerConfigSchema = BaseSignerConfigSchema.extend({
150
153
  haSigningEnabled: z.boolean(),
151
- databaseUrl: z.string().optional(),
154
+ databaseUrl: SecretValue.schema(z.string()).optional(),
152
155
  poolMaxCount: z.number().min(0).optional(),
153
156
  poolMinCount: z.number().min(0).optional(),
154
157
  poolIdleTimeoutMs: z.number().min(0).optional(),
@@ -16,12 +16,14 @@ export {
16
16
  } from './local_config.js';
17
17
  export {
18
18
  DutyType,
19
+ type AttestationSigningContext,
19
20
  type BlockProposalSigningContext,
21
+ type CheckpointProposalSigningContext,
20
22
  type HAProtectedSigningContext,
21
23
  type NoHAProtectionSigningContext,
22
- type OtherSigningContext,
23
24
  type SigningContext,
24
25
  type VoteSigningContext,
25
26
  getBlockNumberFromSigningContext,
27
+ getCheckpointNumberFromSigningContext,
26
28
  isHAProtectedContext,
27
29
  } from './types.js';
@@ -26,7 +26,7 @@ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> =
26
26
  env: 'SIGNING_PROTECTION_MAP_SIZE_KB',
27
27
  description:
28
28
  'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
29
- parseEnv: (val: string | undefined) => (val ? +val : undefined),
29
+ parseEnv: (val: string) => +val,
30
30
  },
31
31
  };
32
32
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BlockNumber,
3
- type CheckpointNumber,
3
+ CheckpointNumber,
4
4
  type IndexWithinCheckpoint,
5
5
  type SlotNumber,
6
6
  } from '@aztec/foundation/branded-types';
@@ -20,40 +20,40 @@ export enum DutyType {
20
20
  }
21
21
 
22
22
  /**
23
- * Base context for signing operations
23
+ * Signing context for block proposals.
24
+ * Includes both the block number and the checkpoint number the block belongs to.
24
25
  */
25
- interface BaseSigningContext {
26
- /** Slot number for this duty */
26
+ export interface BlockProposalSigningContext {
27
27
  slot: SlotNumber;
28
- /**
29
- * Block or checkpoint number for this duty.
30
- * For block proposals, this is the block number.
31
- * For checkpoint proposals, this is the checkpoint number.
32
- */
33
- blockNumber: BlockNumber | CheckpointNumber;
28
+ blockNumber: BlockNumber;
29
+ checkpointNumber: CheckpointNumber;
30
+ /** Block index within checkpoint (0, 1, 2...). Required for block proposals. */
31
+ blockIndexWithinCheckpoint: IndexWithinCheckpoint;
32
+ dutyType: DutyType.BLOCK_PROPOSAL;
34
33
  }
35
34
 
36
35
  /**
37
- * Signing context for block proposals.
38
- * blockIndexWithinCheckpoint is REQUIRED and must be >= 0.
36
+ * Signing context for checkpoint proposals.
37
+ * Includes the checkpoint number being proposed, but not a block number.
39
38
  */
40
- export interface BlockProposalSigningContext extends BaseSigningContext {
41
- /** Block index within checkpoint (0, 1, 2...). Required for block proposals. */
42
- blockIndexWithinCheckpoint: IndexWithinCheckpoint;
43
- dutyType: DutyType.BLOCK_PROPOSAL;
39
+ export interface CheckpointProposalSigningContext {
40
+ slot: SlotNumber;
41
+ checkpointNumber: CheckpointNumber;
42
+ dutyType: DutyType.CHECKPOINT_PROPOSAL;
44
43
  }
45
44
 
46
45
  /**
47
- * Signing context for non-block-proposal duties that require HA protection.
48
- * blockIndexWithinCheckpoint is not applicable (internally always -1).
46
+ * Signing context for attestation duties (checkpoint attestations).
47
+ * Includes the checkpoint number when available (from proposal validation).
49
48
  */
50
- export interface OtherSigningContext extends BaseSigningContext {
51
- dutyType: DutyType.CHECKPOINT_PROPOSAL | DutyType.ATTESTATION | DutyType.ATTESTATIONS_AND_SIGNERS;
49
+ export interface AttestationSigningContext {
50
+ slot: SlotNumber;
51
+ checkpointNumber: CheckpointNumber;
52
+ dutyType: DutyType.ATTESTATION | DutyType.ATTESTATIONS_AND_SIGNERS;
52
53
  }
53
54
 
54
55
  /**
55
56
  * Signing context for governance/slashing votes which only need slot for HA protection.
56
- * blockNumber is not applicable (internally always 0).
57
57
  */
58
58
  export interface VoteSigningContext {
59
59
  slot: SlotNumber;
@@ -69,18 +69,23 @@ export interface NoHAProtectionSigningContext {
69
69
  }
70
70
 
71
71
  /**
72
- * Signing contexts that require HA protection (excludes AUTH_REQUEST).
72
+ * Signing contexts that require HA protection (excludes AUTH_REQUEST and TXS).
73
73
  * Used by the HA signer's signWithProtection method.
74
74
  */
75
- export type HAProtectedSigningContext = BlockProposalSigningContext | OtherSigningContext | VoteSigningContext;
75
+ export type HAProtectedSigningContext =
76
+ | BlockProposalSigningContext
77
+ | CheckpointProposalSigningContext
78
+ | AttestationSigningContext
79
+ | VoteSigningContext;
76
80
 
77
81
  /**
78
82
  * Context required for slashing protection during signing operations.
79
83
  * Uses discriminated union to enforce type safety:
80
- * - BLOCK_PROPOSAL duties MUST have blockIndexWithinCheckpoint >= 0
81
- * - Other duty types do NOT have blockIndexWithinCheckpoint (internally -1)
82
- * - Vote duties only need slot (blockNumber is internally 0)
83
- * - AUTH_REQUEST and TXS duties don't need slot/blockNumber (no HA protection needed)
84
+ * - BLOCK_PROPOSAL duties have blockNumber, checkpointNumber, and blockIndexWithinCheckpoint
85
+ * - CHECKPOINT_PROPOSAL duties have checkpointNumber
86
+ * - ATTESTATION/ATTESTATIONS_AND_SIGNERS duties have only slot
87
+ * - Vote duties have only slot
88
+ * - AUTH_REQUEST and TXS duties don't need HA protection
84
89
  */
85
90
  export type SigningContext = HAProtectedSigningContext | NoHAProtectionSigningContext;
86
91
 
@@ -94,19 +99,28 @@ export function isHAProtectedContext(context: SigningContext): context is HAProt
94
99
 
95
100
  /**
96
101
  * Gets the block number from a signing context.
97
- * - Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE): returns BlockNumber(0)
98
- * - Other duties: returns the blockNumber from the context
102
+ * Only BLOCK_PROPOSAL duties carry a block number; all others return BlockNumber(0).
99
103
  */
100
- export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber | CheckpointNumber {
101
- // Check for duty types that have blockNumber
104
+ export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber {
105
+ if (context.dutyType === DutyType.BLOCK_PROPOSAL) {
106
+ return context.blockNumber;
107
+ }
108
+ return BlockNumber(0);
109
+ }
110
+
111
+ /**
112
+ * Gets the checkpoint number from a signing context.
113
+ * BLOCK_PROPOSAL, CHECKPOINT_PROPOSAL, ATTESTATION, and ATTESTATIONS_AND_SIGNERS duties carry a checkpoint number;
114
+ * vote duties return CheckpointNumber(0).
115
+ */
116
+ export function getCheckpointNumberFromSigningContext(context: HAProtectedSigningContext): CheckpointNumber {
102
117
  if (
103
118
  context.dutyType === DutyType.BLOCK_PROPOSAL ||
104
119
  context.dutyType === DutyType.CHECKPOINT_PROPOSAL ||
105
120
  context.dutyType === DutyType.ATTESTATION ||
106
121
  context.dutyType === DutyType.ATTESTATIONS_AND_SIGNERS
107
122
  ) {
108
- return context.blockNumber;
123
+ return context.checkpointNumber;
109
124
  }
110
- // Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE) don't have blockNumber
111
- return BlockNumber(0);
125
+ return CheckpointNumber(0);
112
126
  }
package/src/hash/hash.ts CHANGED
@@ -6,6 +6,21 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
6
6
 
7
7
  import { AztecAddress } from '../aztec-address/index.js';
8
8
 
9
+ /** Computes a Poseidon2 merkle tree internal node hash for append-only trees (note-hash, L1->L2, archive). */
10
+ export function computeMerkleHash(left: Fr, right: Fr): Promise<Fr> {
11
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.MERKLE_HASH);
12
+ }
13
+
14
+ /** Merkle-node hasher for the nullifier tree's sibling paths. */
15
+ export function computeNullifierMerkleHash(left: Fr, right: Fr): Promise<Fr> {
16
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.NULLIFIER_MERKLE);
17
+ }
18
+
19
+ /** Merkle-node hasher for the public-data tree's sibling paths. */
20
+ export function computePublicDataMerkleHash(left: Fr, right: Fr): Promise<Fr> {
21
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.PUBLIC_DATA_MERKLE);
22
+ }
23
+
9
24
  /**
10
25
  * Computes a hash of a given verification key.
11
26
  * @param keyAsFields - The verification key as fields.
@@ -103,6 +118,18 @@ export function computeLogTag(rawTag: number | bigint | boolean | Fr | Buffer, d
103
118
  return poseidon2HashWithSeparator([new Fr(rawTag)], domSep);
104
119
  }
105
120
 
121
+ /**
122
+ * Computes the commitment of a private event from its preimage.
123
+ * @param randomness - Random value emitted alongside the event to prevent preimage brute-forcing.
124
+ * @param eventSelector - Event selector as an Fr.
125
+ * @param content - Serialized event content.
126
+ *
127
+ * @dev Must match the implementation in aztec-nr/aztec/src/event/event_interface.nr > compute_private_serialized_event_commitment
128
+ */
129
+ export function computePrivateEventCommitment(randomness: Fr, eventSelector: Fr, content: Fr[]): Promise<Fr> {
130
+ return poseidon2HashWithSeparator([randomness, eventSelector, ...content], DomainSeparator.EVENT_COMMITMENT);
131
+ }
132
+
106
133
  export function computeSiloedPrivateLogFirstField(contract: AztecAddress, field: Fr): Promise<Fr> {
107
134
  return poseidon2HashWithSeparator([contract, field], DomainSeparator.PRIVATE_LOG_FIRST_FIELD);
108
135
  }
@@ -60,8 +60,14 @@ export type ArchiverSpecificConfig = {
60
60
  /** Whether to allow starting the archiver without debug/trace method support on Ethereum hosts */
61
61
  ethereumAllowNoDebugHosts?: boolean;
62
62
 
63
+ /** Skip the startup check that probes the L1 RPC for historical logs on the Rollup contract. */
64
+ archiverSkipHistoricalLogsCheck?: boolean;
65
+
63
66
  /** Skip validating checkpoint attestations (for testing purposes only) */
64
67
  skipValidateCheckpointAttestations?: boolean;
68
+
69
+ /** Skip promoting proposed checkpoints during L1 sync (for testing purposes only) */
70
+ skipPromoteProposedCheckpointDuringL1Sync?: boolean;
65
71
  };
66
72
 
67
73
  export const ArchiverSpecificConfigSchema = z.object({
@@ -72,7 +78,9 @@ export const ArchiverSpecificConfigSchema = z.object({
72
78
  archiverStoreMapSizeKb: schemas.Integer.optional(),
73
79
  maxAllowedEthClientDriftSeconds: schemas.Integer.optional(),
74
80
  ethereumAllowNoDebugHosts: z.boolean().optional(),
81
+ archiverSkipHistoricalLogsCheck: z.boolean().optional(),
75
82
  skipValidateCheckpointAttestations: z.boolean().optional(),
83
+ skipPromoteProposedCheckpointDuringL1Sync: z.boolean().optional(),
76
84
  });
77
85
 
78
86
  export type ArchiverApi = Omit<
@@ -3,7 +3,8 @@ import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rp
3
3
  import { z } from 'zod';
4
4
 
5
5
  import type { ApiSchemaFor } from '../schemas/schemas.js';
6
- import { type Offense, OffenseSchema, type SlashPayloadRound, SlashPayloadRoundSchema } from '../slashing/index.js';
6
+ import { optional } from '../schemas/schemas.js';
7
+ import { type Offense, OffenseSchema } from '../slashing/index.js';
7
8
  import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
8
9
  import { type ArchiverSpecificConfig, ArchiverSpecificConfigSchema } from './archiver.js';
9
10
  import { type SequencerConfig, SequencerConfigSchema } from './configs.js';
@@ -36,8 +37,9 @@ export interface AztecNodeAdmin {
36
37
  * Pauses syncing and rolls back the database to the target L2 block number.
37
38
  * @param targetBlockNumber - The block number to roll back to.
38
39
  * @param force - If true, clears the world state db and p2p dbs if rolling back to behind the finalized block.
40
+ * @param resumeSync - If true (default), resumes archiver and world state sync after rollback.
39
41
  */
40
- rollbackTo(targetBlockNumber: number, force?: boolean): Promise<void>;
42
+ rollbackTo(targetBlockNumber: number, force?: boolean, resumeSync?: boolean): Promise<void>;
41
43
 
42
44
  /** Pauses archiver and world state syncing. */
43
45
  pauseSync(): Promise<void>;
@@ -45,9 +47,6 @@ export interface AztecNodeAdmin {
45
47
  /** Resumes archiver and world state syncing. */
46
48
  resumeSync(): Promise<void>;
47
49
 
48
- /** Returns all monitored payloads by the slasher for the current round. */
49
- getSlashPayloads(): Promise<SlashPayloadRound[]>;
50
-
51
50
  /** Returns all offenses applicable for the given round. */
52
51
  getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]>;
53
52
 
@@ -100,10 +99,9 @@ export const AztecNodeAdminApiSchema: ApiSchemaFor<AztecNodeAdmin> = {
100
99
  getConfig: z.function().returns(AztecNodeAdminConfigSchema),
101
100
  setConfig: z.function().args(AztecNodeAdminConfigSchema.partial()).returns(z.void()),
102
101
  startSnapshotUpload: z.function().args(z.string()).returns(z.void()),
103
- rollbackTo: z.function().args(z.number()).returns(z.void()),
102
+ rollbackTo: z.function().args(z.number(), optional(z.boolean()), optional(z.boolean())).returns(z.void()),
104
103
  pauseSync: z.function().returns(z.void()),
105
104
  resumeSync: z.function().returns(z.void()),
106
- getSlashPayloads: z.function().returns(z.array(SlashPayloadRoundSchema)),
107
105
  getSlashOffenses: z
108
106
  .function()
109
107
  .args(z.union([z.bigint(), z.literal('all'), z.literal('current')]))
@@ -0,0 +1,40 @@
1
+ import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import type { ApiSchemaFor } from '../schemas/schemas.js';
6
+ import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
7
+
8
+ /**
9
+ * Debug interface for Aztec node available in sandbox/local-network mode.
10
+ */
11
+ export interface AztecNodeDebug {
12
+ /**
13
+ * Triggers the sequencer to produce an L2 block and waits for it to appear.
14
+ *
15
+ * **Precondition**: The current L2 slot must not already contain a block. Callers must ensure L1 time has been
16
+ * advanced to a slot with no existing block before calling this method (e.g. via `EthCheatCodes.warp()`).
17
+ * If the slot is already taken, the sequencer will fail to propose and this call will time out.
18
+ *
19
+ * @throws If no sequencer is running.
20
+ */
21
+ mineBlock(): Promise<void>;
22
+ }
23
+
24
+ export const AztecNodeDebugApiSchema: ApiSchemaFor<AztecNodeDebug> = {
25
+ mineBlock: z.function().returns(z.void()),
26
+ };
27
+
28
+ export function createAztecNodeDebugClient(
29
+ url: string,
30
+ versions: Partial<ComponentsVersions> = {},
31
+ fetch = defaultFetch,
32
+ apiKey?: string,
33
+ ): AztecNodeDebug {
34
+ return createSafeJsonRpcClient<AztecNodeDebug>(url, AztecNodeDebugApiSchema, {
35
+ namespaceMethods: 'nodeDebug',
36
+ fetch,
37
+ onResponse: getVersioningResponseHandler(versions),
38
+ ...(apiKey ? { extraHeaders: { 'x-api-key': apiKey } } : {}),
39
+ });
40
+ }
@@ -37,6 +37,7 @@ import {
37
37
  type ProtocolContractAddresses,
38
38
  ProtocolContractAddressesSchema,
39
39
  } from '../contract/index.js';
40
+ import { ManaUsageEstimate } from '../gas/fee_math.js';
40
41
  import { GasFees } from '../gas/gas_fees.js';
41
42
  import { SiloedTag, Tag, TxScopedL2Log } from '../logs/index.js';
42
43
  import { type LogFilter, LogFilterSchema } from '../logs/log_filter.js';
@@ -272,6 +273,15 @@ export interface AztecNode
272
273
  */
273
274
  getCurrentMinFees(): Promise<GasFees>;
274
275
 
276
+ /**
277
+ * Returns predicted min fees for the current slot and next N slots.
278
+ * Each entry accounts for the L1 gas oracle transition and congestion growth based on the
279
+ * given mana usage estimate. Defaults to target usage (steady state).
280
+ * @param manaUsage - Expected mana usage per checkpoint (none, target, or limit).
281
+ * @returns An array of GasFees, one per slot in the prediction window.
282
+ */
283
+ getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
284
+
275
285
  /**
276
286
  * Method to fetch the current max priority fee of txs in the mempool.
277
287
  * @returns The current max priority fees.
@@ -578,6 +588,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
578
588
 
579
589
  getCurrentMinFees: z.function().returns(GasFees.schema),
580
590
 
591
+ getPredictedMinFees: z
592
+ .function()
593
+ .args(optional(z.nativeEnum(ManaUsageEstimate)))
594
+ .returns(z.array(GasFees.schema)),
595
+
581
596
  getMaxPriorityFees: z.function().returns(GasFees.schema),
582
597
 
583
598
  getNodeVersion: z.function().returns(z.string()),
@@ -1,5 +1,6 @@
1
1
  export * from './aztec-node.js';
2
2
  export * from './aztec-node-admin.js';
3
+ export * from './aztec-node-debug.js';
3
4
  export * from './private_kernel_prover.js';
4
5
  export * from './get_logs_response.js';
5
6
  export * from './api_limit.js';