docs: rework book (#2566)

This commit is contained in:
Georgios Konstantopoulos
2023-05-04 20:28:33 -07:00
committed by GitHub
parent 70bcd76032
commit 52f2bc5ebc
32 changed files with 537 additions and 251 deletions

62
book/run/mainnet.md Normal file
View File

@ -0,0 +1,62 @@
# Running Reth on Ethereum Mainnet or testnets
Reth is an [_execution client_](https://ethereum.org/en/developers/docs/nodes-and-clients/#execution-clients). After Ethereum's transition to Proof of Stake (aka the Merge) it became required to run a [_consensus client_](https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients) along your execution client in order to sync into any "post-Merge" network. This is because the Ethereum execution layer now outsources consensus to a separate component, known as the consensus client.
There are multiple choices of consensus clients, but in this guide we will assume usage of Lighthouse 🦀.
## Running the Reth Node
First, ensure that you have Reth installed by following the [installation instructions][installation].
Now, start the node as follows:
```bash
RUST_LOG=info reth node
```
> Note that this command will not open any HTTP/WS ports by default. You can change this by adding the `--http`, `--ws` flags, respectively and using the `--http.api` and `--ws.api` flags to enable various [JSON-RPC APIs](../api/api.md). For more commands, see the [`reth node` CLI reference](../cli/node.md).
The EL <> CL communication happens over the [Engine API](https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md), which is by default exposed at `http://localhost:8551`. The connection is authenticated over JWT using a JWT secret which is auto-generated by Reth under `~/.local/share/reth/mainnet/jwt.hex` in Linux (`/Users/<NAME>/Library/Application Support/reth/mainnet/jwt.hex` in Mac).
You can override this path using the `--authrpc.jwtsecret` option. You MUST use the same JWT secret in BOTH Reth and the chosen Consensus Layer. If you want to override the address or port, you can use the `--authrpc.addr` and `--authrpc.port` options, respectively.
So one might do:
```bash
RUST_LOG=info reth node \
--authrpc.jwtsecret /path/to/secret \
--authrpc.addr 127.0.0.1 \
--authrpc.port 9999
```
At this point, our Reth node has started discovery, and even discovered some new peers. But it will not start syncing until you spin up the consensus layer!
## Running the Consensus Layer
First, make sure you have Lighthouse installed. Sigma Prime provides excellent [installation](https://lighthouse-book.sigmaprime.io/installation.html) and [node operation](https://lighthouse-book.sigmaprime.io/run_a_node.html) instructions.
Assuming you have done that, run:
```bash
RUST_LOG=info lighthouse bn \
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
--execution-endpoint http://localhost:8551 \
--execution-jwt ~/.local/share/reth/jwtsecret/jwt.hex
```
Your Reth node should start receiving "fork choice updated" messages, and begin syncing the chain.
## Verify the chain is growing
You can easily verify that by inspecting the logs, and seeing that headers are arriving in Reth. Sit back now and wait for the stages to run!
In the meantime, consider setting up [observability](./observability.md) to monitor your node's health or [test the JSON RPC API](../api/api.md).
<!-- TODO: Add more logs to help node operators debug any weird CL to EL messages! -->
[installation]: ./../installation//installation.md
[docs]: https://github.com/paradigmxyz/reth/tree/main/docs
[metrics]: https://github.com/paradigmxyz/reth/blob/main/docs/design/metrics.md#current-metrics
## Running without a Consensus Layer
We provide a method for running Reth without a Consensus Layer via the `--debug.tip <HASH>` parameter. If you provide that to your node, it will simulate sending a `engine_forkChoiceUpdated` message _once_ and will trigger syncing to the provided block hash. This is useful for testing and debugging purposes, but in order to have a node that can keep up with the tip you'll need to run a CL alongside it. At the moment we have no plans of including a Consensus Layer implementation in Reth, and we are open to including light clients other methods of syncing like importing Lighthouse as a library.