@aztec/ethereum 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account.d.ts +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +2 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/config.d.ts +16 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +160 -62
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +7 -6
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +7 -6
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +9 -3
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +4 -4
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +16 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +7 -3
- package/dest/contracts/governance_proposer.d.ts +6 -6
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +9 -4
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +1 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/index.d.ts +1 -1
- package/dest/contracts/multicall.d.ts +5 -7
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +6 -4
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +83 -72
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +144 -139
- package/dest/contracts/slasher_contract.d.ts +11 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/slasher_contract.js +18 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +30 -9
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +58 -8
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +477 -15
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +610 -386
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +14258 -6015
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +10 -5
- package/dest/l1_contract_addresses.d.ts +8 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +16 -26
- 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 +6 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +14 -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/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 +10 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +10 -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_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 +94 -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 +431 -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 +1 -1
- package/dest/publisher_manager.d.ts +8 -3
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +36 -8
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +13 -12
- package/dest/test/chain_monitor.d.ts +33 -19
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +100 -33
- package/dest/test/delayed_tx_utils.d.ts +3 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +2 -2
- package/dest/test/eth_cheat_codes.d.ts +36 -14
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +124 -31
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +23 -20
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +79 -42
- package/dest/test/start_anvil.d.ts +2 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +3 -2
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +3 -2
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +2 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +10 -161
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/dest/zkPassportVerifierAddress.js +1 -1
- package/package.json +27 -13
- package/src/client.ts +1 -1
- package/src/config.ts +177 -65
- package/src/contracts/empire_base.ts +7 -6
- package/src/contracts/empire_slashing_proposer.ts +18 -8
- package/src/contracts/fee_asset_handler.ts +1 -1
- package/src/contracts/governance.ts +3 -3
- package/src/contracts/governance_proposer.ts +14 -9
- package/src/contracts/multicall.ts +12 -10
- package/src/contracts/rollup.ts +170 -171
- package/src/contracts/slasher_contract.ts +22 -0
- package/src/contracts/tally_slashing_proposer.ts +63 -12
- package/src/deploy_l1_contracts.ts +610 -337
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +14 -6
- package/src/l1_contract_addresses.ts +17 -26
- 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 +18 -0
- package/src/l1_tx_utils/factory.ts +64 -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 +12 -0
- package/src/l1_tx_utils/interfaces.ts +86 -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 +557 -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/publisher_manager.ts +51 -9
- package/src/queries.ts +16 -8
- package/src/test/chain_monitor.ts +118 -36
- package/src/test/delayed_tx_utils.ts +2 -2
- package/src/test/eth_cheat_codes.ts +149 -30
- package/src/test/rollup_cheat_codes.ts +94 -52
- package/src/test/start_anvil.ts +2 -0
- package/src/test/tx_delayer.ts +4 -2
- package/src/test/upgrade_utils.ts +3 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +12 -184
- package/src/zkPassportVerifierAddress.ts +1 -1
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils.d.ts +0 -250
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -826
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -19
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -85
- package/src/index.ts +0 -17
- package/src/l1_tx_utils.ts +0 -1105
- package/src/l1_tx_utils_with_blobs.ts +0 -144
package/dest/contracts/rollup.js
CHANGED
|
@@ -4,13 +4,13 @@ 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
10
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
10
11
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
11
|
-
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
12
12
|
import chunk from 'lodash.chunk';
|
|
13
|
-
import { encodeFunctionData,
|
|
13
|
+
import { encodeFunctionData, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
14
14
|
import { getPublicClient } from '../client.js';
|
|
15
15
|
import { formatViemError } from '../utils.js';
|
|
16
16
|
import { EmpireSlashingProposerContract } from './empire_slashing_proposer.js';
|
|
@@ -68,16 +68,11 @@ export class RollupContract {
|
|
|
68
68
|
return this.rollup;
|
|
69
69
|
}
|
|
70
70
|
async getSlashingProposer() {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
71
|
+
const slasher = await this.getSlasherContract();
|
|
72
|
+
if (!slasher) {
|
|
73
73
|
return undefined;
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
address: slasherAddress,
|
|
77
|
-
abi: SlasherAbi,
|
|
78
|
-
client: this.client
|
|
79
|
-
});
|
|
80
|
-
const proposerAddress = await slasher.read.PROPOSER();
|
|
75
|
+
const proposerAddress = await slasher.getProposer();
|
|
81
76
|
const proposerAbi = [
|
|
82
77
|
{
|
|
83
78
|
type: 'function',
|
|
@@ -94,7 +89,7 @@ export class RollupContract {
|
|
|
94
89
|
}
|
|
95
90
|
];
|
|
96
91
|
const proposer = getContract({
|
|
97
|
-
address: proposerAddress,
|
|
92
|
+
address: proposerAddress.toString(),
|
|
98
93
|
abi: proposerAbi,
|
|
99
94
|
client: this.client
|
|
100
95
|
});
|
|
@@ -119,8 +114,8 @@ export class RollupContract {
|
|
|
119
114
|
getEpochDuration() {
|
|
120
115
|
return this.rollup.read.getEpochDuration();
|
|
121
116
|
}
|
|
122
|
-
getSlotDuration() {
|
|
123
|
-
return this.rollup.read.getSlotDuration();
|
|
117
|
+
async getSlotDuration() {
|
|
118
|
+
return Number(await this.rollup.read.getSlotDuration());
|
|
124
119
|
}
|
|
125
120
|
getTargetCommitteeSize() {
|
|
126
121
|
return this.rollup.read.getTargetCommitteeSize();
|
|
@@ -128,6 +123,15 @@ export class RollupContract {
|
|
|
128
123
|
getEjectionThreshold() {
|
|
129
124
|
return this.rollup.read.getEjectionThreshold();
|
|
130
125
|
}
|
|
126
|
+
getLocalEjectionThreshold() {
|
|
127
|
+
return this.rollup.read.getLocalEjectionThreshold();
|
|
128
|
+
}
|
|
129
|
+
getLagInEpochsForValidatorSet() {
|
|
130
|
+
return this.rollup.read.getLagInEpochsForValidatorSet();
|
|
131
|
+
}
|
|
132
|
+
getLagInEpochsForRandao() {
|
|
133
|
+
return this.rollup.read.getLagInEpochsForRandao();
|
|
134
|
+
}
|
|
131
135
|
getActivationThreshold() {
|
|
132
136
|
return this.rollup.read.getActivationThreshold();
|
|
133
137
|
}
|
|
@@ -150,19 +154,41 @@ export class RollupContract {
|
|
|
150
154
|
return this.rollup.read.getVersion();
|
|
151
155
|
}
|
|
152
156
|
async getGenesisArchiveTreeRoot() {
|
|
153
|
-
|
|
157
|
+
return await this.rollup.read.archiveAt([
|
|
154
158
|
0n
|
|
155
159
|
]);
|
|
156
|
-
return block.archive;
|
|
157
160
|
}
|
|
158
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Returns rollup constants used for epoch queries.
|
|
163
|
+
* Return type is `L1RollupConstants` which is defined in stdlib,
|
|
164
|
+
* so we cant reference it until we move this contract to that package.
|
|
165
|
+
*/ async getRollupConstants() {
|
|
166
|
+
const [l1StartBlock, l1GenesisTime, slotDuration, epochDuration, proofSubmissionEpochs] = await Promise.all([
|
|
167
|
+
this.getL1StartBlock(),
|
|
168
|
+
this.getL1GenesisTime(),
|
|
169
|
+
this.getSlotDuration(),
|
|
170
|
+
this.getEpochDuration(),
|
|
171
|
+
this.getProofSubmissionEpochs()
|
|
172
|
+
]);
|
|
173
|
+
return {
|
|
174
|
+
l1StartBlock,
|
|
175
|
+
l1GenesisTime,
|
|
176
|
+
slotDuration,
|
|
177
|
+
epochDuration: Number(epochDuration),
|
|
178
|
+
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
getSlasherAddress() {
|
|
159
182
|
return this.rollup.read.getSlasher();
|
|
160
183
|
}
|
|
161
184
|
/**
|
|
162
185
|
* Returns a SlasherContract instance for interacting with the slasher contract.
|
|
163
186
|
*/ async getSlasherContract() {
|
|
164
|
-
const slasherAddress = await this.
|
|
165
|
-
|
|
187
|
+
const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
|
|
188
|
+
if (slasherAddress.isZero()) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return new SlasherContract(this.client, slasherAddress);
|
|
166
192
|
}
|
|
167
193
|
getOwner() {
|
|
168
194
|
return this.rollup.read.owner();
|
|
@@ -171,25 +197,23 @@ export class RollupContract {
|
|
|
171
197
|
return this.rollup.read.getActiveAttesterCount();
|
|
172
198
|
}
|
|
173
199
|
async getSlashingProposerAddress() {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
return EthAddress.fromString(await slasher.read.PROPOSER());
|
|
200
|
+
const slasher = await this.getSlasherContract();
|
|
201
|
+
if (!slasher) {
|
|
202
|
+
return EthAddress.ZERO;
|
|
203
|
+
}
|
|
204
|
+
return await slasher.getProposer();
|
|
181
205
|
}
|
|
182
|
-
|
|
183
|
-
return this.rollup.read.
|
|
206
|
+
getCheckpointReward() {
|
|
207
|
+
return this.rollup.read.getCheckpointReward();
|
|
184
208
|
}
|
|
185
|
-
|
|
186
|
-
return this.rollup.read.
|
|
209
|
+
async getCheckpointNumber() {
|
|
210
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
|
|
187
211
|
}
|
|
188
|
-
|
|
189
|
-
return this.rollup.read.
|
|
212
|
+
async getProvenCheckpointNumber() {
|
|
213
|
+
return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
|
|
190
214
|
}
|
|
191
|
-
getSlotNumber() {
|
|
192
|
-
return this.rollup.read.getCurrentSlot();
|
|
215
|
+
async getSlotNumber() {
|
|
216
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
193
217
|
}
|
|
194
218
|
getL1FeesAt(timestamp) {
|
|
195
219
|
return this.rollup.read.getL1FeesAt([
|
|
@@ -225,8 +249,8 @@ export class RollupContract {
|
|
|
225
249
|
getCurrentSampleSeed() {
|
|
226
250
|
return this.rollup.read.getCurrentSampleSeed();
|
|
227
251
|
}
|
|
228
|
-
getCurrentEpoch() {
|
|
229
|
-
return this.rollup.read.getCurrentEpoch();
|
|
252
|
+
async getCurrentEpoch() {
|
|
253
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
230
254
|
}
|
|
231
255
|
async getCurrentEpochCommittee() {
|
|
232
256
|
const { result } = await this.client.simulateContract({
|
|
@@ -264,27 +288,39 @@ export class RollupContract {
|
|
|
264
288
|
});
|
|
265
289
|
return result;
|
|
266
290
|
}
|
|
267
|
-
|
|
268
|
-
return this.rollup.read.
|
|
269
|
-
|
|
291
|
+
getCheckpoint(checkpointNumber) {
|
|
292
|
+
return this.rollup.read.getCheckpoint([
|
|
293
|
+
BigInt(checkpointNumber)
|
|
270
294
|
]);
|
|
271
295
|
}
|
|
272
|
-
getTips() {
|
|
273
|
-
|
|
296
|
+
async getTips() {
|
|
297
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
298
|
+
return {
|
|
299
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
300
|
+
proven: CheckpointNumber.fromBigInt(proven)
|
|
301
|
+
};
|
|
274
302
|
}
|
|
275
303
|
getTimestampForSlot(slot) {
|
|
276
304
|
return this.rollup.read.getTimestampForSlot([
|
|
277
|
-
slot
|
|
305
|
+
BigInt(slot)
|
|
278
306
|
]);
|
|
279
307
|
}
|
|
280
308
|
getEntryQueueLength() {
|
|
281
309
|
return this.rollup.read.getEntryQueueLength();
|
|
282
310
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
311
|
+
getAvailableValidatorFlushes() {
|
|
312
|
+
return this.rollup.read.getAvailableValidatorFlushes();
|
|
313
|
+
}
|
|
314
|
+
async getNextFlushableEpoch() {
|
|
315
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
|
|
316
|
+
}
|
|
317
|
+
async getCurrentEpochNumber() {
|
|
318
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
|
|
319
|
+
}
|
|
320
|
+
async getEpochNumberForCheckpoint(checkpointNumber) {
|
|
321
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([
|
|
322
|
+
BigInt(checkpointNumber)
|
|
323
|
+
]));
|
|
288
324
|
}
|
|
289
325
|
async getRollupAddresses() {
|
|
290
326
|
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
|
|
@@ -311,9 +347,9 @@ export class RollupContract {
|
|
|
311
347
|
return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
|
|
312
348
|
}
|
|
313
349
|
async getEpochNumberForSlotNumber(slotNumber) {
|
|
314
|
-
return await this.rollup.read.getEpochAtSlot([
|
|
315
|
-
slotNumber
|
|
316
|
-
]);
|
|
350
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
|
|
351
|
+
BigInt(slotNumber)
|
|
352
|
+
]));
|
|
317
353
|
}
|
|
318
354
|
getEpochProofPublicInputs(args) {
|
|
319
355
|
return this.rollup.read.getEpochProofPublicInputs(args);
|
|
@@ -332,80 +368,20 @@ export class RollupContract {
|
|
|
332
368
|
}
|
|
333
369
|
}
|
|
334
370
|
/**
|
|
335
|
-
* Packs an array of committee attestations into the format expected by the Solidity contract
|
|
336
|
-
*
|
|
337
|
-
* @param attestations - Array of committee attestations with addresses and signatures
|
|
338
|
-
* @returns Packed attestations with bitmap and tightly packed signature/address data
|
|
339
|
-
*/ static packAttestations(attestations) {
|
|
340
|
-
const length = attestations.length;
|
|
341
|
-
// Calculate bitmap size (1 bit per attestation, rounded up to nearest byte)
|
|
342
|
-
const bitmapSize = Math.ceil(length / 8);
|
|
343
|
-
const signatureIndices = new Uint8Array(bitmapSize);
|
|
344
|
-
// Calculate total data size needed
|
|
345
|
-
let totalDataSize = 0;
|
|
346
|
-
for(let i = 0; i < length; i++){
|
|
347
|
-
const signature = attestations[i].signature;
|
|
348
|
-
// Check if signature is empty (v = 0)
|
|
349
|
-
const isEmpty = signature.v === 0;
|
|
350
|
-
if (!isEmpty) {
|
|
351
|
-
totalDataSize += 65; // v (1) + r (32) + s (32)
|
|
352
|
-
} else {
|
|
353
|
-
totalDataSize += 20; // address only
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
const signaturesOrAddresses = new Uint8Array(totalDataSize);
|
|
357
|
-
let dataIndex = 0;
|
|
358
|
-
// Pack the data
|
|
359
|
-
for(let i = 0; i < length; i++){
|
|
360
|
-
const attestation = attestations[i];
|
|
361
|
-
const signature = attestation.signature;
|
|
362
|
-
// Check if signature is empty
|
|
363
|
-
const isEmpty = signature.v === 0;
|
|
364
|
-
if (!isEmpty) {
|
|
365
|
-
// Set bit in bitmap (bit 7-0 in each byte, left to right)
|
|
366
|
-
const byteIndex = Math.floor(i / 8);
|
|
367
|
-
const bitIndex = 7 - i % 8;
|
|
368
|
-
signatureIndices[byteIndex] |= 1 << bitIndex;
|
|
369
|
-
// Pack signature: v + r + s
|
|
370
|
-
signaturesOrAddresses[dataIndex] = signature.v;
|
|
371
|
-
dataIndex++;
|
|
372
|
-
// Pack r (32 bytes)
|
|
373
|
-
const rBytes = Buffer.from(signature.r.slice(2), 'hex');
|
|
374
|
-
signaturesOrAddresses.set(rBytes, dataIndex);
|
|
375
|
-
dataIndex += 32;
|
|
376
|
-
// Pack s (32 bytes)
|
|
377
|
-
const sBytes = Buffer.from(signature.s.slice(2), 'hex');
|
|
378
|
-
signaturesOrAddresses.set(sBytes, dataIndex);
|
|
379
|
-
dataIndex += 32;
|
|
380
|
-
} else {
|
|
381
|
-
// Pack address only (20 bytes)
|
|
382
|
-
const addrBytes = Buffer.from(attestation.addr.slice(2), 'hex');
|
|
383
|
-
signaturesOrAddresses.set(addrBytes, dataIndex);
|
|
384
|
-
dataIndex += 20;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return {
|
|
388
|
-
signatureIndices: `0x${Buffer.from(signatureIndices).toString('hex')}`,
|
|
389
|
-
signaturesOrAddresses: `0x${Buffer.from(signaturesOrAddresses).toString('hex')}`
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
371
|
* @notice Calls `canProposeAtTime` with the time of the next Ethereum block and the sender address
|
|
394
372
|
*
|
|
395
373
|
* @dev Throws if unable to propose
|
|
396
374
|
*
|
|
397
375
|
* @param archive - The archive that we expect to be current state
|
|
398
|
-
* @return [slot,
|
|
376
|
+
* @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
|
|
377
|
+
* timestamp of the next L1 block
|
|
399
378
|
* @throws otherwise
|
|
400
379
|
*/ async canProposeAtNextEthBlock(archive, account, slotDuration, opts = {}) {
|
|
401
|
-
if (typeof slotDuration === 'number') {
|
|
402
|
-
slotDuration = BigInt(slotDuration);
|
|
403
|
-
}
|
|
404
380
|
const latestBlock = await this.client.getBlock();
|
|
405
|
-
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
381
|
+
const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
|
|
406
382
|
const who = typeof account === 'string' ? account : account.address;
|
|
407
383
|
try {
|
|
408
|
-
const { result: [slot,
|
|
384
|
+
const { result: [slot, checkpointNumber] } = await this.client.simulateContract({
|
|
409
385
|
address: this.address,
|
|
410
386
|
abi: RollupAbi,
|
|
411
387
|
functionName: 'canProposeAtTime',
|
|
@@ -415,11 +391,11 @@ export class RollupContract {
|
|
|
415
391
|
who
|
|
416
392
|
],
|
|
417
393
|
account,
|
|
418
|
-
stateOverride: await this.
|
|
394
|
+
stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber)
|
|
419
395
|
});
|
|
420
396
|
return {
|
|
421
|
-
slot,
|
|
422
|
-
|
|
397
|
+
slot: SlotNumber.fromBigInt(slot),
|
|
398
|
+
checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
|
|
423
399
|
timeOfNextL1Slot
|
|
424
400
|
};
|
|
425
401
|
} catch (err) {
|
|
@@ -427,11 +403,11 @@ export class RollupContract {
|
|
|
427
403
|
}
|
|
428
404
|
}
|
|
429
405
|
/**
|
|
430
|
-
* Returns a state override that sets the pending
|
|
431
|
-
* Requires querying the current state of the contract to get the current proven
|
|
406
|
+
* Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
|
|
407
|
+
* Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
|
|
432
408
|
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
433
|
-
*/ async
|
|
434
|
-
if (
|
|
409
|
+
*/ async makePendingCheckpointNumberOverride(forcePendingCheckpointNumber) {
|
|
410
|
+
if (forcePendingCheckpointNumber === undefined) {
|
|
435
411
|
return [];
|
|
436
412
|
}
|
|
437
413
|
const slot = RollupContract.stfStorageSlot;
|
|
@@ -439,8 +415,8 @@ export class RollupContract {
|
|
|
439
415
|
address: this.address,
|
|
440
416
|
slot
|
|
441
417
|
});
|
|
442
|
-
const
|
|
443
|
-
const newValue = BigInt(
|
|
418
|
+
const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & (1n << 128n) - 1n : 0n;
|
|
419
|
+
const newValue = BigInt(forcePendingCheckpointNumber) << 128n | currentProvenCheckpointNumber;
|
|
444
420
|
return [
|
|
445
421
|
{
|
|
446
422
|
address: this.address,
|
|
@@ -453,42 +429,42 @@ export class RollupContract {
|
|
|
453
429
|
}
|
|
454
430
|
];
|
|
455
431
|
}
|
|
456
|
-
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(
|
|
432
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(checkpointNumber, attestationsAndSigners, committee, invalidIndex) {
|
|
457
433
|
return {
|
|
458
434
|
to: this.address,
|
|
459
435
|
data: encodeFunctionData({
|
|
460
436
|
abi: RollupAbi,
|
|
461
437
|
functionName: 'invalidateBadAttestation',
|
|
462
438
|
args: [
|
|
463
|
-
BigInt(
|
|
464
|
-
|
|
439
|
+
BigInt(checkpointNumber),
|
|
440
|
+
attestationsAndSigners,
|
|
465
441
|
committee.map((addr)=>addr.toString()),
|
|
466
442
|
BigInt(invalidIndex)
|
|
467
443
|
]
|
|
468
444
|
})
|
|
469
445
|
};
|
|
470
446
|
}
|
|
471
|
-
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(
|
|
447
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(checkpointNumber, attestationsAndSigners, committee) {
|
|
472
448
|
return {
|
|
473
449
|
to: this.address,
|
|
474
450
|
data: encodeFunctionData({
|
|
475
451
|
abi: RollupAbi,
|
|
476
452
|
functionName: 'invalidateInsufficientAttestations',
|
|
477
453
|
args: [
|
|
478
|
-
BigInt(
|
|
479
|
-
|
|
454
|
+
BigInt(checkpointNumber),
|
|
455
|
+
attestationsAndSigners,
|
|
480
456
|
committee.map((addr)=>addr.toString())
|
|
481
457
|
]
|
|
482
458
|
})
|
|
483
459
|
};
|
|
484
460
|
}
|
|
485
|
-
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber,
|
|
461
|
+
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfCheckpointsInEpoch, prover) {
|
|
486
462
|
if (prover instanceof EthAddress) {
|
|
487
463
|
prover = prover.toString();
|
|
488
464
|
}
|
|
489
465
|
return this.rollup.read.getHasSubmitted([
|
|
490
466
|
BigInt(epochNumber),
|
|
491
|
-
BigInt(
|
|
467
|
+
BigInt(numberOfCheckpointsInEpoch),
|
|
492
468
|
prover
|
|
493
469
|
]);
|
|
494
470
|
}
|
|
@@ -498,15 +474,15 @@ export class RollupContract {
|
|
|
498
474
|
inFeeAsset
|
|
499
475
|
]);
|
|
500
476
|
}
|
|
501
|
-
getSlotAt(timestamp) {
|
|
502
|
-
return this.rollup.read.getSlotAt([
|
|
477
|
+
async getSlotAt(timestamp) {
|
|
478
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
503
479
|
timestamp
|
|
504
|
-
]);
|
|
480
|
+
]));
|
|
505
481
|
}
|
|
506
|
-
async status(
|
|
482
|
+
async status(checkpointNumber, options) {
|
|
507
483
|
await checkBlockTag(options?.blockNumber, this.client);
|
|
508
484
|
return this.rollup.read.status([
|
|
509
|
-
|
|
485
|
+
BigInt(checkpointNumber)
|
|
510
486
|
], options);
|
|
511
487
|
}
|
|
512
488
|
async canPruneAtTime(timestamp, options) {
|
|
@@ -518,9 +494,9 @@ export class RollupContract {
|
|
|
518
494
|
archive() {
|
|
519
495
|
return this.rollup.read.archive();
|
|
520
496
|
}
|
|
521
|
-
archiveAt(
|
|
497
|
+
archiveAt(checkpointNumber) {
|
|
522
498
|
return this.rollup.read.archiveAt([
|
|
523
|
-
|
|
499
|
+
BigInt(checkpointNumber)
|
|
524
500
|
]);
|
|
525
501
|
}
|
|
526
502
|
getSequencerRewards(address) {
|
|
@@ -566,9 +542,9 @@ export class RollupContract {
|
|
|
566
542
|
address
|
|
567
543
|
]);
|
|
568
544
|
}
|
|
569
|
-
getBlobCommitmentsHash(
|
|
545
|
+
getBlobCommitmentsHash(checkpointNumber) {
|
|
570
546
|
return this.rollup.read.getBlobCommitmentsHash([
|
|
571
|
-
|
|
547
|
+
BigInt(checkpointNumber)
|
|
572
548
|
]);
|
|
573
549
|
}
|
|
574
550
|
getCurrentBlobCommitmentsHash() {
|
|
@@ -577,6 +553,9 @@ export class RollupContract {
|
|
|
577
553
|
getStakingAsset() {
|
|
578
554
|
return this.rollup.read.getStakingAsset();
|
|
579
555
|
}
|
|
556
|
+
getRewardConfig() {
|
|
557
|
+
return this.rollup.read.getRewardConfig();
|
|
558
|
+
}
|
|
580
559
|
setupEpoch(l1TxUtils) {
|
|
581
560
|
return l1TxUtils.sendAndMonitorTransaction({
|
|
582
561
|
to: this.address,
|
|
@@ -611,6 +590,20 @@ export class RollupContract {
|
|
|
611
590
|
}
|
|
612
591
|
});
|
|
613
592
|
}
|
|
593
|
+
listenToCheckpointInvalidated(callback) {
|
|
594
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
595
|
+
onLogs: (logs)=>{
|
|
596
|
+
for (const log of logs){
|
|
597
|
+
const args = log.args;
|
|
598
|
+
if (args.checkpointNumber !== undefined) {
|
|
599
|
+
callback({
|
|
600
|
+
checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber)
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
614
607
|
async getSlashEvents(l1BlockHash) {
|
|
615
608
|
const events = await this.rollup.getEvents.Slashed({}, {
|
|
616
609
|
blockHash: l1BlockHash,
|
|
@@ -657,6 +650,15 @@ _ts_decorate([
|
|
|
657
650
|
_ts_decorate([
|
|
658
651
|
memoize
|
|
659
652
|
], RollupContract.prototype, "getEjectionThreshold", null);
|
|
653
|
+
_ts_decorate([
|
|
654
|
+
memoize
|
|
655
|
+
], RollupContract.prototype, "getLocalEjectionThreshold", null);
|
|
656
|
+
_ts_decorate([
|
|
657
|
+
memoize
|
|
658
|
+
], RollupContract.prototype, "getLagInEpochsForValidatorSet", null);
|
|
659
|
+
_ts_decorate([
|
|
660
|
+
memoize
|
|
661
|
+
], RollupContract.prototype, "getLagInEpochsForRandao", null);
|
|
660
662
|
_ts_decorate([
|
|
661
663
|
memoize
|
|
662
664
|
], RollupContract.prototype, "getActivationThreshold", null);
|
|
@@ -681,3 +683,6 @@ _ts_decorate([
|
|
|
681
683
|
_ts_decorate([
|
|
682
684
|
memoize
|
|
683
685
|
], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
|
|
686
|
+
_ts_decorate([
|
|
687
|
+
memoize
|
|
688
|
+
], RollupContract.prototype, "getRollupConstants", null);
|
|
@@ -15,11 +15,21 @@ export declare class SlasherContract {
|
|
|
15
15
|
* @returns True if the payload is vetoed, false otherwise
|
|
16
16
|
*/
|
|
17
17
|
isPayloadVetoed(payloadAddress: EthAddress): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if slashing is currently enabled. Slashing can be disabled by the vetoer.
|
|
20
|
+
* @returns True if slashing is enabled, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
isSlashingEnabled(): Promise<boolean>;
|
|
18
23
|
/**
|
|
19
24
|
* Gets the current vetoer address.
|
|
20
25
|
* @returns The vetoer address
|
|
21
26
|
*/
|
|
22
27
|
getVetoer(): Promise<EthAddress>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the disable duration by the vetoer.
|
|
30
|
+
* @returns The disable duration in seconds
|
|
31
|
+
*/
|
|
32
|
+
getSlashingDisableDuration(): Promise<number>;
|
|
23
33
|
/**
|
|
24
34
|
* Gets the current governance address.
|
|
25
35
|
* @returns The governance address
|
|
@@ -31,4 +41,4 @@ export declare class SlasherContract {
|
|
|
31
41
|
*/
|
|
32
42
|
getProposer(): Promise<EthAddress>;
|
|
33
43
|
}
|
|
34
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhc2hlcl9jb250cmFjdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0cy9zbGFzaGVyX2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQU0zRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFFOUM7O0dBRUc7QUFDSCxxQkFBYSxlQUFlO0lBSXhCLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTTtJQUN2QixPQUFPLENBQUMsUUFBUSxDQUFDLE9BQU87SUFDeEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBTHRCLE9BQU8sQ0FBQyxRQUFRLENBQXVEO0lBRXZFLFlBQ21CLE1BQU0sRUFBRSxVQUFVLEVBQ2xCLE9BQU8sRUFBRSxVQUFVLEVBQ25CLEdBQUcseUNBQW1DLEVBT3hEO0lBRUQ7Ozs7T0FJRztJQUNVLGVBQWUsQ0FBQyxjQUFjLEVBQUUsVUFBVSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FPekU7SUFFRDs7O09BR0c7SUFDVSxpQkFBaUIsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLENBT2pEO0lBRUQ7OztPQUdHO0lBQ1UsU0FBUyxJQUFJLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FHNUM7SUFFRDs7O09BR0c7SUFDVSwwQkFBMEIsSUFBSSxPQUFPLENBQUMsTUFBTSxDQUFDLENBR3pEO0lBRUQ7OztPQUdHO0lBQ1UsYUFBYSxJQUFJLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FHaEQ7SUFFRDs7O09BR0c7SUFDVSxXQUFXLElBQUksT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUc5QztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slasher_contract.d.ts","sourceRoot":"","sources":["../../src/contracts/slasher_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAM3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,OAAO,CAAC,QAAQ,CAAuD;
|
|
1
|
+
{"version":3,"file":"slasher_contract.d.ts","sourceRoot":"","sources":["../../src/contracts/slasher_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAM3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,OAAO,CAAC,QAAQ,CAAuD;IAEvE,YACmB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,UAAU,EACnB,GAAG,yCAAmC,EAOxD;IAED;;;;OAIG;IACU,eAAe,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAOzE;IAED;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAOjD;IAED;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAG5C;IAED;;;OAGG;IACU,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC,CAGzD;IAED;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,CAGhD;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAG9C;CACF"}
|
|
@@ -34,6 +34,17 @@ import { getContract } from 'viem';
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
+
* Checks if slashing is currently enabled. Slashing can be disabled by the vetoer.
|
|
38
|
+
* @returns True if slashing is enabled, false otherwise
|
|
39
|
+
*/ async isSlashingEnabled() {
|
|
40
|
+
try {
|
|
41
|
+
return await this.contract.read.isSlashingEnabled();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
this.log.error(`Error checking if slashing is enabled`, error);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
37
48
|
* Gets the current vetoer address.
|
|
38
49
|
* @returns The vetoer address
|
|
39
50
|
*/ async getVetoer() {
|
|
@@ -41,6 +52,13 @@ import { getContract } from 'viem';
|
|
|
41
52
|
return EthAddress.fromString(vetoer);
|
|
42
53
|
}
|
|
43
54
|
/**
|
|
55
|
+
* Gets the disable duration by the vetoer.
|
|
56
|
+
* @returns The disable duration in seconds
|
|
57
|
+
*/ async getSlashingDisableDuration() {
|
|
58
|
+
const duration = await this.contract.read.SLASHING_DISABLE_DURATION();
|
|
59
|
+
return Number(duration);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
44
62
|
* Gets the current governance address.
|
|
45
63
|
* @returns The governance address
|
|
46
64
|
*/ async getGovernance() {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
|
|
2
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
4
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import EventEmitter from 'events';
|
|
5
6
|
import { type Hex, type Log, type TypedDataDefinition } from 'viem';
|
|
6
7
|
/**
|
|
7
8
|
* Wrapper around the TallySlashingProposer contract that provides
|
|
8
9
|
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
9
10
|
*/
|
|
10
|
-
export declare class TallySlashingProposerContract
|
|
11
|
+
export declare class TallySlashingProposerContract {
|
|
11
12
|
readonly client: ViemClient;
|
|
12
13
|
private readonly contract;
|
|
13
14
|
readonly type: "tally";
|
|
@@ -29,9 +30,15 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
29
30
|
*/
|
|
30
31
|
getRound(round: bigint): Promise<{
|
|
31
32
|
isExecuted: boolean;
|
|
32
|
-
readyToExecute: boolean;
|
|
33
33
|
voteCount: bigint;
|
|
34
34
|
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a round is ready to execute at a given slot
|
|
37
|
+
* @param round - The round number to check
|
|
38
|
+
* @param slot - The slot number to check at
|
|
39
|
+
* @returns Whether the round is ready to execute
|
|
40
|
+
*/
|
|
41
|
+
isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean>;
|
|
35
42
|
/** Returns the slash actions and payload address for a given round (zero if no slash actions) */
|
|
36
43
|
getPayload(round: bigint): Promise<{
|
|
37
44
|
actions: {
|
|
@@ -53,9 +60,9 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
53
60
|
tryExtractVoteCastEvent(logs: Log[]): {
|
|
54
61
|
eventName: "VoteCast";
|
|
55
62
|
args: {
|
|
63
|
+
proposer: `0x${string}`;
|
|
56
64
|
round: bigint;
|
|
57
65
|
slot: bigint;
|
|
58
|
-
proposer: `0x${string}`;
|
|
59
66
|
};
|
|
60
67
|
} | undefined;
|
|
61
68
|
/** Tries to extract a RoundExecuted event from the given logs. */
|
|
@@ -73,11 +80,11 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
73
80
|
* @param signer - The signer to produce the signature
|
|
74
81
|
* @returns L1 transaction request
|
|
75
82
|
*/
|
|
76
|
-
buildVoteRequestFromSigner(votes: Hex, slot:
|
|
83
|
+
buildVoteRequestFromSigner(votes: Hex, slot: SlotNumber, signer: (msg: TypedDataDefinition) => Promise<Hex>): Promise<L1TxRequest>;
|
|
77
84
|
/** Returns the typed data definition to EIP712-sign for voting */
|
|
78
|
-
buildVoteTypedData(votes: Hex, slot:
|
|
85
|
+
buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition;
|
|
79
86
|
/** Gets the digest to sign for voting directly from the contract */
|
|
80
|
-
getVoteDataDigest(votes: Hex, slot:
|
|
87
|
+
getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32>;
|
|
81
88
|
/**
|
|
82
89
|
* Create a transaction to vote for slashing offenses
|
|
83
90
|
* @param votes - The encoded votes for slashing
|
|
@@ -96,6 +103,11 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
96
103
|
* @returns L1 transaction request
|
|
97
104
|
*/
|
|
98
105
|
buildExecuteRoundRequest(round: bigint, committees: EthAddress[][]): L1TxRequest;
|
|
106
|
+
/** Returns the last vote emitted for a given round */
|
|
107
|
+
getLastVote(round: bigint): Promise<{
|
|
108
|
+
validator: EthAddress;
|
|
109
|
+
slashAmount: bigint;
|
|
110
|
+
}[]>;
|
|
99
111
|
/**
|
|
100
112
|
* Listen for VoteCast events
|
|
101
113
|
* @param callback - Callback function to handle vote cast events
|
|
@@ -116,4 +128,13 @@ export declare class TallySlashingProposerContract extends EventEmitter {
|
|
|
116
128
|
l1BlockHash: Hex;
|
|
117
129
|
}) => void): () => void;
|
|
118
130
|
}
|
|
119
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Decodes a Buffer containing slash votes back into an array of numbers.
|
|
133
|
+
* Each vote is represented as a 2-bit value (0, 1, 2, or 3) representing slashing units.
|
|
134
|
+
* @dev This should live in stdlib next to encodeSlashConsensusVotes but is here since we
|
|
135
|
+
* do not have a dependency to stdlib from the ethereum package. We need a larger refactor to fix this.
|
|
136
|
+
* @param buffer - The Buffer containing encoded slash votes
|
|
137
|
+
* @returns An array of numbers representing the slash votes
|
|
138
|
+
*/
|
|
139
|
+
export declare function decodeSlashConsensusVotes(buffer: Buffer): number[];
|
|
140
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFsbHlfc2xhc2hpbmdfcHJvcG9zZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdHMvdGFsbHlfc2xhc2hpbmdfcHJvcG9zZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFeEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzdELE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFLM0QsT0FBTyxFQUVMLEtBQUssR0FBRyxFQUNSLEtBQUssR0FBRyxFQUNSLEtBQUssbUJBQW1CLEVBR3pCLE1BQU0sTUFBTSxDQUFDO0FBRWQ7OztHQUdHO0FBQ0gscUJBQWEsNkJBQTZC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