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

Update README and graph-node tests #110

Merged
merged 2 commits into from
Apr 27, 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
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@

There are packages used from github so we need to follow the following steps to install them:

* To install this package we need to follow steps required to install github packages.
1. Create a github PAT (personal access token) if it does not already exist.

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-token

* We will need to authenticate to github packages. Follow the steps in https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages.
2. Configure the PAT with scopes mentioned in https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries. This is required to install or publish github packages.

Use personal access token to authenticate to github packages ( https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token).
3. Follow the steps in https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token to authenticate to github packages. We can also run the follwing to authenticate by logging in to npm.

```bash
$ npm login --scope=@vulcanize --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
```

Replace with the following:
- `USERNAME`: GitHub username
- `TOKEN`: Personal access token (configured above)
- `PUBLIC-EMAIL-ADDRESS`: Email address

4. When authenticating to github packages for the first time, yarn install may throw Unauthorized error. To overcome this we need to run yarn install in `packages/graph-node` directory of graph-watcher repo. After this yarn install for graph-watcher-ts works properly even from root of the repo.

This project uses [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).

Expand All @@ -20,21 +35,25 @@ Install packages (Node.JS v16.13.1):
yarn
```

### Services
## Tests

* [graph-node](./packages/graph-node/README.md)

## Services

The default config files used by the watchers assume the following services are setup and running on localhost:

* `vulcanize/go-ethereum` on port 8545
* `vulcanize/ipld-eth-server` with native GQL API enabled, on port 8082
* `postgraphile` on the `vulcanize/ipld-eth-server` database, on port 5000

#### Note
### Note

* In `vulcanize/ipld-eth-server`, add the following statement to `[ethereum]` section in `environments/config.toml`:

`chainConfig = "./chain.json" # ETH_CHAIN_CONFIG`

### Databases
## Databases

Note: Requires `postgres12`.

Expand Down Expand Up @@ -140,10 +159,3 @@ If the watcher uses a job queue, start the job runner in another terminal:
```bash
yarn job-runner
```


## Known Issues

* When authenticating to github packages for the first time, yarn install throws Unauthorized error in [graph-watcher-ts](https://github.com/vulcanize/graph-watcher-ts) repo even after setup.

To overcome this we need to run yarn install in `packages/graph-node` directory of graph-watcher repo. After this yarn install for graph-watcher-ts works properly even from root of the repo.
27 changes: 2 additions & 25 deletions packages/graph-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,9 @@
$ cp .env.example .env
```

3. To deploy contract for example subgraph use https://github.com/deep-stack/eth-contract-tests
3. Run `yarn build:example` to build the wasm files.

```bash
# In eth-contract-test repo.
$ yarn

$ yarn example:deploy
```

Use the address the contract got deployed to and set it to `EXAMPLE_CONTRACT_ADDRESS` in .env file.

3. To deploy contracts for eden subgraph use https://github.com/vulcanize/governance

4. Follow the steps in https://github.com/vulcanize/governance/tree/watcher-ts#instructions

5. Set the contract addresses for eden contracts in .env file from `deployments/localhost` directory in the governance repository.

Following are the contracts whose address needs to be set in .env file:

* EdenNetwork - EDEN_NETWORK_CONTRACT_ADDRESS
* MerkleDistributor - EDEN_NETWORK_DISTRIBUTION_CONTRACT_ADDRESS
* DistributorGovernance - EDEN_NETWORK_GOVERNANCE_CONTRACT_ADDRESS

6. Run `yarn build:example` to build the wasm files.

7. Run `yarn test`.
4. Run `yarn test`.

## Run

Expand Down
2 changes: 1 addition & 1 deletion packages/graph-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"asbuild:debug": "asc assembly/index.ts --lib ./node_modules --exportRuntime --target debug --runPasses asyncify --runtime stub --maximumMemory 10",
"asbuild:release": "asc assembly/index.ts --lib ./node_modules --exportRuntime --target release --runPasses asyncify",
"asbuild": "yarn asbuild:debug && yarn asbuild:release",
"test": "yarn asbuild:debug && DEBUG=vulcanize:* node --experimental-wasm-bigint node_modules/.bin/_mocha src/**/*.test.ts",
"test": "yarn asbuild:debug && DEBUG=vulcanize:* node node_modules/.bin/_mocha src/**/*.test.ts",
"build:example": "cd test/subgraph/example1 && yarn && yarn codegen && yarn build",
"watch": "DEBUG=vulcanize:* nodemon --watch src src/watcher.ts",
"compare-entity": "node bin/compare-entity"
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-node/src/call-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ chai.use(spies);

const sandbox = chai.spy.sandbox();

describe('call handler in mapping code', () => {
xdescribe('call handler in mapping code', () => {
let exports: any;
let db: Database;
let indexer: Indexer;
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-node/src/eden.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ chai.use(spies);

const sandbox = chai.spy.sandbox();

describe('eden wasm loader tests', async () => {
xdescribe('eden wasm loader tests', async () => {
let db: Database;
let indexer: Indexer;
let provider: BaseProvider;
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-node/src/eth-call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Database } from './database';
import { Indexer } from '../test/utils/indexer';
import { EventData } from './utils';

describe('eth-call wasm tests', () => {
xdescribe('eth-call wasm tests', () => {
let exports: any;
let db: Database;
let indexer: Indexer;
Expand Down
43 changes: 1 addition & 42 deletions packages/graph-node/test/subgraph/example1/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dataSources:
name: Example1
network: mainnet
source:
address: ""
address: "0xD5567AFC3C6c1325698F27d97b74D9ea9c44295e"
abi: Example1
startBlock: 100
mapping:
Expand All @@ -24,44 +24,3 @@ dataSources:
blockHandlers:
- handler: handleBlock
file: ./src/mapping.ts
- kind: ethereum/contract
name: Factory
network: mainnet
source:
address: ""
abi: Factory
startBlock: 100
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities: []
abis:
- name: Factory
file: ./abis/factory.json
- name: Pool
file: ./abis/pool.json
eventHandlers:
- event: PoolCreated(indexed address,indexed address,indexed uint24,int24,address)
handler: handlePoolCreated
file: ./src/factory.ts
templates:
- kind: ethereum/contract
name: Pool
network: mainnet
source:
abi: Pool
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities: []
file: ./src/pool.ts
abis:
- name: Pool
file: ./abis/pool.json
blockHandlers:
- handler: handleBlock
eventHandlers:
- event: Initialize(uint160,int24)
handler: handleInitialize