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

Interfaces v2 (rebased 2) #969

Merged
merged 31 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97bafdd
feat: interfaces for the arbitrator, arbitrables and evidence v2
jaybuidl Jan 27, 2023
bdc43e4
docs: examples of metaevidence and dispute templates
jaybuidl Apr 17, 2023
1530844
docs: wip specs
jaybuidl Apr 18, 2023
cff4a41
docs: interfaces docs update
jaybuidl Apr 18, 2023
aca496d
docs: added curate, improved the schema
jaybuidl Apr 18, 2023
4a6ca5d
docs: added poh, removed type to rely on default
jaybuidl Apr 18, 2023
75b2e61
docs: new dispute template schema improvement
jaybuidl Apr 18, 2023
f07a99e
docs: added the datetime type
jaybuidl Apr 19, 2023
76eabb7
feat: interfaces wip
jaybuidl Jun 13, 2023
8072a95
docs: CrossChainDisputeRequest event
jaybuidl Jun 13, 2023
6a18a7a
refactor: example folder
jaybuidl Jun 13, 2023
6089177
fix: natspec
jaybuidl Jun 13, 2023
3f13fec
feat: migrated DisputeResolver
jaybuidl Jun 13, 2023
15b69ee
docs: removed comments
jaybuidl Jun 13, 2023
95a4e9e
feat: deploy scripts improvements
jaybuidl Jun 13, 2023
1eae9fe
feat: resolver migrated and deployed to chiado, interfaces natspec im…
jaybuidl Jun 14, 2023
65c3e0f
fix: forge doc assumes the top-level folder when linking to the githu…
jaybuidl Jun 14, 2023
02a7df5
fix: bsd vs gnu compatibility
jaybuidl Jun 14, 2023
f954c20
docs: minor parameter rename
jaybuidl Jun 14, 2023
b6b563c
refactor: moved crosschain event to the gateway interface
jaybuidl Jun 15, 2023
5bc1ed7
feat: migrated all the interfaces to the new v2 ones)
jaybuidl Jun 19, 2023
c6b7470
feat: added a simple dispute template, moved IMetaEvidence to the v1 …
jaybuidl Jun 19, 2023
73eec68
fix: adding missing files for the dispute resolver
jaybuidl Jun 20, 2023
dede020
fix: manual fixes after rebasing onto feat/erc20-fees-on-arbitrator
jaybuidl Jun 20, 2023
fae3c88
refactor: folder structure
jaybuidl Jun 20, 2023
7a08a37
fix: manual fixes after rebase
jaybuidl Jun 23, 2023
e46bffc
Merge branch 'feat/erc20-fees-on-arbitrator' into feat/interfaces-v2-…
jaybuidl Jun 23, 2023
1764e67
Merge branch 'feat/erc20-fees-on-arbitrator' into feat/interfaces-v2-…
jaybuidl Jun 23, 2023
5153508
fix: variable in DisputeDetails.simple.jsonc
jaybuidl Jun 23, 2023
ac47dd5
fix: added the arbitrator disputeID to the CrossChainDisputeIncoming …
jaybuidl Jun 23, 2023
eb703cb
chore: redeployed the contracts
jaybuidl Jun 23, 2023
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
20 changes: 10 additions & 10 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ Smart contracts for Kleros v2

Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh`.

### v2-alpha-1

#### Chiado

- [ArbitrableExample](https://blockscout.com/gnosis/chiado/address/0xc0fcc96BFd78e36550FCaB434A9EE1210B57225b)
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x573bcD6ee4aEe152eCC9Cafd2c0820Dc548AF6cC)
- [ArbitrableExample](https://blockscout.com/gnosis/chiado/address/0x6BC234359c2Bc212B81A5cF2dfE504940e98d4cC)
- [DisputeResolver](https://blockscout.com/gnosis/chiado/address/0x433eD78895df1df7668C40b3e82d54410331F942)
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x2357ef115E98d171b083105E9b398231206989A3)
- [SortitionSumTreeFactory](https://blockscout.com/gnosis/chiado/address/0xc7e3BF90299f6BD9FA7c3703837A9CAbB5743636)
- [TokenBridge](https://blockscout.com/gnosis/chiado/address/0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2)
- [WETH](https://blockscout.com/gnosis/chiado/address/0x2DFC9c3141268e6eac04a7D6d98Fbf64BDe836a8)
Expand All @@ -23,20 +22,20 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
#### Goerli

- [PNK](https://goerli.etherscan.io/token/0xA3B02bA6E10F55fb177637917B1b472da0110CcC)
- [ArbitrableExample](https://goerli.etherscan.io/address/0xd78dcdde2c5a2bd4bb246bc7db6994b95f7c442c)

#### Arbitrum Goerli

- [PNK](https://goerli.arbiscan.io/token/0x4DEeeFD054434bf6721eF39Aa18EfB3fd0D12610/token-transfers)
- [ArbitrableExampleEthFee](https://goerli.arbiscan.io/address/0x1fF31be1924f55804350ADe4945f3B3a6a2e15d2)
- [BlockHashRNG](https://goerli.arbiscan.io/address/0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD)
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0xcBE3aD699919Cf59efDF715e4B41AF30A0E4c92d)
- [DisputeResolver](https://goerli.arbiscan.io/address/0x3B4edEFd12a467D1C71506ae2eE88828145202b1)
- [DAI](https://goerli.arbiscan.io/address/0x70A704Dce4cCC00568Cc142C86D07Ec71C944a39)
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0x0245A93ABd9c5b2d767B2D98cE6d5e612208E474)
- [DisputeResolver](https://goerli.arbiscan.io/address/0xcDC05c8d2EEEe384359Bd22E8631528B6b0564e9)
- [HomeGatewayToGnosis](https://goerli.arbiscan.io/address/0xD60CD2151e118Dd796efcb1ceFFcF892226F9b3a)
- [KlerosCore](https://goerli.arbiscan.io/address/0xA429667Abb1A6c530BAd1083df4C69FBce86D696)
- [KlerosCore](https://goerli.arbiscan.io/address/0x8Af82E2F8890acb4AB84cbaB3c4C4Eb3E965CF24)
- [PolicyRegistry](https://goerli.arbiscan.io/address/0xED503aBA65B28D81444294D1eAa5d84CeFdC2C58)
- [RandomizerRNG](https://goerli.arbiscan.io/address/0xa90f7D2e35718FDE9AD96c8B6667AFcAa4BEfd4d)
- [SortitionModule](https://goerli.arbiscan.io/address/0xa65D3ED6494ec5fcAa115A39D625B2F01786F094)
- [SortitionModule](https://goerli.arbiscan.io/address/0x5Ae75Db8B66B574b2c5C29eE4D32cc9Fe62bfdEE)
- [WETH](https://goerli.arbiscan.io/address/0xddE1b84E43505432Fdf5F810ebB9373dD37e9230)

## Getting Started

Expand Down Expand Up @@ -121,6 +120,7 @@ yarn deploy --network localhost --tags <Arbitration|VeaMock|ForeignGatewayOnEthe
yarn deploy --network arbitrumGoerli --tags Arbitration
yarn deploy --network chiado --tags ForeignGatewayOnGnosis
yarn deploy --network chiado --tags KlerosLiquidOnGnosis
yarn deploy --network chiado --tags ForeignArbitrable
yarn deploy --network arbitrumGoerli --tags HomeGatewayToGnosis

# Goerli
Expand Down
16 changes: 10 additions & 6 deletions contracts/deploy/00-home-chain-arbitrable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";

enum HomeChains {
ARBITRUM_ONE = 42161,
Expand All @@ -17,16 +18,19 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);

const klerosCore = await deployments.get("KlerosCore");
const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const weth = await deployments.get("WETH");

await deploy("ArbitrableExample", {
from: deployer,
args: [
klerosCore.address,
0,
"https://cloudflare-ipfs.com/ipfs/bafkreifteme6tusnjwyzajk75fyvzdmtyycxctf7yhfijb6rfigz3n4lvq",
weth.address,
],
args: [klerosCore.address, disputeTemplate, extraData, weth.address],
log: true,
});

await deploy("DisputeResolver", {
from: deployer,
args: [klerosCore.address],
log: true,
});
};
Expand Down
15 changes: 8 additions & 7 deletions contracts/deploy/01-foreign-gateway-on-ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import getContractAddress from "../deploy-helpers/getContractAddress";
import { KlerosCore__factory } from "../typechain-types";

enum ForeignChains {
ETHEREUM_MAINNET = 1,
Expand Down Expand Up @@ -45,13 +46,13 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
});

// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
await execute(
"ForeignGatewayOnEthereum",
{ from: deployer, log: true },
"changeCourtJurorFee",
0,
ethers.BigNumber.from(10).pow(17)
);
const coreDeployment = await hre.companionNetworks.home.deployments.get("KlerosCore");
const core = await KlerosCore__factory.connect(coreDeployment.address, homeChainProvider);
// TODO: set up the correct fees for the FORKING_COURT
const courtId = await core.GENERAL_COURT();
const fee = (await core.courts(courtId)).feeForJuror;
await execute("ForeignGatewayOnGnosis", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
// TODO: set up the correct fees for the lower courts
};

deployForeignGateway.tags = ["ForeignGatewayOnEthereum"];
Expand Down
15 changes: 8 additions & 7 deletions contracts/deploy/01-foreign-gateway-on-gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { parseUnits } from "ethers/lib/utils";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import getContractAddress from "../deploy-helpers/getContractAddress";
import { KlerosCore__factory } from "../typechain-types";

enum ForeignChains {
GNOSIS_MAINNET = 100,
Expand Down Expand Up @@ -49,13 +50,13 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
});

// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
await execute(
"ForeignGatewayOnGnosis",
{ from: deployer, log: true },
"changeCourtJurorFee",
0,
ethers.utils.parseEther("0.00001")
);
const coreDeployment = await hre.companionNetworks.home.deployments.get("KlerosCore");
const core = await KlerosCore__factory.connect(coreDeployment.address, homeChainProvider);
// TODO: set up the correct fees for the FORKING_COURT
const courtId = await core.GENERAL_COURT();
const fee = (await core.courts(courtId)).feeForJuror;
await execute("ForeignGatewayOnGnosis", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
// TODO: set up the correct fees for the lower courts
};

deployForeignGateway.tags = ["ForeignGatewayOnGnosis"];
Expand Down
25 changes: 15 additions & 10 deletions contracts/deploy/03-vea-mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import getContractAddress from "../deploy-helpers/getContractAddress";
import { KlerosCore__factory } from "../typechain-types";
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";

const HARDHAT_NETWORK = 31337;

Expand Down Expand Up @@ -50,19 +52,22 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
log: true,
}); // nonce+1

await execute(
"ForeignGatewayOnEthereum",
{ from: deployer, log: true },
"changeCourtJurorFee",
0,
ethers.BigNumber.from(10).pow(17)
);

const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/goerli/MetaEvidence_ArbitrableExample.json`;
// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
const signer = (await hre.ethers.getSigners())[0];
const core = await KlerosCore__factory.connect(klerosCore.address, signer);
// TODO: set up the correct fees for the FORKING_COURT
const courtId = await core.GENERAL_COURT();
const fee = (await core.courts(courtId)).feeForJuror;
await execute("ForeignGatewayOnEthereum", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
// TODO: set up the correct fees for the lower courts

// TODO: debug why this extraData fails but "0x00" works
// const extraData =
// "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const extraData = "0x00";
await deploy("ArbitrableExample", {
from: deployer,
args: [foreignGateway.address, 0, metaEvidenceUri, ethers.constants.AddressZero],
args: [foreignGateway.address, disputeTemplate, extraData, ethers.constants.AddressZero],
log: true,
});
};
Expand Down
22 changes: 18 additions & 4 deletions contracts/deploy/04-foreign-arbitrable.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";

enum ForeignChains {
ETHEREUM_MAINNET = 1,
ETHEREUM_GOERLI = 5,
GNOSIS_MAINNET = 100,
GNOSIS_CHIADO = 10200,
}

const foreignGatewayArtifactByChain = new Map<ForeignChains, string>([
[ForeignChains.ETHEREUM_MAINNET, "ForeignGatewayOnEthereum"],
[ForeignChains.ETHEREUM_GOERLI, "ForeignGatewayOnEthereum"],
[ForeignChains.GNOSIS_MAINNET, "ForeignGatewayOnGnosis"],
[ForeignChains.GNOSIS_CHIADO, "ForeignGatewayOnGnosis"],
]);

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
const { deploy, execute } = deployments;
Expand All @@ -15,17 +25,21 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
const chainId = Number(await getChainId());
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);

const foreignGateway = await deployments.get("ForeignGatewayOnEthereum");
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/${hre.network.name}/MetaEvidence_ArbitrableExample.json`;
const foreignGatewayArtifact = foreignGatewayArtifactByChain.get(chainId) ?? ethers.constants.AddressZero;
const foreignGateway = await deployments.get(foreignGatewayArtifact);
console.log("Using foreign gateway: %s", foreignGatewayArtifact);

const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const weth = await deployments.get("WETH");
await deploy("ArbitrableExample", {
from: deployer,
args: [foreignGateway.address, 0, metaEvidenceUri, weth.address],
args: [foreignGateway.address, disputeTemplate, extraData, weth.address],
log: true,
});
};

deployForeignGateway.tags = ["ArbitrableOnEthereum"];
deployForeignGateway.tags = ["ForeignArbitrable"];
deployForeignGateway.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !ForeignChains[chainId];
Expand Down
23 changes: 4 additions & 19 deletions contracts/deploy/04-klerosliquid-to-v2-gnosis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parseUnits, parseEther } from "ethers/lib/utils";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";

enum ForeignChains {
GNOSIS_MAINNET = 100,
Expand Down Expand Up @@ -53,6 +54,8 @@ const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment
const jurorsForCourtJump = 9999999;
const sortitionSumTreeK = 3;
const foreignGateway = await deployments.get("ForeignGatewayOnGnosis");
const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const weth = await deployments.get("WETH");

console.log("Using: \nwPNK at %s, \nForeignGateway at %s", wPnkAddress, foreignGateway.address, weth.address);
Expand Down Expand Up @@ -98,29 +101,11 @@ const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment
// const xKlerosLiquidV2 = await deployments.get("xKlerosLiquidV2");
await deploy("ArbitrableExample", {
from: deployer,
args: [
xKlerosLiquidV2.address,
0,
"/ipfs/bafkreifteme6tusnjwyzajk75fyvzdmtyycxctf7yhfijb6rfigz3n4lvq", // PoH registration
weth.address,
],
args: [xKlerosLiquidV2.address, 0, disputeTemplate, extraData, weth.address],
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});

await execute(
"ArbitrableExample",
{
from: deployer,
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
},
"changeMetaEvidence",
1,
"/ipfs/bafkreibiuxwejijwg4pxco7fqszawcwmpt26itbdxeqgh7cvpeuwtmlhoa" // PoH clearing
);
};

// TODO: mock deployment on the hardhat network
Expand Down
39 changes: 39 additions & 0 deletions contracts/deploy/04-resolver-to-v2-gnosis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { parseUnits } from "ethers/lib/utils";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";

enum ForeignChains {
GNOSIS_MAINNET = 100,
GNOSIS_CHIADO = 10200,
HARDHAT = 31337,
}

const ONE_GWEI = parseUnits("1", "gwei");

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

// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);

const foreignGateway = await deployments.get("ForeignGatewayOnGnosis");

await deploy("DisputeResolver", {
from: deployer,
args: [foreignGateway.address],
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
};

deployResolver.tags = ["ResolverOnGnosis"];
deployResolver.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !ForeignChains[chainId];
};

export default deployResolver;
Loading