@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec
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/client.js +6 -2
- package/dest/config.d.ts +11 -44
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +20 -332
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +7 -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 +6 -4
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +17 -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 +6 -4
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +17 -2
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +7 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +4 -0
- 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 +71 -64
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +90 -67
- package/dest/contracts/slasher_contract.d.ts +1 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts +9 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +4 -4
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +247 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +336 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +2078 -880
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +3 -3
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +3 -3
- package/dest/l1_reader.d.ts +3 -1
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +6 -0
- package/dest/l1_tx_utils/config.d.ts +5 -5
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +30 -7
- package/dest/l1_tx_utils/constants.d.ts +7 -1
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +25 -0
- package/dest/l1_tx_utils/factory.d.ts +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +9 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +11 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +18 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +111 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +32 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +173 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +64 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +24 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +3 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +2 -0
- package/dest/l1_tx_utils/interfaces.d.ts +2 -2
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -2
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +17 -4
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +1 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -26
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +70 -141
- 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 +10 -3
- package/dest/test/chain_monitor.d.ts +27 -24
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +32 -34
- package/dest/test/delayed_tx_utils.d.ts +1 -1
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.d.ts +8 -12
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +11 -3
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +14 -13
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +46 -39
- package/dest/test/start_anvil.d.ts +4 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +4 -3
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +15 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +18 -0
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +33 -14
- package/src/client.ts +2 -2
- package/src/config.ts +24 -412
- package/src/contracts/empire_base.ts +6 -5
- package/src/contracts/empire_slashing_proposer.ts +16 -5
- package/src/contracts/governance_proposer.ts +16 -5
- package/src/contracts/inbox.ts +7 -2
- package/src/contracts/rollup.ts +99 -82
- package/src/contracts/tally_slashing_proposer.ts +11 -8
- package/src/deploy_aztec_l1_contracts.ts +557 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_contract_addresses.ts +22 -20
- package/src/l1_reader.ts +8 -0
- package/src/l1_tx_utils/config.ts +32 -11
- package/src/l1_tx_utils/constants.ts +11 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +159 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +241 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +88 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +2 -0
- package/src/l1_tx_utils/interfaces.ts +1 -1
- package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +24 -4
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +78 -179
- package/src/queries.ts +12 -3
- package/src/test/chain_monitor.ts +50 -48
- package/src/test/eth_cheat_codes.ts +9 -3
- package/src/test/rollup_cheat_codes.ts +45 -43
- package/src/test/start_anvil.ts +4 -0
- package/src/test/tx_delayer.ts +5 -3
- package/src/types.ts +62 -0
- package/src/utils.ts +30 -1
- package/dest/deploy_l1_contracts.d.ts +0 -226
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1473
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/src/deploy_l1_contracts.ts +0 -1849
- package/src/index.ts +0 -17
package/src/contracts/rollup.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { memoize } from '@aztec/foundation/decorators';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import type { ViemSignature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
5
7
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
6
8
|
|
|
@@ -18,7 +20,7 @@ import {
|
|
|
18
20
|
} from 'viem';
|
|
19
21
|
|
|
20
22
|
import { getPublicClient } from '../client.js';
|
|
21
|
-
import type {
|
|
23
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
22
24
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
23
25
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
24
26
|
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
@@ -61,6 +63,7 @@ export type EpochProofPublicInputArgs = {
|
|
|
61
63
|
|
|
62
64
|
export type ViemHeader = {
|
|
63
65
|
lastArchiveRoot: `0x${string}`;
|
|
66
|
+
blockHeadersHash: `0x${string}`;
|
|
64
67
|
contentCommitment: ViemContentCommitment;
|
|
65
68
|
slotNumber: bigint;
|
|
66
69
|
timestamp: bigint;
|
|
@@ -81,22 +84,6 @@ export type ViemGasFees = {
|
|
|
81
84
|
feePerL2Gas: bigint;
|
|
82
85
|
};
|
|
83
86
|
|
|
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
87
|
export enum SlashingProposerType {
|
|
101
88
|
None = 0,
|
|
102
89
|
Tally = 1,
|
|
@@ -120,7 +107,7 @@ export class RollupContract {
|
|
|
120
107
|
return (RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8')));
|
|
121
108
|
}
|
|
122
109
|
|
|
123
|
-
static getFromL1ContractsValues(deployL1ContractsValues:
|
|
110
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
124
111
|
const {
|
|
125
112
|
l1Client,
|
|
126
113
|
l1ContractAddresses: { rollupAddress },
|
|
@@ -207,8 +194,8 @@ export class RollupContract {
|
|
|
207
194
|
}
|
|
208
195
|
|
|
209
196
|
@memoize
|
|
210
|
-
getSlotDuration() {
|
|
211
|
-
return this.rollup.read.getSlotDuration();
|
|
197
|
+
async getSlotDuration(): Promise<number> {
|
|
198
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
212
199
|
}
|
|
213
200
|
|
|
214
201
|
@memoize
|
|
@@ -227,8 +214,13 @@ export class RollupContract {
|
|
|
227
214
|
}
|
|
228
215
|
|
|
229
216
|
@memoize
|
|
230
|
-
|
|
231
|
-
return this.rollup.read.
|
|
217
|
+
getLagInEpochsForValidatorSet() {
|
|
218
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@memoize
|
|
222
|
+
getLagInEpochsForRandao() {
|
|
223
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
232
224
|
}
|
|
233
225
|
|
|
234
226
|
@memoize
|
|
@@ -294,7 +286,7 @@ export class RollupContract {
|
|
|
294
286
|
return {
|
|
295
287
|
l1StartBlock,
|
|
296
288
|
l1GenesisTime,
|
|
297
|
-
slotDuration
|
|
289
|
+
slotDuration,
|
|
298
290
|
epochDuration: Number(epochDuration),
|
|
299
291
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
300
292
|
};
|
|
@@ -331,20 +323,20 @@ export class RollupContract {
|
|
|
331
323
|
return await slasher.getProposer();
|
|
332
324
|
}
|
|
333
325
|
|
|
334
|
-
|
|
335
|
-
return this.rollup.read.
|
|
326
|
+
getCheckpointReward() {
|
|
327
|
+
return this.rollup.read.getCheckpointReward();
|
|
336
328
|
}
|
|
337
329
|
|
|
338
|
-
|
|
339
|
-
return this.rollup.read.
|
|
330
|
+
async getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
331
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
|
|
340
332
|
}
|
|
341
333
|
|
|
342
|
-
|
|
343
|
-
return this.rollup.read.
|
|
334
|
+
async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
335
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
|
|
344
336
|
}
|
|
345
337
|
|
|
346
|
-
getSlotNumber() {
|
|
347
|
-
return this.rollup.read.getCurrentSlot();
|
|
338
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
339
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
348
340
|
}
|
|
349
341
|
|
|
350
342
|
getL1FeesAt(timestamp: bigint) {
|
|
@@ -381,8 +373,8 @@ export class RollupContract {
|
|
|
381
373
|
return this.rollup.read.getCurrentSampleSeed();
|
|
382
374
|
}
|
|
383
375
|
|
|
384
|
-
getCurrentEpoch() {
|
|
385
|
-
return this.rollup.read.getCurrentEpoch();
|
|
376
|
+
async getCurrentEpoch(): Promise<EpochNumber> {
|
|
377
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
386
378
|
}
|
|
387
379
|
|
|
388
380
|
async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
|
|
@@ -425,16 +417,35 @@ export class RollupContract {
|
|
|
425
417
|
return result;
|
|
426
418
|
}
|
|
427
419
|
|
|
428
|
-
|
|
429
|
-
return this.rollup.read.
|
|
420
|
+
getCheckpoint(checkpointNumber: CheckpointNumber) {
|
|
421
|
+
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
430
422
|
}
|
|
431
423
|
|
|
432
|
-
|
|
433
|
-
|
|
424
|
+
/** Returns the pending checkpoint from the rollup contract */
|
|
425
|
+
getPendingCheckpoint() {
|
|
426
|
+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
427
|
+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
|
|
428
|
+
return retry(
|
|
429
|
+
async () => {
|
|
430
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber();
|
|
431
|
+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
|
|
432
|
+
return pendingCheckpoint;
|
|
433
|
+
},
|
|
434
|
+
'getting pending checkpoint',
|
|
435
|
+
makeBackoff([0.5, 0.5, 0.5]),
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
|
|
440
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
441
|
+
return {
|
|
442
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
443
|
+
proven: CheckpointNumber.fromBigInt(proven),
|
|
444
|
+
};
|
|
434
445
|
}
|
|
435
446
|
|
|
436
|
-
getTimestampForSlot(slot:
|
|
437
|
-
return this.rollup.read.getTimestampForSlot([slot]);
|
|
447
|
+
getTimestampForSlot(slot: SlotNumber) {
|
|
448
|
+
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
438
449
|
}
|
|
439
450
|
|
|
440
451
|
getEntryQueueLength() {
|
|
@@ -445,16 +456,16 @@ export class RollupContract {
|
|
|
445
456
|
return this.rollup.read.getAvailableValidatorFlushes();
|
|
446
457
|
}
|
|
447
458
|
|
|
448
|
-
getNextFlushableEpoch() {
|
|
449
|
-
return this.rollup.read.getNextFlushableEpoch();
|
|
459
|
+
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
460
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
450
461
|
}
|
|
451
462
|
|
|
452
|
-
getCurrentEpochNumber(): Promise<
|
|
453
|
-
return this.rollup.read.getCurrentEpoch();
|
|
463
|
+
async getCurrentEpochNumber(): Promise<EpochNumber> {
|
|
464
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
454
465
|
}
|
|
455
466
|
|
|
456
|
-
|
|
457
|
-
return this.rollup.read.
|
|
467
|
+
async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
|
|
468
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
|
|
458
469
|
}
|
|
459
470
|
|
|
460
471
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -494,8 +505,8 @@ export class RollupContract {
|
|
|
494
505
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
495
506
|
}
|
|
496
507
|
|
|
497
|
-
public async getEpochNumberForSlotNumber(slotNumber:
|
|
498
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
508
|
+
public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
|
|
509
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
499
510
|
}
|
|
500
511
|
|
|
501
512
|
getEpochProofPublicInputs(
|
|
@@ -538,53 +549,57 @@ export class RollupContract {
|
|
|
538
549
|
* @dev Throws if unable to propose
|
|
539
550
|
*
|
|
540
551
|
* @param archive - The archive that we expect to be current state
|
|
541
|
-
* @return [slot,
|
|
552
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
553
|
+
* timestamp of the next L1 block
|
|
542
554
|
* @throws otherwise
|
|
543
555
|
*/
|
|
544
556
|
public async canProposeAtNextEthBlock(
|
|
545
557
|
archive: Buffer,
|
|
546
558
|
account: `0x${string}` | Account,
|
|
547
|
-
slotDuration:
|
|
548
|
-
opts: {
|
|
549
|
-
): Promise<{ slot:
|
|
550
|
-
if (typeof slotDuration === 'number') {
|
|
551
|
-
slotDuration = BigInt(slotDuration);
|
|
552
|
-
}
|
|
559
|
+
slotDuration: number,
|
|
560
|
+
opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
|
|
561
|
+
): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
|
|
553
562
|
const latestBlock = await this.client.getBlock();
|
|
554
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
563
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
555
564
|
const who = typeof account === 'string' ? account : account.address;
|
|
556
565
|
|
|
557
566
|
try {
|
|
558
567
|
const {
|
|
559
|
-
result: [slot,
|
|
568
|
+
result: [slot, checkpointNumber],
|
|
560
569
|
} = await this.client.simulateContract({
|
|
561
570
|
address: this.address,
|
|
562
571
|
abi: RollupAbi,
|
|
563
572
|
functionName: 'canProposeAtTime',
|
|
564
573
|
args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
|
|
565
574
|
account,
|
|
566
|
-
stateOverride: await this.
|
|
575
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
567
576
|
});
|
|
568
577
|
|
|
569
|
-
return {
|
|
578
|
+
return {
|
|
579
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
580
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
581
|
+
timeOfNextL1Slot,
|
|
582
|
+
};
|
|
570
583
|
} catch (err: unknown) {
|
|
571
584
|
throw formatViemError(err);
|
|
572
585
|
}
|
|
573
586
|
}
|
|
574
587
|
|
|
575
588
|
/**
|
|
576
|
-
* Returns a state override that sets the pending
|
|
577
|
-
* Requires querying the current state of the contract to get the current proven
|
|
589
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
590
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
578
591
|
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
579
592
|
*/
|
|
580
|
-
public async
|
|
581
|
-
|
|
593
|
+
public async makePendingCheckpointNumberOverride(
|
|
594
|
+
forcePendingCheckpointNumber: CheckpointNumber | undefined,
|
|
595
|
+
): Promise<StateOverride> {
|
|
596
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
582
597
|
return [];
|
|
583
598
|
}
|
|
584
599
|
const slot = RollupContract.stfStorageSlot;
|
|
585
600
|
const currentValue = await this.client.getStorageAt({ address: this.address, slot });
|
|
586
|
-
const
|
|
587
|
-
const newValue = (BigInt(
|
|
601
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
|
|
602
|
+
const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
|
|
588
603
|
return [
|
|
589
604
|
{
|
|
590
605
|
address: this.address,
|
|
@@ -595,7 +610,7 @@ export class RollupContract {
|
|
|
595
610
|
|
|
596
611
|
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
597
612
|
public buildInvalidateBadAttestationRequest(
|
|
598
|
-
|
|
613
|
+
checkpointNumber: CheckpointNumber,
|
|
599
614
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
600
615
|
committee: EthAddress[],
|
|
601
616
|
invalidIndex: number,
|
|
@@ -606,7 +621,7 @@ export class RollupContract {
|
|
|
606
621
|
abi: RollupAbi,
|
|
607
622
|
functionName: 'invalidateBadAttestation',
|
|
608
623
|
args: [
|
|
609
|
-
BigInt(
|
|
624
|
+
BigInt(checkpointNumber),
|
|
610
625
|
attestationsAndSigners,
|
|
611
626
|
committee.map(addr => addr.toString()),
|
|
612
627
|
BigInt(invalidIndex),
|
|
@@ -617,7 +632,7 @@ export class RollupContract {
|
|
|
617
632
|
|
|
618
633
|
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
619
634
|
public buildInvalidateInsufficientAttestationsRequest(
|
|
620
|
-
|
|
635
|
+
checkpointNumber: CheckpointNumber,
|
|
621
636
|
attestationsAndSigners: ViemCommitteeAttestations,
|
|
622
637
|
committee: EthAddress[],
|
|
623
638
|
): L1TxRequest {
|
|
@@ -626,30 +641,30 @@ export class RollupContract {
|
|
|
626
641
|
data: encodeFunctionData({
|
|
627
642
|
abi: RollupAbi,
|
|
628
643
|
functionName: 'invalidateInsufficientAttestations',
|
|
629
|
-
args: [BigInt(
|
|
644
|
+
args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
|
|
630
645
|
}),
|
|
631
646
|
};
|
|
632
647
|
}
|
|
633
648
|
|
|
634
649
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
635
|
-
public getHasSubmittedProof(epochNumber:
|
|
650
|
+
public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
636
651
|
if (prover instanceof EthAddress) {
|
|
637
652
|
prover = prover.toString();
|
|
638
653
|
}
|
|
639
|
-
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(
|
|
654
|
+
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
640
655
|
}
|
|
641
656
|
|
|
642
657
|
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
|
|
643
658
|
return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
|
|
644
659
|
}
|
|
645
660
|
|
|
646
|
-
getSlotAt(timestamp: bigint) {
|
|
647
|
-
return this.rollup.read.getSlotAt([timestamp]);
|
|
661
|
+
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
662
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
648
663
|
}
|
|
649
664
|
|
|
650
|
-
async status(
|
|
665
|
+
async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
|
|
651
666
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
652
|
-
return this.rollup.read.status([
|
|
667
|
+
return this.rollup.read.status([BigInt(checkpointNumber)], options);
|
|
653
668
|
}
|
|
654
669
|
|
|
655
670
|
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
@@ -661,8 +676,8 @@ export class RollupContract {
|
|
|
661
676
|
return this.rollup.read.archive();
|
|
662
677
|
}
|
|
663
678
|
|
|
664
|
-
archiveAt(
|
|
665
|
-
return this.rollup.read.archiveAt([
|
|
679
|
+
archiveAt(checkpointNumber: CheckpointNumber) {
|
|
680
|
+
return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
|
|
666
681
|
}
|
|
667
682
|
|
|
668
683
|
getSequencerRewards(address: Hex | EthAddress) {
|
|
@@ -704,8 +719,8 @@ export class RollupContract {
|
|
|
704
719
|
return this.rollup.read.getStatus([address]);
|
|
705
720
|
}
|
|
706
721
|
|
|
707
|
-
getBlobCommitmentsHash(
|
|
708
|
-
return this.rollup.read.getBlobCommitmentsHash([
|
|
722
|
+
getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
|
|
723
|
+
return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
|
|
709
724
|
}
|
|
710
725
|
|
|
711
726
|
getCurrentBlobCommitmentsHash() {
|
|
@@ -760,15 +775,17 @@ export class RollupContract {
|
|
|
760
775
|
);
|
|
761
776
|
}
|
|
762
777
|
|
|
763
|
-
public
|
|
764
|
-
|
|
778
|
+
public listenToCheckpointInvalidated(
|
|
779
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
780
|
+
): WatchContractEventReturnType {
|
|
781
|
+
return this.rollup.watchEvent.CheckpointInvalidated(
|
|
765
782
|
{},
|
|
766
783
|
{
|
|
767
784
|
onLogs: logs => {
|
|
768
785
|
for (const log of logs) {
|
|
769
786
|
const args = log.args;
|
|
770
|
-
if (args.
|
|
771
|
-
callback({
|
|
787
|
+
if (args.checkpointNumber !== undefined) {
|
|
788
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
|
|
772
789
|
}
|
|
773
790
|
}
|
|
774
791
|
},
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
|
|
2
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { tryExtractEvent } from '@aztec/ethereum/utils';
|
|
4
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
5
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -97,8 +100,8 @@ export class TallySlashingProposerContract {
|
|
|
97
100
|
* @param slot - The slot number to check at
|
|
98
101
|
* @returns Whether the round is ready to execute
|
|
99
102
|
*/
|
|
100
|
-
public async isRoundReadyToExecute(round: bigint, slot:
|
|
101
|
-
return await this.contract.read.isRoundReadyToExecute([round, slot]);
|
|
103
|
+
public async isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean> {
|
|
104
|
+
return await this.contract.read.isRoundReadyToExecute([round, BigInt(slot)]);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/** Returns the slash actions and payload address for a given round (zero if no slash actions) */
|
|
@@ -149,7 +152,7 @@ export class TallySlashingProposerContract {
|
|
|
149
152
|
*/
|
|
150
153
|
public async buildVoteRequestFromSigner(
|
|
151
154
|
votes: Hex,
|
|
152
|
-
slot:
|
|
155
|
+
slot: SlotNumber,
|
|
153
156
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
154
157
|
): Promise<L1TxRequest> {
|
|
155
158
|
const typedData = this.buildVoteTypedData(votes, slot);
|
|
@@ -166,7 +169,7 @@ export class TallySlashingProposerContract {
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
/** Returns the typed data definition to EIP712-sign for voting */
|
|
169
|
-
public buildVoteTypedData(votes: Hex, slot:
|
|
172
|
+
public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
|
|
170
173
|
const domain = {
|
|
171
174
|
name: 'TallySlashingProposer',
|
|
172
175
|
version: '1',
|
|
@@ -187,12 +190,12 @@ export class TallySlashingProposerContract {
|
|
|
187
190
|
],
|
|
188
191
|
};
|
|
189
192
|
|
|
190
|
-
return { domain, types, primaryType: 'Vote', message: { votes, slot } };
|
|
193
|
+
return { domain, types, primaryType: 'Vote', message: { votes, slot: BigInt(slot) } };
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
/** 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]));
|
|
197
|
+
public async getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32> {
|
|
198
|
+
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, BigInt(slot)]));
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
/**
|