Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
import { HomeChains, isSkipped, isDevnet, PNK, ETH } from "./utils";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { deployERC20AndFaucet, deployERC721 } from "./utils/deployTokens";
import { ChainlinkRNG, DisputeKitClassic, KlerosCoreNeo, RNGWithFallback } from "../typechain-types";
import { DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";

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

const classicDisputeKitID = 1; // Classic DK
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
from: deployer,
contract: "DisputeKitClassic",
args: [deployer, ZeroAddress, weth.target, classicDisputeKitID],
log: true,
});

let klerosCoreAddress = await deployments.getOrNull("KlerosCoreNeo").then((deployment) => deployment?.address);
let klerosCoreAddress = await deployments.getOrNull("KlerosCore").then((deployment) => deployment?.address);
if (!klerosCoreAddress) {
const nonce = await ethers.provider.getTransactionCount(deployer);
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
console.log("calculated future KlerosCoreNeo address for nonce %d: %s", nonce + 3, klerosCoreAddress);
console.log("calculated future KlerosCore address for nonce %d: %s", nonce + 3, klerosCoreAddress);
}
const devnet = isDevnet(hre.network);
const minStakingTime = devnet ? 180 : 1800;
const maxFreezingTime = devnet ? 600 : 1800;
const rngWithFallback = await ethers.getContract<RNGWithFallback>("RNGWithFallback");
const maxStakePerJuror = PNK(2_000);
const maxTotalStaked = PNK(2_000_000);
const sortitionModule = await deployUpgradable(deployments, "SortitionModuleNeo", {
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
from: deployer,
args: [
deployer,
Expand All @@ -66,7 +65,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const alpha = 10000;
const feeForJuror = ETH(0.1);
const jurorsForCourtJump = 256;
const klerosCore = await deployUpgradable(deployments, "KlerosCoreNeo", {
const klerosCore = await deployUpgradable(deployments, "KlerosCore", {
from: deployer,
args: [
deployer,
Expand All @@ -79,14 +78,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
sortitionModule.address,
nft.target,
weth.target,
nft.target,
],
log: true,
}); // nonce+2 (implementation), nonce+3 (proxy)

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

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

const resolver = await deploy("DisputeResolverNeo", {
const resolver = await deploy("DisputeResolver", {
from: deployer,
contract: "DisputeResolver",
args: [core.target, disputeTemplateRegistry.target],
log: true,
});
console.log(`core.changeArbitrableWhitelistEnabled(true)`);
await core.changeArbitrableWhitelistEnabled(true);
console.log(`core.changeArbitrableWhitelist(${resolver.address}, true)`);
await core.changeArbitrableWhitelist(resolver.address, true);

Expand Down Expand Up @@ -155,7 +155,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
});
};

deployArbitration.tags = ["ArbitrationNeo"];
deployArbitration.tags = ["ArbitrationMainnet"];
deployArbitration.dependencies = ["ChainlinkRNG"];
deployArbitration.skip = async ({ network }) => {
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
Expand Down
13 changes: 11 additions & 2 deletions contracts/deploy/00-home-chain-arbitration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
import { HomeChains, isSkipped, isDevnet, PNK, ETH, Courts } from "./utils";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { ChainlinkRNG, DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";
import { DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
Expand Down Expand Up @@ -53,7 +53,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const rngWithFallback = await ethers.getContract<RNGWithFallback>("RNGWithFallback");
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
from: deployer,
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rngWithFallback.target],
args: [
deployer,
klerosCoreAddress,
minStakingTime,
maxFreezingTime,
rngWithFallback.target,
ethers.MaxUint256, // maxStakePerJuror
ethers.MaxUint256, // maxTotalStaked
],
log: true,
}); // nonce (implementation), nonce+1 (proxy)

Expand All @@ -75,6 +83,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
sortitionModule.address,
weth.target,
ZeroAddress, // jurorNft
],
log: true,
}); // nonce+2 (implementation), nonce+3 (proxy)
Expand Down
14 changes: 3 additions & 11 deletions contracts/deploy/change-sortition-module-rng.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { HomeChains, isMainnet, isSkipped } from "./utils";
import { HomeChains, isSkipped } from "./utils";
import { ethers } from "hardhat";
import { ChainlinkRNG, SortitionModule, SortitionModuleNeo } from "../typechain-types";
import { ChainlinkRNG, SortitionModule } from "../typechain-types";

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

const chainlinkRng = await ethers.getContract<ChainlinkRNG>("ChainlinkRNG");

let sortitionModule: SortitionModule | SortitionModuleNeo;
if (isMainnet(hre.network)) {
console.log("Using SortitionModuleNeo");
sortitionModule = await ethers.getContract<SortitionModuleNeo>("SortitionModuleNeo");
} else {
console.log("Using SortitionModule");
sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");
}
const sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");

console.log(`chainlinkRng.changeConsumer(${sortitionModule.target})`);
await chainlinkRng.changeConsumer(sortitionModule.target);
Expand Down
41 changes: 7 additions & 34 deletions contracts/deploy/upgrade-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { prompt, print } from "gluegun";
import { deployUpgradable } from "./utils/deployUpgradable";
import { HomeChains, isSkipped } from "./utils";
import { getContractNames, getContractNamesFromNetwork } from "../scripts/utils/contracts";
import { getContractNamesFromNetwork } from "../scripts/utils/contracts";

const { bold } = print.colors;

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

const contractNameWithoutNeo = contractName.replace(/Neo.*$/, "");
let compareStorageOptions = { contract: contractName } as any;
if (hre.network.name === "arbitrum") {
switch (contractName) {
case "KlerosCoreNeo":
case "SortitionModuleNeo":
compareStorageOptions = { deployedArtifact: `${contractName}_Implementation`, contract: contractName };
break;
default:
compareStorageOptions = {
deployedArtifact: `${contractName}_Implementation`,
contract: contractNameWithoutNeo,
};
}
}
await hre.run("compare-storage", compareStorageOptions);
print.newline();
print.highlight(`💣 Upgrading ${bold(contractName)}`);
Expand All @@ -65,25 +51,12 @@ const deployUpgradeAll: DeployFunction = async (hre: HardhatRuntimeEnvironment)
}
print.info(`Upgrading ${contractName}...`);

switch (contractName) {
case "DisputeKitClassicNeo":
case "DisputeResolverNeo":
await deployUpgradable(deployments, contractName, {
contract: contractName,
newImplementation: contractNameWithoutNeo,
initializer,
from: deployer,
args, // Warning: do not reinitialize existing state variables, only the new ones
});
break;
default:
await deployUpgradable(deployments, contractName, {
newImplementation: contractName,
initializer,
from: deployer,
args, // Warning: do not reinitialize existing state variables, only the new ones
});
}
await deployUpgradable(deployments, contractName, {
newImplementation: contractName,
initializer,
from: deployer,
args, // Warning: do not reinitialize existing state variables, only the new ones
});
print.info(`Verifying ${contractName} on Etherscan...`);
await hre.run("etherscan-verify", { contractName: `${contractName}_Implementation` });
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/deploy/utils/klerosCoreHelper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { KlerosCore, KlerosCoreNeo, KlerosCoreRuler, KlerosCoreUniversity } from "../../typechain-types";
import { KlerosCore, KlerosCoreRuler, KlerosCoreUniversity } from "../../typechain-types";
import { BigNumberish, toBigInt } from "ethers";

export const changeCurrencyRate = async (
core: KlerosCore | KlerosCoreNeo | KlerosCoreRuler | KlerosCoreUniversity,
core: KlerosCore | KlerosCoreRuler | KlerosCoreUniversity,
erc20: string,
accepted: boolean,
rateInEth: BigNumberish,
Expand Down
6 changes: 3 additions & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
"docbuild": "scripts/docPreprocess.sh && forge doc --build --out dist && scripts/docPostprocess.sh",
"populate:courts:devnet": "hardhat populate:courts --from v2_devnet --network arbitrumSepoliaDevnet",
"populate:courts:testnet": "hardhat populate:courts --from v2_testnet --network arbitrumSepolia",
"populate:courts:mainnetNeo": "hardhat populate:courts --core-type neo --from v2_mainnet_neo --network arbitrum",
"populate:policiesUris": "scripts/setPoliciesURIs.sh config/policies.v2.{devnet,testnet,mainnet-neo}.json",
"populate:courts:mainnet": "hardhat populate:courts --from v2_mainnet --network arbitrum",
"populate:policiesUris": "scripts/setPoliciesURIs.sh config/policies.v2.{devnet,testnet,mainnet}.json",
"populate:policies:devnet": "hardhat populate:policy-registry --from v2_devnet --network arbitrumSepoliaDevnet",
"populate:policies:testnet": "hardhat populate:policy-registry --from v2_testnet --network arbitrumSepolia",
"populate:policies:mainnetNeo": "hardhat populate:policy-registry --from v2_mainnet_neo --network arbitrum",
"populate:policies:mainnet": "hardhat populate:policy-registry --from v2_mainnet --network arbitrum",
"release:patch": "scripts/publish.sh patch",
"release:minor": "scripts/publish.sh minor",
"release:major": "scripts/publish.sh major",
Expand Down
6 changes: 3 additions & 3 deletions contracts/scripts/generateDeploymentsMarkdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function generate() { #deploymentDir #explorerUrl
done
}

echo "### V2 Neo (prelaunch)"
echo "### V2 Mainnet"
echo "#### Arbitrum One"
echo
generate "$SCRIPT_DIR/../deployments/arbitrum" "https://arbiscan.io/address/" | grep -v 'DAI\|WETH\|PNKFaucet'
echo
echo "### Official Testnet"
echo "### V2 Testnet"
echo "#### Arbitrum Sepolia"
echo
generate "$SCRIPT_DIR/../deployments/arbitrumSepolia" "https://sepolia.arbiscan.io/address/"
Expand All @@ -47,7 +47,7 @@ echo
generate "$SCRIPT_DIR/../deployments/chiado" "https://gnosis-chiado.blockscout.com/address/"
echo

echo "### Devnet"
echo "### V2 Devnet (unstable)"
echo "#### Arbitrum Sepolia"
echo
generate "$SCRIPT_DIR/../deployments/arbitrumSepoliaDevnet" "https://sepolia.arbiscan.io/address/"
Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/storage-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
task("storage-layout", "Prints the storage layout of a contract").setAction(
async ({}, hre: HardhatRuntimeEnvironment) => {
await hre.run("compile");
const buildInfo = await hre.artifacts.getBuildInfo(`src/arbitration/KlerosCoreNeo.sol:KlerosCoreNeo`);
console.log(buildInfo.output.contracts["src/arbitration/KlerosCoreNeo.sol"]["KlerosCoreNeo"].storageLayout);
const buildInfo = await hre.artifacts.getBuildInfo(`src/arbitration/KlerosCore.sol:KlerosCore`);
console.log(buildInfo.output.contracts["src/arbitration/KlerosCore.sol"]["KlerosCore"].storageLayout);
}
);
Loading
Loading