@aztec/ethereum 0.0.0-test.1 → 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/dest/contracts/rollup.js
CHANGED
|
@@ -4,16 +4,31 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { memoize } from '@aztec/foundation/decorators';
|
|
8
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
11
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
12
|
+
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
13
|
+
import chunk from 'lodash.chunk';
|
|
14
|
+
import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
11
15
|
import { getPublicClient } from '../client.js';
|
|
12
16
|
import { formatViemError } from '../utils.js';
|
|
13
|
-
import {
|
|
17
|
+
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
18
|
+
import { GSEContract } from './gse.js';
|
|
19
|
+
import { SlasherContract } from './slasher_contract.js';
|
|
20
|
+
import { TallySlashingProposerContract } from './tally_slashing_proposer.js';
|
|
21
|
+
import { checkBlockTag } from './utils.js';
|
|
22
|
+
export var SlashingProposerType = /*#__PURE__*/ function(SlashingProposerType) {
|
|
23
|
+
SlashingProposerType[SlashingProposerType["None"] = 0] = "None";
|
|
24
|
+
SlashingProposerType[SlashingProposerType["Tally"] = 1] = "Tally";
|
|
25
|
+
SlashingProposerType[SlashingProposerType["Empire"] = 2] = "Empire";
|
|
26
|
+
return SlashingProposerType;
|
|
27
|
+
}({});
|
|
14
28
|
export class RollupContract {
|
|
15
29
|
client;
|
|
16
30
|
rollup;
|
|
31
|
+
static cachedStfStorageSlot;
|
|
17
32
|
static get checkBlobStorageSlot() {
|
|
18
33
|
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
19
34
|
if (asString === undefined) {
|
|
@@ -21,9 +36,12 @@ export class RollupContract {
|
|
|
21
36
|
}
|
|
22
37
|
return BigInt(asString);
|
|
23
38
|
}
|
|
39
|
+
static get stfStorageSlot() {
|
|
40
|
+
return RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8'));
|
|
41
|
+
}
|
|
24
42
|
static getFromL1ContractsValues(deployL1ContractsValues) {
|
|
25
|
-
const {
|
|
26
|
-
return new RollupContract(
|
|
43
|
+
const { l1Client, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
|
|
44
|
+
return new RollupContract(l1Client, rollupAddress.toString());
|
|
27
45
|
}
|
|
28
46
|
static getFromConfig(config) {
|
|
29
47
|
const client = getPublicClient(config);
|
|
@@ -41,18 +59,49 @@ export class RollupContract {
|
|
|
41
59
|
client
|
|
42
60
|
});
|
|
43
61
|
}
|
|
62
|
+
getGSE() {
|
|
63
|
+
return this.rollup.read.getGSE();
|
|
64
|
+
}
|
|
44
65
|
get address() {
|
|
45
66
|
return this.rollup.address;
|
|
46
67
|
}
|
|
68
|
+
getContract() {
|
|
69
|
+
return this.rollup;
|
|
70
|
+
}
|
|
47
71
|
async getSlashingProposer() {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
const slasher = await this.getSlasherContract();
|
|
73
|
+
if (!slasher) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const proposerAddress = await slasher.getProposer();
|
|
77
|
+
const proposerAbi = [
|
|
78
|
+
{
|
|
79
|
+
type: 'function',
|
|
80
|
+
name: 'SLASHING_PROPOSER_TYPE',
|
|
81
|
+
inputs: [],
|
|
82
|
+
outputs: [
|
|
83
|
+
{
|
|
84
|
+
name: '',
|
|
85
|
+
type: 'uint8',
|
|
86
|
+
internalType: 'enum SlasherFlavor'
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
stateMutability: 'view'
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
const proposer = getContract({
|
|
93
|
+
address: proposerAddress.toString(),
|
|
94
|
+
abi: proposerAbi,
|
|
52
95
|
client: this.client
|
|
53
96
|
});
|
|
54
|
-
const
|
|
55
|
-
|
|
97
|
+
const proposerType = await proposer.read.SLASHING_PROPOSER_TYPE();
|
|
98
|
+
if (proposerType === 1..valueOf()) {
|
|
99
|
+
return new TallySlashingProposerContract(this.client, proposerAddress);
|
|
100
|
+
} else if (proposerType === 2..valueOf()) {
|
|
101
|
+
return new EmpireSlashingProposerContract(this.client, proposerAddress);
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error(`Unknown slashing proposer type: ${proposerType}`);
|
|
104
|
+
}
|
|
56
105
|
}
|
|
57
106
|
getL1StartBlock() {
|
|
58
107
|
return this.rollup.read.L1_BLOCK_AT_GENESIS();
|
|
@@ -60,44 +109,139 @@ export class RollupContract {
|
|
|
60
109
|
getL1GenesisTime() {
|
|
61
110
|
return this.rollup.read.getGenesisTime();
|
|
62
111
|
}
|
|
63
|
-
|
|
64
|
-
return this.rollup.read.
|
|
112
|
+
getProofSubmissionEpochs() {
|
|
113
|
+
return this.rollup.read.getProofSubmissionEpochs();
|
|
65
114
|
}
|
|
66
115
|
getEpochDuration() {
|
|
67
116
|
return this.rollup.read.getEpochDuration();
|
|
68
117
|
}
|
|
69
|
-
getSlotDuration() {
|
|
70
|
-
return this.rollup.read.getSlotDuration();
|
|
118
|
+
async getSlotDuration() {
|
|
119
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
71
120
|
}
|
|
72
121
|
getTargetCommitteeSize() {
|
|
73
122
|
return this.rollup.read.getTargetCommitteeSize();
|
|
74
123
|
}
|
|
75
|
-
|
|
76
|
-
return this.rollup.read.
|
|
124
|
+
getEjectionThreshold() {
|
|
125
|
+
return this.rollup.read.getEjectionThreshold();
|
|
126
|
+
}
|
|
127
|
+
getLocalEjectionThreshold() {
|
|
128
|
+
return this.rollup.read.getLocalEjectionThreshold();
|
|
129
|
+
}
|
|
130
|
+
getLagInEpochsForValidatorSet() {
|
|
131
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
132
|
+
}
|
|
133
|
+
getLagInEpochsForRandao() {
|
|
134
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
135
|
+
}
|
|
136
|
+
getActivationThreshold() {
|
|
137
|
+
return this.rollup.read.getActivationThreshold();
|
|
138
|
+
}
|
|
139
|
+
getExitDelay() {
|
|
140
|
+
return this.rollup.read.getExitDelay();
|
|
141
|
+
}
|
|
142
|
+
getManaTarget() {
|
|
143
|
+
return this.rollup.read.getManaTarget();
|
|
144
|
+
}
|
|
145
|
+
getProvingCostPerMana() {
|
|
146
|
+
return this.rollup.read.getProvingCostPerManaInEth();
|
|
147
|
+
}
|
|
148
|
+
getProvingCostPerManaInFeeAsset() {
|
|
149
|
+
return this.rollup.read.getProvingCostPerManaInFeeAsset();
|
|
150
|
+
}
|
|
151
|
+
getManaLimit() {
|
|
152
|
+
return this.rollup.read.getManaLimit();
|
|
153
|
+
}
|
|
154
|
+
getVersion() {
|
|
155
|
+
return this.rollup.read.getVersion();
|
|
156
|
+
}
|
|
157
|
+
async getGenesisArchiveTreeRoot() {
|
|
158
|
+
return await this.rollup.read.archiveAt([
|
|
159
|
+
0n
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns rollup constants used for epoch queries.
|
|
164
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
165
|
+
* so we cant reference it until we move this contract to that package.
|
|
166
|
+
*/ async getRollupConstants() {
|
|
167
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
168
|
+
this.getL1StartBlock(),
|
|
169
|
+
this.getL1GenesisTime(),
|
|
170
|
+
this.getSlotDuration(),
|
|
171
|
+
this.getEpochDuration(),
|
|
172
|
+
this.getProofSubmissionEpochs()
|
|
173
|
+
]);
|
|
174
|
+
return {
|
|
175
|
+
l1StartBlock,
|
|
176
|
+
l1GenesisTime,
|
|
177
|
+
slotDuration,
|
|
178
|
+
epochDuration: Number(epochDuration),
|
|
179
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
getSlasherAddress() {
|
|
183
|
+
return this.rollup.read.getSlasher();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
187
|
+
*/ async getSlasherContract() {
|
|
188
|
+
const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
|
|
189
|
+
if (slasherAddress.isZero()) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
return new SlasherContract(this.client, slasherAddress);
|
|
193
|
+
}
|
|
194
|
+
getOwner() {
|
|
195
|
+
return this.rollup.read.owner();
|
|
196
|
+
}
|
|
197
|
+
getActiveAttesterCount() {
|
|
198
|
+
return this.rollup.read.getActiveAttesterCount();
|
|
77
199
|
}
|
|
78
200
|
async getSlashingProposerAddress() {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
return EthAddress.fromString(await slasher.read.PROPOSER());
|
|
201
|
+
const slasher = await this.getSlasherContract();
|
|
202
|
+
if (!slasher) {
|
|
203
|
+
return EthAddress.ZERO;
|
|
204
|
+
}
|
|
205
|
+
return await slasher.getProposer();
|
|
86
206
|
}
|
|
87
|
-
|
|
88
|
-
return this.rollup.read.
|
|
207
|
+
getCheckpointReward() {
|
|
208
|
+
return this.rollup.read.getCheckpointReward();
|
|
89
209
|
}
|
|
90
|
-
|
|
91
|
-
return this.rollup.read.
|
|
210
|
+
async getCheckpointNumber() {
|
|
211
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
|
|
92
212
|
}
|
|
93
|
-
|
|
94
|
-
return this.rollup.read.
|
|
213
|
+
async getProvenCheckpointNumber() {
|
|
214
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
|
|
95
215
|
}
|
|
96
|
-
|
|
97
|
-
return this.rollup.read.
|
|
216
|
+
async getSlotNumber() {
|
|
217
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
218
|
+
}
|
|
219
|
+
getL1FeesAt(timestamp) {
|
|
220
|
+
return this.rollup.read.getL1FeesAt([
|
|
98
221
|
timestamp
|
|
99
222
|
]);
|
|
100
223
|
}
|
|
224
|
+
getFeeAssetPerEth() {
|
|
225
|
+
return this.rollup.read.getFeeAssetPerEth();
|
|
226
|
+
}
|
|
227
|
+
async getCommitteeAt(timestamp) {
|
|
228
|
+
const { result } = await this.client.simulateContract({
|
|
229
|
+
address: this.address,
|
|
230
|
+
abi: RollupAbi,
|
|
231
|
+
functionName: 'getCommitteeAt',
|
|
232
|
+
args: [
|
|
233
|
+
timestamp
|
|
234
|
+
]
|
|
235
|
+
}).catch((e)=>{
|
|
236
|
+
if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
|
|
237
|
+
return {
|
|
238
|
+
result: undefined
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
throw e;
|
|
242
|
+
});
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
101
245
|
getSampleSeedAt(timestamp) {
|
|
102
246
|
return this.rollup.read.getSampleSeedAt([
|
|
103
247
|
timestamp
|
|
@@ -106,44 +250,101 @@ export class RollupContract {
|
|
|
106
250
|
getCurrentSampleSeed() {
|
|
107
251
|
return this.rollup.read.getCurrentSampleSeed();
|
|
108
252
|
}
|
|
109
|
-
|
|
110
|
-
return this.rollup.read.
|
|
253
|
+
async getCurrentEpoch() {
|
|
254
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
111
255
|
}
|
|
112
|
-
|
|
113
|
-
|
|
256
|
+
async getCurrentEpochCommittee() {
|
|
257
|
+
const { result } = await this.client.simulateContract({
|
|
258
|
+
address: this.address,
|
|
259
|
+
abi: RollupAbi,
|
|
260
|
+
functionName: 'getCurrentEpochCommittee',
|
|
261
|
+
args: []
|
|
262
|
+
}).catch((e)=>{
|
|
263
|
+
if (e instanceof Error && e.message.includes('ValidatorSelection__InsufficientValidatorSetSize')) {
|
|
264
|
+
return {
|
|
265
|
+
result: undefined
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
throw e;
|
|
269
|
+
});
|
|
270
|
+
return result;
|
|
114
271
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
272
|
+
async getCurrentProposer() {
|
|
273
|
+
const { result } = await this.client.simulateContract({
|
|
274
|
+
address: this.address,
|
|
275
|
+
abi: RollupAbi,
|
|
276
|
+
functionName: 'getCurrentProposer',
|
|
277
|
+
args: []
|
|
278
|
+
});
|
|
279
|
+
return result;
|
|
119
280
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
281
|
+
async getProposerAt(timestamp) {
|
|
282
|
+
const { result } = await this.client.simulateContract({
|
|
283
|
+
address: this.address,
|
|
284
|
+
abi: RollupAbi,
|
|
285
|
+
functionName: 'getProposerAt',
|
|
286
|
+
args: [
|
|
287
|
+
timestamp
|
|
288
|
+
]
|
|
289
|
+
});
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
getCheckpoint(checkpointNumber) {
|
|
293
|
+
return this.rollup.read.getCheckpoint([
|
|
294
|
+
BigInt(checkpointNumber)
|
|
123
295
|
]);
|
|
124
296
|
}
|
|
125
|
-
|
|
126
|
-
|
|
297
|
+
/** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
|
|
298
|
+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
299
|
+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
|
|
300
|
+
return retry(async ()=>{
|
|
301
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber();
|
|
302
|
+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
|
|
303
|
+
return pendingCheckpoint;
|
|
304
|
+
}, 'getting pending checkpoint', makeBackoff([
|
|
305
|
+
0.5,
|
|
306
|
+
0.5,
|
|
307
|
+
0.5
|
|
308
|
+
]));
|
|
309
|
+
}
|
|
310
|
+
async getTips() {
|
|
311
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
312
|
+
return {
|
|
313
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
314
|
+
proven: CheckpointNumber.fromBigInt(proven)
|
|
315
|
+
};
|
|
127
316
|
}
|
|
128
317
|
getTimestampForSlot(slot) {
|
|
129
318
|
return this.rollup.read.getTimestampForSlot([
|
|
130
|
-
slot
|
|
319
|
+
BigInt(slot)
|
|
131
320
|
]);
|
|
132
321
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
322
|
+
getEntryQueueLength() {
|
|
323
|
+
return this.rollup.read.getEntryQueueLength();
|
|
324
|
+
}
|
|
325
|
+
getAvailableValidatorFlushes() {
|
|
326
|
+
return this.rollup.read.getAvailableValidatorFlushes();
|
|
327
|
+
}
|
|
328
|
+
async getNextFlushableEpoch() {
|
|
329
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
330
|
+
}
|
|
331
|
+
async getCurrentEpochNumber() {
|
|
332
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
333
|
+
}
|
|
334
|
+
async getEpochNumberForCheckpoint(checkpointNumber) {
|
|
335
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([
|
|
336
|
+
BigInt(checkpointNumber)
|
|
337
|
+
]));
|
|
138
338
|
}
|
|
139
339
|
async getRollupAddresses() {
|
|
140
|
-
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
|
|
340
|
+
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
|
|
141
341
|
this.rollup.read.getInbox(),
|
|
142
342
|
this.rollup.read.getOutbox(),
|
|
143
343
|
this.rollup.read.getFeeAssetPortal(),
|
|
144
344
|
this.rollup.read.getRewardDistributor(),
|
|
145
345
|
this.rollup.read.getFeeAsset(),
|
|
146
|
-
this.rollup.read.getStakingAsset()
|
|
346
|
+
this.rollup.read.getStakingAsset(),
|
|
347
|
+
this.rollup.read.getGSE()
|
|
147
348
|
])).map(EthAddress.fromString);
|
|
148
349
|
return {
|
|
149
350
|
rollupAddress: EthAddress.fromString(this.address),
|
|
@@ -152,20 +353,28 @@ export class RollupContract {
|
|
|
152
353
|
feeJuicePortalAddress,
|
|
153
354
|
feeJuiceAddress,
|
|
154
355
|
stakingAssetAddress,
|
|
155
|
-
rewardDistributorAddress
|
|
356
|
+
rewardDistributorAddress,
|
|
357
|
+
gseAddress
|
|
156
358
|
};
|
|
157
359
|
}
|
|
360
|
+
async getFeeJuicePortal() {
|
|
361
|
+
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
362
|
+
}
|
|
158
363
|
async getEpochNumberForSlotNumber(slotNumber) {
|
|
159
|
-
return await this.rollup.read.getEpochAtSlot([
|
|
160
|
-
slotNumber
|
|
161
|
-
]);
|
|
364
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
|
|
365
|
+
BigInt(slotNumber)
|
|
366
|
+
]));
|
|
162
367
|
}
|
|
163
368
|
getEpochProofPublicInputs(args) {
|
|
164
369
|
return this.rollup.read.getEpochProofPublicInputs(args);
|
|
165
370
|
}
|
|
166
371
|
async validateHeader(args, account) {
|
|
167
372
|
try {
|
|
168
|
-
await this.
|
|
373
|
+
await this.client.simulateContract({
|
|
374
|
+
address: this.address,
|
|
375
|
+
abi: RollupAbi,
|
|
376
|
+
functionName: 'validateHeaderWithAttestations',
|
|
377
|
+
args,
|
|
169
378
|
account
|
|
170
379
|
});
|
|
171
380
|
} catch (error) {
|
|
@@ -178,39 +387,262 @@ export class RollupContract {
|
|
|
178
387
|
* @dev Throws if unable to propose
|
|
179
388
|
*
|
|
180
389
|
* @param archive - The archive that we expect to be current state
|
|
181
|
-
* @return [slot,
|
|
390
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
391
|
+
* timestamp of the next L1 block
|
|
182
392
|
* @throws otherwise
|
|
183
|
-
*/ async canProposeAtNextEthBlock(archive, account, slotDuration) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const timeOfNextL1Slot = (await this.client.getBlock()).timestamp + slotDuration;
|
|
393
|
+
*/ async canProposeAtNextEthBlock(archive, account, slotDuration, opts = {}) {
|
|
394
|
+
const latestBlock = await this.client.getBlock();
|
|
395
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
396
|
+
const who = typeof account === 'string' ? account : account.address;
|
|
188
397
|
try {
|
|
189
|
-
const [slot,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
398
|
+
const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
|
|
399
|
+
address: this.address,
|
|
400
|
+
abi: RollupAbi,
|
|
401
|
+
functionName: 'canProposeAtTime',
|
|
402
|
+
args: [
|
|
403
|
+
timeOfNextL1Slot,
|
|
404
|
+
`0x${archive.toString('hex')}`,
|
|
405
|
+
who
|
|
406
|
+
],
|
|
407
|
+
account,
|
|
408
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber)
|
|
194
409
|
});
|
|
195
|
-
return
|
|
196
|
-
slot,
|
|
197
|
-
|
|
198
|
-
|
|
410
|
+
return {
|
|
411
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
412
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
413
|
+
timeOfNextL1Slot
|
|
414
|
+
};
|
|
199
415
|
} catch (err) {
|
|
200
416
|
throw formatViemError(err);
|
|
201
417
|
}
|
|
202
418
|
}
|
|
203
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
421
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
422
|
+
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
423
|
+
*/ async makePendingCheckpointNumberOverride(forcePendingCheckpointNumber) {
|
|
424
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
425
|
+
return [];
|
|
426
|
+
}
|
|
427
|
+
const slot = RollupContract.stfStorageSlot;
|
|
428
|
+
const currentValue = await this.client.getStorageAt({
|
|
429
|
+
address: this.address,
|
|
430
|
+
slot
|
|
431
|
+
});
|
|
432
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & (1n << 128n) - 1n : 0n;
|
|
433
|
+
const newValue = BigInt(forcePendingCheckpointNumber) << 128n | currentProvenCheckpointNumber;
|
|
434
|
+
return [
|
|
435
|
+
{
|
|
436
|
+
address: this.address,
|
|
437
|
+
stateDiff: [
|
|
438
|
+
{
|
|
439
|
+
slot,
|
|
440
|
+
value: `0x${newValue.toString(16).padStart(64, '0')}`
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
];
|
|
445
|
+
}
|
|
446
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
|
|
447
|
+
return {
|
|
448
|
+
to: this.address,
|
|
449
|
+
data: encodeFunctionData({
|
|
450
|
+
abi: RollupAbi,
|
|
451
|
+
functionName: 'invalidateBadAttestation',
|
|
452
|
+
args: [
|
|
453
|
+
BigInt(checkpointNumber),
|
|
454
|
+
attestationsAndSigners,
|
|
455
|
+
committee.map((addr)=>addr.toString()),
|
|
456
|
+
BigInt(invalidIndex)
|
|
457
|
+
]
|
|
458
|
+
})
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
|
|
462
|
+
return {
|
|
463
|
+
to: this.address,
|
|
464
|
+
data: encodeFunctionData({
|
|
465
|
+
abi: RollupAbi,
|
|
466
|
+
functionName: 'invalidateInsufficientAttestations',
|
|
467
|
+
args: [
|
|
468
|
+
BigInt(checkpointNumber),
|
|
469
|
+
attestationsAndSigners,
|
|
470
|
+
committee.map((addr)=>addr.toString())
|
|
471
|
+
]
|
|
472
|
+
})
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfCheckpointsInEpoch, prover) {
|
|
476
|
+
if (prover instanceof EthAddress) {
|
|
477
|
+
prover = prover.toString();
|
|
478
|
+
}
|
|
204
479
|
return this.rollup.read.getHasSubmitted([
|
|
205
480
|
BigInt(epochNumber),
|
|
206
|
-
BigInt(
|
|
207
|
-
prover
|
|
481
|
+
BigInt(numberOfCheckpointsInEpoch),
|
|
482
|
+
prover
|
|
483
|
+
]);
|
|
484
|
+
}
|
|
485
|
+
getManaBaseFeeAt(timestamp, inFeeAsset) {
|
|
486
|
+
return this.rollup.read.getManaBaseFeeAt([
|
|
487
|
+
timestamp,
|
|
488
|
+
inFeeAsset
|
|
489
|
+
]);
|
|
490
|
+
}
|
|
491
|
+
async getSlotAt(timestamp) {
|
|
492
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
493
|
+
timestamp
|
|
494
|
+
]));
|
|
495
|
+
}
|
|
496
|
+
async status(checkpointNumber, options) {
|
|
497
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
498
|
+
return this.rollup.read.status([
|
|
499
|
+
BigInt(checkpointNumber)
|
|
500
|
+
], options);
|
|
501
|
+
}
|
|
502
|
+
async canPruneAtTime(timestamp, options) {
|
|
503
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
504
|
+
return this.rollup.read.canPruneAtTime([
|
|
505
|
+
timestamp
|
|
506
|
+
], options);
|
|
507
|
+
}
|
|
508
|
+
archive() {
|
|
509
|
+
return this.rollup.read.archive();
|
|
510
|
+
}
|
|
511
|
+
archiveAt(checkpointNumber) {
|
|
512
|
+
return this.rollup.read.archiveAt([
|
|
513
|
+
BigInt(checkpointNumber)
|
|
208
514
|
]);
|
|
209
515
|
}
|
|
516
|
+
getSequencerRewards(address) {
|
|
517
|
+
if (address instanceof EthAddress) {
|
|
518
|
+
address = address.toString();
|
|
519
|
+
}
|
|
520
|
+
return this.rollup.read.getSequencerRewards([
|
|
521
|
+
address
|
|
522
|
+
]);
|
|
523
|
+
}
|
|
524
|
+
getSpecificProverRewardsForEpoch(epoch, prover) {
|
|
525
|
+
if (prover instanceof EthAddress) {
|
|
526
|
+
prover = prover.toString();
|
|
527
|
+
}
|
|
528
|
+
return this.rollup.read.getSpecificProverRewardsForEpoch([
|
|
529
|
+
epoch,
|
|
530
|
+
prover
|
|
531
|
+
]);
|
|
532
|
+
}
|
|
533
|
+
async getAttesters() {
|
|
534
|
+
const attesterSize = await this.getActiveAttesterCount();
|
|
535
|
+
const gse = new GSEContract(this.client, await this.getGSE());
|
|
536
|
+
const ts = (await this.client.getBlock()).timestamp;
|
|
537
|
+
const indices = Array.from({
|
|
538
|
+
length: Number(attesterSize)
|
|
539
|
+
}, (_, i)=>BigInt(i));
|
|
540
|
+
const chunks = chunk(indices, 1000);
|
|
541
|
+
return (await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)))).flat();
|
|
542
|
+
}
|
|
543
|
+
getAttesterView(address) {
|
|
544
|
+
if (address instanceof EthAddress) {
|
|
545
|
+
address = address.toString();
|
|
546
|
+
}
|
|
547
|
+
return this.rollup.read.getAttesterView([
|
|
548
|
+
address
|
|
549
|
+
]);
|
|
550
|
+
}
|
|
551
|
+
getStatus(address) {
|
|
552
|
+
if (address instanceof EthAddress) {
|
|
553
|
+
address = address.toString();
|
|
554
|
+
}
|
|
555
|
+
return this.rollup.read.getStatus([
|
|
556
|
+
address
|
|
557
|
+
]);
|
|
558
|
+
}
|
|
559
|
+
getBlobCommitmentsHash(checkpointNumber) {
|
|
560
|
+
return this.rollup.read.getBlobCommitmentsHash([
|
|
561
|
+
BigInt(checkpointNumber)
|
|
562
|
+
]);
|
|
563
|
+
}
|
|
564
|
+
getCurrentBlobCommitmentsHash() {
|
|
565
|
+
return this.rollup.read.getCurrentBlobCommitmentsHash();
|
|
566
|
+
}
|
|
567
|
+
getStakingAsset() {
|
|
568
|
+
return this.rollup.read.getStakingAsset();
|
|
569
|
+
}
|
|
570
|
+
getRewardConfig() {
|
|
571
|
+
return this.rollup.read.getRewardConfig();
|
|
572
|
+
}
|
|
573
|
+
setupEpoch(l1TxUtils) {
|
|
574
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
575
|
+
to: this.address,
|
|
576
|
+
data: encodeFunctionData({
|
|
577
|
+
abi: RollupAbi,
|
|
578
|
+
functionName: 'setupEpoch',
|
|
579
|
+
args: []
|
|
580
|
+
})
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
vote(l1TxUtils, proposalId) {
|
|
584
|
+
return l1TxUtils.sendAndMonitorTransaction({
|
|
585
|
+
to: this.address,
|
|
586
|
+
data: encodeFunctionData({
|
|
587
|
+
abi: RollupAbi,
|
|
588
|
+
functionName: 'vote',
|
|
589
|
+
args: [
|
|
590
|
+
proposalId
|
|
591
|
+
]
|
|
592
|
+
})
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
listenToSlasherChanged(callback) {
|
|
596
|
+
return this.rollup.watchEvent.SlasherUpdated({}, {
|
|
597
|
+
onLogs: (logs)=>{
|
|
598
|
+
for (const log of logs){
|
|
599
|
+
const args = log.args;
|
|
600
|
+
if (args.oldSlasher && args.newSlasher) {
|
|
601
|
+
callback(args);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
listenToCheckpointInvalidated(callback) {
|
|
608
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
609
|
+
onLogs: (logs)=>{
|
|
610
|
+
for (const log of logs){
|
|
611
|
+
const args = log.args;
|
|
612
|
+
if (args.checkpointNumber !== undefined) {
|
|
613
|
+
callback({
|
|
614
|
+
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber)
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
async getSlashEvents(l1BlockHash) {
|
|
622
|
+
const events = await this.rollup.getEvents.Slashed({}, {
|
|
623
|
+
blockHash: l1BlockHash,
|
|
624
|
+
strict: true
|
|
625
|
+
});
|
|
626
|
+
return events.map((event)=>({
|
|
627
|
+
amount: event.args.amount,
|
|
628
|
+
attester: EthAddress.fromString(event.args.attester)
|
|
629
|
+
}));
|
|
630
|
+
}
|
|
631
|
+
listenToSlash(callback) {
|
|
632
|
+
return this.rollup.watchEvent.Slashed({}, {
|
|
633
|
+
strict: true,
|
|
634
|
+
onLogs: (logs)=>{
|
|
635
|
+
for (const log of logs){
|
|
636
|
+
const args = log.args;
|
|
637
|
+
callback({
|
|
638
|
+
amount: args.amount,
|
|
639
|
+
attester: EthAddress.fromString(args.attester)
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
}
|
|
210
645
|
}
|
|
211
|
-
_ts_decorate([
|
|
212
|
-
memoize
|
|
213
|
-
], RollupContract.prototype, "getSlashingProposer", null);
|
|
214
646
|
_ts_decorate([
|
|
215
647
|
memoize
|
|
216
648
|
], RollupContract.prototype, "getL1StartBlock", null);
|
|
@@ -219,7 +651,7 @@ _ts_decorate([
|
|
|
219
651
|
], RollupContract.prototype, "getL1GenesisTime", null);
|
|
220
652
|
_ts_decorate([
|
|
221
653
|
memoize
|
|
222
|
-
], RollupContract.prototype, "
|
|
654
|
+
], RollupContract.prototype, "getProofSubmissionEpochs", null);
|
|
223
655
|
_ts_decorate([
|
|
224
656
|
memoize
|
|
225
657
|
], RollupContract.prototype, "getEpochDuration", null);
|
|
@@ -231,4 +663,40 @@ _ts_decorate([
|
|
|
231
663
|
], RollupContract.prototype, "getTargetCommitteeSize", null);
|
|
232
664
|
_ts_decorate([
|
|
233
665
|
memoize
|
|
234
|
-
], RollupContract.prototype, "
|
|
666
|
+
], RollupContract.prototype, "getEjectionThreshold", null);
|
|
667
|
+
_ts_decorate([
|
|
668
|
+
memoize
|
|
669
|
+
], RollupContract.prototype, "getLocalEjectionThreshold", null);
|
|
670
|
+
_ts_decorate([
|
|
671
|
+
memoize
|
|
672
|
+
], RollupContract.prototype, "getLagInEpochsForValidatorSet", null);
|
|
673
|
+
_ts_decorate([
|
|
674
|
+
memoize
|
|
675
|
+
], RollupContract.prototype, "getLagInEpochsForRandao", null);
|
|
676
|
+
_ts_decorate([
|
|
677
|
+
memoize
|
|
678
|
+
], RollupContract.prototype, "getActivationThreshold", null);
|
|
679
|
+
_ts_decorate([
|
|
680
|
+
memoize
|
|
681
|
+
], RollupContract.prototype, "getExitDelay", null);
|
|
682
|
+
_ts_decorate([
|
|
683
|
+
memoize
|
|
684
|
+
], RollupContract.prototype, "getManaTarget", null);
|
|
685
|
+
_ts_decorate([
|
|
686
|
+
memoize
|
|
687
|
+
], RollupContract.prototype, "getProvingCostPerMana", null);
|
|
688
|
+
_ts_decorate([
|
|
689
|
+
memoize
|
|
690
|
+
], RollupContract.prototype, "getProvingCostPerManaInFeeAsset", null);
|
|
691
|
+
_ts_decorate([
|
|
692
|
+
memoize
|
|
693
|
+
], RollupContract.prototype, "getManaLimit", null);
|
|
694
|
+
_ts_decorate([
|
|
695
|
+
memoize
|
|
696
|
+
], RollupContract.prototype, "getVersion", null);
|
|
697
|
+
_ts_decorate([
|
|
698
|
+
memoize
|
|
699
|
+
], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
|
|
700
|
+
_ts_decorate([
|
|
701
|
+
memoize
|
|
702
|
+
], RollupContract.prototype, "getRollupConstants", null);
|