Skip to content

Commit 1e2c7aa

Browse files
committed
Revamp the toplevel and the docker README
These were woefully out of date and utterly confusing
1 parent 44934aa commit 1e2c7aa

File tree

3 files changed

+88
-178
lines changed

3 files changed

+88
-178
lines changed

README.md

Lines changed: 68 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -3,193 +3,113 @@
33
[![Build Status](https://github.com/graphprotocol/graph-node/actions/workflows/ci.yml/badge.svg)](https://github.com/graphprotocol/graph-node/actions/workflows/ci.yml?query=branch%3Amaster)
44
[![Getting Started Docs](https://img.shields.io/badge/docs-getting--started-brightgreen.svg)](docs/getting-started.md)
55

6-
[The Graph](https://thegraph.com/) is a protocol for building decentralized applications (dApps) quickly on Ethereum and IPFS using GraphQL.
6+
[The Graph](https://thegraph.com/) is a protocol that organizes and serves web3 data.
77

8-
Graph Node is an open source Rust implementation that event sources the Ethereum blockchain to deterministically update a data store that can be queried via the GraphQL endpoint.
8+
Graph Node extracts and transforms blockchain data and makes the transformed
9+
data available to decentralized applications (dApps) via GraphQL queries.
10+
You can find more details on how to write these transformations, called
11+
_subgraphs_, in the official [Graph
12+
documentation](https://thegraph.com/docs/en/subgraphs/quick-start/). If you
13+
are not familiar already with subgraphs, we highly recommend at least
14+
reading through that documentation first.
915

10-
For detailed instructions and more context, check out the [Getting Started Guide](docs/getting-started.md).
16+
The rest of this page is geared towards two audiences:
1117

12-
## Quick Start
18+
1. Subgraph developers who want to run `graph-node` locally so they can test
19+
their subgraphs during development
20+
2. Developers who want to contribute bug fixes and features to `graph-node`
21+
itself
22+
23+
## Running `graph-node` from Docker images
24+
25+
For subgraph developers, it is highly recommended to use prebuilt Docker
26+
images to set up a local `graph-node` environment. Please read [these
27+
instructions](./docker/README.md) to learn how to do that.
28+
29+
## Running `graph-node` from source
30+
31+
This is usually only needed for developers who want to contribute to `graph-node`.
1332

1433
### Prerequisites
1534

1635
To build and run this project you need to have the following installed on your system:
1736

1837
- Rust (latest stable) – [How to install Rust](https://www.rust-lang.org/en-US/install.html)
19-
- Note that `rustfmt`, which is part of the default Rust installation, is a build-time requirement.
20-
- PostgreSQL – [PostgreSQL Downloads](https://www.postgresql.org/download/)
38+
has general instructions. Run `rustup install stable` in this directory to make
39+
sure all required components are installed. The `graph-node` code assumes that the
40+
latest available `stable` compiler is used.
41+
- PostgreSQL – [PostgreSQL Downloads](https://www.postgresql.org/download/) lists
42+
downloads for almost all operating systems. For OSX users, we highly recommend
43+
using [Postgres.app](https://postgresapp.com/). Linux users can simply use the
44+
Postgres version that comes with their distribution.
2145
- IPFS – [Installing IPFS](https://docs.ipfs.io/install/)
2246
- Protobuf Compiler - [Installing Protobuf](https://grpc.io/docs/protoc-installation/)
2347

2448
For Ethereum network data, you can either run your own Ethereum node or use an Ethereum node provider of your choice.
2549

26-
**Minimum Hardware Requirements:**
27-
28-
- To build graph-node with `cargo`, 8GB RAM are required.
29-
30-
### Docker
31-
32-
The easiest way to run a Graph Node is to use the official Docker compose setup. This will start a Postgres database, IPFS node, and Graph Node.
33-
[Follow the instructions here](./docker/README.md).
34-
35-
### Running a Local Graph Node
36-
37-
This is a quick example to show a working Graph Node. It is a [subgraph for Gravatars](https://github.com/graphprotocol/example-subgraph).
38-
39-
1. Install IPFS and run `ipfs init` followed by `ipfs daemon`.
40-
2. Install PostgreSQL and run `initdb -D .postgres -E UTF8 --locale=C` followed by `pg_ctl -D .postgres -l logfile start` and `createdb graph-node`.
41-
3. If using Ubuntu, you may need to install additional packages:
42-
- `sudo apt-get install -y clang libpq-dev libssl-dev pkg-config`
43-
4. In the terminal, clone https://github.com/graphprotocol/example-subgraph, and install dependencies and generate types for contract ABIs:
50+
### Create a database
4451

45-
```
46-
yarn
47-
yarn codegen
48-
```
49-
50-
5. In the terminal, clone https://github.com/graphprotocol/graph-node, and run `cargo build`.
51-
52-
Once you have all the dependencies set up, you can run the following:
53-
54-
```
55-
cargo run -p graph-node --release -- \
56-
--postgres-url postgresql://USERNAME[:PASSWORD]@localhost:5432/graph-node \
57-
--ethereum-rpc NETWORK_NAME:[CAPABILITIES]:URL \
58-
--ipfs 127.0.0.1:5001
59-
```
60-
61-
Try your OS username as `USERNAME` and `PASSWORD`. For details on setting
62-
the connection string, check the [Postgres
63-
documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING).
64-
`graph-node` uses a few Postgres extensions. If the Postgres user with which
65-
you run `graph-node` is a superuser, `graph-node` will enable these
66-
extensions when it initializes the database. If the Postgres user is not a
67-
superuser, you will need to create the extensions manually since only
68-
superusers are allowed to do that. To create them you need to connect as a
69-
superuser, which in many installations is the `postgres` user:
52+
Once Postgres is running, you need to issue the following commands to create a database
53+
and set it up so that `graph-node` can use it. The name of the `SUPERUSER` depends
54+
on your installation, but is usually `postgres` or your username.
7055

7156
```bash
72-
psql -q -X -U <SUPERUSER> graph-node <<EOF
57+
psql -U <SUPERUSER> <<EOF
58+
create user graph with password '<password>';
59+
create database "graph-node" with owner=graph template=template0 encoding='UTF8' locale='C';
7360
create extension pg_trgm;
74-
create extension pg_stat_statements;
7561
create extension btree_gist;
7662
create extension postgres_fdw;
77-
grant usage on foreign data wrapper postgres_fdw to <USERNAME>;
63+
grant usage on foreign data wrapper postgres_fdw to graph;
7864
EOF
7965

66+
# Save this in ~/.bashrc or similar
67+
export POSTGRES_URL=postgresql://graph:<password>@localhost:5432/graph-node
8068
```
8169

82-
This will also spin up a GraphiQL interface at `http://127.0.0.1:8000/`.
83-
84-
6. With this Gravatar example, to get the subgraph working locally run:
85-
86-
```
87-
yarn create-local
88-
```
89-
90-
Then you can deploy the subgraph:
70+
With this setup, the URL that you will use to have `graph-node` connect to the
71+
database will be `postgresql://graph:<password>@localhost:5432/graph-node`. If
72+
you ever need to manually inspect the contents of your database, you can do
73+
that by running `psql $POSTGRES_URL`.
9174

92-
```
93-
yarn deploy-local
94-
```
75+
### Build `graph-node`
9576

96-
This will build and deploy the subgraph to the Graph Node. It should start indexing the subgraph immediately.
97-
98-
### Command-Line Interface
77+
To build `graph-node`, clone this repository and run this command at the
78+
root of the repository:
9979

80+
```bash
81+
export GRAPH_LOG=debug
82+
cargo run -p graph-node --release -- \
83+
--postgres-url $POSTGRES_URL \
84+
--ethereum-rpc NETWORK_NAME:[CAPABILITIES]:URL \
85+
--ipfs 127.0.0.1:5001
10086
```
101-
USAGE:
102-
graph-node [FLAGS] [OPTIONS] --ethereum-ipc <NETWORK_NAME:FILE> --ethereum-rpc <NETWORK_NAME:URL> --ethereum-ws <NETWORK_NAME:URL> --ipfs <HOST:PORT> --postgres-url <URL>
103-
104-
FLAGS:
105-
--debug Enable debug logging
106-
-h, --help Prints help information
107-
-V, --version Prints version information
108-
109-
OPTIONS:
110-
--admin-port <PORT> Port for the JSON-RPC admin server [default: 8020]
111-
--elasticsearch-password <PASSWORD>
112-
Password to use for Elasticsearch logging [env: ELASTICSEARCH_PASSWORD]
11387

114-
--elasticsearch-url <URL>
115-
Elasticsearch service to write subgraph logs to [env: ELASTICSEARCH_URL=]
88+
The argument for `--ethereum-rpc` contains a network name (e.g. `mainnet`) and
89+
a list of provider capabilities (e.g. `archive,traces`). The URL is the address
90+
of the Ethereum node you want to connect to, usually a `https` URL, so that the
91+
entire argument might be `mainnet:archive,traces:https://provider.io/some/path`.
11692

117-
--elasticsearch-user <USER> User to use for Elasticsearch logging [env: ELASTICSEARCH_USER=]
118-
--ethereum-ipc <NETWORK_NAME:[CAPABILITIES]:FILE>
119-
Ethereum network name (e.g. 'mainnet'), optional comma-separated capabilities (eg full,archive), and an Ethereum IPC pipe, separated by a ':'
93+
When `graph-node` starts, it prints the various ports that it is listening on.
94+
The most important of these is the GraphQL HTTP server, which is by default
95+
is at `http://localhost:8000`. You can use routes like `/subgraphs/name/<subgraph-name>`
96+
and `/subgraphs/id/<IPFS hash>` to query subgraphs once you have deployed them.
12097

121-
--ethereum-polling-interval <MILLISECONDS>
122-
How often to poll the Ethereum node for new blocks [env: ETHEREUM_POLLING_INTERVAL=] [default: 500]
98+
### Deploying a Subgraph
12399

124-
--ethereum-rpc <NETWORK_NAME:[CAPABILITIES]:URL>
125-
Ethereum network name (e.g. 'mainnet'), optional comma-separated capabilities (eg 'full,archive'), and an Ethereum RPC URL, separated by a ':'
126-
127-
--ethereum-ws <NETWORK_NAME:[CAPABILITIES]:URL>
128-
Ethereum network name (e.g. 'mainnet'), optional comma-separated capabilities (eg `full,archive), and an Ethereum WebSocket URL, separated by a ':'
129-
130-
--node-id <NODE_ID>
131-
A unique identifier for this node instance. Should have the same value between consecutive node restarts [default: default]
132-
133-
--http-port <PORT> Port for the GraphQL HTTP server [default: 8000]
134-
--ipfs <HOST:PORT> HTTP address of an IPFS node
135-
--postgres-url <URL> Location of the Postgres database used for storing entities
136-
--subgraph <[NAME:]IPFS_HASH> Name and IPFS hash of the subgraph manifest
137-
--ws-port <PORT> Port for the GraphQL WebSocket server [default: 8001]
138-
```
100+
Instructions for how to deploy subgraphs can be found [here](https://thegraph.com/docs/en/subgraphs/developing/introduction/) After setting up `graph-cli` as described there, you can deploy a subgraph to your local Graph Node instance.
139101

140102
### Advanced Configuration
141103

142104
The command line arguments generally are all that is needed to run a
143105
`graph-node` instance. For advanced uses, various aspects of `graph-node`
144106
can further be configured through [environment
145-
variables](https://github.com/graphprotocol/graph-node/blob/master/docs/environment-variables.md). Very
146-
large `graph-node` instances can also split the work of querying and
147-
indexing across [multiple databases](./docs/config.md).
148-
149-
## Project Layout
150-
151-
- `node` — A local Graph Node.
152-
- `graph` — A library providing traits for system components and types for
153-
common data.
154-
- `core` — A library providing implementations for core components, used by all
155-
nodes.
156-
- `chain/ethereum` — A library with components for obtaining data from
157-
Ethereum.
158-
- `graphql` — A GraphQL implementation with API schema generation,
159-
introspection, and more.
160-
- `mock` — A library providing mock implementations for all system components.
161-
- `runtime/wasm` — A library for running WASM data-extraction scripts.
162-
- `server/http` — A library providing a GraphQL server over HTTP.
163-
- `store/postgres` — A Postgres store with a GraphQL-friendly interface
164-
and audit logs.
165-
166-
## Roadmap
167-
168-
🔨 = In Progress
169-
170-
🛠 = Feature complete. Additional testing required.
171-
172-
✅ = Feature complete
173-
174-
175-
| Feature | Status |
176-
| ------- | :------: |
177-
| **Ethereum** | |
178-
| Indexing smart contract events ||
179-
| Handle chain reorganizations ||
180-
| **Mappings** | |
181-
| WASM-based mappings||
182-
| TypeScript-to-WASM toolchain ||
183-
| Autogenerated TypeScript types ||
184-
| **GraphQL** | |
185-
| Query entities by ID ||
186-
| Query entity collections ||
187-
| Pagination ||
188-
| Filtering ||
189-
| Block-based Filtering ||
190-
| Entity relationships ||
191-
| Subscriptions ||
107+
variables](https://github.com/graphprotocol/graph-node/blob/master/docs/environment-variables.md).
192108

109+
Very large `graph-node` instances can also be configured using a
110+
[configuration file](./docs/config.md) That is usually only necessary when
111+
the `graph-node` needs to connect to multiple chains or if the work of
112+
indexing and querying needs to be split across [multiple databases](./docs/config.md).
193113

194114
## Contributing
195115

docker/README.md

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
1-
# Graph Node Docker Image
1+
# Running prebuilt `graph-node` images
22

3-
Preconfigured Docker image for running a Graph Node.
4-
5-
## Usage
6-
7-
```sh
8-
docker run -it \
9-
-e postgres_host=<HOST> \
10-
-e postgres_port=<PORT> \
11-
-e postgres_user=<USER> \
12-
-e postgres_pass=<PASSWORD> \
13-
-e postgres_db=<DBNAME> \
14-
-e ipfs=<HOST>:<PORT> \
15-
-e ethereum=<NETWORK_NAME>:<ETHEREUM_RPC_URL> \
16-
graphprotocol/graph-node:latest
17-
```
18-
19-
### Example usage
20-
21-
```sh
22-
docker run -it \
23-
-e postgres_host=host.docker.internal \
24-
-e postgres_port=5432 \
25-
-e postgres_user=graph-node \
26-
-e postgres_pass=oh-hello \
27-
-e postgres_db=graph-node \
28-
-e ipfs=host.docker.internal:5001 \
29-
-e ethereum=mainnet:http://localhost:8545/ \
30-
graphprotocol/graph-node:latest
31-
```
3+
You can run the `graph-node` docker image either in a [complete
4+
setup](#docker-compose) controlled by Docker Compose, or, if you already
5+
have an IPFS and Postgres server, [by
6+
itself](#running-with-existing-ipfs-and-postgres).
327

338
## Docker Compose
349

@@ -77,3 +52,17 @@ docker rmi graphprotocol/graph-node:latest
7752
# Tag the newly created image
7853
docker tag graph-node graphprotocol/graph-node:latest
7954
```
55+
56+
## Running with existing IPFS and Postgres
57+
58+
```sh
59+
docker run -it \
60+
-e postgres_host=<HOST> \
61+
-e postgres_port=<PORT> \
62+
-e postgres_user=<USER> \
63+
-e postgres_pass=<PASSWORD> \
64+
-e postgres_db=<DBNAME> \
65+
-e ipfs=<HOST>:<PORT> \
66+
-e ethereum=<NETWORK_NAME>:<ETHEREUM_RPC_URL> \
67+
graphprotocol/graph-node:latest
68+
```

rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[toolchain]
22
channel = "stable"
33
profile = "default"
4+
components = [ "rustfmt" ]

0 commit comments

Comments
 (0)