Skip to content

Commit e05e656

Browse files
committed
streamline docs
1 parent ae225cd commit e05e656

File tree

1 file changed

+105
-154
lines changed

1 file changed

+105
-154
lines changed
Lines changed: 105 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
# Blockchain nodes
1+
# Blockchain Nodes
22

3-
It is highly advised that if you did decide to play around with these Docker containers that you use an existing Ethereum enviroment builder
4-
instead of trying to put all the pieces together. That's especially important for Proof-Of-Stake networks, where the setup is a multi-stage
5-
operation that needs to be executed in specific order and where multiple containers need access to the same (or shared) state.
3+
If you plan to experiment with these Docker containers, **use an existing Ethereum environment builder** rather than assembling components manually. This is particularly important for Proof-of-Stake (PoS) networks, where the setup involves multi-stage operations and shared state across multiple containers.
64

7-
By default, each of supported clients has a default image version that's defined [here](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/lib/docker/ethereum/images.go).
8-
All of them apart from Reth, come in two flavours: one that is a Proof-Of-Stake (Ethereum 2.0) network and another that's a Proof-Of-Work/Authority (Ethereum 1.0). Reth has only the former
9-
since the latter was never implemented by its creators.
5+
Each supported client has a default image version defined [here](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/lib/docker/ethereum/images.go). Clients (except Reth) are available in two flavors:
6+
- **Proof-of-Stake (PoS)**: Ethereum 2.0.
7+
- **Proof-of-Work/Authority (PoW/PoA)**: Ethereum 1.0.
108

11-
All of these epehemeral networks are using a grossly simplified configuration that is composed of a single blockchain node. Technically that's also true, in case of PoS networks,
12-
even though they are running three containers:
13-
* execution layer container
14-
* consensus layer container
15-
* validator
9+
Reth supports only PoS networks.
10+
11+
These ephemeral networks use a simplified configuration with a single blockchain node. For PoS, three containers simulate this:
12+
- Execution layer
13+
- Consensus layer
14+
- Validator
1615

1716
> [!NOTE]
18-
> We use our own fork of [Ethereum Genesis Generator](https://github.com/ethpandaops/ethereum-genesis-generator) to
19-
> create genesis files both for PoW/PoA and PoS Ethereum networks.
20-
21-
## Execution Layer
22-
Following execution layers are available
23-
* Besu
24-
* Erigon
25-
* Geth
26-
* Nethermind
27-
* Reth
28-
29-
## Consensus Layer
30-
Only one consensus client is available: Prysm.
31-
32-
# Quick start
33-
The simplest of starting a new Ethereum network is by specifying only the execution layer:
17+
> We use a fork of [Ethereum Genesis Generator](https://github.com/ethpandaops/ethereum-genesis-generator) to create genesis files for PoS networks.
18+
19+
---
20+
21+
## Execution Layer Clients
22+
The following execution layer clients are available:
23+
- Besu
24+
- Erigon
25+
- Geth
26+
- Nethermind
27+
- Reth
28+
29+
## Consensus Layer Client
30+
- **Prysm** (the only available consensus client).
31+
32+
---
33+
34+
# Quick Start
35+
36+
The simplest way to start an Ethereum network is by specifying the execution layer only:
37+
3438
```go
3539
builder := NewEthereumNetworkBuilder()
3640
cfg, err := builder.
@@ -45,15 +49,14 @@ if err != nil {
4549
panic(err)
4650
}
4751
```
52+
If no version is specified, **Ethereum 1.0 (pre-Merge)** will be used.
4853

49-
If no Ethereum version is specified, Ethereum 1.0 (pre-Merge) will be used.
54+
### Starting Ethereum 2.0 Networks
55+
To start an Ethereum 2.0 network, add the Ethereum version parameter:
5056

51-
# Ethereum 2 network
52-
To start Ethereum 2.0 network you need to pass one more parameter to the builder:
5357
```go
5458
builder := NewEthereumNetworkBuilder()
5559
cfg, err := builder.
56-
// notice the new parameter
5760
WithEthereumVersion(config_types.EthereumVersion_Eth2).
5861
WithExecutionLayer(config_types.ExecutionLayer_Geth).
5962
Build()
@@ -66,14 +69,14 @@ if err != nil {
6669
panic(err)
6770
}
6871
```
69-
7072
> [!NOTE]
71-
> It takes significantly longer to boot up an Ethereum 2.0 network due to number of
72-
> containers involved. 1 minute long wait times are not unheard of, so if startup
73-
> speed is crucial think if Ethereum 1.0 is good enough for your use case.
73+
> Booting Ethereum 2.0 networks takes longer due to the additional containers. Wait times of up to 1 minute are common.
74+
75+
---
76+
77+
## Custom Docker Images
78+
To use custom Docker images instead of the defaults:
7479

75-
# Custom docker images
76-
If you don't want to use default image versions you can pass custom ones in the following manner:
7780
```go
7881
builder := NewEthereumNetworkBuilder()
7982
cfg, err := builder.
@@ -90,73 +93,47 @@ if err != nil {
9093
panic(err)
9194
}
9295
```
93-
Where available container types are:
96+
### Available Container Types
9497
```go
9598
const (
96-
ContainerType_ExecutionLayer ContainerType = "execution_layer"
97-
ContainerType_ConsensusLayer ContainerType = "consensus_layer"
98-
ContainerType_ConsensusValidator ContainerType = "consensus_validator"
99-
ContainerType_GenesisGenerator ContainerType = "genesis_generator"
100-
ContainerType_ValKeysGenerator ContainerType = "val_keys_generator"
99+
ContainerType_ExecutionLayer ContainerType = "execution_layer"
100+
ContainerType_ConsensusLayer ContainerType = "consensus_layer"
101+
ContainerType_ConsensusValidator ContainerType = "consensus_validator"
102+
ContainerType_GenesisGenerator ContainerType = "genesis_generator"
103+
ContainerType_ValKeysGenerator ContainerType = "val_keys_generator"
101104
)
102105
```
103-
When passing custom docker image for execution layer you don't need to use neither `WithEthereumVersion()` nor `WithExecutionLayer()` functions
104-
as we will get these from the Docker image.
105-
106106
> [!NOTE]
107-
> There are two useful "synthetic" Docker tags you can use with custom images:
108-
> - `latest_available` - which represents the latest release (including pre-releases)
109-
> - `latest_stable` - which represents latest **stable** release
107+
> Use the `latest_available` tag for the most recent release, including pre-releases, or the `latest_stable` tag for the latest officially stable release. The `latest_available` may include beta or development versions, whereas `latest_stable` ensures compatibility with production environments.
108+
109+
---
110+
111+
# Advanced Options
112+
113+
## Connect to Existing Docker Networks
114+
By default, a new random Docker network is created. To use an existing one:
110115

111-
# Existing Docker network(s)
112-
By default, the chain will be started on a new Docker network with random name. If you want it to connect to existing one instead, use the following option:
113116
```go
114117
builder := NewEthereumNetworkBuilder()
115118
cfg, err := builder.
116119
WithExecutionLayer(types.ExecutionLayer_Nethermind).
117120
WithDockerNetworks([]string{"my-existing-network"}).
118121
Build()
119-
if err != nil {
120-
panic(err)
121-
}
122122
```
123123

124-
# Chain customisation
125-
Below you will find a description of easily customisable parameters of the chain or its startup.
126-
127-
## Slots per epoch and seconds per slot (Ethereum 2.0 only)
128-
These parameters control how fast epochs progress.
129-
130-
`Seconds per slot` represents the number of seconds that validator have to vote on blocks.
131-
The lower the value the faster the epoch finalisation. If it's too low, validators will not be
132-
able to vote and no new blocks will be produced. Minimum allowed value is `3`.
133-
134-
`Slots per epoch` represent the number of voting runds per epoch. The lower the number, the faster
135-
the finalization. Minimum allowed value is `2.`
136-
137-
## ChainID
138-
Can be anything as long as it's an integer.
139-
140-
## Addresses to fund
141-
Addresses that will be funded with `9000000000000000000000000000 wei` in the genesis.
124+
## Chain Customization
142125

143-
## Hard Forks (Ethereum 2.0 only)
144-
Map of hard fork name to epoch, in which the fork should happen. Has to be `> 0`. It's useful for testing
145-
how software will behave during the fork. Currently, the only fork that's supported is `Deneb`, but it can
146-
only be used with Docker images that belong to "pre-Deneb times" and running on `Shanghai` version of Ethereum 2.0
147-
(so pretty old versions). For the latest images there are no supported future forks as of time of this documentation
148-
creation there were no dates set for any of the incoming forks (which means none of them is supported by neither
149-
execution nor consensus layer clients).
126+
### Ethereum 2.0 Parameters
127+
- **Seconds per slot**: This defines how many seconds validators have to propose and vote on blocks. Lower values accelerate block production and epoch finalization but can cause issues if validators fail to keep up. The minimum allowed value is `3`.
128+
- **Slots per epoch**: Determines the number of slots (voting rounds) per epoch. Lower values mean epochs finalize faster, but fewer voting rounds can impact network stability. The minimum value is `2`.
129+
- **Genesis delay**: The extra delay (in seconds) before the genesis block starts. This ensures all containers (execution, consensus, and validator) are up and running before block production begins.
130+
- **Validator count**: Specifies the number of validators in the network. A higher count increases the robustness of block validation but requires more resources. The minimum allowed value is `4`.
150131

151-
## Validator count (Ethereum 2.0 only)
152-
Number of validators to run. `4` is a minimum allowed.
132+
### General Parameters
133+
- **ChainID**: Integer value for the chain.
134+
- **Addresses to fund**: Pre-fund accounts in the genesis block.
153135

154-
## Genesis Delay (Ethereum 2.0 only)
155-
Extra delay added to genesis block timestamp to be sure that both layers are up and running before it happens. Increasing it could be
156-
useful in case of running on very slow system.
157-
158-
## Default values
159-
Default chain config comes with the following values:
136+
### Default Configuration
160137
```toml
161138
seconds_per_slot=12
162139
slots_per_epoch=6
@@ -166,86 +143,60 @@ chain_id=1337
166143
addresses_to_fund=["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]
167144
```
168145

169-
# Other useful options
170-
## Blockchain node log level
171-
By default, all blockchain nodes use `info` log level, but you can change that with the following option:
146+
---
147+
148+
## Log Level
149+
Customize node log levels (default: `info`):
172150
```go
173-
builder := NewEthereumNetworkBuilder()
174-
cfg, err := builder.
175-
WithCustomDockerImages(map[config.ContainerType]string{
176-
config.ContainerType_ExecutionLayer: "ethereum/client-go:v1.15.0",
177-
}).
178-
WithNodeLogLevel("debug").
179-
Build()
180-
if err != nil {
181-
panic(err)
182-
}
151+
WithNodeLogLevel("debug")
183152
```
184-
This configuration is applied only to execution layer nodes. Following values are supported:
185-
* `trace`
186-
* `debug`
187-
* `info`
188-
* `warn`
189-
* `error`
190-
191-
## Waiting for first epoch finalization (Ethereum 2.0 only)
192-
In case you want the network to wait until first epoch has been finalised you can use the following option:
153+
Supported values:
154+
- `trace`, `debug`, `info`, `warn`, `error`
155+
156+
## Wait for Finalization (Ethereum 2.0)
157+
Wait until the first epoch finalizes:
193158
```go
194-
builder := NewEthereumNetworkBuilder()
195-
cfg, err := builder.
196-
WithCustomDockerImages(map[config.ContainerType]string{
197-
config.ContainerType_ExecutionLayer: "ethereum/client-go:v1.15.0",
198-
}).
199-
WithWaitingForFinalization().
200-
Build()
201-
if err != nil {
202-
panic(err)
203-
}
159+
WithWaitingForFinalization()
204160
```
205161

206-
# Accessing containers from inside and outside of the Docker network
207-
Function that starts the environment returns an error or two values:
208-
* instance of `blockchain.Network` that can be used to start our test clients
209-
* instance of `test_env.RpcProvider` that has a list of useful endpoints
162+
---
210163

211-
These endpoints come in two flavours:
212-
* public (accessible from other Docker networks and the host machine)
213-
* private (accessible only from inside the same Docker network)
164+
# Accessing Containers
165+
The `builder.Start()` function returns:
166+
1. **Network configuration**: Input to test clients.
167+
2. **RPC endpoints**:
168+
- **Public**: Accessible externally.
169+
- **Private**: Internal to the Docker network.
214170

215-
And are the HTTP and WS endpoints of the execution layer clients, ones which the Chainlink Node
216-
needs to communicate with. Beacon Chain (consensus layer) endpoints are not exposed.
171+
### Endpoint Usage
172+
- Use **public endpoints** for Ethereum clients deploying contracts, interacting with the chain, etc.
173+
- Use **private endpoints** for Chainlink nodes within the same Docker network.
217174

218-
If you're wondering which one to use, the usual case would be:
219-
* public for the Ethereum Client that will interact with the chain, deploy contracts, etc.
220-
* private for the Chainlink Node if it uses the same Docker network as the chain, public otherwise
175+
---
221176

222-
# Ethereum 2.0 container creation sequence
223-
Since the sequence of container creation and interaction for Ethereum 2.0 is much more complicated
224-
than for Ethereum 1.0 (where we only need to start a single container) below you will find a sequence
225-
diagram that explains it in more detail:
177+
# Ethereum 2.0 Container Creation Sequence
178+
The following sequence explains Ethereum 2.0 container startup:
226179

227180
```mermaid
228-
---
229-
title: Ethereum 2.0 container creation sequence
230-
---
231181
sequenceDiagram
232-
participant Host Machine
233-
participant Validators Keys Generator
182+
participant Host
183+
participant Validator Keys Generator
234184
participant Genesis Generator
235-
participant Execution Layer (e.g. Besu or Geth)
236-
participant Consensus Layer (Prysm Beacon Chain)
237-
participant Consensus Layer (Prysm Validator)
185+
participant Execution Layer
186+
participant Beacon Chain (Consensus Layer)
187+
participant Validator
238188
participant After Genesis Helper
239189
participant User
240-
Validators Keys Generator->>Host Machine: Generate new validators keys<br/> and save them to on the host
241-
Genesis Generator->>Host Machine: Generate Ethereum 1.0 and Ethereum 2.0 genesis files<br/> and save them on the host
242-
Host Machine->>Execution Layer (e.g. Besu or Geth): Read Ehtereum 1.0 genesis and start
243-
Host Machine->>Consensus Layer (Prysm Beacon Chain): Read Ehtereum 2.0 genesis and start
244-
Consensus Layer (Prysm Beacon Chain)->>Execution Layer (e.g. Besu or Geth): Conntect and start<br/> following the chain
245-
Host Machine->>Consensus Layer (Prysm Validator): Read validator keys and start
246-
Consensus Layer (Prysm Validator)->>Consensus Layer (Prysm Beacon Chain): Connect and start voting on blocks
247-
loop observe chain
248-
After Genesis Helper->>Execution Layer (e.g. Besu or Geth): Wait until new blocks are produced
190+
191+
Validator Keys Generator->>Host: Generate validator keys
192+
Genesis Generator->>Host: Create genesis files
193+
Host->>Execution Layer: Start with genesis
194+
Host->>Beacon Chain (Consensus Layer): Start with genesis
195+
Beacon Chain (Consensus Layer)->>Execution Layer: Connect and sync
196+
Host->>Validator: Start with validator keys
197+
Validator->>Beacon Chain (Consensus Layer): Begin block voting
198+
loop new blocks
199+
After Genesis Helper->>Execution Layer: Monitor new blocks
249200
end
250-
After Genesis Helper->>User: Allow to proceed<br/> and interact with the chain
201+
After Genesis Helper->>User: Ready to interact
251202
```

0 commit comments

Comments
 (0)