You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add subgraph GitHub workflow and update the Readme (#780)
* First try
Signed-off-by: Maksim Dimitrov <[email protected]>
* Generate package-lock.json. Update workflow
Signed-off-by: Maksim Dimitrov <[email protected]>
* Try to set default working dir
Signed-off-by: Maksim Dimitrov <[email protected]>
* Add create .env file step
Signed-off-by: Maksim Dimitrov <[email protected]>
* Run hedera-local in detached
Signed-off-by: Maksim Dimitrov <[email protected]>
* Update packages and workflow
Signed-off-by: Maksim Dimitrov <[email protected]>
* Add sleep step
Signed-off-by: Maksim Dimitrov <[email protected]>
* Change npx to npm
Signed-off-by: Maksim Dimitrov <[email protected]>
* Remove step
Signed-off-by: Maksim Dimitrov <[email protected]>
* Try without retry
Signed-off-by: Maksim Dimitrov <[email protected]>
* Try without retry v2
Signed-off-by: Maksim Dimitrov <[email protected]>
* Try without retry v3
Signed-off-by: Maksim Dimitrov <[email protected]>
* Add loadash.isequal
Signed-off-by: Maksim Dimitrov <[email protected]>
* Use lodash
Signed-off-by: Maksim Dimitrov <[email protected]>
* Load isEqual from lodash
Signed-off-by: Maksim Dimitrov <[email protected]>
* Use npm ci
Signed-off-by: Maksim Dimitrov <[email protected]>
* Fix typo
Signed-off-by: Maksim Dimitrov <[email protected]>
* Reduce the wait time, update the readme
Signed-off-by: Maksim Dimitrov <[email protected]>
* Update Readme
Signed-off-by: Maksim Dimitrov <[email protected]>
* More Readme updates
Signed-off-by: Maksim Dimitrov <[email protected]>
* Update Readme again
Signed-off-by: Maksim Dimitrov <[email protected]>
* Update relay and mirror-node version in readme
Signed-off-by: Maksim Dimitrov <[email protected]>
Signed-off-by: Maksim Dimitrov <[email protected]>
Note: Currently this example needs to be executed against older relay and mirror-node versions, until all fixes have been released.
25
+
Note: Currently this example needs to be executed against older relay (v0.10.0) and mirror-node (v0.67.0-rc1) versions, until all fixes have been released.
16
26
17
-
### Install the dependencies:
27
+
The full hedera local-node config can be found [here](./configs/local-test.json)
28
+
29
+
#### Install the dependencies:
18
30
19
31
Run `npm install` or `yarn [install]`
20
32
21
-
### Run Hedera local node:
33
+
####Run Hedera local node:
22
34
23
35
To start a Hedera local node by running `npx hedera start --network local-test`. Note that when the containers are up, you'll need to stop the `json-rpc-relay` container and start a local relay server.
24
36
25
-
### JSON-RPC Relay configurations:
26
-
27
-
Note: Currently you'll have to start the relay from the main branch in this repo, because it contains important bugfixes. This doc will be updated when a new version containing all the fixes is released.
37
+
#### JSON-RPC Relay configurations:
28
38
29
-
The graph node is configured to run against a local instance of the json-rpc-relay. Be sure to set the following options in your json-rpc .env file:
39
+
If the graph node is configured to run against a local instance of the json-rpc-relay. Be sure to set the following env variables in your json-rpc-relay .env file:
30
40
```
31
41
ETH_GET_LOGS_BLOCK_RANGE_LIMIT=2000
32
42
RATE_LIMIT_DISABLED = true
33
43
```
34
44
35
-
### Set .env vars
45
+
####Set .env vars
36
46
37
47
Rename `.env.example` to `.env`
38
48
@@ -53,7 +63,7 @@ Rename `.env.example` to `.env`
53
63
54
64
`npx hardhat createGravatar`
55
65
56
-
NOTE: This example uses the [hardhat-graph](https://github.com/graphprotocol/hardhat-graph)hardhat plugin. After every contract deploy, the plugin will update the networks.json file with the contract address (and the startBlock), so you don't have to manually update it in the `subgraph.yaml` file.
66
+
_NOTE: This example uses the [hardhat-graph](https://github.com/graphprotocol/hardhat-graph) plugin. After every contract deploy, the plugin will update the networks.json file with the contract address (and the startBlock), this way you can use the `--network <network_name>` option of the `deploy` command, which will automatically update the address (and startBlock) in the `subgraph.yaml` file to the last contract deployment._
57
67
58
68
### Generate the types:
59
69
@@ -63,34 +73,49 @@ Run `npm run graph-codegen` or `yarn graph-codegen`
63
73
64
74
Run `npm run graph-local` or `yarn graph-local`
65
75
66
-
Note: If you run the graph-node against a local Hedera node and see this error in the graph-node console:
76
+
_NOTE: If you run the graph-node against a local Hedera node and see this error in the graph-node console:_
77
+
67
78
```
68
79
Trying again after eth_getBlockByNumber(0, false) RPC call failed (attempt #10) with result Err(Ethereum node could not find genesis block), provider: local-rpc-0
69
80
```
70
81
71
-
Uncomment[this](./docker-compose.yml#L24) line and restart the node.
82
+
_Add[this](./docker-compose.yml#L24) line to your `docker-compose.yml`and restart the node._
72
83
73
-
Every time you restart the hedera-node it is recommended to do a clean-up of the graph-node. To do this run `npm run graph-local-clean` or `yarn graph-local-clean`
84
+
_NOTE: Every time you restart the hedera-node it is recommended to do a clean-up of the graph-node. To do this run `npm run graph-local-clean` or `yarn graph-local-clean`_
74
85
75
86
### Deploy the subgraph to the local graph-node:
76
87
77
-
Before deploying the subgraph, be sure to update the address (and startBlock) in `subgraph.yaml` to the address of the deployed Greeter contract.
78
-
79
88
To deploy the subgraph:
80
89
81
90
1. Run `npm run create-local` or `yarn create-local`
82
91
2. Run `npm run deploy-local -- --network local` or `yarn deploy-local --network local`
83
92
3. Follow the instructions
84
93
4. After the subgraph is successfully deployed open the [GraphQL playground](http://127.0.0.1:8000/subgraphs/name/subgraph-example/graphql?query=%7B+%0A++gravatars+%7B%0A++++id%0A++++owner%0A++++displayName%0A++++imageUrl%0A++%7D%0A++erc20S+%7B%0A++++id%0A++++supply%0A++++type%0A++++transfers+%7B%0A++++++from%0A++++++to%0A++++++amount%0A++++%7D%0A++%7D%0A++erc721S+%7B%0A++++id%0A++++owner%0A++++type%0A++++tokenId%0A++++transfers+%7B%0A++++++from%0A++++++to%0A++++%7D%0A++%7D%0A%7D%0A) where you can execute queries and fetch indexed data.
85
94
86
-
###Running the tests:
95
+
## Running the tests:
87
96
88
-
Note: At this time the whole test workflow can't be proficiently automated, so you'll need to perform some manual steps:
97
+
_NOTE: At this time the whole test workflow can't be proficiently automated, so you'll need to perform some manual steps:_
89
98
90
99
1. Be sure to start a clean local hedera node. If the node is currently running stop it.
91
-
- Run `npx hedera stop` to be sure that all containers are stopped and the temp files and volumes have been removed.
92
-
- Run `npx hedera start --network local-test` to start a new clean node.
100
+
1. Run `npx hedera stop` to be sure that all containers are stopped and the temp files and volumes have been removed.
101
+
2. Run `npx hedera start --network local-test` to start a new clean node.
93
102
2. After the node has started, execute `npx hardhat prepare` task, which will deploy and interact with the contracts.
94
103
3. Be sure to start a clean graph-node by executing `yarn/npm run graph-local-clean` and then `yarn/npm run graph-local`
95
104
4. Create and deploy the subgraph by executing `yarn/npm run create-local` and `yarn deploy-local --network local` or `npx run deploy-local -- --network local` and follow the instructions
96
105
5. Execute `npx hardhat test`
106
+
107
+
108
+
## HOW TOs:
109
+
110
+
### Run a private graph-node against testnet, previewnet and mainnet:
111
+
112
+
The easiest way to run a local `graph-node` against `testnet`, `previewnet` or `mainnet` is using the [docker-compose](https://github.com/graphprotocol/graph-node/tree/master/docker#docker-compose) setup.
113
+
114
+
1. Copy the content of the provided [docker-compose.yml](https://github.com/graphprotocol/graph-node/blob/master/docker/docker-compose.yml) file, or use the one from the [subgraph-example](./docker-compose.yml)
115
+
2. Replace `'mainnet:http://host.docker.internal:8545'` on [this](https://github.com/graphprotocol/graph-node/blob/master/docker/docker-compose.yml#L22) line with:
116
+
1.`'mainnet:https://mainnet.hashio.io/api'` for `mainnet`
117
+
2.`'testnet:https://testnet.hashio.io/api'` for `testnet`
118
+
3.`'previewnet:https://previewnet.hashio.io/api'` for `testnet`
119
+
3. In the `subgraph.yaml` file change the dataSources network with to the network you want to index. Also don't forget to update the address (and the startBlock).
120
+
121
+
Advanced info on how to set up an indexer could be found in [The Graph Docs](https://thegraph.com/docs/en/indexing/operating-graph-node/) and the [official graph-node GitHub repository](https://github.com/graphprotocol/graph-node)
0 commit comments