@aztec/ethereum 0.0.1-commit.c7c42ec → 0.0.1-commit.cf93bcc56
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.
- package/dest/config.d.ts +15 -28
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +50 -57
- package/dest/contracts/empire_base.d.ts +3 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +3 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +22 -15
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +651 -0
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +14 -4
- package/dest/contracts/governance_proposer.d.ts +3 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +395 -9
- package/dest/contracts/inbox.d.ts +18 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +32 -1
- package/dest/contracts/index.d.ts +4 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +1 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +161 -96
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +677 -132
- package/dest/contracts/tally_slashing_proposer.d.ts +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +8 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +16 -4
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +110 -33
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +5877 -1515
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +14 -1
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +15 -5
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +47 -13
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +17 -54
- package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +62 -34
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +6 -3
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +5 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +19 -2
- package/dest/test/start_anvil.js +1 -1
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +46 -0
- package/package.json +8 -7
- package/src/config.ts +58 -56
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +2 -0
- package/src/contracts/empire_slashing_proposer.ts +22 -27
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/governance.ts +13 -4
- package/src/contracts/governance_proposer.ts +10 -1
- package/src/contracts/inbox.ts +48 -1
- package/src/contracts/index.ts +3 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +348 -100
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +135 -42
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_tx_utils/config.ts +20 -0
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +52 -17
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +23 -62
- package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +5 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +21 -3
- package/src/test/start_anvil.ts +1 -1
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +53 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/src/config.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
-
// type NetworkNames,
|
|
4
3
|
bigintConfigHelper,
|
|
5
4
|
booleanConfigHelper,
|
|
6
5
|
enumConfigHelper,
|
|
7
6
|
getConfigFromMappings,
|
|
7
|
+
getDefaultConfig,
|
|
8
8
|
numberConfigHelper,
|
|
9
|
+
omitConfigMappings,
|
|
9
10
|
optionalNumberConfigHelper,
|
|
10
11
|
} from '@aztec/foundation/config';
|
|
11
12
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
13
|
|
|
14
|
+
import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
|
|
13
15
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
|
|
14
16
|
|
|
15
17
|
export type GenesisStateConfig = {
|
|
@@ -68,124 +70,108 @@ export type L1ContractsConfig = {
|
|
|
68
70
|
governanceProposerQuorum?: number;
|
|
69
71
|
/** Governance proposing round size */
|
|
70
72
|
governanceProposerRoundSize: number;
|
|
73
|
+
/** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
|
|
74
|
+
governanceVotingDuration?: number;
|
|
71
75
|
/** The mana target for the rollup */
|
|
72
76
|
manaTarget: bigint;
|
|
73
77
|
/** The proving cost per mana */
|
|
74
78
|
provingCostPerMana: bigint;
|
|
79
|
+
/** The initial ETH per fee asset price (with 1e12 precision) */
|
|
80
|
+
initialEthPerFeeAsset: bigint;
|
|
75
81
|
/** The number of seconds to wait for an exit */
|
|
76
82
|
exitDelaySeconds: number;
|
|
77
83
|
} & L1TxUtilsConfig;
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
lagInEpochsForValidatorSet: 2,
|
|
85
|
-
lagInEpochsForRandao: 2, // For PROD, this value should be > lagInEpochsForValidatorSet
|
|
86
|
-
inboxLag: 1, // Default inbox lag to prevent sequencer DOS attacks
|
|
87
|
-
aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
|
|
88
|
-
activationThreshold: 100n * 10n ** 18n,
|
|
89
|
-
ejectionThreshold: 50n * 10n ** 18n,
|
|
90
|
-
localEjectionThreshold: 98n * 10n ** 18n,
|
|
91
|
-
slashAmountSmall: 10n * 10n ** 18n,
|
|
92
|
-
slashAmountMedium: 20n * 10n ** 18n,
|
|
93
|
-
slashAmountLarge: 50n * 10n ** 18n,
|
|
94
|
-
slashingRoundSizeInEpochs: 4,
|
|
95
|
-
slashingLifetimeInRounds: 5,
|
|
96
|
-
slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
|
|
97
|
-
slashingVetoer: EthAddress.ZERO,
|
|
98
|
-
governanceProposerRoundSize: 300,
|
|
99
|
-
manaTarget: BigInt(100e6),
|
|
100
|
-
provingCostPerMana: BigInt(100),
|
|
101
|
-
exitDelaySeconds: 2 * 24 * 60 * 60,
|
|
102
|
-
slasherFlavor: 'tally' as const,
|
|
103
|
-
slashingOffsetInRounds: 2,
|
|
104
|
-
slashingDisableDuration: 5 * 24 * 60 * 60, // 5 days in seconds
|
|
105
|
-
} satisfies L1ContractsConfig;
|
|
106
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Config mappings for L1ContractsConfig.
|
|
87
|
+
* Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
|
|
88
|
+
* Real deployments use forge scripts which require explicit env vars (vm.envUint).
|
|
89
|
+
*/
|
|
107
90
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
|
108
91
|
ethereumSlotDuration: {
|
|
109
92
|
env: 'ETHEREUM_SLOT_DURATION',
|
|
110
93
|
description: 'How many seconds an L1 slot lasts.',
|
|
111
|
-
...numberConfigHelper(
|
|
94
|
+
...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
|
|
112
95
|
},
|
|
113
96
|
aztecSlotDuration: {
|
|
114
97
|
env: 'AZTEC_SLOT_DURATION',
|
|
115
98
|
description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
|
|
116
|
-
...numberConfigHelper(
|
|
99
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
|
|
117
100
|
},
|
|
118
101
|
aztecEpochDuration: {
|
|
119
102
|
env: 'AZTEC_EPOCH_DURATION',
|
|
120
|
-
description: `How many L2 slots an epoch lasts (maximum
|
|
121
|
-
...numberConfigHelper(
|
|
103
|
+
description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
|
|
104
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
|
|
122
105
|
},
|
|
123
106
|
aztecTargetCommitteeSize: {
|
|
124
107
|
env: 'AZTEC_TARGET_COMMITTEE_SIZE',
|
|
125
108
|
description: 'The target validator committee size.',
|
|
126
|
-
...numberConfigHelper(
|
|
109
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
|
|
127
110
|
},
|
|
128
111
|
lagInEpochsForValidatorSet: {
|
|
129
112
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
130
113
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
131
|
-
...numberConfigHelper(
|
|
114
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
|
|
132
115
|
},
|
|
133
116
|
lagInEpochsForRandao: {
|
|
134
117
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
|
|
135
118
|
description: 'The number of epochs to lag behind the current epoch for randao selection.',
|
|
136
|
-
...numberConfigHelper(
|
|
119
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
|
|
137
120
|
},
|
|
138
121
|
inboxLag: {
|
|
139
122
|
env: 'AZTEC_INBOX_LAG',
|
|
140
123
|
description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
|
|
141
|
-
...numberConfigHelper(
|
|
124
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
|
|
142
125
|
},
|
|
143
126
|
aztecProofSubmissionEpochs: {
|
|
144
127
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
|
145
128
|
description: 'The number of epochs after an epoch ends that proofs are still accepted.',
|
|
146
|
-
...numberConfigHelper(
|
|
129
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
|
|
147
130
|
},
|
|
148
131
|
activationThreshold: {
|
|
149
132
|
env: 'AZTEC_ACTIVATION_THRESHOLD',
|
|
150
133
|
description: 'The deposit amount for a validator',
|
|
151
|
-
...bigintConfigHelper(
|
|
134
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
|
|
152
135
|
},
|
|
153
136
|
ejectionThreshold: {
|
|
154
137
|
env: 'AZTEC_EJECTION_THRESHOLD',
|
|
155
138
|
description: 'The minimum stake for a validator.',
|
|
156
|
-
...bigintConfigHelper(
|
|
139
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
|
|
157
140
|
},
|
|
158
141
|
localEjectionThreshold: {
|
|
159
142
|
env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
|
|
160
143
|
description:
|
|
161
144
|
'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
|
|
162
|
-
...bigintConfigHelper(
|
|
145
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
|
|
163
146
|
},
|
|
164
147
|
slashingOffsetInRounds: {
|
|
165
148
|
env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
|
|
166
149
|
description:
|
|
167
150
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
168
|
-
...numberConfigHelper(
|
|
151
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
169
152
|
},
|
|
170
153
|
slasherFlavor: {
|
|
171
154
|
env: 'AZTEC_SLASHER_FLAVOR',
|
|
172
155
|
description: 'Type of slasher proposer (empire, tally, or none)',
|
|
173
|
-
...enumConfigHelper(
|
|
156
|
+
...enumConfigHelper(
|
|
157
|
+
['empire', 'tally', 'none'] as const,
|
|
158
|
+
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
159
|
+
),
|
|
174
160
|
},
|
|
175
161
|
slashAmountSmall: {
|
|
176
162
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
177
163
|
description: 'Small slashing amount for light offenses',
|
|
178
|
-
...bigintConfigHelper(
|
|
164
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
|
|
179
165
|
},
|
|
180
166
|
slashAmountMedium: {
|
|
181
167
|
env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
|
|
182
168
|
description: 'Medium slashing amount for moderate offenses',
|
|
183
|
-
...bigintConfigHelper(
|
|
169
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
|
|
184
170
|
},
|
|
185
171
|
slashAmountLarge: {
|
|
186
172
|
env: 'AZTEC_SLASH_AMOUNT_LARGE',
|
|
187
173
|
description: 'Large slashing amount for severe offenses',
|
|
188
|
-
...bigintConfigHelper(
|
|
174
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
|
|
189
175
|
},
|
|
190
176
|
slashingQuorum: {
|
|
191
177
|
env: 'AZTEC_SLASHING_QUORUM',
|
|
@@ -195,28 +181,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
195
181
|
slashingRoundSizeInEpochs: {
|
|
196
182
|
env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
|
|
197
183
|
description: 'The slashing round size',
|
|
198
|
-
...numberConfigHelper(
|
|
184
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
|
|
199
185
|
},
|
|
200
186
|
slashingLifetimeInRounds: {
|
|
201
187
|
env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
|
|
202
188
|
description: 'The slashing lifetime in rounds',
|
|
203
|
-
...numberConfigHelper(
|
|
189
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
|
|
204
190
|
},
|
|
205
191
|
slashingExecutionDelayInRounds: {
|
|
206
192
|
env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
|
|
207
193
|
description: 'The slashing execution delay in rounds',
|
|
208
|
-
...numberConfigHelper(
|
|
194
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
|
|
209
195
|
},
|
|
210
196
|
slashingVetoer: {
|
|
211
197
|
env: 'AZTEC_SLASHING_VETOER',
|
|
212
198
|
description: 'The slashing vetoer',
|
|
213
199
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
214
|
-
defaultValue:
|
|
200
|
+
defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
|
|
215
201
|
},
|
|
216
202
|
slashingDisableDuration: {
|
|
217
203
|
env: 'AZTEC_SLASHING_DISABLE_DURATION',
|
|
218
204
|
description: 'How long slashing can be disabled for in seconds when vetoer disables it',
|
|
219
|
-
...numberConfigHelper(
|
|
205
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
|
|
220
206
|
},
|
|
221
207
|
governanceProposerQuorum: {
|
|
222
208
|
env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
|
|
@@ -226,26 +212,42 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
226
212
|
governanceProposerRoundSize: {
|
|
227
213
|
env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
|
|
228
214
|
description: 'The governance proposing round size',
|
|
229
|
-
...numberConfigHelper(
|
|
215
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
|
|
216
|
+
},
|
|
217
|
+
governanceVotingDuration: {
|
|
218
|
+
env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
|
|
219
|
+
description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
|
|
220
|
+
...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
|
|
230
221
|
},
|
|
231
222
|
manaTarget: {
|
|
232
223
|
env: 'AZTEC_MANA_TARGET',
|
|
233
224
|
description: 'The mana target for the rollup',
|
|
234
|
-
...bigintConfigHelper(
|
|
225
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
|
|
235
226
|
},
|
|
236
227
|
provingCostPerMana: {
|
|
237
228
|
env: 'AZTEC_PROVING_COST_PER_MANA',
|
|
238
229
|
description: 'The proving cost per mana',
|
|
239
|
-
...bigintConfigHelper(
|
|
230
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
|
|
231
|
+
},
|
|
232
|
+
initialEthPerFeeAsset: {
|
|
233
|
+
env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
|
|
234
|
+
description: 'The initial ETH per fee asset price (with 1e12 precision)',
|
|
235
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
|
|
240
236
|
},
|
|
241
237
|
exitDelaySeconds: {
|
|
242
238
|
env: 'AZTEC_EXIT_DELAY_SECONDS',
|
|
243
239
|
description: 'The delay before a validator can exit the set',
|
|
244
|
-
...numberConfigHelper(
|
|
240
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
245
241
|
},
|
|
246
|
-
...l1TxUtilsConfigMappings,
|
|
242
|
+
...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
|
|
247
243
|
};
|
|
248
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Default L1 contracts configuration derived from l1ContractsConfigMappings.
|
|
247
|
+
* Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
|
|
248
|
+
*/
|
|
249
|
+
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
250
|
+
|
|
249
251
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
250
252
|
testAccounts: {
|
|
251
253
|
env: 'TEST_ACCOUNTS',
|
|
@@ -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.
|
|
@@ -22,6 +22,8 @@ export interface IEmpireBase {
|
|
|
22
22
|
signerAddress: Hex,
|
|
23
23
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
24
24
|
): Promise<L1TxRequest>;
|
|
25
|
+
/** Checks if a payload was ever submitted to governance via submitRoundWinner. */
|
|
26
|
+
hasPayloadBeenProposed(payload: Hex, fromBlock: bigint): Promise<boolean>;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export function encodeSignal(payload: Hex): Hex {
|
|
@@ -6,7 +6,6 @@ import { EmpireSlashingProposerAbi } from '@aztec/l1-artifacts/EmpireSlashingPro
|
|
|
6
6
|
|
|
7
7
|
import EventEmitter from 'events';
|
|
8
8
|
import {
|
|
9
|
-
type EncodeFunctionDataParameters,
|
|
10
9
|
type GetContractReturnType,
|
|
11
10
|
type Hex,
|
|
12
11
|
type Log,
|
|
@@ -100,6 +99,7 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
100
99
|
public createSignalRequest(payload: Hex): L1TxRequest {
|
|
101
100
|
return {
|
|
102
101
|
to: this.address.toString(),
|
|
102
|
+
abi: EmpireSlashingProposerAbi,
|
|
103
103
|
data: encodeSignal(payload),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
@@ -121,10 +121,17 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
121
121
|
);
|
|
122
122
|
return {
|
|
123
123
|
to: this.address.toString(),
|
|
124
|
+
abi: EmpireSlashingProposerAbi,
|
|
124
125
|
data: encodeSignalWithSignature(payload, signature),
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
/** Checks if a payload was ever submitted to governance via submitRoundWinner. */
|
|
130
|
+
public async hasPayloadBeenProposed(payload: Hex, fromBlock: bigint): Promise<boolean> {
|
|
131
|
+
const events = await this.proposer.getEvents.PayloadSubmitted({ payload }, { fromBlock, strict: true });
|
|
132
|
+
return events.length > 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
public listenToSubmittablePayloads(callback: (args: { payload: `0x${string}`; round: bigint }) => unknown) {
|
|
129
136
|
return this.proposer.watchEvent.PayloadSubmittable(
|
|
130
137
|
{},
|
|
@@ -180,6 +187,7 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
180
187
|
public buildExecuteRoundRequest(round: bigint): L1TxRequest {
|
|
181
188
|
return {
|
|
182
189
|
to: this.address.toString(),
|
|
190
|
+
abi: EmpireSlashingProposerAbi,
|
|
183
191
|
data: encodeFunctionData({
|
|
184
192
|
abi: EmpireSlashingProposerAbi,
|
|
185
193
|
functionName: 'submitRoundWinner',
|
|
@@ -222,24 +230,13 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
222
230
|
if (typeof round === 'number') {
|
|
223
231
|
round = BigInt(round);
|
|
224
232
|
}
|
|
225
|
-
const
|
|
226
|
-
abi: EmpireSlashingProposerAbi,
|
|
227
|
-
functionName: 'submitRoundWinner',
|
|
228
|
-
args: [round],
|
|
229
|
-
};
|
|
230
|
-
const data = encodeFunctionData(args);
|
|
233
|
+
const request = this.buildExecuteRoundRequest(round);
|
|
231
234
|
const response = await txUtils
|
|
232
|
-
.sendAndMonitorTransaction(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
// Gas estimation is way off for this, likely because we are creating the contract/selector to call
|
|
239
|
-
// for the actual slashing dynamically.
|
|
240
|
-
gasLimitBufferPercentage: 50, // +50% gas
|
|
241
|
-
},
|
|
242
|
-
)
|
|
235
|
+
.sendAndMonitorTransaction(request, {
|
|
236
|
+
// Gas estimation is way off for this, likely because we are creating the contract/selector to call
|
|
237
|
+
// for the actual slashing dynamically.
|
|
238
|
+
gasLimitBufferPercentage: 50, // +50% gas
|
|
239
|
+
})
|
|
243
240
|
.catch(err => {
|
|
244
241
|
if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
|
|
245
242
|
throw new ProposalAlreadyExecutedError(round);
|
|
@@ -248,15 +245,13 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
248
245
|
});
|
|
249
246
|
|
|
250
247
|
if (response.receipt.status === 'reverted') {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
[],
|
|
259
|
-
);
|
|
248
|
+
const args = {
|
|
249
|
+
abi: EmpireSlashingProposerAbi,
|
|
250
|
+
functionName: 'submitRoundWinner' as const,
|
|
251
|
+
args: [round] as const,
|
|
252
|
+
address: this.address.toString(),
|
|
253
|
+
};
|
|
254
|
+
const error = await txUtils.tryGetErrorFromRevertedTx(request.data!, args, undefined, []);
|
|
260
255
|
if (error?.includes('ProposalAlreadyExecuted')) {
|
|
261
256
|
throw new ProposalAlreadyExecutedError(round);
|
|
262
257
|
}
|
|
@@ -4,13 +4,14 @@ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
|
|
|
4
4
|
import { type Hex, encodeFunctionData, getContract } from 'viem';
|
|
5
5
|
|
|
6
6
|
import type { L1TxUtils } from '../l1_tx_utils/index.js';
|
|
7
|
+
import type { ViemClient } from '../types.js';
|
|
7
8
|
|
|
8
9
|
export class FeeAssetHandlerContract {
|
|
9
10
|
public address: EthAddress;
|
|
10
11
|
|
|
11
12
|
constructor(
|
|
13
|
+
public readonly client: ViemClient,
|
|
12
14
|
address: Hex | EthAddress,
|
|
13
|
-
public readonly txUtils: L1TxUtils,
|
|
14
15
|
) {
|
|
15
16
|
if (address instanceof EthAddress) {
|
|
16
17
|
address = address.toString();
|
|
@@ -22,7 +23,7 @@ export class FeeAssetHandlerContract {
|
|
|
22
23
|
const contract = getContract({
|
|
23
24
|
abi: FeeAssetHandlerAbi,
|
|
24
25
|
address: this.address.toString(),
|
|
25
|
-
client: this.
|
|
26
|
+
client: this.client,
|
|
26
27
|
});
|
|
27
28
|
return EthAddress.fromString(await contract.read.owner());
|
|
28
29
|
}
|
|
@@ -31,17 +32,18 @@ export class FeeAssetHandlerContract {
|
|
|
31
32
|
const contract = getContract({
|
|
32
33
|
abi: FeeAssetHandlerAbi,
|
|
33
34
|
address: this.address.toString(),
|
|
34
|
-
client: this.
|
|
35
|
+
client: this.client,
|
|
35
36
|
});
|
|
36
37
|
return contract.read.mintAmount();
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
public mint(recipient: Hex | EthAddress) {
|
|
40
|
+
public mint(txUtils: L1TxUtils, recipient: Hex | EthAddress) {
|
|
40
41
|
if (recipient instanceof EthAddress) {
|
|
41
42
|
recipient = recipient.toString();
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return txUtils.sendAndMonitorTransaction({
|
|
44
45
|
to: this.address.toString(),
|
|
46
|
+
abi: FeeAssetHandlerAbi,
|
|
45
47
|
data: encodeFunctionData({
|
|
46
48
|
abi: FeeAssetHandlerAbi,
|
|
47
49
|
functionName: 'mint',
|
|
@@ -50,9 +52,10 @@ export class FeeAssetHandlerContract {
|
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
public setMintAmount(amount: bigint) {
|
|
54
|
-
return
|
|
55
|
+
public setMintAmount(txUtils: L1TxUtils, amount: bigint) {
|
|
56
|
+
return txUtils.sendAndMonitorTransaction({
|
|
55
57
|
to: this.address.toString(),
|
|
58
|
+
abi: FeeAssetHandlerAbi,
|
|
56
59
|
data: encodeFunctionData({
|
|
57
60
|
abi: FeeAssetHandlerAbi,
|
|
58
61
|
functionName: 'setMintAmount',
|