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

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 (229) 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/client.d.ts +5 -3
  5. package/dest/client.d.ts.map +1 -1
  6. package/dest/client.js +16 -2
  7. package/dest/config.d.ts +107 -16
  8. package/dest/config.d.ts.map +1 -1
  9. package/dest/config.js +456 -22
  10. package/dest/contracts/empire_base.d.ts +21 -6
  11. package/dest/contracts/empire_base.d.ts.map +1 -1
  12. package/dest/contracts/empire_base.js +75 -2
  13. package/dest/contracts/empire_slashing_proposer.d.ts +65 -0
  14. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
  15. package/dest/contracts/empire_slashing_proposer.js +194 -0
  16. package/dest/contracts/errors.d.ts +7 -0
  17. package/dest/contracts/errors.d.ts.map +1 -0
  18. package/dest/contracts/errors.js +12 -0
  19. package/dest/contracts/fee_asset_handler.d.ts +19 -0
  20. package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
  21. package/dest/contracts/fee_asset_handler.js +57 -0
  22. package/dest/contracts/fee_juice.d.ts +5 -6
  23. package/dest/contracts/fee_juice.d.ts.map +1 -1
  24. package/dest/contracts/fee_juice.js +27 -20
  25. package/dest/contracts/governance.d.ts +36 -25
  26. package/dest/contracts/governance.d.ts.map +1 -1
  27. package/dest/contracts/governance.js +87 -84
  28. package/dest/contracts/governance_proposer.d.ts +13 -11
  29. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  30. package/dest/contracts/governance_proposer.js +32 -18
  31. package/dest/contracts/gse.d.ts +32 -0
  32. package/dest/contracts/gse.d.ts.map +1 -0
  33. package/dest/contracts/gse.js +72 -0
  34. package/dest/contracts/inbox.d.ts +26 -0
  35. package/dest/contracts/inbox.d.ts.map +1 -0
  36. package/dest/contracts/inbox.js +45 -0
  37. package/dest/contracts/index.d.ts +8 -2
  38. package/dest/contracts/index.d.ts.map +1 -1
  39. package/dest/contracts/index.js +8 -2
  40. package/dest/contracts/multicall.d.ts +21 -0
  41. package/dest/contracts/multicall.d.ts.map +1 -0
  42. package/dest/contracts/multicall.js +156 -0
  43. package/dest/contracts/registry.d.ts +9 -4
  44. package/dest/contracts/registry.d.ts.map +1 -1
  45. package/dest/contracts/registry.js +44 -16
  46. package/dest/contracts/rollup.d.ts +202 -29
  47. package/dest/contracts/rollup.d.ts.map +1 -1
  48. package/dest/contracts/rollup.js +500 -55
  49. package/dest/contracts/slasher_contract.d.ts +44 -0
  50. package/dest/contracts/slasher_contract.d.ts.map +1 -0
  51. package/dest/contracts/slasher_contract.js +75 -0
  52. package/dest/contracts/tally_slashing_proposer.d.ts +138 -0
  53. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
  54. package/dest/contracts/tally_slashing_proposer.js +313 -0
  55. package/dest/contracts/utils.d.ts +3 -0
  56. package/dest/contracts/utils.d.ts.map +1 -0
  57. package/dest/contracts/utils.js +11 -0
  58. package/dest/deploy_l1_contracts.d.ts +128 -21112
  59. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  60. package/dest/deploy_l1_contracts.js +1204 -418
  61. package/dest/eth-signer/eth-signer.d.ts +21 -0
  62. package/dest/eth-signer/eth-signer.d.ts.map +1 -0
  63. package/dest/eth-signer/eth-signer.js +5 -0
  64. package/dest/eth-signer/index.d.ts +2 -0
  65. package/dest/eth-signer/index.d.ts.map +1 -0
  66. package/dest/eth-signer/index.js +1 -0
  67. package/dest/index.d.ts +6 -2
  68. package/dest/index.d.ts.map +1 -1
  69. package/dest/index.js +6 -2
  70. package/dest/l1_artifacts.d.ts +76184 -0
  71. package/dest/l1_artifacts.d.ts.map +1 -0
  72. package/dest/l1_artifacts.js +166 -0
  73. package/dest/l1_contract_addresses.d.ts +21 -1
  74. package/dest/l1_contract_addresses.d.ts.map +1 -1
  75. package/dest/l1_contract_addresses.js +22 -18
  76. package/dest/l1_reader.d.ts +1 -1
  77. package/dest/l1_reader.d.ts.map +1 -1
  78. package/dest/l1_reader.js +8 -8
  79. package/dest/l1_tx_utils/config.d.ts +59 -0
  80. package/dest/l1_tx_utils/config.d.ts.map +1 -0
  81. package/dest/l1_tx_utils/config.js +73 -0
  82. package/dest/l1_tx_utils/constants.d.ts +6 -0
  83. package/dest/l1_tx_utils/constants.d.ts.map +1 -0
  84. package/dest/l1_tx_utils/constants.js +14 -0
  85. package/dest/l1_tx_utils/factory.d.ts +24 -0
  86. package/dest/l1_tx_utils/factory.d.ts.map +1 -0
  87. package/dest/l1_tx_utils/factory.js +12 -0
  88. package/dest/l1_tx_utils/index.d.ts +10 -0
  89. package/dest/l1_tx_utils/index.d.ts.map +1 -0
  90. package/dest/l1_tx_utils/index.js +10 -0
  91. package/dest/l1_tx_utils/interfaces.d.ts +76 -0
  92. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
  93. package/dest/l1_tx_utils/interfaces.js +4 -0
  94. package/dest/l1_tx_utils/l1_tx_utils.d.ts +95 -0
  95. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
  96. package/dest/l1_tx_utils/l1_tx_utils.js +610 -0
  97. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
  98. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
  99. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
  100. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +94 -0
  101. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
  102. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +431 -0
  103. package/dest/l1_tx_utils/signer.d.ts +4 -0
  104. package/dest/l1_tx_utils/signer.d.ts.map +1 -0
  105. package/dest/l1_tx_utils/signer.js +16 -0
  106. package/dest/l1_tx_utils/types.d.ts +67 -0
  107. package/dest/l1_tx_utils/types.d.ts.map +1 -0
  108. package/dest/l1_tx_utils/types.js +26 -0
  109. package/dest/l1_tx_utils/utils.d.ts +4 -0
  110. package/dest/l1_tx_utils/utils.d.ts.map +1 -0
  111. package/dest/l1_tx_utils/utils.js +14 -0
  112. package/dest/l1_types.d.ts +6 -0
  113. package/dest/l1_types.d.ts.map +1 -0
  114. package/dest/l1_types.js +1 -0
  115. package/dest/publisher_manager.d.ts +15 -0
  116. package/dest/publisher_manager.d.ts.map +1 -0
  117. package/dest/publisher_manager.js +88 -0
  118. package/dest/queries.d.ts +3 -1
  119. package/dest/queries.d.ts.map +1 -1
  120. package/dest/queries.js +51 -12
  121. package/dest/test/chain_monitor.d.ts +72 -0
  122. package/dest/test/chain_monitor.d.ts.map +1 -0
  123. package/dest/test/chain_monitor.js +216 -0
  124. package/dest/test/delayed_tx_utils.d.ts +7 -2
  125. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  126. package/dest/test/delayed_tx_utils.js +13 -6
  127. package/dest/{eth_cheat_codes.d.ts → test/eth_cheat_codes.d.ts} +87 -13
  128. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  129. package/dest/test/eth_cheat_codes.js +552 -0
  130. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  131. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  132. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  133. package/dest/test/index.d.ts +3 -0
  134. package/dest/test/index.d.ts.map +1 -1
  135. package/dest/test/index.js +3 -0
  136. package/dest/test/rollup_cheat_codes.d.ts +86 -0
  137. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  138. package/dest/test/rollup_cheat_codes.js +268 -0
  139. package/dest/test/start_anvil.d.ts +5 -0
  140. package/dest/test/start_anvil.d.ts.map +1 -1
  141. package/dest/test/start_anvil.js +15 -7
  142. package/dest/test/tx_delayer.d.ts +17 -6
  143. package/dest/test/tx_delayer.d.ts.map +1 -1
  144. package/dest/test/tx_delayer.js +95 -19
  145. package/dest/test/upgrade_utils.d.ts +5 -4
  146. package/dest/test/upgrade_utils.d.ts.map +1 -1
  147. package/dest/test/upgrade_utils.js +23 -16
  148. package/dest/types.d.ts +6 -7
  149. package/dest/types.d.ts.map +1 -1
  150. package/dest/types.js +3 -1
  151. package/dest/utils.d.ts +1 -0
  152. package/dest/utils.d.ts.map +1 -1
  153. package/dest/utils.js +43 -88
  154. package/dest/zkPassportVerifierAddress.d.ts +15 -0
  155. package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
  156. package/dest/zkPassportVerifierAddress.js +11 -0
  157. package/package.json +24 -16
  158. package/src/account.ts +5 -0
  159. package/src/client.ts +42 -4
  160. package/src/config.ts +584 -31
  161. package/src/contracts/empire_base.ts +75 -6
  162. package/src/contracts/empire_slashing_proposer.ts +259 -0
  163. package/src/contracts/errors.ts +13 -0
  164. package/src/contracts/fee_asset_handler.ts +63 -0
  165. package/src/contracts/fee_juice.ts +29 -15
  166. package/src/contracts/governance.ts +80 -77
  167. package/src/contracts/governance_proposer.ts +60 -24
  168. package/src/contracts/gse.ts +88 -0
  169. package/src/contracts/inbox.ts +63 -0
  170. package/src/contracts/index.ts +8 -2
  171. package/src/contracts/multicall.ts +155 -0
  172. package/src/contracts/registry.ts +51 -26
  173. package/src/contracts/rollup.ts +585 -56
  174. package/src/contracts/slasher_contract.ts +89 -0
  175. package/src/contracts/tally_slashing_proposer.ts +315 -0
  176. package/src/contracts/utils.ts +14 -0
  177. package/src/deploy_l1_contracts.ts +1467 -566
  178. package/src/eth-signer/eth-signer.ts +25 -0
  179. package/src/eth-signer/index.ts +1 -0
  180. package/src/index.ts +6 -2
  181. package/src/l1_artifacts.ts +254 -0
  182. package/src/l1_contract_addresses.ts +32 -19
  183. package/src/l1_reader.ts +9 -9
  184. package/src/l1_tx_utils/README.md +177 -0
  185. package/src/l1_tx_utils/config.ts +140 -0
  186. package/src/l1_tx_utils/constants.ts +18 -0
  187. package/src/l1_tx_utils/factory.ts +64 -0
  188. package/src/l1_tx_utils/index.ts +12 -0
  189. package/src/l1_tx_utils/interfaces.ts +86 -0
  190. package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
  191. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
  192. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +559 -0
  193. package/src/l1_tx_utils/signer.ts +28 -0
  194. package/src/l1_tx_utils/types.ts +85 -0
  195. package/src/l1_tx_utils/utils.ts +16 -0
  196. package/src/l1_types.ts +6 -0
  197. package/src/publisher_manager.ts +106 -0
  198. package/src/queries.ts +70 -15
  199. package/src/test/chain_monitor.ts +243 -0
  200. package/src/test/delayed_tx_utils.ts +34 -6
  201. package/src/test/eth_cheat_codes.ts +582 -0
  202. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  203. package/src/test/index.ts +3 -0
  204. package/src/test/rollup_cheat_codes.ts +310 -0
  205. package/src/test/start_anvil.ts +20 -5
  206. package/src/test/tx_delayer.ts +127 -26
  207. package/src/test/upgrade_utils.ts +30 -21
  208. package/src/types.ts +10 -8
  209. package/src/utils.ts +49 -90
  210. package/src/zkPassportVerifierAddress.ts +15 -0
  211. package/dest/contracts/forwarder.d.ts +0 -24
  212. package/dest/contracts/forwarder.d.ts.map +0 -1
  213. package/dest/contracts/forwarder.js +0 -101
  214. package/dest/contracts/slashing_proposer.d.ts +0 -21
  215. package/dest/contracts/slashing_proposer.d.ts.map +0 -1
  216. package/dest/contracts/slashing_proposer.js +0 -47
  217. package/dest/eth_cheat_codes.d.ts.map +0 -1
  218. package/dest/eth_cheat_codes.js +0 -303
  219. package/dest/l1_tx_utils.d.ts +0 -192
  220. package/dest/l1_tx_utils.d.ts.map +0 -1
  221. package/dest/l1_tx_utils.js +0 -641
  222. package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
  223. package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
  224. package/dest/l1_tx_utils_with_blobs.js +0 -64
  225. package/src/contracts/forwarder.ts +0 -132
  226. package/src/contracts/slashing_proposer.ts +0 -51
  227. package/src/eth_cheat_codes.ts +0 -314
  228. package/src/l1_tx_utils.ts +0 -847
  229. package/src/l1_tx_utils_with_blobs.ts +0 -86
package/dest/config.js CHANGED
@@ -1,16 +1,212 @@
1
- import { bigintConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
2
- import { l1TxUtilsConfigMappings } from './l1_tx_utils.js';
1
+ import { bigintConfigHelper, booleanConfigHelper, enumConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { l1TxUtilsConfigMappings } from './l1_tx_utils/index.js';
3
4
  export const DefaultL1ContractsConfig = {
4
5
  ethereumSlotDuration: 12,
5
- aztecSlotDuration: 24,
6
- aztecEpochDuration: 16,
6
+ aztecSlotDuration: 36,
7
+ aztecEpochDuration: 32,
7
8
  aztecTargetCommitteeSize: 48,
8
- aztecProofSubmissionWindow: 31,
9
- minimumStake: BigInt(100e18),
10
- slashingQuorum: 6,
11
- slashingRoundSize: 10,
12
- governanceProposerQuorum: 6,
13
- governanceProposerRoundSize: 10
9
+ lagInEpochs: 2,
10
+ aztecProofSubmissionEpochs: 1,
11
+ activationThreshold: 100n * 10n ** 18n,
12
+ ejectionThreshold: 50n * 10n ** 18n,
13
+ localEjectionThreshold: 98n * 10n ** 18n,
14
+ slashAmountSmall: 10n * 10n ** 18n,
15
+ slashAmountMedium: 20n * 10n ** 18n,
16
+ slashAmountLarge: 50n * 10n ** 18n,
17
+ slashingRoundSizeInEpochs: 4,
18
+ slashingLifetimeInRounds: 5,
19
+ slashingExecutionDelayInRounds: 0,
20
+ slashingVetoer: EthAddress.ZERO,
21
+ governanceProposerRoundSize: 300,
22
+ manaTarget: BigInt(1e10),
23
+ provingCostPerMana: BigInt(100),
24
+ exitDelaySeconds: 2 * 24 * 60 * 60,
25
+ slasherFlavor: 'tally',
26
+ slashingOffsetInRounds: 2,
27
+ slashingDisableDuration: 5 * 24 * 60 * 60
28
+ };
29
+ const LocalGovernanceConfiguration = {
30
+ proposeConfig: {
31
+ lockDelay: 60n * 60n * 24n * 30n,
32
+ lockAmount: 1n * 10n ** 24n
33
+ },
34
+ votingDelay: 60n,
35
+ votingDuration: 60n * 60n,
36
+ executionDelay: 60n,
37
+ gracePeriod: 60n * 60n * 24n * 7n,
38
+ quorum: 1n * 10n ** 17n,
39
+ requiredYeaMargin: 4n * 10n ** 16n,
40
+ minimumVotes: 400n * 10n ** 18n
41
+ };
42
+ const StagingPublicGovernanceConfiguration = {
43
+ proposeConfig: {
44
+ lockDelay: 60n * 60n * 24n * 30n,
45
+ lockAmount: DefaultL1ContractsConfig.activationThreshold * 100n
46
+ },
47
+ votingDelay: 60n,
48
+ votingDuration: 60n * 60n,
49
+ executionDelay: 60n,
50
+ gracePeriod: 60n * 60n * 24n * 7n,
51
+ quorum: 3n * 10n ** 17n,
52
+ requiredYeaMargin: 4n * 10n ** 16n,
53
+ minimumVotes: DefaultL1ContractsConfig.ejectionThreshold * 200n
54
+ };
55
+ const TestnetGovernanceConfiguration = {
56
+ proposeConfig: {
57
+ lockDelay: 10n * 365n * 24n * 60n * 60n,
58
+ lockAmount: 1250n * 200_000n * 10n ** 18n
59
+ },
60
+ votingDelay: 12n * 60n * 60n,
61
+ votingDuration: 1n * 24n * 60n * 60n,
62
+ executionDelay: 12n * 60n * 60n,
63
+ gracePeriod: 1n * 24n * 60n * 60n,
64
+ quorum: 2n * 10n ** 17n,
65
+ requiredYeaMargin: 1n * 10n ** 17n,
66
+ minimumVotes: 100n * 200_000n * 10n ** 18n
67
+ };
68
+ const StagingIgnitionGovernanceConfiguration = {
69
+ proposeConfig: {
70
+ lockDelay: 10n * 365n * 24n * 60n * 60n,
71
+ lockAmount: 1250n * 200_000n * 10n ** 18n
72
+ },
73
+ votingDelay: 7n * 24n * 60n * 60n,
74
+ votingDuration: 7n * 24n * 60n * 60n,
75
+ executionDelay: 30n * 24n * 60n * 60n,
76
+ gracePeriod: 7n * 24n * 60n * 60n,
77
+ quorum: 2n * 10n ** 17n,
78
+ requiredYeaMargin: 1n * 10n ** 17n,
79
+ minimumVotes: 1250n * 200_000n * 10n ** 18n
80
+ };
81
+ const MainnetGovernanceConfiguration = {
82
+ proposeConfig: {
83
+ lockDelay: 90n * 24n * 60n * 60n,
84
+ lockAmount: 258_750_000n * 10n ** 18n
85
+ },
86
+ votingDelay: 3n * 24n * 60n * 60n,
87
+ votingDuration: 7n * 24n * 60n * 60n,
88
+ executionDelay: 7n * 24n * 60n * 60n,
89
+ gracePeriod: 7n * 24n * 60n * 60n,
90
+ quorum: 2n * 10n ** 17n,
91
+ requiredYeaMargin: 33n * 10n ** 16n,
92
+ minimumVotes: 1000n * 200_000n * 10n ** 18n
93
+ };
94
+ export const getGovernanceConfiguration = (networkName)=>{
95
+ switch(networkName){
96
+ case 'local':
97
+ return LocalGovernanceConfiguration;
98
+ case 'next-net':
99
+ return LocalGovernanceConfiguration;
100
+ case 'devnet':
101
+ return LocalGovernanceConfiguration;
102
+ case 'staging-public':
103
+ return StagingPublicGovernanceConfiguration;
104
+ case 'testnet':
105
+ return TestnetGovernanceConfiguration;
106
+ case 'staging-ignition':
107
+ return StagingIgnitionGovernanceConfiguration;
108
+ case 'mainnet':
109
+ return MainnetGovernanceConfiguration;
110
+ default:
111
+ throw new Error(`Unrecognized network name: ${networkName}`);
112
+ }
113
+ };
114
+ // Making a default config here as we are only using it thought the deployment
115
+ // and do not expect to be using different setups, so having environment variables
116
+ // for it seems overkill
117
+ const DefaultRewardConfig = {
118
+ sequencerBps: 8000,
119
+ rewardDistributor: EthAddress.ZERO.toString(),
120
+ booster: EthAddress.ZERO.toString(),
121
+ blockReward: 500n * 10n ** 18n
122
+ };
123
+ const MainnetRewardConfig = {
124
+ sequencerBps: 7_000,
125
+ rewardDistributor: EthAddress.ZERO.toString(),
126
+ booster: EthAddress.ZERO.toString(),
127
+ blockReward: 400n * 10n ** 18n
128
+ };
129
+ export const getRewardConfig = (networkName)=>{
130
+ switch(networkName){
131
+ case 'local':
132
+ case 'devnet':
133
+ case 'next-net':
134
+ case 'staging-public':
135
+ case 'testnet':
136
+ case 'staging-ignition':
137
+ return DefaultRewardConfig;
138
+ case 'mainnet':
139
+ return MainnetRewardConfig;
140
+ default:
141
+ throw new Error(`Unrecognized network name: ${networkName}`);
142
+ }
143
+ };
144
+ export const getRewardBoostConfig = ()=>{
145
+ // The reward configuration is specified with a precision of 1e5, and we use the same across
146
+ // all networks.
147
+ return {
148
+ increment: 125_000,
149
+ maxScore: 15_000_000,
150
+ a: 1_000,
151
+ k: 1_000_000,
152
+ minimum: 100_000
153
+ };
154
+ };
155
+ // Similar to the above, no need for environment variables for this.
156
+ const LocalEntryQueueConfig = {
157
+ bootstrapValidatorSetSize: 0n,
158
+ bootstrapFlushSize: 0n,
159
+ normalFlushSizeMin: 48n,
160
+ normalFlushSizeQuotient: 2n,
161
+ maxQueueFlushSize: 48n
162
+ };
163
+ const StagingPublicEntryQueueConfig = {
164
+ bootstrapValidatorSetSize: 48n,
165
+ bootstrapFlushSize: 48n,
166
+ normalFlushSizeMin: 1n,
167
+ normalFlushSizeQuotient: 2475n,
168
+ maxQueueFlushSize: 32n
169
+ };
170
+ const TestnetEntryQueueConfig = {
171
+ bootstrapValidatorSetSize: 256n,
172
+ bootstrapFlushSize: 256n,
173
+ normalFlushSizeMin: 4n,
174
+ normalFlushSizeQuotient: 2048n,
175
+ maxQueueFlushSize: 8n
176
+ };
177
+ const StagingIgnitionEntryQueueConfig = {
178
+ bootstrapValidatorSetSize: 48n,
179
+ bootstrapFlushSize: 48n,
180
+ normalFlushSizeMin: 1n,
181
+ normalFlushSizeQuotient: 2048n,
182
+ maxQueueFlushSize: 24n
183
+ };
184
+ const MainnetEntryQueueConfig = {
185
+ bootstrapValidatorSetSize: 1_000n,
186
+ bootstrapFlushSize: 1_000n,
187
+ normalFlushSizeMin: 1n,
188
+ normalFlushSizeQuotient: 2_048n,
189
+ maxQueueFlushSize: 8n
190
+ };
191
+ export const getEntryQueueConfig = (networkName)=>{
192
+ switch(networkName){
193
+ case 'local':
194
+ return LocalEntryQueueConfig;
195
+ case 'next-net':
196
+ return LocalEntryQueueConfig;
197
+ case 'devnet':
198
+ return LocalEntryQueueConfig;
199
+ case 'staging-public':
200
+ return StagingPublicEntryQueueConfig;
201
+ case 'testnet':
202
+ return TestnetEntryQueueConfig;
203
+ case 'staging-ignition':
204
+ return StagingIgnitionEntryQueueConfig;
205
+ case 'mainnet':
206
+ return MainnetEntryQueueConfig;
207
+ default:
208
+ throw new Error(`Unrecognized network name: ${networkName}`);
209
+ }
14
210
  };
15
211
  export const l1ContractsConfigMappings = {
16
212
  ethereumSlotDuration: {
@@ -33,38 +229,276 @@ export const l1ContractsConfigMappings = {
33
229
  description: 'The target validator committee size.',
34
230
  ...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize)
35
231
  },
36
- aztecProofSubmissionWindow: {
37
- env: 'AZTEC_PROOF_SUBMISSION_WINDOW',
38
- description: 'The number of L2 slots that a proof for an epoch can be submitted in, starting from the beginning of the epoch.',
39
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionWindow)
232
+ lagInEpochs: {
233
+ env: 'AZTEC_LAG_IN_EPOCHS',
234
+ description: 'The number of epochs to lag behind the current epoch for validator selection.',
235
+ ...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochs)
40
236
  },
41
- minimumStake: {
42
- env: 'AZTEC_MINIMUM_STAKE',
237
+ aztecProofSubmissionEpochs: {
238
+ env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
239
+ description: 'The number of epochs after an epoch ends that proofs are still accepted.',
240
+ ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionEpochs)
241
+ },
242
+ activationThreshold: {
243
+ env: 'AZTEC_ACTIVATION_THRESHOLD',
244
+ description: 'The deposit amount for a validator',
245
+ ...bigintConfigHelper(DefaultL1ContractsConfig.activationThreshold)
246
+ },
247
+ ejectionThreshold: {
248
+ env: 'AZTEC_EJECTION_THRESHOLD',
43
249
  description: 'The minimum stake for a validator.',
44
- ...bigintConfigHelper(DefaultL1ContractsConfig.minimumStake)
250
+ ...bigintConfigHelper(DefaultL1ContractsConfig.ejectionThreshold)
251
+ },
252
+ localEjectionThreshold: {
253
+ env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
254
+ description: 'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
255
+ ...bigintConfigHelper(DefaultL1ContractsConfig.localEjectionThreshold)
256
+ },
257
+ slashingOffsetInRounds: {
258
+ env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
259
+ description: 'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
260
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingOffsetInRounds)
261
+ },
262
+ slasherFlavor: {
263
+ env: 'AZTEC_SLASHER_FLAVOR',
264
+ description: 'Type of slasher proposer (empire, tally, or none)',
265
+ ...enumConfigHelper([
266
+ 'empire',
267
+ 'tally',
268
+ 'none'
269
+ ], DefaultL1ContractsConfig.slasherFlavor)
270
+ },
271
+ slashAmountSmall: {
272
+ env: 'AZTEC_SLASH_AMOUNT_SMALL',
273
+ description: 'Small slashing amount for light offenses',
274
+ ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountSmall)
275
+ },
276
+ slashAmountMedium: {
277
+ env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
278
+ description: 'Medium slashing amount for moderate offenses',
279
+ ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountMedium)
280
+ },
281
+ slashAmountLarge: {
282
+ env: 'AZTEC_SLASH_AMOUNT_LARGE',
283
+ description: 'Large slashing amount for severe offenses',
284
+ ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountLarge)
45
285
  },
46
286
  slashingQuorum: {
47
287
  env: 'AZTEC_SLASHING_QUORUM',
48
288
  description: 'The slashing quorum',
49
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingQuorum)
289
+ ...optionalNumberConfigHelper()
50
290
  },
51
- slashingRoundSize: {
52
- env: 'AZTEC_SLASHING_ROUND_SIZE',
291
+ slashingRoundSizeInEpochs: {
292
+ env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
53
293
  description: 'The slashing round size',
54
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSize)
294
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSizeInEpochs)
295
+ },
296
+ slashingLifetimeInRounds: {
297
+ env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
298
+ description: 'The slashing lifetime in rounds',
299
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingLifetimeInRounds)
300
+ },
301
+ slashingExecutionDelayInRounds: {
302
+ env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
303
+ description: 'The slashing execution delay in rounds',
304
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingExecutionDelayInRounds)
305
+ },
306
+ slashingVetoer: {
307
+ env: 'AZTEC_SLASHING_VETOER',
308
+ description: 'The slashing vetoer',
309
+ parseEnv: (val)=>EthAddress.fromString(val),
310
+ defaultValue: DefaultL1ContractsConfig.slashingVetoer
311
+ },
312
+ slashingDisableDuration: {
313
+ env: 'AZTEC_SLASHING_DISABLE_DURATION',
314
+ description: 'How long slashing can be disabled for in seconds when vetoer disables it',
315
+ ...numberConfigHelper(DefaultL1ContractsConfig.slashingDisableDuration)
55
316
  },
56
317
  governanceProposerQuorum: {
57
318
  env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
58
319
  description: 'The governance proposing quorum',
59
- ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerQuorum)
320
+ ...optionalNumberConfigHelper()
60
321
  },
61
322
  governanceProposerRoundSize: {
62
323
  env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
63
324
  description: 'The governance proposing round size',
64
325
  ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerRoundSize)
65
326
  },
327
+ manaTarget: {
328
+ env: 'AZTEC_MANA_TARGET',
329
+ description: 'The mana target for the rollup',
330
+ ...bigintConfigHelper(DefaultL1ContractsConfig.manaTarget)
331
+ },
332
+ provingCostPerMana: {
333
+ env: 'AZTEC_PROVING_COST_PER_MANA',
334
+ description: 'The proving cost per mana',
335
+ ...bigintConfigHelper(DefaultL1ContractsConfig.provingCostPerMana)
336
+ },
337
+ exitDelaySeconds: {
338
+ env: 'AZTEC_EXIT_DELAY_SECONDS',
339
+ description: 'The delay before a validator can exit the set',
340
+ ...numberConfigHelper(DefaultL1ContractsConfig.exitDelaySeconds)
341
+ },
66
342
  ...l1TxUtilsConfigMappings
67
343
  };
344
+ export const genesisStateConfigMappings = {
345
+ testAccounts: {
346
+ env: 'TEST_ACCOUNTS',
347
+ description: 'Whether to populate the genesis state with initial fee juice for the test accounts.',
348
+ ...booleanConfigHelper(false)
349
+ },
350
+ sponsoredFPC: {
351
+ env: 'SPONSORED_FPC',
352
+ description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
353
+ ...booleanConfigHelper(false)
354
+ }
355
+ };
68
356
  export function getL1ContractsConfigEnvVars() {
69
357
  return getConfigFromMappings(l1ContractsConfigMappings);
70
358
  }
359
+ export function getGenesisStateConfigEnvVars() {
360
+ return getConfigFromMappings(genesisStateConfigMappings);
361
+ }
362
+ /**
363
+ * Validates the L1 contracts configuration to ensure all requirements enforced by L1 contracts
364
+ * during construction are satisfied before deployment.
365
+ * Accumulates all validation errors and throws an exception listing them all if any are found.
366
+ */ export function validateConfig(config) {
367
+ const errors = [];
368
+ // RollupCore constructor validation: normalFlushSizeMin > 0
369
+ // From: require(_config.stakingQueueConfig.normalFlushSizeMin > 0, Errors.Staking__InvalidStakingQueueConfig());
370
+ const entryQueueConfig = getEntryQueueConfig('testnet'); // Get config to check normalFlushSizeMin
371
+ if (entryQueueConfig.normalFlushSizeMin <= 0n) {
372
+ errors.push('normalFlushSizeMin must be greater than 0');
373
+ }
374
+ // TimeLib initialization validation: aztecSlotDuration should be a multiple of ethereumSlotDuration
375
+ // While not explicitly required in constructor, this is a common validation for time-based systems
376
+ if (config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
377
+ errors.push(`aztecSlotDuration (${config.aztecSlotDuration}) must be a multiple of ethereumSlotDuration (${config.ethereumSlotDuration})`);
378
+ }
379
+ // EmpireBase constructor validations for governance/slashing proposers
380
+ // From: require(QUORUM_SIZE > ROUND_SIZE / 2, Errors.EmpireBase__InvalidQuorumAndRoundSize(QUORUM_SIZE, ROUND_SIZE));
381
+ const { governanceProposerQuorum, governanceProposerRoundSize } = config;
382
+ if (governanceProposerQuorum !== undefined && governanceProposerQuorum <= Math.floor(governanceProposerRoundSize / 2)) {
383
+ errors.push(`governanceProposerQuorum (${governanceProposerQuorum}) must be greater than half of governanceProposerRoundSize (${Math.floor(governanceProposerRoundSize / 2)})`);
384
+ }
385
+ // From: require(QUORUM_SIZE <= ROUND_SIZE, Errors.EmpireBase__QuorumCannotBeLargerThanRoundSize(QUORUM_SIZE, ROUND_SIZE));
386
+ if (governanceProposerQuorum !== undefined && governanceProposerQuorum > governanceProposerRoundSize) {
387
+ errors.push(`governanceProposerQuorum (${governanceProposerQuorum}) cannot be larger than governanceProposerRoundSize (${governanceProposerRoundSize})`);
388
+ }
389
+ // Slashing quorum validations (similar to governance quorum)
390
+ const slashingRoundSize = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
391
+ const { slashingQuorum } = config;
392
+ if (slashingQuorum !== undefined && slashingQuorum <= Math.floor(slashingRoundSize / 2)) {
393
+ errors.push(`slashingQuorum (${slashingQuorum}) must be greater than half of slashingRoundSizeInEpochs (${Math.floor(slashingRoundSize / 2)})`);
394
+ }
395
+ if (slashingQuorum !== undefined && slashingQuorum > slashingRoundSize) {
396
+ errors.push(`slashingQuorum (${slashingQuorum}) cannot be larger than slashingRoundSizeInEpochs (${slashingRoundSize})`);
397
+ }
398
+ // EmpireBase and TallySlashingProposer lifetime and execution delay validation
399
+ // From: require(LIFETIME_IN_ROUNDS > EXECUTION_DELAY_IN_ROUNDS);
400
+ if (config.slashingLifetimeInRounds <= config.slashingExecutionDelayInRounds) {
401
+ errors.push(`slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be greater than slashingExecutionDelayInRounds (${config.slashingExecutionDelayInRounds})`);
402
+ }
403
+ // Staking asset validation: activationThreshold > ejectionThreshold
404
+ if (config.activationThreshold < config.ejectionThreshold) {
405
+ errors.push(`activationThreshold (${config.activationThreshold}) must be greater than ejectionThreshold (${config.ejectionThreshold})`);
406
+ }
407
+ // TallySlashingProposer constructor validations
408
+ if (config.slasherFlavor === 'tally') {
409
+ validateTallySlasherConfig(config, errors);
410
+ }
411
+ // Epoch and slot duration validations
412
+ if (config.aztecSlotDuration <= 0) {
413
+ errors.push('aztecSlotDuration must be greater than 0');
414
+ }
415
+ if (config.ethereumSlotDuration <= 0) {
416
+ errors.push('ethereumSlotDuration must be greater than 0');
417
+ }
418
+ if (config.aztecEpochDuration <= 0) {
419
+ errors.push('aztecEpochDuration must be greater than 0');
420
+ }
421
+ // Committee size validation
422
+ if (config.aztecTargetCommitteeSize < 0) {
423
+ errors.push('aztecTargetCommitteeSize cannot be negative');
424
+ }
425
+ // Proof submission epochs validation
426
+ if (config.aztecProofSubmissionEpochs < 0) {
427
+ errors.push('aztecProofSubmissionEpochs cannot be negative');
428
+ }
429
+ // Exit delay validation
430
+ if (config.exitDelaySeconds < 0) {
431
+ errors.push('exitDelaySeconds cannot be negative');
432
+ }
433
+ // Mana validation
434
+ if (config.manaTarget < 0n) {
435
+ errors.push('manaTarget cannot be negative');
436
+ }
437
+ if (config.provingCostPerMana < 0n) {
438
+ errors.push('provingCostPerMana cannot be negative');
439
+ }
440
+ // If any errors were found, throw an exception with all of them
441
+ if (errors.length > 0) {
442
+ throw new Error(`L1 contracts configuration validation failed with ${errors.length} error(s):\n${errors.map((error, index)=>`${index + 1}. ${error}`).join('\n')}`);
443
+ }
444
+ }
445
+ function validateTallySlasherConfig(config, errors) {
446
+ if (config.slasherFlavor !== 'tally') {
447
+ return;
448
+ }
449
+ // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
450
+ if (config.slashingOffsetInRounds <= 0) {
451
+ errors.push(`slashingOffsetInRounds (${config.slashingOffsetInRounds}) must be greater than 0`);
452
+ }
453
+ // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
454
+ const roundSizeInSlots = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
455
+ // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
456
+ const { slashingQuorum } = config;
457
+ if (slashingQuorum !== undefined && slashingQuorum <= 0) {
458
+ errors.push(`slashingQuorum (${slashingQuorum}) must be greater than 0`);
459
+ }
460
+ // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
461
+ if (roundSizeInSlots <= 1) {
462
+ errors.push(`slashing round size in slots (${roundSizeInSlots}) must be greater than 1`);
463
+ }
464
+ // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
465
+ if (config.slashAmountSmall > config.slashAmountMedium) {
466
+ errors.push(`slashAmountSmall (${config.slashAmountSmall}) must be less than or equal to slashAmountMedium (${config.slashAmountMedium})`);
467
+ }
468
+ // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
469
+ if (config.slashAmountMedium > config.slashAmountLarge) {
470
+ errors.push(`slashAmountMedium (${config.slashAmountMedium}) must be less than or equal to slashAmountLarge (${config.slashAmountLarge})`);
471
+ }
472
+ // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
473
+ const ROUNDABOUT_SIZE = 128; // Constant from TallySlashingProposer
474
+ if (config.slashingLifetimeInRounds >= ROUNDABOUT_SIZE) {
475
+ errors.push(`slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be less than ${ROUNDABOUT_SIZE}`);
476
+ }
477
+ // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
478
+ if (config.slashingRoundSizeInEpochs <= 0) {
479
+ errors.push(`slashingRoundSizeInEpochs (${config.slashingRoundSizeInEpochs}) must be greater than 0`);
480
+ }
481
+ // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
482
+ const MAX_ROUND_SIZE = 1024; // Constant from TallySlashingProposer
483
+ if (roundSizeInSlots >= MAX_ROUND_SIZE) {
484
+ errors.push(`slashing round size in slots (${roundSizeInSlots}) must be less than ${MAX_ROUND_SIZE}`);
485
+ }
486
+ // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
487
+ if (config.aztecTargetCommitteeSize <= 0) {
488
+ errors.push(`aztecTargetCommitteeSize (${config.aztecTargetCommitteeSize}) must be greater than 0`);
489
+ }
490
+ // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
491
+ // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
492
+ const voteSize = config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs / 4;
493
+ if (voteSize > 128) {
494
+ errors.push(`vote size (${voteSize}) must be <= 128 (committee size * round size in epochs / 4)`);
495
+ }
496
+ // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
497
+ if (config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs % 4 !== 0) {
498
+ errors.push(`aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs}) must be divisible by 4`);
499
+ }
500
+ // Slashing offset validation: should be positive to allow proper slashing timing
501
+ if (config.slashingOffsetInRounds < 0) {
502
+ errors.push('slashingOffsetInRounds cannot be negative');
503
+ }
504
+ }
@@ -1,13 +1,28 @@
1
- import { type Hex } from 'viem';
2
- import type { L1TxRequest } from '../l1_tx_utils.js';
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { Signature } from '@aztec/foundation/eth-signature';
3
+ import { type Hex, type TypedDataDefinition } from 'viem';
4
+ import type { L1TxRequest } from '../l1_tx_utils/index.js';
3
5
  export interface IEmpireBase {
6
+ get address(): EthAddress;
4
7
  getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
5
- lastVote: bigint;
6
- leader: Hex;
8
+ lastSignalSlot: bigint;
9
+ payloadWithMostSignals: Hex;
7
10
  executed: boolean;
8
11
  }>;
9
12
  computeRound(slot: bigint): Promise<bigint>;
10
- createVoteRequest(payload: Hex): L1TxRequest;
13
+ createSignalRequest(payload: Hex): L1TxRequest;
14
+ createSignalRequestWithSignature(payload: Hex, round: bigint, chainId: number, signerAddress: Hex, signer: (msg: TypedDataDefinition) => Promise<Hex>): Promise<L1TxRequest>;
11
15
  }
12
- export declare function encodeVote(payload: Hex): Hex;
16
+ export declare function encodeSignal(payload: Hex): Hex;
17
+ export declare function encodeSignalWithSignature(payload: Hex, signature: Signature): `0x${string}`;
18
+ /**
19
+ * Signs a signal proposal using EIP-712 typed data for use with signalWithSig
20
+ * @param walletClient - The viem wallet client to sign with
21
+ * @param payload - The payload address to signal
22
+ * @param verifyingContract - The address of the EmpireBase contract
23
+ * @param chainId - The chain ID where the contract is deployed
24
+ * @param account - The account to sign with (optional if hoisted on wallet client)
25
+ * @returns The EIP-712 signature
26
+ */
27
+ export declare function signSignalWithSig(signer: (msg: TypedDataDefinition) => Promise<Hex>, payload: Hex, slot: bigint, instance: Hex, verifyingContract: Hex, chainId: number): Promise<Signature>;
13
28
  //# sourceMappingURL=empire_base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"empire_base.d.ts","sourceRoot":"","sources":["../../src/contracts/empire_base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAsB,MAAM,MAAM,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/G,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,CAAC;CAC9C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAM5C"}
1
+ {"version":3,"file":"empire_base.d.ts","sourceRoot":"","sources":["../../src/contracts/empire_base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,mBAAmB,EAAsB,MAAM,MAAM,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,IAAI,OAAO,IAAI,UAAU,CAAC;IAC1B,YAAY,CACV,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,sBAAsB,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvF,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,CAAC;IAC/C,gCAAgC,CAC9B,OAAO,EAAE,GAAG,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,GAAG,EAClB,MAAM,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,GACjD,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAM9C;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,iBAM3E;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,EAClD,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,GAAG,EACb,iBAAiB,EAAE,GAAG,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CA8BpB"}
@@ -1,11 +1,84 @@
1
+ import { Signature } from '@aztec/foundation/eth-signature';
1
2
  import { EmpireBaseAbi } from '@aztec/l1-artifacts/EmpireBaseAbi';
2
3
  import { encodeFunctionData } from 'viem';
3
- export function encodeVote(payload) {
4
+ export function encodeSignal(payload) {
4
5
  return encodeFunctionData({
5
6
  abi: EmpireBaseAbi,
6
- functionName: 'vote',
7
+ functionName: 'signal',
7
8
  args: [
8
9
  payload
9
10
  ]
10
11
  });
11
12
  }
13
+ export function encodeSignalWithSignature(payload, signature) {
14
+ return encodeFunctionData({
15
+ abi: EmpireBaseAbi,
16
+ functionName: 'signalWithSig',
17
+ args: [
18
+ payload,
19
+ signature.toViemSignature()
20
+ ]
21
+ });
22
+ }
23
+ /**
24
+ * Signs a signal proposal using EIP-712 typed data for use with signalWithSig
25
+ * @param walletClient - The viem wallet client to sign with
26
+ * @param payload - The payload address to signal
27
+ * @param verifyingContract - The address of the EmpireBase contract
28
+ * @param chainId - The chain ID where the contract is deployed
29
+ * @param account - The account to sign with (optional if hoisted on wallet client)
30
+ * @returns The EIP-712 signature
31
+ */ export async function signSignalWithSig(signer, payload, slot, instance, verifyingContract, chainId) {
32
+ const domain = {
33
+ name: 'EmpireBase',
34
+ version: '1',
35
+ chainId,
36
+ verifyingContract
37
+ };
38
+ const types = {
39
+ EIP712Domain: [
40
+ {
41
+ name: 'name',
42
+ type: 'string'
43
+ },
44
+ {
45
+ name: 'version',
46
+ type: 'string'
47
+ },
48
+ {
49
+ name: 'chainId',
50
+ type: 'uint256'
51
+ },
52
+ {
53
+ name: 'verifyingContract',
54
+ type: 'address'
55
+ }
56
+ ],
57
+ Signal: [
58
+ {
59
+ name: 'payload',
60
+ type: 'address'
61
+ },
62
+ {
63
+ name: 'slot',
64
+ type: 'uint256'
65
+ },
66
+ {
67
+ name: 'instance',
68
+ type: 'address'
69
+ }
70
+ ]
71
+ };
72
+ const message = {
73
+ payload,
74
+ slot,
75
+ instance
76
+ };
77
+ const typedData = {
78
+ domain,
79
+ types,
80
+ primaryType: 'Signal',
81
+ message
82
+ };
83
+ return Signature.fromString(await signer(typedData));
84
+ }