@aztec/ethereum 0.73.0 → 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2
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/chain.js +17 -18
- package/dest/client.js +5 -9
- package/dest/config.js +13 -14
- package/dest/constants.js +0 -1
- package/dest/contracts/empire_base.js +11 -0
- package/dest/contracts/forwarder.js +67 -32
- package/dest/contracts/governance.js +11 -6
- package/dest/contracts/governance_proposer.js +79 -37
- package/dest/contracts/index.js +2 -2
- package/dest/contracts/rollup.js +271 -234
- package/dest/contracts/slashing_proposer.js +32 -4
- package/dest/deploy_l1_contracts.js +203 -124
- package/dest/eth_cheat_codes.js +144 -127
- package/dest/index.js +0 -1
- package/dest/l1_contract_addresses.js +17 -19
- package/dest/l1_reader.js +6 -7
- package/dest/l1_tx_utils.js +229 -199
- package/dest/l1_tx_utils_with_blobs.js +25 -22
- package/dest/queries.js +6 -9
- package/dest/test/delayed_tx_utils.js +3 -3
- package/dest/test/eth_cheat_codes_with_state.js +10 -12
- package/dest/test/index.js +0 -1
- package/dest/test/start_anvil.js +17 -9
- package/dest/test/tx_delayer.js +77 -74
- package/dest/types.js +1 -2
- package/dest/utils.js +58 -38
- package/package.json +5 -4
- package/src/contracts/empire_base.ts +19 -0
- package/src/contracts/forwarder.ts +37 -14
- package/src/contracts/governance_proposer.ts +54 -4
- package/src/contracts/index.ts +2 -1
- package/src/contracts/rollup.ts +21 -9
- package/src/contracts/slashing_proposer.ts +29 -2
- package/src/deploy_l1_contracts.ts +6 -0
- package/src/l1_tx_utils.ts +9 -19
- package/src/l1_tx_utils_with_blobs.ts +1 -1
- package/src/utils.ts +29 -3
- package/dest/chain.d.ts +0 -25
- package/dest/chain.d.ts.map +0 -1
- package/dest/client.d.ts +0 -16
- package/dest/client.d.ts.map +0 -1
- package/dest/config.d.ts +0 -38
- package/dest/config.d.ts.map +0 -1
- package/dest/constants.d.ts +0 -4
- package/dest/constants.d.ts.map +0 -1
- package/dest/contracts/forwarder.d.ts +0 -23
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/governance.d.ts +0 -14
- package/dest/contracts/governance.d.ts.map +0 -1
- package/dest/contracts/governance_proposer.d.ts +0 -13
- package/dest/contracts/governance_proposer.d.ts.map +0 -1
- package/dest/contracts/index.d.ts +0 -6
- package/dest/contracts/index.d.ts.map +0 -1
- package/dest/contracts/rollup.d.ts +0 -113
- package/dest/contracts/rollup.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.d.ts +0 -11
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.d.ts +0 -19873
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/eth_cheat_codes.d.ts +0 -146
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/index.d.ts +0 -15
- package/dest/index.d.ts.map +0 -1
- package/dest/l1_contract_addresses.d.ts +0 -55
- package/dest/l1_contract_addresses.d.ts.map +0 -1
- package/dest/l1_reader.d.ts +0 -16
- package/dest/l1_reader.d.ts.map +0 -1
- package/dest/l1_tx_utils.d.ts +0 -193
- package/dest/l1_tx_utils.d.ts.map +0 -1
- 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/queries.d.ts +0 -15
- package/dest/queries.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.d.ts +0 -8
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts +0 -18
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +0 -1
- package/dest/test/index.d.ts +0 -5
- package/dest/test/index.d.ts.map +0 -1
- package/dest/test/start_anvil.d.ts +0 -9
- package/dest/test/start_anvil.d.ts.map +0 -1
- package/dest/test/tx_delayer.d.ts +0 -24
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/dest/types.d.ts +0 -12
- package/dest/types.d.ts.map +0 -1
- package/dest/utils.d.ts +0 -24
- package/dest/utils.d.ts.map +0 -1
package/dest/contracts/rollup.js
CHANGED
|
@@ -1,239 +1,276 @@
|
|
|
1
|
-
|
|
1
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
}
|
|
2
7
|
import { memoize } from '@aztec/foundation/decorators';
|
|
3
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { RollupAbi, SlasherAbi } from '@aztec/l1-artifacts';
|
|
5
|
-
import { createPublicClient, getAddress, getContract, http
|
|
9
|
+
import { RollupAbi, RollupStorage, SlasherAbi } from '@aztec/l1-artifacts';
|
|
10
|
+
import { createPublicClient, getAddress, getContract, http } from 'viem';
|
|
6
11
|
import { createEthereumChain } from '../chain.js';
|
|
7
12
|
import { formatViemError } from '../utils.js';
|
|
8
13
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
14
|
+
export class RollupContract {
|
|
15
|
+
client;
|
|
16
|
+
rollup;
|
|
17
|
+
static get checkBlobStorageSlot() {
|
|
18
|
+
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
19
|
+
if (asString === undefined) {
|
|
20
|
+
throw new Error('checkBlobStorageSlot not found');
|
|
21
|
+
}
|
|
22
|
+
return BigInt(asString);
|
|
23
|
+
}
|
|
24
|
+
static getFromL1ContractsValues(deployL1ContractsValues) {
|
|
25
|
+
const { publicClient, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
|
|
26
|
+
return new RollupContract(publicClient, rollupAddress.toString());
|
|
27
|
+
}
|
|
28
|
+
static getFromConfig(config) {
|
|
29
|
+
const client = createPublicClient({
|
|
30
|
+
transport: http(config.l1RpcUrl),
|
|
31
|
+
chain: createEthereumChain(config.l1RpcUrl, config.l1ChainId).chainInfo
|
|
32
|
+
});
|
|
33
|
+
const address = config.l1Contracts.rollupAddress.toString();
|
|
34
|
+
return new RollupContract(client, address);
|
|
35
|
+
}
|
|
36
|
+
constructor(client, address){
|
|
37
|
+
this.client = client;
|
|
38
|
+
this.rollup = getContract({
|
|
39
|
+
address,
|
|
40
|
+
abi: RollupAbi,
|
|
41
|
+
client
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
get address() {
|
|
45
|
+
return this.rollup.address;
|
|
46
|
+
}
|
|
47
|
+
async getSlashingProposer() {
|
|
48
|
+
const slasherAddress = await this.rollup.read.getSlasher();
|
|
49
|
+
const slasher = getContract({
|
|
50
|
+
address: slasherAddress,
|
|
51
|
+
abi: SlasherAbi,
|
|
52
|
+
client: this.client
|
|
53
|
+
});
|
|
54
|
+
const proposerAddress = await slasher.read.PROPOSER();
|
|
55
|
+
return new SlashingProposerContract(this.client, proposerAddress);
|
|
56
|
+
}
|
|
57
|
+
getL1StartBlock() {
|
|
58
|
+
return this.rollup.read.L1_BLOCK_AT_GENESIS();
|
|
59
|
+
}
|
|
60
|
+
getL1GenesisTime() {
|
|
61
|
+
return this.rollup.read.getGenesisTime();
|
|
62
|
+
}
|
|
63
|
+
getClaimDurationInL2Slots() {
|
|
64
|
+
return this.rollup.read.CLAIM_DURATION_IN_L2_SLOTS();
|
|
65
|
+
}
|
|
66
|
+
getEpochDuration() {
|
|
67
|
+
return this.rollup.read.getEpochDuration();
|
|
68
|
+
}
|
|
69
|
+
getSlotDuration() {
|
|
70
|
+
return this.rollup.read.getSlotDuration();
|
|
71
|
+
}
|
|
72
|
+
getTargetCommitteeSize() {
|
|
73
|
+
return this.rollup.read.getTargetCommitteeSize();
|
|
74
|
+
}
|
|
75
|
+
getMinimumStake() {
|
|
76
|
+
return this.rollup.read.getMinimumStake();
|
|
77
|
+
}
|
|
78
|
+
async getSlashingProposerAddress() {
|
|
79
|
+
const slasherAddress = await this.rollup.read.getSlasher();
|
|
80
|
+
const slasher = getContract({
|
|
81
|
+
address: getAddress(slasherAddress.toString()),
|
|
82
|
+
abi: SlasherAbi,
|
|
83
|
+
client: this.client
|
|
84
|
+
});
|
|
85
|
+
return EthAddress.fromString(await slasher.read.PROPOSER());
|
|
86
|
+
}
|
|
87
|
+
getBlockNumber() {
|
|
88
|
+
return this.rollup.read.getPendingBlockNumber();
|
|
89
|
+
}
|
|
90
|
+
getProvenBlockNumber() {
|
|
91
|
+
return this.rollup.read.getProvenBlockNumber();
|
|
92
|
+
}
|
|
93
|
+
getSlotNumber() {
|
|
94
|
+
return this.rollup.read.getCurrentSlot();
|
|
95
|
+
}
|
|
96
|
+
getCommitteeAt(timestamp) {
|
|
97
|
+
return this.rollup.read.getCommitteeAt([
|
|
98
|
+
timestamp
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
getSampleSeedAt(timestamp) {
|
|
102
|
+
return this.rollup.read.getSampleSeedAt([
|
|
103
|
+
timestamp
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
getCurrentSampleSeed() {
|
|
107
|
+
return this.rollup.read.getCurrentSampleSeed();
|
|
108
|
+
}
|
|
109
|
+
getCurrentEpochCommittee() {
|
|
110
|
+
return this.rollup.read.getCurrentEpochCommittee();
|
|
111
|
+
}
|
|
112
|
+
getCurrentProposer() {
|
|
113
|
+
return this.rollup.read.getCurrentProposer();
|
|
114
|
+
}
|
|
115
|
+
getProposerAt(timestamp) {
|
|
116
|
+
return this.rollup.read.getProposerAt([
|
|
117
|
+
timestamp
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
getBlock(blockNumber) {
|
|
121
|
+
return this.rollup.read.getBlock([
|
|
122
|
+
blockNumber
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
getProofCommitmentEscrow() {
|
|
126
|
+
return this.rollup.read.PROOF_COMMITMENT_ESCROW();
|
|
127
|
+
}
|
|
128
|
+
getTips() {
|
|
129
|
+
return this.rollup.read.getTips();
|
|
130
|
+
}
|
|
131
|
+
getTimestampForSlot(slot) {
|
|
132
|
+
return this.rollup.read.getTimestampForSlot([
|
|
133
|
+
slot
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
async getEpochNumber(blockNumber) {
|
|
137
|
+
blockNumber ??= await this.getBlockNumber();
|
|
138
|
+
return this.rollup.read.getEpochForBlock([
|
|
139
|
+
BigInt(blockNumber)
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
async getRollupAddresses() {
|
|
143
|
+
const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
|
|
144
|
+
this.rollup.read.INBOX(),
|
|
145
|
+
this.rollup.read.OUTBOX(),
|
|
146
|
+
this.rollup.read.FEE_JUICE_PORTAL(),
|
|
147
|
+
this.rollup.read.REWARD_DISTRIBUTOR(),
|
|
148
|
+
this.rollup.read.ASSET(),
|
|
149
|
+
this.rollup.read.getStakingAsset()
|
|
150
|
+
])).map(EthAddress.fromString);
|
|
151
|
+
return {
|
|
152
|
+
rollupAddress: EthAddress.fromString(this.address),
|
|
153
|
+
inboxAddress,
|
|
154
|
+
outboxAddress,
|
|
155
|
+
feeJuicePortalAddress,
|
|
156
|
+
feeJuiceAddress,
|
|
157
|
+
stakingAssetAddress,
|
|
158
|
+
rewardDistributorAddress
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async getEpochNumberForSlotNumber(slotNumber) {
|
|
162
|
+
return await this.rollup.read.getEpochAtSlot([
|
|
163
|
+
slotNumber
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
getEpochProofPublicInputs(args) {
|
|
167
|
+
return this.rollup.read.getEpochProofPublicInputs(args);
|
|
168
|
+
}
|
|
169
|
+
async getProofClaim() {
|
|
170
|
+
const { epochToProve, basisPointFee, bondAmount, bondProvider: bondProviderHex, proposerClaimant: proposerClaimantHex } = await this.rollup.read.getProofClaim();
|
|
171
|
+
const bondProvider = EthAddress.fromString(bondProviderHex);
|
|
172
|
+
const proposerClaimant = EthAddress.fromString(proposerClaimantHex);
|
|
173
|
+
if (bondProvider.isZero() && proposerClaimant.isZero() && epochToProve === 0n) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
epochToProve,
|
|
178
|
+
basisPointFee,
|
|
179
|
+
bondAmount,
|
|
180
|
+
bondProvider,
|
|
181
|
+
proposerClaimant
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async getClaimableEpoch() {
|
|
185
|
+
try {
|
|
186
|
+
return await this.rollup.read.getClaimableEpoch();
|
|
187
|
+
} catch (err) {
|
|
188
|
+
throw formatViemError(err);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async getEpochToProve() {
|
|
192
|
+
try {
|
|
193
|
+
return await this.rollup.read.getEpochToProve();
|
|
194
|
+
} catch (err) {
|
|
195
|
+
throw formatViemError(err);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async validateProofQuote(quote, account, slotDuration) {
|
|
199
|
+
if (typeof slotDuration === 'number') {
|
|
200
|
+
slotDuration = BigInt(slotDuration);
|
|
201
|
+
}
|
|
202
|
+
const timeOfNextL1Slot = BigInt((await this.client.getBlock()).timestamp + slotDuration);
|
|
203
|
+
const args = [
|
|
204
|
+
timeOfNextL1Slot,
|
|
205
|
+
quote
|
|
206
|
+
];
|
|
207
|
+
try {
|
|
208
|
+
await this.rollup.read.validateEpochProofRightClaimAtTime(args, {
|
|
209
|
+
account
|
|
210
|
+
});
|
|
211
|
+
} catch (err) {
|
|
212
|
+
throw formatViemError(err);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async validateHeader(args, account) {
|
|
216
|
+
try {
|
|
217
|
+
await this.rollup.read.validateHeader(args, {
|
|
218
|
+
account
|
|
219
|
+
});
|
|
220
|
+
} catch (error) {
|
|
221
|
+
throw formatViemError(error);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @notice Calls `canProposeAtTime` with the time of the next Ethereum block and the sender address
|
|
226
|
+
*
|
|
227
|
+
* @dev Throws if unable to propose
|
|
228
|
+
*
|
|
229
|
+
* @param archive - The archive that we expect to be current state
|
|
230
|
+
* @return [slot, blockNumber] - If you can propose, the L2 slot number and L2 block number of the next Ethereum block,
|
|
231
|
+
* @throws otherwise
|
|
232
|
+
*/ async canProposeAtNextEthBlock(archive, account, slotDuration) {
|
|
233
|
+
if (typeof slotDuration === 'number') {
|
|
234
|
+
slotDuration = BigInt(slotDuration);
|
|
235
|
+
}
|
|
236
|
+
const timeOfNextL1Slot = (await this.client.getBlock()).timestamp + slotDuration;
|
|
237
|
+
try {
|
|
238
|
+
const [slot, blockNumber] = await this.rollup.read.canProposeAtTime([
|
|
239
|
+
timeOfNextL1Slot,
|
|
240
|
+
`0x${archive.toString('hex')}`
|
|
241
|
+
], {
|
|
242
|
+
account
|
|
243
|
+
});
|
|
244
|
+
return [
|
|
245
|
+
slot,
|
|
246
|
+
blockNumber
|
|
247
|
+
];
|
|
248
|
+
} catch (err) {
|
|
249
|
+
throw formatViemError(err);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
_ts_decorate([
|
|
254
|
+
memoize
|
|
255
|
+
], RollupContract.prototype, "getSlashingProposer", null);
|
|
256
|
+
_ts_decorate([
|
|
257
|
+
memoize
|
|
258
|
+
], RollupContract.prototype, "getL1StartBlock", null);
|
|
259
|
+
_ts_decorate([
|
|
260
|
+
memoize
|
|
261
|
+
], RollupContract.prototype, "getL1GenesisTime", null);
|
|
262
|
+
_ts_decorate([
|
|
263
|
+
memoize
|
|
264
|
+
], RollupContract.prototype, "getClaimDurationInL2Slots", null);
|
|
265
|
+
_ts_decorate([
|
|
266
|
+
memoize
|
|
267
|
+
], RollupContract.prototype, "getEpochDuration", null);
|
|
268
|
+
_ts_decorate([
|
|
269
|
+
memoize
|
|
270
|
+
], RollupContract.prototype, "getSlotDuration", null);
|
|
271
|
+
_ts_decorate([
|
|
272
|
+
memoize
|
|
273
|
+
], RollupContract.prototype, "getTargetCommitteeSize", null);
|
|
274
|
+
_ts_decorate([
|
|
275
|
+
memoize
|
|
276
|
+
], RollupContract.prototype, "getMinimumStake", null);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { SlashingProposerAbi } from '@aztec/l1-artifacts';
|
|
3
|
-
import { getContract
|
|
3
|
+
import { getContract } from 'viem';
|
|
4
|
+
import { encodeVote } from './empire_base.js';
|
|
4
5
|
export class SlashingProposerContract {
|
|
5
|
-
|
|
6
|
+
client;
|
|
7
|
+
proposer;
|
|
8
|
+
constructor(client, address){
|
|
6
9
|
this.client = client;
|
|
7
|
-
this.proposer = getContract({
|
|
10
|
+
this.proposer = getContract({
|
|
11
|
+
address,
|
|
12
|
+
abi: SlashingProposerAbi,
|
|
13
|
+
client
|
|
14
|
+
});
|
|
8
15
|
}
|
|
9
16
|
get address() {
|
|
10
17
|
return EthAddress.fromString(this.proposer.address);
|
|
@@ -15,5 +22,26 @@ export class SlashingProposerContract {
|
|
|
15
22
|
getRoundSize() {
|
|
16
23
|
return this.proposer.read.M();
|
|
17
24
|
}
|
|
25
|
+
computeRound(slot) {
|
|
26
|
+
return this.proposer.read.computeRound([
|
|
27
|
+
slot
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
async getRoundInfo(rollupAddress, round) {
|
|
31
|
+
const roundInfo = await this.proposer.read.rounds([
|
|
32
|
+
rollupAddress,
|
|
33
|
+
round
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
lastVote: roundInfo[0],
|
|
37
|
+
leader: roundInfo[1],
|
|
38
|
+
executed: roundInfo[2]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
createVoteRequest(payload) {
|
|
42
|
+
return {
|
|
43
|
+
to: this.address.toString(),
|
|
44
|
+
data: encodeVote(payload)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
18
47
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhc2hpbmdfcHJvcG9zZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RzL3NsYXNoaW5nX3Byb3Bvc2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUUxRCxPQUFPLEVBTUwsV0FBVyxHQUNaLE1BQU0sTUFBTSxDQUFDO0FBRWQsTUFBTSxPQUFPLHdCQUF3QjtJQUduQyxZQUE0QixNQUEwQyxFQUFFLE9BQVk7UUFBeEQsV0FBTSxHQUFOLE1BQU0sQ0FBb0M7UUFDcEUsSUFBSSxDQUFDLFFBQVEsR0FBRyxXQUFXLENBQUMsRUFBRSxPQUFPLEVBQUUsR0FBRyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sRUFBRSxDQUFDLENBQUM7SUFDN0UsQ0FBQztJQUVELElBQVcsT0FBTztRQUNoQixPQUFPLFVBQVUsQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUN0RCxDQUFDO0lBRU0sYUFBYTtRQUNsQixPQUFPLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxDQUFDO0lBQ2hDLENBQUM7SUFFTSxZQUFZO1FBQ2pCLE9BQU8sSUFBSSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDaEMsQ0FBQztDQUNGIn0=
|