Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,29 @@ $ yarn local-stack
$ yarn workspace @kleros/kleros-v2-contracts start-local
...
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/

```

⏳ Wait until deployment is complete.

##### In a new terminal run:

```bash
$ yarn workspace @kleros/kleros-v2-contracts populate:local
```

This will populate the courts local by pulling devnet courts.

> Note: Whenever contracts are redeployed or their ABIs change, you must regenerate
> the typed wagmi/viem contract bindings used by the frontend.
>
> ```bash
> yarn workspace @kleros/kleros-v2-contracts viem:generate-hardhat
> ```

#### Shell 2 - Local Graph Node

> Requires Docker desktop to be installed and running

```bash
$ yarn workspace @kleros/kleros-v2-subgraph start-local-indexer
...
Expand Down Expand Up @@ -140,16 +156,20 @@ Queries (HTTP): http://localhost:8000/subgraphs/name/kleros/kleros-v2-core-l

#### Shell 4 - Frontend Pointing to the Local Subgraph

> Note: If not already built, or on any change, build `kleros-app` first.
>
> ```bash
> yarn workspace @kleros/kleros-app build
> ```

```bash
yarn workspace @kleros/kleros-v2-web generate
$ yarn workspace @kleros/kleros-v2-web start-local
✔ Parse Configuration
✔ Generate outputs
✔ Validating plugins
✔ Resolving contracts
✔ Running plugins
✔ Writing to src/hooks/contracts/generated.ts

$ yarn workspace @kleros/kleros-v2-web start-local
Server running at http://localhost:1234
✨ Built in 2.35s
```
Expand All @@ -160,9 +180,15 @@ Server running at http://localhost:1234
# Contracts
$ yarn workspace @kleros/kleros-v2-contracts deploy-local

# If contracts were updated
$ yarn workspace @kleros/kleros-v2-contracts viem:generate-hardhat

# Subgraph
$ yarn workspace @kleros/kleros-v2-subgraph rebuild-deploy:local

# If contracts were updated, restart web server to regenerate the wagmi hooks
$ yarn workspace @kleros/kleros-v2-web start-local

```

### Simulating Arbitration Activity
Expand All @@ -186,10 +212,28 @@ Just press `Ctrl + c` in each terminal.

Every versions were saved as `subgraph.yaml.bak.<timestamp>`.

##### Based on the ArbitrumGoerli deployment artifacts
##### Based on the ArbitrumSepolia deployment artifacts

`yarn workspace @kleros/kleros-v2-subgraph update`

##### Based on the last commit

`git restore subgraph.yaml`

## Run a local Blockscout explorer to inspect transactions on hardhat (Optional)

Make sure [hardhat node](#####shell-1---local-rpc-with-contracts-deployed) is running.

#### Step 1 - Clone [blockscout](https://github.com/blockscout/blockscout/blob/master/docker-compose/README.md) repo

```bash
git clone https://github.com/blockscout/blockscout.git
```

#### Step 2: Start the Docker compose stack

```bash
docker-compose -f hardhat-network.yml up -d
```

This should run a Blockscout locally at http://localhost.
Comment on lines +223 to +239
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix heading hierarchy and link fragment.

Static analysis flagged two issues:

  1. Line 225: The link fragment #####shell-1---local-rpc-with-contracts-deployed appears malformed (uses 5 hashes instead of matching the actual heading format)
  2. Line 227: Heading jumps from ## (h2) directly to #### (h4), skipping h3
🔎 Proposed fixes
 ## Run a local Blockscout explorer to inspect transactions on hardhat (Optional)

-Make sure [hardhat node](#####shell-1---local-rpc-with-contracts-deployed) is running.
+Make sure [hardhat node](#shell-1---local-rpc-with-contracts-deployed) is running.

-#### Step 1 - Clone [blockscout](https://github.com/blockscout/blockscout/blob/master/docker-compose/README.md) repo
+### Step 1 - Clone [blockscout](https://github.com/blockscout/blockscout/blob/master/docker-compose/README.md) repo

 ```bash
 git clone https://github.com/blockscout/blockscout.git

-#### Step 2: Start the Docker compose stack
+### Step 2: Start the Docker compose stack

docker-compose -f hardhat-network.yml up -d

-This should run a Blockscout locally at http://localhost.
+This should run a Blockscout locally at http://localhost.

</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
## Run a local Blockscout explorer to inspect transactions on hardhat (Optional)

Make sure [hardhat node](#shell-1---local-rpc-with-contracts-deployed) is running.

### Step 1 - Clone [blockscout](https://github.com/blockscout/blockscout/blob/master/docker-compose/README.md) repo

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

225-225: Link fragments should be valid

(MD051, link-fragments)


227-227: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)


239-239: Bare URL used

(MD034, no-bare-urls)

🤖 Prompt for AI Agents
In @README.md around lines 223 - 239, Fix the malformed link fragment and
heading level: replace the fragment text
"#####shell-1---local-rpc-with-contracts-deployed" used in the [hardhat node]
link with a proper fragment starting with a single hash (e.g.,
"#shell-1---local-rpc-with-contracts-deployed"), and change the "#### Step 2:
Start the Docker compose stack" heading to "### Step 2: Start the Docker compose
stack" so the heading hierarchy flows from "##" to "###"; also ensure the
localhost URL is written as <http://localhost> for consistency.

4 changes: 2 additions & 2 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, Courts } from "./utils";
import { HomeChains, isSkipped, isDevnet, PNK, ETH, Courts, isLocalhost } from "./utils";
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
import { deployERC20AndFaucet } from "./utils/deployTokens";
import { DisputeKitClassic, KlerosCore, RNGWithFallback } from "../typechain-types";
Expand Down Expand Up @@ -47,7 +47,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
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 KlerosCore address for nonce %d: %s", nonce + 3, klerosCoreAddress);
}
const devnet = isDevnet(hre.network);
const devnet = isDevnet(hre.network) || isLocalhost(hre.network);
const minStakingTime = devnet ? 180 : 1800;
const maxFreezingTime = devnet ? 600 : 1800;
const rngWithFallback = await ethers.getContract<RNGWithFallback>("RNGWithFallback");
Expand Down
4 changes: 2 additions & 2 deletions contracts/deploy/00-rng-chainlink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { HomeChains, isSkipped } from "./utils";
import { HomeChains, isLocalhost, isSkipped } from "./utils";
import { getContractOrDeploy } from "./utils/getContractOrDeploy";
import { RNGWithFallback } from "../typechain-types";

Expand Down Expand Up @@ -76,7 +76,7 @@ const deployRng: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
log: true,
});

const fallbackTimeoutSeconds = 30 * 60; // 30 minutes
const fallbackTimeoutSeconds = isLocalhost(hre.network) ? 10 : 30 * 60; // 30 minutes
await getContractOrDeploy(hre, "RNGWithFallback", {
from: deployer,
args: [
Expand Down
10 changes: 7 additions & 3 deletions contracts/deploy/utils/deployTokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Contract } from "ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getContractOrDeploy } from "./getContractOrDeploy";
import { isMainnet } from ".";
import { isLocalhost, isMainnet } from ".";

export const deployERC20AndFaucet = async (
hre: HardhatRuntimeEnvironment,
Expand All @@ -21,10 +21,14 @@ export const deployERC20 = async (
deployer: string,
ticker: string
): Promise<Contract> => {
// locally the ERC20contract lacks `increaseAllowance` function,
// so we swap it with an updated contract to allow local development
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in comment.

The comment contains a typo: "ERC20contract" should be "ERC20 contract".

🔎 Proposed fix
-  // locally the ERC20contract lacks `increaseAllowance` function,
+  // locally the ERC20 contract lacks `increaseAllowance` function,
   // so we swap it with an updated contract to allow local development
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// locally the ERC20contract lacks `increaseAllowance` function,
// so we swap it with an updated contract to allow local development
// locally the ERC20 contract lacks `increaseAllowance` function,
// so we swap it with an updated contract to allow local development
🤖 Prompt for AI Agents
In @contracts/deploy/utils/deployTokens.ts around lines 24 - 25, Fix the typo in
the inline comment inside deployTokens.ts: change "ERC20contract" to "ERC20
contract" in the comment that explains swapping the local ERC20 implementation
to one with increaseAllowance (refer to the comment containing
"increaseAllowance" in deployTokens.ts).

const contractName = ticker === "PNK" && isLocalhost(hre.network) ? "PinakionV2Local" : "TestERC20";
const args = ticker === "PNK" && isLocalhost(hre.network) ? [] : [ticker, ticker];
return await getContractOrDeploy(hre, ticker, {
from: deployer,
contract: "TestERC20",
args: [ticker, ticker],
contract: contractName,
args: args,
log: true,
});
};
Expand Down
2 changes: 2 additions & 0 deletions contracts/deploy/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export enum Courts {

export const isMainnet = (network: Network) => network.tags.production ?? false;
export const isDevnet = (network: Network) => network.name.endsWith("Devnet");
// when deployed while starting node, the network name is "hardhat", the common factor for determining local node is chainId
export const isLocalhost = (network: Network) => network.name === "localhost" || network.config.chainId === 31337;

export const isSkipped = async (network: Network, skip: boolean) => {
if (skip) {
Expand Down
Loading
Loading