@aztec/ethereum 3.0.0-nightly.20251124 → 3.0.0-nightly.20251126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config.d.ts +6 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +13 -7
- package/dest/contracts/rollup.d.ts +25 -23
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +48 -41
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +4 -3
- package/dest/l1_artifacts.d.ts +1582 -763
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +1 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +5 -3
- package/dest/test/chain_monitor.d.ts +13 -13
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +28 -28
- package/dest/test/rollup_cheat_codes.d.ts +4 -4
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +18 -22
- package/package.json +5 -5
- package/src/config.ts +16 -8
- package/src/contracts/rollup.ts +50 -40
- package/src/deploy_l1_contracts.ts +4 -3
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +1 -2
- package/src/queries.ts +6 -3
- package/src/test/chain_monitor.ts +35 -35
- package/src/test/rollup_cheat_codes.ts +18 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;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AAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;IAQ1G;;OAEG;IACU,UAAU;IASvB,4CAA4C;IAC/B,oBAAoB;IAQjC;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM;IAMtE;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAWpD"}
|
|
@@ -43,25 +43,21 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
43
43
|
* Returns the pending and proven chain tips
|
|
44
44
|
* @returns The pending and proven chain tips
|
|
45
45
|
*/ async getTips() {
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
pending: res.pendingBlockNumber,
|
|
49
|
-
proven: res.provenBlockNumber
|
|
50
|
-
};
|
|
46
|
+
return await this.rollup.read.getTips();
|
|
51
47
|
}
|
|
52
48
|
/**
|
|
53
49
|
* Logs the current state of the rollup contract.
|
|
54
50
|
*/ async debugRollup() {
|
|
55
51
|
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
56
|
-
const pendingNum = await rollup.
|
|
57
|
-
const provenNum = await rollup.
|
|
52
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
53
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
58
54
|
const validators = await rollup.getAttesters();
|
|
59
55
|
const committee = await rollup.getCurrentEpochCommittee();
|
|
60
56
|
const archive = await rollup.archive();
|
|
61
57
|
const slot = await this.getSlot();
|
|
62
58
|
const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
|
|
63
|
-
this.logger.info(`Pending
|
|
64
|
-
this.logger.info(`Proven
|
|
59
|
+
this.logger.info(`Pending checkpoint num: ${pendingNum}`);
|
|
60
|
+
this.logger.info(`Proven checkpoint num: ${provenNum}`);
|
|
65
61
|
this.logger.info(`Validators: ${validators.map((v)=>v.toString()).join(', ')}`);
|
|
66
62
|
this.logger.info(`Committee: ${committee?.map((v)=>v.toString()).join(', ')}`);
|
|
67
63
|
this.logger.info(`Archive: ${archive}`);
|
|
@@ -144,36 +140,36 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
144
140
|
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|
|
145
141
|
}
|
|
146
142
|
/**
|
|
147
|
-
* Marks the specified
|
|
148
|
-
* @param
|
|
149
|
-
*/ markAsProven(
|
|
143
|
+
* Marks the specified checkpoint (or latest if none) as proven
|
|
144
|
+
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
145
|
+
*/ markAsProven(maybeCheckpointNumber) {
|
|
150
146
|
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
151
147
|
const tipsBefore = await this.getTips();
|
|
152
148
|
const { pending, proven } = tipsBefore;
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
155
|
-
|
|
149
|
+
let checkpointNumber = maybeCheckpointNumber;
|
|
150
|
+
if (checkpointNumber === undefined || checkpointNumber > pending) {
|
|
151
|
+
checkpointNumber = pending;
|
|
156
152
|
}
|
|
157
|
-
if (
|
|
158
|
-
this.logger.debug(`
|
|
153
|
+
if (checkpointNumber <= proven) {
|
|
154
|
+
this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
|
|
159
155
|
return;
|
|
160
156
|
}
|
|
161
157
|
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
162
158
|
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
163
|
-
const
|
|
159
|
+
const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
|
|
164
160
|
// Need to pack it as a single 32 byte word
|
|
165
|
-
const newValue = BigInt(tipsBefore.pending) << 128n | BigInt(
|
|
166
|
-
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address),
|
|
161
|
+
const newValue = BigInt(tipsBefore.pending) << 128n | BigInt(checkpointNumber);
|
|
162
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenCheckpointNumberSlot, newValue);
|
|
167
163
|
const tipsAfter = await this.getTips();
|
|
168
164
|
if (tipsAfter.pending < tipsAfter.proven) {
|
|
169
|
-
throw new Error('Overwrote pending tip to a
|
|
165
|
+
throw new Error('Overwrote pending tip to a checkpoint in the past');
|
|
170
166
|
}
|
|
171
167
|
this.logger.info(`Proven tip moved: ${tipsBefore.proven} -> ${tipsAfter.proven}. Pending tip: ${tipsAfter.pending}.`);
|
|
172
168
|
});
|
|
173
169
|
}
|
|
174
170
|
/**
|
|
175
171
|
* Overrides the inProgress field of the Inbox contract state
|
|
176
|
-
* @param howMuch - How many
|
|
172
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
177
173
|
*/ advanceInboxInProgress(howMuch) {
|
|
178
174
|
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
179
175
|
// Storage slot 2 contains the InboxState struct
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251126",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"../package.common.json"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
35
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
36
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
37
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
34
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251126",
|
|
35
|
+
"@aztec/constants": "3.0.0-nightly.20251126",
|
|
36
|
+
"@aztec/foundation": "3.0.0-nightly.20251126",
|
|
37
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251126",
|
|
38
38
|
"@viem/anvil": "^0.0.10",
|
|
39
39
|
"dotenv": "^16.0.3",
|
|
40
40
|
"lodash.chunk": "^4.2.0",
|
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,
|
|
@@ -200,14 +203,14 @@ const DefaultRewardConfig = {
|
|
|
200
203
|
sequencerBps: 8000,
|
|
201
204
|
rewardDistributor: EthAddress.ZERO.toString(),
|
|
202
205
|
booster: EthAddress.ZERO.toString(),
|
|
203
|
-
|
|
206
|
+
checkpointReward: 500n * 10n ** 18n,
|
|
204
207
|
};
|
|
205
208
|
|
|
206
209
|
const MainnetRewardConfig = {
|
|
207
210
|
sequencerBps: 7_000,
|
|
208
211
|
rewardDistributor: EthAddress.ZERO.toString(),
|
|
209
212
|
booster: EthAddress.ZERO.toString(),
|
|
210
|
-
|
|
213
|
+
checkpointReward: 400n * 10n ** 18n,
|
|
211
214
|
};
|
|
212
215
|
|
|
213
216
|
export const getRewardConfig = (networkName: NetworkNames) => {
|
|
@@ -321,10 +324,15 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
321
324
|
description: 'The target validator committee size.',
|
|
322
325
|
...numberConfigHelper(DefaultL1ContractsConfig.aztecTargetCommitteeSize),
|
|
323
326
|
},
|
|
324
|
-
|
|
325
|
-
env: '
|
|
327
|
+
lagInEpochsForValidatorSet: {
|
|
328
|
+
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
326
329
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
327
|
-
...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),
|
|
328
336
|
},
|
|
329
337
|
aztecProofSubmissionEpochs: {
|
|
330
338
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
package/src/contracts/rollup.ts
CHANGED
|
@@ -228,8 +228,13 @@ export class RollupContract {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
@memoize
|
|
231
|
-
|
|
232
|
-
return this.rollup.read.
|
|
231
|
+
getLagInEpochsForValidatorSet() {
|
|
232
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@memoize
|
|
236
|
+
getLagInEpochsForRandao() {
|
|
237
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
@memoize
|
|
@@ -332,16 +337,16 @@ export class RollupContract {
|
|
|
332
337
|
return await slasher.getProposer();
|
|
333
338
|
}
|
|
334
339
|
|
|
335
|
-
|
|
336
|
-
return this.rollup.read.
|
|
340
|
+
getCheckpointReward() {
|
|
341
|
+
return this.rollup.read.getCheckpointReward();
|
|
337
342
|
}
|
|
338
343
|
|
|
339
|
-
|
|
340
|
-
return this.rollup.read.
|
|
344
|
+
getCheckpointNumber() {
|
|
345
|
+
return this.rollup.read.getPendingCheckpointNumber();
|
|
341
346
|
}
|
|
342
347
|
|
|
343
|
-
|
|
344
|
-
return this.rollup.read.
|
|
348
|
+
getProvenCheckpointNumber() {
|
|
349
|
+
return this.rollup.read.getProvenCheckpointNumber();
|
|
345
350
|
}
|
|
346
351
|
|
|
347
352
|
getSlotNumber() {
|
|
@@ -426,8 +431,8 @@ export class RollupContract {
|
|
|
426
431
|
return result;
|
|
427
432
|
}
|
|
428
433
|
|
|
429
|
-
|
|
430
|
-
return this.rollup.read.
|
|
434
|
+
getCheckpoint(checkpointNumber: bigint | number) {
|
|
435
|
+
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
431
436
|
}
|
|
432
437
|
|
|
433
438
|
getTips() {
|
|
@@ -454,8 +459,8 @@ export class RollupContract {
|
|
|
454
459
|
return this.rollup.read.getCurrentEpoch();
|
|
455
460
|
}
|
|
456
461
|
|
|
457
|
-
|
|
458
|
-
return this.rollup.read.
|
|
462
|
+
getEpochNumberForCheckpoint(checkpointNumber: bigint) {
|
|
463
|
+
return this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]);
|
|
459
464
|
}
|
|
460
465
|
|
|
461
466
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -539,15 +544,16 @@ export class RollupContract {
|
|
|
539
544
|
* @dev Throws if unable to propose
|
|
540
545
|
*
|
|
541
546
|
* @param archive - The archive that we expect to be current state
|
|
542
|
-
* @return [slot,
|
|
547
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
548
|
+
* timestamp of the next L1 block
|
|
543
549
|
* @throws otherwise
|
|
544
550
|
*/
|
|
545
551
|
public async canProposeAtNextEthBlock(
|
|
546
552
|
archive: Buffer,
|
|
547
553
|
account: `0x${string}` | Account,
|
|
548
554
|
slotDuration: bigint | number,
|
|
549
|
-
opts: {
|
|
550
|
-
): Promise<{ slot: bigint;
|
|
555
|
+
opts: { forcePendingCheckpointNumber?: number } = {},
|
|
556
|
+
): Promise<{ slot: bigint; checkpointNumber: bigint; timeOfNextL1Slot: bigint }> {
|
|
551
557
|
if (typeof slotDuration === 'number') {
|
|
552
558
|
slotDuration = BigInt(slotDuration);
|
|
553
559
|
}
|
|
@@ -557,35 +563,37 @@ export class RollupContract {
|
|
|
557
563
|
|
|
558
564
|
try {
|
|
559
565
|
const {
|
|
560
|
-
result: [slot,
|
|
566
|
+
result: [slot, checkpointNumber],
|
|
561
567
|
} = await this.client.simulateContract({
|
|
562
568
|
address: this.address,
|
|
563
569
|
abi: RollupAbi,
|
|
564
570
|
functionName: 'canProposeAtTime',
|
|
565
571
|
args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
|
|
566
572
|
account,
|
|
567
|
-
stateOverride: await this.
|
|
573
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
568
574
|
});
|
|
569
575
|
|
|
570
|
-
return { slot,
|
|
576
|
+
return { slot, checkpointNumber, timeOfNextL1Slot };
|
|
571
577
|
} catch (err: unknown) {
|
|
572
578
|
throw formatViemError(err);
|
|
573
579
|
}
|
|
574
580
|
}
|
|
575
581
|
|
|
576
582
|
/**
|
|
577
|
-
* Returns a state override that sets the pending
|
|
578
|
-
* Requires querying the current state of the contract to get the current proven
|
|
583
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
584
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
579
585
|
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
580
586
|
*/
|
|
581
|
-
public async
|
|
582
|
-
|
|
587
|
+
public async makePendingCheckpointNumberOverride(
|
|
588
|
+
forcePendingCheckpointNumber: number | undefined,
|
|
589
|
+
): Promise<StateOverride> {
|
|
590
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
583
591
|
return [];
|
|
584
592
|
}
|
|
585
593
|
const slot = RollupContract.stfStorageSlot;
|
|
586
594
|
const currentValue = await this.client.getStorageAt({ address: this.address, slot });
|
|
587
|
-
const
|
|
588
|
-
const newValue = (BigInt(
|
|
595
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
|
|
596
|
+
const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
|
|
589
597
|
return [
|
|
590
598
|
{
|
|
591
599
|
address: this.address,
|
|
@@ -596,7 +604,7 @@ export class RollupContract {
|
|
|
596
604
|
|
|
597
605
|
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
598
606
|
public buildInvalidateBadAttestationRequest(
|
|
599
|
-
|
|
607
|
+
checkpointNumber: number,
|
|
600
608
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
601
609
|
committee: EthAddress[],
|
|
602
610
|
invalidIndex: number,
|
|
@@ -607,7 +615,7 @@ export class RollupContract {
|
|
|
607
615
|
abi: RollupAbi,
|
|
608
616
|
functionName: 'invalidateBadAttestation',
|
|
609
617
|
args: [
|
|
610
|
-
BigInt(
|
|
618
|
+
BigInt(checkpointNumber),
|
|
611
619
|
attestationsAndSigners,
|
|
612
620
|
committee.map(addr => addr.toString()),
|
|
613
621
|
BigInt(invalidIndex),
|
|
@@ -618,7 +626,7 @@ export class RollupContract {
|
|
|
618
626
|
|
|
619
627
|
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
620
628
|
public buildInvalidateInsufficientAttestationsRequest(
|
|
621
|
-
|
|
629
|
+
checkpointNumber: number,
|
|
622
630
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
623
631
|
committee: EthAddress[],
|
|
624
632
|
): L1TxRequest {
|
|
@@ -627,17 +635,17 @@ export class RollupContract {
|
|
|
627
635
|
data: encodeFunctionData({
|
|
628
636
|
abi: RollupAbi,
|
|
629
637
|
functionName: 'invalidateInsufficientAttestations',
|
|
630
|
-
args: [BigInt(
|
|
638
|
+
args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
|
|
631
639
|
}),
|
|
632
640
|
};
|
|
633
641
|
}
|
|
634
642
|
|
|
635
643
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
636
|
-
public getHasSubmittedProof(epochNumber: number,
|
|
644
|
+
public getHasSubmittedProof(epochNumber: number, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
637
645
|
if (prover instanceof EthAddress) {
|
|
638
646
|
prover = prover.toString();
|
|
639
647
|
}
|
|
640
|
-
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(
|
|
648
|
+
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
641
649
|
}
|
|
642
650
|
|
|
643
651
|
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
|
|
@@ -648,9 +656,9 @@ export class RollupContract {
|
|
|
648
656
|
return this.rollup.read.getSlotAt([timestamp]);
|
|
649
657
|
}
|
|
650
658
|
|
|
651
|
-
async status(
|
|
659
|
+
async status(checkpointNumber: bigint, options?: { blockNumber?: bigint }) {
|
|
652
660
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
653
|
-
return this.rollup.read.status([
|
|
661
|
+
return this.rollup.read.status([checkpointNumber], options);
|
|
654
662
|
}
|
|
655
663
|
|
|
656
664
|
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
@@ -662,8 +670,8 @@ export class RollupContract {
|
|
|
662
670
|
return this.rollup.read.archive();
|
|
663
671
|
}
|
|
664
672
|
|
|
665
|
-
archiveAt(
|
|
666
|
-
return this.rollup.read.archiveAt([
|
|
673
|
+
archiveAt(checkpointNumber: bigint) {
|
|
674
|
+
return this.rollup.read.archiveAt([checkpointNumber]);
|
|
667
675
|
}
|
|
668
676
|
|
|
669
677
|
getSequencerRewards(address: Hex | EthAddress) {
|
|
@@ -705,8 +713,8 @@ export class RollupContract {
|
|
|
705
713
|
return this.rollup.read.getStatus([address]);
|
|
706
714
|
}
|
|
707
715
|
|
|
708
|
-
getBlobCommitmentsHash(
|
|
709
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
716
|
+
getBlobCommitmentsHash(checkpointNumber: bigint) {
|
|
717
|
+
return this.rollup.read.getBlobCommitmentsHash([checkpointNumber]);
|
|
710
718
|
}
|
|
711
719
|
|
|
712
720
|
getCurrentBlobCommitmentsHash() {
|
|
@@ -761,15 +769,17 @@ export class RollupContract {
|
|
|
761
769
|
);
|
|
762
770
|
}
|
|
763
771
|
|
|
764
|
-
public
|
|
765
|
-
|
|
772
|
+
public listenToCheckpointInvalidated(
|
|
773
|
+
callback: (args: { checkpointNumber: bigint }) => unknown,
|
|
774
|
+
): WatchContractEventReturnType {
|
|
775
|
+
return this.rollup.watchEvent.CheckpointInvalidated(
|
|
766
776
|
{},
|
|
767
777
|
{
|
|
768
778
|
onLogs: logs => {
|
|
769
779
|
for (const log of logs) {
|
|
770
780
|
const args = log.args;
|
|
771
|
-
if (args.
|
|
772
|
-
callback({
|
|
781
|
+
if (args.checkpointNumber !== undefined) {
|
|
782
|
+
callback({ checkpointNumber: args.checkpointNumber });
|
|
773
783
|
}
|
|
774
784
|
}
|
|
775
785
|
},
|
|
@@ -487,9 +487,9 @@ export const deploySharedContracts = async (
|
|
|
487
487
|
const rewardDistributorAddress = await registry.getRewardDistributor();
|
|
488
488
|
|
|
489
489
|
if (!args.existingTokenAddress) {
|
|
490
|
-
const
|
|
490
|
+
const checkpointReward = getRewardConfig(networkName).checkpointReward;
|
|
491
491
|
|
|
492
|
-
const funding =
|
|
492
|
+
const funding = checkpointReward * 200000n;
|
|
493
493
|
const { txHash: fundRewardDistributorTxHash } = await deployer.sendTransaction({
|
|
494
494
|
to: feeAssetAddress.toString(),
|
|
495
495
|
data: encodeFunctionData({
|
|
@@ -863,7 +863,8 @@ export const deployRollup = async (
|
|
|
863
863
|
aztecSlotDuration: BigInt(args.aztecSlotDuration),
|
|
864
864
|
aztecEpochDuration: BigInt(args.aztecEpochDuration),
|
|
865
865
|
targetCommitteeSize: BigInt(args.aztecTargetCommitteeSize),
|
|
866
|
-
|
|
866
|
+
lagInEpochsForValidatorSet: BigInt(args.lagInEpochsForValidatorSet),
|
|
867
|
+
lagInEpochsForRandao: BigInt(args.lagInEpochsForRandao),
|
|
867
868
|
aztecProofSubmissionEpochs: BigInt(args.aztecProofSubmissionEpochs),
|
|
868
869
|
slashingQuorum: BigInt(args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1),
|
|
869
870
|
slashingRoundSize: BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration),
|
|
@@ -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);
|
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,
|
|
@@ -10,8 +10,8 @@ import type { ViemClient } from '../types.js';
|
|
|
10
10
|
|
|
11
11
|
export type ChainMonitorEventMap = {
|
|
12
12
|
'l1-block': [{ l1BlockNumber: number; timestamp: bigint }];
|
|
13
|
-
|
|
14
|
-
'
|
|
13
|
+
checkpoint: [{ checkpointNumber: number; l1BlockNumber: number; l2SlotNumber: number; timestamp: bigint }];
|
|
14
|
+
'checkpoint-proven': [{ provenCheckpointNumber: number; l1BlockNumber: number; timestamp: bigint }];
|
|
15
15
|
'l2-messages': [{ totalL2Messages: number; l1BlockNumber: number }];
|
|
16
16
|
'l2-epoch': [{ l2EpochNumber: number; timestamp: bigint; committee: EthAddress[] | undefined }];
|
|
17
17
|
'l2-slot': [{ l2SlotNumber: number; timestamp: bigint }];
|
|
@@ -27,14 +27,14 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
27
27
|
|
|
28
28
|
/** Current L1 block number */
|
|
29
29
|
public l1BlockNumber!: number;
|
|
30
|
-
/** Current
|
|
31
|
-
public
|
|
32
|
-
/** Current
|
|
33
|
-
public
|
|
34
|
-
/** L1 timestamp for the current
|
|
35
|
-
public
|
|
36
|
-
/** L1 timestamp for the proven
|
|
37
|
-
public
|
|
30
|
+
/** Current checkpoint number */
|
|
31
|
+
public checkpointNumber!: number;
|
|
32
|
+
/** Current proven checkpoint number */
|
|
33
|
+
public provenCheckpointNumber!: number;
|
|
34
|
+
/** L1 timestamp for the current checkpoint */
|
|
35
|
+
public checkpointTimestamp!: bigint;
|
|
36
|
+
/** L1 timestamp for the proven checkpoint */
|
|
37
|
+
public provenCheckpointTimestamp!: bigint;
|
|
38
38
|
/** Total number of L2 messages pushed into the Inbox */
|
|
39
39
|
public totalL2Messages: number = 0;
|
|
40
40
|
/** Current L2 epoch number */
|
|
@@ -114,28 +114,28 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
114
114
|
this.emit('l1-block', { l1BlockNumber: newL1BlockNumber, timestamp });
|
|
115
115
|
let msg = `L1 block ${newL1BlockNumber} mined at ${timestampString}`;
|
|
116
116
|
|
|
117
|
-
const
|
|
118
|
-
if (this.
|
|
119
|
-
const epochNumber = await this.rollup.
|
|
120
|
-
msg += ` with new
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.emit('
|
|
124
|
-
|
|
117
|
+
const newCheckpointNumber = Number(await this.rollup.getCheckpointNumber());
|
|
118
|
+
if (this.checkpointNumber !== newCheckpointNumber) {
|
|
119
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(BigInt(newCheckpointNumber));
|
|
120
|
+
msg += ` with new checkpoint ${newCheckpointNumber} for epoch ${epochNumber}`;
|
|
121
|
+
this.checkpointNumber = newCheckpointNumber;
|
|
122
|
+
this.checkpointTimestamp = timestamp;
|
|
123
|
+
this.emit('checkpoint', {
|
|
124
|
+
checkpointNumber: newCheckpointNumber,
|
|
125
125
|
l1BlockNumber: newL1BlockNumber,
|
|
126
126
|
l2SlotNumber: Number(l2SlotNumber),
|
|
127
127
|
timestamp,
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const
|
|
132
|
-
if (this.
|
|
133
|
-
const epochNumber = await this.rollup.
|
|
134
|
-
msg += ` with proof up to
|
|
135
|
-
this.
|
|
136
|
-
this.
|
|
137
|
-
this.emit('
|
|
138
|
-
|
|
131
|
+
const newProvenCheckpointNumber = Number(await this.rollup.getProvenCheckpointNumber());
|
|
132
|
+
if (this.provenCheckpointNumber !== newProvenCheckpointNumber) {
|
|
133
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(BigInt(newProvenCheckpointNumber));
|
|
134
|
+
msg += ` with proof up to checkpoint ${newProvenCheckpointNumber} for epoch ${epochNumber}`;
|
|
135
|
+
this.provenCheckpointNumber = newProvenCheckpointNumber;
|
|
136
|
+
this.provenCheckpointTimestamp = timestamp;
|
|
137
|
+
this.emit('checkpoint-proven', {
|
|
138
|
+
provenCheckpointNumber: newProvenCheckpointNumber,
|
|
139
139
|
l1BlockNumber: newL1BlockNumber,
|
|
140
140
|
timestamp,
|
|
141
141
|
});
|
|
@@ -168,8 +168,8 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
168
168
|
l1BlockNumber: this.l1BlockNumber,
|
|
169
169
|
l2SlotNumber,
|
|
170
170
|
l2Epoch,
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
checkpointNumber: this.checkpointNumber,
|
|
172
|
+
provenCheckpointNumber: this.provenCheckpointNumber,
|
|
173
173
|
totalL2Messages: this.totalL2Messages,
|
|
174
174
|
committee,
|
|
175
175
|
});
|
|
@@ -225,19 +225,19 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
public
|
|
229
|
-
const targetBlock = typeof
|
|
230
|
-
if (this.
|
|
228
|
+
public waitUntilCheckpoint(checkpointNumber: number | bigint): Promise<void> {
|
|
229
|
+
const targetBlock = typeof checkpointNumber === 'bigint' ? checkpointNumber.valueOf() : checkpointNumber;
|
|
230
|
+
if (this.checkpointNumber >= targetBlock) {
|
|
231
231
|
return Promise.resolve();
|
|
232
232
|
}
|
|
233
233
|
return new Promise(resolve => {
|
|
234
|
-
const listener = (data: {
|
|
235
|
-
if (data.
|
|
236
|
-
this.off('
|
|
234
|
+
const listener = (data: { checkpointNumber: number; timestamp: bigint }) => {
|
|
235
|
+
if (data.checkpointNumber >= targetBlock) {
|
|
236
|
+
this.off('checkpoint', listener);
|
|
237
237
|
resolve();
|
|
238
238
|
}
|
|
239
239
|
};
|
|
240
|
-
this.on('
|
|
240
|
+
this.on('checkpoint', listener);
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
}
|