@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.fce3e4f
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 +13 -7
- 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 +70 -65
- 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 +455 -8
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +51 -33
- 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 +2020 -860
- 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 +3 -3
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +13 -4
- 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/readonly_l1_tx_utils.js +3 -4
- 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 +21 -20
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +33 -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 +8 -2
- 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 +11 -10
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +36 -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/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 +10 -9
- package/src/config.ts +16 -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 +71 -78
- package/src/contracts/tally_slashing_proposer.ts +8 -7
- package/src/deploy_l1_contracts.ts +55 -35
- package/src/l1_tx_utils/config.ts +9 -6
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +3 -4
- package/src/queries.ts +6 -3
- package/src/test/chain_monitor.ts +47 -47
- package/src/test/eth_cheat_codes.ts +7 -1
- package/src/test/rollup_cheat_codes.ts +37 -40
- package/src/test/start_anvil.ts +2 -0
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';
|
|
@@ -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
|
+
getCheckpointNumber() {
|
|
330
|
+
return this.rollup.read.getPendingCheckpointNumber();
|
|
340
331
|
}
|
|
341
332
|
|
|
342
|
-
|
|
343
|
-
return this.rollup.read.
|
|
333
|
+
getProvenCheckpointNumber() {
|
|
334
|
+
return 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,16 @@ export class RollupContract {
|
|
|
425
416
|
return result;
|
|
426
417
|
}
|
|
427
418
|
|
|
428
|
-
|
|
429
|
-
return this.rollup.read.
|
|
419
|
+
getCheckpoint(checkpointNumber: bigint | number) {
|
|
420
|
+
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
430
421
|
}
|
|
431
422
|
|
|
432
423
|
getTips() {
|
|
433
424
|
return this.rollup.read.getTips();
|
|
434
425
|
}
|
|
435
426
|
|
|
436
|
-
getTimestampForSlot(slot:
|
|
437
|
-
return this.rollup.read.getTimestampForSlot([slot]);
|
|
427
|
+
getTimestampForSlot(slot: SlotNumber) {
|
|
428
|
+
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
438
429
|
}
|
|
439
430
|
|
|
440
431
|
getEntryQueueLength() {
|
|
@@ -445,16 +436,16 @@ export class RollupContract {
|
|
|
445
436
|
return this.rollup.read.getAvailableValidatorFlushes();
|
|
446
437
|
}
|
|
447
438
|
|
|
448
|
-
getNextFlushableEpoch() {
|
|
449
|
-
return this.rollup.read.getNextFlushableEpoch();
|
|
439
|
+
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
440
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
450
441
|
}
|
|
451
442
|
|
|
452
|
-
getCurrentEpochNumber(): Promise<
|
|
453
|
-
return this.rollup.read.getCurrentEpoch();
|
|
443
|
+
async getCurrentEpochNumber(): Promise<EpochNumber> {
|
|
444
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
454
445
|
}
|
|
455
446
|
|
|
456
|
-
|
|
457
|
-
return this.rollup.read.
|
|
447
|
+
async getEpochNumberForCheckpoint(checkpointNumber: bigint): Promise<EpochNumber> {
|
|
448
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
|
|
458
449
|
}
|
|
459
450
|
|
|
460
451
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -494,8 +485,8 @@ export class RollupContract {
|
|
|
494
485
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
495
486
|
}
|
|
496
487
|
|
|
497
|
-
public async getEpochNumberForSlotNumber(slotNumber:
|
|
498
|
-
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)]));
|
|
499
490
|
}
|
|
500
491
|
|
|
501
492
|
getEpochProofPublicInputs(
|
|
@@ -538,53 +529,53 @@ export class RollupContract {
|
|
|
538
529
|
* @dev Throws if unable to propose
|
|
539
530
|
*
|
|
540
531
|
* @param archive - The archive that we expect to be current state
|
|
541
|
-
* @return [slot,
|
|
532
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
533
|
+
* timestamp of the next L1 block
|
|
542
534
|
* @throws otherwise
|
|
543
535
|
*/
|
|
544
536
|
public async canProposeAtNextEthBlock(
|
|
545
537
|
archive: Buffer,
|
|
546
538
|
account: `0x${string}` | Account,
|
|
547
|
-
slotDuration:
|
|
548
|
-
opts: {
|
|
549
|
-
): Promise<{ slot:
|
|
550
|
-
if (typeof slotDuration === 'number') {
|
|
551
|
-
slotDuration = BigInt(slotDuration);
|
|
552
|
-
}
|
|
539
|
+
slotDuration: number,
|
|
540
|
+
opts: { forcePendingCheckpointNumber?: number } = {},
|
|
541
|
+
): Promise<{ slot: SlotNumber; checkpointNumber: bigint; timeOfNextL1Slot: bigint }> {
|
|
553
542
|
const latestBlock = await this.client.getBlock();
|
|
554
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
543
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
555
544
|
const who = typeof account === 'string' ? account : account.address;
|
|
556
545
|
|
|
557
546
|
try {
|
|
558
547
|
const {
|
|
559
|
-
result: [slot,
|
|
548
|
+
result: [slot, checkpointNumber],
|
|
560
549
|
} = await this.client.simulateContract({
|
|
561
550
|
address: this.address,
|
|
562
551
|
abi: RollupAbi,
|
|
563
552
|
functionName: 'canProposeAtTime',
|
|
564
553
|
args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
|
|
565
554
|
account,
|
|
566
|
-
stateOverride: await this.
|
|
555
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
567
556
|
});
|
|
568
557
|
|
|
569
|
-
return { slot,
|
|
558
|
+
return { slot: SlotNumber.fromBigInt(slot), checkpointNumber, timeOfNextL1Slot };
|
|
570
559
|
} catch (err: unknown) {
|
|
571
560
|
throw formatViemError(err);
|
|
572
561
|
}
|
|
573
562
|
}
|
|
574
563
|
|
|
575
564
|
/**
|
|
576
|
-
* Returns a state override that sets the pending
|
|
577
|
-
* Requires querying the current state of the contract to get the current proven
|
|
565
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
566
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
578
567
|
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
579
568
|
*/
|
|
580
|
-
public async
|
|
581
|
-
|
|
569
|
+
public async makePendingCheckpointNumberOverride(
|
|
570
|
+
forcePendingCheckpointNumber: number | undefined,
|
|
571
|
+
): Promise<StateOverride> {
|
|
572
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
582
573
|
return [];
|
|
583
574
|
}
|
|
584
575
|
const slot = RollupContract.stfStorageSlot;
|
|
585
576
|
const currentValue = await this.client.getStorageAt({ address: this.address, slot });
|
|
586
|
-
const
|
|
587
|
-
const newValue = (BigInt(
|
|
577
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
|
|
578
|
+
const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
|
|
588
579
|
return [
|
|
589
580
|
{
|
|
590
581
|
address: this.address,
|
|
@@ -595,7 +586,7 @@ export class RollupContract {
|
|
|
595
586
|
|
|
596
587
|
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
597
588
|
public buildInvalidateBadAttestationRequest(
|
|
598
|
-
|
|
589
|
+
checkpointNumber: number,
|
|
599
590
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
600
591
|
committee: EthAddress[],
|
|
601
592
|
invalidIndex: number,
|
|
@@ -606,7 +597,7 @@ export class RollupContract {
|
|
|
606
597
|
abi: RollupAbi,
|
|
607
598
|
functionName: 'invalidateBadAttestation',
|
|
608
599
|
args: [
|
|
609
|
-
BigInt(
|
|
600
|
+
BigInt(checkpointNumber),
|
|
610
601
|
attestationsAndSigners,
|
|
611
602
|
committee.map(addr => addr.toString()),
|
|
612
603
|
BigInt(invalidIndex),
|
|
@@ -617,7 +608,7 @@ export class RollupContract {
|
|
|
617
608
|
|
|
618
609
|
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
619
610
|
public buildInvalidateInsufficientAttestationsRequest(
|
|
620
|
-
|
|
611
|
+
checkpointNumber: number,
|
|
621
612
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
622
613
|
committee: EthAddress[],
|
|
623
614
|
): L1TxRequest {
|
|
@@ -626,30 +617,30 @@ export class RollupContract {
|
|
|
626
617
|
data: encodeFunctionData({
|
|
627
618
|
abi: RollupAbi,
|
|
628
619
|
functionName: 'invalidateInsufficientAttestations',
|
|
629
|
-
args: [BigInt(
|
|
620
|
+
args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
|
|
630
621
|
}),
|
|
631
622
|
};
|
|
632
623
|
}
|
|
633
624
|
|
|
634
625
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
635
|
-
public getHasSubmittedProof(epochNumber:
|
|
626
|
+
public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
636
627
|
if (prover instanceof EthAddress) {
|
|
637
628
|
prover = prover.toString();
|
|
638
629
|
}
|
|
639
|
-
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(
|
|
630
|
+
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
640
631
|
}
|
|
641
632
|
|
|
642
633
|
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
|
|
643
634
|
return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
|
|
644
635
|
}
|
|
645
636
|
|
|
646
|
-
getSlotAt(timestamp: bigint) {
|
|
647
|
-
return this.rollup.read.getSlotAt([timestamp]);
|
|
637
|
+
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
638
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
648
639
|
}
|
|
649
640
|
|
|
650
|
-
async status(
|
|
641
|
+
async status(checkpointNumber: bigint, options?: { blockNumber?: bigint }) {
|
|
651
642
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
652
|
-
return this.rollup.read.status([
|
|
643
|
+
return this.rollup.read.status([checkpointNumber], options);
|
|
653
644
|
}
|
|
654
645
|
|
|
655
646
|
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
@@ -661,8 +652,8 @@ export class RollupContract {
|
|
|
661
652
|
return this.rollup.read.archive();
|
|
662
653
|
}
|
|
663
654
|
|
|
664
|
-
archiveAt(
|
|
665
|
-
return this.rollup.read.archiveAt([
|
|
655
|
+
archiveAt(checkpointNumber: bigint) {
|
|
656
|
+
return this.rollup.read.archiveAt([checkpointNumber]);
|
|
666
657
|
}
|
|
667
658
|
|
|
668
659
|
getSequencerRewards(address: Hex | EthAddress) {
|
|
@@ -704,8 +695,8 @@ export class RollupContract {
|
|
|
704
695
|
return this.rollup.read.getStatus([address]);
|
|
705
696
|
}
|
|
706
697
|
|
|
707
|
-
getBlobCommitmentsHash(
|
|
708
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
698
|
+
getBlobCommitmentsHash(checkpointNumber: bigint) {
|
|
699
|
+
return this.rollup.read.getBlobCommitmentsHash([checkpointNumber]);
|
|
709
700
|
}
|
|
710
701
|
|
|
711
702
|
getCurrentBlobCommitmentsHash() {
|
|
@@ -760,15 +751,17 @@ export class RollupContract {
|
|
|
760
751
|
);
|
|
761
752
|
}
|
|
762
753
|
|
|
763
|
-
public
|
|
764
|
-
|
|
754
|
+
public listenToCheckpointInvalidated(
|
|
755
|
+
callback: (args: { checkpointNumber: bigint }) => unknown,
|
|
756
|
+
): WatchContractEventReturnType {
|
|
757
|
+
return this.rollup.watchEvent.CheckpointInvalidated(
|
|
765
758
|
{},
|
|
766
759
|
{
|
|
767
760
|
onLogs: logs => {
|
|
768
761
|
for (const log of logs) {
|
|
769
762
|
const args = log.args;
|
|
770
|
-
if (args.
|
|
771
|
-
callback({
|
|
763
|
+
if (args.checkpointNumber !== undefined) {
|
|
764
|
+
callback({ checkpointNumber: args.checkpointNumber });
|
|
772
765
|
}
|
|
773
766
|
}
|
|
774
767
|
},
|
|
@@ -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';
|
|
@@ -277,14 +278,22 @@ export const deploySharedContracts = async (
|
|
|
277
278
|
logger.verbose(`Deployed Fee Asset at ${feeAssetAddress}`);
|
|
278
279
|
|
|
279
280
|
// Mint a tiny bit of tokens to satisfy coin-issuer constraints
|
|
280
|
-
const { txHash } = await deployer.sendTransaction(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
const { txHash } = await deployer.sendTransaction(
|
|
282
|
+
{
|
|
283
|
+
to: feeAssetAddress.toString(),
|
|
284
|
+
data: encodeFunctionData({
|
|
285
|
+
abi: FeeAssetArtifact.contractAbi,
|
|
286
|
+
functionName: 'mint',
|
|
287
|
+
args: [l1Client.account.address, 1n * 10n ** 18n],
|
|
288
|
+
}),
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
// contract may not have been deployed yet (CREATE2 returns address before mining),
|
|
292
|
+
// which causes gas estimation to fail. Hardcode to 100k which is plenty for ERC20 mint.
|
|
293
|
+
gasLimit: 100_000n,
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
await l1Client.waitForTransactionReceipt({ hash: txHash });
|
|
288
297
|
logger.verbose(`Minted tiny bit of tokens to satisfy coin-issuer constraints in ${txHash}`);
|
|
289
298
|
|
|
290
299
|
const deployedStaking = await deployer.deploy(StakingAssetArtifact, ['Staking', 'STK', l1Client.account.address]);
|
|
@@ -362,12 +371,19 @@ export const deploySharedContracts = async (
|
|
|
362
371
|
txHashes.push(txHash);
|
|
363
372
|
}
|
|
364
373
|
|
|
374
|
+
logger.verbose(`Waiting for deployments to complete`);
|
|
375
|
+
await deployer.waitForDeployments();
|
|
376
|
+
|
|
365
377
|
const coinIssuerAddress = (
|
|
366
|
-
await deployer.deploy(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
378
|
+
await deployer.deploy(
|
|
379
|
+
CoinIssuerArtifact,
|
|
380
|
+
[
|
|
381
|
+
feeAssetAddress.toString(),
|
|
382
|
+
2n * 10n ** 17n, // hard cap of 20% per year
|
|
383
|
+
l1Client.account.address,
|
|
384
|
+
],
|
|
385
|
+
{ gasLimit: 1_000_000n, noSimulation: true },
|
|
386
|
+
)
|
|
371
387
|
).address;
|
|
372
388
|
logger.verbose(`Deployed CoinIssuer at ${coinIssuerAddress}`);
|
|
373
389
|
|
|
@@ -386,17 +402,16 @@ export const deploySharedContracts = async (
|
|
|
386
402
|
/* CHEAT CODES START HERE */
|
|
387
403
|
/* -------------------------------------------------------------------------- */
|
|
388
404
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
).address;
|
|
405
|
+
const deployedFeeAssetHandler = await deployer.deploy(FeeAssetHandlerArtifact, [
|
|
406
|
+
l1Client.account.address,
|
|
407
|
+
feeAssetAddress.toString(),
|
|
408
|
+
BigInt(1000n * 10n ** 18n),
|
|
409
|
+
]);
|
|
410
|
+
feeAssetHandlerAddress = deployedFeeAssetHandler.address;
|
|
396
411
|
logger.verbose(`Deployed FeeAssetHandler at ${feeAssetHandlerAddress}`);
|
|
397
412
|
|
|
398
|
-
// Only
|
|
399
|
-
if (
|
|
413
|
+
// Only add as minter if this is a new deployment (not reusing existing handler from failed previous run)
|
|
414
|
+
if (!deployedFeeAssetHandler.existed) {
|
|
400
415
|
const { txHash } = await deployer.sendTransaction({
|
|
401
416
|
to: feeAssetAddress.toString(),
|
|
402
417
|
data: encodeFunctionData({
|
|
@@ -473,9 +488,9 @@ export const deploySharedContracts = async (
|
|
|
473
488
|
const rewardDistributorAddress = await registry.getRewardDistributor();
|
|
474
489
|
|
|
475
490
|
if (!args.existingTokenAddress) {
|
|
476
|
-
const
|
|
491
|
+
const checkpointReward = getRewardConfig(networkName).checkpointReward;
|
|
477
492
|
|
|
478
|
-
const funding =
|
|
493
|
+
const funding = checkpointReward * 200000n;
|
|
479
494
|
const { txHash: fundRewardDistributorTxHash } = await deployer.sendTransaction({
|
|
480
495
|
to: feeAssetAddress.toString(),
|
|
481
496
|
data: encodeFunctionData({
|
|
@@ -849,7 +864,8 @@ export const deployRollup = async (
|
|
|
849
864
|
aztecSlotDuration: BigInt(args.aztecSlotDuration),
|
|
850
865
|
aztecEpochDuration: BigInt(args.aztecEpochDuration),
|
|
851
866
|
targetCommitteeSize: BigInt(args.aztecTargetCommitteeSize),
|
|
852
|
-
|
|
867
|
+
lagInEpochsForValidatorSet: BigInt(args.lagInEpochsForValidatorSet),
|
|
868
|
+
lagInEpochsForRandao: BigInt(args.lagInEpochsForRandao),
|
|
853
869
|
aztecProofSubmissionEpochs: BigInt(args.aztecProofSubmissionEpochs),
|
|
854
870
|
slashingQuorum: BigInt(args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1),
|
|
855
871
|
slashingRoundSize: BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration),
|
|
@@ -1504,13 +1520,13 @@ export const deployL1Contracts = async (
|
|
|
1504
1520
|
// Need to get the time
|
|
1505
1521
|
const currentSlot = await rollup.getSlotNumber();
|
|
1506
1522
|
|
|
1507
|
-
if (
|
|
1508
|
-
const ts = Number(await rollup.getTimestampForSlot(
|
|
1523
|
+
if (currentSlot === 0) {
|
|
1524
|
+
const ts = Number(await rollup.getTimestampForSlot(SlotNumber(1)));
|
|
1509
1525
|
await rpcCall('evm_setNextBlockTimestamp', [ts]);
|
|
1510
1526
|
await rpcCall('hardhat_mine', [1]);
|
|
1511
1527
|
const currentSlot = await rollup.getSlotNumber();
|
|
1512
1528
|
|
|
1513
|
-
if (
|
|
1529
|
+
if (currentSlot !== 1) {
|
|
1514
1530
|
throw new Error(`Error jumping time: current slot is ${currentSlot}`);
|
|
1515
1531
|
}
|
|
1516
1532
|
logger.info(`Jumped to slot 1`);
|
|
@@ -1561,7 +1577,7 @@ export class L1Deployer {
|
|
|
1561
1577
|
async deploy<const TAbi extends Abi>(
|
|
1562
1578
|
params: ContractArtifacts<TAbi>,
|
|
1563
1579
|
args?: ContractConstructorArgs<TAbi>,
|
|
1564
|
-
opts: { gasLimit?: bigint } = {},
|
|
1580
|
+
opts: { gasLimit?: bigint; noSimulation?: boolean } = {},
|
|
1565
1581
|
): Promise<{ address: EthAddress; existed: boolean }> {
|
|
1566
1582
|
this.logger.debug(`Deploying ${params.name} contract`, { args });
|
|
1567
1583
|
try {
|
|
@@ -1577,6 +1593,7 @@ export class L1Deployer {
|
|
|
1577
1593
|
l1TxUtils: this.l1TxUtils,
|
|
1578
1594
|
acceleratedTestDeployments: this.acceleratedTestDeployments,
|
|
1579
1595
|
gasLimit: opts.gasLimit,
|
|
1596
|
+
noSimulation: opts.noSimulation,
|
|
1580
1597
|
},
|
|
1581
1598
|
);
|
|
1582
1599
|
if (txHash) {
|
|
@@ -1666,6 +1683,7 @@ export async function deployL1Contract(
|
|
|
1666
1683
|
l1TxUtils?: L1TxUtils;
|
|
1667
1684
|
gasLimit?: bigint;
|
|
1668
1685
|
acceleratedTestDeployments?: boolean;
|
|
1686
|
+
noSimulation?: boolean;
|
|
1669
1687
|
} = {},
|
|
1670
1688
|
): Promise<{
|
|
1671
1689
|
address: EthAddress;
|
|
@@ -1677,7 +1695,7 @@ export async function deployL1Contract(
|
|
|
1677
1695
|
let resultingAddress: Hex | null | undefined = undefined;
|
|
1678
1696
|
const deployedLibraries: VerificationLibraryEntry[] = [];
|
|
1679
1697
|
|
|
1680
|
-
const { salt: saltFromOpts, libraries, logger, gasLimit, acceleratedTestDeployments } = opts;
|
|
1698
|
+
const { salt: saltFromOpts, libraries, logger, gasLimit, acceleratedTestDeployments, noSimulation } = opts;
|
|
1681
1699
|
let { l1TxUtils } = opts;
|
|
1682
1700
|
|
|
1683
1701
|
if (!l1TxUtils) {
|
|
@@ -1786,11 +1804,13 @@ export async function deployL1Contract(
|
|
|
1786
1804
|
resultingAddress = address;
|
|
1787
1805
|
const existing = await extendedClient.getCode({ address: resultingAddress });
|
|
1788
1806
|
if (existing === undefined || existing === '0x') {
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1807
|
+
if (!noSimulation) {
|
|
1808
|
+
try {
|
|
1809
|
+
await l1TxUtils.simulate({ to: DEPLOYER_ADDRESS, data: concatHex([salt, calldata]), gas: gasLimit });
|
|
1810
|
+
} catch (err) {
|
|
1811
|
+
logger?.error(`Failed to simulate deployment tx using universal deployer`, err);
|
|
1812
|
+
await l1TxUtils.simulate({ to: null, data: encodeDeployData({ abi, bytecode, args }), gas: gasLimit });
|
|
1813
|
+
}
|
|
1794
1814
|
}
|
|
1795
1815
|
const res = await l1TxUtils.sendTransaction(
|
|
1796
1816
|
{ to: DEPLOYER_ADDRESS, data: concatHex([salt, calldata]) },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
-
bigintConfigHelper,
|
|
4
3
|
booleanConfigHelper,
|
|
4
|
+
floatConfigHelper,
|
|
5
5
|
getConfigFromMappings,
|
|
6
6
|
getDefaultConfig,
|
|
7
7
|
numberConfigHelper,
|
|
@@ -15,11 +15,11 @@ export interface L1TxUtilsConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* Maximum gas price in gwei
|
|
17
17
|
*/
|
|
18
|
-
maxGwei?:
|
|
18
|
+
maxGwei?: number;
|
|
19
19
|
/**
|
|
20
20
|
* Maximum blob fee per gas in gwei
|
|
21
21
|
*/
|
|
22
|
-
maxBlobGwei?:
|
|
22
|
+
maxBlobGwei?: number;
|
|
23
23
|
/**
|
|
24
24
|
* Priority fee bump percentage
|
|
25
25
|
*/
|
|
@@ -71,12 +71,14 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
|
71
71
|
maxGwei: {
|
|
72
72
|
description: 'Maximum gas price in gwei to be used for transactions.',
|
|
73
73
|
env: 'L1_GAS_PRICE_MAX',
|
|
74
|
-
|
|
74
|
+
fallback: ['L1_FEE_PER_GAS_GWEI_MAX'],
|
|
75
|
+
...floatConfigHelper(2000),
|
|
75
76
|
},
|
|
76
77
|
maxBlobGwei: {
|
|
77
78
|
description: 'Maximum blob fee per gas in gwei',
|
|
78
79
|
env: 'L1_BLOB_FEE_PER_GAS_MAX',
|
|
79
|
-
|
|
80
|
+
fallback: ['L1_BLOB_FEE_PER_GAS_GWEI_MAX'],
|
|
81
|
+
...floatConfigHelper(3000),
|
|
80
82
|
},
|
|
81
83
|
priorityFeeBumpPercentage: {
|
|
82
84
|
description: 'How much to increase priority fee by each attempt (percentage)',
|
|
@@ -91,7 +93,8 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
|
91
93
|
fixedPriorityFeePerGas: {
|
|
92
94
|
description: 'Fixed priority fee per gas in Gwei. Overrides any priority fee bump percentage',
|
|
93
95
|
env: 'L1_FIXED_PRIORITY_FEE_PER_GAS',
|
|
94
|
-
|
|
96
|
+
fallback: ['L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI'],
|
|
97
|
+
...floatConfigHelper(0),
|
|
95
98
|
},
|
|
96
99
|
maxSpeedUpAttempts: {
|
|
97
100
|
description: 'Maximum number of speed-up attempts',
|
|
@@ -248,8 +248,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
248
248
|
this.logger?.debug('Using fixed priority fee per L1 gas', {
|
|
249
249
|
fixedPriorityFeePerGas: gasConfig.fixedPriorityFeePerGas,
|
|
250
250
|
});
|
|
251
|
-
|
|
252
|
-
priorityFee = BigInt(gasConfig.fixedPriorityFeePerGas * 1_000_000) * (WEI_CONST / 1_000_000n);
|
|
251
|
+
priorityFee = BigInt(Math.trunc(gasConfig.fixedPriorityFeePerGas * Number(WEI_CONST)));
|
|
253
252
|
} else {
|
|
254
253
|
// Get competitive priority fee (includes network estimate + analysis)
|
|
255
254
|
priorityFee = this.getCompetitivePriorityFee(networkEstimateResult, pendingBlockResult, feeHistoryResult);
|
|
@@ -321,8 +320,8 @@ export class ReadOnlyL1TxUtils {
|
|
|
321
320
|
}
|
|
322
321
|
|
|
323
322
|
// maxGwei and maxBlobGwei are hard limits
|
|
324
|
-
const effectiveMaxGwei = gasConfig.maxGwei! * WEI_CONST;
|
|
325
|
-
const effectiveMaxBlobGwei = gasConfig.maxBlobGwei! * WEI_CONST;
|
|
323
|
+
const effectiveMaxGwei = BigInt(Math.trunc(gasConfig.maxGwei! * Number(WEI_CONST)));
|
|
324
|
+
const effectiveMaxBlobGwei = BigInt(Math.trunc(gasConfig.maxBlobGwei! * Number(WEI_CONST)));
|
|
326
325
|
|
|
327
326
|
// Ensure we don't exceed maxGwei
|
|
328
327
|
if (effectiveMaxGwei > 0n) {
|
package/src/queries.ts
CHANGED
|
@@ -33,7 +33,8 @@ export async function getL1ContractsConfig(
|
|
|
33
33
|
aztecSlotDuration,
|
|
34
34
|
aztecProofSubmissionEpochs,
|
|
35
35
|
aztecTargetCommitteeSize,
|
|
36
|
-
|
|
36
|
+
lagInEpochsForValidatorSet,
|
|
37
|
+
lagInEpochsForRandao,
|
|
37
38
|
activationThreshold,
|
|
38
39
|
ejectionThreshold,
|
|
39
40
|
localEjectionThreshold,
|
|
@@ -59,7 +60,8 @@ export async function getL1ContractsConfig(
|
|
|
59
60
|
rollup.getSlotDuration(),
|
|
60
61
|
rollup.getProofSubmissionEpochs(),
|
|
61
62
|
rollup.getTargetCommitteeSize(),
|
|
62
|
-
rollup.
|
|
63
|
+
rollup.getLagInEpochsForValidatorSet(),
|
|
64
|
+
rollup.getLagInEpochsForRandao(),
|
|
63
65
|
rollup.getActivationThreshold(),
|
|
64
66
|
rollup.getEjectionThreshold(),
|
|
65
67
|
rollup.getLocalEjectionThreshold(),
|
|
@@ -87,7 +89,8 @@ export async function getL1ContractsConfig(
|
|
|
87
89
|
aztecSlotDuration: Number(aztecSlotDuration),
|
|
88
90
|
aztecProofSubmissionEpochs: Number(aztecProofSubmissionEpochs),
|
|
89
91
|
aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
|
|
90
|
-
|
|
92
|
+
lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
|
|
93
|
+
lagInEpochsForRandao: Number(lagInEpochsForRandao),
|
|
91
94
|
governanceProposerQuorum: Number(governanceProposerQuorum),
|
|
92
95
|
governanceProposerRoundSize: Number(governanceProposerRoundSize),
|
|
93
96
|
activationThreshold,
|