Skip to content

Commit 7198e28

Browse files
authored
Merge pull request #1392 from kleros/dev
Release of v2-testnet-3.0.2
2 parents 4963c6a + be7d75c commit 7198e28

File tree

15 files changed

+116
-41
lines changed

15 files changed

+116
-41
lines changed

.github/workflows/deploy-subgraph.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ name: Deploy the Subgraph
33
on:
44
workflow_dispatch:
55
inputs:
6-
network:
7-
description: The network to deploy the subgraph to
6+
graph_environment:
7+
description: The Graph environment to deploy to
88
required: true
9-
default: 'arbitrum-sepolia'
9+
default: 'graph-studio-devnet'
1010
type: choice
1111
options:
12-
- arbitrum-sepolia-devnet
13-
- arbitrum-sepolia
14-
- arbitrum
12+
- graph-studio-devnet
13+
- graph-studio-testnet
14+
- graph-studio-mainnet
1515
subgraph:
1616
description: The name of the subgraph to deploy
1717
required: true
@@ -32,13 +32,17 @@ permissions:
3232
jobs:
3333
buildAndDeploy:
3434
runs-on: ubuntu-latest
35-
environment: kleros-org-subgraph
35+
environment: ${{ inputs.graph_environment }}
3636
steps:
3737
- name: Harden Runner
3838
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
3939
with:
4040
egress-policy: audit
4141

42+
- name: Validate Network environment variable
43+
if: ${{!startsWith(vars.NETWORK, 'arbitrum')}}
44+
run: echo ${{vars.NETWORK}} && exit 1
45+
4246
- name: Checkout code
4347
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
4448

@@ -66,7 +70,7 @@ jobs:
6670
if: ${{ inputs.update }}
6771
run: |
6872
export PATH=$PWD/../bin:$PATH
69-
yarn update:${{ inputs.subgraph }}:${{ inputs.network }}
73+
yarn update:${{ inputs.subgraph }}:${{ vars.NETWORK }}
7074
working-directory: subgraph
7175

7276
- name: Build the subgraph
@@ -75,10 +79,10 @@ jobs:
7579
yarn build:${{ inputs.subgraph }}
7680
working-directory: subgraph
7781

78-
- name: Authenticate with TheGraph
79-
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --product hosted-service
82+
- name: Authenticate with TheGraph Studio
83+
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --studio
8084
working-directory: subgraph
8185

8286
- name: Deploy the subgraph
83-
run: yarn deploy:${{ inputs.subgraph }}:${{ inputs.network }}
87+
run: yarn deploy:${{ inputs.subgraph }}:${{ vars.NETWORK }}
8488
working-directory: subgraph

contracts/deploy/utils/deployERC20AndFaucet.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ export const deployERC20AndFaucet = async (
99
ticker: string,
1010
faucetFundingAmount: BigNumber = hre.ethers.utils.parseUnits("100000")
1111
): Promise<Contract> => {
12-
let erc20 = await hre.ethers.getContractOrNull(ticker);
13-
if (erc20) {
14-
return erc20;
15-
}
16-
erc20 = await getContractOrDeploy(hre, ticker, {
12+
const erc20 = await getContractOrDeploy(hre, ticker, {
1713
from: deployer,
1814
contract: "TestERC20",
1915
args: [ticker, ticker],
@@ -27,7 +23,8 @@ export const deployERC20AndFaucet = async (
2723
});
2824
const faucetBalance = await erc20.balanceOf(faucet.address);
2925
const deployerBalance = await erc20.balanceOf(deployer);
30-
if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.isZero()) {
26+
if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.lt(faucetFundingAmount.div(5))) {
27+
// Fund the faucet if deployer has enough tokens and if the faucet has less than 20% of the faucetFundingAmount
3128
console.log(`funding ${ticker}Faucet with ${faucetFundingAmount}`);
3229
await erc20.transfer(faucet.address, faucetFundingAmount);
3330
}

contracts/scripts/keeperBot.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DisputeKitClassic, KlerosCore, PNK, RandomizerRNG, SortitionModule } from "../typechain-types";
1+
import { DisputeKitClassic, KlerosCore, PNK, RandomizerRNG, BlockHashRNG, SortitionModule } from "../typechain-types";
22
import request from "graphql-request";
33
import env from "./utils/env";
44
import loggerFactory from "./utils/logger";
@@ -36,9 +36,10 @@ const getContracts = async () => {
3636
const core = (await ethers.getContract("KlerosCore")) as KlerosCore;
3737
const sortition = (await ethers.getContract("SortitionModule")) as SortitionModule;
3838
const randomizerRng = (await ethers.getContract("RandomizerRNG")) as RandomizerRNG;
39+
const blockHashRNG = (await ethers.getContract("BlockHashRNG")) as BlockHashRNG;
3940
const disputeKitClassic = (await ethers.getContract("DisputeKitClassic")) as DisputeKitClassic;
4041
const pnk = (await ethers.getContract("PNK")) as PNK;
41-
return { core, sortition, randomizerRng, disputeKitClassic, pnk };
42+
return { core, sortition, randomizerRng, blockHashRNG, disputeKitClassic, pnk };
4243
};
4344

4445
type Contribution = {
@@ -150,15 +151,32 @@ const handleError = (e: any) => {
150151
};
151152

152153
const isRngReady = async () => {
153-
const { randomizerRng, sortition } = await getContracts();
154-
const requesterID = await randomizerRng.requesterToID(sortition.address);
155-
const n = await randomizerRng.randomNumbers(requesterID);
156-
if (Number(n) === 0) {
157-
logger.info("RandomizerRNG is NOT ready yet");
158-
return false;
154+
const { randomizerRng, blockHashRNG, sortition } = await getContracts();
155+
const currentRng = await sortition.rng();
156+
if (currentRng === randomizerRng.address) {
157+
const requesterID = await randomizerRng.requesterToID(sortition.address);
158+
const n = await randomizerRng.randomNumbers(requesterID);
159+
if (Number(n) === 0) {
160+
logger.info("RandomizerRNG is NOT ready yet");
161+
return false;
162+
} else {
163+
logger.info(`RandomizerRNG is ready: ${n.toString()}`);
164+
return true;
165+
}
166+
} else if (currentRng === blockHashRNG.address) {
167+
const requestBlock = await sortition.randomNumberRequestBlock();
168+
const lookahead = await sortition.rngLookahead();
169+
const n = await blockHashRNG.callStatic.receiveRandomness(requestBlock.add(lookahead));
170+
if (Number(n) === 0) {
171+
logger.info("BlockHashRNG is NOT ready yet");
172+
return false;
173+
} else {
174+
logger.info(`BlockHashRNG is ready: ${n.toString()}`);
175+
return true;
176+
}
159177
} else {
160-
logger.info(`RandomizerRNG is ready: ${n.toString()}`);
161-
return true;
178+
logger.error("Unknown RNG at ", currentRng);
179+
return false;
162180
}
163181
};
164182

scripts/act-subgraph.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
act workflow_dispatch -j buildAndDeploy --input network=arbitrum-sepolia,update=true
3+
act workflow_dispatch -j buildAndDeploy --input graph_environment=graph-studio-devnet,update=true --env network=arbitrum-sepolia-devnet

subgraph/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ $ yarn run graph auth --studio
4040
#### Deployment
4141

4242
```bash
43+
# bump the package version number
44+
yarn version patch
45+
46+
# deploy the new version
4347
yarn deploy:arbitrum-sepolia-devnet
48+
49+
# commit the new version number
50+
git commit -m "chore: subgraph deployment"
4451
```
4552

4653
### Using the Kleros organization account

subgraph/core/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type Round @entity {
181181
penalties: BigInt!
182182
drawnJurors: [Draw!]! @derivedFrom(field: "round")
183183
dispute: Dispute!
184+
court: Court!
184185
feeToken: FeeToken
185186
}
186187

subgraph/core/src/KlerosCore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function handleDisputeCreation(event: DisputeCreation): void {
7878
court.save();
7979
createDisputeFromEvent(event);
8080
const roundInfo = contract.getRoundInfo(disputeID, ZERO);
81-
createRoundFromRoundInfo(disputeID, ZERO, roundInfo);
81+
createRoundFromRoundInfo(KlerosCore.bind(event.address), disputeID, ZERO, roundInfo);
8282
const arbitrable = event.params._arbitrable.toHexString();
8383
updateArbitrableCases(arbitrable, ONE);
8484
updateCases(ONE, event.block.timestamp);
@@ -163,7 +163,7 @@ export function handleAppealDecision(event: AppealDecision): void {
163163
dispute.currentRound = roundID;
164164
dispute.save();
165165
const roundInfo = contract.getRoundInfo(disputeID, newRoundIndex);
166-
createRoundFromRoundInfo(disputeID, newRoundIndex, roundInfo);
166+
createRoundFromRoundInfo(KlerosCore.bind(event.address), disputeID, newRoundIndex, roundInfo);
167167
}
168168

169169
export function handleCourtJump(event: CourtJump): void {

subgraph/core/src/entities/Round.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { BigInt } from "@graphprotocol/graph-ts";
2-
import { KlerosCore__getRoundInfoResultValue0Struct } from "../../generated/KlerosCore/KlerosCore";
2+
import { KlerosCore, KlerosCore__getRoundInfoResultValue0Struct } from "../../generated/KlerosCore/KlerosCore";
33
import { Round } from "../../generated/schema";
44

55
export function createRoundFromRoundInfo(
6+
contract: KlerosCore,
67
disputeID: BigInt,
78
roundIndex: BigInt,
89
roundInfo: KlerosCore__getRoundInfoResultValue0Struct
@@ -19,5 +20,7 @@ export function createRoundFromRoundInfo(
1920
round.repartitions = roundInfo.repartitions;
2021
round.penalties = roundInfo.pnkPenalties;
2122
round.dispute = disputeID.toString();
23+
const courtID = contract.disputes(disputeID).value0.toString();
24+
round.court = courtID;
2225
round.save();
2326
}

subgraph/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3+
"version": "0.3.1",
34
"license": "MIT",
45
"scripts": {
56
"update:core:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia core/subgraph.yaml",
@@ -10,9 +11,9 @@
1011
"build:core": "graph build --output-dir core/build/ core/subgraph.yaml",
1112
"test:core": "cd core && graph test",
1213
"clean:core": "graph clean --codegen-dir core/generated/ --build-dir core/build/ && rm core/subgraph.yaml.bak.*",
13-
"deploy:core:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-core-devnet -l v0.0.2 core/subgraph.yaml",
14-
"deploy:core:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-core-testnet -l v0.0.2 core/subgraph.yaml",
15-
"deploy:core:arbitrum": "graph deploy --product subgraph-studio kleros-v2-core -l v0.0.2 core/subgraph.yaml",
14+
"deploy:core:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-core-devnet -l v$npm_package_version core/subgraph.yaml",
15+
"deploy:core:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-core-testnet -l v$npm_package_version core/subgraph.yaml",
16+
"deploy:core:arbitrum": "graph deploy --product subgraph-studio kleros-v2-core -l v$npm_package_version core/subgraph.yaml",
1617
"": "------------------------------------------------------------------------------------------",
1718
"update:drt:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia dispute-template-registry/subgraph.yaml",
1819
"update:drt:arbitrum-sepolia": "./scripts/update.sh arbitrumSepolia arbitrum-sepolia dispute-template-registry/subgraph.yaml",
@@ -22,8 +23,8 @@
2223
"build:drt": "graph build --output-dir dispute-template-registry/generated/ dispute-template-registry/subgraph.yaml",
2324
"test:drt": "cd dispute-template-registry && graph test ",
2425
"clean:drt": "graph clean --codegen-dir dispute-template-registry/generated/ --build-dir dispute-template-registry/build/ && rm dispute-template-registry/subgraph.yaml.bak.*",
25-
"deploy:drt:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-devnet -l v0.0.2 dispute-template-registry/subgraph.yaml",
26-
"deploy:drt:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-testnet -l v0.0.2 dispute-template-registry/subgraph.yaml",
26+
"deploy:drt:arbitrum-sepolia-devnet": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-devnet -l v$npm_package_version dispute-template-registry/subgraph.yaml",
27+
"deploy:drt:arbitrum-sepolia": "graph deploy --product subgraph-studio kleros-v2-drt-arbisep-testnet -l v$npm_package_version dispute-template-registry/subgraph.yaml",
2728
" ": "-----------------------------------------------------------------------------------------",
2829
"update:arbitrum-sepolia-devnet": "./scripts/all.sh update arbitrum-sepolia-devnet",
2930
"update:arbitrum-sepolia": "./scripts/all.sh update arbitrum-sepolia",
Lines changed: 17 additions & 0 deletions
Loading

web/src/components/Verdict/DisputeTimeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const useItems = (disputeDetails?: DisputeDetailsQuery, arbitrable?: `0x${string
8787
acc.push({
8888
title: `Jury Decision - Round ${index + 1}`,
8989
party: isOngoing ? "Voting is ongoing" : getVoteChoice(parsedRoundChoice, answers),
90-
subtitle: eventDate,
90+
subtitle: `${eventDate} / ${votingHistory?.dispute?.rounds.at(index)?.court.name}`,
9191
rightSided: true,
9292
variant: theme.secondaryPurple,
9393
Icon: icon !== "" ? icon : undefined,

web/src/hooks/queries/useVotingHistory.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const votingHistoryQuery = graphql(`
1010
id
1111
rounds {
1212
nbVotes
13+
court {
14+
id
15+
name
16+
}
1317
}
1418
disputeKitDispute {
1519
localRounds {

web/src/pages/Cases/CaseDetails/Overview/Policies.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IPFS_GATEWAY } from "consts/index";
55
import PolicyIcon from "svgs/icons/policy.svg";
66
import { isUndefined } from "utils/index";
77
import { responsiveSize } from "styles/responsiveSize";
8+
import PaperclipIcon from "svgs/icons/paperclip.svg";
89

910
const ShadeArea = styled.div`
1011
display: flex;
@@ -46,21 +47,38 @@ const StyledPolicyIcon = styled(PolicyIcon)`
4647
fill: ${({ theme }) => theme.primaryBlue};
4748
`;
4849

50+
const StyledPaperclipIcon = styled(PaperclipIcon)`
51+
width: 16px;
52+
fill: ${({ theme }) => theme.primaryBlue};
53+
`;
54+
4955
const LinkContainer = styled.div`
5056
display: flex;
51-
gap: ${responsiveSize(8, 24)};
57+
gap: ${responsiveSize(16, 24)};
58+
flex-wrap: wrap;
5259
`;
5360

61+
type Attachment = {
62+
label?: string;
63+
uri: string;
64+
};
5465
interface IPolicies {
5566
disputePolicyURI?: string;
5667
courtId?: string;
68+
attachment?: Attachment;
5769
}
5870

59-
export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId }) => {
71+
export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId, attachment }) => {
6072
return (
6173
<ShadeArea>
6274
<StyledP>Make sure you read and understand the Policies</StyledP>
6375
<LinkContainer>
76+
{!isUndefined(attachment) && !isUndefined(attachment.uri) ? (
77+
<StyledA href={`${IPFS_GATEWAY}${attachment.uri}`} target="_blank" rel="noreferrer">
78+
<StyledPaperclipIcon />
79+
{attachment.label ?? "Attachment"}
80+
</StyledA>
81+
) : null}
6482
{isUndefined(disputePolicyURI) ? null : (
6583
<StyledA href={`${IPFS_GATEWAY}${disputePolicyURI}`} target="_blank" rel="noreferrer">
6684
<StyledPolicyIcon />

web/src/pages/Cases/CaseDetails/Overview/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ const Overview: React.FC<IOverview> = ({ arbitrable, courtID, currentPeriodIndex
7373
{...{ rewards, category }}
7474
/>
7575
</Container>
76-
<Policies disputePolicyURI={disputeTemplate?.policyURI} courtId={courtID} />
76+
<Policies
77+
disputePolicyURI={disputeTemplate?.policyURI}
78+
courtId={courtID}
79+
attachment={disputeTemplate?.attachment}
80+
/>
7781
</>
7882
);
7983
};

web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
133133
? "All jurors voted"
134134
: localRounds.at(currentTab)?.totalVoted.toString() +
135135
` vote${localRounds.at(currentTab)?.totalVoted.toString() === "1" ? "" : "s"} cast out of ` +
136-
rounds.at(currentTab)?.nbVotes}
136+
rounds.at(currentTab)?.nbVotes}{" "}
137+
- {rounds.at(currentTab)?.court.name}
137138
</p>
138139
</StyledBox>
139140
<StyledAccordion

0 commit comments

Comments
 (0)