Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
f1c956e
feat(subgraph): improve subgraph indexing
alcercu Aug 8, 2022
8eb38b5
Merge branch 'master' into feat(subgraph)/add-subcourt-entity
alcercu Aug 10, 2022
abd5725
feat: migration to Goerli (L1) and Arbitrum Goerli (L2)
jaybuidl Aug 10, 2022
42be8b5
chore(deps-dev): bump @openzeppelin/contracts from 4.7.2 to 4.7.3
dependabot[bot] Aug 11, 2022
f0caa66
Merge branch 'master' into feat(subgraph)/add-subcourt-entity
alcercu Aug 15, 2022
718e4fb
chore(deps-dev): bump @typescript-eslint/parser from 5.32.0 to 5.33.1
dependabot[bot] Aug 16, 2022
c461c7d
wip: add missing events to subgraph
alcercu Aug 18, 2022
35e68ef
refactor(web): make cases page into component for reusability
alcercu Aug 18, 2022
be72580
feat: arbitrable metaevidence can be changed by governor
jaybuidl Aug 18, 2022
2cf527e
wip(web): add Dashboard page
alcercu Aug 19, 2022
d42238f
refactor: finally KlerosCore is now below 24KB
jaybuidl Aug 20, 2022
baf8114
Message layout comment update
shotaronowhere Aug 13, 2022
7e6cd82
chore: reployed successfully to both goerli and rinkeby
jaybuidl Aug 20, 2022
75d1fa8
feat: migration to Goerli (L1) and Arbitrum Goerli (L2)
jaybuidl Aug 10, 2022
0396618
refactor: finally KlerosCore is now below 24KB
jaybuidl Aug 20, 2022
53a42f5
chore: reployed successfully to both goerli and rinkeby
jaybuidl Aug 20, 2022
6d9504d
Merge pull request #202 from kleros/chore/redeploy
jaybuidl Aug 20, 2022
74a5b8b
chore(deps-dev): bump @tenderly/hardhat-tenderly from 1.1.4 to 1.1.6
dependabot[bot] Aug 17, 2022
6016368
chore(deps-dev): bump @typescript-eslint/eslint-plugin
dependabot[bot] Aug 16, 2022
15ca58a
chore(deps): bump actions/cache from 3.0.5 to 3.0.7
dependabot[bot] Aug 12, 2022
1e701e5
chore(deps): bump @graphql-codegen/cli from 2.11.3 to 2.11.6
dependabot[bot] Aug 12, 2022
b0a99c9
chore(deps): bump @graphql-codegen/typescript-operations
dependabot[bot] Aug 8, 2022
eff0da3
chore(deps-dev): bump @types/chai from 4.3.1 to 4.3.3
dependabot[bot] Aug 8, 2022
c022a7e
chore(deps-dev): bump parcel from 2.6.2 to 2.7.0
dependabot[bot] Aug 8, 2022
6713106
chore(deps-dev): bump @parcel/transformer-svg-react from 2.6.2 to 2.7.0
dependabot[bot] Aug 8, 2022
e96ee63
chore(deps): bump chart.js from 3.8.2 to 3.9.1
dependabot[bot] Aug 8, 2022
f724288
Merge branch 'chore/patches' into dependabot/npm_and_yarn/typescript-…
jaybuidl Aug 20, 2022
c0b4197
Merge pull request #208 from kleros/dependabot/npm_and_yarn/typescrip…
jaybuidl Aug 20, 2022
98ee057
Merge branch 'chore/patches' into dependabot/npm_and_yarn/openzeppeli…
jaybuidl Aug 20, 2022
7ad8e21
Merge pull request #203 from kleros/dependabot/npm_and_yarn/openzeppe…
jaybuidl Aug 20, 2022
1cc85f0
chore: lockfile update
jaybuidl Aug 20, 2022
ee687ba
feat(bridge): sender subgraph
shotaronowhere Jun 27, 2022
69e431f
refactor: subfolder removed
jaybuidl Aug 2, 2022
0b7c751
feat: bridge subgraph update script
jaybuidl Aug 10, 2022
f007411
feat: updated and reployed the fastbridge subgraph, added a local gra…
jaybuidl Aug 22, 2022
2aed0e0
fix: keeping the linter happy
jaybuidl Aug 22, 2022
582c47c
feat(web): add dashboard page
alcercu Aug 23, 2022
945bc18
Merge branch 'master' into feat(web)/dashboard-page
alcercu Aug 23, 2022
2ee489e
Merge branch 'master' into feat(subgraph)/add-subcourt-entity
alcercu Aug 23, 2022
2b80028
fix(KC): properly unstake inactive juror
unknownunknown1 Aug 16, 2022
fca5c82
feat(KC): test for unstaking bug
unknownunknown1 Aug 24, 2022
afebe7c
test: fixed test fixtures
jaybuidl Aug 24, 2022
51fb37b
fix: fast bridge receiver claim() revert reason more specific
jaybuidl Aug 25, 2022
25c16d6
feat: accommodate latest changes to subgraph
alcercu Aug 25, 2022
e7f0597
fix: home page crash with empty arrays in subgraph
alcercu Aug 25, 2022
16116d8
feat: added script to update the contracts address and startBlock
jaybuidl Aug 25, 2022
820209d
Merge pull request #231 from kleros/fix(web)/crash-with-empty-subgraph
alcercu Aug 26, 2022
0ff508d
fix: reset deploy package script to original value
alcercu Aug 26, 2022
708a6b5
Merge branch 'master' into feat(web)/dashboard-page
alcercu Aug 26, 2022
57e6da0
Merge pull request #232 from kleros/feat(subgraph)/add-subcourt-entity
alcercu Aug 26, 2022
9f83f3e
Merge pull request #223 from kleros/feat(web)/dashboard-page
alcercu Aug 26, 2022
ca2ba42
feat: data pinner bot for court evidence
jaybuidl Aug 26, 2022
2d23f2c
docs: extra metadata
jaybuidl Aug 29, 2022
f83ba53
feat: docker containers to replicate evidence hashes
Aug 30, 2022
984d039
refactor: code style
jaybuidl Aug 30, 2022
e394dc5
feat: dappnode packaging for bot-pinner
jaybuidl Aug 30, 2022
e1f77d4
fix: lock file
jaybuidl Sep 1, 2022
7b0944c
feat: workflow for bot deployment to AWS
jaybuidl Sep 2, 2022
75b3705
refactor: workflow rename
jaybuidl Sep 2, 2022
0d64f44
docs: added gitpoap badge
jaybuidl Sep 4, 2022
e4ef880
fix: bot-pinner dappnode semver
jaybuidl Sep 5, 2022
ce5e4b3
feat: migrated and deployed the PolicyRegistry
jaybuidl Sep 6, 2022
cef1ffd
chore: scripts to populate the policy registry
jaybuidl Sep 6, 2022
7ca424c
fix: linting
jaybuidl Sep 6, 2022
7e0cff4
feat: migration to a L1 blockhash-based RNG with significant lookahea…
jaybuidl Aug 25, 2022
5461dc1
fix: changed the lookahead to 20 (L2 sequencer finality only)
jaybuidl Aug 25, 2022
faf7344
refactor: rng inheritance simplified, removed unused incentive mechanism
jaybuidl Aug 25, 2022
b545255
fix: gas improvements
jaybuidl Sep 7, 2022
070bc44
fix: lock file
jaybuidl Sep 7, 2022
8745c9d
chore: scripts to populate the subcourts
jaybuidl Sep 8, 2022
fe1d7cc
feat: subcourt initialization script can update existing subcourts
jaybuidl Sep 8, 2022
6887d71
feat(web): add web3 boilerplate
alcercu Sep 19, 2022
b3b1405
feat(web): add web3 connect button and wrong chain error boundary
alcercu Sep 19, 2022
613bd20
fix(web): improve mobile header menu
alcercu Sep 19, 2022
13a57f0
fix(web): move key prop to correct level
alcercu Sep 19, 2022
e353ebe
fix(Sortition): remove multiple module support
unknownunknown1 Sep 19, 2022
7df6330
chore: script to force reinstall
jaybuidl Sep 20, 2022
31a985f
docs: removed deprecation for Rinkeby
jaybuidl Sep 21, 2022
c1a80fe
fix: lock file
jaybuidl Sep 22, 2022
c435215
fix: lock file
jaybuidl Sep 22, 2022
d57b26b
Merge branch 'master' into feat/add-web3
alcercu Sep 23, 2022
f193b1c
fix: yarn.lock
alcercu Sep 23, 2022
1dd519d
fix(web): remove redundant awaits
alcercu Sep 23, 2022
9aaef90
Merge pull request #307 from kleros/feat/add-web3
alcercu Sep 23, 2022
a64218d
fix(Sortition): generalize drawing
unknownunknown1 Sep 26, 2022
40e1649
Merge branch 'master' in feat/sortition-modularity
unknownunknown1 Sep 26, 2022
a27af27
chore: added override subcourt parameters override for testing purposes
jaybuidl Sep 26, 2022
c593073
fix(Sortition): fix compiler and test errors
unknownunknown1 Sep 28, 2022
4ffcec9
Merge branch 'master' into feat/sortition-modularity
unknownunknown1 Sep 28, 2022
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 .github/workflows/contracts-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3

- name: Cache node modules
uses: actions/cache@v3.0.5
uses: actions/cache@v3.0.7
env:
cache-name: cache-node-modules
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/deploy-bots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on: [workflow_dispatch]

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: aws-actions/setup-sam@v1
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_KEY }}
aws-region: us-east-2

# sam build
- run: sam build --use-container
working-directory: bots

# Run Unit tests- Specify unit tests here

# sam deploy
- run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name kleros-v2-bots --s3-bucket kleros-v2-bots --capabilities CAPABILITY_IAM --region us-east-2
working-directory: bots
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<p align="center">
<a href="https://app.netlify.com/sites/kleros-v2/deploys"><img src="https://api.netlify.com/api/v1/badges/86d94ae8-f655-46a4-a859-d68696173f3a/deploy-status" alt="Netlify Build Status"></a>
<a href="https://www.gitpoap.io/gh/kleros/kleros-v2"><img src="https://public-api.gitpoap.io/v1/repo/kleros/kleros-v2/badge" alt="GitPoap badge"></a>
</br>
<a href="https://sonarcloud.io/summary/new_code?id=kleros_kleros-v2"><img src="https://sonarcloud.io/api/project_badges/measure?project=kleros_kleros-v2&metric=security_rating" alt="Security Rating"></a>
<a href="https://sonarcloud.io/summary/new_code?id=kleros_kleros-v2"><img src="https://sonarcloud.io/api/project_badges/measure?project=kleros_kleros-v2&metric=alert_status" alt="Quality Gate Status"></a>
Expand Down
24 changes: 24 additions & 0 deletions bot-pinner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
court
compose

# DAppNodeSDK release directories
build_*
releases.json

### yarn ###
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored

# .yarn/unplugged and .yarn/build-state.yml should likely always be ignored since
# they typically hold machine-specific build artifacts. Ignoring them might however
# prevent Zero-Installs from working (to prevent this, set enableScripts to false).
.yarn/unplugged
.yarn/build-state.yml

# .yarn/cache and .pnp.* may be safely ignored, but you'll need to run yarn install
# to regenerate them between each branch switch.
# Uncomment the following lines if you're not using Zero-Installs:
# .yarn/cache
# .pnp.*

# End of https://www.toptal.com/developers/gitignore/api/yarn

10 changes: 10 additions & 0 deletions bot-pinner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY src/* .

CMD [ "python", "-u", "./add_hashes.py" ]
10 changes: 10 additions & 0 deletions bot-pinner/Dockerfile-dappnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt src/* ./
RUN pip install --no-cache-dir -r requirements.txt

COPY watchlist/* /var/lib/watchlist/

CMD [ "python", "-u", "./add_hashes.py" ]
85 changes: 85 additions & 0 deletions bot-pinner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Kleros Court V2 Evidence: Containers to replicate and decentralize data

## Quick start

If you don't have a local RPC node, add a RPC to the docker-compose file.

```bash
$ git clone git@github.com:kleros/kleros-v2.git
$ cd bot-pinner/
$ docker-compose build
$ docker-compose up -d
```

### In the box

1. Standard IPFS container which creates a local mount for data
2. Evidence container that awaits new events and then scrapes the latest hashes and submits it to IPFS.

## DappNode

:warning: For the following steps, you need access to [a DappNode](https://dappnode.io) system with the IPFS service running.

The IPFS service is expected by default at `http://ipfs-cluster.dappnode:9094`, it can be configured at build time in `docker-compose-dappnode.yml` or at runtime in the Config tab of the package in the dAppnode UI.

```bash
# first time only
$ yarn install
```

### Package installation without publishing

```bash
$ yarn build:dappnode
✔ Verify connection
✔ Create release dir
✔ Validate files
✔ Copy files
✔ Build docker image
✔ Save and compress image
✔ Upload release to IPFS node
✔ Save upload results

DNP (DAppNode Package) built and uploaded
Release hash : /ipfs/Qma773qBk3PqTDQk6biRagcjiNutmit2rpKStq5WbH16XJ
http://my.dappnode/#/installer/%2Fipfs%2FQma773qBk3PqTDQk6biRagcjiNutmit2rpKStq5WbH16XJ
```

Then follow the url to install the package, or open the DappStore page and paste the ipfs hash.

![DappNode package](docs/image.png)

### Publishing

```bash
# Increase the version number, specify either: major, minor, patch.
$ yarn bump:dappnode patch
0.1.1

# Upload to IPFS
$ yarn publish:dappnode patch
✔ Fetch current version from APM (next version: 0.1.1)
✔ Build and upload
✔ Generate transaction

DNP (DAppNode Package) published (version 0.1.1)
Release hash : /ipfs/xxxx
http://my.dappnode/#/installer/%2Fipfs%2Fxxxx

You must execute this transaction in mainnet to publish a new version of this DNP.

To : 0x988b3A538b618C7A603e1c11Ab82Cd16dbE28069
Value : 0
Data : 0x32ab6afxxxxx
Gas : 1100000

You can also execute this transaction with Metamask by following this pre-filled link

https://dappnode.github.io/sdk-publish/?r=data-pinner.kleros.eth&v=0.1.1&h=%2Fipfs%2Fxxxxx

```

## Contributions

Please visit [contribution.kleros.io](contributing.kleros.io.).
For any questions, please join the Kleros Discord or Telegram.
Binary file added bot-pinner/avatar-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions bot-pinner/dappnode_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "kleros-data-pinner.public.dappnode.eth",
"version": "0.1.0",
"shortDescription": "IPFS data pinner for Kleros",
"description": "IPFS data pinner for Kleros",
"type": "service",
"author": "Kleros <contact@kleros.io> (https://github.com/kleros)",
"contributors": [
"JayBuidl <jb@kleros.io> (https://github.com/jaybuidl)",
"George <george@kleros.io> (https://github.com/geaxed)"
],
"categories": [
"Storage",
"Developer tools"
],
"links": {
"homepage": "https://kleros.io"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/kleros/kleros-v2.git"
},
"bugs": {
"url": "https://github.com/kleros/kleros-v2/issues"
}
}
17 changes: 17 additions & 0 deletions bot-pinner/docker-compose-dappnode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.5"
services:
data-pinner.kleros.eth:
build:
context: .
dockerfile: Dockerfile-dappnode
image: "data-pinner.kleros.eth.kleros-data-pinner.public.dappnode.eth:0.1.0"
restart: unless-stopped
volumes:
- "data:/var/lib/data/"
environment:
RPC: "https://rinkeby.arbitrum.io/rpc"
IPFS: "http://ipfs-cluster.dappnode:9094"
INTERVAL: 60
RETRY: 2
volumes:
data: {}
27 changes: 27 additions & 0 deletions bot-pinner/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.4"
services:
ipfs1:
container_name: ipfs1
image: ipfs/go-ipfs:latest
ports:
# - "4001:4001" # ipfs swarm - expose if needed/wanted
- "5001:5001" # ipfs api - expose if needed/wanted
- "8080:8080" # ipfs gateway - expose if needed/wanted
volumes:
- ./compose/ipfs0:/data/ipfs

kleros-court-v2-evidence:
depends_on:
- ipfs1
network_mode: host
container_name: court-v2-evidence
build: .
volumes:
- ./court/:/var/lib/data/
- ./watchlist/:/var/lib/watchlist/
environment:
RPC: "https://rinkeby.arbitrum.io/rpc"
IPFS: "http://localhost:5001/api/v0"
INTERVAL: 300
RETRY: 2

Binary file added bot-pinner/docs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions bot-pinner/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@kleros/kleros-v2-bot-pinner",
"version": "0.1.0",
"description": "Pinning of the court data to decentralized storage.",
"author": "Kleros",
"license": "MIT",
"packageManager": "yarn@3.1.0",
"volta": {
"node": "16.13.0"
},
"scripts": {
"build:local": "docker-compose build",
"build:dappnode": "dappnodesdk build --compose_file_name docker-compose-dappnode.yml",
"bump:dappnode": "dappnodesdk increase --compose_file_name docker-compose-dappnode.yml",
"publish:dappnode": "dappnodesdk publish --compose_file_name docker-compose-dappnode.yml",
"run:local": "docker-compose up"
},
"engines": {
"node": ">=16.13.0"
},
"devDependencies": {
"@dappnode/dappnodesdk": "^0.2.65"
}
}
2 changes: 2 additions & 0 deletions bot-pinner/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web3
requests
109 changes: 109 additions & 0 deletions bot-pinner/src/add_hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from web3 import Web3
import requests
import os
import time
from tooling import motd, create_logger, port_up
import json
import glob


logger = create_logger()
motd()

# Init
RPC = os.environ.get("RPC", "http://localhost:8545")
IPFS = os.environ.get("IPFS", "http://ipfs-cluster.dappnode:9094")
INTERVAL = os.environ.get("INTERVAL", 600) # Events are not constantly listened to, instead it checks per INTERVAL.
RETRY = int(os.environ.get("RETRY", 0)) # Retry interval value
attempted_retries = dict()

# Contract / RPC
w3 = Web3(Web3.HTTPProvider(RPC))

# Read block height from disk or pull latest
block = 0
try:
with open("/var/lib/data/block") as file:
block = file.read()
except FileNotFoundError:
block = w3.eth.getBlock("latest")['number']

# Read want-list from disk
hashes_wanted = list()
try:
with open("/var/lib/data/missed_hashes") as file:
hashes_wanted = file.read().splitlines()
except FileNotFoundError:
pass

def main():
block_number = block
tasks = ["Evidence"]
contracts = get_contracts()
while True:
logger.info(f"Cycle starting from block #{block_number}. WANTED HASHES: {len(hashes_wanted)}")
latest = w3.eth.getBlock('latest')['number']
for contract in contracts:
for task in tasks:
event_filter = eval(str(f'contract.events.{task}.createFilter(fromBlock={block_number}, toBlock={latest})'))
for event in event_filter.get_all_entries():
try:
add_hash(event['args']['_evidence'])
except Exception as e:
logger.error(f"Failure {e} at {block_number}")
block_number = latest

# Keep track of block height
with open("/var/lib/data/block", "w") as file:
file.write(str(latest))

if len(hashes_wanted) > 0:
retry_hashes()

# Persist want-list
with open('/var/lib/data/missed_hashes', 'w') as f:
for line in hashes_wanted:
f.write(f"{line}\n")
time.sleep(int(INTERVAL))


def retry_hashes():
for _hash in hashes_wanted:
if not _hash in attempted_retries:
attempted_retries[_hash] = 0
else:
attempted_retries[_hash] += 1
if RETRY == 0 or attempted_retries[_hash] < RETRY:
add_hash(_hash)
elif attempted_retries[_hash] > int(RETRY + 10):
attempted_retries[_hash] = int(RETRY - 2) # Reset the search

def check_hash(_hash):
return _hash.rsplit('/', 1)[0] # Recursive pin // i.e. strip _hash/something.json

def add_hash(_hash):
_hash = check_hash(_hash)
try:
r = requests.post(f"{IPFS}/pin/add/{_hash}", timeout=30)
logger.info(f"Added {_hash}")
if _hash in hashes_wanted: hashes_wanted.remove(_hash)
except requests.exceptions.ReadTimeout:
logger.warning(f"Time-out: Couldn't find {_hash} on the IPFS network")
if _hash not in hashes_wanted: hashes_wanted.append(_hash)

def get_contracts():
contracts = []
for f in glob.glob('/var/lib/watchlist/**/*.json', recursive=True):
try:
with open(f) as fio:
data=json.load(fio)
abi = data["abi"]
address = w3.toChecksumAddress(data["address"])
contracts.append(w3.eth.contract(address=address, abi=abi))
logger.info(f"Adding to the watchlist: {address}")
except FileNotFoundError:
pass
return contracts

if __name__ == '__main__':
main()
Loading