@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
package/src/config.ts CHANGED
@@ -1,22 +1,25 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
- type NetworkNames,
4
3
  bigintConfigHelper,
5
4
  booleanConfigHelper,
6
- enumConfigHelper,
7
5
  getConfigFromMappings,
6
+ getDefaultConfig,
8
7
  numberConfigHelper,
8
+ omitConfigMappings,
9
9
  optionalNumberConfigHelper,
10
10
  } from '@aztec/foundation/config';
11
11
  import { EthAddress } from '@aztec/foundation/eth-address';
12
+ import l1ContractsDefaultEnv from '@aztec/l1-artifacts/network-defaults.json' with { type: 'json' };
12
13
 
13
- import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/index.js';
14
+ import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
14
15
 
15
16
  export type GenesisStateConfig = {
16
17
  /** Whether to populate the genesis state with initial fee juice for the test accounts */
17
18
  testAccounts: boolean;
18
19
  /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
19
20
  sponsoredFPC: boolean;
21
+ /** Additional addresses to prefund with fee juice at genesis */
22
+ prefundAddresses: string[];
20
23
  };
21
24
 
22
25
  export type L1ContractsConfig = {
@@ -29,7 +32,11 @@ export type L1ContractsConfig = {
29
32
  /** The target validator committee size. */
30
33
  aztecTargetCommitteeSize: number;
31
34
  /** The number of epochs to lag behind the current epoch for validator selection. */
32
- lagInEpochs: number;
35
+ lagInEpochsForValidatorSet: number;
36
+ /** The number of epochs to lag behind the current epoch for randao selection. */
37
+ lagInEpochsForRandao: number;
38
+ /** The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks). */
39
+ inboxLag: number;
33
40
  /** The number of epochs after an epoch ends that proofs are still accepted. */
34
41
  aztecProofSubmissionEpochs: number;
35
42
  /** The deposit amount for a validator */
@@ -52,326 +59,127 @@ export type L1ContractsConfig = {
52
59
  slashingOffsetInRounds: number;
53
60
  /** How long slashing can be disabled for in seconds when vetoer disables it */
54
61
  slashingDisableDuration: number;
55
- /** Type of slasher proposer */
56
- slasherFlavor: 'empire' | 'tally' | 'none';
57
- /** Minimum amount that can be slashed in tally slashing */
62
+ /** Whether to deploy a slasher proposer */
63
+ slasherEnabled: boolean;
64
+ /** Minimum amount that can be slashed */
58
65
  slashAmountSmall: bigint;
59
- /** Medium amount to slash in tally slashing */
66
+ /** Medium amount to slash */
60
67
  slashAmountMedium: bigint;
61
- /** Largest amount that can be slashed per round in tally slashing */
68
+ /** Largest amount that can be slashed per round */
62
69
  slashAmountLarge: bigint;
63
70
  /** Governance proposing quorum (defaults to roundSize/2 + 1) */
64
71
  governanceProposerQuorum?: number;
65
72
  /** Governance proposing round size */
66
73
  governanceProposerRoundSize: number;
74
+ /** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
75
+ governanceVotingDuration?: number;
67
76
  /** The mana target for the rollup */
68
77
  manaTarget: bigint;
69
78
  /** The proving cost per mana */
70
79
  provingCostPerMana: bigint;
80
+ /** The initial ETH per fee asset price (with 1e12 precision) */
81
+ initialEthPerFeeAsset: bigint;
71
82
  /** The number of seconds to wait for an exit */
72
83
  exitDelaySeconds: number;
84
+ /** Validator set size at or below which the entry queue uses the bootstrap flush size. */
85
+ entryQueueBootstrapValidatorSetSize: number;
86
+ /** Number of validators admitted from the entry queue per flush during the bootstrap phase. */
87
+ entryQueueBootstrapFlushSize: number;
88
+ /** Minimum number of validators admitted from the entry queue per flush. */
89
+ entryQueueFlushSizeMin: number;
90
+ /** Divisor applied to the queue size to derive the normal per-flush admission count. */
91
+ entryQueueFlushSizeQuotient: number;
92
+ /** Maximum number of validators admitted from the entry queue per flush. */
93
+ entryQueueMaxFlushSize: number;
73
94
  } & L1TxUtilsConfig;
74
95
 
75
- export const DefaultL1ContractsConfig = {
76
- ethereumSlotDuration: 12,
77
- aztecSlotDuration: 36,
78
- aztecEpochDuration: 32,
79
- aztecTargetCommitteeSize: 48,
80
- lagInEpochs: 2,
81
- aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
82
- activationThreshold: 100n * 10n ** 18n,
83
- ejectionThreshold: 50n * 10n ** 18n,
84
- localEjectionThreshold: 98n * 10n ** 18n,
85
- slashAmountSmall: 10n * 10n ** 18n,
86
- slashAmountMedium: 20n * 10n ** 18n,
87
- slashAmountLarge: 50n * 10n ** 18n,
88
- slashingRoundSizeInEpochs: 4,
89
- slashingLifetimeInRounds: 5,
90
- slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
91
- slashingVetoer: EthAddress.ZERO,
92
- governanceProposerRoundSize: 300,
93
- manaTarget: BigInt(1e10),
94
- provingCostPerMana: BigInt(100),
95
- exitDelaySeconds: 2 * 24 * 60 * 60,
96
- slasherFlavor: 'tally' as const,
97
- slashingOffsetInRounds: 2,
98
- slashingDisableDuration: 5 * 24 * 60 * 60, // 5 days in seconds
99
- } satisfies L1ContractsConfig;
100
-
101
- const LocalGovernanceConfiguration = {
102
- proposeConfig: {
103
- lockDelay: 60n * 60n * 24n * 30n,
104
- lockAmount: 1n * 10n ** 24n,
105
- },
106
- votingDelay: 60n,
107
- votingDuration: 60n * 60n,
108
- executionDelay: 60n,
109
- gracePeriod: 60n * 60n * 24n * 7n,
110
- quorum: 1n * 10n ** 17n, // 10%
111
- requiredYeaMargin: 4n * 10n ** 16n, // 4%
112
- minimumVotes: 400n * 10n ** 18n,
113
- };
114
-
115
- const StagingPublicGovernanceConfiguration = {
116
- proposeConfig: {
117
- lockDelay: 60n * 60n * 24n * 30n,
118
- lockAmount: DefaultL1ContractsConfig.activationThreshold * 100n,
119
- },
120
- votingDelay: 60n,
121
- votingDuration: 60n * 60n,
122
- executionDelay: 60n,
123
- gracePeriod: 60n * 60n * 24n * 7n,
124
- quorum: 3n * 10n ** 17n, // 30%
125
- requiredYeaMargin: 4n * 10n ** 16n, // 4%
126
- minimumVotes: DefaultL1ContractsConfig.ejectionThreshold * 200n, // >= 200 validators must vote
127
- };
128
-
129
- const TestnetGovernanceConfiguration = {
130
- proposeConfig: {
131
- lockDelay: 10n * 365n * 24n * 60n * 60n,
132
- lockAmount: 1250n * 200_000n * 10n ** 18n,
133
- },
134
-
135
- votingDelay: 12n * 60n * 60n, // 12 hours
136
- votingDuration: 1n * 24n * 60n * 60n, // 1 day
137
- executionDelay: 12n * 60n * 60n, // 12 hours
138
- gracePeriod: 1n * 24n * 60n * 60n, // 1 day
139
- quorum: 2n * 10n ** 17n, // 20%
140
- requiredYeaMargin: 1n * 10n ** 17n, // 10%
141
- minimumVotes: 100n * 200_000n * 10n ** 18n,
142
- };
143
-
144
- const StagingIgnitionGovernanceConfiguration = {
145
- proposeConfig: {
146
- lockDelay: 10n * 365n * 24n * 60n * 60n,
147
- lockAmount: 1250n * 200_000n * 10n ** 18n,
148
- },
149
-
150
- votingDelay: 7n * 24n * 60n * 60n,
151
- votingDuration: 7n * 24n * 60n * 60n,
152
- executionDelay: 30n * 24n * 60n * 60n,
153
- gracePeriod: 7n * 24n * 60n * 60n,
154
- quorum: 2n * 10n ** 17n, // 20%
155
- requiredYeaMargin: 1n * 10n ** 17n, // 10%
156
- minimumVotes: 1250n * 200_000n * 10n ** 18n,
157
- };
158
-
159
- const MainnetGovernanceConfiguration = {
160
- proposeConfig: {
161
- lockDelay: 90n * 24n * 60n * 60n,
162
- lockAmount: 258_750_000n * 10n ** 18n,
163
- },
164
-
165
- votingDelay: 3n * 24n * 60n * 60n,
166
- votingDuration: 7n * 24n * 60n * 60n,
167
- executionDelay: 7n * 24n * 60n * 60n,
168
- gracePeriod: 7n * 24n * 60n * 60n,
169
- quorum: 2n * 10n ** 17n, // 20%
170
- requiredYeaMargin: 33n * 10n ** 16n, // 33%
171
- minimumVotes: 1000n * 200_000n * 10n ** 18n,
172
- };
173
-
174
- export const getGovernanceConfiguration = (networkName: NetworkNames) => {
175
- switch (networkName) {
176
- case 'local':
177
- return LocalGovernanceConfiguration;
178
- case 'next-net':
179
- return LocalGovernanceConfiguration;
180
- case 'devnet':
181
- return LocalGovernanceConfiguration;
182
- case 'staging-public':
183
- return StagingPublicGovernanceConfiguration;
184
- case 'testnet':
185
- return TestnetGovernanceConfiguration;
186
- case 'staging-ignition':
187
- return StagingIgnitionGovernanceConfiguration;
188
- case 'mainnet':
189
- return MainnetGovernanceConfiguration;
190
- default:
191
- throw new Error(`Unrecognized network name: ${networkName}`);
192
- }
193
- };
194
-
195
- // Making a default config here as we are only using it thought the deployment
196
- // and do not expect to be using different setups, so having environment variables
197
- // for it seems overkill
198
-
199
- const DefaultRewardConfig = {
200
- sequencerBps: 8000,
201
- rewardDistributor: EthAddress.ZERO.toString(),
202
- booster: EthAddress.ZERO.toString(),
203
- blockReward: 500n * 10n ** 18n,
204
- };
205
-
206
- const MainnetRewardConfig = {
207
- sequencerBps: 7_000,
208
- rewardDistributor: EthAddress.ZERO.toString(),
209
- booster: EthAddress.ZERO.toString(),
210
- blockReward: 400n * 10n ** 18n,
211
- };
212
-
213
- export const getRewardConfig = (networkName: NetworkNames) => {
214
- switch (networkName) {
215
- case 'local':
216
- case 'devnet':
217
- case 'next-net':
218
- case 'staging-public':
219
- case 'testnet':
220
- case 'staging-ignition':
221
- return DefaultRewardConfig;
222
- case 'mainnet':
223
- return MainnetRewardConfig;
224
- default:
225
- throw new Error(`Unrecognized network name: ${networkName}`);
226
- }
227
- };
228
-
229
- export const getRewardBoostConfig = () => {
230
- // The reward configuration is specified with a precision of 1e5, and we use the same across
231
- // all networks.
232
- return {
233
- increment: 125_000, // 1.25
234
- maxScore: 15_000_000, // 150
235
- a: 1_000, // 0.01
236
- k: 1_000_000, // 10
237
- minimum: 100_000, // 1
238
- };
239
- };
240
-
241
- // Similar to the above, no need for environment variables for this.
242
- const LocalEntryQueueConfig = {
243
- bootstrapValidatorSetSize: 0n,
244
- bootstrapFlushSize: 0n,
245
- normalFlushSizeMin: 48n,
246
- normalFlushSizeQuotient: 2n,
247
- maxQueueFlushSize: 48n,
248
- };
249
-
250
- const StagingPublicEntryQueueConfig = {
251
- bootstrapValidatorSetSize: 48n,
252
- bootstrapFlushSize: 48n,
253
- normalFlushSizeMin: 1n,
254
- normalFlushSizeQuotient: 2475n,
255
- maxQueueFlushSize: 32n, // Limited to 32 so flush cost are kept below 15M gas.
256
- };
257
-
258
- const TestnetEntryQueueConfig = {
259
- bootstrapValidatorSetSize: 256n,
260
- bootstrapFlushSize: 256n,
261
- normalFlushSizeMin: 4n,
262
- normalFlushSizeQuotient: 2048n,
263
- maxQueueFlushSize: 8n,
264
- };
265
-
266
- const StagingIgnitionEntryQueueConfig = {
267
- bootstrapValidatorSetSize: 48n,
268
- bootstrapFlushSize: 48n,
269
- normalFlushSizeMin: 1n,
270
- normalFlushSizeQuotient: 2048n,
271
- maxQueueFlushSize: 24n,
272
- };
273
-
274
- const MainnetEntryQueueConfig = {
275
- bootstrapValidatorSetSize: 1_000n,
276
- bootstrapFlushSize: 1_000n,
277
- normalFlushSizeMin: 1n,
278
- normalFlushSizeQuotient: 2_048n,
279
- maxQueueFlushSize: 8n,
280
- };
281
-
282
- export const getEntryQueueConfig = (networkName: NetworkNames) => {
283
- switch (networkName) {
284
- case 'local':
285
- return LocalEntryQueueConfig;
286
- case 'next-net':
287
- return LocalEntryQueueConfig;
288
- case 'devnet':
289
- return LocalEntryQueueConfig;
290
- case 'staging-public':
291
- return StagingPublicEntryQueueConfig;
292
- case 'testnet':
293
- return TestnetEntryQueueConfig;
294
- case 'staging-ignition':
295
- return StagingIgnitionEntryQueueConfig;
296
- case 'mainnet':
297
- return MainnetEntryQueueConfig;
298
- default:
299
- throw new Error(`Unrecognized network name: ${networkName}`);
300
- }
301
- };
302
-
96
+ /**
97
+ * Config mappings for L1ContractsConfig.
98
+ * Default values come from l1-contracts/scripts/network-defaults.json (published via @aztec/l1-artifacts).
99
+ * Real deployments use forge scripts which require explicit env vars (vm.envUint).
100
+ */
303
101
  export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
304
102
  ethereumSlotDuration: {
305
103
  env: 'ETHEREUM_SLOT_DURATION',
306
104
  description: 'How many seconds an L1 slot lasts.',
307
- ...numberConfigHelper(DefaultL1ContractsConfig.ethereumSlotDuration),
105
+ ...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
308
106
  },
309
107
  aztecSlotDuration: {
310
108
  env: 'AZTEC_SLOT_DURATION',
311
109
  description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
312
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecSlotDuration),
110
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
313
111
  },
314
112
  aztecEpochDuration: {
315
113
  env: 'AZTEC_EPOCH_DURATION',
316
- description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
317
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecEpochDuration),
114
+ description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
115
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
318
116
  },
319
117
  aztecTargetCommitteeSize: {
320
118
  env: 'AZTEC_TARGET_COMMITTEE_SIZE',
321
119
  description: 'The target validator committee size.',
322
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize),
120
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
323
121
  },
324
- lagInEpochs: {
325
- env: 'AZTEC_LAG_IN_EPOCHS',
122
+ lagInEpochsForValidatorSet: {
123
+ env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
326
124
  description: 'The number of epochs to lag behind the current epoch for validator selection.',
327
- ...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochs),
125
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
126
+ },
127
+ lagInEpochsForRandao: {
128
+ env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
129
+ description: 'The number of epochs to lag behind the current epoch for randao selection.',
130
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
131
+ },
132
+ inboxLag: {
133
+ env: 'AZTEC_INBOX_LAG',
134
+ description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
135
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
328
136
  },
329
137
  aztecProofSubmissionEpochs: {
330
138
  env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
331
139
  description: 'The number of epochs after an epoch ends that proofs are still accepted.',
332
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionEpochs),
140
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
333
141
  },
334
142
  activationThreshold: {
335
143
  env: 'AZTEC_ACTIVATION_THRESHOLD',
336
144
  description: 'The deposit amount for a validator',
337
- ...bigintConfigHelper(DefaultL1ContractsConfig.activationThreshold),
145
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
338
146
  },
339
147
  ejectionThreshold: {
340
148
  env: 'AZTEC_EJECTION_THRESHOLD',
341
149
  description: 'The minimum stake for a validator.',
342
- ...bigintConfigHelper(DefaultL1ContractsConfig.ejectionThreshold),
150
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
343
151
  },
344
152
  localEjectionThreshold: {
345
153
  env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
346
154
  description:
347
155
  'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
348
- ...bigintConfigHelper(DefaultL1ContractsConfig.localEjectionThreshold),
156
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
349
157
  },
350
158
  slashingOffsetInRounds: {
351
159
  env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
352
160
  description:
353
161
  'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
354
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingOffsetInRounds),
162
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
355
163
  },
356
- slasherFlavor: {
357
- env: 'AZTEC_SLASHER_FLAVOR',
358
- description: 'Type of slasher proposer (empire, tally, or none)',
359
- ...enumConfigHelper(['empire', 'tally', 'none'] as const, DefaultL1ContractsConfig.slasherFlavor),
164
+ slasherEnabled: {
165
+ env: 'AZTEC_SLASHER_ENABLED',
166
+ description: 'Whether to deploy a slasher proposer',
167
+ ...booleanConfigHelper(true),
360
168
  },
361
169
  slashAmountSmall: {
362
170
  env: 'AZTEC_SLASH_AMOUNT_SMALL',
363
171
  description: 'Small slashing amount for light offenses',
364
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountSmall),
172
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
365
173
  },
366
174
  slashAmountMedium: {
367
175
  env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
368
176
  description: 'Medium slashing amount for moderate offenses',
369
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountMedium),
177
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
370
178
  },
371
179
  slashAmountLarge: {
372
180
  env: 'AZTEC_SLASH_AMOUNT_LARGE',
373
181
  description: 'Large slashing amount for severe offenses',
374
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountLarge),
182
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
375
183
  },
376
184
  slashingQuorum: {
377
185
  env: 'AZTEC_SLASHING_QUORUM',
@@ -381,28 +189,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
381
189
  slashingRoundSizeInEpochs: {
382
190
  env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
383
191
  description: 'The slashing round size',
384
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSizeInEpochs),
192
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
385
193
  },
386
194
  slashingLifetimeInRounds: {
387
195
  env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
388
196
  description: 'The slashing lifetime in rounds',
389
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingLifetimeInRounds),
197
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
390
198
  },
391
199
  slashingExecutionDelayInRounds: {
392
200
  env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
393
201
  description: 'The slashing execution delay in rounds',
394
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingExecutionDelayInRounds),
202
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
395
203
  },
396
204
  slashingVetoer: {
397
205
  env: 'AZTEC_SLASHING_VETOER',
398
206
  description: 'The slashing vetoer',
399
207
  parseEnv: (val: string) => EthAddress.fromString(val),
400
- defaultValue: DefaultL1ContractsConfig.slashingVetoer,
208
+ defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
401
209
  },
402
210
  slashingDisableDuration: {
403
211
  env: 'AZTEC_SLASHING_DISABLE_DURATION',
404
212
  description: 'How long slashing can be disabled for in seconds when vetoer disables it',
405
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingDisableDuration),
213
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
406
214
  },
407
215
  governanceProposerQuorum: {
408
216
  env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
@@ -412,26 +220,102 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
412
220
  governanceProposerRoundSize: {
413
221
  env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
414
222
  description: 'The governance proposing round size',
415
- ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerRoundSize),
223
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
224
+ },
225
+ governanceVotingDuration: {
226
+ env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
227
+ description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
228
+ ...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
416
229
  },
417
230
  manaTarget: {
418
231
  env: 'AZTEC_MANA_TARGET',
419
232
  description: 'The mana target for the rollup',
420
- ...bigintConfigHelper(DefaultL1ContractsConfig.manaTarget),
233
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
421
234
  },
422
235
  provingCostPerMana: {
423
236
  env: 'AZTEC_PROVING_COST_PER_MANA',
424
237
  description: 'The proving cost per mana',
425
- ...bigintConfigHelper(DefaultL1ContractsConfig.provingCostPerMana),
238
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
239
+ },
240
+ initialEthPerFeeAsset: {
241
+ env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
242
+ description: 'The initial ETH per fee asset price (with 1e12 precision)',
243
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
426
244
  },
427
245
  exitDelaySeconds: {
428
246
  env: 'AZTEC_EXIT_DELAY_SECONDS',
429
247
  description: 'The delay before a validator can exit the set',
430
- ...numberConfigHelper(DefaultL1ContractsConfig.exitDelaySeconds),
431
- },
432
- ...l1TxUtilsConfigMappings,
248
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
249
+ },
250
+ entryQueueBootstrapValidatorSetSize: {
251
+ env: 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE',
252
+ description: 'Validator set size at or below which the entry queue uses the bootstrap flush size.',
253
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE),
254
+ },
255
+ entryQueueBootstrapFlushSize: {
256
+ env: 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE',
257
+ description: 'Number of validators admitted from the entry queue per flush during the bootstrap phase.',
258
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE),
259
+ },
260
+ entryQueueFlushSizeMin: {
261
+ env: 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN',
262
+ description: 'Minimum number of validators admitted from the entry queue per flush.',
263
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN),
264
+ },
265
+ entryQueueFlushSizeQuotient: {
266
+ env: 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT',
267
+ description: 'Divisor applied to the queue size to derive the normal per-flush admission count.',
268
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT),
269
+ },
270
+ entryQueueMaxFlushSize: {
271
+ env: 'AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE',
272
+ description: 'Maximum number of validators admitted from the entry queue per flush.',
273
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE),
274
+ },
275
+ ...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
433
276
  };
434
277
 
278
+ /**
279
+ * Default L1 contracts configuration derived from l1ContractsConfigMappings.
280
+ * Source of truth: l1-contracts/scripts/network-defaults.json (published via @aztec/l1-artifacts).
281
+ */
282
+ export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
283
+
284
+ /**
285
+ * Validates that `ethereumSlotDuration` and `aztecSlotDuration` are positive and that the L2 slot is an exact
286
+ * multiple of the L1 slot. Every L2 slot boundary must land on an L1 slot boundary; a non-multiple pairing
287
+ * desyncs the epoch/checkpoint timing math throughout the sequencer, validator client, and timetables. Returns
288
+ * a list of error messages (empty when valid).
289
+ */
290
+ export function validateSlotDurations(
291
+ config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
292
+ ): string[] {
293
+ const errors: string[] = [];
294
+ if (config.ethereumSlotDuration <= 0) {
295
+ errors.push(`ethereumSlotDuration must be positive (got ${config.ethereumSlotDuration})`);
296
+ }
297
+ if (config.aztecSlotDuration <= 0) {
298
+ errors.push(`aztecSlotDuration must be positive (got ${config.aztecSlotDuration})`);
299
+ }
300
+ if (config.ethereumSlotDuration > 0 && config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
301
+ errors.push(
302
+ `aztecSlotDuration (${config.aztecSlotDuration}s) must be a multiple of ethereumSlotDuration ` +
303
+ `(${config.ethereumSlotDuration}s)`,
304
+ );
305
+ }
306
+ return errors;
307
+ }
308
+
309
+ /** Throws if {@link validateSlotDurations} reports any errors. */
310
+ export function assertValidSlotDurations(
311
+ config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
312
+ ): void {
313
+ const errors = validateSlotDurations(config);
314
+ if (errors.length > 0) {
315
+ throw new Error(`Invalid slot duration configuration:\n${errors.map(e => ` - ${e}`).join('\n')}`);
316
+ }
317
+ }
318
+
435
319
  export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
436
320
  testAccounts: {
437
321
  env: 'TEST_ACCOUNTS',
@@ -443,6 +327,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
443
327
  description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
444
328
  ...booleanConfigHelper(false),
445
329
  },
330
+ prefundAddresses: {
331
+ env: 'PREFUND_ADDRESSES',
332
+ description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
333
+ parseEnv: (val: string) =>
334
+ val
335
+ .split(',')
336
+ .map(a => a.trim())
337
+ .filter(a => a.length > 0),
338
+ defaultValue: [],
339
+ },
446
340
  };
447
341
 
448
342
  export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
@@ -452,205 +346,3 @@ export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
452
346
  export function getGenesisStateConfigEnvVars(): GenesisStateConfig {
453
347
  return getConfigFromMappings(genesisStateConfigMappings);
454
348
  }
455
-
456
- /**
457
- * Validates the L1 contracts configuration to ensure all requirements enforced by L1 contracts
458
- * during construction are satisfied before deployment.
459
- * Accumulates all validation errors and throws an exception listing them all if any are found.
460
- */
461
- export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsConfig>): void {
462
- const errors: string[] = [];
463
-
464
- // RollupCore constructor validation: normalFlushSizeMin > 0
465
- // From: require(_config.stakingQueueConfig.normalFlushSizeMin > 0, Errors.Staking__InvalidStakingQueueConfig());
466
- const entryQueueConfig = getEntryQueueConfig('testnet'); // Get config to check normalFlushSizeMin
467
- if (entryQueueConfig.normalFlushSizeMin <= 0n) {
468
- errors.push('normalFlushSizeMin must be greater than 0');
469
- }
470
-
471
- // TimeLib initialization validation: aztecSlotDuration should be a multiple of ethereumSlotDuration
472
- // While not explicitly required in constructor, this is a common validation for time-based systems
473
- if (config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
474
- errors.push(
475
- `aztecSlotDuration (${config.aztecSlotDuration}) must be a multiple of ethereumSlotDuration (${config.ethereumSlotDuration})`,
476
- );
477
- }
478
-
479
- // EmpireBase constructor validations for governance/slashing proposers
480
- // From: require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.EmpireBase__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
481
- const { governanceProposerQuorum, governanceProposerRoundSize } = config;
482
- if (
483
- governanceProposerQuorum !== undefined &&
484
- governanceProposerQuorum <= Math.floor(governanceProposerRoundSize / 2)
485
- ) {
486
- errors.push(
487
- `governanceProposerQuorum (${governanceProposerQuorum}) must be greater than half of governanceProposerRoundSize (${Math.floor(governanceProposerRoundSize / 2)})`,
488
- );
489
- }
490
-
491
- // From: require(QUORUM_SIZE <= ROUND_SIZE, Errors.EmpireBase__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE));
492
- if (governanceProposerQuorum !== undefined && governanceProposerQuorum > governanceProposerRoundSize) {
493
- errors.push(
494
- `governanceProposerQuorum (${governanceProposerQuorum}) cannot be larger than governanceProposerRoundSize (${governanceProposerRoundSize})`,
495
- );
496
- }
497
-
498
- // Slashing quorum validations (similar to governance quorum)
499
- const slashingRoundSize = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
500
- const { slashingQuorum } = config;
501
- if (slashingQuorum !== undefined && slashingQuorum <= Math.floor(slashingRoundSize / 2)) {
502
- errors.push(
503
- `slashingQuorum (${slashingQuorum}) must be greater than half of slashingRoundSizeInEpochs (${Math.floor(slashingRoundSize / 2)})`,
504
- );
505
- }
506
-
507
- if (slashingQuorum !== undefined && slashingQuorum > slashingRoundSize) {
508
- errors.push(
509
- `slashingQuorum (${slashingQuorum}) cannot be larger than slashingRoundSizeInEpochs (${slashingRoundSize})`,
510
- );
511
- }
512
-
513
- // EmpireBase and TallySlashingProposer lifetime and execution delay validation
514
- // From: require(LIFETIME_IN_ROUNDS > EXECUTION_DELAY_IN_ROUNDS);
515
- if (config.slashingLifetimeInRounds <= config.slashingExecutionDelayInRounds) {
516
- errors.push(
517
- `slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be greater than slashingExecutionDelayInRounds (${config.slashingExecutionDelayInRounds})`,
518
- );
519
- }
520
-
521
- // Staking asset validation: activationThreshold > ejectionThreshold
522
- if (config.activationThreshold < config.ejectionThreshold) {
523
- errors.push(
524
- `activationThreshold (${config.activationThreshold}) must be greater than ejectionThreshold (${config.ejectionThreshold})`,
525
- );
526
- }
527
-
528
- // TallySlashingProposer constructor validations
529
- if (config.slasherFlavor === 'tally') {
530
- validateTallySlasherConfig(config, errors);
531
- }
532
-
533
- // Epoch and slot duration validations
534
- if (config.aztecSlotDuration <= 0) {
535
- errors.push('aztecSlotDuration must be greater than 0');
536
- }
537
-
538
- if (config.ethereumSlotDuration <= 0) {
539
- errors.push('ethereumSlotDuration must be greater than 0');
540
- }
541
-
542
- if (config.aztecEpochDuration <= 0) {
543
- errors.push('aztecEpochDuration must be greater than 0');
544
- }
545
-
546
- // Committee size validation
547
- if (config.aztecTargetCommitteeSize < 0) {
548
- errors.push('aztecTargetCommitteeSize cannot be negative');
549
- }
550
-
551
- // Proof submission epochs validation
552
- if (config.aztecProofSubmissionEpochs < 0) {
553
- errors.push('aztecProofSubmissionEpochs cannot be negative');
554
- }
555
-
556
- // Exit delay validation
557
- if (config.exitDelaySeconds < 0) {
558
- errors.push('exitDelaySeconds cannot be negative');
559
- }
560
-
561
- // Mana validation
562
- if (config.manaTarget < 0n) {
563
- errors.push('manaTarget cannot be negative');
564
- }
565
-
566
- if (config.provingCostPerMana < 0n) {
567
- errors.push('provingCostPerMana cannot be negative');
568
- }
569
-
570
- // If any errors were found, throw an exception with all of them
571
- if (errors.length > 0) {
572
- throw new Error(
573
- `L1 contracts configuration validation failed with ${errors.length} error(s):\n${errors.map((error, index) => `${index + 1}. ${error}`).join('\n')}`,
574
- );
575
- }
576
- }
577
-
578
- function validateTallySlasherConfig(config: L1ContractsConfig, errors: string[]) {
579
- if (config.slasherFlavor !== 'tally') {
580
- return;
581
- }
582
-
583
- // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
584
- if (config.slashingOffsetInRounds <= 0) {
585
- errors.push(`slashingOffsetInRounds (${config.slashingOffsetInRounds}) must be greater than 0`);
586
- }
587
-
588
- // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
589
- const roundSizeInSlots = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
590
-
591
- // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
592
- const { slashingQuorum } = config;
593
- if (slashingQuorum !== undefined && slashingQuorum <= 0) {
594
- errors.push(`slashingQuorum (${slashingQuorum}) must be greater than 0`);
595
- }
596
-
597
- // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
598
- if (roundSizeInSlots <= 1) {
599
- errors.push(`slashing round size in slots (${roundSizeInSlots}) must be greater than 1`);
600
- }
601
-
602
- // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
603
- if (config.slashAmountSmall > config.slashAmountMedium) {
604
- errors.push(
605
- `slashAmountSmall (${config.slashAmountSmall}) must be less than or equal to slashAmountMedium (${config.slashAmountMedium})`,
606
- );
607
- }
608
-
609
- // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
610
- if (config.slashAmountMedium > config.slashAmountLarge) {
611
- errors.push(
612
- `slashAmountMedium (${config.slashAmountMedium}) must be less than or equal to slashAmountLarge (${config.slashAmountLarge})`,
613
- );
614
- }
615
-
616
- // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
617
- const ROUNDABOUT_SIZE = 128; // Constant from TallySlashingProposer
618
- if (config.slashingLifetimeInRounds >= ROUNDABOUT_SIZE) {
619
- errors.push(`slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be less than ${ROUNDABOUT_SIZE}`);
620
- }
621
-
622
- // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
623
- if (config.slashingRoundSizeInEpochs <= 0) {
624
- errors.push(`slashingRoundSizeInEpochs (${config.slashingRoundSizeInEpochs}) must be greater than 0`);
625
- }
626
-
627
- // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
628
- const MAX_ROUND_SIZE = 1024; // Constant from TallySlashingProposer
629
- if (roundSizeInSlots >= MAX_ROUND_SIZE) {
630
- errors.push(`slashing round size in slots (${roundSizeInSlots}) must be less than ${MAX_ROUND_SIZE}`);
631
- }
632
-
633
- // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
634
- if (config.aztecTargetCommitteeSize <= 0) {
635
- errors.push(`aztecTargetCommitteeSize (${config.aztecTargetCommitteeSize}) must be greater than 0`);
636
- }
637
-
638
- // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
639
- // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
640
- const voteSize = (config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) / 4;
641
- if (voteSize > 128) {
642
- errors.push(`vote size (${voteSize}) must be <= 128 (committee size * round size in epochs / 4)`);
643
- }
644
-
645
- // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
646
- if ((config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) % 4 !== 0) {
647
- errors.push(
648
- `aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs}) must be divisible by 4`,
649
- );
650
- }
651
-
652
- // Slashing offset validation: should be positive to allow proper slashing timing
653
- if (config.slashingOffsetInRounds < 0) {
654
- errors.push('slashingOffsetInRounds cannot be negative');
655
- }
656
- }