Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore(hardhat)/hardhat ether version update #1620

Merged
merged 24 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
068c649
chore: dependency update
Anmol-Dhiman Jun 17, 2024
aae6752
chore: merge dev
Anmol-Dhiman Jun 17, 2024
13a8931
chore: deploy utils refactor
Anmol-Dhiman Jun 17, 2024
9badc57
chore: deploy scripts
Anmol-Dhiman Jun 17, 2024
a22ade0
chore: scripts simulation
Anmol-Dhiman Jun 19, 2024
bfaefd2
chore: keeper bot script
Anmol-Dhiman Jun 19, 2024
a34870c
Merge branch 'dev' into chore(hardhat)/hardhat-ether-version-update
Anmol-Dhiman Jun 19, 2024
6fb8d96
chore: rng testcases
Anmol-Dhiman Jun 21, 2024
b558f6e
chore: branch update
Anmol-Dhiman Jun 21, 2024
6d486ce
chore: proxy and integration test update
Anmol-Dhiman Jun 21, 2024
d6b5531
chore: evidence test update
Anmol-Dhiman Jun 21, 2024
c9492b2
chore: arbitration/staking.ts update
Anmol-Dhiman Jun 21, 2024
d1c5961
chore: draw staking-neo and disputeKit upgrade
Anmol-Dhiman Jun 21, 2024
df6132e
chore: integration test update
Anmol-Dhiman Jun 21, 2024
acbdccd
chore: merge dev
Anmol-Dhiman Jun 21, 2024
8f1ed1a
chore: approval changes
Anmol-Dhiman Jun 21, 2024
97755ae
chore: solidity coverage workflow fix
Anmol-Dhiman Jun 26, 2024
b1e4632
chore: contracts testing yml fix
Anmol-Dhiman Jun 26, 2024
434ccea
Apply suggestions from code review
jaybuidl Nov 4, 2024
f7b7ac8
fix: hardhat ethers versions bump, test fix
jaybuidl Nov 5, 2024
0b88e87
Merge branch 'dev' into chore(hardhat)/hardhat-ether-version-update
jaybuidl Nov 5, 2024
205a708
chore: bumped contracts testing workflow
jaybuidl Nov 5, 2024
9c01a4c
fix: mostly minor
jaybuidl Nov 5, 2024
8c91784
fix: coderabbit
jaybuidl Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/contracts-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
uses: step-security/harden-runner@v2.10.1
with:
disable-sudo: true
egress-policy: block
Expand All @@ -40,14 +40,14 @@ jobs:
54.185.253.63:443

- name: Setup Node.js environment
uses: actions/setup-node@2a017f350dbf6c4b6bb4508cc83809719115162e
uses: actions/setup-node@v4
with:
node-version: 18.x

- uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
- uses: actions/checkout@v4

- name: Cache node modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -74,11 +74,11 @@ jobs:

- name: Test with coverage
run: |
yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\" --show-stack-traces
yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles './test/**/*.ts' --show-stack-traces
working-directory: contracts

- name: Upload a build artifact
uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: contracts/coverage
19 changes: 9 additions & 10 deletions contracts/deploy/00-home-chain-arbitration-neo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { BigNumber, BigNumberish } from "ethers";
import { getContractAddress } from "./utils/getContractAddress";
import { deployUpgradable } from "./utils/deployUpgradable";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
Expand All @@ -12,7 +11,7 @@ import { DisputeKitClassic, KlerosCoreNeo } from "../typechain-types";
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { deploy, execute } = deployments;
const { AddressZero } = hre.ethers.constants;
const { ZeroAddress } = hre.ethers;
const RNG_LOOKAHEAD = 20;

// fallback to hardhat node signers on local network
Expand All @@ -37,14 +36,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const rng = await deployUpgradable(deployments, "RandomizerRNG", {
from: deployer,
args: [randomizerOracle.address, deployer],
args: [randomizerOracle.target, deployer],
log: true,
});

const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
from: deployer,
contract: "DisputeKitClassic",
args: [deployer, AddressZero],
args: [deployer, ZeroAddress],
log: true,
});

Expand Down Expand Up @@ -83,15 +82,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
args: [
deployer,
deployer,
pnk.address,
AddressZero,
pnk.target,
ZeroAddress,
disputeKit.address,
false,
[minStake, alpha, feeForJuror, jurorsForCourtJump],
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
ethers.utils.hexlify(5), // Extra data for sortition module will return the default value of K
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
sortitionModule.address,
nft.address,
nft.target,
],
log: true,
}); // nonce+2 (implementation), nonce+3 (proxy)
Expand All @@ -106,7 +105,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const core = (await hre.ethers.getContract("KlerosCoreNeo")) as KlerosCoreNeo;
try {
await changeCurrencyRate(core, weth.address, true, 1, 1);
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
} catch (e) {
console.error("failed to change currency rates:", e);
}
Expand All @@ -120,7 +119,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const resolver = await deploy("DisputeResolverNeo", {
from: deployer,
contract: "DisputeResolver",
args: [core.address, disputeTemplateRegistry.address],
args: [core.target, disputeTemplateRegistry.target],
log: true,
});

Expand Down
39 changes: 11 additions & 28 deletions contracts/deploy/00-home-chain-arbitration-ruler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { BigNumber, BigNumberish } from "ethers";
import { deployUpgradable } from "./utils/deployUpgradable";
import { HomeChains, isSkipped } from "./utils";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { KlerosCore } from "../typechain-types";
import { KlerosCore, KlerosCoreRuler } from "../typechain-types";
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

// fallback to hardhat node signers on local network
Expand All @@ -22,40 +22,23 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const minStake = 0;
const alpha = 10000;
const feeForJuror = BigNumber.from(10).pow(17);
const feeForJuror = 10n ** 17n;
const jurorsForCourtJump = 16;
const klerosCore = await deployUpgradable(deployments, "KlerosCoreRuler", {
await deployUpgradable(deployments, "KlerosCoreRuler", {
from: deployer,
args: [
deployer, // governor
pnk.address,
pnk.target,
[minStake, alpha, feeForJuror, jurorsForCourtJump],
],
log: true,
});

const changeCurrencyRate = async (
erc20: string,
accepted: boolean,
rateInEth: BigNumberish,
rateDecimals: BigNumberish
) => {
const core = (await ethers.getContract("KlerosCoreRuler")) as KlerosCore;
const pnkRate = await core.currencyRates(erc20);
if (pnkRate.feePaymentAccepted !== accepted) {
console.log(`core.changeAcceptedFeeTokens(${erc20}, ${accepted})`);
await core.changeAcceptedFeeTokens(erc20, accepted);
}
if (!pnkRate.rateInEth.eq(rateInEth) || pnkRate.rateDecimals !== rateDecimals) {
console.log(`core.changeCurrencyRates(${erc20}, ${rateInEth}, ${rateDecimals})`);
await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
}
};
const core = (await hre.ethers.getContract("KlerosCoreRuler")) as KlerosCoreRuler;

try {
await changeCurrencyRate(pnk.address, true, 12225583, 12);
await changeCurrencyRate(dai.address, true, 60327783, 11);
await changeCurrencyRate(weth.address, true, 1, 1);
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
} catch (e) {
console.error("failed to change currency rates:", e);
}
Expand All @@ -68,7 +51,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

await deploy("DisputeResolverRuler", {
from: deployer,
args: [klerosCore.address, disputeTemplateRegistry.address],
args: [core.target, disputeTemplateRegistry.target],
log: true,
});
};
Expand Down
19 changes: 9 additions & 10 deletions contracts/deploy/00-home-chain-arbitration-university.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { BigNumber, BigNumberish } from "ethers";
import { getContractAddress } from "./utils/getContractAddress";
import { deployUpgradable } from "./utils/deployUpgradable";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
Expand All @@ -12,7 +11,7 @@ import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;
const { AddressZero } = hre.ethers.constants;
const { ZeroAddress } = hre.ethers;

// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
Expand All @@ -26,7 +25,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicUniversity", {
from: deployer,
contract: "DisputeKitClassic",
args: [deployer, AddressZero],
args: [deployer, ZeroAddress],
log: true,
});

Expand All @@ -51,8 +50,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
args: [
deployer, // governor
deployer, // instructor
pnk.address,
AddressZero,
pnk.target,
ZeroAddress,
disputeKit.address,
false,
[minStake, alpha, feeForJuror, jurorsForCourtJump],
Expand All @@ -72,11 +71,11 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const core = (await hre.ethers.getContract("KlerosCoreUniversity")) as KlerosCoreUniversity;
try {
await changeCurrencyRate(core, pnk.address, true, 12225583, 12);
await changeCurrencyRate(core, dai.address, true, 60327783, 11);
await changeCurrencyRate(core, weth.address, true, 1, 1);
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
} catch (e) {
console.error("failed to change currency rates:", e);
console.error("Failed to change currency rates for token, with error:", e);
}

const disputeTemplateRegistry = await getContractOrDeployUpgradable(hre, "DisputeTemplateRegistry", {
Expand All @@ -88,7 +87,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
await deploy("DisputeResolverUniversity", {
from: deployer,
contract: "DisputeResolver",
args: [core.address, disputeTemplateRegistry.address],
args: [core.target, disputeTemplateRegistry.target],
log: true,
});
};
Expand Down
19 changes: 9 additions & 10 deletions contracts/deploy/00-home-chain-arbitration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { BigNumber, BigNumberish } from "ethers";
import { getContractAddress } from "./utils/getContractAddress";
import { deployUpgradable } from "./utils/deployUpgradable";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
Expand All @@ -11,7 +10,7 @@ import { DisputeKitClassic, KlerosCore } from "../typechain-types";

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { AddressZero } = hre.ethers.constants;
const { ZeroAddress } = hre.ethers;
const RNG_LOOKAHEAD = 20;

// fallback to hardhat node signers on local network
Expand All @@ -36,13 +35,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const rng = await deployUpgradable(deployments, "RandomizerRNG", {
from: deployer,
args: [randomizerOracle.address, deployer],
args: [randomizerOracle.target, deployer],
log: true,
});

const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
from: deployer,
args: [deployer, AddressZero],
args: [deployer, ZeroAddress],
log: true,
});

Expand Down Expand Up @@ -70,13 +69,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
args: [
deployer,
deployer,
pnk.address,
AddressZero,
pnk.target,
ZeroAddress,
disputeKit.address,
false,
[minStake, alpha, feeForJuror, jurorsForCourtJump],
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
ethers.utils.hexlify(5), // Extra data for sortition module will return the default value of K
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
sortitionModule.address,
],
log: true,
Expand All @@ -92,9 +91,9 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const core = (await hre.ethers.getContract("KlerosCore")) as KlerosCore;
try {
await changeCurrencyRate(core, pnk.address, true, 12225583, 12);
await changeCurrencyRate(core, dai.address, true, 60327783, 11);
await changeCurrencyRate(core, weth.address, true, 1, 1);
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
} catch (e) {
console.error("failed to change currency rates:", e);
}
Expand Down
9 changes: 2 additions & 7 deletions contracts/deploy/00-home-chain-pnk-faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pnkByChain = new Map<HomeChains, string>([
]);

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy, execute } = deployments;

// fallback to hardhat node signers on local network
Expand All @@ -24,12 +24,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
args: [pnkAddress],
log: true,
});
await execute(
"PNKFaucet",
{ from: deployer, log: true },
"changeAmount",
hre.ethers.utils.parseUnits("10000", "ether")
);
await execute("PNKFaucet", { from: deployer, log: true }, "changeAmount", hre.ethers.parseUnits("10000", "ether"));
}
};

Expand Down
8 changes: 4 additions & 4 deletions contracts/deploy/01-foreign-gateway-on-ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { deployUpgradable } from "./utils/deployUpgradable";

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
const { deploy, execute } = deployments;
const { hexZeroPad, hexlify } = ethers.utils;
const { execute } = deployments;
const { zeroPadValue, toBeHex } = ethers;

// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
Expand All @@ -19,7 +19,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
// TODO: use deterministic deployments
const network = config.networks[hre.network.name];
const homeNetwork = config.networks[network.companionNetworks.home] as HttpNetworkConfig;
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetwork.url);
const homeChainProvider = new ethers.JsonRpcProvider(homeNetwork.url);
let nonce = await homeChainProvider.getTransactionCount(deployer);
nonce += 1; // HomeGatewayToEthereum Proxy deploy tx will be the 2nd tx after this on its home network, so we add 1 to the current nonce.
const homeGatewayAddress = getContractAddress(deployer, nonce);
Expand All @@ -29,7 +29,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
console.log("using VeaOutboxArbToEthDevnet at %s", veaOutbox.address);

const homeChainId = (await homeChainProvider.getNetwork()).chainId;
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
const homeChainIdAsBytes32 = zeroPadValue(toBeHex(homeChainId), 32);
await deployUpgradable(deployments, "ForeignGatewayOnEthereum", {
from: deployer,
contract: "ForeignGateway",
Expand Down
Loading
Loading