@aztec/ethereum 0.0.1-commit.d3ec352c → 0.0.1-commit.d6f2b3f94
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/client.js +6 -2
- package/dest/config.d.ts +19 -68
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +52 -379
- package/dest/contracts/empire_base.d.ts +2 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +2 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +22 -15
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +11 -1
- package/dest/contracts/governance_proposer.d.ts +2 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +395 -9
- package/dest/contracts/inbox.d.ts +24 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +36 -1
- package/dest/contracts/index.d.ts +3 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +1 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +164 -83
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +691 -132
- package/dest/contracts/tally_slashing_proposer.d.ts +3 -2
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +8 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +260 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +399 -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/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +4964 -1573
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +1 -1
- 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 +3 -3
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +17 -3
- package/dest/l1_tx_utils/constants.d.ts +8 -2
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +27 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -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 +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -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 +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -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 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +23 -10
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +53 -160
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +12 -4
- package/dest/test/chain_monitor.d.ts +2 -2
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +4 -2
- package/dest/test/rollup_cheat_codes.d.ts +6 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +26 -4
- package/dest/test/start_anvil.d.ts +3 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +1 -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/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +64 -0
- package/package.json +31 -12
- package/src/client.ts +2 -2
- package/src/config.ts +63 -458
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +1 -1
- package/src/contracts/empire_slashing_proposer.ts +22 -28
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/governance.ts +10 -1
- package/src/contracts/governance_proposer.ts +10 -2
- package/src/contracts/inbox.ts +55 -3
- package/src/contracts/index.ts +2 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +366 -102
- package/src/contracts/tally_slashing_proposer.ts +7 -1
- package/src/deploy_aztec_l1_contracts.ts +623 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_contract_addresses.ts +22 -20
- package/src/l1_reader.ts +8 -0
- package/src/l1_tx_utils/config.ts +24 -6
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -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 +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +30 -10
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +67 -206
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +11 -3
- package/src/test/chain_monitor.ts +3 -2
- package/src/test/eth_cheat_codes.ts +2 -2
- package/src/test/rollup_cheat_codes.ts +24 -5
- package/src/test/start_anvil.ts +3 -1
- package/src/test/tx_delayer.ts +5 -3
- package/src/types.ts +62 -0
- package/src/utils.ts +83 -1
- package/dest/deploy_l1_contracts.d.ts +0 -673
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1491
- 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 -1869
- package/src/index.ts +0 -17
package/src/contracts/rollup.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import { memoize } from '@aztec/foundation/decorators';
|
|
3
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
6
|
import type { ViemSignature } from '@aztec/foundation/eth-signature';
|
|
7
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
8
|
+
import { EscapeHatchAbi } from '@aztec/l1-artifacts/EscapeHatchAbi';
|
|
5
9
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
10
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
7
11
|
|
|
@@ -19,7 +23,7 @@ import {
|
|
|
19
23
|
} from 'viem';
|
|
20
24
|
|
|
21
25
|
import { getPublicClient } from '../client.js';
|
|
22
|
-
import type {
|
|
26
|
+
import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
|
|
23
27
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
24
28
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
25
29
|
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
@@ -27,6 +31,7 @@ import type { ViemClient } from '../types.js';
|
|
|
27
31
|
import { formatViemError } from '../utils.js';
|
|
28
32
|
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
29
33
|
import { GSEContract } from './gse.js';
|
|
34
|
+
import type { L1EventLog } from './log.js';
|
|
30
35
|
import { SlasherContract } from './slasher_contract.js';
|
|
31
36
|
import { TallySlashingProposerContract } from './tally_slashing_proposer.js';
|
|
32
37
|
import { checkBlockTag } from './utils.js';
|
|
@@ -57,13 +62,16 @@ export type L1RollupContractAddresses = Pick<
|
|
|
57
62
|
export type EpochProofPublicInputArgs = {
|
|
58
63
|
previousArchive: `0x${string}`;
|
|
59
64
|
endArchive: `0x${string}`;
|
|
65
|
+
outHash: `0x${string}`;
|
|
60
66
|
proverId: `0x${string}`;
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
export type ViemHeader = {
|
|
64
70
|
lastArchiveRoot: `0x${string}`;
|
|
65
71
|
blockHeadersHash: `0x${string}`;
|
|
66
|
-
|
|
72
|
+
blobsHash: `0x${string}`;
|
|
73
|
+
inHash: `0x${string}`;
|
|
74
|
+
outHash: `0x${string}`;
|
|
67
75
|
slotNumber: bigint;
|
|
68
76
|
timestamp: bigint;
|
|
69
77
|
coinbase: `0x${string}`;
|
|
@@ -72,12 +80,6 @@ export type ViemHeader = {
|
|
|
72
80
|
totalManaUsed: bigint;
|
|
73
81
|
};
|
|
74
82
|
|
|
75
|
-
export type ViemContentCommitment = {
|
|
76
|
-
blobsHash: `0x${string}`;
|
|
77
|
-
inHash: `0x${string}`;
|
|
78
|
-
outHash: `0x${string}`;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
83
|
export type ViemGasFees = {
|
|
82
84
|
feePerDaGas: bigint;
|
|
83
85
|
feePerL2Gas: bigint;
|
|
@@ -89,10 +91,125 @@ export enum SlashingProposerType {
|
|
|
89
91
|
Empire = 2,
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Status of a validator/attester in the staking system.
|
|
96
|
+
* Matches the Status enum in StakingLib.sol
|
|
97
|
+
*/
|
|
98
|
+
export enum AttesterStatus {
|
|
99
|
+
NONE = 0,
|
|
100
|
+
VALIDATING = 1,
|
|
101
|
+
ZOMBIE = 2,
|
|
102
|
+
EXITING = 3,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Fee header data for a checkpoint
|
|
107
|
+
*/
|
|
108
|
+
export type FeeHeader = {
|
|
109
|
+
excessMana: bigint;
|
|
110
|
+
manaUsed: bigint;
|
|
111
|
+
ethPerFeeAsset: bigint;
|
|
112
|
+
congestionCost: bigint;
|
|
113
|
+
proverCost: bigint;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Checkpoint log data returned from the rollup contract
|
|
118
|
+
*/
|
|
119
|
+
export type CheckpointLog = {
|
|
120
|
+
archive: Fr;
|
|
121
|
+
headerHash: Buffer32;
|
|
122
|
+
blobCommitmentsHash: Buffer32;
|
|
123
|
+
attestationsHash: Buffer32;
|
|
124
|
+
payloadDigest: Buffer32;
|
|
125
|
+
slotNumber: SlotNumber;
|
|
126
|
+
feeHeader: FeeHeader;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* L1 fee data (base fee and blob fee)
|
|
131
|
+
*/
|
|
132
|
+
export type L1FeeData = {
|
|
133
|
+
baseFee: bigint;
|
|
134
|
+
blobFee: bigint;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Reward configuration for the rollup
|
|
139
|
+
*/
|
|
140
|
+
export type RewardConfig = {
|
|
141
|
+
rewardDistributor: EthAddress;
|
|
142
|
+
sequencerBps: bigint;
|
|
143
|
+
booster: EthAddress;
|
|
144
|
+
checkpointReward: bigint;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Exit information for a validator
|
|
149
|
+
*/
|
|
150
|
+
export type Exit = {
|
|
151
|
+
withdrawalId: bigint;
|
|
152
|
+
amount: bigint;
|
|
153
|
+
exitableAt: bigint;
|
|
154
|
+
recipientOrWithdrawer: EthAddress;
|
|
155
|
+
isRecipient: boolean;
|
|
156
|
+
exists: boolean;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Attester configuration including public key and withdrawer
|
|
161
|
+
*/
|
|
162
|
+
export type AttesterConfig = {
|
|
163
|
+
publicKey: {
|
|
164
|
+
x: bigint;
|
|
165
|
+
y: bigint;
|
|
166
|
+
};
|
|
167
|
+
withdrawer: EthAddress;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Complete view of an attester's state
|
|
172
|
+
*/
|
|
173
|
+
export type AttesterView = {
|
|
174
|
+
status: AttesterStatus;
|
|
175
|
+
effectiveBalance: bigint;
|
|
176
|
+
exit: Exit;
|
|
177
|
+
config: AttesterConfig;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Return for a status call
|
|
182
|
+
*/
|
|
183
|
+
export type RollupStatusResponse = {
|
|
184
|
+
provenCheckpointNumber: CheckpointNumber;
|
|
185
|
+
provenArchive: Fr;
|
|
186
|
+
pendingCheckpointNumber: CheckpointNumber;
|
|
187
|
+
pendingArchive: Fr;
|
|
188
|
+
archiveOfMyCheckpoint: Fr;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** Arguments for the CheckpointProposed event. */
|
|
192
|
+
export type CheckpointProposedArgs = {
|
|
193
|
+
checkpointNumber: CheckpointNumber;
|
|
194
|
+
archive: Fr;
|
|
195
|
+
versionedBlobHashes: Buffer[];
|
|
196
|
+
/** Hash of attestations. Undefined for older events (backwards compatibility). */
|
|
197
|
+
attestationsHash?: Buffer32;
|
|
198
|
+
/** Digest of the payload. Undefined for older events (backwards compatibility). */
|
|
199
|
+
payloadDigest?: Buffer32;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/** Log type for CheckpointProposed events. */
|
|
203
|
+
export type CheckpointProposedLog = L1EventLog<CheckpointProposedArgs>;
|
|
204
|
+
|
|
92
205
|
export class RollupContract {
|
|
93
206
|
private readonly rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
94
207
|
|
|
95
208
|
private static cachedStfStorageSlot: Hex | undefined;
|
|
209
|
+
private cachedEscapeHatch?: {
|
|
210
|
+
address: EthAddress;
|
|
211
|
+
contract: GetContractReturnType<typeof EscapeHatchAbi, ViemClient>;
|
|
212
|
+
};
|
|
96
213
|
|
|
97
214
|
static get checkBlobStorageSlot(): bigint {
|
|
98
215
|
const asString = RollupStorage.find(storage => storage.label === 'checkBlob')?.slot;
|
|
@@ -106,7 +223,7 @@ export class RollupContract {
|
|
|
106
223
|
return (RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8')));
|
|
107
224
|
}
|
|
108
225
|
|
|
109
|
-
static getFromL1ContractsValues(deployL1ContractsValues:
|
|
226
|
+
static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
|
|
110
227
|
const {
|
|
111
228
|
l1Client,
|
|
112
229
|
l1ContractAddresses: { rollupAddress },
|
|
@@ -130,8 +247,8 @@ export class RollupContract {
|
|
|
130
247
|
this.rollup = getContract({ address, abi: RollupAbi, client });
|
|
131
248
|
}
|
|
132
249
|
|
|
133
|
-
getGSE() {
|
|
134
|
-
return this.rollup.read.getGSE();
|
|
250
|
+
async getGSE(): Promise<EthAddress> {
|
|
251
|
+
return EthAddress.fromString(await this.rollup.read.getGSE());
|
|
135
252
|
}
|
|
136
253
|
|
|
137
254
|
public get address() {
|
|
@@ -173,23 +290,23 @@ export class RollupContract {
|
|
|
173
290
|
}
|
|
174
291
|
|
|
175
292
|
@memoize
|
|
176
|
-
getL1StartBlock() {
|
|
293
|
+
getL1StartBlock(): Promise<bigint> {
|
|
177
294
|
return this.rollup.read.L1_BLOCK_AT_GENESIS();
|
|
178
295
|
}
|
|
179
296
|
|
|
180
297
|
@memoize
|
|
181
|
-
getL1GenesisTime() {
|
|
298
|
+
getL1GenesisTime(): Promise<bigint> {
|
|
182
299
|
return this.rollup.read.getGenesisTime();
|
|
183
300
|
}
|
|
184
301
|
|
|
185
302
|
@memoize
|
|
186
|
-
getProofSubmissionEpochs() {
|
|
187
|
-
return this.rollup.read.getProofSubmissionEpochs();
|
|
303
|
+
async getProofSubmissionEpochs(): Promise<number> {
|
|
304
|
+
return Number(await this.rollup.read.getProofSubmissionEpochs());
|
|
188
305
|
}
|
|
189
306
|
|
|
190
307
|
@memoize
|
|
191
|
-
getEpochDuration() {
|
|
192
|
-
return this.rollup.read.getEpochDuration();
|
|
308
|
+
async getEpochDuration(): Promise<number> {
|
|
309
|
+
return Number(await this.rollup.read.getEpochDuration());
|
|
193
310
|
}
|
|
194
311
|
|
|
195
312
|
@memoize
|
|
@@ -198,68 +315,68 @@ export class RollupContract {
|
|
|
198
315
|
}
|
|
199
316
|
|
|
200
317
|
@memoize
|
|
201
|
-
getTargetCommitteeSize() {
|
|
202
|
-
return this.rollup.read.getTargetCommitteeSize();
|
|
318
|
+
async getTargetCommitteeSize(): Promise<number> {
|
|
319
|
+
return Number(await this.rollup.read.getTargetCommitteeSize());
|
|
203
320
|
}
|
|
204
321
|
|
|
205
322
|
@memoize
|
|
206
|
-
getEjectionThreshold() {
|
|
323
|
+
getEjectionThreshold(): Promise<bigint> {
|
|
207
324
|
return this.rollup.read.getEjectionThreshold();
|
|
208
325
|
}
|
|
209
326
|
|
|
210
327
|
@memoize
|
|
211
|
-
getLocalEjectionThreshold() {
|
|
328
|
+
getLocalEjectionThreshold(): Promise<bigint> {
|
|
212
329
|
return this.rollup.read.getLocalEjectionThreshold();
|
|
213
330
|
}
|
|
214
331
|
|
|
215
332
|
@memoize
|
|
216
|
-
getLagInEpochsForValidatorSet() {
|
|
217
|
-
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
333
|
+
async getLagInEpochsForValidatorSet(): Promise<number> {
|
|
334
|
+
return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
|
|
218
335
|
}
|
|
219
336
|
|
|
220
337
|
@memoize
|
|
221
|
-
getLagInEpochsForRandao() {
|
|
222
|
-
return this.rollup.read.getLagInEpochsForRandao();
|
|
338
|
+
async getLagInEpochsForRandao(): Promise<number> {
|
|
339
|
+
return Number(await this.rollup.read.getLagInEpochsForRandao());
|
|
223
340
|
}
|
|
224
341
|
|
|
225
342
|
@memoize
|
|
226
|
-
getActivationThreshold() {
|
|
343
|
+
getActivationThreshold(): Promise<bigint> {
|
|
227
344
|
return this.rollup.read.getActivationThreshold();
|
|
228
345
|
}
|
|
229
346
|
|
|
230
347
|
@memoize
|
|
231
|
-
getExitDelay() {
|
|
232
|
-
return this.rollup.read.getExitDelay();
|
|
348
|
+
async getExitDelay(): Promise<number> {
|
|
349
|
+
return Number(await this.rollup.read.getExitDelay());
|
|
233
350
|
}
|
|
234
351
|
|
|
235
352
|
@memoize
|
|
236
|
-
getManaTarget() {
|
|
353
|
+
getManaTarget(): Promise<bigint> {
|
|
237
354
|
return this.rollup.read.getManaTarget();
|
|
238
355
|
}
|
|
239
356
|
|
|
240
357
|
@memoize
|
|
241
|
-
getProvingCostPerMana() {
|
|
358
|
+
getProvingCostPerMana(): Promise<bigint> {
|
|
242
359
|
return this.rollup.read.getProvingCostPerManaInEth();
|
|
243
360
|
}
|
|
244
361
|
|
|
245
362
|
@memoize
|
|
246
|
-
getProvingCostPerManaInFeeAsset() {
|
|
363
|
+
getProvingCostPerManaInFeeAsset(): Promise<bigint> {
|
|
247
364
|
return this.rollup.read.getProvingCostPerManaInFeeAsset();
|
|
248
365
|
}
|
|
249
366
|
|
|
250
367
|
@memoize
|
|
251
|
-
getManaLimit() {
|
|
368
|
+
getManaLimit(): Promise<bigint> {
|
|
252
369
|
return this.rollup.read.getManaLimit();
|
|
253
370
|
}
|
|
254
371
|
|
|
255
372
|
@memoize
|
|
256
|
-
getVersion() {
|
|
373
|
+
getVersion(): Promise<bigint> {
|
|
257
374
|
return this.rollup.read.getVersion();
|
|
258
375
|
}
|
|
259
376
|
|
|
260
377
|
@memoize
|
|
261
|
-
async getGenesisArchiveTreeRoot(): Promise
|
|
262
|
-
return await this.rollup.read.archiveAt([0n]);
|
|
378
|
+
async getGenesisArchiveTreeRoot(): Promise<Fr> {
|
|
379
|
+
return Fr.fromString(await this.rollup.read.archiveAt([0n]));
|
|
263
380
|
}
|
|
264
381
|
|
|
265
382
|
/**
|
|
@@ -274,44 +391,100 @@ export class RollupContract {
|
|
|
274
391
|
slotDuration: number;
|
|
275
392
|
epochDuration: number;
|
|
276
393
|
proofSubmissionEpochs: number;
|
|
394
|
+
targetCommitteeSize: number;
|
|
277
395
|
}> {
|
|
278
|
-
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] =
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
396
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs, targetCommitteeSize] =
|
|
397
|
+
await Promise.all([
|
|
398
|
+
this.getL1StartBlock(),
|
|
399
|
+
this.getL1GenesisTime(),
|
|
400
|
+
this.getSlotDuration(),
|
|
401
|
+
this.getEpochDuration(),
|
|
402
|
+
this.getProofSubmissionEpochs(),
|
|
403
|
+
this.getTargetCommitteeSize(),
|
|
404
|
+
]);
|
|
285
405
|
return {
|
|
286
406
|
l1StartBlock,
|
|
287
407
|
l1GenesisTime,
|
|
288
408
|
slotDuration,
|
|
289
409
|
epochDuration: Number(epochDuration),
|
|
290
410
|
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
411
|
+
targetCommitteeSize,
|
|
291
412
|
};
|
|
292
413
|
}
|
|
293
414
|
|
|
294
|
-
getSlasherAddress() {
|
|
295
|
-
return this.rollup.read.getSlasher();
|
|
415
|
+
async getSlasherAddress(): Promise<EthAddress> {
|
|
416
|
+
return EthAddress.fromString(await this.rollup.read.getSlasher());
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Returns the configured escape hatch contract address, or zero if disabled.
|
|
421
|
+
*/
|
|
422
|
+
async getEscapeHatchAddress(): Promise<EthAddress> {
|
|
423
|
+
return EthAddress.fromString(await this.rollup.read.getEscapeHatch());
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private async getEscapeHatchContract(): Promise<
|
|
427
|
+
GetContractReturnType<typeof EscapeHatchAbi, ViemClient> | undefined
|
|
428
|
+
> {
|
|
429
|
+
const escapeHatchAddress = await this.getEscapeHatchAddress();
|
|
430
|
+
if (escapeHatchAddress.isZero()) {
|
|
431
|
+
return undefined;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Cache the viem contract wrapper since it will be used frequently.
|
|
435
|
+
if (!this.cachedEscapeHatch || !this.cachedEscapeHatch.address.equals(escapeHatchAddress)) {
|
|
436
|
+
this.cachedEscapeHatch = {
|
|
437
|
+
address: escapeHatchAddress,
|
|
438
|
+
contract: getContract({
|
|
439
|
+
address: escapeHatchAddress.toString(),
|
|
440
|
+
abi: EscapeHatchAbi,
|
|
441
|
+
client: this.client,
|
|
442
|
+
}),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return this.cachedEscapeHatch.contract;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Returns whether the escape hatch is open for the given epoch.
|
|
451
|
+
* If escape hatch is not configured, returns false.
|
|
452
|
+
*
|
|
453
|
+
* This function is intentionally defensive: any failure to query the escape hatch
|
|
454
|
+
* (RPC issues, transient errors, etc.) is treated as "closed" to avoid callers
|
|
455
|
+
* needing to sprinkle try/catch everywhere.
|
|
456
|
+
*/
|
|
457
|
+
async isEscapeHatchOpen(epoch: EpochNumber): Promise<boolean> {
|
|
458
|
+
try {
|
|
459
|
+
const escapeHatch = await this.getEscapeHatchContract();
|
|
460
|
+
if (!escapeHatch) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const [isOpen] = await escapeHatch.read.isHatchOpen([BigInt(epoch)]);
|
|
465
|
+
return isOpen;
|
|
466
|
+
} catch {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
296
469
|
}
|
|
297
470
|
|
|
298
471
|
/**
|
|
299
472
|
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
300
473
|
*/
|
|
301
474
|
async getSlasherContract(): Promise<SlasherContract | undefined> {
|
|
302
|
-
const slasherAddress =
|
|
475
|
+
const slasherAddress = await this.getSlasherAddress();
|
|
303
476
|
if (slasherAddress.isZero()) {
|
|
304
477
|
return undefined;
|
|
305
478
|
}
|
|
306
479
|
return new SlasherContract(this.client, slasherAddress);
|
|
307
480
|
}
|
|
308
481
|
|
|
309
|
-
getOwner() {
|
|
310
|
-
return this.rollup.read.owner();
|
|
482
|
+
async getOwner(): Promise<EthAddress> {
|
|
483
|
+
return EthAddress.fromString(await this.rollup.read.owner());
|
|
311
484
|
}
|
|
312
485
|
|
|
313
|
-
getActiveAttesterCount() {
|
|
314
|
-
return this.rollup.read.getActiveAttesterCount();
|
|
486
|
+
async getActiveAttesterCount(): Promise<number> {
|
|
487
|
+
return Number(await this.rollup.read.getActiveAttesterCount());
|
|
315
488
|
}
|
|
316
489
|
|
|
317
490
|
public async getSlashingProposerAddress() {
|
|
@@ -322,7 +495,7 @@ export class RollupContract {
|
|
|
322
495
|
return await slasher.getProposer();
|
|
323
496
|
}
|
|
324
497
|
|
|
325
|
-
getCheckpointReward() {
|
|
498
|
+
getCheckpointReward(): Promise<bigint> {
|
|
326
499
|
return this.rollup.read.getCheckpointReward();
|
|
327
500
|
}
|
|
328
501
|
|
|
@@ -338,15 +511,19 @@ export class RollupContract {
|
|
|
338
511
|
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
339
512
|
}
|
|
340
513
|
|
|
341
|
-
getL1FeesAt(timestamp: bigint) {
|
|
342
|
-
|
|
514
|
+
async getL1FeesAt(timestamp: bigint): Promise<L1FeeData> {
|
|
515
|
+
const result = await this.rollup.read.getL1FeesAt([timestamp]);
|
|
516
|
+
return {
|
|
517
|
+
baseFee: result.baseFee,
|
|
518
|
+
blobFee: result.blobFee,
|
|
519
|
+
};
|
|
343
520
|
}
|
|
344
521
|
|
|
345
|
-
|
|
346
|
-
return this.rollup.read.
|
|
522
|
+
getEthPerFeeAsset(): Promise<bigint> {
|
|
523
|
+
return this.rollup.read.getEthPerFeeAsset();
|
|
347
524
|
}
|
|
348
525
|
|
|
349
|
-
async getCommitteeAt(timestamp: bigint): Promise<
|
|
526
|
+
async getCommitteeAt(timestamp: bigint): Promise<EthAddress[] | undefined> {
|
|
350
527
|
const { result } = await this.client
|
|
351
528
|
.simulateContract({
|
|
352
529
|
address: this.address,
|
|
@@ -361,22 +538,22 @@ export class RollupContract {
|
|
|
361
538
|
throw e;
|
|
362
539
|
});
|
|
363
540
|
|
|
364
|
-
return result;
|
|
541
|
+
return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
|
|
365
542
|
}
|
|
366
543
|
|
|
367
|
-
getSampleSeedAt(timestamp: bigint) {
|
|
368
|
-
return this.rollup.read.getSampleSeedAt([timestamp]);
|
|
544
|
+
async getSampleSeedAt(timestamp: bigint): Promise<Buffer32> {
|
|
545
|
+
return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([timestamp]));
|
|
369
546
|
}
|
|
370
547
|
|
|
371
|
-
getCurrentSampleSeed() {
|
|
372
|
-
return this.rollup.read.getCurrentSampleSeed();
|
|
548
|
+
async getCurrentSampleSeed(): Promise<Buffer32> {
|
|
549
|
+
return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
|
|
373
550
|
}
|
|
374
551
|
|
|
375
552
|
async getCurrentEpoch(): Promise<EpochNumber> {
|
|
376
553
|
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
377
554
|
}
|
|
378
555
|
|
|
379
|
-
async getCurrentEpochCommittee(): Promise<
|
|
556
|
+
async getCurrentEpochCommittee(): Promise<EthAddress[] | undefined> {
|
|
380
557
|
const { result } = await this.client
|
|
381
558
|
.simulateContract({
|
|
382
559
|
address: this.address,
|
|
@@ -391,10 +568,10 @@ export class RollupContract {
|
|
|
391
568
|
throw e;
|
|
392
569
|
});
|
|
393
570
|
|
|
394
|
-
return result;
|
|
571
|
+
return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
|
|
395
572
|
}
|
|
396
573
|
|
|
397
|
-
async getCurrentProposer() {
|
|
574
|
+
async getCurrentProposer(): Promise<EthAddress> {
|
|
398
575
|
const { result } = await this.client.simulateContract({
|
|
399
576
|
address: this.address,
|
|
400
577
|
abi: RollupAbi,
|
|
@@ -402,10 +579,10 @@ export class RollupContract {
|
|
|
402
579
|
args: [],
|
|
403
580
|
});
|
|
404
581
|
|
|
405
|
-
return result;
|
|
582
|
+
return EthAddress.fromString(result);
|
|
406
583
|
}
|
|
407
584
|
|
|
408
|
-
async getProposerAt(timestamp: bigint) {
|
|
585
|
+
async getProposerAt(timestamp: bigint): Promise<EthAddress> {
|
|
409
586
|
const { result } = await this.client.simulateContract({
|
|
410
587
|
address: this.address,
|
|
411
588
|
abi: RollupAbi,
|
|
@@ -413,11 +590,41 @@ export class RollupContract {
|
|
|
413
590
|
args: [timestamp],
|
|
414
591
|
});
|
|
415
592
|
|
|
416
|
-
return result;
|
|
593
|
+
return EthAddress.fromString(result);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
|
|
597
|
+
const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
598
|
+
return {
|
|
599
|
+
archive: Fr.fromString(result.archive),
|
|
600
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
601
|
+
blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
|
|
602
|
+
attestationsHash: Buffer32.fromString(result.attestationsHash),
|
|
603
|
+
payloadDigest: Buffer32.fromString(result.payloadDigest),
|
|
604
|
+
slotNumber: SlotNumber.fromBigInt(result.slotNumber),
|
|
605
|
+
feeHeader: {
|
|
606
|
+
excessMana: result.feeHeader.excessMana,
|
|
607
|
+
manaUsed: result.feeHeader.manaUsed,
|
|
608
|
+
ethPerFeeAsset: result.feeHeader.ethPerFeeAsset,
|
|
609
|
+
congestionCost: result.feeHeader.congestionCost,
|
|
610
|
+
proverCost: result.feeHeader.proverCost,
|
|
611
|
+
},
|
|
612
|
+
};
|
|
417
613
|
}
|
|
418
614
|
|
|
419
|
-
|
|
420
|
-
|
|
615
|
+
/** Returns the pending checkpoint from the rollup contract */
|
|
616
|
+
getPendingCheckpoint() {
|
|
617
|
+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
|
|
618
|
+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
|
|
619
|
+
return retry(
|
|
620
|
+
async () => {
|
|
621
|
+
const pendingCheckpointNumber = await this.getCheckpointNumber();
|
|
622
|
+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
|
|
623
|
+
return pendingCheckpoint;
|
|
624
|
+
},
|
|
625
|
+
'getting pending checkpoint',
|
|
626
|
+
makeBackoff([0.5, 0.5, 0.5]),
|
|
627
|
+
);
|
|
421
628
|
}
|
|
422
629
|
|
|
423
630
|
async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
|
|
@@ -428,16 +635,16 @@ export class RollupContract {
|
|
|
428
635
|
};
|
|
429
636
|
}
|
|
430
637
|
|
|
431
|
-
getTimestampForSlot(slot: SlotNumber) {
|
|
638
|
+
getTimestampForSlot(slot: SlotNumber): Promise<bigint> {
|
|
432
639
|
return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
|
|
433
640
|
}
|
|
434
641
|
|
|
435
|
-
getEntryQueueLength() {
|
|
436
|
-
return this.rollup.read.getEntryQueueLength();
|
|
642
|
+
async getEntryQueueLength(): Promise<number> {
|
|
643
|
+
return Number(await this.rollup.read.getEntryQueueLength());
|
|
437
644
|
}
|
|
438
645
|
|
|
439
|
-
getAvailableValidatorFlushes() {
|
|
440
|
-
return this.rollup.read.getAvailableValidatorFlushes();
|
|
646
|
+
async getAvailableValidatorFlushes(): Promise<number> {
|
|
647
|
+
return Number(await this.rollup.read.getAvailableValidatorFlushes());
|
|
441
648
|
}
|
|
442
649
|
|
|
443
650
|
async getNextFlushableEpoch(): Promise<EpochNumber> {
|
|
@@ -493,10 +700,11 @@ export class RollupContract {
|
|
|
493
700
|
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
494
701
|
}
|
|
495
702
|
|
|
496
|
-
getEpochProofPublicInputs(
|
|
703
|
+
async getEpochProofPublicInputs(
|
|
497
704
|
args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`],
|
|
498
|
-
) {
|
|
499
|
-
|
|
705
|
+
): Promise<Fr[]> {
|
|
706
|
+
const result = await this.rollup.read.getEpochProofPublicInputs(args);
|
|
707
|
+
return result.map(Fr.fromString);
|
|
500
708
|
}
|
|
501
709
|
|
|
502
710
|
public async validateHeader(
|
|
@@ -601,6 +809,7 @@ export class RollupContract {
|
|
|
601
809
|
): L1TxRequest {
|
|
602
810
|
return {
|
|
603
811
|
to: this.address,
|
|
812
|
+
abi: RollupAbi,
|
|
604
813
|
data: encodeFunctionData({
|
|
605
814
|
abi: RollupAbi,
|
|
606
815
|
functionName: 'invalidateBadAttestation',
|
|
@@ -622,6 +831,7 @@ export class RollupContract {
|
|
|
622
831
|
): L1TxRequest {
|
|
623
832
|
return {
|
|
624
833
|
to: this.address,
|
|
834
|
+
abi: RollupAbi,
|
|
625
835
|
data: encodeFunctionData({
|
|
626
836
|
abi: RollupAbi,
|
|
627
837
|
functionName: 'invalidateInsufficientAttestations',
|
|
@@ -638,90 +848,124 @@ export class RollupContract {
|
|
|
638
848
|
return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
|
|
639
849
|
}
|
|
640
850
|
|
|
641
|
-
|
|
642
|
-
return this.rollup.read.
|
|
851
|
+
getManaMinFeeAt(timestamp: bigint, inFeeAsset: boolean): Promise<bigint> {
|
|
852
|
+
return this.rollup.read.getManaMinFeeAt([timestamp, inFeeAsset]);
|
|
643
853
|
}
|
|
644
854
|
|
|
645
855
|
async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
|
|
646
856
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
|
|
647
857
|
}
|
|
648
858
|
|
|
649
|
-
async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
|
|
859
|
+
async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }): Promise<RollupStatusResponse> {
|
|
650
860
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
651
|
-
|
|
861
|
+
const result = await this.rollup.read.status([BigInt(checkpointNumber)], options);
|
|
862
|
+
return {
|
|
863
|
+
provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
|
|
864
|
+
provenArchive: Fr.fromString(result[1]),
|
|
865
|
+
pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
|
|
866
|
+
pendingArchive: Fr.fromString(result[3]),
|
|
867
|
+
archiveOfMyCheckpoint: Fr.fromString(result[4]),
|
|
868
|
+
};
|
|
652
869
|
}
|
|
653
870
|
|
|
654
|
-
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
|
|
871
|
+
async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }): Promise<boolean> {
|
|
655
872
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
656
873
|
return this.rollup.read.canPruneAtTime([timestamp], options);
|
|
657
874
|
}
|
|
658
875
|
|
|
659
|
-
archive() {
|
|
660
|
-
return this.rollup.read.archive();
|
|
876
|
+
async archive(): Promise<Fr> {
|
|
877
|
+
return Fr.fromString(await this.rollup.read.archive());
|
|
661
878
|
}
|
|
662
879
|
|
|
663
|
-
archiveAt(checkpointNumber: CheckpointNumber) {
|
|
664
|
-
return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
|
|
880
|
+
async archiveAt(checkpointNumber: CheckpointNumber): Promise<Fr> {
|
|
881
|
+
return Fr.fromString(await this.rollup.read.archiveAt([BigInt(checkpointNumber)]));
|
|
665
882
|
}
|
|
666
883
|
|
|
667
|
-
getSequencerRewards(address: Hex | EthAddress) {
|
|
884
|
+
getSequencerRewards(address: Hex | EthAddress): Promise<bigint> {
|
|
668
885
|
if (address instanceof EthAddress) {
|
|
669
886
|
address = address.toString();
|
|
670
887
|
}
|
|
671
888
|
return this.rollup.read.getSequencerRewards([address]);
|
|
672
889
|
}
|
|
673
890
|
|
|
674
|
-
getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress) {
|
|
891
|
+
getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress): Promise<bigint> {
|
|
675
892
|
if (prover instanceof EthAddress) {
|
|
676
893
|
prover = prover.toString();
|
|
677
894
|
}
|
|
678
895
|
return this.rollup.read.getSpecificProverRewardsForEpoch([epoch, prover]);
|
|
679
896
|
}
|
|
680
897
|
|
|
681
|
-
async getAttesters() {
|
|
898
|
+
async getAttesters(): Promise<EthAddress[]> {
|
|
682
899
|
const attesterSize = await this.getActiveAttesterCount();
|
|
683
900
|
const gse = new GSEContract(this.client, await this.getGSE());
|
|
684
901
|
const ts = (await this.client.getBlock()).timestamp;
|
|
685
902
|
|
|
686
|
-
const indices = Array.from({ length:
|
|
903
|
+
const indices = Array.from({ length: attesterSize }, (_, i) => BigInt(i));
|
|
687
904
|
const chunks = chunk(indices, 1000);
|
|
688
905
|
|
|
689
|
-
|
|
906
|
+
const results = await Promise.all(chunks.map(chunk => gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
|
|
907
|
+
return results.flat().map(addr => EthAddress.fromString(addr));
|
|
690
908
|
}
|
|
691
909
|
|
|
692
|
-
getAttesterView(address: Hex | EthAddress) {
|
|
910
|
+
async getAttesterView(address: Hex | EthAddress): Promise<AttesterView> {
|
|
693
911
|
if (address instanceof EthAddress) {
|
|
694
912
|
address = address.toString();
|
|
695
913
|
}
|
|
696
|
-
|
|
914
|
+
const result = await this.rollup.read.getAttesterView([address]);
|
|
915
|
+
return {
|
|
916
|
+
status: result.status as AttesterStatus,
|
|
917
|
+
effectiveBalance: result.effectiveBalance,
|
|
918
|
+
exit: {
|
|
919
|
+
withdrawalId: result.exit.withdrawalId,
|
|
920
|
+
amount: result.exit.amount,
|
|
921
|
+
exitableAt: result.exit.exitableAt,
|
|
922
|
+
recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
|
|
923
|
+
isRecipient: result.exit.isRecipient,
|
|
924
|
+
exists: result.exit.exists,
|
|
925
|
+
},
|
|
926
|
+
config: {
|
|
927
|
+
publicKey: {
|
|
928
|
+
x: result.config.publicKey.x,
|
|
929
|
+
y: result.config.publicKey.y,
|
|
930
|
+
},
|
|
931
|
+
withdrawer: EthAddress.fromString(result.config.withdrawer),
|
|
932
|
+
},
|
|
933
|
+
};
|
|
697
934
|
}
|
|
698
935
|
|
|
699
|
-
getStatus(address: Hex | EthAddress) {
|
|
936
|
+
async getStatus(address: Hex | EthAddress): Promise<AttesterStatus> {
|
|
700
937
|
if (address instanceof EthAddress) {
|
|
701
938
|
address = address.toString();
|
|
702
939
|
}
|
|
703
|
-
return this.rollup.read.getStatus([address]);
|
|
940
|
+
return (await this.rollup.read.getStatus([address])) as AttesterStatus;
|
|
704
941
|
}
|
|
705
942
|
|
|
706
|
-
getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
|
|
707
|
-
return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
|
|
943
|
+
async getBlobCommitmentsHash(checkpointNumber: CheckpointNumber): Promise<Buffer32> {
|
|
944
|
+
return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]));
|
|
708
945
|
}
|
|
709
946
|
|
|
710
|
-
getCurrentBlobCommitmentsHash() {
|
|
711
|
-
return this.rollup.read.getCurrentBlobCommitmentsHash();
|
|
947
|
+
async getCurrentBlobCommitmentsHash(): Promise<Buffer32> {
|
|
948
|
+
return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
|
|
712
949
|
}
|
|
713
950
|
|
|
714
|
-
getStakingAsset() {
|
|
715
|
-
return this.rollup.read.getStakingAsset();
|
|
951
|
+
async getStakingAsset(): Promise<EthAddress> {
|
|
952
|
+
return EthAddress.fromString(await this.rollup.read.getStakingAsset());
|
|
716
953
|
}
|
|
717
954
|
|
|
718
|
-
getRewardConfig() {
|
|
719
|
-
|
|
955
|
+
async getRewardConfig(): Promise<RewardConfig> {
|
|
956
|
+
const result = await this.rollup.read.getRewardConfig();
|
|
957
|
+
return {
|
|
958
|
+
rewardDistributor: EthAddress.fromString(result.rewardDistributor),
|
|
959
|
+
sequencerBps: BigInt(result.sequencerBps),
|
|
960
|
+
booster: EthAddress.fromString(result.booster),
|
|
961
|
+
checkpointReward: result.checkpointReward,
|
|
962
|
+
};
|
|
720
963
|
}
|
|
721
964
|
|
|
722
965
|
setupEpoch(l1TxUtils: L1TxUtils) {
|
|
723
966
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
724
967
|
to: this.address,
|
|
968
|
+
abi: RollupAbi,
|
|
725
969
|
data: encodeFunctionData({
|
|
726
970
|
abi: RollupAbi,
|
|
727
971
|
functionName: 'setupEpoch',
|
|
@@ -733,6 +977,7 @@ export class RollupContract {
|
|
|
733
977
|
vote(l1TxUtils: L1TxUtils, proposalId: bigint) {
|
|
734
978
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
735
979
|
to: this.address,
|
|
980
|
+
abi: RollupAbi,
|
|
736
981
|
data: encodeFunctionData({
|
|
737
982
|
abi: RollupAbi,
|
|
738
983
|
functionName: 'vote',
|
|
@@ -801,4 +1046,23 @@ export class RollupContract {
|
|
|
801
1046
|
},
|
|
802
1047
|
);
|
|
803
1048
|
}
|
|
1049
|
+
|
|
1050
|
+
/** Fetches CheckpointProposed events within the given block range. */
|
|
1051
|
+
async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
|
|
1052
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
|
|
1053
|
+
return logs
|
|
1054
|
+
.filter(log => log.blockNumber! >= fromBlock && log.blockNumber! <= toBlock)
|
|
1055
|
+
.map(log => ({
|
|
1056
|
+
l1BlockNumber: log.blockNumber!,
|
|
1057
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
1058
|
+
l1TransactionHash: log.transactionHash!,
|
|
1059
|
+
args: {
|
|
1060
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
1061
|
+
archive: Fr.fromString(log.args.archive!),
|
|
1062
|
+
versionedBlobHashes: log.args.versionedBlobHashes!.map(h => Buffer.from(h.slice(2), 'hex')),
|
|
1063
|
+
attestationsHash: log.args.attestationsHash ? Buffer32.fromString(log.args.attestationsHash) : undefined,
|
|
1064
|
+
payloadDigest: log.args.payloadDigest ? Buffer32.fromString(log.args.payloadDigest) : undefined,
|
|
1065
|
+
},
|
|
1066
|
+
}));
|
|
1067
|
+
}
|
|
804
1068
|
}
|