Skip to content

feat(bridge): sender subgraph #124

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

Merged
merged 5 commits into from
Aug 22, 2022
Merged
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
4 changes: 2 additions & 2 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
- [PNK](https://goerli-rollup-explorer.arbitrum.io/token/0x4DEeeFD054434bf6721eF39Aa18EfB3fd0D12610/token-transfers)
- [DisputeKitClassic](https://goerli-rollup-explorer.arbitrum.io/address/0x8F1a2B8F9b04320375856580Fc6B1669Cb12a9EE)
- [DisputeResolver](https://goerli-rollup-explorer.arbitrum.io/address/0x04Fb43F2Ce076867b5ba38750Ecb2cc6BDe78D61)
- [FastBridgeSenderToEthereum](https://goerli-rollup-explorer.arbitrum.io/address/0xcFc0b84419583ff7b32fD5139B789cE858517d4C)
- [FastBridgeSender](https://goerli-rollup-explorer.arbitrum.io/address/0xcFc0b84419583ff7b32fD5139B789cE858517d4C)
- [HomeGatewayToEthereum](https://goerli-rollup-explorer.arbitrum.io/address/0xc7e3BF90299f6BD9FA7c3703837A9CAbB5743636)
- [IncrementalNG](https://goerli-rollup-explorer.arbitrum.io/address/0x99c1f883f0f5de1737099F1BCB268d1f8D450f8b)
- [KlerosCore](https://goerli-rollup-explorer.arbitrum.io/address/0x87142b7E9C7D026776499120D902AF8896C07894)
Expand All @@ -38,7 +38,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
- [PNK](https://testnet.arbiscan.io/token/0x364530164a2338cdba211f72c1438eb811b5c639)
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xA2c538AA05BBCc44c213441f6f3777223D2BF9e5)
- [DisputeResolver](https://testnet.arbiscan.io/address/0x67e8191F61466c57A17542A52F9f39f336A242fD)
- [FastBridgeSenderToEthereum](https://testnet.arbiscan.io/address/0xf8A4a85e7153374A1b9BDA763a84252eC286843b)
- [FastBridgeSender](https://testnet.arbiscan.io/address/0xf8A4a85e7153374A1b9BDA763a84252eC286843b)
- [HomeGatewayToEthereum](https://testnet.arbiscan.io/address/0x4e894c2B60214beC53B60D09F39544518296C07B)
- [IncrementalNG](https://testnet.arbiscan.io/address/0x078dAd05373d19d7fd6829735b765F12242a4300)
- [KlerosCore](https://testnet.arbiscan.io/address/0x815d709EFCF5E69e2e9E2F8d3815d762496a2f0F)
Expand Down
4 changes: 2 additions & 2 deletions contracts/deploy/02-home-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const fastBridgeReceiver = await deployments.get("FastBridgeReceiverOnEthereum");
const arbSysMock = await deploy("ArbSysMock", { from: deployer, log: true });

const fastBridgeSender = await deploy("FastBridgeSenderToEthereumMock", {
const fastBridgeSender = await deploy("FastBridgeSenderMock", {
from: deployer,
contract: "FastBridgeSenderMock",
args: [epochPeriod, fastBridgeReceiver.address, arbSysMock.address],
Expand Down Expand Up @@ -63,7 +63,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const liveDeployer = async () => {
const fastBridgeReceiver = await hre.companionNetworks.foreign.deployments.get("FastBridgeReceiverOnEthereum");

const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
const fastBridgeSender = await deploy("FastBridgeSender", {
from: deployer,
contract: "FastBridgeSender",
args: [epochPeriod, fastBridgeReceiver.address],
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FastBridgeReceiverOnEthereum,
ForeignGatewayOnEthereum,
ArbitrableExample,
FastBridgeSenderToEthereumMock,
FastBridgeSenderMock,
HomeGatewayToEthereum,
DisputeKitClassic,
InboxMock,
Expand Down Expand Up @@ -62,7 +62,7 @@ describe("Integration tests", async () => {
fastBridgeReceiver = (await ethers.getContract("FastBridgeReceiverOnEthereum")) as FastBridgeReceiverOnEthereum;
foreignGateway = (await ethers.getContract("ForeignGatewayOnEthereum")) as ForeignGatewayOnEthereum;
arbitrable = (await ethers.getContract("ArbitrableExample")) as ArbitrableExample;
fastBridgeSender = (await ethers.getContract("FastBridgeSenderToEthereumMock")) as FastBridgeSenderToEthereumMock;
fastBridgeSender = (await ethers.getContract("FastBridgeSenderMock")) as FastBridgeSenderMock;
homeGateway = (await ethers.getContract("HomeGatewayToEthereum")) as HomeGatewayToEthereum;
inbox = (await ethers.getContract("InboxMock")) as InboxMock;
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"evidence-display",
"klerosjs",
"subgraph",
"subgraph-fastbridge",
"web"
],
"packageManager": "yarn@3.1.1",
Expand Down
10 changes: 10 additions & 0 deletions subgraph-fastbridge/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
]
}
3 changes: 3 additions & 0 deletions subgraph-fastbridge/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 80
}
108 changes: 108 additions & 0 deletions subgraph-fastbridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# @kleros/kleros-v2-subgraph-fastbridge

## Deployments

- [kleros/fastbridge-arbitrum-rinkeby](https://thegraph.com/hosted-service/subgraph/kleros/fastbridge-arbitrum-rinkeby)

## Build

```bash
$ yarn

$ yarn codegen

$ yarn build
```

## Deployment to The Graph (hosted service)

### Authentication

Get an API key from the thegraph.com, then authenticate.

```bash
$ yarn run graph auth --product hosted-service
```

### Deployment

```bash
yarn deploy
```

## Deployment to a local Graph node

_Credits to the [scaffold-eth service package](https://github.com/scaffold-eth/scaffold-eth/tree/b03d07f15882db626300ffa04f222736b2a22f81/packages/services/graph-node)_

Preconfigured Docker image for running a Graph Node.

## Usage

**Prerequisite**: docker and docker-compose.

```bash
$ docker-compose up -d
Starting graph-node_postgres_1 ... done
Starting graph-node_ipfs_1 ... done
Starting graph-node_graph-node_1 ... done

$ docker-compose logs -f
...
```

This will start docker containers for the following services:

- IPFS,
- Postgres
- **Graph Node** connecting to the Arbitrum Rinkeby official RPC

This also creates persistent data directories for IPFS and Postgres in `./data/ipfs` and `./data/postgres`.

Once this is up and running, you can use [`graph-cli`](https://github.com/graphprotocol/graph-cli) to create and deploy your subgraph to the running Graph Node.

```bash
# First time only.
$ yarn create-local
Created subgraph: fastbridge

$ yarn deploy-local --version-label v0.0.1
✔ Apply migrations
✔ Load subgraph from subgraph.yaml
Compile data source: FastBridgeSender => build/FastBridgeSender/FastBridgeSender.wasm
✔ Compile subgraph
Copy schema file build/schema.graphql
Write subgraph file build/FastBridgeSender/abis/FastBridgeSender.json
Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/
Add file to IPFS build/schema.graphql
.. Qmb3Uahj4qKh5u3V4KuraXJqsrUVwPtvva1KQQSb5tLov9
Add file to IPFS build/FastBridgeSender/abis/FastBridgeSender.json
.. QmQas2SuTQH6zybTVMGBym76kyBoTp7MwkogcmtHAeMoRj
Add file to IPFS build/FastBridgeSender/FastBridgeSender.wasm
.. QmSLfCYp19WW5JEiaKdmcGFgBCJ5DA723dEkM6QvXE2eCa
✔ Upload subgraph to IPFS

Build completed: QmWjRVXec6auQdnpvYJ7F8vW7PzkJHYJhFtorWZAhtP9A3

Deployed to http://localhost:8000/subgraphs/name/fastbridge/graphql

Subgraph endpoints:
Queries (HTTP): http://localhost:8000/subgraphs/name/fastbridge
```

## Access

### Graph Node

- GraphiQL: `http://localhost:8000/`
- HTTP: `http://localhost:8000/subgraphs/name/<subgraph-name>`
- WebSockets: `ws://localhost:8001/subgraphs/name/<subgraph-name>`
- Admin: `http://localhost:8020/`

### IPFS

- `127.0.0.1:5001` or `/ip4/127.0.0.1/tcp/5001`

### Postgres

- `postgresql://graph-node:let-me-in@localhost:5432/graph-node`
Loading