@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +21 -3
- package/dest/config.d.ts +71 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +138 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +25 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/empire_slashing_proposer.d.ts +67 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +209 -0
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +19 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +57 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +43 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +87 -84
- package/dest/contracts/governance_proposer.d.ts +17 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +46 -17
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +26 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +45 -0
- package/dest/contracts/index.d.ts +9 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +8 -2
- package/dest/contracts/multicall.d.ts +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +156 -0
- package/dest/contracts/registry.d.ts +10 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +44 -16
- package/dest/contracts/rollup.d.ts +221 -41
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +549 -81
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +140 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +313 -0
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +245 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +335 -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 +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- 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 +77364 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +166 -0
- package/dest/l1_contract_addresses.d.ts +24 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +25 -21
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +14 -8
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +96 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- 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 +12 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +12 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- 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 +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +87 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +360 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +15 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +4 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +53 -12
- package/dest/test/chain_monitor.d.ts +75 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +214 -0
- package/dest/test/delayed_tx_utils.d.ts +8 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +13 -6
- package/dest/test/eth_cheat_codes.d.ts +217 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +560 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -0
- package/dest/test/rollup_cheat_codes.d.ts +87 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +275 -0
- package/dest/test/start_anvil.d.ts +9 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -7
- package/dest/test/tx_delayer.d.ts +18 -7
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +97 -20
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +61 -88
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +50 -23
- package/src/account.ts +5 -0
- package/src/client.ts +43 -5
- package/src/config.ts +188 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +270 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +63 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +80 -77
- package/src/contracts/governance_proposer.ts +71 -24
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +8 -2
- package/src/contracts/multicall.ts +155 -0
- package/src/contracts/registry.ts +51 -26
- package/src/contracts/rollup.ts +624 -78
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +318 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +556 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +49 -34
- package/src/l1_reader.ts +17 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +161 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -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 +14 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +458 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +106 -0
- package/src/queries.ts +73 -15
- package/src/test/chain_monitor.ts +245 -0
- package/src/test/delayed_tx_utils.ts +34 -6
- package/src/test/eth_cheat_codes.ts +588 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -0
- package/src/test/rollup_cheat_codes.ts +312 -0
- package/src/test/start_anvil.ts +24 -5
- package/src/test/tx_delayer.ts +130 -27
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +79 -91
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/contracts/slashing_proposer.d.ts +0 -21
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.js +0 -47
- package/dest/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
package/src/contracts/rollup.ts
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
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';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
5
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
6
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
7
|
+
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
8
|
+
|
|
9
|
+
import chunk from 'lodash.chunk';
|
|
10
|
+
import {
|
|
11
|
+
type Account,
|
|
12
|
+
type GetContractReturnType,
|
|
13
|
+
type Hex,
|
|
14
|
+
type StateOverride,
|
|
15
|
+
type WatchContractEventReturnType,
|
|
16
|
+
encodeFunctionData,
|
|
17
|
+
getContract,
|
|
18
|
+
hexToBigInt,
|
|
19
|
+
keccak256,
|
|
20
|
+
} from 'viem';
|
|
7
21
|
|
|
8
22
|
import { getPublicClient } from '../client.js';
|
|
9
|
-
import type {
|
|
23
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
10
24
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
11
25
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
12
|
-
import type {
|
|
26
|
+
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
27
|
+
import type { ViemClient } from '../types.js';
|
|
13
28
|
import { formatViemError } from '../utils.js';
|
|
14
|
-
import {
|
|
29
|
+
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
30
|
+
import { GSEContract } from './gse.js';
|
|
31
|
+
import { SlasherContract } from './slasher_contract.js';
|
|
32
|
+
import { TallySlashingProposerContract } from './tally_slashing_proposer.js';
|
|
33
|
+
import { checkBlockTag } from './utils.js';
|
|
34
|
+
|
|
35
|
+
export type ViemCommitteeAttestation = {
|
|
36
|
+
addr: `0x${string}`;
|
|
37
|
+
signature: ViemSignature;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type ViemCommitteeAttestations = {
|
|
41
|
+
signatureIndices: `0x${string}`;
|
|
42
|
+
signaturesOrAddresses: `0x${string}`;
|
|
43
|
+
};
|
|
15
44
|
|
|
16
45
|
export type L1RollupContractAddresses = Pick<
|
|
17
46
|
L1ContractAddresses,
|
|
@@ -23,20 +52,48 @@ export type L1RollupContractAddresses = Pick<
|
|
|
23
52
|
| 'stakingAssetAddress'
|
|
24
53
|
| 'rewardDistributorAddress'
|
|
25
54
|
| 'slashFactoryAddress'
|
|
55
|
+
| 'gseAddress'
|
|
26
56
|
>;
|
|
27
57
|
|
|
28
58
|
export type EpochProofPublicInputArgs = {
|
|
29
59
|
previousArchive: `0x${string}`;
|
|
30
60
|
endArchive: `0x${string}`;
|
|
31
|
-
previousBlockHash: `0x${string}`;
|
|
32
|
-
endBlockHash: `0x${string}`;
|
|
33
|
-
endTimestamp: bigint;
|
|
34
|
-
outHash: `0x${string}`;
|
|
35
61
|
proverId: `0x${string}`;
|
|
36
62
|
};
|
|
37
63
|
|
|
64
|
+
export type ViemHeader = {
|
|
65
|
+
lastArchiveRoot: `0x${string}`;
|
|
66
|
+
blockHeadersHash: `0x${string}`;
|
|
67
|
+
contentCommitment: ViemContentCommitment;
|
|
68
|
+
slotNumber: bigint;
|
|
69
|
+
timestamp: bigint;
|
|
70
|
+
coinbase: `0x${string}`;
|
|
71
|
+
feeRecipient: `0x${string}`;
|
|
72
|
+
gasFees: ViemGasFees;
|
|
73
|
+
totalManaUsed: bigint;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type ViemContentCommitment = {
|
|
77
|
+
blobsHash: `0x${string}`;
|
|
78
|
+
inHash: `0x${string}`;
|
|
79
|
+
outHash: `0x${string}`;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type ViemGasFees = {
|
|
83
|
+
feePerDaGas: bigint;
|
|
84
|
+
feePerL2Gas: bigint;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export enum SlashingProposerType {
|
|
88
|
+
None = 0,
|
|
89
|
+
Tally = 1,
|
|
90
|
+
Empire = 2,
|
|
91
|
+
}
|
|
92
|
+
|
|
38
93
|
export class RollupContract {
|
|
39
|
-
private readonly rollup: GetContractReturnType<typeof RollupAbi,
|
|
94
|
+
private readonly rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
95
|
+
|
|
96
|
+
private static cachedStfStorageSlot: Hex | undefined;
|
|
40
97
|
|
|
41
98
|
static get checkBlobStorageSlot(): bigint {
|
|
42
99
|
const asString = RollupStorage.find(storage => storage.label === 'checkBlob')?.slot;
|
|
@@ -46,12 +103,16 @@ export class RollupContract {
|
|
|
46
103
|
return BigInt(asString);
|
|
47
104
|
}
|
|
48
105
|
|
|
49
|
-
static
|
|
106
|
+
static get stfStorageSlot(): Hex {
|
|
107
|
+
return (RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8')));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
50
111
|
const {
|
|
51
|
-
|
|
112
|
+
l1Client,
|
|
52
113
|
l1ContractAddresses: { rollupAddress },
|
|
53
114
|
} = deployL1ContractsValues;
|
|
54
|
-
return new RollupContract(
|
|
115
|
+
return new RollupContract(l1Client, rollupAddress.toString());
|
|
55
116
|
}
|
|
56
117
|
|
|
57
118
|
static getFromConfig(config: L1ReaderConfig) {
|
|
@@ -60,23 +121,56 @@ export class RollupContract {
|
|
|
60
121
|
return new RollupContract(client, address);
|
|
61
122
|
}
|
|
62
123
|
|
|
63
|
-
constructor(
|
|
124
|
+
constructor(
|
|
125
|
+
public readonly client: ViemClient,
|
|
126
|
+
address: Hex | EthAddress,
|
|
127
|
+
) {
|
|
64
128
|
if (address instanceof EthAddress) {
|
|
65
129
|
address = address.toString();
|
|
66
130
|
}
|
|
67
131
|
this.rollup = getContract({ address, abi: RollupAbi, client });
|
|
68
132
|
}
|
|
69
133
|
|
|
134
|
+
getGSE() {
|
|
135
|
+
return this.rollup.read.getGSE();
|
|
136
|
+
}
|
|
137
|
+
|
|
70
138
|
public get address() {
|
|
71
139
|
return this.rollup.address;
|
|
72
140
|
}
|
|
73
141
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
142
|
+
getContract(): GetContractReturnType<typeof RollupAbi, ViemClient> {
|
|
143
|
+
return this.rollup;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public async getSlashingProposer(): Promise<
|
|
147
|
+
EmpireSlashingProposerContract | TallySlashingProposerContract | undefined
|
|
148
|
+
> {
|
|
149
|
+
const slasher = await this.getSlasherContract();
|
|
150
|
+
if (!slasher) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const proposerAddress = await slasher.getProposer();
|
|
155
|
+
const proposerAbi = [
|
|
156
|
+
{
|
|
157
|
+
type: 'function',
|
|
158
|
+
name: 'SLASHING_PROPOSER_TYPE',
|
|
159
|
+
inputs: [],
|
|
160
|
+
outputs: [{ name: '', type: 'uint8', internalType: 'enum SlasherFlavor' }],
|
|
161
|
+
stateMutability: 'view',
|
|
162
|
+
},
|
|
163
|
+
] as const;
|
|
164
|
+
|
|
165
|
+
const proposer = getContract({ address: proposerAddress.toString(), abi: proposerAbi, client: this.client });
|
|
166
|
+
const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
|
|
167
|
+
if (proposerType === SlashingProposerType.Tally.valueOf()) {
|
|
168
|
+
return new TallySlashingProposerContract(this.client, proposerAddress);
|
|
169
|
+
} else if (proposerType === SlashingProposerType.Empire.valueOf()) {
|
|
170
|
+
return new EmpireSlashingProposerContract(this.client, proposerAddress);
|
|
171
|
+
} else {
|
|
172
|
+
throw new Error(`Unknown slashing proposer type: ${proposerType}`);
|
|
173
|
+
}
|
|
80
174
|
}
|
|
81
175
|
|
|
82
176
|
@memoize
|
|
@@ -90,8 +184,8 @@ export class RollupContract {
|
|
|
90
184
|
}
|
|
91
185
|
|
|
92
186
|
@memoize
|
|
93
|
-
|
|
94
|
-
return this.rollup.read.
|
|
187
|
+
getProofSubmissionEpochs() {
|
|
188
|
+
return this.rollup.read.getProofSubmissionEpochs();
|
|
95
189
|
}
|
|
96
190
|
|
|
97
191
|
@memoize
|
|
@@ -100,8 +194,8 @@ export class RollupContract {
|
|
|
100
194
|
}
|
|
101
195
|
|
|
102
196
|
@memoize
|
|
103
|
-
getSlotDuration() {
|
|
104
|
-
return this.rollup.read.getSlotDuration();
|
|
197
|
+
async getSlotDuration(): Promise<number> {
|
|
198
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
105
199
|
}
|
|
106
200
|
|
|
107
201
|
@memoize
|
|
@@ -110,34 +204,165 @@ export class RollupContract {
|
|
|
110
204
|
}
|
|
111
205
|
|
|
112
206
|
@memoize
|
|
113
|
-
|
|
114
|
-
return this.rollup.read.
|
|
207
|
+
getEjectionThreshold() {
|
|
208
|
+
return this.rollup.read.getEjectionThreshold();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@memoize
|
|
212
|
+
getLocalEjectionThreshold() {
|
|
213
|
+
return this.rollup.read.getLocalEjectionThreshold();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@memoize
|
|
217
|
+
getLagInEpochsForValidatorSet() {
|
|
218
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@memoize
|
|
222
|
+
getLagInEpochsForRandao() {
|
|
223
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@memoize
|
|
227
|
+
getActivationThreshold() {
|
|
228
|
+
return this.rollup.read.getActivationThreshold();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@memoize
|
|
232
|
+
getExitDelay() {
|
|
233
|
+
return this.rollup.read.getExitDelay();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@memoize
|
|
237
|
+
getManaTarget() {
|
|
238
|
+
return this.rollup.read.getManaTarget();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@memoize
|
|
242
|
+
getProvingCostPerMana() {
|
|
243
|
+
return this.rollup.read.getProvingCostPerManaInEth();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@memoize
|
|
247
|
+
getProvingCostPerManaInFeeAsset() {
|
|
248
|
+
return this.rollup.read.getProvingCostPerManaInFeeAsset();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@memoize
|
|
252
|
+
getManaLimit() {
|
|
253
|
+
return this.rollup.read.getManaLimit();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@memoize
|
|
257
|
+
getVersion() {
|
|
258
|
+
return this.rollup.read.getVersion();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@memoize
|
|
262
|
+
async getGenesisArchiveTreeRoot(): Promise<`0x${string}`> {
|
|
263
|
+
return await this.rollup.read.archiveAt([0n]);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Returns rollup constants used for epoch queries.
|
|
268
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
269
|
+
* so we cant reference it until we move this contract to that package.
|
|
270
|
+
*/
|
|
271
|
+
@memoize
|
|
272
|
+
public async getRollupConstants(): Promise<{
|
|
273
|
+
l1StartBlock: bigint;
|
|
274
|
+
l1GenesisTime: bigint;
|
|
275
|
+
slotDuration: number;
|
|
276
|
+
epochDuration: number;
|
|
277
|
+
proofSubmissionEpochs: number;
|
|
278
|
+
}> {
|
|
279
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
280
|
+
this.getL1StartBlock(),
|
|
281
|
+
this.getL1GenesisTime(),
|
|
282
|
+
this.getSlotDuration(),
|
|
283
|
+
this.getEpochDuration(),
|
|
284
|
+
this.getProofSubmissionEpochs(),
|
|
285
|
+
]);
|
|
286
|
+
return {
|
|
287
|
+
l1StartBlock,
|
|
288
|
+
l1GenesisTime,
|
|
289
|
+
slotDuration,
|
|
290
|
+
epochDuration: Number(epochDuration),
|
|
291
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
getSlasherAddress() {
|
|
296
|
+
return this.rollup.read.getSlasher();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
301
|
+
*/
|
|
302
|
+
async getSlasherContract(): Promise<SlasherContract | undefined> {
|
|
303
|
+
const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
|
|
304
|
+
if (slasherAddress.isZero()) {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
return new SlasherContract(this.client, slasherAddress);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
getOwner() {
|
|
311
|
+
return this.rollup.read.owner();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
getActiveAttesterCount() {
|
|
315
|
+
return this.rollup.read.getActiveAttesterCount();
|
|
115
316
|
}
|
|
116
317
|
|
|
117
318
|
public async getSlashingProposerAddress() {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
319
|
+
const slasher = await this.getSlasherContract();
|
|
320
|
+
if (!slasher) {
|
|
321
|
+
return EthAddress.ZERO;
|
|
322
|
+
}
|
|
323
|
+
return await slasher.getProposer();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
getCheckpointReward() {
|
|
327
|
+
return this.rollup.read.getCheckpointReward();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
331
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
335
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
|
|
125
336
|
}
|
|
126
337
|
|
|
127
|
-
|
|
128
|
-
return this.rollup.read.
|
|
338
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
339
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
129
340
|
}
|
|
130
341
|
|
|
131
|
-
|
|
132
|
-
return this.rollup.read.
|
|
342
|
+
getL1FeesAt(timestamp: bigint) {
|
|
343
|
+
return this.rollup.read.getL1FeesAt([timestamp]);
|
|
133
344
|
}
|
|
134
345
|
|
|
135
|
-
|
|
136
|
-
return this.rollup.read.
|
|
346
|
+
getFeeAssetPerEth() {
|
|
347
|
+
return this.rollup.read.getFeeAssetPerEth();
|
|
137
348
|
}
|
|
138
349
|
|
|
139
|
-
getCommitteeAt(timestamp: bigint) {
|
|
140
|
-
|
|
350
|
+
async getCommitteeAt(timestamp: bigint): Promise<readonly `0x${string}`[] | undefined> {
|
|
351
|
+
const { result } = await this.client
|
|
352
|
+
.simulateContract({
|
|
353
|
+
address: this.address,
|
|
354
|
+
abi: RollupAbi,
|
|
355
|
+
functionName: 'getCommitteeAt',
|
|
356
|
+
args: [timestamp],
|
|
357
|
+
})
|
|
358
|
+
.catch(e => {
|
|
359
|
+
if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
|
|
360
|
+
return { result: undefined };
|
|
361
|
+
}
|
|
362
|
+
throw e;
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
return result;
|
|
141
366
|
}
|
|
142
367
|
|
|
143
368
|
getSampleSeedAt(timestamp: bigint) {
|
|
@@ -148,33 +373,99 @@ export class RollupContract {
|
|
|
148
373
|
return this.rollup.read.getCurrentSampleSeed();
|
|
149
374
|
}
|
|
150
375
|
|
|
151
|
-
|
|
152
|
-
return this.rollup.read.
|
|
376
|
+
async getCurrentEpoch(): Promise<EpochNumber> {
|
|
377
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
153
378
|
}
|
|
154
379
|
|
|
155
|
-
|
|
156
|
-
|
|
380
|
+
async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
|
|
381
|
+
const { result } = await this.client
|
|
382
|
+
.simulateContract({
|
|
383
|
+
address: this.address,
|
|
384
|
+
abi: RollupAbi,
|
|
385
|
+
functionName: 'getCurrentEpochCommittee',
|
|
386
|
+
args: [],
|
|
387
|
+
})
|
|
388
|
+
.catch(e => {
|
|
389
|
+
if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
|
|
390
|
+
return { result: undefined };
|
|
391
|
+
}
|
|
392
|
+
throw e;
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
return result;
|
|
157
396
|
}
|
|
158
397
|
|
|
159
|
-
|
|
160
|
-
|
|
398
|
+
async getCurrentProposer() {
|
|
399
|
+
const { result } = await this.client.simulateContract({
|
|
400
|
+
address: this.address,
|
|
401
|
+
abi: RollupAbi,
|
|
402
|
+
functionName: 'getCurrentProposer',
|
|
403
|
+
args: [],
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
return result;
|
|
161
407
|
}
|
|
162
408
|
|
|
163
|
-
|
|
164
|
-
|
|
409
|
+
async getProposerAt(timestamp: bigint) {
|
|
410
|
+
const { result } = await this.client.simulateContract({
|
|
411
|
+
address: this.address,
|
|
412
|
+
abi: RollupAbi,
|
|
413
|
+
functionName: 'getProposerAt',
|
|
414
|
+
args: [timestamp],
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return result;
|
|
165
418
|
}
|
|
166
419
|
|
|
167
|
-
|
|
168
|
-
return this.rollup.read.
|
|
420
|
+
getCheckpoint(checkpointNumber: CheckpointNumber) {
|
|
421
|
+
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
169
422
|
}
|
|
170
423
|
|
|
171
|
-
|
|
172
|
-
|
|
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
|
+
);
|
|
173
437
|
}
|
|
174
438
|
|
|
175
|
-
async
|
|
176
|
-
|
|
177
|
-
return
|
|
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
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
getTimestampForSlot(slot: SlotNumber) {
|
|
448
|
+
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
getEntryQueueLength() {
|
|
452
|
+
return this.rollup.read.getEntryQueueLength();
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
getAvailableValidatorFlushes() {
|
|
456
|
+
return this.rollup.read.getAvailableValidatorFlushes();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
460
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async getCurrentEpochNumber(): Promise<EpochNumber> {
|
|
464
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
|
|
468
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
|
|
178
469
|
}
|
|
179
470
|
|
|
180
471
|
async getRollupAddresses(): Promise<L1RollupContractAddresses> {
|
|
@@ -185,6 +476,7 @@ export class RollupContract {
|
|
|
185
476
|
rewardDistributorAddress,
|
|
186
477
|
feeJuiceAddress,
|
|
187
478
|
stakingAssetAddress,
|
|
479
|
+
gseAddress,
|
|
188
480
|
] = (
|
|
189
481
|
await Promise.all([
|
|
190
482
|
this.rollup.read.getInbox(),
|
|
@@ -193,6 +485,7 @@ export class RollupContract {
|
|
|
193
485
|
this.rollup.read.getRewardDistributor(),
|
|
194
486
|
this.rollup.read.getFeeAsset(),
|
|
195
487
|
this.rollup.read.getStakingAsset(),
|
|
488
|
+
this.rollup.read.getGSE(),
|
|
196
489
|
] as const)
|
|
197
490
|
).map(EthAddress.fromString);
|
|
198
491
|
|
|
@@ -204,25 +497,31 @@ export class RollupContract {
|
|
|
204
497
|
feeJuiceAddress,
|
|
205
498
|
stakingAssetAddress,
|
|
206
499
|
rewardDistributorAddress,
|
|
500
|
+
gseAddress,
|
|
207
501
|
};
|
|
208
502
|
}
|
|
209
503
|
|
|
210
|
-
public async
|
|
211
|
-
return await this.rollup.read.
|
|
504
|
+
public async getFeeJuicePortal() {
|
|
505
|
+
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
|
|
509
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
212
510
|
}
|
|
213
511
|
|
|
214
512
|
getEpochProofPublicInputs(
|
|
215
|
-
args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}
|
|
513
|
+
args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`],
|
|
216
514
|
) {
|
|
217
515
|
return this.rollup.read.getEpochProofPublicInputs(args);
|
|
218
516
|
}
|
|
219
517
|
|
|
220
518
|
public async validateHeader(
|
|
221
519
|
args: readonly [
|
|
520
|
+
ViemHeader,
|
|
521
|
+
ViemCommitteeAttestations,
|
|
522
|
+
`0x${string}`[],
|
|
523
|
+
ViemSignature,
|
|
222
524
|
`0x${string}`,
|
|
223
|
-
ViemSignature[],
|
|
224
|
-
`0x${string}`,
|
|
225
|
-
bigint,
|
|
226
525
|
`0x${string}`,
|
|
227
526
|
{
|
|
228
527
|
ignoreDA: boolean;
|
|
@@ -232,7 +531,13 @@ export class RollupContract {
|
|
|
232
531
|
account: `0x${string}` | Account,
|
|
233
532
|
): Promise<void> {
|
|
234
533
|
try {
|
|
235
|
-
await this.
|
|
534
|
+
await this.client.simulateContract({
|
|
535
|
+
address: this.address,
|
|
536
|
+
abi: RollupAbi,
|
|
537
|
+
functionName: 'validateHeaderWithAttestations',
|
|
538
|
+
args,
|
|
539
|
+
account,
|
|
540
|
+
});
|
|
236
541
|
} catch (error: unknown) {
|
|
237
542
|
throw formatViemError(error);
|
|
238
543
|
}
|
|
@@ -244,31 +549,272 @@ export class RollupContract {
|
|
|
244
549
|
* @dev Throws if unable to propose
|
|
245
550
|
*
|
|
246
551
|
* @param archive - The archive that we expect to be current state
|
|
247
|
-
* @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
|
|
248
554
|
* @throws otherwise
|
|
249
555
|
*/
|
|
250
556
|
public async canProposeAtNextEthBlock(
|
|
251
557
|
archive: Buffer,
|
|
252
558
|
account: `0x${string}` | Account,
|
|
253
|
-
slotDuration:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
559
|
+
slotDuration: number,
|
|
560
|
+
opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
|
|
561
|
+
): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
|
|
562
|
+
const latestBlock = await this.client.getBlock();
|
|
563
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
564
|
+
const who = typeof account === 'string' ? account : account.address;
|
|
565
|
+
|
|
259
566
|
try {
|
|
260
|
-
const
|
|
261
|
-
[
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
567
|
+
const {
|
|
568
|
+
result: [slot, checkpointNumber],
|
|
569
|
+
} = await this.client.simulateContract({
|
|
570
|
+
address: this.address,
|
|
571
|
+
abi: RollupAbi,
|
|
572
|
+
functionName: 'canProposeAtTime',
|
|
573
|
+
args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
|
|
574
|
+
account,
|
|
575
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
return {
|
|
579
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
580
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
581
|
+
timeOfNextL1Slot,
|
|
582
|
+
};
|
|
265
583
|
} catch (err: unknown) {
|
|
266
584
|
throw formatViemError(err);
|
|
267
585
|
}
|
|
268
586
|
}
|
|
269
587
|
|
|
588
|
+
/**
|
|
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
|
|
591
|
+
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
592
|
+
*/
|
|
593
|
+
public async makePendingCheckpointNumberOverride(
|
|
594
|
+
forcePendingCheckpointNumber: CheckpointNumber | undefined,
|
|
595
|
+
): Promise<StateOverride> {
|
|
596
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
const slot = RollupContract.stfStorageSlot;
|
|
600
|
+
const currentValue = await this.client.getStorageAt({ address: this.address, slot });
|
|
601
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
|
|
602
|
+
const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
|
|
603
|
+
return [
|
|
604
|
+
{
|
|
605
|
+
address: this.address,
|
|
606
|
+
stateDiff: [{ slot, value: `0x${newValue.toString(16).padStart(64, '0')}` }],
|
|
607
|
+
},
|
|
608
|
+
];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
612
|
+
public buildInvalidateBadAttestationRequest(
|
|
613
|
+
checkpointNumber: CheckpointNumber,
|
|
614
|
+
attestationsAndSigners: ViemCommitteeAttestations,
|
|
615
|
+
committee: EthAddress[],
|
|
616
|
+
invalidIndex: number,
|
|
617
|
+
): L1TxRequest {
|
|
618
|
+
return {
|
|
619
|
+
to: this.address,
|
|
620
|
+
data: encodeFunctionData({
|
|
621
|
+
abi: RollupAbi,
|
|
622
|
+
functionName: 'invalidateBadAttestation',
|
|
623
|
+
args: [
|
|
624
|
+
BigInt(checkpointNumber),
|
|
625
|
+
attestationsAndSigners,
|
|
626
|
+
committee.map(addr => addr.toString()),
|
|
627
|
+
BigInt(invalidIndex),
|
|
628
|
+
],
|
|
629
|
+
}),
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
634
|
+
public buildInvalidateInsufficientAttestationsRequest(
|
|
635
|
+
checkpointNumber: CheckpointNumber,
|
|
636
|
+
attestationsAndSigners: ViemCommitteeAttestations,
|
|
637
|
+
committee: EthAddress[],
|
|
638
|
+
): L1TxRequest {
|
|
639
|
+
return {
|
|
640
|
+
to: this.address,
|
|
641
|
+
data: encodeFunctionData({
|
|
642
|
+
abi: RollupAbi,
|
|
643
|
+
functionName: 'invalidateInsufficientAttestations',
|
|
644
|
+
args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
|
|
645
|
+
}),
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
270
649
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
271
|
-
public getHasSubmittedProof(epochNumber:
|
|
272
|
-
|
|
650
|
+
public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
|
|
651
|
+
if (prover instanceof EthAddress) {
|
|
652
|
+
prover = prover.toString();
|
|
653
|
+
}
|
|
654
|
+
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
|
|
658
|
+
return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
662
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
|
|
666
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
667
|
+
return this.rollup.read.status([BigInt(checkpointNumber)], options);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
671
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
672
|
+
return this.rollup.read.canPruneAtTime([timestamp], options);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
archive() {
|
|
676
|
+
return this.rollup.read.archive();
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
archiveAt(checkpointNumber: CheckpointNumber) {
|
|
680
|
+
return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
getSequencerRewards(address: Hex | EthAddress) {
|
|
684
|
+
if (address instanceof EthAddress) {
|
|
685
|
+
address = address.toString();
|
|
686
|
+
}
|
|
687
|
+
return this.rollup.read.getSequencerRewards([address]);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress) {
|
|
691
|
+
if (prover instanceof EthAddress) {
|
|
692
|
+
prover = prover.toString();
|
|
693
|
+
}
|
|
694
|
+
return this.rollup.read.getSpecificProverRewardsForEpoch([epoch, prover]);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
async getAttesters() {
|
|
698
|
+
const attesterSize = await this.getActiveAttesterCount();
|
|
699
|
+
const gse = new GSEContract(this.client, await this.getGSE());
|
|
700
|
+
const ts = (await this.client.getBlock()).timestamp;
|
|
701
|
+
|
|
702
|
+
const indices = Array.from({ length: Number(attesterSize) }, (_, i) => BigInt(i));
|
|
703
|
+
const chunks = chunk(indices, 1000);
|
|
704
|
+
|
|
705
|
+
return (await Promise.all(chunks.map(chunk => gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)))).flat();
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
getAttesterView(address: Hex | EthAddress) {
|
|
709
|
+
if (address instanceof EthAddress) {
|
|
710
|
+
address = address.toString();
|
|
711
|
+
}
|
|
712
|
+
return this.rollup.read.getAttesterView([address]);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
getStatus(address: Hex | EthAddress) {
|
|
716
|
+
if (address instanceof EthAddress) {
|
|
717
|
+
address = address.toString();
|
|
718
|
+
}
|
|
719
|
+
return this.rollup.read.getStatus([address]);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
|
|
723
|
+
return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
getCurrentBlobCommitmentsHash() {
|
|
727
|
+
return this.rollup.read.getCurrentBlobCommitmentsHash();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
getStakingAsset() {
|
|
731
|
+
return this.rollup.read.getStakingAsset();
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
getRewardConfig() {
|
|
735
|
+
return this.rollup.read.getRewardConfig();
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
setupEpoch(l1TxUtils: L1TxUtils) {
|
|
739
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
740
|
+
to: this.address,
|
|
741
|
+
data: encodeFunctionData({
|
|
742
|
+
abi: RollupAbi,
|
|
743
|
+
functionName: 'setupEpoch',
|
|
744
|
+
args: [],
|
|
745
|
+
}),
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
vote(l1TxUtils: L1TxUtils, proposalId: bigint) {
|
|
750
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
751
|
+
to: this.address,
|
|
752
|
+
data: encodeFunctionData({
|
|
753
|
+
abi: RollupAbi,
|
|
754
|
+
functionName: 'vote',
|
|
755
|
+
args: [proposalId],
|
|
756
|
+
}),
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
public listenToSlasherChanged(
|
|
761
|
+
callback: (args: { oldSlasher: `0x${string}`; newSlasher: `0x${string}` }) => unknown,
|
|
762
|
+
): WatchContractEventReturnType {
|
|
763
|
+
return this.rollup.watchEvent.SlasherUpdated(
|
|
764
|
+
{},
|
|
765
|
+
{
|
|
766
|
+
onLogs: logs => {
|
|
767
|
+
for (const log of logs) {
|
|
768
|
+
const args = log.args;
|
|
769
|
+
if (args.oldSlasher && args.newSlasher) {
|
|
770
|
+
callback(args as { oldSlasher: `0x${string}`; newSlasher: `0x${string}` });
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
public listenToCheckpointInvalidated(
|
|
779
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
780
|
+
): WatchContractEventReturnType {
|
|
781
|
+
return this.rollup.watchEvent.CheckpointInvalidated(
|
|
782
|
+
{},
|
|
783
|
+
{
|
|
784
|
+
onLogs: logs => {
|
|
785
|
+
for (const log of logs) {
|
|
786
|
+
const args = log.args;
|
|
787
|
+
if (args.checkpointNumber !== undefined) {
|
|
788
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
public async getSlashEvents(l1BlockHash: Hex): Promise<{ amount: bigint; attester: EthAddress }[]> {
|
|
797
|
+
const events = await this.rollup.getEvents.Slashed({}, { blockHash: l1BlockHash, strict: true });
|
|
798
|
+
return events.map(event => ({
|
|
799
|
+
amount: event.args.amount!,
|
|
800
|
+
attester: EthAddress.fromString(event.args.attester!),
|
|
801
|
+
}));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
public listenToSlash(
|
|
805
|
+
callback: (args: { amount: bigint; attester: EthAddress }) => unknown,
|
|
806
|
+
): WatchContractEventReturnType {
|
|
807
|
+
return this.rollup.watchEvent.Slashed(
|
|
808
|
+
{},
|
|
809
|
+
{
|
|
810
|
+
strict: true,
|
|
811
|
+
onLogs: logs => {
|
|
812
|
+
for (const log of logs) {
|
|
813
|
+
const args = log.args;
|
|
814
|
+
callback({ amount: args.amount!, attester: EthAddress.fromString(args.attester!) });
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
);
|
|
273
819
|
}
|
|
274
820
|
}
|