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

Consolidation of all the Cross-Chain Proxy repositories #53

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ad25d52
chore: renamed xDAI to Gnosis, added Chiado, removed old testnets
jaybuidl Jan 15, 2025
f3f7e11
chore: update evidence and dynamic script packages
jaybuidl Jan 15, 2025
f476930
feat: gnosis and optimism contracts with different major solidity ver…
jaybuidl Jan 16, 2025
dfdf70c
fix: dynamic and evidence scripts build
jaybuidl Jan 16, 2025
71f1ea4
chore: added the optimism proxies
jaybuidl Jan 16, 2025
16c52ab
feat(GnosisProxy): bump compiler
unknownunknown1 Jan 17, 2025
e9b2088
refactor(OptimismProxy): remove unnecessary additions
unknownunknown1 Jan 17, 2025
d11ff9b
docs(GnosisProxy): typo
unknownunknown1 Jan 17, 2025
69b1b4b
fix: check-effect-interaction
jaybuidl Jan 17, 2025
d1cc1fc
Merge pull request #54 from kleros/feat/gnosis-proxy-compiler-bump
jaybuidl Jan 17, 2025
73b8193
feat: added the arbitrum and polygon proxies
jaybuidl Jan 17, 2025
535b8c9
feat: hardhat config for arbitrum, polygon, zksync
jaybuidl Jan 17, 2025
5308e75
fix: compilation
jaybuidl Jan 17, 2025
500e861
chore: home deploy scripts
jaybuidl Jan 17, 2025
8141a01
chore: foreign deploy scripts, migrated obsolete mumbai network to amoy
jaybuidl Jan 17, 2025
0c79c8b
chore: eslint
jaybuidl Jan 17, 2025
865619f
docs: deployments in README
jaybuidl Jan 17, 2025
eaff0f3
fix: various deploy script fixes
jaybuidl Jan 17, 2025
8c86531
fix: polygon deploy scripts
jaybuidl Jan 18, 2025
27f212e
chore: hardhat config
jaybuidl Jan 18, 2025
394c73a
feat: governance removal for Arbitrum, changed jurors from 7 to 15 on…
jaybuidl Jan 20, 2025
b98aa4f
feat: zkSync deploy scripts (not tested), reordered constructor param…
jaybuidl Jan 20, 2025
012c6c1
chore: refactored the deploy script constants and utils
jaybuidl Jan 20, 2025
431fba2
feat: removal of governance for zksync
jaybuidl Jan 20, 2025
57b1be5
docs: readme
jaybuidl Jan 21, 2025
7db1789
fix: coderabbit feedback
jaybuidl Jan 21, 2025
dc6a36c
docs: typo
jaybuidl Jan 21, 2025
4457ffd
refactor: renamed RealitioInterfaces into IRealitio and ArbitrationPr…
jaybuidl Jan 21, 2025
ea719c7
feat: arbitrum relay tasks
jaybuidl Jan 22, 2025
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8

[*.{html,js,.json,mjs,rjson,ts}]
[*.{html,js,.json,mjs,rjson,ts,yml}]
indent_style = space
indent_size = 2

Expand Down
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": true,
"parserOptions": {
"ecmaVersion": 2018
},
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ tags

# if you are NOT using Zero-installs, then:
# comment the following lines
!.yarn/cache
#!.yarn/cache

# and uncomment the following lines
# .pnp.*
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

22 changes: 22 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"scanSettings": {
"baseBranches": ["master", "dev"]
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "MEDIUM",
"issueType": "DEPENDENCY",
"customLabels": ["Type: Security🛡️ ", "dependencies"]
},
"remediateSettings": {
"workflowRules": {
"enabled": true,
"minVulnerabilityScore": 3,
"maxVulnerabilityScore": 10
}
}
}
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

875 changes: 875 additions & 0 deletions .yarn/releases/yarn-3.8.7.cjs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.8.7.cjs
63 changes: 57 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Cross-Chain Realitio Proxy

Enables cross-chain arbitration for Realition (Reality.eth) on xDAI or other AMB-compatible networks using Kleros as arbitrator.
Enables cross-chain arbitration for Realitio (Reality.eth) using Kleros as arbitrator.

## Supported Chains

### Mainnets
- Gnosis
- Optimism and other OP stack chains: Unichain, Redstone
- Arbitrum
- Polygon PoS
- ZkSync

### Testnets
The testnet of the above chains except Redstone.

## High-Level Flow Description

1. Alice requests arbitration on the main chain paying the arbitration fee to the ETH proxy and indicates the maximum value of the bond for the question (A.K.A. `max_previous`).
1. The ETH proxy communicates the request to the xDAI proxy through the AMB.
1. The xDAI tries to notify Realitio of the arbitration request and forwards the `max_previous` value:
1. The ETH proxy communicates the request to the Gnosis proxy through the AMB.
1. The Gnosis tries to notify Realitio of the arbitration request and forwards the `max_previous` value:
1. If the bond has not changed, the arbitration request will be accepted.
1. Notify the ETH proxy through the AMB.
1. Otherwise, if it changed then:
Expand All @@ -20,9 +32,9 @@ Enables cross-chain arbitration for Realition (Reality.eth) on xDAI or other AMB
1. Refund Alice of the difference.
1. If the fees have increased, then the arbitration request will fail:
1. Refund Alice of the value paid so far.
1. The ETH proxy notifies the xDAI proxy through the AMB that the arbitration failed to be created.
1. The xDAI proxy notifies Realitio of the failed arbitration. **END**
1. The Kleros court gives a ruling. It is relayed to the xDAI proxy through the AMB.
1. The ETH proxy notifies the Gnosis proxy through the AMB that the arbitration failed to be created.
1. The Gnosis proxy notifies Realitio of the failed arbitration. **END**
1. The Kleros court gives a ruling. It is relayed to the Gnosis proxy through the AMB.
1. If the ruling is the current answer, Bob, the last answerer, is the winner. **END**
1. If it is not, Alice is the winner. **END**

Expand All @@ -41,3 +53,42 @@ Each directory at the root of this repository contains code for each individual
- **`contracts/`**: Smart contracts to enable cross-chain arbitration for Realitio (Reality.eth). [Learn more](contracts/README.md).
- **`dynamic-script/`**: allows fetching the dynamic content for the arbitration, as described by [ERC-1497: Evidence Standard](https://github.com/ethereum/EIPs/issues/1497).
- **`evidence-display/`**: display interface that should be used to render the evidence for arbitrators, as described by [ERC-1497: Evidence Standard](https://github.com/ethereum/EIPs/issues/1497).

### Adding support for a new chain

#### 0. Preliminary
* Get the Reality.eth contract **address** and deployment **block number** from the [Reality monorepo](https://github.com/RealityETH/reality-eth-monorepo/tree/main/packages/contracts/chains/deployments).

#### 1. Hardhat configuration
* Add the new chain configuration to hardhat.config.
* Make sure to add the correct **tag** (home or foreign) and the correct **companion network** for the home and foreign networks (so that both networks have a companion network referring to the other). The deployment scripts rely on them.
* In `package.json`, add the extra convenience scripts: `metaevidence:xxx` , `deploy:xxx`

#### 2. Contracts code
* Build the bridging logic in the proxies if needed.
* E.g. for an OP L2 it is not needed, the logic is the same for all OP L2s and is already implemented.
* Test, review etc

#### 3. Dynamic & Evidence scripts
* Add the Reality.eth contract and deployment block number to the script files [here](https://github.com/kleros/cross-chain-realitio-proxy-optimism/blob/1ed08c3ea06ef00398b02f64d1657de3d4ac50c8/dynamic-script/src/index.js#L8) and [here](https://github.com/kleros/cross-chain-realitio-proxy-optimism/blob/1ed08c3ea06ef00398b02f64d1657de3d4ac50c8/evidence-display/src/containers/realitio.js#L10).
* `yarn build`
* Upload the file `dynamic-script/dist/realitio-dynamic-script-vx.x.x.js` to IPFS.
* Upload the folder `evidence-display/evidence-display-vx.x.x` to IPFS.

#### 4. MetaEvidence
* [In this script](https://github.com/kleros/cross-chain-realitio-proxy-optimism/blob/1ed08c3ea06ef00398b02f64d1657de3d4ac50c8/contracts/tasks/generate-metaevidence.js#L36-L37), update the CIDs with the latest dynamic and evidence scripts uploaded to IPFS in the above steps.
* Run `yarn metaevidence:xxx` for the new chain
* Upload the resulting metaevidence-xxx.json to IPFS

#### 5. Contracts deployment
* Configuration:
* In the home and foreign proxy deployment script, add a configuration object to `params` .
* The home script needs the Reality contract address.
* The foreign script needs the desired courtId and number of jurors (arbitratorExtraData), the L1 bridge address (messenger) and the metaEvidence IPFS URI (from earlier step).
* Deploy and verify with `yarn deploy:xxx`.
* Update the contracts README by running `./scripts/populateReadme.sh`, expand the script if needed.
* Make sure to commit to `deployments` folder to git.

#### 6. Adding support to the Court v1
* Add support for the new chain (because the dynamic/evidence scripts need a RPC provided by the court).
* Whitelist the newly deployed arbitrable.
8 changes: 4 additions & 4 deletions bots/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BOTS_PRIVATE_KEYS_FILE='cross-chain-realitio-proxy.json'
FOREIGN_CHAIN_ID='<chain ID on Ethereum>'
FOREIGN_TX_BATCHER_CONTRACT_ADDRESS='<Mainnet/Kovan address>}'
FOREIGN_PROXY_CONTRACT_ADDRESS='<Mainnet/Kovan address>'
HOME_CHAIN_ID='<xDAI or Sokol chain ID>'
HOME_TX_BATCHER_CONTRACT_ADDRESS='<xDAI/Sokol address>'
HOME_PROXY_CONTRACT_ADDRESS='<xDAI/Sokol address>'
HOME_REALITIO_CONTRACT_ADDRESS='<xDAI/Sokol address>'
HOME_CHAIN_ID='<Gnosis chain ID>'
HOME_TX_BATCHER_CONTRACT_ADDRESS='<Gnosis address>'
HOME_PROXY_CONTRACT_ADDRESS='<Gnosis address>'
HOME_REALITIO_CONTRACT_ADDRESS='<Gnosis address>'
9 changes: 4 additions & 5 deletions bots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@kleros/contract-deployments": "^0.3.2",
"@kleros/cross-chain-realitio-contracts": "~0.5.0",
"@kleros/cross-chain-realitio-contracts": "^1.0.0",
"aws-sdk": "^2.730.0",
"core-js": "^3.0.0",
"dayjs": "^1.8.33",
"deepmerge": "^4.2.2",
"ramda": "^0.27.1",
"web3": "^1.7.0",
"web3": "^1.10.4",
"web3-batched-send": "^1.0.3"
},
"devDependencies": {
Expand All @@ -32,7 +32,6 @@
"babel-loader": "^8.2.3",
"babel-plugin-ramda": "^2.0.0",
"clean-webpack-plugin": "^3.0.0",
"electron": "^10.1.3",
"serverless": "^2.72.2",
"serverless-dotenv-plugin": "^3.0.0",
"serverless-dynamodb-client": "^0.0.2",
Expand All @@ -41,7 +40,7 @@
"serverless-plugin-ifelse": "^1.0.5",
"serverless-prune-plugin": "^1.4.3",
"serverless-webpack": "^5.3.5",
"webpack": "^4.44.1",
"webpack-node-externals": "^2.5.1"
"webpack": "^4.47.0",
"webpack-node-externals": "^2.5.2"
}
}
2 changes: 1 addition & 1 deletion bots/src/on-chain-api/foreign-chain/createApiInstance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ForeignProxy from "@kleros/cross-chain-realitio-contracts/artifacts/src/RealitioForeignArbitrationProxy.sol/RealitioForeignArbitrationProxy.json";
import ForeignProxy from "@kleros/cross-chain-realitio-contracts/artifacts/src/0.7/RealitioForeignProxyGnosis.sol/RealitioForeignProxyGnosis.json";
import { compose, filter, into, map, prop, propEq } from "ramda";
jaybuidl marked this conversation as resolved.
Show resolved Hide resolved
import { createBatchSend } from "~/shared/batchSend";
import { getContract } from "~/shared/contract";
Expand Down
4 changes: 2 additions & 2 deletions bots/src/on-chain-api/home-chain/createApiInstance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RealitioInterface from "@kleros/cross-chain-realitio-contracts/artifacts/src/dependencies/RealitioInterface.sol/RealitioInterface.json";
import HomeProxy from "@kleros/cross-chain-realitio-contracts/artifacts/src/RealitioHomeArbitrationProxy.sol/RealitioHomeArbitrationProxy.json";
import RealitioInterface from "@kleros/cross-chain-realitio-contracts/artifacts/src/0.7/interfaces/RealitioInterface.sol/RealitioInterface.json";
import HomeProxy from "@kleros/cross-chain-realitio-contracts/artifacts/src/0.7/RealitioHomeProxyGnosis.sol/RealitioHomeProxyGnosis.json";
import { compose, descend, filter, into, map, prop, propEq, sort } from "ramda";
import { createBatchSend } from "~/shared/batchSend";
import { getContract } from "~/shared/contract";
Expand Down
7 changes: 3 additions & 4 deletions bots/src/shared/web3.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Web3 from "web3";

const homeRpcEndpoints = {
77: "https://sokol.poa.network/",
100: "https://rpc.xdaichain.com/",
100: "https://rpc.gnosis.gateway.fm",
10200: "https://rpc.chiado.gnosis.gateway.fm",
};

const HOME_CHAIN_ID = process.env.HOME_CHAIN_ID ?? "100";
Expand All @@ -11,8 +11,7 @@ export const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRpcEndpoint

const foreignRpcEndpoints = {
1: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
4: `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}`,
42: `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`,
11155111: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
};

jaybuidl marked this conversation as resolved.
Show resolved Hide resolved
const FOREIGN_CHAIN_ID = process.env.FOREIGN_CHAIN_ID ?? "4";
Expand Down
6 changes: 4 additions & 2 deletions contracts/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
PRIVATE_KEY='<0x encoded private key>'
MAINNET_PRIVATE_KEY='<0x encoded private key for Ethereum Mainnet>'
INFURA_API_KEY='<key>'
ETHERSCAN_API_KEY='<key>'
GNOSIS_API_KEY='<key>'
GNOSISSCAN_API_KEY='<key>'
POLYGONSCAN_API_KEY='<key>'
ARBISCAN_API_KEY='<key>'
OPTIMISM_API_KEY='<key>'
2 changes: 2 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Hardhat files
cache
artifacts
cache-zk
artifacts-zk

# Hardhat deploy files
deployments/localhost
Expand Down
5 changes: 0 additions & 5 deletions contracts/.npmignore

This file was deleted.

84 changes: 45 additions & 39 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
# @kleros/cross-chain-realitio-contracts

Smart contracts to enable cross-chain arbitration for Realitio (Reality.eth)
Smart contracts for the Reality.eth cross-chain proxies.

## Deployed Addresses
## Deployments

### Home Proxy
Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh` or `./scripts/populateReadme.sh`.
jaybuidl marked this conversation as resolved.
Show resolved Hide resolved

- Sokol: [deployment](deployments/sokol/RealitioHomeArbitrationProxy.json#L2).
- xDai: [deployment](deployments/xdai/RealitioHomeArbitrationProxy.json#L2).
### Testnets

### Foreign Proxy
#### Chiado

- [RealitioHomeArbitrationProxy](https://gnosis-chiado.blockscout.com/address/0xE620947519E8102aa625BBB4669fE317c9FffeD7)
- [RealitioForeignProxyWithAppealsGnosis](https://sepolia.etherscan.io/address/0x5d7cB72B31C080CF2de5f57fd38DedBeaf969D42)


#### UnichainSepolia

- [RealitioHomeProxyUnichain](https://sepolia.uniscan.xyz/address/0x05295972F75cFeE7fE66E6BDDC0435c9Fd083D18)
- [RealitioForeignProxyUnichain](https://sepolia.etherscan.io/address/0xC10D916467aDdC02464aC98036E58644F0E50311)


#### OptimismSepolia

- [RealitioHomeProxyOptimism](https://sepolia-optimism.etherscan.io/address/0xFe0eb5fC686f929Eb26D541D75Bb59F816c0Aa68)
- [RealitioForeignProxyOptimism](https://sepolia.etherscan.io/address/0x6a41AF8FC7f68bdd13B2c7D50824Ed49155DC3bA)


#### ArbitrumSepolia

- [RealitioHomeProxyArbitrum](https://sepolia.arbiscan.io/address/0x890deB4111F92fE9447e83aBEF1b754372d6770e)
- [RealitioForeignProxyArbitrum](https://sepolia.etherscan.io/address/0x26222Ec1F548953a4fEaE4C5A216337E26A821F9)


### Mainnets

#### Gnosis

- [RealitioHomeArbitrationProxy](https://gnosisscan.io/address/0x88Fb25D399310c07d35cB9091b8346d8b1893aa5)
- [RealitioForeignProxyGnosis](https://etherscan.io/address/0x79d0464Ec27F67663DADf761432fC8DD0AeA3D49)
- [RealitioForeignProxyWithAppealsGnosis](https://etherscan.io/address/0x32bcDC9776692679CfBBf8350BAd67Da13FaaA3F)

#### Polygon

- [RealitioHomeProxyPolygon](https://polygonscan.com/address/0x5AFa42b30955f137e10f89dfb5EF1542a186F90e)
- [RealitioForeignProxyPolygon](https://etherscan.io/address/0x776e5853e3d61B2dFB22Bcf872a43bF9A1231e52)

- Kovan: [deployment](deployments/kovan/RealitioForeignArbitrationProxy.json#L2).
- Mainnet: [deployment](deployments/mainnet/RealitioForeignArbitrationProxy.json#L2).

## Contributing

Expand All @@ -34,18 +66,6 @@ yarn test
yarn build
```

### Run Linter on Files

```bash
yarn lint
```

### Fix Linter Issues on Files

```bash
yarn fix
```

### Deploy Instructions

**IMPORTANT:** new versions of any of the contracts require publishing **both** Home and Foreign proxies, as their binding is immutable.
Expand All @@ -60,13 +80,10 @@ Copy `.env.example` file as `.env` and edit it accordingly.
cp .env.example .env
```

The following env vars are required:
- `PRIVATE_KEY`: the private key of the deployer account used for xDAI, Sokol and Kovan.
- `MAINNET_PRIVATE_KEY`: the private key of the deployer account used for Mainnet.
Set the following env vars:
- `PRIVATE_KEY`: the private key of the deployer account.
- `INFURA_API_KEY`: the API key for infura.

The ones below are optional:
- `ETHERSCAN_API_KEY`: used only if you wish to verify the source of the newly deployed contracts on Etherscan.
- `ETHERSCAN_API_KEY`: the API key to verify the contracts on Etherscan.

#### 1. Update the Constructor Parameters (optional)

Expand All @@ -75,21 +92,10 @@ If some of the constructor parameters (such as the Meta Evidence) needs to chang
#### 2. Deploy the Proxies

```bash
yarn deploy:staging # to deploy to Sokol/Kovan
# yarn deploy:production # to deploy to xDAI/Mainnet
yarn deploy:chiado:home
yarn deploy:chiado:foreign
jaybuidl marked this conversation as resolved.
Show resolved Hide resolved
```

The deployed addresses should be output to the screen after the deployment is complete.
If you miss that, you can always go to the `deployments/<network>` directory and look for the respective file.

#### 3. Verify the Source Code for Contracts

This must be done for each network separately.

For `Kovan` or `Mainnet` you can use the `etherscan-verify` command from `hardhat`:

```bash
yarn hardhat --network <kovan|mainnet> etherscan-verify
```

For `Sokol` and `xDAI` the process currently must be done manually through [Blockscout](https://blockscout.com/).
Loading
Loading