@aztec/ethereum 3.0.0-devnet.2 → 3.0.0-devnet.20251212
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/account.d.ts +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +1 -1
- package/dest/config.d.ts +7 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +55 -17
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +6 -5
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +5 -4
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +8 -2
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +16 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.d.ts +5 -4
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +8 -2
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +1 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/index.d.ts +1 -1
- package/dest/contracts/multicall.d.ts +2 -2
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +55 -64
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +76 -67
- package/dest/contracts/slasher_contract.d.ts +1 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts +9 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +4 -4
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +456 -9
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +68 -37
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +6400 -872
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +3 -3
- package/dest/l1_reader.d.ts +3 -1
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +6 -0
- package/dest/l1_tx_utils/config.d.ts +5 -5
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +32 -9
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/factory.d.ts +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +1 -1
- package/dest/l1_tx_utils/interfaces.d.ts +2 -2
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -2
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +17 -4
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +1 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +29 -16
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +171 -34
- package/dest/l1_tx_utils/signer.d.ts +1 -1
- package/dest/l1_tx_utils/types.d.ts +1 -1
- package/dest/l1_tx_utils/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/utils.d.ts +1 -1
- package/dest/l1_types.d.ts +1 -1
- package/dest/publisher_manager.d.ts +1 -1
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +5 -3
- package/dest/test/chain_monitor.d.ts +27 -24
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +32 -34
- package/dest/test/delayed_tx_utils.d.ts +1 -1
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.d.ts +8 -12
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +9 -3
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +14 -13
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +43 -38
- package/dest/test/start_anvil.d.ts +2 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +3 -2
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +2 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +27 -13
- package/src/config.ts +62 -18
- package/src/contracts/empire_base.ts +6 -5
- package/src/contracts/empire_slashing_proposer.ts +11 -5
- package/src/contracts/governance_proposer.ts +11 -5
- package/src/contracts/rollup.ts +81 -80
- package/src/contracts/tally_slashing_proposer.ts +11 -8
- package/src/deploy_l1_contracts.ts +63 -32
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_reader.ts +8 -0
- package/src/l1_tx_utils/config.ts +34 -13
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/interfaces.ts +1 -1
- package/src/l1_tx_utils/l1_tx_utils.ts +24 -4
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +223 -38
- package/src/queries.ts +6 -3
- package/src/test/chain_monitor.ts +50 -48
- package/src/test/eth_cheat_codes.ts +8 -2
- package/src/test/rollup_cheat_codes.ts +44 -42
- package/src/test/start_anvil.ts +2 -0
- package/src/test/tx_delayer.ts +4 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +1 -1
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/src/index.ts +0 -17
package/src/config.ts
CHANGED
|
@@ -29,7 +29,9 @@ export type L1ContractsConfig = {
|
|
|
29
29
|
/** The target validator committee size. */
|
|
30
30
|
aztecTargetCommitteeSize: number;
|
|
31
31
|
/** The number of epochs to lag behind the current epoch for validator selection. */
|
|
32
|
-
|
|
32
|
+
lagInEpochsForValidatorSet: number;
|
|
33
|
+
/** The number of epochs to lag behind the current epoch for randao selection. */
|
|
34
|
+
lagInEpochsForRandao: number;
|
|
33
35
|
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
34
36
|
aztecProofSubmissionEpochs: number;
|
|
35
37
|
/** The deposit amount for a validator */
|
|
@@ -77,7 +79,8 @@ export const DefaultL1ContractsConfig = {
|
|
|
77
79
|
aztecSlotDuration: 36,
|
|
78
80
|
aztecEpochDuration: 32,
|
|
79
81
|
aztecTargetCommitteeSize: 48,
|
|
80
|
-
|
|
82
|
+
lagInEpochsForValidatorSet: 2,
|
|
83
|
+
lagInEpochsForRandao: 2, // For PROD, this value should be > lagInEpochsForValidatorSet
|
|
81
84
|
aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
|
|
82
85
|
activationThreshold: 100n * 10n ** 18n,
|
|
83
86
|
ejectionThreshold: 50n * 10n ** 18n,
|
|
@@ -90,7 +93,7 @@ export const DefaultL1ContractsConfig = {
|
|
|
90
93
|
slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
|
|
91
94
|
slashingVetoer: EthAddress.ZERO,
|
|
92
95
|
governanceProposerRoundSize: 300,
|
|
93
|
-
manaTarget: BigInt(
|
|
96
|
+
manaTarget: BigInt(100e6),
|
|
94
97
|
provingCostPerMana: BigInt(100),
|
|
95
98
|
exitDelaySeconds: 2 * 24 * 60 * 60,
|
|
96
99
|
slasherFlavor: 'tally' as const,
|
|
@@ -138,7 +141,7 @@ const TestnetGovernanceConfiguration = {
|
|
|
138
141
|
gracePeriod: 1n * 24n * 60n * 60n, // 1 day
|
|
139
142
|
quorum: 2n * 10n ** 17n, // 20%
|
|
140
143
|
requiredYeaMargin: 1n * 10n ** 17n, // 10%
|
|
141
|
-
minimumVotes:
|
|
144
|
+
minimumVotes: 100n * 200_000n * 10n ** 18n,
|
|
142
145
|
};
|
|
143
146
|
|
|
144
147
|
const StagingIgnitionGovernanceConfiguration = {
|
|
@@ -156,6 +159,21 @@ const StagingIgnitionGovernanceConfiguration = {
|
|
|
156
159
|
minimumVotes: 1250n * 200_000n * 10n ** 18n,
|
|
157
160
|
};
|
|
158
161
|
|
|
162
|
+
const MainnetGovernanceConfiguration = {
|
|
163
|
+
proposeConfig: {
|
|
164
|
+
lockDelay: 90n * 24n * 60n * 60n,
|
|
165
|
+
lockAmount: 258_750_000n * 10n ** 18n,
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
votingDelay: 3n * 24n * 60n * 60n,
|
|
169
|
+
votingDuration: 7n * 24n * 60n * 60n,
|
|
170
|
+
executionDelay: 7n * 24n * 60n * 60n,
|
|
171
|
+
gracePeriod: 7n * 24n * 60n * 60n,
|
|
172
|
+
quorum: 2n * 10n ** 17n, // 20%
|
|
173
|
+
requiredYeaMargin: 33n * 10n ** 16n, // 33%
|
|
174
|
+
minimumVotes: 1000n * 200_000n * 10n ** 18n,
|
|
175
|
+
};
|
|
176
|
+
|
|
159
177
|
export const getGovernanceConfiguration = (networkName: NetworkNames) => {
|
|
160
178
|
switch (networkName) {
|
|
161
179
|
case 'local':
|
|
@@ -170,6 +188,8 @@ export const getGovernanceConfiguration = (networkName: NetworkNames) => {
|
|
|
170
188
|
return TestnetGovernanceConfiguration;
|
|
171
189
|
case 'staging-ignition':
|
|
172
190
|
return StagingIgnitionGovernanceConfiguration;
|
|
191
|
+
case 'mainnet':
|
|
192
|
+
return MainnetGovernanceConfiguration;
|
|
173
193
|
default:
|
|
174
194
|
throw new Error(`Unrecognized network name: ${networkName}`);
|
|
175
195
|
}
|
|
@@ -183,7 +203,14 @@ const DefaultRewardConfig = {
|
|
|
183
203
|
sequencerBps: 8000,
|
|
184
204
|
rewardDistributor: EthAddress.ZERO.toString(),
|
|
185
205
|
booster: EthAddress.ZERO.toString(),
|
|
186
|
-
|
|
206
|
+
checkpointReward: 500n * 10n ** 18n,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const MainnetRewardConfig = {
|
|
210
|
+
sequencerBps: 7_000,
|
|
211
|
+
rewardDistributor: EthAddress.ZERO.toString(),
|
|
212
|
+
booster: EthAddress.ZERO.toString(),
|
|
213
|
+
checkpointReward: 400n * 10n ** 18n,
|
|
187
214
|
};
|
|
188
215
|
|
|
189
216
|
export const getRewardConfig = (networkName: NetworkNames) => {
|
|
@@ -195,6 +222,8 @@ export const getRewardConfig = (networkName: NetworkNames) => {
|
|
|
195
222
|
case 'testnet':
|
|
196
223
|
case 'staging-ignition':
|
|
197
224
|
return DefaultRewardConfig;
|
|
225
|
+
case 'mainnet':
|
|
226
|
+
return MainnetRewardConfig;
|
|
198
227
|
default:
|
|
199
228
|
throw new Error(`Unrecognized network name: ${networkName}`);
|
|
200
229
|
}
|
|
@@ -204,11 +233,11 @@ export const getRewardBoostConfig = () => {
|
|
|
204
233
|
// The reward configuration is specified with a precision of 1e5, and we use the same across
|
|
205
234
|
// all networks.
|
|
206
235
|
return {
|
|
207
|
-
increment:
|
|
208
|
-
maxScore:
|
|
209
|
-
a:
|
|
210
|
-
k:
|
|
211
|
-
minimum:
|
|
236
|
+
increment: 125_000, // 1.25
|
|
237
|
+
maxScore: 15_000_000, // 150
|
|
238
|
+
a: 1_000, // 0.01
|
|
239
|
+
k: 1_000_000, // 10
|
|
240
|
+
minimum: 100_000, // 1
|
|
212
241
|
};
|
|
213
242
|
};
|
|
214
243
|
|
|
@@ -230,11 +259,11 @@ const StagingPublicEntryQueueConfig = {
|
|
|
230
259
|
};
|
|
231
260
|
|
|
232
261
|
const TestnetEntryQueueConfig = {
|
|
233
|
-
bootstrapValidatorSetSize:
|
|
234
|
-
bootstrapFlushSize:
|
|
235
|
-
normalFlushSizeMin:
|
|
236
|
-
normalFlushSizeQuotient:
|
|
237
|
-
maxQueueFlushSize:
|
|
262
|
+
bootstrapValidatorSetSize: 256n,
|
|
263
|
+
bootstrapFlushSize: 256n,
|
|
264
|
+
normalFlushSizeMin: 4n,
|
|
265
|
+
normalFlushSizeQuotient: 2048n,
|
|
266
|
+
maxQueueFlushSize: 8n,
|
|
238
267
|
};
|
|
239
268
|
|
|
240
269
|
const StagingIgnitionEntryQueueConfig = {
|
|
@@ -245,6 +274,14 @@ const StagingIgnitionEntryQueueConfig = {
|
|
|
245
274
|
maxQueueFlushSize: 24n,
|
|
246
275
|
};
|
|
247
276
|
|
|
277
|
+
const MainnetEntryQueueConfig = {
|
|
278
|
+
bootstrapValidatorSetSize: 1_000n,
|
|
279
|
+
bootstrapFlushSize: 1_000n,
|
|
280
|
+
normalFlushSizeMin: 1n,
|
|
281
|
+
normalFlushSizeQuotient: 2_048n,
|
|
282
|
+
maxQueueFlushSize: 8n,
|
|
283
|
+
};
|
|
284
|
+
|
|
248
285
|
export const getEntryQueueConfig = (networkName: NetworkNames) => {
|
|
249
286
|
switch (networkName) {
|
|
250
287
|
case 'local':
|
|
@@ -259,6 +296,8 @@ export const getEntryQueueConfig = (networkName: NetworkNames) => {
|
|
|
259
296
|
return TestnetEntryQueueConfig;
|
|
260
297
|
case 'staging-ignition':
|
|
261
298
|
return StagingIgnitionEntryQueueConfig;
|
|
299
|
+
case 'mainnet':
|
|
300
|
+
return MainnetEntryQueueConfig;
|
|
262
301
|
default:
|
|
263
302
|
throw new Error(`Unrecognized network name: ${networkName}`);
|
|
264
303
|
}
|
|
@@ -285,10 +324,15 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
285
324
|
description: 'The target validator committee size.',
|
|
286
325
|
...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize),
|
|
287
326
|
},
|
|
288
|
-
|
|
289
|
-
env: '
|
|
327
|
+
lagInEpochsForValidatorSet: {
|
|
328
|
+
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
290
329
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
291
|
-
...numberConfigHelper(DefaultL1ContractsConfig.
|
|
330
|
+
...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochsForValidatorSet),
|
|
331
|
+
},
|
|
332
|
+
lagInEpochsForRandao: {
|
|
333
|
+
env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
|
|
334
|
+
description: 'The number of epochs to lag behind the current epoch for randao selection.',
|
|
335
|
+
...numberConfigHelper(DefaultL1ContractsConfig.lagInEpochsForRandao),
|
|
292
336
|
},
|
|
293
337
|
aztecProofSubmissionEpochs: {
|
|
294
338
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
3
4
|
import { EmpireBaseAbi } from '@aztec/l1-artifacts/EmpireBaseAbi';
|
|
@@ -11,12 +12,12 @@ export interface IEmpireBase {
|
|
|
11
12
|
getRoundInfo(
|
|
12
13
|
rollupAddress: Hex,
|
|
13
14
|
round: bigint,
|
|
14
|
-
): Promise<{ lastSignalSlot:
|
|
15
|
-
computeRound(slot:
|
|
15
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; executed: boolean }>;
|
|
16
|
+
computeRound(slot: SlotNumber): Promise<bigint>;
|
|
16
17
|
createSignalRequest(payload: Hex): L1TxRequest;
|
|
17
18
|
createSignalRequestWithSignature(
|
|
18
19
|
payload: Hex,
|
|
19
|
-
|
|
20
|
+
slot: SlotNumber,
|
|
20
21
|
chainId: number,
|
|
21
22
|
signerAddress: Hex,
|
|
22
23
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
@@ -51,7 +52,7 @@ export function encodeSignalWithSignature(payload: Hex, signature: Signature) {
|
|
|
51
52
|
export async function signSignalWithSig(
|
|
52
53
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
53
54
|
payload: Hex,
|
|
54
|
-
slot:
|
|
55
|
+
slot: SlotNumber,
|
|
55
56
|
instance: Hex,
|
|
56
57
|
verifyingContract: Hex,
|
|
57
58
|
chainId: number,
|
|
@@ -79,7 +80,7 @@ export async function signSignalWithSig(
|
|
|
79
80
|
|
|
80
81
|
const message = {
|
|
81
82
|
payload,
|
|
82
|
-
slot,
|
|
83
|
+
slot: BigInt(slot),
|
|
83
84
|
instance,
|
|
84
85
|
};
|
|
85
86
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
@@ -67,8 +68,8 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
67
68
|
return this.proposer.read.getCurrentRound();
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
public computeRound(slot:
|
|
71
|
-
return this.proposer.read.computeRound([slot]);
|
|
71
|
+
public computeRound(slot: SlotNumber): Promise<bigint> {
|
|
72
|
+
return this.proposer.read.computeRound([BigInt(slot)]);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
public getInstance() {
|
|
@@ -78,8 +79,13 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
78
79
|
public async getRoundInfo(
|
|
79
80
|
rollupAddress: Hex,
|
|
80
81
|
round: bigint,
|
|
81
|
-
): Promise<{ lastSignalSlot:
|
|
82
|
-
|
|
82
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; executed: boolean }> {
|
|
83
|
+
const result = await this.proposer.read.getRoundData([rollupAddress, round]);
|
|
84
|
+
return {
|
|
85
|
+
lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
|
|
86
|
+
payloadWithMostSignals: result.payloadWithMostSignals,
|
|
87
|
+
executed: result.executed,
|
|
88
|
+
};
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
|
|
@@ -95,7 +101,7 @@ export class EmpireSlashingProposerContract extends EventEmitter implements IEmp
|
|
|
95
101
|
|
|
96
102
|
public async createSignalRequestWithSignature(
|
|
97
103
|
payload: Hex,
|
|
98
|
-
slot:
|
|
104
|
+
slot: SlotNumber,
|
|
99
105
|
chainId: number,
|
|
100
106
|
signerAddress: Hex,
|
|
101
107
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { memoize } from '@aztec/foundation/decorators';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { GovernanceProposerAbi } from '@aztec/l1-artifacts/GovernanceProposerAbi';
|
|
@@ -54,15 +55,20 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
54
55
|
return this.proposer.read.getInstance();
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
public computeRound(slot:
|
|
58
|
-
return this.proposer.read.computeRound([slot]);
|
|
58
|
+
public computeRound(slot: SlotNumber): Promise<bigint> {
|
|
59
|
+
return this.proposer.read.computeRound([BigInt(slot)]);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
public async getRoundInfo(
|
|
62
63
|
rollupAddress: Hex,
|
|
63
64
|
round: bigint,
|
|
64
|
-
): Promise<{ lastSignalSlot:
|
|
65
|
-
|
|
65
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; executed: boolean }> {
|
|
66
|
+
const result = await this.proposer.read.getRoundData([rollupAddress, round]);
|
|
67
|
+
return {
|
|
68
|
+
lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
|
|
69
|
+
payloadWithMostSignals: result.payloadWithMostSignals,
|
|
70
|
+
executed: result.executed,
|
|
71
|
+
};
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
|
|
@@ -78,7 +84,7 @@ export class GovernanceProposerContract implements IEmpireBase {
|
|
|
78
84
|
|
|
79
85
|
public async createSignalRequestWithSignature(
|
|
80
86
|
payload: Hex,
|
|
81
|
-
slot:
|
|
87
|
+
slot: SlotNumber,
|
|
82
88
|
chainId: number,
|
|
83
89
|
signerAddress: Hex,
|
|
84
90
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
package/src/contracts/rollup.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { memoize } from '@aztec/foundation/decorators';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import type { ViemSignature } from '@aztec/foundation/eth-signature';
|
|
@@ -61,6 +62,7 @@ export type EpochProofPublicInputArgs = {
|
|
|
61
62
|
|
|
62
63
|
export type ViemHeader = {
|
|
63
64
|
lastArchiveRoot: `0x${string}`;
|
|
65
|
+
blockHeadersHash: `0x${string}`;
|
|
64
66
|
contentCommitment: ViemContentCommitment;
|
|
65
67
|
slotNumber: bigint;
|
|
66
68
|
timestamp: bigint;
|
|
@@ -81,22 +83,6 @@ export type ViemGasFees = {
|
|
|
81
83
|
feePerL2Gas: bigint;
|
|
82
84
|
};
|
|
83
85
|
|
|
84
|
-
export type ViemStateReference = {
|
|
85
|
-
l1ToL2MessageTree: ViemAppendOnlyTreeSnapshot;
|
|
86
|
-
partialStateReference: ViemPartialStateReference;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type ViemPartialStateReference = {
|
|
90
|
-
noteHashTree: ViemAppendOnlyTreeSnapshot;
|
|
91
|
-
nullifierTree: ViemAppendOnlyTreeSnapshot;
|
|
92
|
-
publicDataTree: ViemAppendOnlyTreeSnapshot;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type ViemAppendOnlyTreeSnapshot = {
|
|
96
|
-
root: `0x${string}`;
|
|
97
|
-
nextAvailableLeafIndex: number;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
86
|
export enum SlashingProposerType {
|
|
101
87
|
None = 0,
|
|
102
88
|
Tally = 1,
|
|
@@ -207,8 +193,8 @@ export class RollupContract {
|
|
|
207
193
|
}
|
|
208
194
|
|
|
209
195
|
@memoize
|
|
210
|
-
getSlotDuration() {
|
|
211
|
-
return this.rollup.read.getSlotDuration();
|
|
196
|
+
async getSlotDuration(): Promise<number> {
|
|
197
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
212
198
|
}
|
|
213
199
|
|
|
214
200
|
@memoize
|
|
@@ -227,8 +213,13 @@ export class RollupContract {
|
|
|
227
213
|
}
|
|
228
214
|
|
|
229
215
|
@memoize
|
|
230
|
-
|
|
231
|
-
return this.rollup.read.
|
|
216
|
+
getLagInEpochsForValidatorSet() {
|
|
217
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@memoize
|
|
221
|
+
getLagInEpochsForRandao() {
|
|
222
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
232
223
|
}
|
|
233
224
|
|
|
234
225
|
@memoize
|
|
@@ -294,7 +285,7 @@ export class RollupContract {
|
|
|
294
285
|
return {
|
|
295
286
|
l1StartBlock,
|
|
296
287
|
l1GenesisTime,
|
|
297
|
-
slotDuration
|
|
288
|
+
slotDuration,
|
|
298
289
|
epochDuration: Number(epochDuration),
|
|
299
290
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
300
291
|
};
|
|
@@ -331,20 +322,20 @@ export class RollupContract {
|
|
|
331
322
|
return await slasher.getProposer();
|
|
332
323
|
}
|
|
333
324
|
|
|
334
|
-
|
|
335
|
-
return this.rollup.read.
|
|
325
|
+
getCheckpointReward() {
|
|
326
|
+
return this.rollup.read.getCheckpointReward();
|
|
336
327
|
}
|
|
337
328
|
|
|
338
|
-
|
|
339
|
-
return this.rollup.read.
|
|
329
|
+
async getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
330
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
|
|
340
331
|
}
|
|
341
332
|
|
|
342
|
-
|
|
343
|
-
return this.rollup.read.
|
|
333
|
+
async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
334
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
|
|
344
335
|
}
|
|
345
336
|
|
|
346
|
-
getSlotNumber() {
|
|
347
|
-
return this.rollup.read.getCurrentSlot();
|
|
337
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
338
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
348
339
|
}
|
|
349
340
|
|
|
350
341
|
getL1FeesAt(timestamp: bigint) {
|
|
@@ -381,8 +372,8 @@ export class RollupContract {
|
|
|
381
372
|
return this.rollup.read.getCurrentSampleSeed();
|
|
382
373
|
}
|
|
383
374
|
|
|
384
|
-
getCurrentEpoch() {
|
|
385
|
-
return this.rollup.read.getCurrentEpoch();
|
|
375
|
+
async getCurrentEpoch(): Promise<EpochNumber> {
|
|
376
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
386
377
|
}
|
|
387
378
|
|
|
388
379
|
async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
|
|
@@ -425,16 +416,20 @@ export class RollupContract {
|
|
|
425
416
|
return result;
|
|
426
417
|
}
|
|
427
418
|
|
|
428
|
-
|
|
429
|
-
return this.rollup.read.
|
|
419
|
+
getCheckpoint(checkpointNumber: CheckpointNumber) {
|
|
420
|
+
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
430
421
|
}
|
|
431
422
|
|
|
432
|
-
getTips() {
|
|
433
|
-
|
|
423
|
+
async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
|
|
424
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
425
|
+
return {
|
|
426
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
427
|
+
proven: CheckpointNumber.fromBigInt(proven),
|
|
428
|
+
};
|
|
434
429
|
}
|
|
435
430
|
|
|
436
|
-
getTimestampForSlot(slot:
|
|
437
|
-
return this.rollup.read.getTimestampForSlot([slot]);
|
|
431
|
+
getTimestampForSlot(slot: SlotNumber) {
|
|
432
|
+
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
438
433
|
}
|
|
439
434
|
|
|
440
435
|
getEntryQueueLength() {
|
|
@@ -445,16 +440,16 @@ export class RollupContract {
|
|
|
445
440
|
return this.rollup.read.getAvailableValidatorFlushes();
|
|
446
441
|
}
|
|
447
442
|
|
|
448
|
-
getNextFlushableEpoch() {
|
|
449
|
-
return this.rollup.read.getNextFlushableEpoch();
|
|
443
|
+
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
444
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
450
445
|
}
|
|
451
446
|
|
|
452
|
-
getCurrentEpochNumber(): Promise<
|
|
453
|
-
return this.rollup.read.getCurrentEpoch();
|
|
447
|
+
async getCurrentEpochNumber(): Promise<EpochNumber> {
|
|
448
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
454
449
|
}
|
|
455
450
|
|
|
456
|
-
|
|
457
|
-
return this.rollup.read.
|
|
451
|
+
async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
|
|
452
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
|
|
458
453
|
}
|
|
459
454
|
|
|
460
455
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -494,8 +489,8 @@ export class RollupContract {
|
|
|
494
489
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
495
490
|
}
|
|
496
491
|
|
|
497
|
-
public async getEpochNumberForSlotNumber(slotNumber:
|
|
498
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
492
|
+
public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
|
|
493
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
499
494
|
}
|
|
500
495
|
|
|
501
496
|
getEpochProofPublicInputs(
|
|
@@ -538,53 +533,57 @@ export class RollupContract {
|
|
|
538
533
|
* @dev Throws if unable to propose
|
|
539
534
|
*
|
|
540
535
|
* @param archive - The archive that we expect to be current state
|
|
541
|
-
* @return [slot,
|
|
536
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
537
|
+
* timestamp of the next L1 block
|
|
542
538
|
* @throws otherwise
|
|
543
539
|
*/
|
|
544
540
|
public async canProposeAtNextEthBlock(
|
|
545
541
|
archive: Buffer,
|
|
546
542
|
account: `0x${string}` | Account,
|
|
547
|
-
slotDuration:
|
|
548
|
-
opts: {
|
|
549
|
-
): Promise<{ slot:
|
|
550
|
-
if (typeof slotDuration === 'number') {
|
|
551
|
-
slotDuration = BigInt(slotDuration);
|
|
552
|
-
}
|
|
543
|
+
slotDuration: number,
|
|
544
|
+
opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
|
|
545
|
+
): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
|
|
553
546
|
const latestBlock = await this.client.getBlock();
|
|
554
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
547
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
555
548
|
const who = typeof account === 'string' ? account : account.address;
|
|
556
549
|
|
|
557
550
|
try {
|
|
558
551
|
const {
|
|
559
|
-
result: [slot,
|
|
552
|
+
result: [slot, checkpointNumber],
|
|
560
553
|
} = await this.client.simulateContract({
|
|
561
554
|
address: this.address,
|
|
562
555
|
abi: RollupAbi,
|
|
563
556
|
functionName: 'canProposeAtTime',
|
|
564
557
|
args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
|
|
565
558
|
account,
|
|
566
|
-
stateOverride: await this.
|
|
559
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
567
560
|
});
|
|
568
561
|
|
|
569
|
-
return {
|
|
562
|
+
return {
|
|
563
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
564
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
565
|
+
timeOfNextL1Slot,
|
|
566
|
+
};
|
|
570
567
|
} catch (err: unknown) {
|
|
571
568
|
throw formatViemError(err);
|
|
572
569
|
}
|
|
573
570
|
}
|
|
574
571
|
|
|
575
572
|
/**
|
|
576
|
-
* Returns a state override that sets the pending
|
|
577
|
-
* Requires querying the current state of the contract to get the current proven
|
|
573
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
574
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
578
575
|
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
579
576
|
*/
|
|
580
|
-
public async
|
|
581
|
-
|
|
577
|
+
public async makePendingCheckpointNumberOverride(
|
|
578
|
+
forcePendingCheckpointNumber: CheckpointNumber | undefined,
|
|
579
|
+
): Promise<StateOverride> {
|
|
580
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
582
581
|
return [];
|
|
583
582
|
}
|
|
584
583
|
const slot = RollupContract.stfStorageSlot;
|
|
585
584
|
const currentValue = await this.client.getStorageAt({ address: this.address, slot });
|
|
586
|
-
const
|
|
587
|
-
const newValue = (BigInt(
|
|
585
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
|
|
586
|
+
const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
|
|
588
587
|
return [
|
|
589
588
|
{
|
|
590
589
|
address: this.address,
|
|
@@ -595,7 +594,7 @@ export class RollupContract {
|
|
|
595
594
|
|
|
596
595
|
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
597
596
|
public buildInvalidateBadAttestationRequest(
|
|
598
|
-
|
|
597
|
+
checkpointNumber: CheckpointNumber,
|
|
599
598
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
600
599
|
committee: EthAddress[],
|
|
601
600
|
invalidIndex: number,
|
|
@@ -606,7 +605,7 @@ export class RollupContract {
|
|
|
606
605
|
abi: RollupAbi,
|
|
607
606
|
functionName: 'invalidateBadAttestation',
|
|
608
607
|
args: [
|
|
609
|
-
BigInt(
|
|
608
|
+
BigInt(checkpointNumber),
|
|
610
609
|
attestationsAndSigners,
|
|
611
610
|
committee.map(addr => addr.toString()),
|
|
612
611
|
BigInt(invalidIndex),
|
|
@@ -617,7 +616,7 @@ export class RollupContract {
|
|
|
617
616
|
|
|
618
617
|
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
619
618
|
public buildInvalidateInsufficientAttestationsRequest(
|
|
620
|
-
|
|
619
|
+
checkpointNumber: CheckpointNumber,
|
|
621
620
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
622
621
|
committee: EthAddress[],
|
|
623
622
|
): L1TxRequest {
|
|
@@ -626,30 +625,30 @@ export class RollupContract {
|
|
|
626
625
|
data: encodeFunctionData({
|
|
627
626
|
abi: RollupAbi,
|
|
628
627
|
functionName: 'invalidateInsufficientAttestations',
|
|
629
|
-
args: [BigInt(
|
|
628
|
+
args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
|
|
630
629
|
}),
|
|
631
630
|
};
|
|
632
631
|
}
|
|
633
632
|
|
|
634
633
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
635
|
-
public getHasSubmittedProof(epochNumber:
|
|
634
|
+
public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
636
635
|
if (prover instanceof EthAddress) {
|
|
637
636
|
prover = prover.toString();
|
|
638
637
|
}
|
|
639
|
-
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(
|
|
638
|
+
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
640
639
|
}
|
|
641
640
|
|
|
642
641
|
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
|
|
643
642
|
return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
|
|
644
643
|
}
|
|
645
644
|
|
|
646
|
-
getSlotAt(timestamp: bigint) {
|
|
647
|
-
return this.rollup.read.getSlotAt([timestamp]);
|
|
645
|
+
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
646
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
648
647
|
}
|
|
649
648
|
|
|
650
|
-
async status(
|
|
649
|
+
async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
|
|
651
650
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
652
|
-
return this.rollup.read.status([
|
|
651
|
+
return this.rollup.read.status([BigInt(checkpointNumber)], options);
|
|
653
652
|
}
|
|
654
653
|
|
|
655
654
|
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
@@ -661,8 +660,8 @@ export class RollupContract {
|
|
|
661
660
|
return this.rollup.read.archive();
|
|
662
661
|
}
|
|
663
662
|
|
|
664
|
-
archiveAt(
|
|
665
|
-
return this.rollup.read.archiveAt([
|
|
663
|
+
archiveAt(checkpointNumber: CheckpointNumber) {
|
|
664
|
+
return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
|
|
666
665
|
}
|
|
667
666
|
|
|
668
667
|
getSequencerRewards(address: Hex | EthAddress) {
|
|
@@ -704,8 +703,8 @@ export class RollupContract {
|
|
|
704
703
|
return this.rollup.read.getStatus([address]);
|
|
705
704
|
}
|
|
706
705
|
|
|
707
|
-
getBlobCommitmentsHash(
|
|
708
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
706
|
+
getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
|
|
707
|
+
return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
|
|
709
708
|
}
|
|
710
709
|
|
|
711
710
|
getCurrentBlobCommitmentsHash() {
|
|
@@ -760,15 +759,17 @@ export class RollupContract {
|
|
|
760
759
|
);
|
|
761
760
|
}
|
|
762
761
|
|
|
763
|
-
public
|
|
764
|
-
|
|
762
|
+
public listenToCheckpointInvalidated(
|
|
763
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
764
|
+
): WatchContractEventReturnType {
|
|
765
|
+
return this.rollup.watchEvent.CheckpointInvalidated(
|
|
765
766
|
{},
|
|
766
767
|
{
|
|
767
768
|
onLogs: logs => {
|
|
768
769
|
for (const log of logs) {
|
|
769
770
|
const args = log.args;
|
|
770
|
-
if (args.
|
|
771
|
-
callback({
|
|
771
|
+
if (args.checkpointNumber !== undefined) {
|
|
772
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
|
|
772
773
|
}
|
|
773
774
|
}
|
|
774
775
|
},
|