docs: update pre-merge info (#25099)

* initial commit for pre-merge prep pages

* tidy and add validator info

* tidy up typos etc

* Apply suggestions from code review

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>

* apply suggestions from review

* apply suggestion from review

updates sentence about Geth stalling w/out consensus client

* apply changes from review + warn about early prep

Removes info as suggested by Martin.
Adds warning suggested by Remy on Launchpad repo about waiting for merge releases before setting up ex/cons clients on mainnet.

* minor fixes

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
pull/25273/head
Joseph Cook 2 years ago committed by GitHub
parent 69424d6bcd
commit 52672ff330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 140
      docs/_interface/consensus-clients.md
  2. 152
      docs/_interface/merge.md
  3. BIN
      static/images/client-architecture.png

@ -0,0 +1,140 @@
---
title: Connecting to Consensus Clients
sort_key: A3
---
Geth is an [execution client][ex-client-link]. Historically, an execution client alone has been enough to run a full Ethereum node.
However, Ethereum will soon swap its consensus mechanism from [proof-of-work][pow-link] (PoW) to
[proof-of-stake][pos-link] (PoS) in a transition known as [The Merge](/docs/interface/merge).
When that happens, Geth will not be able to track the Ethereum chain on its own. Instead, it will need to
be coupled to another piece of software called a ["consensus client"][con-client-link]. For Geth users that
intend to continue to run full nodes after The Merge, it is sensible to start running a consensus client now,
so that The Merge can happen smoothly. There are five consensus clients available, all of which connect to Geth in the same way.
This page will outline how Geth can be set up with a consensus client in advance of The Merge (or to interact with an alread-merged testnet).
{% include note.html content=" It is recommended to practise connecting a consensus client to Geth on a testnet such as Sepolia or Goerli but to
wait until merge-ready releases are available before doing it on Ethereum Mainnet." %}
## Configuring Geth
Geth can be downloaded and installed according to the instructions on the
[Installing Geth](/docs/install-and-build/installing-geth) page. In order to connect to a consensus client,
Geth must expose a port for the inter-client RPC connection.
The RPC connection must be authenticated using a `jwtsecret` file. This is created and saved
to `<datadir>/geth/jwtsecret` by default but can also be created and saved to a custom location or it can be
self-generated and provided to Geth by passing the file path to `--authrpc.jwtsecret`. The `jwtsecret` file
is required by both Geth and the consensus client.
The authorization must then be applied to a specific address/port. This is achievd by passing an address to
`--authrpc.addr` and a port number to `--authrpc.port`. It is also safe to provide either `localhost` or a wildcard
`*` to `--authrpc.vhosts` so that incoming requests from virtual hosts are accepted by Geth because it only
applies to the port authenticated using `jwtsecret`.
The Merge itself will be triggered using a terminal total difficulty (TTD). The specific value for the TTD has not yet
been decided. When it is decided, Geth needs to know what it is in order to merge successfully. This will most likely be
included in a new release, so Geth will have to be stopped, updated and restarted in advance of The Merge.
A complete command to start Geth so that it can connect to a consensus client looks as follows:
```shell
geth --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret /tmp/jwtsecret
```
## Consensus clients
There are currently four consensus clients that can be run alongside Geth. These are:
[Lighthouse](https://lighthouse-book.sigmaprime.io/): written in Rust
[Nimbus](https://nimbus.team/): written in Nim
[Prysm](https://docs.prylabs.network/docs/getting-started/): written in Go
[Teku](https://pegasys.tech/teku): written in Java
It is recommended to consider [client diversity][client-div-link] when choosing a consensus client. Instructions for installing each client are provided in the documentation linked in the list above.
The consensus client must be started with the right port configuration to establish an RPC connection
to the local Geth instance. In the example above, `localhost:8551` was authorized
for this purpose. The consensus clients all have a command similar to `--http-webprovider` that
takes the exposed Geth port as an argument.
The consensus client also needs the path to Geth's `jwt-secret` in order to authenticate the RPC connection between them.
Each consensus client has a command similar to `--jwt-secret` that takes the file path as an argument. This must
be consistent with the `--authrpc.jwtsecret` path provided to Geth.
The consensus clients all expose a [Beacon API][beacon-api-link] that can be used to check the status
of the Beacon client or download blocks and consensus data by sending requests using tools such as [Curl](https://curl.se).
More information on this can be found in the documentation for each consensus client.
## Validators
After The Merge, miners are no longer responsible for securing the Ethereum blockchain. Instead, this becomes the responsibility
of validators that have staked at least 32 ETH into a deposit contract and run validator software. Each of the consensus clients
have their own validator software that is described in detail in their respective documentation. The easiest way to handle
staking and validator key generation is to use the Ethereum Foundation [Staking Launchpad][launchpad-link]. The launchpad is also
available for [Prater][prater-launchpad-link], [Ropsten][ropsten-launchpad-link] and [Kiln][kiln-launchpad-link] testnets. It is
also highly recommended to review the [Merge readiness checklist][checklist-link].
## Using Geth
After the merge, Geth will follow the head of the chain via its connection to the consensus client. However, Geth is still
the portal for users to send transactions to Ethereum. Overall, Geth will not change very much from a user-perspective.
The Geth Javascript console is still available for this purpose, and the majority of the [JSON-RPC API](/docs/rpc/server) will
remain available via web3js or HTTP requests with commands as json payloads. These options are explained in more detail on the
[Javascript Console page](/docs/interface/javascript-console). The Javascript console can be started using the following command
in a separate terminal (assuming Geth's IPC file is saved in `datadir`):
```shell
geth attach datadir/geth.ipc
```
## Testnets
Ethereum Mainnet has not yet undergone The Merge, but some public testnets have. This means that running Geth alone is no longer
enough to interact with merged testnets. This includes two testnets that were purpose built to test The Merge (Kiln, Kintsugi) and
the long-standing public PoW chain, Ropsten, as well as the relatively new testnet Sepolia. If Geth is connected to these merged networks alone it will simply stall when it syncs as far
as the merge block, awaiting information from a consensus client. Therefore, any activity on these testnets requires Geth to be
connected to a consensus client. There are many instructional articles that exlain how to connect to these testnets using Geth in
combination with various consensus clients, for example:
[Connecting to Kiln using Teku](https://github.com/chrishobcroft/TestingTheMerge/blob/main/geku.md)
[Connecting to Kiln using Lighthouse](https://github.com/remyroy/ethstaker/blob/main/merge-devnet.md)
[Connecting to Kiln using Prysm](https://hackmd.io/@prysmaticlabs/B1Q2SluWq)
[Connecting to Ropsten using Lighthouse](https://github.com/remyroy/ethstaker/blob/main/merge-ropsten.md)
The Merge testing will soon progress to merging the Goerli testnet. Once this has happened Geth will require a connection
to a consensus client to work on those networks too.
## Summary
As The Merge approaches it is important for Geth users to prepare by installing and running a consensus client. Otherwise, Geth will stop
following the head of the chain immediately after The Merge. There are five consensus clients to choose from. This page provided an overview
of how to choose a consensus client and configure Geth to connect to it. This pre-emptive action will protect against disruption to users as a
result of The Merge.
[pow-link]:https://ethereum.org/en/developers/docs/consensus-mechanisms/pow
[pos-link]:https://ethereum.org/en/developers/docs/consensus-mechanisms/pos
[con-client-link]:https://ethereum.org/en/glossary/#consensus-client
[ex-client-link]:https://ethereum.org/en/glossary/#execution-client
[beacon-api-link]:https://ethereum.github.io/beacon-APIs
[engine-api-link]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md
[client-div-link]:https://ethereum.org/en/developers/docs/nodes-and-clients/client-diversity
[execution-clients-link]: https://ethereum.org/en/developers/docs/nodes-and-clients/client-diversity/#execution-clients
[launchpad-link]:https://launchpad.ethereum.org/
[prater-launchpad-link]:https://prater.launchpad.ethereum.org/
[kiln-launchpad-link]:https://kiln.launchpad.ethereum.org/
[ropsten-launchpad-link]:https://ropsten.launchpad.ethereum.org/
[e-org-link]: https://ethereum.org/en/developers/docs/nodes-and-clients/run-a-node/
[checklist-link]:https://launchpad.ethereum.org/en/merge-readiness

@ -3,93 +3,91 @@ title: The Merge
sort_key: A2
---
As an Execution-Layer (EL) client, Geth supports the transition of Ethereum from proof-of-work (PoW) to
proof-of-stake (PoS), a.k.a. [The Merge](https://ethereum.org/en/upgrades/merge/).
The Merge is probably the most significant upgrade to Ethereum since Homestead. This page explains what The Merge is
and how it will affect Geth users. Instructions on how to configure an Ethereum node in
anticipation of The Merge are provided on the [Consensus Clients page](/docs/interface/consensus-clients).
### What happens to Geth?
## What is The Merge
The merge changes Ethereum's PoW consensus mechanism to PoS. At the moment of the merge,
Geth switches off its mining algorithm and block gossip functions. Geth's role after the merge is
executing transactions and generating execution payloads using the [EVM](https://ethereum.org/en/developers/docs/evm).
[The Merge](https://ethereum.org/en/upgrades/merge/) is an upcoming upgrade to Ethereum that swaps out its current
proof-of-work (PoW) consensus mechanism for a proof-of-stake (PoS) mechanism. The term "Merge" refers
to the fact that the initial phase of the transition involved launching a PoS chain in parallel with
the existing PoW Ethereum Mainnet. This PoS chain, known as the Beacon Chain, has been executing the PoS
consensus logic since November 2020 but without integrating real Ethereum transaction data. The Merge refers
to the moment when Ethereum's existing blockchain and the Beacon Chain join together to form one unified chain.
At the moment of the merge, execution clients will switch off their proof-of-work and block gossiping functions
and hand responsibility for all consensus and fork choice logic over to consensus clients. This is a profound
change to how Ethereum operates and it will require node operators to run a consensus client in addition to
Geth.
From a user's perspective Geth will not change much at the merge. Responsibility for consensus logic and
block propagation are handed over to the consensus layer, but all of Geth's other functionality remains
intact. This means transactions, contract deployments and data queries can still be handled by Geth using
the same methods as before.
## How will Geth change?
### Transition
Geth is an execution client. Historically, an execution client alone has been enough to run a full Ethereum node.
However, when The Merge happens, Geth will not be able to track the Ethereum chain on its own. Instead, it will need to
be coupled to another piece of software called a ["consensus client"][con-client-link]. In this configuration,
the execution client will be responsible for transaction handling, transaction gossip, state management and
the Ethereum Virtual Machine (EVM). However, Geth will no longer be responsible for block building, block
gossiping or handling consensus logic. These will be in the remit of the consensus client.
The transition from PoW to PoS will happen when a pre-announced total difficulty is reached by the chain.
This is unlike usual forks which occur at a certain scheduled block number.
The total difficulty threshold that triggers the Merge is also known as the [*Terminal
Total Difficulty* (TTD)](https://ethereum.org/en/glossary/#terminal-total-difficulty). In
case of an emergency delay, the TTD can be overriden using the `--override.terminaltotaldifficulty` command-line
flag.
#### Ropsten Transition
In advance of the Mainnet merge, several public testnets will transition from PoW to PoS.
The first public testnet to merge will be Ropsten. As the Ropsten merge approaches, Geth
users will need to prepare to ensure a smooth transition.
{% include note.html content="The merge event did not go smoothly on Ropsten. However, if you are running Geth v1.10.19 or later, no action is required. If you are running Geth v1.10.18 or earlier, you should use `--override.terminaltotaldifficulty 50000000000000000` when launching Geth for Ropsten." %}
### Consensus client
After the merge, Geth will no longer be able to follow the head of the chain unless it is connected to a second
piece of software known as a ["consensus client"](https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients)
which handles all of Ethereum's consensus logic.
The consensus client communicates with Geth using the `engine` API over a local RPC connection. The consensus client
is responsible for gossiping blocks, block proposal, attestation and fork choice.
Geth must be connected to a consensus client in advance of the merge so that the two pieces of software can get in sync and
transition smoothly by coordinating together. There are several choices of [consensus client implementations][cl-list].
For Geth users that intend to continue to run full nodes after The Merge, it is sensible to start running
a consensus client in advance, so that The Merge can happen smoothly. There are five consensus clients available, all
of which connect to Geth in the same way. Instructions for this are available on the
[Consensus Clients page](/docs/interface/consensus-clients).
Note that CL clients are equipped with two modes. One for following the beacon chain (Beacon node), and another mode
used for validators. **It is NOT required to run a validator or stake 32 ETH in order to follow the chain!**
### EL - CL communication
## Client architecture
ELs and CLs communicate using a [JSON-RPC API][engineapi] under the namespace `engine` which is exposed by Geth.
The relationship between the two Ethereum clients is shown in the schematic below. The two clients each connect
to their own respective peer-to-peer (P2P) networks. This is because the execution clients gossip transactions over
their P2P network enabling them to manage their local mempool. The consensus clients gossip blocks over their P2P
network, enabling consensus and chain growth.
The `engine` API is authenticated via [JWT](https://jwt.io). If a TTD is set for the given network, as is the
case for Ropsten, Geth will:
![Client schematic](/static/images/client-architecture.png)
- Generate a JWT secret under the path `<datadir>/geth/jwtsecret`. This secret is needed
both by Geth and the CL client.
For this two-client structure to work, consensus clients must be able to pass bundles of transactions to Geth
to be executed. Executing the transactions locally is how the client validates that the transactions do not
violate any Ethereum rules and that the proposed update to Ethereum's state is correct. Likewise, when the node
is selected to be a block producer the consensus client must be able to request bundles of transactions from Geth to
include in the new block. This inter-client communication is handled by a local RPC connection using the
[`engine` API][engine-api-link] which is part of the JSON-RPC API exposed by Geth.
- Open HTTP and WS endpoints on the authenticated port 8551.
## Transition
This is what it looks like by default:
```shell
geth --ropsten --datadir ~/.ropsten --override.terminaltotaldifficulty 50000000000000000
```
```terminal
INFO [05-25|11:04:41.179] Starting Geth on Ropsten testnet...
...
WARN [05-25|11:04:41.520] Catalyst mode enabled protocol=eth
INFO [05-25|11:04:41.627] Generated JWT secret path=/home/user/.ropsten/geth/jwtsecret
INFO [05-25|11:04:41.628] WebSocket enabled url=ws://127.0.0.1:8551
INFO [05-25|11:04:41.628] HTTP server started endpoint=127.0.0.1:8551 auth=true prefix= cors=localhost vhosts=localhost
```
### Engine API Authentication
The listening address of the engine API is configurable. It is also possible to self-generate the JWT secret and feed the resulting file to Geth. To generate the secret, run:
```shell
openssl rand -hex 32 | tr -d "\n" > "/tmp/jwtsecret"
```
Now configure authentication using Geth flags:
```shell
geth --ropsten --datadir ~/.ropsten --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret /tmp/jwtsecret --override.terminaltotaldifficulty 50000000000000000
```
[engineapi]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md
The transition from PoW to PoS will happen when a pre-announced total difficulty is reached by the chain.
This is different to other forks which usually occur at a certain scheduled block number. The total difficulty threshold
that will trigger the Merge is also known as the [*Terminal
Total Difficulty* (TTD)](https://ethereum.org/en/glossary/#terminal-total-difficulty). In
case of an emergency delay, the TTD can be overriden in Geth using the `--override.terminaltotaldifficulty` command-line
flag. Once the merge block exists, Geth will no longer be able to follow the head of the chain without a consensus
client. If Geth is not connected to a consensus client it will simply stall at the merge block.
Assuming a consensus client is connected in advance, the two clients will automatically
handle the merge together with no disruption to the user.
## Using Geth after The Merge
Although The Merge is a profound change to Ethereum's underlying achitecture, there will be minimal changes to how Geth
users interact with Ethereum. At The Merge responsibility for consensus logic and block propagation are handed over to
the consensus layer, but all of Geth’s other functionality remains intact. This means transactions, contract deployments
and data queries can still be handled by Geth using the same methods as before. This includes interacting with Geth using
the JSON_RPC_API directly using tools such as [curl](https//curl.se), third party libraries such as
[Web3.js][web3js-link] or [Web3.py][web3py-link] in development frameworks, e.g. [Truffle][truffle-link], [Hardhat][hardhat-link],
[Brownie][brownie-link], [Foundry][foundry-link] or using Web3.js in Geth's built-in Javascript console.
Much more information about the Javascript console is available on the [Javascript Console page](/docs/interface/javascript-console).
## Summary
The Merge is an upcoming upgrade to Ethereum that swaps the existing PoW consensus mechanism for a PoS consensus
mechanism. This changes the client software organization for Ethereum nodes. After The Merge, nodes are required to
run both execution and consensus clients that each have responsibility for specific parts of the Ethereum protocol
and communicate with each other over a local RPC connection. Although there is some necessary configuration in advance
of The Merge, the experience for Geth users should change minimally as a result of The Merge.
[engine-api-link]: https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md
[cl-list]: https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients
[web3py-link]: https://web3py.readthedocs.io/en/stable/web3.main.html
[web3js-link]: https://web3js.readthedocs.io/en/v1.2.9/
[brownie-link]: https://eth-brownie.readthedocs.io/en/stable/
[truffle-link]: https://trufflesuite.com/
[hardhat-link]: https://hardhat.org/
[foundry-link]: https://github.com/foundry-rs/foundry)
[con-client-link]:https://ethereum.org/en/glossary/#consensus-client

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Loading…
Cancel
Save