@aztec/ethereum 3.0.0-nightly.20251127 → 3.0.0-nightly.20251201.2
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 +1 -1
- package/dest/config.d.ts.map +1 -1
- 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 +32 -44
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +24 -26
- 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 +7 -6
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +3 -3
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +453 -8
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +4 -3
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/l1_artifacts.d.ts +37 -100
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +3 -3
- package/dest/l1_reader.d.ts +1 -1
- package/dest/l1_tx_utils/config.d.ts +1 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- 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/index.d.ts +1 -1
- package/dest/l1_tx_utils/interfaces.d.ts +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_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 +16 -16
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- 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/test/chain_monitor.d.ts +8 -7
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +5 -6
- 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 +1 -13
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- 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 +7 -6
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +17 -14
- package/dest/test/start_anvil.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/types.d.ts +1 -1
- package/dest/utils.d.ts +1 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +9 -8
- 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 +25 -43
- package/src/contracts/tally_slashing_proposer.ts +8 -7
- package/src/deploy_l1_contracts.ts +4 -3
- package/src/test/chain_monitor.ts +13 -13
- package/src/test/rollup_cheat_codes.ts +18 -16
|
@@ -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 { 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';
|
|
@@ -82,22 +83,6 @@ export type ViemGasFees = {
|
|
|
82
83
|
feePerL2Gas: bigint;
|
|
83
84
|
};
|
|
84
85
|
|
|
85
|
-
export type ViemStateReference = {
|
|
86
|
-
l1ToL2MessageTree: ViemAppendOnlyTreeSnapshot;
|
|
87
|
-
partialStateReference: ViemPartialStateReference;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export type ViemPartialStateReference = {
|
|
91
|
-
noteHashTree: ViemAppendOnlyTreeSnapshot;
|
|
92
|
-
nullifierTree: ViemAppendOnlyTreeSnapshot;
|
|
93
|
-
publicDataTree: ViemAppendOnlyTreeSnapshot;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export type ViemAppendOnlyTreeSnapshot = {
|
|
97
|
-
root: `0x${string}`;
|
|
98
|
-
nextAvailableLeafIndex: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
86
|
export enum SlashingProposerType {
|
|
102
87
|
None = 0,
|
|
103
88
|
Tally = 1,
|
|
@@ -208,8 +193,8 @@ export class RollupContract {
|
|
|
208
193
|
}
|
|
209
194
|
|
|
210
195
|
@memoize
|
|
211
|
-
getSlotDuration() {
|
|
212
|
-
return this.rollup.read.getSlotDuration();
|
|
196
|
+
async getSlotDuration(): Promise<number> {
|
|
197
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
213
198
|
}
|
|
214
199
|
|
|
215
200
|
@memoize
|
|
@@ -300,7 +285,7 @@ export class RollupContract {
|
|
|
300
285
|
return {
|
|
301
286
|
l1StartBlock,
|
|
302
287
|
l1GenesisTime,
|
|
303
|
-
slotDuration
|
|
288
|
+
slotDuration,
|
|
304
289
|
epochDuration: Number(epochDuration),
|
|
305
290
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
306
291
|
};
|
|
@@ -349,8 +334,8 @@ export class RollupContract {
|
|
|
349
334
|
return this.rollup.read.getProvenCheckpointNumber();
|
|
350
335
|
}
|
|
351
336
|
|
|
352
|
-
getSlotNumber() {
|
|
353
|
-
return this.rollup.read.getCurrentSlot();
|
|
337
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
338
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
354
339
|
}
|
|
355
340
|
|
|
356
341
|
getL1FeesAt(timestamp: bigint) {
|
|
@@ -387,8 +372,8 @@ export class RollupContract {
|
|
|
387
372
|
return this.rollup.read.getCurrentSampleSeed();
|
|
388
373
|
}
|
|
389
374
|
|
|
390
|
-
getCurrentEpoch() {
|
|
391
|
-
return this.rollup.read.getCurrentEpoch();
|
|
375
|
+
async getCurrentEpoch(): Promise<EpochNumber> {
|
|
376
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
392
377
|
}
|
|
393
378
|
|
|
394
379
|
async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
|
|
@@ -439,8 +424,8 @@ export class RollupContract {
|
|
|
439
424
|
return this.rollup.read.getTips();
|
|
440
425
|
}
|
|
441
426
|
|
|
442
|
-
getTimestampForSlot(slot:
|
|
443
|
-
return this.rollup.read.getTimestampForSlot([slot]);
|
|
427
|
+
getTimestampForSlot(slot: SlotNumber) {
|
|
428
|
+
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
444
429
|
}
|
|
445
430
|
|
|
446
431
|
getEntryQueueLength() {
|
|
@@ -451,16 +436,16 @@ export class RollupContract {
|
|
|
451
436
|
return this.rollup.read.getAvailableValidatorFlushes();
|
|
452
437
|
}
|
|
453
438
|
|
|
454
|
-
getNextFlushableEpoch() {
|
|
455
|
-
return this.rollup.read.getNextFlushableEpoch();
|
|
439
|
+
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
440
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
456
441
|
}
|
|
457
442
|
|
|
458
|
-
getCurrentEpochNumber(): Promise<
|
|
459
|
-
return this.rollup.read.getCurrentEpoch();
|
|
443
|
+
async getCurrentEpochNumber(): Promise<EpochNumber> {
|
|
444
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
460
445
|
}
|
|
461
446
|
|
|
462
|
-
getEpochNumberForCheckpoint(checkpointNumber: bigint) {
|
|
463
|
-
return this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]);
|
|
447
|
+
async getEpochNumberForCheckpoint(checkpointNumber: bigint): Promise<EpochNumber> {
|
|
448
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
|
|
464
449
|
}
|
|
465
450
|
|
|
466
451
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -500,8 +485,8 @@ export class RollupContract {
|
|
|
500
485
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
501
486
|
}
|
|
502
487
|
|
|
503
|
-
public async getEpochNumberForSlotNumber(slotNumber:
|
|
504
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
488
|
+
public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
|
|
489
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
505
490
|
}
|
|
506
491
|
|
|
507
492
|
getEpochProofPublicInputs(
|
|
@@ -551,14 +536,11 @@ export class RollupContract {
|
|
|
551
536
|
public async canProposeAtNextEthBlock(
|
|
552
537
|
archive: Buffer,
|
|
553
538
|
account: `0x${string}` | Account,
|
|
554
|
-
slotDuration:
|
|
539
|
+
slotDuration: number,
|
|
555
540
|
opts: { forcePendingCheckpointNumber?: number } = {},
|
|
556
|
-
): Promise<{ slot:
|
|
557
|
-
if (typeof slotDuration === 'number') {
|
|
558
|
-
slotDuration = BigInt(slotDuration);
|
|
559
|
-
}
|
|
541
|
+
): Promise<{ slot: SlotNumber; checkpointNumber: bigint; timeOfNextL1Slot: bigint }> {
|
|
560
542
|
const latestBlock = await this.client.getBlock();
|
|
561
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
543
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
562
544
|
const who = typeof account === 'string' ? account : account.address;
|
|
563
545
|
|
|
564
546
|
try {
|
|
@@ -573,7 +555,7 @@ export class RollupContract {
|
|
|
573
555
|
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
574
556
|
});
|
|
575
557
|
|
|
576
|
-
return { slot, checkpointNumber, timeOfNextL1Slot };
|
|
558
|
+
return { slot: SlotNumber.fromBigInt(slot), checkpointNumber, timeOfNextL1Slot };
|
|
577
559
|
} catch (err: unknown) {
|
|
578
560
|
throw formatViemError(err);
|
|
579
561
|
}
|
|
@@ -641,7 +623,7 @@ export class RollupContract {
|
|
|
641
623
|
}
|
|
642
624
|
|
|
643
625
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
644
|
-
public getHasSubmittedProof(epochNumber:
|
|
626
|
+
public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
645
627
|
if (prover instanceof EthAddress) {
|
|
646
628
|
prover = prover.toString();
|
|
647
629
|
}
|
|
@@ -652,8 +634,8 @@ export class RollupContract {
|
|
|
652
634
|
return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
|
|
653
635
|
}
|
|
654
636
|
|
|
655
|
-
getSlotAt(timestamp: bigint) {
|
|
656
|
-
return this.rollup.read.getSlotAt([timestamp]);
|
|
637
|
+
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
638
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
657
639
|
}
|
|
658
640
|
|
|
659
641
|
async status(checkpointNumber: bigint, options?: { blockNumber?: bigint }) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type L1TxRequest, type ViemClient, tryExtractEvent } from '@aztec/ethereum';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -97,8 +98,8 @@ export class TallySlashingProposerContract {
|
|
|
97
98
|
* @param slot - The slot number to check at
|
|
98
99
|
* @returns Whether the round is ready to execute
|
|
99
100
|
*/
|
|
100
|
-
public async isRoundReadyToExecute(round: bigint, slot:
|
|
101
|
-
return await this.contract.read.isRoundReadyToExecute([round, slot]);
|
|
101
|
+
public async isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean> {
|
|
102
|
+
return await this.contract.read.isRoundReadyToExecute([round, BigInt(slot)]);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/** Returns the slash actions and payload address for a given round (zero if no slash actions) */
|
|
@@ -149,7 +150,7 @@ export class TallySlashingProposerContract {
|
|
|
149
150
|
*/
|
|
150
151
|
public async buildVoteRequestFromSigner(
|
|
151
152
|
votes: Hex,
|
|
152
|
-
slot:
|
|
153
|
+
slot: SlotNumber,
|
|
153
154
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
154
155
|
): Promise<L1TxRequest> {
|
|
155
156
|
const typedData = this.buildVoteTypedData(votes, slot);
|
|
@@ -166,7 +167,7 @@ export class TallySlashingProposerContract {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
/** Returns the typed data definition to EIP712-sign for voting */
|
|
169
|
-
public buildVoteTypedData(votes: Hex, slot:
|
|
170
|
+
public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
|
|
170
171
|
const domain = {
|
|
171
172
|
name: 'TallySlashingProposer',
|
|
172
173
|
version: '1',
|
|
@@ -187,12 +188,12 @@ export class TallySlashingProposerContract {
|
|
|
187
188
|
],
|
|
188
189
|
};
|
|
189
190
|
|
|
190
|
-
return { domain, types, primaryType: 'Vote', message: { votes, slot } };
|
|
191
|
+
return { domain, types, primaryType: 'Vote', message: { votes, slot: BigInt(slot) } };
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
/** Gets the digest to sign for voting directly from the contract */
|
|
194
|
-
public async getVoteDataDigest(votes: Hex, slot:
|
|
195
|
-
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, slot]));
|
|
195
|
+
public async getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32> {
|
|
196
|
+
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, BigInt(slot)]));
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { SecretValue, getActiveNetworkName } from '@aztec/foundation/config';
|
|
3
4
|
import { keccak256String } from '@aztec/foundation/crypto';
|
|
4
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -1519,13 +1520,13 @@ export const deployL1Contracts = async (
|
|
|
1519
1520
|
// Need to get the time
|
|
1520
1521
|
const currentSlot = await rollup.getSlotNumber();
|
|
1521
1522
|
|
|
1522
|
-
if (
|
|
1523
|
-
const ts = Number(await rollup.getTimestampForSlot(
|
|
1523
|
+
if (currentSlot === 0) {
|
|
1524
|
+
const ts = Number(await rollup.getTimestampForSlot(SlotNumber(1)));
|
|
1524
1525
|
await rpcCall('evm_setNextBlockTimestamp', [ts]);
|
|
1525
1526
|
await rpcCall('hardhat_mine', [1]);
|
|
1526
1527
|
const currentSlot = await rollup.getSlotNumber();
|
|
1527
1528
|
|
|
1528
|
-
if (
|
|
1529
|
+
if (currentSlot !== 1) {
|
|
1529
1530
|
throw new Error(`Error jumping time: current slot is ${currentSlot}`);
|
|
1530
1531
|
}
|
|
1531
1532
|
logger.info(`Jumped to slot 1`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InboxContract, type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
@@ -10,11 +11,11 @@ import type { ViemClient } from '../types.js';
|
|
|
10
11
|
|
|
11
12
|
export type ChainMonitorEventMap = {
|
|
12
13
|
'l1-block': [{ l1BlockNumber: number; timestamp: bigint }];
|
|
13
|
-
checkpoint: [{ checkpointNumber: number; l1BlockNumber: number; l2SlotNumber:
|
|
14
|
+
checkpoint: [{ checkpointNumber: number; l1BlockNumber: number; l2SlotNumber: SlotNumber; timestamp: bigint }];
|
|
14
15
|
'checkpoint-proven': [{ provenCheckpointNumber: number; l1BlockNumber: number; timestamp: bigint }];
|
|
15
16
|
'l2-messages': [{ totalL2Messages: number; l1BlockNumber: number }];
|
|
16
|
-
'l2-epoch': [{ l2EpochNumber:
|
|
17
|
-
'l2-slot': [{ l2SlotNumber:
|
|
17
|
+
'l2-epoch': [{ l2EpochNumber: EpochNumber; timestamp: bigint; committee: EthAddress[] | undefined }];
|
|
18
|
+
'l2-slot': [{ l2SlotNumber: SlotNumber; timestamp: bigint }];
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
@@ -38,9 +39,9 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
38
39
|
/** Total number of L2 messages pushed into the Inbox */
|
|
39
40
|
public totalL2Messages: number = 0;
|
|
40
41
|
/** Current L2 epoch number */
|
|
41
|
-
public l2EpochNumber!:
|
|
42
|
+
public l2EpochNumber!: EpochNumber;
|
|
42
43
|
/** Current L2 slot number */
|
|
43
|
-
public l2SlotNumber!:
|
|
44
|
+
public l2SlotNumber!: SlotNumber;
|
|
44
45
|
|
|
45
46
|
constructor(
|
|
46
47
|
private readonly rollup: RollupContract,
|
|
@@ -123,7 +124,7 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
123
124
|
this.emit('checkpoint', {
|
|
124
125
|
checkpointNumber: newCheckpointNumber,
|
|
125
126
|
l1BlockNumber: newL1BlockNumber,
|
|
126
|
-
l2SlotNumber
|
|
127
|
+
l2SlotNumber,
|
|
127
128
|
timestamp,
|
|
128
129
|
});
|
|
129
130
|
}
|
|
@@ -153,13 +154,13 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
153
154
|
if (l2Epoch !== this.l2EpochNumber) {
|
|
154
155
|
this.l2EpochNumber = l2Epoch;
|
|
155
156
|
committee = (await this.rollup.getCurrentEpochCommittee())?.map(addr => EthAddress.fromString(addr));
|
|
156
|
-
this.emit('l2-epoch', { l2EpochNumber:
|
|
157
|
+
this.emit('l2-epoch', { l2EpochNumber: l2Epoch, timestamp, committee });
|
|
157
158
|
msg += ` starting new epoch ${this.l2EpochNumber} `;
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
if (l2SlotNumber !== this.l2SlotNumber) {
|
|
161
162
|
this.l2SlotNumber = l2SlotNumber;
|
|
162
|
-
this.emit('l2-slot', { l2SlotNumber
|
|
163
|
+
this.emit('l2-slot', { l2SlotNumber, timestamp });
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
this.logger.info(msg, {
|
|
@@ -177,14 +178,13 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
177
178
|
return this;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
public waitUntilL2Slot(slot:
|
|
181
|
-
|
|
182
|
-
if (this.l2SlotNumber >= targetSlot) {
|
|
181
|
+
public waitUntilL2Slot(slot: SlotNumber): Promise<void> {
|
|
182
|
+
if (this.l2SlotNumber >= slot) {
|
|
183
183
|
return Promise.resolve();
|
|
184
184
|
}
|
|
185
185
|
return new Promise(resolve => {
|
|
186
|
-
const listener = (data: { l2SlotNumber:
|
|
187
|
-
if (data.l2SlotNumber >=
|
|
186
|
+
const listener = (data: { l2SlotNumber: SlotNumber; timestamp: bigint }) => {
|
|
187
|
+
if (data.l2SlotNumber >= slot) {
|
|
188
188
|
this.off('l2-slot', listener);
|
|
189
189
|
resolve();
|
|
190
190
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RollupContract, type ViemPublicClient } from '@aztec/ethereum';
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -49,15 +50,15 @@ export class RollupCheatCodes {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/** Returns the current slot */
|
|
52
|
-
public async getSlot() {
|
|
53
|
+
public async getSlot(): Promise<SlotNumber> {
|
|
53
54
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
54
|
-
return await this.rollup.read.getSlotAt([ts]);
|
|
55
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([ts]));
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/** Returns the current epoch */
|
|
58
|
-
public async getEpoch() {
|
|
59
|
+
public async getEpoch(): Promise<EpochNumber> {
|
|
59
60
|
const slotNumber = await this.getSlot();
|
|
60
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
61
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/**
|
|
@@ -96,13 +97,13 @@ export class RollupCheatCodes {
|
|
|
96
97
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
97
98
|
public async getConfig(): Promise<{
|
|
98
99
|
/** Epoch duration */ epochDuration: bigint;
|
|
99
|
-
/** Slot duration */ slotDuration:
|
|
100
|
+
/** Slot duration */ slotDuration: number;
|
|
100
101
|
}> {
|
|
101
102
|
const [epochDuration, slotDuration] = await Promise.all([
|
|
102
103
|
this.rollup.read.getEpochDuration(),
|
|
103
104
|
this.rollup.read.getSlotDuration(),
|
|
104
105
|
]);
|
|
105
|
-
return { epochDuration, slotDuration };
|
|
106
|
+
return { epochDuration, slotDuration: Number(slotDuration) };
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
/**
|
|
@@ -111,15 +112,15 @@ export class RollupCheatCodes {
|
|
|
111
112
|
* @param opts - Options
|
|
112
113
|
*/
|
|
113
114
|
public async advanceToEpoch(
|
|
114
|
-
epoch:
|
|
115
|
+
epoch: EpochNumber,
|
|
115
116
|
opts: {
|
|
116
117
|
/** Offset in seconds */
|
|
117
118
|
offset?: number;
|
|
118
119
|
} = {},
|
|
119
120
|
) {
|
|
120
121
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
121
|
-
const
|
|
122
|
-
|
|
122
|
+
const slotNumber = SlotNumber(epoch * Number(slotsInEpoch));
|
|
123
|
+
const timestamp = (await this.rollup.read.getTimestampForSlot([BigInt(slotNumber)])) + BigInt(opts.offset ?? 0);
|
|
123
124
|
try {
|
|
124
125
|
await this.ethCheatCodes.warp(Number(timestamp), { ...opts, silent: true, resetBlockInterval: true });
|
|
125
126
|
this.logger.warn(`Warped to epoch ${epoch}`);
|
|
@@ -133,8 +134,8 @@ export class RollupCheatCodes {
|
|
|
133
134
|
public async advanceToNextEpoch() {
|
|
134
135
|
const slot = await this.getSlot();
|
|
135
136
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
136
|
-
const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
|
|
137
|
-
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
137
|
+
const slotsUntilNextEpoch = epochDuration - (BigInt(slot) % epochDuration) + 1n;
|
|
138
|
+
const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
|
|
138
139
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
139
140
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
140
141
|
silent: true,
|
|
@@ -146,10 +147,11 @@ export class RollupCheatCodes {
|
|
|
146
147
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
147
148
|
public async advanceToNextSlot() {
|
|
148
149
|
const currentSlot = await this.getSlot();
|
|
149
|
-
const
|
|
150
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
151
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]);
|
|
150
152
|
await this.ethCheatCodes.warp(Number(timestamp), { silent: true, resetBlockInterval: true });
|
|
151
|
-
this.logger.warn(`Advanced to slot ${
|
|
152
|
-
return [timestamp,
|
|
153
|
+
this.logger.warn(`Advanced to slot ${nextSlot}`);
|
|
154
|
+
return [timestamp, nextSlot];
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
/**
|
|
@@ -158,8 +160,8 @@ export class RollupCheatCodes {
|
|
|
158
160
|
*/
|
|
159
161
|
public async advanceSlots(howMany: number) {
|
|
160
162
|
const l1Timestamp = (await this.client.getBlock()).timestamp;
|
|
161
|
-
const slotDuration = await this.rollup.read.getSlotDuration();
|
|
162
|
-
const timeToWarp = BigInt(howMany) * slotDuration;
|
|
163
|
+
const slotDuration = Number(await this.rollup.read.getSlotDuration());
|
|
164
|
+
const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
|
|
163
165
|
await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, { silent: true, resetBlockInterval: true });
|
|
164
166
|
const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]);
|
|
165
167
|
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|