Skip to content

Commit 36a2455

Browse files
authored
Merge pull request #2126 from kleros/feat/migration-no-more-neo
No more Neo contract distinction
2 parents 6ded616 + 8636c23 commit 36a2455

File tree

68 files changed

+5341
-5638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5341
-5638
lines changed

contracts/audit/METRICS.html

Lines changed: 413 additions & 419 deletions
Large diffs are not rendered by default.

contracts/audit/METRICS.md

Lines changed: 376 additions & 403 deletions
Large diffs are not rendered by default.

contracts/deploy/00-home-chain-arbitration-neo.ts renamed to contracts/deploy/00-home-chain-arbitration-mainnet.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
66
import { HomeChains, isSkipped, isDevnet, PNK, ETH } from "./utils";
77
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
88
import { deployERC20AndFaucet, deployERC721 } from "./utils/deployTokens";
9-
import { ChainlinkRNG, DisputeKitClassic, KlerosCoreNeo, RNGWithFallback } from "../typechain-types";
9+
import { DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";
1010

1111
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1212
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
@@ -29,26 +29,25 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2929
await deployUpgradable(deployments, "EvidenceModule", { from: deployer, args: [deployer], log: true });
3030

3131
const classicDisputeKitID = 1; // Classic DK
32-
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
32+
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
3333
from: deployer,
34-
contract: "DisputeKitClassic",
3534
args: [deployer, ZeroAddress, weth.target, classicDisputeKitID],
3635
log: true,
3736
});
3837

39-
let klerosCoreAddress = await deployments.getOrNull("KlerosCoreNeo").then((deployment) => deployment?.address);
38+
let klerosCoreAddress = await deployments.getOrNull("KlerosCore").then((deployment) => deployment?.address);
4039
if (!klerosCoreAddress) {
4140
const nonce = await ethers.provider.getTransactionCount(deployer);
4241
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
43-
console.log("calculated future KlerosCoreNeo address for nonce %d: %s", nonce + 3, klerosCoreAddress);
42+
console.log("calculated future KlerosCore address for nonce %d: %s", nonce + 3, klerosCoreAddress);
4443
}
4544
const devnet = isDevnet(hre.network);
4645
const minStakingTime = devnet ? 180 : 1800;
4746
const maxFreezingTime = devnet ? 600 : 1800;
4847
const rngWithFallback = await ethers.getContract<RNGWithFallback>("RNGWithFallback");
4948
const maxStakePerJuror = PNK(2_000);
5049
const maxTotalStaked = PNK(2_000_000);
51-
const sortitionModule = await deployUpgradable(deployments, "SortitionModuleNeo", {
50+
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
5251
from: deployer,
5352
args: [
5453
deployer,
@@ -66,7 +65,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6665
const alpha = 10000;
6766
const feeForJuror = ETH(0.1);
6867
const jurorsForCourtJump = 256;
69-
const klerosCore = await deployUpgradable(deployments, "KlerosCoreNeo", {
68+
const klerosCore = await deployUpgradable(deployments, "KlerosCore", {
7069
from: deployer,
7170
args: [
7271
deployer,
@@ -79,14 +78,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7978
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
8079
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
8180
sortitionModule.address,
82-
nft.target,
8381
weth.target,
82+
nft.target,
8483
],
8584
log: true,
8685
}); // nonce+2 (implementation), nonce+3 (proxy)
8786

8887
// disputeKit.changeCore() only if necessary
89-
const disputeKitContract = await hre.ethers.getContract<DisputeKitClassic>("DisputeKitClassicNeo");
88+
const disputeKitContract = await hre.ethers.getContract<DisputeKitClassic>("DisputeKitClassic");
9089
const currentCore = await disputeKitContract.core();
9190
if (currentCore !== klerosCore.address) {
9291
console.log(`disputeKit.changeCore(${klerosCore.address})`);
@@ -100,7 +99,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
10099
await rngWithFallback.changeConsumer(sortitionModule.address);
101100
}
102101

103-
const core = await hre.ethers.getContract<KlerosCoreNeo>("KlerosCoreNeo");
102+
const core = await hre.ethers.getContract<KlerosCore>("KlerosCore");
104103
try {
105104
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
106105
} catch (e) {
@@ -113,12 +112,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
113112
log: true,
114113
});
115114

116-
const resolver = await deploy("DisputeResolverNeo", {
115+
const resolver = await deploy("DisputeResolver", {
117116
from: deployer,
118-
contract: "DisputeResolver",
119117
args: [core.target, disputeTemplateRegistry.target],
120118
log: true,
121119
});
120+
console.log(`core.changeArbitrableWhitelistEnabled(true)`);
121+
await core.changeArbitrableWhitelistEnabled(true);
122122
console.log(`core.changeArbitrableWhitelist(${resolver.address}, true)`);
123123
await core.changeArbitrableWhitelist(resolver.address, true);
124124

@@ -155,7 +155,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
155155
});
156156
};
157157

158-
deployArbitration.tags = ["ArbitrationNeo"];
158+
deployArbitration.tags = ["ArbitrationMainnet"];
159159
deployArbitration.dependencies = ["ChainlinkRNG"];
160160
deployArbitration.skip = async ({ network }) => {
161161
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);

contracts/deploy/00-home-chain-arbitration.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
66
import { HomeChains, isSkipped, isDevnet, PNK, ETH, Courts } from "./utils";
77
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
88
import { deployERC20AndFaucet } from "./utils/deployTokens";
9-
import { ChainlinkRNG, DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";
9+
import { DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";
1010

1111
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1212
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
@@ -53,7 +53,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5353
const rngWithFallback = await ethers.getContract<RNGWithFallback>("RNGWithFallback");
5454
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
5555
from: deployer,
56-
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rngWithFallback.target],
56+
args: [
57+
deployer,
58+
klerosCoreAddress,
59+
minStakingTime,
60+
maxFreezingTime,
61+
rngWithFallback.target,
62+
ethers.MaxUint256, // maxStakePerJuror
63+
ethers.MaxUint256, // maxTotalStaked
64+
],
5765
log: true,
5866
}); // nonce (implementation), nonce+1 (proxy)
5967

@@ -75,6 +83,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7583
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
7684
sortitionModule.address,
7785
weth.target,
86+
ZeroAddress, // jurorNft
7887
],
7988
log: true,
8089
}); // nonce+2 (implementation), nonce+3 (proxy)

contracts/deploy/change-sortition-module-rng.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { HomeChains, isMainnet, isSkipped } from "./utils";
3+
import { HomeChains, isSkipped } from "./utils";
44
import { ethers } from "hardhat";
5-
import { ChainlinkRNG, SortitionModule, SortitionModuleNeo } from "../typechain-types";
5+
import { ChainlinkRNG, SortitionModule } from "../typechain-types";
66

77
const task: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
88
const { getNamedAccounts, getChainId } = hre;
@@ -13,15 +13,7 @@ const task: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1313
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
1414

1515
const chainlinkRng = await ethers.getContract<ChainlinkRNG>("ChainlinkRNG");
16-
17-
let sortitionModule: SortitionModule | SortitionModuleNeo;
18-
if (isMainnet(hre.network)) {
19-
console.log("Using SortitionModuleNeo");
20-
sortitionModule = await ethers.getContract<SortitionModuleNeo>("SortitionModuleNeo");
21-
} else {
22-
console.log("Using SortitionModule");
23-
sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");
24-
}
16+
const sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");
2517

2618
console.log(`chainlinkRng.changeConsumer(${sortitionModule.target})`);
2719
await chainlinkRng.changeConsumer(sortitionModule.target);

contracts/deploy/upgrade-all.ts

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { prompt, print } from "gluegun";
44
import { deployUpgradable } from "./utils/deployUpgradable";
55
import { HomeChains, isSkipped } from "./utils";
6-
import { getContractNames, getContractNamesFromNetwork } from "../scripts/utils/contracts";
6+
import { getContractNamesFromNetwork } from "../scripts/utils/contracts";
77

88
const { bold } = print.colors;
99

@@ -36,21 +36,7 @@ const deployUpgradeAll: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3636
try {
3737
print.highlight(`🔍 Validating upgrade of ${bold(contractName)}`);
3838

39-
const contractNameWithoutNeo = contractName.replace(/Neo.*$/, "");
4039
let compareStorageOptions = { contract: contractName } as any;
41-
if (hre.network.name === "arbitrum") {
42-
switch (contractName) {
43-
case "KlerosCoreNeo":
44-
case "SortitionModuleNeo":
45-
compareStorageOptions = { deployedArtifact: `${contractName}_Implementation`, contract: contractName };
46-
break;
47-
default:
48-
compareStorageOptions = {
49-
deployedArtifact: `${contractName}_Implementation`,
50-
contract: contractNameWithoutNeo,
51-
};
52-
}
53-
}
5440
await hre.run("compare-storage", compareStorageOptions);
5541
print.newline();
5642
print.highlight(`💣 Upgrading ${bold(contractName)}`);
@@ -65,25 +51,12 @@ const deployUpgradeAll: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6551
}
6652
print.info(`Upgrading ${contractName}...`);
6753

68-
switch (contractName) {
69-
case "DisputeKitClassicNeo":
70-
case "DisputeResolverNeo":
71-
await deployUpgradable(deployments, contractName, {
72-
contract: contractName,
73-
newImplementation: contractNameWithoutNeo,
74-
initializer,
75-
from: deployer,
76-
args, // Warning: do not reinitialize existing state variables, only the new ones
77-
});
78-
break;
79-
default:
80-
await deployUpgradable(deployments, contractName, {
81-
newImplementation: contractName,
82-
initializer,
83-
from: deployer,
84-
args, // Warning: do not reinitialize existing state variables, only the new ones
85-
});
86-
}
54+
await deployUpgradable(deployments, contractName, {
55+
newImplementation: contractName,
56+
initializer,
57+
from: deployer,
58+
args, // Warning: do not reinitialize existing state variables, only the new ones
59+
});
8760
print.info(`Verifying ${contractName} on Etherscan...`);
8861
await hre.run("etherscan-verify", { contractName: `${contractName}_Implementation` });
8962
} catch (err) {

contracts/deploy/utils/klerosCoreHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { KlerosCore, KlerosCoreNeo, KlerosCoreRuler, KlerosCoreUniversity } from "../../typechain-types";
1+
import { KlerosCore, KlerosCoreRuler, KlerosCoreUniversity } from "../../typechain-types";
22
import { BigNumberish, toBigInt } from "ethers";
33

44
export const changeCurrencyRate = async (
5-
core: KlerosCore | KlerosCoreNeo | KlerosCoreRuler | KlerosCoreUniversity,
5+
core: KlerosCore | KlerosCoreRuler | KlerosCoreUniversity,
66
erc20: string,
77
accepted: boolean,
88
rateInEth: BigNumberish,

0 commit comments

Comments
 (0)