Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybuidl committed Nov 7, 2024
2 parents 0b1d63e + 690069b commit ba231ff
Show file tree
Hide file tree
Showing 49 changed files with 3,395 additions and 1,371 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.yarn/install-state.gz

contracts/.env
contracts/.env.*
contracts/test
contracts/lib
contracts/cache
contracts/cache_hardhat
contracts/config
contracts/tenderly.yaml

*/.DS_Store
*/*.log
*/*.log
17 changes: 9 additions & 8 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
- [BlockHashRNG](https://sepolia.arbiscan.io/address/0x0298a3EFa6Faf90865725E2b48Cf0F66e5d52754)
- [DAI](https://sepolia.arbiscan.io/address/0xc34aeFEa232956542C5b2f2EE55fD5c378B35c03)
- [DAIFaucet](https://sepolia.arbiscan.io/address/0x1Fa58B52326488D62A406E71DBaD839560e810fF)
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x10bDc76B491BFcA466AB5C74431880C086b07c67), [implementation](https://sepolia.arbiscan.io/address/0x718a6FB3b6f8dc8205e9052E6B745Ff0c23205dD)
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xa5A7F0F8e5f90eb8738C7Ee1be37A9794024Bc1B)
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xf2833d188269Df7c7B6951f9114DA0bD6BAE70af), [implementation](https://sepolia.arbiscan.io/address/0xa04d631e5660635D8e8f724F799A4e83Bb1EDb18)
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xFA4Df75ab27525e65Db073a9aF195cd6B7707046), [implementation](https://sepolia.arbiscan.io/address/0xA1280FA86a65c4Fe6e22586066A89372C22AA03f)
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0x8ab813348fA90DE51A87131365c458D43ca03F9c), [implementation](https://sepolia.arbiscan.io/address/0xea9cc831DA99C2d9EeC82aA8d281Bb3e26572e52)
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x0c38f115D001d3b5bBec5e8D44f78C7B61A27D94), [implementation](https://sepolia.arbiscan.io/address/0xDb0B7908C46E2Bb08459bf9b3155b9bb8F8713E1)
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xed31bEE8b1F7cE89E93033C0d3B2ccF4cEb27652)
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xe763d31Cb096B4bc7294012B78FC7F148324ebcb), [implementation](https://sepolia.arbiscan.io/address/0x7283c07CC5224B20f431B1fa0E6d6db3cA02de34)
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xA88A9a25cE7f1d8b3941dA3b322Ba91D009E1397), [implementation](https://sepolia.arbiscan.io/address/0x63CF56e1c99E65E4a9eCDCC805F4735E016F2dc8)
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xE8442307d36e9bf6aB27F1A009F95CE8E11C3479), [implementation](https://sepolia.arbiscan.io/address/0x0766e4B8c4a3aAC9371a5A9D6119E8125Adcfd55)
- [PNKFaucet](https://sepolia.arbiscan.io/address/0x9f6ffc13B685A68ae359fCA128dfE776458Df464)
- [PinakionV2](https://sepolia.arbiscan.io/address/0x34B944D42cAcfC8266955D07A80181D2054aa225)
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0xb177AC8827146AC74C412688c6b10676ca170096), [implementation](https://sepolia.arbiscan.io/address/0xd543D50dcba2c3E067296210D64c8F91206Df908)
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0x1E2960117f570f48c773154C0A63919c12Db0Cc2), [implementation](https://sepolia.arbiscan.io/address/0x0974eF19c9202141D20ce50D60c5A3c522e7A9Ae)
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0xa156fAC2e209126273f841E81490DA7D4381Cc03), [implementation](https://sepolia.arbiscan.io/address/0xF506eA3E25ed3BFc9aFa30c81e0254cb0E4E0A35)
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0x2668c46A14af8997417138B064ca1bEB70769585), [implementation](https://sepolia.arbiscan.io/address/0xB958113f96950C7806d584eFBed964288d46a0B8)
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0x51a97ad9F0aA818e75819da3cA20CAc319580627), [implementation](https://sepolia.arbiscan.io/address/0x1237F02bBeFDAEA20cE3A66aCAe458C4106Ae203)
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0xbAA5068F0bD1417046250A3eDe2B1F27e31383BD), [implementation](https://sepolia.arbiscan.io/address/0xA418a7E63DC8Aa0F379487E4445f86543C16A0E9)
- [TransactionBatcher](https://sepolia.arbiscan.io/address/0x35f93986950804ac1F93519BF68C2a7Dd776db0E)
- [WETH](https://sepolia.arbiscan.io/address/0xAEE953CC26DbDeA52beBE3F97f281981f2B9d511)
- [WETHFaucet](https://sepolia.arbiscan.io/address/0x922B84134e41BC5c9EDE7D5EFCE22Ba3D0e71835)

Expand Down
2 changes: 2 additions & 0 deletions contracts/deploy/00-home-chain-arbitration-neo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
const nft = await deployERC721(hre, deployer, "Kleros V2 Neo Early User", "KlerosV2NeoEarlyUser");

await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });

const randomizerOracle = await getContractOrDeploy(hre, "RandomizerOracle", {
from: deployer,
contract: "RandomizerMock",
Expand Down
6 changes: 4 additions & 2 deletions contracts/deploy/00-home-chain-arbitration-ruler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { DeployFunction } from "hardhat-deploy/types";
import { deployUpgradable } from "./utils/deployUpgradable";
import { HomeChains, isSkipped } from "./utils";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { KlerosCore, KlerosCoreRuler } from "../typechain-types";
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { KlerosCoreRuler } from "../typechain-types";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
Expand All @@ -20,6 +20,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");

await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });

const minStake = 0;
const alpha = 10000;
const feeForJuror = 10n ** 17n;
Expand Down
4 changes: 3 additions & 1 deletion contracts/deploy/00-home-chain-arbitration-university.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
import { ETH, HomeChains, PNK, isSkipped } from "./utils";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { DisputeKitClassic, KlerosCore, KlerosCoreUniversity } from "../typechain-types";
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
Expand All @@ -22,6 +22,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");

await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });

const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicUniversity", {
from: deployer,
contract: "DisputeKitClassic",
Expand Down
18 changes: 15 additions & 3 deletions contracts/deploy/00-home-chain-arbitration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { getContractAddress } from "./utils/getContractAddress";
import { deployUpgradable } from "./utils/deployUpgradable";
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
import { HomeChains, isSkipped, isDevnet, PNK, ETH } from "./utils";
import { HomeChains, isSkipped, isDevnet, isMainnet, PNK, ETH } from "./utils";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { DisputeKitClassic, KlerosCore } from "../typechain-types";
Expand All @@ -22,6 +22,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");

await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });

await getContractOrDeployUpgradable(hre, "PolicyRegistry", { from: deployer, args: [deployer], log: true });

await getContractOrDeployUpgradable(hre, "EvidenceModule", { from: deployer, args: [deployer], log: true });
Expand All @@ -34,12 +36,22 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
log: true,
});

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

const blockhashRng = await getContractOrDeploy(hre, "BlockHashRNG", {
from: deployer,
args: [],
log: true,
});

// RNG fallback on Arbitrum Sepolia because the Randomizer.ai oracle contract is unverified and not officially supported.
const rng = isMainnet(hre.network) ? randomizerRng : blockhashRng;
console.log(isMainnet(hre.network) ? "using RandomizerRNG on mainnet" : "using BlockHashRNG on testnet/devnet");

const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
from: deployer,
args: [deployer, ZeroAddress],
Expand All @@ -57,7 +69,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const maxFreezingTime = devnet ? 600 : 1800;
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
from: deployer,
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rng.address, RNG_LOOKAHEAD],
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rng.target, RNG_LOOKAHEAD],
log: true,
}); // nonce (implementation), nonce+1 (proxy)

Expand Down
26 changes: 0 additions & 26 deletions contracts/deploy/00-transaction-batcher.ts

This file was deleted.

44 changes: 31 additions & 13 deletions contracts/deploy/utils/deployUpgradable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,47 @@ import {
} from "hardhat-deploy/types";

// Rationale: https://github.com/kleros/kleros-v2/pull/1214#issue-1879116629
const PROXY_OPTIONS: ProxyOptions = {
proxyContract: "UUPSProxy",
proxyArgs: ["{implementation}", "{data}"],
checkProxyAdmin: false, // Not relevant for UUPSProxy
checkABIConflict: false, // Not relevant for UUPSProxy
upgradeFunction: {
methodName: "upgradeToAndCall",
upgradeArgs: ["{implementation}", "{data}"],
},
};
function proxyOptions(proxyContract: string): ProxyOptions {
return {
proxyContract,
proxyArgs: ["{implementation}", "{data}"],
checkProxyAdmin: false, // Not relevant for UUPSProxy
checkABIConflict: false, // Not relevant for UUPSProxy
upgradeFunction: {
methodName: "upgradeToAndCall",
upgradeArgs: ["{implementation}", "{data}"],
},
};
}

type DeployUpgradableOptions = {
export type DeployUpgradableOptions = {
newImplementation?: string;
initializer?: string;
proxyAlias?: string;
} & DeployOptionsBase;

/**
* Deploy a contract with an upgradable proxy
* NOTE: This function assumes the existence of a proxy contract with the name `${proxy}Proxy`, if there is none add the option `proxyAlias: "UUPSProxy"`
* @param deployments - The deployments extension
* @param proxy - The name of the proxy contract
* @param options - The options for the deployment
* @returns The deployment result
*/
export const deployUpgradable = async (
deployments: DeploymentsExtension,
proxy: string,
options: DeployUpgradableOptions
): Promise<DeployResult> => {
const { deploy } = deployments;
const { newImplementation, initializer, args: initializerArgs, proxy: proxyOverrides, ...otherOptions } = options;
const {
newImplementation,
initializer,
args: initializerArgs,
proxy: proxyOverrides,
proxyAlias,
...otherOptions
} = options;

const methodName = initializer ?? "initialize";
const args = initializerArgs ?? [];
Expand All @@ -50,7 +68,7 @@ export const deployUpgradable = async (
...otherOptions,
...contract,
proxy: {
...PROXY_OPTIONS,
...proxyOptions(proxyAlias ?? `${proxy}Proxy`),
...implementationName,
...((proxyOverrides as ProxyOptions) ?? {}),
execute: {
Expand Down
1 change: 1 addition & 0 deletions contracts/deploy/utils/getContractOrDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DeployOptions } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployUpgradable } from "./deployUpgradable";
import { Contract } from "ethers";

export const getContractOrDeploy = async (
hre: HardhatRuntimeEnvironment,
contractName: string,
Expand Down
6 changes: 4 additions & 2 deletions contracts/deploy/utils/klerosCoreHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export const changeCurrencyRate = async (
const pnkRate = await core.currencyRates(erc20);
if (pnkRate.feePaymentAccepted !== accepted) {
console.log(`core.changeAcceptedFeeTokens(${erc20}, ${accepted})`);
await core.changeAcceptedFeeTokens(erc20, accepted);
const tx = await core.changeAcceptedFeeTokens(erc20, accepted);
await tx.wait();
}
if (pnkRate.rateInEth !== toBigInt(rateInEth) || pnkRate.rateDecimals !== rateDecimals) {
console.log(`core.changeCurrencyRates(${erc20}, ${rateInEth}, ${rateDecimals})`);
await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
const tx = await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
await tx.wait();
}
};
55 changes: 53 additions & 2 deletions contracts/deployments/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ export default {
],
},
DisputeResolverNeo: {
address: "0x95eCE455bD817D6adB92F2383617d36eBE10D6EB",
address: "0x3645F9e08D80E47c82aD9E33fCB4EA703822C831",
abi: [
{
inputs: [
Expand Down Expand Up @@ -2442,7 +2442,7 @@ export default {
{
indexed: true,
internalType: "uint256",
name: "_arbitrableDisputeID",
name: "_arbitratorDisputeID",
type: "uint256",
},
{
Expand Down Expand Up @@ -12144,6 +12144,57 @@ export default {
},
],
},
TransactionBatcher: {
address: "0xBC5ef8d9ad307154447AE148c088f083d2dEa4eF",
abi: [
{
inputs: [
{
internalType: "address[]",
name: "targets",
type: "address[]",
},
{
internalType: "uint256[]",
name: "values",
type: "uint256[]",
},
{
internalType: "bytes[]",
name: "datas",
type: "bytes[]",
},
],
name: "batchSend",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
internalType: "address[]",
name: "targets",
type: "address[]",
},
{
internalType: "uint256[]",
name: "values",
type: "uint256[]",
},
{
internalType: "bytes[]",
name: "datas",
type: "bytes[]",
},
],
name: "batchSendUnchecked",
outputs: [],
stateMutability: "payable",
type: "function",
},
],
},
WETH: {
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
abi: [
Expand Down
Loading

0 comments on commit ba231ff

Please sign in to comment.