Skip to content

Commit f7b7ac8

Browse files
committed
fix: hardhat ethers versions bump, test fix
1 parent 434ccea commit f7b7ac8

File tree

7 files changed

+3727
-3923
lines changed

7 files changed

+3727
-3923
lines changed

contracts/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
"@kleros/kleros-v2-prettier-config": "workspace:^",
6262
"@kleros/kleros-v2-tsconfig": "workspace:^",
6363
"@logtail/pino": "^0.4.19",
64-
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
65-
"@nomicfoundation/hardhat-ethers": "^3.0.0",
66-
"@nomiclabs/hardhat-solhint": "^3.0.1",
67-
"@openzeppelin/contracts": "^5.0.2",
68-
"@typechain/ethers-v6": "^0.5.0",
64+
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
65+
"@nomicfoundation/hardhat-ethers": "^3.0.8",
66+
"@nomiclabs/hardhat-solhint": "^3.1.0",
67+
"@openzeppelin/contracts": "^5.1.0",
68+
"@typechain/ethers-v6": "^0.5.1",
6969
"@typechain/hardhat": "^9.1.0",
7070
"@types/chai": "^4.3.11",
7171
"@types/mocha": "^10.0.6",
@@ -75,17 +75,17 @@
7575
"chai": "^4.4.1",
7676
"dotenv": "^16.3.1",
7777
"ethereumjs-util": "^7.1.5",
78-
"ethers": "^6.10.0",
78+
"ethers": "^6.13.4",
7979
"graphql": "^16.8.1",
8080
"graphql-request": "^6.1.0",
81-
"hardhat": "2.19.0",
81+
"hardhat": "2.22.15",
8282
"hardhat-contract-sizer": "^2.10.0",
83-
"hardhat-deploy": "^0.11.45",
84-
"hardhat-deploy-ethers": "^0.4.1",
83+
"hardhat-deploy": "^0.14.0",
84+
"hardhat-deploy-ethers": "^0.4.2",
8585
"hardhat-deploy-tenderly": "^0.2.0",
8686
"hardhat-docgen": "^1.3.0",
87-
"hardhat-gas-reporter": "^1.0.9",
88-
"hardhat-tracer": "^2.7.0",
87+
"hardhat-gas-reporter": "^1.0.10",
88+
"hardhat-tracer": "^3.1.0",
8989
"hardhat-watcher": "^2.5.0",
9090
"node-fetch": "^3.3.2",
9191
"pino": "^8.17.2",

contracts/scripts/keeperBot.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const passPhase = async () => {
192192
}
193193
const before = getNumber(await sortition.phase());
194194
try {
195-
const gas = ((await sortition.passPhase.estimateGas()) * toBigInt(150)) / toBigInt(100); // 50% extra gas
195+
const gas = ((await sortition.passPhase.estimateGas()) * 150n) / 100n; // 50% extra gas
196196
const tx = await (await sortition.passPhase({ gasLimit: gas })).wait();
197197
logger.info(`passPhase txID: ${tx?.hash}`);
198198
} catch (e) {
@@ -221,7 +221,7 @@ const passPeriod = async (dispute: { id: string }) => {
221221
}
222222
const before = (await core.disputes(dispute.id)).period;
223223
try {
224-
const gas = ((await core.passPeriod.estimateGas(dispute.id)) * toBigInt(150)) / toBigInt(100); // 50% extra gas
224+
const gas = ((await core.passPeriod.estimateGas(dispute.id)) * 150n) / 100n; // 50% extra gas
225225
const tx = await (await core.passPeriod(dispute.id, { gasLimit: gas })).wait();
226226
logger.info(`passPeriod txID: ${tx?.hash}`);
227227
} catch (e) {
@@ -285,7 +285,7 @@ const executeRuling = async (dispute: { id: string }) => {
285285
return success;
286286
}
287287
try {
288-
const gas = ((await core.executeRuling.estimateGas(dispute.id)) * toBigInt(150)) / toBigInt(100); // 50% extra gas
288+
const gas = ((await core.executeRuling.estimateGas(dispute.id)) * 150n) / 100n; // 50% extra gas
289289
const tx = await (await core.executeRuling(dispute.id, { gasLimit: gas })).wait();
290290
logger.info(`ExecuteRuling txID: ${tx?.hash}`);
291291
success = true;
@@ -302,7 +302,7 @@ const withdrawAppealContribution = async (
302302
): Promise<boolean> => {
303303
const { disputeKitClassic: kit } = await getContracts();
304304
let success = false;
305-
let amountWithdrawn = toBigInt(0);
305+
let amountWithdrawn = 0n;
306306
try {
307307
amountWithdrawn = await kit.withdrawFeesAndRewards.staticCall(
308308
disputeId,
@@ -316,7 +316,7 @@ const withdrawAppealContribution = async (
316316
);
317317
return success;
318318
}
319-
if (amountWithdrawn === toBigInt(0)) {
319+
if (amountWithdrawn === 0n) {
320320
logger.debug(
321321
`WithdrawFeesAndRewards: no fees or rewards to withdraw for dispute #${disputeId}, round #${roundId}, choice ${contribution.choice} and beneficiary ${contribution.contributor.id}, skipping`
322322
);
@@ -333,8 +333,8 @@ const withdrawAppealContribution = async (
333333
roundId,
334334
contribution.choice
335335
)) *
336-
toBigInt(150)) /
337-
toBigInt(100); // 50% extra gas
336+
150n) /
337+
100n; // 50% extra gas
338338
const tx = await (
339339
await kit.withdrawFeesAndRewards(disputeId, contribution.contributor.id, roundId, contribution.choice, {
340340
gasLimit: gas,
@@ -353,14 +353,14 @@ const executeDelayedStakes = async () => {
353353

354354
// delayedStakes = 1 + delayedStakeWriteIndex - delayedStakeReadIndex
355355
const delayedStakesRemaining =
356-
toBigInt(1) + (await sortition.delayedStakeWriteIndex()) - (await sortition.delayedStakeReadIndex());
356+
1n + (await sortition.delayedStakeWriteIndex()) - (await sortition.delayedStakeReadIndex());
357357

358358
const delayedStakes =
359359
delayedStakesRemaining < MAX_DELAYED_STAKES_ITERATIONS
360360
? delayedStakesRemaining
361361
: toBigInt(MAX_DELAYED_STAKES_ITERATIONS);
362362

363-
if (delayedStakes === toBigInt(0)) {
363+
if (delayedStakes === 0n) {
364364
logger.info("No delayed stakes to execute");
365365
return true;
366366
}
@@ -373,7 +373,7 @@ const executeDelayedStakes = async () => {
373373
return success;
374374
}
375375
try {
376-
const gas = ((await sortition.executeDelayedStakes.estimateGas(delayedStakes)) * toBigInt(150)) / toBigInt(100); // 50% extra gas
376+
const gas = ((await sortition.executeDelayedStakes.estimateGas(delayedStakes)) * 150n) / 100n; // 50% extra gas
377377
const tx = await (await sortition.executeDelayedStakes(delayedStakes, { gasLimit: gas })).wait();
378378
logger.info(`executeDelayedStakes txID: ${tx?.hash}`);
379379
} catch (e) {
@@ -389,7 +389,7 @@ const getMissingJurors = async (dispute: { id: string; currentRoundIndex: string
389389
};
390390

391391
const isDisputeFullyDrawn = async (dispute: { id: string; currentRoundIndex: string }): Promise<boolean> => {
392-
return (await getMissingJurors(dispute)) === toBigInt(0);
392+
return (await getMissingJurors(dispute)) === 0n;
393393
};
394394

395395
const getNumberOfMissingRepartitions = async (
@@ -398,7 +398,7 @@ const getNumberOfMissingRepartitions = async (
398398
) => {
399399
const { core } = await getContracts();
400400
const { repartitions, drawnJurors } = await core.getRoundInfo(dispute.id, dispute.currentRoundIndex);
401-
return coherentCount === toBigInt(0)
401+
return coherentCount === 0n
402402
? drawnJurors.length - getNumber(repartitions)
403403
: 2 * drawnJurors.length - getNumber(repartitions);
404404
};
@@ -545,7 +545,7 @@ async function main() {
545545
await delay(ITERATIONS_COOLDOWN_PERIOD); // To avoid spiking the gas price
546546
maxDrawingTimePassed = await hasMaxDrawingTimePassed();
547547
numberOfMissingJurors = await getMissingJurors(dispute);
548-
} while (!(numberOfMissingJurors === toBigInt(0)) && !maxDrawingTimePassed);
548+
} while (!(numberOfMissingJurors === 0n) && !maxDrawingTimePassed);
549549
}
550550
// At this point, either all disputes are fully drawn or max drawing time has passed
551551
}
@@ -589,7 +589,7 @@ async function main() {
589589

590590
for (var dispute of unprocessedDisputesInExecution) {
591591
const { period } = await core.disputes(dispute.id);
592-
if (period !== toBigInt(4)) {
592+
if (period !== 4n) {
593593
logger.info(`Skipping dispute #${dispute.id} because it is not in the execution period`);
594594
continue;
595595
}
@@ -642,7 +642,7 @@ async function main() {
642642
contributions = [...new Set(contributions)];
643643
for (let contribution of contributions) {
644644
// Could be improved by pinpointing exactly which round requires a withdrawal, just try all of them for now.
645-
for (let round = toBigInt(dispute.currentRoundIndex); round >= 0; round = round - toBigInt(1)) {
645+
for (let round = toBigInt(dispute.currentRoundIndex); round >= 0; round = round - 1n) {
646646
await withdrawAppealContribution(dispute.id, round.toString(), contribution);
647647
await delay(ITERATIONS_COOLDOWN_PERIOD); // To avoid spiking the gas price
648648
}

contracts/test/arbitration/draw.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe("Draw Benchmark", async () => {
139139
});
140140
if (tx.blockNumber === null) throw new Error("tx.blockNumber is null");
141141
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
142-
const [disputeId] = abiCoder.decode(["uint"], `0x${trace.returnValue}`);
142+
const [disputeId] = abiCoder.decode(["uint"], ethers.getBytes(`${trace.returnValue}`));
143143
const lastBlock = await ethers.provider.getBlock(tx.blockNumber - 1);
144144
if (lastBlock?.hash === null || lastBlock?.hash === undefined) throw new Error("lastBlock is null || undefined");
145145
// Relayer tx

contracts/test/integration/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe("Integration tests", async () => {
107107
});
108108

109109
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
110-
const [disputeId] = abiCoder.decode(["uint"], `0x${trace.returnValue}`); // get returned value from createDispute()
110+
const [disputeId] = abiCoder.decode(["uint"], ethers.getBytes(`${trace.returnValue}`)); // get returned value from createDispute()
111111
console.log("Dispute Created with disputeId: %d", disputeId);
112112
await expect(tx)
113113
.to.emit(foreignGateway, "CrossChainDisputeOutgoing")

contracts/test/rng/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ describe("BlockHashRNG", async () => {
3333
it("Should return a non-zero number for a block number in the past", async () => {
3434
const tx = await rng.receiveRandomness(9876543210);
3535
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
36-
const [rn] = abiCoder.decode(["uint"], `0x${trace.returnValue}`);
36+
const [rn] = abiCoder.decode(["uint"], ethers.getBytes(`${trace.returnValue}`));
3737
expect(rn).to.equal(0);
3838
});
3939

4040
it("Should return zero for a block number in the future", async () => {
4141
const tx = await rng.receiveRandomness(5);
4242
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
43-
const [rn] = abiCoder.decode(["uint"], `0x${trace.returnValue}`);
43+
const [rn] = abiCoder.decode(["uint"], ethers.getBytes(`${trace.returnValue}`));
4444
expect(rn).to.not.equal(0);
4545
});
4646
});

kleros-sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@kleros/kleros-v2-contracts": "workspace:^",
38-
"@reality.eth/reality-eth-lib": "^3.2.30",
38+
"@reality.eth/reality-eth-lib": "^3.2.44",
3939
"mustache": "^4.2.0",
4040
"zod": "^3.22.4"
4141
}

0 commit comments

Comments
 (0)