@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.0208eb9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dest/account.d.ts +2 -0
  2. package/dest/account.d.ts.map +1 -0
  3. package/dest/account.js +4 -0
  4. package/dest/chain.d.ts +1 -1
  5. package/dest/client.d.ts +6 -4
  6. package/dest/client.d.ts.map +1 -1
  7. package/dest/client.js +21 -3
  8. package/dest/config.d.ts +68 -23
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +145 -32
  11. package/dest/constants.d.ts +1 -1
  12. package/dest/contracts/empire_base.d.ts +25 -8
  13. package/dest/contracts/empire_base.d.ts.map +1 -1
  14. package/dest/contracts/empire_base.js +75 -2
  15. package/dest/contracts/empire_slashing_proposer.d.ts +67 -0
  16. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  17. package/dest/contracts/empire_slashing_proposer.js +207 -0
  18. package/dest/contracts/errors.d.ts +7 -0
  19. package/dest/contracts/errors.d.ts.map +1 -0
  20. package/dest/contracts/errors.js +12 -0
  21. package/dest/contracts/fee_asset_handler.d.ts +20 -0
  22. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  23. package/dest/contracts/fee_asset_handler.js +59 -0
  24. package/dest/contracts/fee_juice.d.ts +6 -7
  25. package/dest/contracts/fee_juice.d.ts.map +1 -1
  26. package/dest/contracts/fee_juice.js +27 -20
  27. package/dest/contracts/governance.d.ts +45 -32
  28. package/dest/contracts/governance.d.ts.map +1 -1
  29. package/dest/contracts/governance.js +98 -85
  30. package/dest/contracts/governance_proposer.d.ts +17 -13
  31. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  32. package/dest/contracts/governance_proposer.js +432 -26
  33. package/dest/contracts/gse.d.ts +32 -0
  34. package/dest/contracts/gse.d.ts.map +1 -0
  35. package/dest/contracts/gse.js +72 -0
  36. package/dest/contracts/inbox.d.ts +47 -0
  37. package/dest/contracts/inbox.d.ts.map +1 -0
  38. package/dest/contracts/inbox.js +80 -0
  39. package/dest/contracts/index.d.ts +11 -3
  40. package/dest/contracts/index.d.ts.map +1 -1
  41. package/dest/contracts/index.js +10 -2
  42. package/dest/contracts/log.d.ts +13 -0
  43. package/dest/contracts/log.d.ts.map +1 -0
  44. package/dest/contracts/log.js +1 -0
  45. package/dest/contracts/multicall.d.ts +21 -0
  46. package/dest/contracts/multicall.d.ts.map +1 -0
  47. package/dest/contracts/multicall.js +157 -0
  48. package/dest/contracts/outbox.d.ts +41 -0
  49. package/dest/contracts/outbox.d.ts.map +1 -0
  50. package/dest/contracts/outbox.js +86 -0
  51. package/dest/contracts/registry.d.ts +10 -5
  52. package/dest/contracts/registry.d.ts.map +1 -1
  53. package/dest/contracts/registry.js +44 -16
  54. package/dest/contracts/rollup.d.ts +297 -53
  55. package/dest/contracts/rollup.d.ts.map +1 -1
  56. package/dest/contracts/rollup.js +1127 -116
  57. package/dest/contracts/slasher_contract.d.ts +44 -0
  58. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  59. package/dest/contracts/slasher_contract.js +75 -0
  60. package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
  61. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  62. package/dest/contracts/tally_slashing_proposer.js +320 -0
  63. package/dest/contracts/utils.d.ts +3 -0
  64. package/dest/contracts/utils.d.ts.map +1 -0
  65. package/dest/contracts/utils.js +11 -0
  66. package/dest/deploy_aztec_l1_contracts.d.ts +260 -0
  67. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  68. package/dest/deploy_aztec_l1_contracts.js +399 -0
  69. package/dest/deploy_l1_contract.d.ts +68 -0
  70. package/dest/deploy_l1_contract.d.ts.map +1 -0
  71. package/dest/deploy_l1_contract.js +312 -0
  72. package/dest/eth-signer/eth-signer.d.ts +21 -0
  73. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  74. package/dest/eth-signer/eth-signer.js +5 -0
  75. package/dest/eth-signer/index.d.ts +2 -0
  76. package/dest/eth-signer/index.d.ts.map +1 -0
  77. package/dest/eth-signer/index.js +1 -0
  78. package/dest/forwarder_proxy.d.ts +32 -0
  79. package/dest/forwarder_proxy.d.ts.map +1 -0
  80. package/dest/forwarder_proxy.js +93 -0
  81. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  82. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  83. package/dest/generated/l1-contracts-defaults.js +30 -0
  84. package/dest/l1_artifacts.d.ts +80735 -0
  85. package/dest/l1_artifacts.d.ts.map +1 -0
  86. package/dest/l1_artifacts.js +166 -0
  87. package/dest/l1_contract_addresses.d.ts +24 -4
  88. package/dest/l1_contract_addresses.d.ts.map +1 -1
  89. package/dest/l1_contract_addresses.js +25 -21
  90. package/dest/l1_reader.d.ts +4 -2
  91. package/dest/l1_reader.d.ts.map +1 -1
  92. package/dest/l1_reader.js +14 -8
  93. package/dest/l1_tx_utils/config.d.ts +59 -0
  94. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  95. package/dest/l1_tx_utils/config.js +96 -0
  96. package/dest/l1_tx_utils/constants.d.ts +12 -0
  97. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  98. package/dest/l1_tx_utils/constants.js +39 -0
  99. package/dest/l1_tx_utils/factory.d.ts +24 -0
  100. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  101. package/dest/l1_tx_utils/factory.js +12 -0
  102. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  103. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  104. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  105. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  106. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  107. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  108. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  109. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  110. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  111. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  112. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  113. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  114. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  115. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  116. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  117. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  118. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  119. package/dest/l1_tx_utils/index-blobs.js +2 -0
  120. package/dest/l1_tx_utils/index.d.ts +12 -0
  121. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  122. package/dest/l1_tx_utils/index.js +12 -0
  123. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  124. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  125. package/dest/l1_tx_utils/interfaces.js +4 -0
  126. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  127. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  128. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  129. package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
  130. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  131. package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
  132. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  133. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  134. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  135. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
  136. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  137. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +323 -0
  138. package/dest/l1_tx_utils/signer.d.ts +4 -0
  139. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  140. package/dest/l1_tx_utils/signer.js +16 -0
  141. package/dest/l1_tx_utils/types.d.ts +67 -0
  142. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  143. package/dest/l1_tx_utils/types.js +26 -0
  144. package/dest/l1_tx_utils/utils.d.ts +4 -0
  145. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  146. package/dest/l1_tx_utils/utils.js +14 -0
  147. package/dest/l1_types.d.ts +6 -0
  148. package/dest/l1_types.d.ts.map +1 -0
  149. package/dest/l1_types.js +1 -0
  150. package/dest/publisher_manager.d.ts +16 -0
  151. package/dest/publisher_manager.d.ts.map +1 -0
  152. package/dest/publisher_manager.js +88 -0
  153. package/dest/queries.d.ts +5 -3
  154. package/dest/queries.d.ts.map +1 -1
  155. package/dest/queries.js +61 -12
  156. package/dest/test/chain_monitor.d.ts +75 -0
  157. package/dest/test/chain_monitor.d.ts.map +1 -0
  158. package/dest/test/chain_monitor.js +213 -0
  159. package/dest/test/delayed_tx_utils.d.ts +8 -3
  160. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  161. package/dest/test/delayed_tx_utils.js +13 -6
  162. package/dest/test/eth_cheat_codes.d.ts +229 -0
  163. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  164. package/dest/test/eth_cheat_codes.js +560 -0
  165. package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
  166. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  167. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  168. package/dest/test/index.d.ts +4 -1
  169. package/dest/test/index.d.ts.map +1 -1
  170. package/dest/test/index.js +3 -0
  171. package/dest/test/rollup_cheat_codes.d.ts +90 -0
  172. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  173. package/dest/test/rollup_cheat_codes.js +292 -0
  174. package/dest/test/start_anvil.d.ts +9 -1
  175. package/dest/test/start_anvil.d.ts.map +1 -1
  176. package/dest/test/start_anvil.js +16 -7
  177. package/dest/test/tx_delayer.d.ts +18 -7
  178. package/dest/test/tx_delayer.d.ts.map +1 -1
  179. package/dest/test/tx_delayer.js +97 -20
  180. package/dest/test/upgrade_utils.d.ts +6 -5
  181. package/dest/test/upgrade_utils.d.ts.map +1 -1
  182. package/dest/test/upgrade_utils.js +23 -16
  183. package/dest/types.d.ts +62 -8
  184. package/dest/types.d.ts.map +1 -1
  185. package/dest/types.js +3 -1
  186. package/dest/utils.d.ts +17 -3
  187. package/dest/utils.d.ts.map +1 -1
  188. package/dest/utils.js +107 -88
  189. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  190. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  191. package/dest/zkPassportVerifierAddress.js +11 -0
  192. package/package.json +51 -23
  193. package/src/account.ts +5 -0
  194. package/src/client.ts +43 -5
  195. package/src/config.ts +207 -41
  196. package/src/contracts/README.md +157 -0
  197. package/src/contracts/empire_base.ts +77 -7
  198. package/src/contracts/empire_slashing_proposer.ts +259 -0
  199. package/src/contracts/errors.ts +13 -0
  200. package/src/contracts/fee_asset_handler.ts +66 -0
  201. package/src/contracts/fee_juice.ts +29 -15
  202. package/src/contracts/governance.ts +90 -78
  203. package/src/contracts/governance_proposer.ts +75 -25
  204. package/src/contracts/gse.ts +88 -0
  205. package/src/contracts/inbox.ts +115 -0
  206. package/src/contracts/index.ts +10 -2
  207. package/src/contracts/log.ts +13 -0
  208. package/src/contracts/multicall.ts +158 -0
  209. package/src/contracts/outbox.ts +98 -0
  210. package/src/contracts/registry.ts +51 -26
  211. package/src/contracts/rollup.ts +879 -89
  212. package/src/contracts/slasher_contract.ts +89 -0
  213. package/src/contracts/tally_slashing_proposer.ts +322 -0
  214. package/src/contracts/utils.ts +14 -0
  215. package/src/deploy_aztec_l1_contracts.ts +623 -0
  216. package/src/deploy_l1_contract.ts +362 -0
  217. package/src/eth-signer/eth-signer.ts +25 -0
  218. package/src/eth-signer/index.ts +1 -0
  219. package/src/forwarder_proxy.ts +108 -0
  220. package/src/generated/l1-contracts-defaults.ts +32 -0
  221. package/src/l1_artifacts.ts +254 -0
  222. package/src/l1_contract_addresses.ts +49 -34
  223. package/src/l1_reader.ts +17 -9
  224. package/src/l1_tx_utils/README.md +177 -0
  225. package/src/l1_tx_utils/config.ts +161 -0
  226. package/src/l1_tx_utils/constants.ts +29 -0
  227. package/src/l1_tx_utils/factory.ts +64 -0
  228. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  229. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  230. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  231. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  232. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  233. package/src/l1_tx_utils/index-blobs.ts +2 -0
  234. package/src/l1_tx_utils/index.ts +14 -0
  235. package/src/l1_tx_utils/interfaces.ts +86 -0
  236. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  237. package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
  238. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  239. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +419 -0
  240. package/src/l1_tx_utils/signer.ts +28 -0
  241. package/src/l1_tx_utils/types.ts +85 -0
  242. package/src/l1_tx_utils/utils.ts +16 -0
  243. package/src/l1_types.ts +6 -0
  244. package/src/publisher_manager.ts +108 -0
  245. package/src/queries.ts +82 -16
  246. package/src/test/chain_monitor.ts +245 -0
  247. package/src/test/delayed_tx_utils.ts +34 -6
  248. package/src/test/eth_cheat_codes.ts +588 -0
  249. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  250. package/src/test/index.ts +3 -0
  251. package/src/test/rollup_cheat_codes.ts +330 -0
  252. package/src/test/start_anvil.ts +24 -5
  253. package/src/test/tx_delayer.ts +130 -27
  254. package/src/test/upgrade_utils.ts +30 -21
  255. package/src/types.ts +71 -7
  256. package/src/utils.ts +133 -92
  257. package/src/zkPassportVerifierAddress.ts +15 -0
  258. package/dest/contracts/forwarder.d.ts +0 -24
  259. package/dest/contracts/forwarder.d.ts.map +0 -1
  260. package/dest/contracts/forwarder.js +0 -101
  261. package/dest/contracts/slashing_proposer.d.ts +0 -21
  262. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  263. package/dest/contracts/slashing_proposer.js +0 -47
  264. package/dest/deploy_l1_contracts.d.ts +0 -21210
  265. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  266. package/dest/deploy_l1_contracts.js +0 -687
  267. package/dest/eth_cheat_codes.d.ts +0 -147
  268. package/dest/eth_cheat_codes.d.ts.map +0 -1
  269. package/dest/eth_cheat_codes.js +0 -303
  270. package/dest/index.d.ts +0 -14
  271. package/dest/index.d.ts.map +0 -1
  272. package/dest/index.js +0 -13
  273. package/dest/l1_tx_utils.d.ts +0 -192
  274. package/dest/l1_tx_utils.d.ts.map +0 -1
  275. package/dest/l1_tx_utils.js +0 -641
  276. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  277. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  278. package/dest/l1_tx_utils_with_blobs.js +0 -64
  279. package/src/contracts/forwarder.ts +0 -132
  280. package/src/contracts/slashing_proposer.ts +0 -51
  281. package/src/deploy_l1_contracts.ts +0 -948
  282. package/src/eth_cheat_codes.ts +0 -314
  283. package/src/index.ts +0 -13
  284. package/src/l1_tx_utils.ts +0 -847
  285. package/src/l1_tx_utils_with_blobs.ts +0 -86
package/src/config.ts CHANGED
@@ -1,11 +1,24 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
3
  bigintConfigHelper,
4
+ booleanConfigHelper,
5
+ enumConfigHelper,
4
6
  getConfigFromMappings,
7
+ getDefaultConfig,
5
8
  numberConfigHelper,
9
+ optionalNumberConfigHelper,
6
10
  } from '@aztec/foundation/config';
11
+ import { EthAddress } from '@aztec/foundation/eth-address';
7
12
 
8
- import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils.js';
13
+ import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
14
+ import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
15
+
16
+ export type GenesisStateConfig = {
17
+ /** Whether to populate the genesis state with initial fee juice for the test accounts */
18
+ testAccounts: boolean;
19
+ /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
20
+ sponsoredFPC: boolean;
21
+ };
9
22
 
10
23
  export type L1ContractsConfig = {
11
24
  /** How many seconds an L1 slot lasts. */
@@ -16,88 +29,241 @@ export type L1ContractsConfig = {
16
29
  aztecEpochDuration: number;
17
30
  /** The target validator committee size. */
18
31
  aztecTargetCommitteeSize: number;
19
- /** The number of L2 slots that we can wait for a proof of an epoch to be produced. */
20
- aztecProofSubmissionWindow: number;
32
+ /** The number of epochs to lag behind the current epoch for validator selection. */
33
+ lagInEpochsForValidatorSet: number;
34
+ /** The number of epochs to lag behind the current epoch for randao selection. */
35
+ lagInEpochsForRandao: number;
36
+ /** The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks). */
37
+ inboxLag: number;
38
+ /** The number of epochs after an epoch ends that proofs are still accepted. */
39
+ aztecProofSubmissionEpochs: number;
40
+ /** The deposit amount for a validator */
41
+ activationThreshold: bigint;
21
42
  /** The minimum stake for a validator. */
22
- minimumStake: bigint;
23
- /** The slashing quorum */
24
- slashingQuorum: number;
25
- /** The slashing round size */
26
- slashingRoundSize: number;
27
- /** Governance proposing quorum */
28
- governanceProposerQuorum: number;
43
+ ejectionThreshold: bigint;
44
+ /** The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup */
45
+ localEjectionThreshold: bigint;
46
+ /** The slashing quorum, i.e. how many slots must signal for the same payload in a round for it to be submittable to the Slasher (defaults to slashRoundSize / 2 + 1) */
47
+ slashingQuorum?: number;
48
+ /** The slashing round size, i.e. how many epochs are in a slashing round */
49
+ slashingRoundSizeInEpochs: number;
50
+ /** The slashing lifetime in rounds. I.e., if 1, round N must be submitted before round N + 2 */
51
+ slashingLifetimeInRounds: number;
52
+ /** The slashing execution delay in rounds. I.e., if 1, round N may not be submitted until round N + 2 */
53
+ slashingExecutionDelayInRounds: number;
54
+ /** The slashing vetoer. May blacklist a payload from being submitted. */
55
+ slashingVetoer: EthAddress;
56
+ /** How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset) */
57
+ slashingOffsetInRounds: number;
58
+ /** How long slashing can be disabled for in seconds when vetoer disables it */
59
+ slashingDisableDuration: number;
60
+ /** Type of slasher proposer */
61
+ slasherFlavor: 'empire' | 'tally' | 'none';
62
+ /** Minimum amount that can be slashed in tally slashing */
63
+ slashAmountSmall: bigint;
64
+ /** Medium amount to slash in tally slashing */
65
+ slashAmountMedium: bigint;
66
+ /** Largest amount that can be slashed per round in tally slashing */
67
+ slashAmountLarge: bigint;
68
+ /** Governance proposing quorum (defaults to roundSize/2 + 1) */
69
+ governanceProposerQuorum?: number;
29
70
  /** Governance proposing round size */
30
71
  governanceProposerRoundSize: number;
72
+ /** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
73
+ governanceVotingDuration?: number;
74
+ /** The mana target for the rollup */
75
+ manaTarget: bigint;
76
+ /** The proving cost per mana */
77
+ provingCostPerMana: bigint;
78
+ /** The initial ETH per fee asset price (with 1e12 precision) */
79
+ initialEthPerFeeAsset: bigint;
80
+ /** The number of seconds to wait for an exit */
81
+ exitDelaySeconds: number;
31
82
  } & L1TxUtilsConfig;
32
83
 
33
- export const DefaultL1ContractsConfig = {
34
- ethereumSlotDuration: 12,
35
- aztecSlotDuration: 24,
36
- aztecEpochDuration: 16,
37
- aztecTargetCommitteeSize: 48,
38
- aztecProofSubmissionWindow: 31, // you have a full epoch to submit a proof after the epoch to prove ends
39
- minimumStake: BigInt(100e18),
40
- slashingQuorum: 6,
41
- slashingRoundSize: 10,
42
- governanceProposerQuorum: 6,
43
- governanceProposerRoundSize: 10,
44
- } satisfies L1ContractsConfig;
45
-
84
+ /**
85
+ * Config mappings for L1ContractsConfig.
86
+ * Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
87
+ * Real deployments use forge scripts which require explicit env vars (vm.envUint).
88
+ */
46
89
  export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
47
90
  ethereumSlotDuration: {
48
91
  env: 'ETHEREUM_SLOT_DURATION',
49
92
  description: 'How many seconds an L1 slot lasts.',
50
- ...numberConfigHelper(DefaultL1ContractsConfig.ethereumSlotDuration),
93
+ ...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
51
94
  },
52
95
  aztecSlotDuration: {
53
96
  env: 'AZTEC_SLOT_DURATION',
54
97
  description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
55
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecSlotDuration),
98
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
56
99
  },
57
100
  aztecEpochDuration: {
58
101
  env: 'AZTEC_EPOCH_DURATION',
59
102
  description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
60
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecEpochDuration),
103
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
61
104
  },
62
105
  aztecTargetCommitteeSize: {
63
106
  env: 'AZTEC_TARGET_COMMITTEE_SIZE',
64
107
  description: 'The target validator committee size.',
65
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize),
108
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
66
109
  },
67
- aztecProofSubmissionWindow: {
68
- env: 'AZTEC_PROOF_SUBMISSION_WINDOW',
69
- description:
70
- 'The number of L2 slots that a proof for an epoch can be submitted in, starting from the beginning of the epoch.',
71
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionWindow),
110
+ lagInEpochsForValidatorSet: {
111
+ env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
112
+ description: 'The number of epochs to lag behind the current epoch for validator selection.',
113
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
114
+ },
115
+ lagInEpochsForRandao: {
116
+ env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
117
+ description: 'The number of epochs to lag behind the current epoch for randao selection.',
118
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
119
+ },
120
+ inboxLag: {
121
+ env: 'AZTEC_INBOX_LAG',
122
+ description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
123
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
124
+ },
125
+ aztecProofSubmissionEpochs: {
126
+ env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
127
+ description: 'The number of epochs after an epoch ends that proofs are still accepted.',
128
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
129
+ },
130
+ activationThreshold: {
131
+ env: 'AZTEC_ACTIVATION_THRESHOLD',
132
+ description: 'The deposit amount for a validator',
133
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
72
134
  },
73
- minimumStake: {
74
- env: 'AZTEC_MINIMUM_STAKE',
135
+ ejectionThreshold: {
136
+ env: 'AZTEC_EJECTION_THRESHOLD',
75
137
  description: 'The minimum stake for a validator.',
76
- ...bigintConfigHelper(DefaultL1ContractsConfig.minimumStake),
138
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
139
+ },
140
+ localEjectionThreshold: {
141
+ env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
142
+ description:
143
+ 'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
144
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
145
+ },
146
+ slashingOffsetInRounds: {
147
+ env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
148
+ description:
149
+ 'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
150
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
151
+ },
152
+ slasherFlavor: {
153
+ env: 'AZTEC_SLASHER_FLAVOR',
154
+ description: 'Type of slasher proposer (empire, tally, or none)',
155
+ ...enumConfigHelper(
156
+ ['empire', 'tally', 'none'] as const,
157
+ l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
158
+ ),
159
+ },
160
+ slashAmountSmall: {
161
+ env: 'AZTEC_SLASH_AMOUNT_SMALL',
162
+ description: 'Small slashing amount for light offenses',
163
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
164
+ },
165
+ slashAmountMedium: {
166
+ env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
167
+ description: 'Medium slashing amount for moderate offenses',
168
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
169
+ },
170
+ slashAmountLarge: {
171
+ env: 'AZTEC_SLASH_AMOUNT_LARGE',
172
+ description: 'Large slashing amount for severe offenses',
173
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
77
174
  },
78
175
  slashingQuorum: {
79
176
  env: 'AZTEC_SLASHING_QUORUM',
80
177
  description: 'The slashing quorum',
81
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingQuorum),
178
+ ...optionalNumberConfigHelper(),
82
179
  },
83
- slashingRoundSize: {
84
- env: 'AZTEC_SLASHING_ROUND_SIZE',
180
+ slashingRoundSizeInEpochs: {
181
+ env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
85
182
  description: 'The slashing round size',
86
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSize),
183
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
184
+ },
185
+ slashingLifetimeInRounds: {
186
+ env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
187
+ description: 'The slashing lifetime in rounds',
188
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
189
+ },
190
+ slashingExecutionDelayInRounds: {
191
+ env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
192
+ description: 'The slashing execution delay in rounds',
193
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
194
+ },
195
+ slashingVetoer: {
196
+ env: 'AZTEC_SLASHING_VETOER',
197
+ description: 'The slashing vetoer',
198
+ parseEnv: (val: string) => EthAddress.fromString(val),
199
+ defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
200
+ },
201
+ slashingDisableDuration: {
202
+ env: 'AZTEC_SLASHING_DISABLE_DURATION',
203
+ description: 'How long slashing can be disabled for in seconds when vetoer disables it',
204
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
87
205
  },
88
206
  governanceProposerQuorum: {
89
207
  env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
90
208
  description: 'The governance proposing quorum',
91
- ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerQuorum),
209
+ ...optionalNumberConfigHelper(),
92
210
  },
93
211
  governanceProposerRoundSize: {
94
212
  env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
95
213
  description: 'The governance proposing round size',
96
- ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerRoundSize),
214
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
215
+ },
216
+ governanceVotingDuration: {
217
+ env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
218
+ description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
219
+ ...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
220
+ },
221
+ manaTarget: {
222
+ env: 'AZTEC_MANA_TARGET',
223
+ description: 'The mana target for the rollup',
224
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
225
+ },
226
+ provingCostPerMana: {
227
+ env: 'AZTEC_PROVING_COST_PER_MANA',
228
+ description: 'The proving cost per mana',
229
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
230
+ },
231
+ initialEthPerFeeAsset: {
232
+ env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
233
+ description: 'The initial ETH per fee asset price (with 1e12 precision)',
234
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
235
+ },
236
+ exitDelaySeconds: {
237
+ env: 'AZTEC_EXIT_DELAY_SECONDS',
238
+ description: 'The delay before a validator can exit the set',
239
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
97
240
  },
98
241
  ...l1TxUtilsConfigMappings,
99
242
  };
100
243
 
244
+ /**
245
+ * Default L1 contracts configuration derived from l1ContractsConfigMappings.
246
+ * Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
247
+ */
248
+ export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
249
+
250
+ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
251
+ testAccounts: {
252
+ env: 'TEST_ACCOUNTS',
253
+ description: 'Whether to populate the genesis state with initial fee juice for the test accounts.',
254
+ ...booleanConfigHelper(false),
255
+ },
256
+ sponsoredFPC: {
257
+ env: 'SPONSORED_FPC',
258
+ description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
259
+ ...booleanConfigHelper(false),
260
+ },
261
+ };
262
+
101
263
  export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
102
264
  return getConfigFromMappings(l1ContractsConfigMappings);
103
265
  }
266
+
267
+ export function getGenesisStateConfigEnvVars(): GenesisStateConfig {
268
+ return getConfigFromMappings(genesisStateConfigMappings);
269
+ }
@@ -0,0 +1,157 @@
1
+ # L1 Contract Wrappers
2
+
3
+ This folder contains TypeScript wrappers for L1 contracts defined in `l1-contracts/`. These wrappers are used by the node client to interact with the rollup and related contracts on Ethereum.
4
+
5
+ ## Purpose
6
+
7
+ The goal of wrapping is to shield consumers from L1-specific and viem-specific details. Clients using these wrappers interact with domain types and branded types native to the Aztec codebase, without needing to understand viem's ABI type system or deal with raw types like `Hex` and `bigint`.
8
+
9
+ ## Type Safety
10
+
11
+ ### Explicit Return Types
12
+
13
+ Every function in the contract wrappers must declare its return type explicitly. This is critical because viem's type inference over ABI types is slow and significantly impacts IDE performance.
14
+
15
+ ```typescript
16
+ // Good: Explicit return type
17
+ async getSlotNumber(): Promise<SlotNumber> {
18
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
19
+ }
20
+
21
+ // Bad: Inferred return type (slow)
22
+ async getSlotNumber() {
23
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
24
+ }
25
+ ```
26
+
27
+ ### Branded and Domain Types
28
+
29
+ Use branded types and domain-specific types instead of viem's autogenerated types for both arguments and return values:
30
+
31
+ - `CheckpointNumber`, `EpochNumber`, `SlotNumber` instead of `bigint`
32
+ - `EthAddress` instead of `` `0x${string}` `` or `Hex`
33
+ - `Fr`, `Buffer32` instead of `Hex` for hashes and field elements
34
+ - Custom domain types (e.g., `CheckpointLog`, `AttesterView`) instead of raw tuples
35
+
36
+ Type conversions happen inside wrapper methods, not at the call site:
37
+
38
+ ```typescript
39
+ async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
40
+ const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
41
+ return {
42
+ archive: Fr.fromString(result.archive),
43
+ headerHash: Buffer32.fromString(result.headerHash),
44
+ blockCount: result.blockCount,
45
+ };
46
+ }
47
+ ```
48
+
49
+ ## Wrapper Pattern
50
+
51
+ ### Basic Structure
52
+
53
+ Each wrapper follows a consistent structure:
54
+
55
+ ```typescript
56
+ export class FooContract {
57
+ private readonly foo: GetContractReturnType<typeof FooAbi, ViemClient>;
58
+
59
+ constructor(
60
+ public readonly client: ViemClient,
61
+ address: Hex | EthAddress,
62
+ ) {
63
+ if (address instanceof EthAddress) {
64
+ address = address.toString();
65
+ }
66
+ this.foo = getContract({ address, abi: FooAbi, client });
67
+ }
68
+
69
+ public get address(): Hex {
70
+ return this.foo.address;
71
+ }
72
+
73
+ public getContract(): GetContractReturnType<typeof FooAbi, ViemClient> {
74
+ return this.foo;
75
+ }
76
+ }
77
+ ```
78
+
79
+ The raw contract is exposed via `getContract()` for cases where direct access is needed, but most consumers should use the typed wrapper methods. Relying on `getContract()` is a code smell and should be avoided.
80
+
81
+ ### Static Factory Methods
82
+
83
+ Wrappers may provide static factory methods for common initialization patterns:
84
+
85
+ - `getFromConfig(config)` - construct from configuration object
86
+ - `getFromL1ContractsValues(deployResult)` - construct from deployment result
87
+
88
+ ### Wallet Assertions
89
+
90
+ For write operations that require a wallet, use an assertion helper:
91
+
92
+ ```typescript
93
+ private assertWallet(): GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient> {
94
+ if (!isExtendedClient(this.client)) {
95
+ throw new Error('Wallet client is required for this operation');
96
+ }
97
+ return this.foo as GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient>;
98
+ }
99
+ ```
100
+
101
+ ## Event Handling
102
+
103
+ ### Event Log Types
104
+
105
+ Event logs are wrapped in `L1EventLog<T>` to include L1 block context:
106
+
107
+ ```typescript
108
+ type L1EventLog<T> = {
109
+ l1BlockNumber: bigint;
110
+ l1BlockHash: Buffer32;
111
+ l1TransactionHash: Hex;
112
+ args: T;
113
+ };
114
+ ```
115
+
116
+ ### Event Fetching
117
+
118
+ Methods that fetch events convert viem's raw logs to domain types:
119
+
120
+ ```typescript
121
+ async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
122
+ const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
123
+ return logs.map(log => ({
124
+ l1BlockNumber: log.blockNumber!,
125
+ l1BlockHash: Buffer32.fromString(log.blockHash!),
126
+ l1TransactionHash: log.transactionHash!,
127
+ args: {
128
+ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
129
+ // ... convert other fields
130
+ },
131
+ }));
132
+ }
133
+ ```
134
+
135
+ ### Event Listeners
136
+
137
+ For reactive event handling, wrapper methods convert arguments before invoking callbacks:
138
+
139
+ ```typescript
140
+ public listenToCheckpointInvalidated(
141
+ callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
142
+ ): WatchContractEventReturnType {
143
+ return this.rollup.watchEvent.CheckpointInvalidated({}, {
144
+ onLogs: logs => {
145
+ for (const log of logs) {
146
+ if (log.args.checkpointNumber !== undefined) {
147
+ callback({ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber) });
148
+ }
149
+ }
150
+ },
151
+ });
152
+ }
153
+ ```
154
+
155
+ ## Error Handling
156
+
157
+ Custom error classes in `errors.ts` extend `Error` and set `this.name` for proper error identification. Include relevant context as public readonly properties.
@@ -1,19 +1,89 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { Signature } from '@aztec/foundation/eth-signature';
1
4
  import { EmpireBaseAbi } from '@aztec/l1-artifacts/EmpireBaseAbi';
2
5
 
3
- import { type Hex, encodeFunctionData } from 'viem';
6
+ import { type Hex, type TypedDataDefinition, encodeFunctionData } from 'viem';
4
7
 
5
- import type { L1TxRequest } from '../l1_tx_utils.js';
8
+ import type { L1TxRequest } from '../l1_tx_utils/index.js';
6
9
 
7
10
  export interface IEmpireBase {
8
- getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{ lastVote: bigint; leader: Hex; executed: boolean }>;
9
- computeRound(slot: bigint): Promise<bigint>;
10
- createVoteRequest(payload: Hex): L1TxRequest;
11
+ get address(): EthAddress;
12
+ getRoundInfo(
13
+ rollupAddress: Hex,
14
+ round: bigint,
15
+ ): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }>;
16
+ computeRound(slot: SlotNumber): Promise<bigint>;
17
+ createSignalRequest(payload: Hex): L1TxRequest;
18
+ createSignalRequestWithSignature(
19
+ payload: Hex,
20
+ slot: SlotNumber,
21
+ chainId: number,
22
+ signerAddress: Hex,
23
+ signer: (msg: TypedDataDefinition) => Promise<Hex>,
24
+ ): Promise<L1TxRequest>;
11
25
  }
12
26
 
13
- export function encodeVote(payload: Hex): Hex {
27
+ export function encodeSignal(payload: Hex): Hex {
14
28
  return encodeFunctionData({
15
29
  abi: EmpireBaseAbi,
16
- functionName: 'vote',
30
+ functionName: 'signal',
17
31
  args: [payload],
18
32
  });
19
33
  }
34
+
35
+ export function encodeSignalWithSignature(payload: Hex, signature: Signature) {
36
+ return encodeFunctionData({
37
+ abi: EmpireBaseAbi,
38
+ functionName: 'signalWithSig',
39
+ args: [payload, signature.toViemSignature()],
40
+ });
41
+ }
42
+
43
+ /**
44
+ * Signs a signal proposal using EIP-712 typed data for use with signalWithSig
45
+ * @param walletClient - The viem wallet client to sign with
46
+ * @param payload - The payload address to signal
47
+ * @param verifyingContract - The address of the EmpireBase contract
48
+ * @param chainId - The chain ID where the contract is deployed
49
+ * @param account - The account to sign with (optional if hoisted on wallet client)
50
+ * @returns The EIP-712 signature
51
+ */
52
+ export async function signSignalWithSig(
53
+ signer: (msg: TypedDataDefinition) => Promise<Hex>,
54
+ payload: Hex,
55
+ slot: SlotNumber,
56
+ instance: Hex,
57
+ verifyingContract: Hex,
58
+ chainId: number,
59
+ ): Promise<Signature> {
60
+ const domain = {
61
+ name: 'EmpireBase',
62
+ version: '1',
63
+ chainId,
64
+ verifyingContract,
65
+ };
66
+
67
+ const types = {
68
+ EIP712Domain: [
69
+ { name: 'name', type: 'string' },
70
+ { name: 'version', type: 'string' },
71
+ { name: 'chainId', type: 'uint256' },
72
+ { name: 'verifyingContract', type: 'address' },
73
+ ],
74
+ Signal: [
75
+ { name: 'payload', type: 'address' },
76
+ { name: 'slot', type: 'uint256' },
77
+ { name: 'instance', type: 'address' },
78
+ ],
79
+ };
80
+
81
+ const message = {
82
+ payload,
83
+ slot: BigInt(slot),
84
+ instance,
85
+ };
86
+
87
+ const typedData = { domain, types, primaryType: 'Signal', message };
88
+ return Signature.fromString(await signer(typedData));
89
+ }