@aztec/ethereum 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (188) hide show
  1. package/dest/client.d.ts +16 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +27 -7
  4. package/dest/config.d.ts +24 -32
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +63 -62
  7. package/dest/contracts/chain_state_override.d.ts +78 -0
  8. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  9. package/dest/contracts/chain_state_override.js +137 -0
  10. package/dest/contracts/fee_asset_handler.d.ts +6 -5
  11. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_handler.js +11 -9
  13. package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
  14. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  15. package/dest/contracts/fee_asset_price_oracle.js +656 -0
  16. package/dest/contracts/governance.d.ts +110 -33
  17. package/dest/contracts/governance.d.ts.map +1 -1
  18. package/dest/contracts/governance.js +207 -16
  19. package/dest/contracts/governance_proposer.d.ts +33 -1
  20. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  21. package/dest/contracts/governance_proposer.js +438 -10
  22. package/dest/contracts/inbox.d.ts +22 -1
  23. package/dest/contracts/inbox.d.ts.map +1 -1
  24. package/dest/contracts/inbox.js +42 -2
  25. package/dest/contracts/index.d.ts +6 -3
  26. package/dest/contracts/index.d.ts.map +1 -1
  27. package/dest/contracts/index.js +5 -2
  28. package/dest/contracts/log.d.ts +13 -0
  29. package/dest/contracts/log.d.ts.map +1 -0
  30. package/dest/contracts/log.js +1 -0
  31. package/dest/contracts/multicall.d.ts +127 -12
  32. package/dest/contracts/multicall.d.ts.map +1 -1
  33. package/dest/contracts/multicall.js +201 -93
  34. package/dest/contracts/outbox.d.ts +58 -0
  35. package/dest/contracts/outbox.d.ts.map +1 -0
  36. package/dest/contracts/outbox.js +109 -0
  37. package/dest/contracts/registry.d.ts +3 -1
  38. package/dest/contracts/registry.d.ts.map +1 -1
  39. package/dest/contracts/registry.js +30 -1
  40. package/dest/contracts/rollup.d.ts +5409 -115
  41. package/dest/contracts/rollup.d.ts.map +1 -1
  42. package/dest/contracts/rollup.js +1027 -189
  43. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
  44. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  45. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
  46. package/dest/deploy_aztec_l1_contracts.d.ts +20 -9
  47. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  48. package/dest/deploy_aztec_l1_contracts.js +113 -37
  49. package/dest/deploy_l1_contract.js +3 -3
  50. package/dest/generated/l1-contracts-defaults.d.ts +30 -0
  51. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
  52. package/dest/generated/l1-contracts-defaults.js +30 -0
  53. package/dest/l1_artifacts.d.ts +18360 -16454
  54. package/dest/l1_artifacts.d.ts.map +1 -1
  55. package/dest/l1_artifacts.js +9 -24
  56. package/dest/l1_contract_addresses.d.ts +61 -65
  57. package/dest/l1_contract_addresses.d.ts.map +1 -1
  58. package/dest/l1_contract_addresses.js +101 -82
  59. package/dest/l1_reader.d.ts +5 -5
  60. package/dest/l1_reader.d.ts.map +1 -1
  61. package/dest/l1_reader.js +9 -7
  62. package/dest/l1_tx_utils/config.d.ts +7 -1
  63. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  64. package/dest/l1_tx_utils/config.js +14 -1
  65. package/dest/l1_tx_utils/constants.d.ts +1 -1
  66. package/dest/l1_tx_utils/constants.js +2 -2
  67. package/dest/l1_tx_utils/factory.d.ts +18 -10
  68. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  69. package/dest/l1_tx_utils/factory.js +17 -7
  70. package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
  71. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
  72. package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
  73. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
  74. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
  75. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
  76. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
  77. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
  78. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
  79. package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
  80. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
  81. package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
  82. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
  83. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
  84. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
  85. package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
  86. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
  87. package/dest/l1_tx_utils/index-blobs.js +2 -2
  88. package/dest/l1_tx_utils/index.d.ts +2 -1
  89. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  90. package/dest/l1_tx_utils/index.js +1 -0
  91. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
  92. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
  93. package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
  94. package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
  95. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  96. package/dest/l1_tx_utils/l1_tx_utils.js +101 -66
  97. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
  98. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  99. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +25 -58
  100. package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
  101. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  102. package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
  103. package/dest/publisher_manager.d.ts +21 -6
  104. package/dest/publisher_manager.d.ts.map +1 -1
  105. package/dest/publisher_manager.js +81 -7
  106. package/dest/queries.d.ts +14 -3
  107. package/dest/queries.d.ts.map +1 -1
  108. package/dest/queries.js +74 -7
  109. package/dest/test/chain_monitor.d.ts +23 -3
  110. package/dest/test/chain_monitor.d.ts.map +1 -1
  111. package/dest/test/chain_monitor.js +39 -4
  112. package/dest/test/eth_cheat_codes.d.ts +24 -4
  113. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  114. package/dest/test/eth_cheat_codes.js +17 -4
  115. package/dest/test/index.d.ts +1 -3
  116. package/dest/test/index.d.ts.map +1 -1
  117. package/dest/test/index.js +0 -2
  118. package/dest/test/rollup_cheat_codes.d.ts +34 -3
  119. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  120. package/dest/test/rollup_cheat_codes.js +75 -6
  121. package/dest/test/start_anvil.d.ts +23 -3
  122. package/dest/test/start_anvil.d.ts.map +1 -1
  123. package/dest/test/start_anvil.js +143 -29
  124. package/dest/test/upgrade_utils.js +2 -2
  125. package/dest/utils.d.ts +9 -1
  126. package/dest/utils.d.ts.map +1 -1
  127. package/dest/utils.js +81 -12
  128. package/package.json +9 -10
  129. package/src/client.ts +28 -2
  130. package/src/config.ts +81 -63
  131. package/src/contracts/README.md +157 -0
  132. package/src/contracts/chain_state_override.ts +200 -0
  133. package/src/contracts/fee_asset_handler.ts +10 -7
  134. package/src/contracts/fee_asset_price_oracle.ts +285 -0
  135. package/src/contracts/governance.ts +279 -13
  136. package/src/contracts/governance_proposer.ts +58 -2
  137. package/src/contracts/inbox.ts +62 -2
  138. package/src/contracts/index.ts +5 -2
  139. package/src/contracts/log.ts +13 -0
  140. package/src/contracts/multicall.ts +243 -102
  141. package/src/contracts/outbox.ts +128 -0
  142. package/src/contracts/registry.ts +31 -1
  143. package/src/contracts/rollup.ts +728 -148
  144. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
  145. package/src/deploy_aztec_l1_contracts.ts +137 -47
  146. package/src/deploy_l1_contract.ts +3 -3
  147. package/src/generated/l1-contracts-defaults.ts +32 -0
  148. package/src/l1_artifacts.ts +12 -35
  149. package/src/l1_contract_addresses.ts +120 -94
  150. package/src/l1_reader.ts +17 -10
  151. package/src/l1_tx_utils/config.ts +20 -0
  152. package/src/l1_tx_utils/constants.ts +2 -2
  153. package/src/l1_tx_utils/factory.ts +31 -31
  154. package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
  155. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
  156. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
  157. package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
  158. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
  159. package/src/l1_tx_utils/index-blobs.ts +2 -2
  160. package/src/l1_tx_utils/index.ts +1 -0
  161. package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
  162. package/src/l1_tx_utils/l1_tx_utils.ts +99 -48
  163. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +31 -66
  164. package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
  165. package/src/publisher_manager.ts +107 -10
  166. package/src/queries.ts +81 -7
  167. package/src/test/chain_monitor.ts +66 -4
  168. package/src/test/eth_cheat_codes.ts +16 -4
  169. package/src/test/index.ts +0 -2
  170. package/src/test/rollup_cheat_codes.ts +82 -6
  171. package/src/test/start_anvil.ts +177 -29
  172. package/src/test/upgrade_utils.ts +2 -2
  173. package/src/utils.ts +88 -14
  174. package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
  175. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  176. package/dest/contracts/empire_slashing_proposer.js +0 -209
  177. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  178. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  179. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  180. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  181. package/dest/test/delayed_tx_utils.d.ts +0 -13
  182. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  183. package/dest/test/delayed_tx_utils.js +0 -28
  184. package/dest/test/tx_delayer.d.ts +0 -36
  185. package/dest/test/tx_delayer.d.ts.map +0 -1
  186. package/src/contracts/empire_slashing_proposer.ts +0 -270
  187. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  188. package/src/test/delayed_tx_utils.ts +0 -52
package/src/config.ts CHANGED
@@ -1,15 +1,16 @@
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
12
 
13
+ import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
13
14
  import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
14
15
 
15
16
  export type GenesisStateConfig = {
@@ -17,6 +18,8 @@ export type GenesisStateConfig = {
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 = {
@@ -32,6 +35,8 @@ export type L1ContractsConfig = {
32
35
  lagInEpochsForValidatorSet: number;
33
36
  /** The number of epochs to lag behind the current epoch for randao selection. */
34
37
  lagInEpochsForRandao: number;
38
+ /** The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks). */
39
+ inboxLag: number;
35
40
  /** The number of epochs after an epoch ends that proofs are still accepted. */
36
41
  aztecProofSubmissionEpochs: number;
37
42
  /** The deposit amount for a validator */
@@ -54,130 +59,117 @@ export type L1ContractsConfig = {
54
59
  slashingOffsetInRounds: number;
55
60
  /** How long slashing can be disabled for in seconds when vetoer disables it */
56
61
  slashingDisableDuration: number;
57
- /** Type of slasher proposer */
58
- slasherFlavor: 'empire' | 'tally' | 'none';
59
- /** 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 */
60
65
  slashAmountSmall: bigint;
61
- /** Medium amount to slash in tally slashing */
66
+ /** Medium amount to slash */
62
67
  slashAmountMedium: bigint;
63
- /** Largest amount that can be slashed per round in tally slashing */
68
+ /** Largest amount that can be slashed per round */
64
69
  slashAmountLarge: bigint;
65
70
  /** Governance proposing quorum (defaults to roundSize/2 + 1) */
66
71
  governanceProposerQuorum?: number;
67
72
  /** Governance proposing round size */
68
73
  governanceProposerRoundSize: number;
74
+ /** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
75
+ governanceVotingDuration?: number;
69
76
  /** The mana target for the rollup */
70
77
  manaTarget: bigint;
71
78
  /** The proving cost per mana */
72
79
  provingCostPerMana: bigint;
80
+ /** The initial ETH per fee asset price (with 1e12 precision) */
81
+ initialEthPerFeeAsset: bigint;
73
82
  /** The number of seconds to wait for an exit */
74
83
  exitDelaySeconds: number;
75
84
  } & L1TxUtilsConfig;
76
85
 
77
- export const DefaultL1ContractsConfig = {
78
- ethereumSlotDuration: 12,
79
- aztecSlotDuration: 36,
80
- aztecEpochDuration: 32,
81
- aztecTargetCommitteeSize: 48,
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
102
- } satisfies L1ContractsConfig;
103
-
86
+ /**
87
+ * Config mappings for L1ContractsConfig.
88
+ * Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
89
+ * Real deployments use forge scripts which require explicit env vars (vm.envUint).
90
+ */
104
91
  export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
105
92
  ethereumSlotDuration: {
106
93
  env: 'ETHEREUM_SLOT_DURATION',
107
94
  description: 'How many seconds an L1 slot lasts.',
108
- ...numberConfigHelper(DefaultL1ContractsConfig.ethereumSlotDuration),
95
+ ...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
109
96
  },
110
97
  aztecSlotDuration: {
111
98
  env: 'AZTEC_SLOT_DURATION',
112
99
  description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
113
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecSlotDuration),
100
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
114
101
  },
115
102
  aztecEpochDuration: {
116
103
  env: 'AZTEC_EPOCH_DURATION',
117
- description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
118
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecEpochDuration),
104
+ description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
105
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
119
106
  },
120
107
  aztecTargetCommitteeSize: {
121
108
  env: 'AZTEC_TARGET_COMMITTEE_SIZE',
122
109
  description: 'The target validator committee size.',
123
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize),
110
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
124
111
  },
125
112
  lagInEpochsForValidatorSet: {
126
113
  env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
127
114
  description: 'The number of epochs to lag behind the current epoch for validator selection.',
128
- ...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochsForValidatorSet),
115
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
129
116
  },
130
117
  lagInEpochsForRandao: {
131
118
  env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
132
119
  description: 'The number of epochs to lag behind the current epoch for randao selection.',
133
- ...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochsForRandao),
120
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
121
+ },
122
+ inboxLag: {
123
+ env: 'AZTEC_INBOX_LAG',
124
+ description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
125
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
134
126
  },
135
127
  aztecProofSubmissionEpochs: {
136
128
  env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
137
129
  description: 'The number of epochs after an epoch ends that proofs are still accepted.',
138
- ...numberConfigHelper(DefaultL1ContractsConfig.aztecProofSubmissionEpochs),
130
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
139
131
  },
140
132
  activationThreshold: {
141
133
  env: 'AZTEC_ACTIVATION_THRESHOLD',
142
134
  description: 'The deposit amount for a validator',
143
- ...bigintConfigHelper(DefaultL1ContractsConfig.activationThreshold),
135
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
144
136
  },
145
137
  ejectionThreshold: {
146
138
  env: 'AZTEC_EJECTION_THRESHOLD',
147
139
  description: 'The minimum stake for a validator.',
148
- ...bigintConfigHelper(DefaultL1ContractsConfig.ejectionThreshold),
140
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
149
141
  },
150
142
  localEjectionThreshold: {
151
143
  env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
152
144
  description:
153
145
  'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
154
- ...bigintConfigHelper(DefaultL1ContractsConfig.localEjectionThreshold),
146
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
155
147
  },
156
148
  slashingOffsetInRounds: {
157
149
  env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
158
150
  description:
159
151
  'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
160
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingOffsetInRounds),
152
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
161
153
  },
162
- slasherFlavor: {
163
- env: 'AZTEC_SLASHER_FLAVOR',
164
- description: 'Type of slasher proposer (empire, tally, or none)',
165
- ...enumConfigHelper(['empire', 'tally', 'none'] as const, DefaultL1ContractsConfig.slasherFlavor),
154
+ slasherEnabled: {
155
+ env: 'AZTEC_SLASHER_ENABLED',
156
+ description: 'Whether to deploy a slasher proposer',
157
+ ...booleanConfigHelper(true),
166
158
  },
167
159
  slashAmountSmall: {
168
160
  env: 'AZTEC_SLASH_AMOUNT_SMALL',
169
161
  description: 'Small slashing amount for light offenses',
170
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountSmall),
162
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
171
163
  },
172
164
  slashAmountMedium: {
173
165
  env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
174
166
  description: 'Medium slashing amount for moderate offenses',
175
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountMedium),
167
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
176
168
  },
177
169
  slashAmountLarge: {
178
170
  env: 'AZTEC_SLASH_AMOUNT_LARGE',
179
171
  description: 'Large slashing amount for severe offenses',
180
- ...bigintConfigHelper(DefaultL1ContractsConfig.slashAmountLarge),
172
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
181
173
  },
182
174
  slashingQuorum: {
183
175
  env: 'AZTEC_SLASHING_QUORUM',
@@ -187,28 +179,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
187
179
  slashingRoundSizeInEpochs: {
188
180
  env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
189
181
  description: 'The slashing round size',
190
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingRoundSizeInEpochs),
182
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
191
183
  },
192
184
  slashingLifetimeInRounds: {
193
185
  env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
194
186
  description: 'The slashing lifetime in rounds',
195
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingLifetimeInRounds),
187
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
196
188
  },
197
189
  slashingExecutionDelayInRounds: {
198
190
  env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
199
191
  description: 'The slashing execution delay in rounds',
200
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingExecutionDelayInRounds),
192
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
201
193
  },
202
194
  slashingVetoer: {
203
195
  env: 'AZTEC_SLASHING_VETOER',
204
196
  description: 'The slashing vetoer',
205
197
  parseEnv: (val: string) => EthAddress.fromString(val),
206
- defaultValue: DefaultL1ContractsConfig.slashingVetoer,
198
+ defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
207
199
  },
208
200
  slashingDisableDuration: {
209
201
  env: 'AZTEC_SLASHING_DISABLE_DURATION',
210
202
  description: 'How long slashing can be disabled for in seconds when vetoer disables it',
211
- ...numberConfigHelper(DefaultL1ContractsConfig.slashingDisableDuration),
203
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
212
204
  },
213
205
  governanceProposerQuorum: {
214
206
  env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
@@ -218,26 +210,42 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
218
210
  governanceProposerRoundSize: {
219
211
  env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
220
212
  description: 'The governance proposing round size',
221
- ...numberConfigHelper(DefaultL1ContractsConfig.governanceProposerRoundSize),
213
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
214
+ },
215
+ governanceVotingDuration: {
216
+ env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
217
+ description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
218
+ ...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
222
219
  },
223
220
  manaTarget: {
224
221
  env: 'AZTEC_MANA_TARGET',
225
222
  description: 'The mana target for the rollup',
226
- ...bigintConfigHelper(DefaultL1ContractsConfig.manaTarget),
223
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
227
224
  },
228
225
  provingCostPerMana: {
229
226
  env: 'AZTEC_PROVING_COST_PER_MANA',
230
227
  description: 'The proving cost per mana',
231
- ...bigintConfigHelper(DefaultL1ContractsConfig.provingCostPerMana),
228
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
229
+ },
230
+ initialEthPerFeeAsset: {
231
+ env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
232
+ description: 'The initial ETH per fee asset price (with 1e12 precision)',
233
+ ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
232
234
  },
233
235
  exitDelaySeconds: {
234
236
  env: 'AZTEC_EXIT_DELAY_SECONDS',
235
237
  description: 'The delay before a validator can exit the set',
236
- ...numberConfigHelper(DefaultL1ContractsConfig.exitDelaySeconds),
238
+ ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
237
239
  },
238
- ...l1TxUtilsConfigMappings,
240
+ ...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
239
241
  };
240
242
 
243
+ /**
244
+ * Default L1 contracts configuration derived from l1ContractsConfigMappings.
245
+ * Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
246
+ */
247
+ export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
248
+
241
249
  export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
242
250
  testAccounts: {
243
251
  env: 'TEST_ACCOUNTS',
@@ -249,6 +257,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
249
257
  description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
250
258
  ...booleanConfigHelper(false),
251
259
  },
260
+ prefundAddresses: {
261
+ env: 'PREFUND_ADDRESSES',
262
+ description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
263
+ parseEnv: (val: string) =>
264
+ val
265
+ .split(',')
266
+ .map(a => a.trim())
267
+ .filter(a => a.length > 0),
268
+ defaultValue: [],
269
+ },
252
270
  };
253
271
 
254
272
  export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
@@ -0,0 +1,157 @@
1
+ # L1 Contract Wrappers
2
+
3
+ This folder contains TypeScript wrappers for L1 contracts defined in `l1-contracts/`. These wrappers are used by the node client to interact with the rollup and related contracts on Ethereum.
4
+
5
+ ## Purpose
6
+
7
+ The goal of wrapping is to shield consumers from L1-specific and viem-specific details. Clients using these wrappers interact with domain types and branded types native to the Aztec codebase, without needing to understand viem's ABI type system or deal with raw types like `Hex` and `bigint`.
8
+
9
+ ## Type Safety
10
+
11
+ ### Explicit Return Types
12
+
13
+ Every function in the contract wrappers must declare its return type explicitly. This is critical because viem's type inference over ABI types is slow and significantly impacts IDE performance.
14
+
15
+ ```typescript
16
+ // Good: Explicit return type
17
+ async getSlotNumber(): Promise<SlotNumber> {
18
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
19
+ }
20
+
21
+ // Bad: Inferred return type (slow)
22
+ async getSlotNumber() {
23
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
24
+ }
25
+ ```
26
+
27
+ ### Branded and Domain Types
28
+
29
+ Use branded types and domain-specific types instead of viem's autogenerated types for both arguments and return values:
30
+
31
+ - `CheckpointNumber`, `EpochNumber`, `SlotNumber` instead of `bigint`
32
+ - `EthAddress` instead of `` `0x${string}` `` or `Hex`
33
+ - `Fr`, `Buffer32` instead of `Hex` for hashes and field elements
34
+ - Custom domain types (e.g., `CheckpointLog`, `AttesterView`) instead of raw tuples
35
+
36
+ Type conversions happen inside wrapper methods, not at the call site:
37
+
38
+ ```typescript
39
+ async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
40
+ const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
41
+ return {
42
+ archive: Fr.fromString(result.archive),
43
+ headerHash: Buffer32.fromString(result.headerHash),
44
+ blockCount: result.blockCount,
45
+ };
46
+ }
47
+ ```
48
+
49
+ ## Wrapper Pattern
50
+
51
+ ### Basic Structure
52
+
53
+ Each wrapper follows a consistent structure:
54
+
55
+ ```typescript
56
+ export class FooContract {
57
+ private readonly foo: GetContractReturnType<typeof FooAbi, ViemClient>;
58
+
59
+ constructor(
60
+ public readonly client: ViemClient,
61
+ address: Hex | EthAddress,
62
+ ) {
63
+ if (address instanceof EthAddress) {
64
+ address = address.toString();
65
+ }
66
+ this.foo = getContract({ address, abi: FooAbi, client });
67
+ }
68
+
69
+ public get address(): Hex {
70
+ return this.foo.address;
71
+ }
72
+
73
+ public getContract(): GetContractReturnType<typeof FooAbi, ViemClient> {
74
+ return this.foo;
75
+ }
76
+ }
77
+ ```
78
+
79
+ The raw contract is exposed via `getContract()` for cases where direct access is needed, but most consumers should use the typed wrapper methods. Relying on `getContract()` is a code smell and should be avoided.
80
+
81
+ ### Static Factory Methods
82
+
83
+ Wrappers may provide static factory methods for common initialization patterns:
84
+
85
+ - `getFromConfig(config)` - construct from configuration object
86
+ - `getFromL1ContractsValues(deployResult)` - construct from deployment result
87
+
88
+ ### Wallet Assertions
89
+
90
+ For write operations that require a wallet, use an assertion helper:
91
+
92
+ ```typescript
93
+ private assertWallet(): GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient> {
94
+ if (!isExtendedClient(this.client)) {
95
+ throw new Error('Wallet client is required for this operation');
96
+ }
97
+ return this.foo as GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient>;
98
+ }
99
+ ```
100
+
101
+ ## Event Handling
102
+
103
+ ### Event Log Types
104
+
105
+ Event logs are wrapped in `L1EventLog<T>` to include L1 block context:
106
+
107
+ ```typescript
108
+ type L1EventLog<T> = {
109
+ l1BlockNumber: bigint;
110
+ l1BlockHash: Buffer32;
111
+ l1TransactionHash: Hex;
112
+ args: T;
113
+ };
114
+ ```
115
+
116
+ ### Event Fetching
117
+
118
+ Methods that fetch events convert viem's raw logs to domain types:
119
+
120
+ ```typescript
121
+ async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
122
+ const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
123
+ return logs.map(log => ({
124
+ l1BlockNumber: log.blockNumber!,
125
+ l1BlockHash: Buffer32.fromString(log.blockHash!),
126
+ l1TransactionHash: log.transactionHash!,
127
+ args: {
128
+ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
129
+ // ... convert other fields
130
+ },
131
+ }));
132
+ }
133
+ ```
134
+
135
+ ### Event Listeners
136
+
137
+ For reactive event handling, wrapper methods convert arguments before invoking callbacks:
138
+
139
+ ```typescript
140
+ public listenToCheckpointInvalidated(
141
+ callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
142
+ ): WatchContractEventReturnType {
143
+ return this.rollup.watchEvent.CheckpointInvalidated({}, {
144
+ onLogs: logs => {
145
+ for (const log of logs) {
146
+ if (log.args.checkpointNumber !== undefined) {
147
+ callback({ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber) });
148
+ }
149
+ }
150
+ },
151
+ });
152
+ }
153
+ ```
154
+
155
+ ## Error Handling
156
+
157
+ Custom error classes in `errors.ts` extend `Error` and set `this.name` for proper error identification. Include relevant context as public readonly properties.
@@ -0,0 +1,200 @@
1
+ import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
2
+ import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
+ import type { Buffer32 } from '@aztec/foundation/buffer';
4
+ import { merge } from '@aztec/foundation/collection';
5
+ import type { Fr } from '@aztec/foundation/curves/bn254';
6
+
7
+ import type { StateOverride } from 'viem';
8
+
9
+ import { type FeeHeader, RollupContract } from './rollup.js';
10
+
11
+ /**
12
+ * Override values for the pending checkpoint that the simulation should treat as already applied.
13
+ * Every field is optional at plan-building time so callers can populate them incrementally; whatever
14
+ * is present at translation time is forwarded to the partial `tempCheckpointLogs` helper so the
15
+ * load-bearing `slotNumber` can land even if other fields could not be derived locally.
16
+ */
17
+ export type PendingCheckpointOverrideState = {
18
+ archive?: Fr;
19
+ feeHeader?: FeeHeader;
20
+ headerHash?: Fr;
21
+ outHash?: Fr;
22
+ payloadDigest?: Buffer32;
23
+ slotNumber?: SlotNumber;
24
+ };
25
+
26
+ export type ChainTipsOverride = {
27
+ pending?: CheckpointNumber;
28
+ proven?: CheckpointNumber;
29
+ };
30
+
31
+ /** Describes the simulated L1 rollup state that downstream calls should observe. */
32
+ export type SimulationOverridesPlan = {
33
+ chainTipsOverride?: ChainTipsOverride;
34
+ pendingCheckpointState?: PendingCheckpointOverrideState;
35
+ disableBlobCheck?: boolean;
36
+ };
37
+
38
+ /** Builds a single-checkpoint simulation plan before it is translated into a viem state override. */
39
+ export class SimulationOverridesBuilder {
40
+ private chainTipsOverride?: ChainTipsOverride;
41
+ private pendingCheckpointState?: PendingCheckpointOverrideState;
42
+ private disableBlobCheck = false;
43
+
44
+ /** Starts from an existing plan so callers can extend or specialize it. */
45
+ public static from(plan: SimulationOverridesPlan | undefined): SimulationOverridesBuilder {
46
+ return new SimulationOverridesBuilder().merge(plan);
47
+ }
48
+
49
+ /**
50
+ * Merges another plan into this builder. Later values win on a per-half basis for chain tips,
51
+ * but explicit `undefined` fields in the incoming plan are ignored so they cannot erase a
52
+ * previously-set value.
53
+ */
54
+ public merge(plan: SimulationOverridesPlan | undefined): this {
55
+ if (!plan) {
56
+ return this;
57
+ }
58
+
59
+ if (plan.chainTipsOverride) {
60
+ this.chainTipsOverride = merge(this.chainTipsOverride ?? {}, plan.chainTipsOverride);
61
+ }
62
+ if (plan.pendingCheckpointState) {
63
+ this.pendingCheckpointState = merge(this.pendingCheckpointState ?? {}, plan.pendingCheckpointState);
64
+ }
65
+ this.disableBlobCheck = this.disableBlobCheck || (plan.disableBlobCheck ?? false);
66
+
67
+ return this;
68
+ }
69
+
70
+ /**
71
+ * Sets the pending and/or proven checkpoint number overrides. Subsequent calls merge into the existing
72
+ * override on a per-half basis, so callers can set pending in one call and proven in another without
73
+ * clobbering each other.
74
+ */
75
+ public withChainTips(override: ChainTipsOverride): this {
76
+ this.chainTipsOverride = { ...(this.chainTipsOverride ?? {}), ...override };
77
+ return this;
78
+ }
79
+
80
+ /** Overrides the archive root for the configured pending checkpoint. */
81
+ public withPendingArchive(archive: Fr): this {
82
+ this.assertPendingCheckpointNumber();
83
+ this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), archive };
84
+ return this;
85
+ }
86
+
87
+ /** Overrides the fee header for the configured pending checkpoint. */
88
+ public withPendingFeeHeader(feeHeader: FeeHeader): this {
89
+ this.assertPendingCheckpointNumber();
90
+ this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), feeHeader };
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * Overrides one or more `tempCheckpointLogs` cell fields for the configured pending checkpoint.
96
+ * Fields are independent: any subset can be provided. The translator (`makeTempCheckpointLogOverride`)
97
+ * emits a stateDiff entry per field actually set, so unspecified fields stay at their on-chain
98
+ * values.
99
+ *
100
+ * `slotNumber` is load-bearing for `STFLib.canPruneAtTime`: when the simulation overrides `pending`
101
+ * to a checkpoint that has no on-chain `tempCheckpointLogs` entry yet, the missing slotNumber falls
102
+ * back to 0 and the contract treats the pending tip as belonging to epoch 0, triggering a phantom
103
+ * prune that silently undoes the `pending` override.
104
+ */
105
+ public withPendingTempCheckpointLogFields(fields: {
106
+ headerHash?: Fr;
107
+ outHash?: Fr;
108
+ payloadDigest?: Buffer32;
109
+ slotNumber?: SlotNumber;
110
+ }): this {
111
+ this.assertPendingCheckpointNumber();
112
+ this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), ...fields };
113
+ return this;
114
+ }
115
+
116
+ /** Disables blob checking for simulations that cannot provide DA inputs. */
117
+ public withoutBlobCheck(): this {
118
+ this.disableBlobCheck = true;
119
+ return this;
120
+ }
121
+
122
+ /** Builds the final plan, or `undefined` when no overrides were configured. */
123
+ public build(): SimulationOverridesPlan | undefined {
124
+ if (!this.pendingCheckpointState && !this.chainTipsOverride && !this.disableBlobCheck) {
125
+ return undefined;
126
+ }
127
+
128
+ return {
129
+ chainTipsOverride: this.chainTipsOverride,
130
+ pendingCheckpointState: this.pendingCheckpointState,
131
+ disableBlobCheck: this.disableBlobCheck || undefined,
132
+ };
133
+ }
134
+
135
+ private assertPendingCheckpointNumber(): void {
136
+ if (this.chainTipsOverride?.pending === undefined) {
137
+ throw new Error('withChainTips({ pending }) must be called before attaching archive or fee header overrides');
138
+ }
139
+ }
140
+ }
141
+
142
+ /** Translates a simulation plan into the viem state override shape expected by rollup calls. */
143
+ export async function buildSimulationOverridesStateOverride(
144
+ rollup: RollupContract,
145
+ plan: SimulationOverridesPlan | undefined,
146
+ ): Promise<StateOverride> {
147
+ if (!plan) {
148
+ return [];
149
+ }
150
+
151
+ const rollupStateDiff: NonNullable<StateOverride[number]['stateDiff']> = [];
152
+
153
+ if (plan.chainTipsOverride) {
154
+ rollupStateDiff.push(...extractRollupStateDiff(await rollup.makeChainTipsOverride(plan.chainTipsOverride)));
155
+ }
156
+
157
+ if (plan.pendingCheckpointState && plan.chainTipsOverride?.pending === undefined) {
158
+ throw new Error('pendingCheckpointState requires chainTipsOverride.pending to be set');
159
+ }
160
+
161
+ if (plan.pendingCheckpointState?.archive) {
162
+ rollupStateDiff.push(
163
+ ...extractRollupStateDiff(
164
+ rollup.makeArchiveOverride(plan.chainTipsOverride!.pending!, plan.pendingCheckpointState.archive),
165
+ ),
166
+ );
167
+ }
168
+
169
+ if (plan.pendingCheckpointState) {
170
+ rollupStateDiff.push(
171
+ ...extractRollupStateDiff(
172
+ await rollup.makeTempCheckpointLogOverride(plan.chainTipsOverride!.pending!, {
173
+ headerHash: plan.pendingCheckpointState.headerHash,
174
+ outHash: plan.pendingCheckpointState.outHash,
175
+ payloadDigest: plan.pendingCheckpointState.payloadDigest,
176
+ slotNumber: plan.pendingCheckpointState.slotNumber,
177
+ feeHeader: plan.pendingCheckpointState.feeHeader,
178
+ }),
179
+ ),
180
+ );
181
+ }
182
+
183
+ if (plan.disableBlobCheck) {
184
+ rollupStateDiff.push({
185
+ slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
186
+ value: toPaddedHex(0n, true),
187
+ });
188
+ }
189
+
190
+ if (rollupStateDiff.length === 0) {
191
+ return [];
192
+ }
193
+
194
+ return [{ address: rollup.address, stateDiff: rollupStateDiff }];
195
+ }
196
+
197
+ function extractRollupStateDiff(override: StateOverride | StateOverride[number] | undefined) {
198
+ const entries = Array.isArray(override) ? override : override ? [override] : [];
199
+ return entries.flatMap(entry => entry.stateDiff ?? []);
200
+ }