@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.21caa21

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