2021-08-09 14:10:58 +00:00
# Fluffy: The Nimbus Portal Network Client
2021-06-17 15:05:00 +00:00
2023-01-02 15:37:22 +00:00
[![Fluffy CI ](https://github.com/status-im/nimbus-eth1/actions/workflows/fluffy.yml/badge.svg )](https://github.com/status-im/nimbus-eth1/actions/workflows/fluffy.yml)
2021-06-17 15:05:00 +00:00
![Stability: experimental ](https://img.shields.io/badge/stability-experimental-orange.svg )
[![License: Apache ](https://img.shields.io/badge/license-Apache%202.0-blue.svg )](https://opensource.org/licenses/Apache-2.0)
[![License: MIT ](https://img.shields.io/badge/license-MIT-blue.svg )](https://opensource.org/licenses/MIT)
[![Discord: Nimbus ](https://img.shields.io/badge/Discord-Nimbus-blue.svg )](https://discord.gg/XRxWahP)
[![Status: #nimbus-general ](https://img.shields.io/badge/Status-nimbus--general-blue.svg )](https://join.status.im/nimbus-general)
## Introduction
This folder holds the development of the Nimbus client implementation supporting
2023-01-02 15:37:22 +00:00
the Portal Network: Fluffy. The Portal Network is a project still heavily in
2021-08-09 14:10:58 +00:00
research phase and fully in flux. This client is thus still highly experimental.
2021-06-17 15:05:00 +00:00
Current status of specifications can be found in the
2021-09-24 15:18:54 +00:00
[portal-network-specs repository ](https://github.com/ethereum/portal-network-specs/blob/master/portal-network.md ).
2021-06-17 15:05:00 +00:00
## Development Updates
2021-12-13 13:12:51 +00:00
Monthly development updates are shared
[here ](https://hackmd.io/jRpxY4WBQJ-hnsKaPDYqTw ).
2023-01-09 16:57:55 +00:00
To keep up to date with changes and development progress, follow the
[Nimbus blog ](https://our.status.im/tag/nimbus/ ).
2021-06-17 15:05:00 +00:00
## How to Build & Run
### Prerequisites
- GNU Make, Bash and the usual POSIX utilities. Git 2.9.4 or newer.
2023-01-02 15:37:22 +00:00
### Build the Fluffy client
2021-06-17 15:05:00 +00:00
```bash
git clone git@github.com:status-im/nimbus-eth1.git
cd nimbus-eth1
2021-06-28 15:53:13 +00:00
make fluffy
2021-06-17 15:05:00 +00:00
# See available command line options
2021-06-28 15:53:13 +00:00
./build/fluffy --help
2021-06-17 15:05:00 +00:00
2021-12-13 13:12:51 +00:00
# Example command: Run the client and connect to a bootstrap node.
./build/fluffy --bootstrap-node:enr:< base64 encoding of ENR >
2021-06-17 15:05:00 +00:00
```
2023-01-02 15:37:22 +00:00
### Update and rebuild the Fluffy client
2021-06-17 15:05:00 +00:00
```bash
# From the nimbus-eth1 repository
git pull
# To bring the git submodules up to date
make update
2021-06-28 15:53:13 +00:00
make fluffy
2021-06-17 15:05:00 +00:00
```
2023-01-02 15:37:22 +00:00
### Run a Fluffy client on the public testnet
2022-03-17 21:41:43 +00:00
```bash
2023-06-28 21:53:27 +00:00
# Connect to the Portal testnet bootstrap nodes and enable the JSON-RPC APIs
./build/fluffy --rpc --table-ip-limit:1024 --bucket-ip-limit:24
2022-03-17 21:41:43 +00:00
```
2023-01-02 15:37:22 +00:00
The `table-ip-limit` and `bucket-ip-limit` options are needed to allow more
nodes with the same IPs in the routing tables. The default limits are there
as security measure. It is currently needed to increase the limits for the testnet
because the fleet of Fluffy nodes runs on only 2 machines / network interfaces.
2023-06-28 21:53:27 +00:00
There is a public [Portal testnet ](https://github.com/ethereum/portal-network-specs/blob/master/testnet.md#portal-network-testnet )
which contains nodes of different clients.
Fluffy will default join the network through these bootstrap nodes.
You can also explicitly provide the `--network:testnet0` option to join this
network, or `--network:none` to not connect to any of these bootstrapn odes.
2023-01-02 15:37:22 +00:00
> **_Note:_** The `--network` option selects automatically a static set of
2022-03-17 21:41:43 +00:00
specific bootstrap nodes belonging to a "testnet". Currently `testnet0` is the
2022-04-13 05:56:01 +00:00
only option, which results in connecting to the
[testnet bootstrap nodes ](https://github.com/ethereum/portal-network-specs/blob/master/testnet.md#bootnodes ).
2023-01-02 15:37:22 +00:00
It should be noted that there is currently no real way to distinguish a "specific" Portal
2022-03-17 21:41:43 +00:00
network, and as long as the same Portal protocols are supported, nodes can
simply connect to it and no real separation can be made.
2023-10-02 08:24:03 +00:00
When testing locally the `--network:none` option can be provided to avoid
connecting to any of the testnet bootstrap nodes.
2022-03-17 21:41:43 +00:00
2023-01-09 16:57:55 +00:00
<!-- TODO: Update this once we have the headersWithProof type merged and data on the network -->
2023-10-02 08:24:03 +00:00
The Portal testnet is slowly being filled up with historical data through bridge nodes.
Because of this, more recent history data is more likely to be available.. This can
2023-01-02 15:37:22 +00:00
be tested by using the JSON-RPC call `eth_getBlockByHash` :
2022-03-17 21:41:43 +00:00
```
# Get the hash of a block from your favorite block explorer, e.g.:
2023-10-02 08:24:03 +00:00
BLOCKHASH=0x34eea44911b19f9aa8c72f69bdcbda3ed933b11a940511b6f3f58a87427231fb # Replace this to the block hash of your choice
# Run this command to get this block:
curl -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"eth_getBlockByHash","params":["'${BLOCKHASH}'", true]}' http://localhost:8545 | jq
2022-03-17 21:41:43 +00:00
```
2022-04-13 05:56:01 +00:00
One can also use the `blockwalk` tool to walk down the blocks one by one, e.g:
```bash
2023-10-02 08:24:03 +00:00
make blockwalk
2022-04-13 05:56:01 +00:00
2023-10-02 08:24:03 +00:00
BLOCKHASH=0x34eea44911b19f9aa8c72f69bdcbda3ed933b11a940511b6f3f58a87427231fb # Replace this to the block hash of your choice
./build/blockwalk --block-hash:${BLOCKHASH}
2022-04-13 05:56:01 +00:00
```
2023-01-02 15:37:22 +00:00
### Run Fluffy test suite
2022-04-13 05:56:01 +00:00
```bash
# From the nimbus-eth1 repository
make fluffy-test
```
2022-03-17 21:41:43 +00:00
2023-01-02 15:37:22 +00:00
### Run Fluffy local testnet script
2021-12-13 13:12:51 +00:00
```bash
./fluffy/scripts/launch_local_testnet.sh
```
2022-02-11 13:43:10 +00:00
Find more details on the usage and workings of the local testnet script
[here ](./docs/local_testnet.md ).
2023-01-09 16:57:55 +00:00
### Windows support
2022-06-23 12:14:31 +00:00
2023-01-09 16:57:55 +00:00
Follow the steps outlined [here ](../README.md#windows ) to build fluffy on Windows.
2022-06-23 12:14:31 +00:00
2023-01-09 16:57:55 +00:00
## Development tools and documentation
2022-06-23 12:14:31 +00:00
2023-07-10 17:35:28 +00:00
The fluffy directory also holds several tools to help development of the Portal
networks.
Command to build the tools:
```bash
make fluffy-tools -j6
```
Additional documention on the tools or on what you can use them for:
- [eth_data_exporter ](./docs/eth_data_exporter.md ): tool to extract content from
EL or CL and prepare it as Portal content and content keys.
2023-01-09 16:57:55 +00:00
- [Content seeding ](./docs/content_seeding.md ): Documentation on how to retrieve & generate history data and how to seed it into the network
- [Manual protocol interop testing ](./docs/protocol_interop.md ): commands on how to manually test the discv5 and Portal protocol request and responses
- [Local testnet script ](./docs/local_testnet.md ): Documentation on the local testnet script and how to use it
2022-06-23 12:14:31 +00:00
2023-01-09 16:57:55 +00:00
## The basics for developers
2022-06-23 12:14:31 +00:00
2023-01-09 16:57:55 +00:00
When working on this repository, you can run the `env.sh` script to run a
command with the right environment variables set. This means the vendored
Nim and Nim modules will be used, just as when you use `make` .
E.g.:
2022-06-23 12:14:31 +00:00
2023-01-09 16:57:55 +00:00
```bash
# start a new interactive shell with the right env vars set
./env.sh bash
2022-06-23 12:14:31 +00:00
```
2023-01-09 16:57:55 +00:00
More [development tips ](../README.md#devel-tips )
can be found on the general nimbus-eth1 readme.
The code follows the
[Status Nim Style Guide ](https://status-im.github.io/nim-style-guide/ ).
2021-06-17 15:05:00 +00:00
2023-09-20 16:07:09 +00:00
## Build local dev container for portal-hive
To develop code against portal-hive tests you will need:
1) Clone and build portal-hive ([#1](https://github.com/ethereum/portal-hive))
2) Modify `Dockerfile` for fluffy in `portal-hive/clients/fluffy/Dockerfile` ([#2](https://github.com/ethereum/portal-hive/blob/main/docs/overview.md#running-a-client-built-from-source))
3) Build local dev container using following command: ```docker build --tag fluffy-dev --file ./fluffy/tools/docker/Dockerfile.portalhive .``` You may need to change fluffy-dev to the tag you using in portal-hive client dockerfile.
4) Run the tests
Also keep in mind that `./vendors` is dockerignored and cached. If you have to make local changes to one of the dependencies in that directory you'll have to remove `vendors/` from `./fluffy/tools/docker/Dockerfile.portalhive.dockerignore` .
2022-04-13 14:11:01 +00:00
## Metrics and their visualisation
To enable metrics run Fluffy with the `--metrics` flag:
```bash
./build/fluffy --metrics
```
Default the metrics are available at http://127.0.0.1:8008/metrics.
The address can be changed with the `--metrics-address` and `--metrics-port` options.
This provides only a snapshot of the current metrics. In order track the metrics over
time and to also visualise them one can use for example Prometheus and Grafana.
The steps on how to set up such system is explained in [this guide ](https://nimbus.guide/metrics-pretty-pictures.html#prometheus-and-grafana ).
A Fluffy specific dashboard can be found [here ](./grafana/fluffy_grafana_dashboard.json ).
2021-06-17 15:05:00 +00:00
2022-06-22 15:22:07 +00:00
This is the dashboard used for our Fluffy testnet fleet.
In order to use it locally, you will have to remove the
`{job="nimbus-fluffy-metrics"}` part from the `instance` and `container`
variables queries in the dashboard settings. Or they can also be changed to a
constant value.
The other option would be to remove those variables and remove their usage in
each panel query.
2021-06-17 15:05:00 +00:00
## License
Licensed and distributed under either of
2021-06-28 15:53:13 +00:00
* MIT license: [LICENSE-MIT ](../LICENSE-MIT ) or http://opensource.org/licenses/MIT
2021-06-17 15:05:00 +00:00
or
2021-06-28 15:53:13 +00:00
* Apache License, Version 2.0, ([LICENSE-APACHEv2](../LICENSE-APACHEv2) or http://www.apache.org/licenses/LICENSE-2.0)
2021-06-17 15:05:00 +00:00
at your option. These files may not be copied, modified, or distributed except according to those terms.