Skip to content

Commit 94ba3eb

Browse files
committed
Update Lighthouse Book API and Advanced Usage section (#4300)
## Issue Addressed Update Information in Lighthouse Book ## Proposed Changes - move Validator Graffiti from Advanced Usage to Validator Management - update API response and command - some items that aren't too sure I put it in comment, which can be seen in raw/review format but not live ## Additional Info Please provide any additional information. For example, future considerations or information useful for reviewers. Co-authored-by: chonghe <[email protected]>
1 parent 7b1a0d4 commit 94ba3eb

20 files changed

+706
-278
lines changed

book/src/SUMMARY.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
* [Validator Monitoring](./validator-monitoring.md)
1919
* [Doppelganger Protection](./validator-doppelganger.md)
2020
* [Suggested Fee Recipient](./suggested-fee-recipient.md)
21+
* [Validator Graffiti](./graffiti.md)
2122
* [APIs](./api.md)
2223
* [Beacon Node API](./api-bn.md)
23-
* [/lighthouse](./api-lighthouse.md)
24-
* [Validator Inclusion APIs](./validator-inclusion.md)
24+
* [Lighthouse API](./api-lighthouse.md)
25+
* [Validator Inclusion APIs](./validator-inclusion.md)
2526
* [Validator Client API](./api-vc.md)
2627
* [Endpoints](./api-vc-endpoints.md)
2728
* [Authorization Header](./api-vc-auth-header.md)
@@ -36,7 +37,6 @@
3637
* [Advanced Usage](./advanced.md)
3738
* [Checkpoint Sync](./checkpoint-sync.md)
3839
* [Custom Data Directories](./advanced-datadir.md)
39-
* [Validator Graffiti](./graffiti.md)
4040
* [Proposer Only Beacon Nodes](./advanced-proposer-only.md)
4141
* [Remote Signing with Web3Signer](./validator-web3signer.md)
4242
* [Database Configuration](./advanced_database.md)
@@ -46,9 +46,8 @@
4646
* [Advanced Networking](./advanced_networking.md)
4747
* [Running a Slasher](./slasher.md)
4848
* [Redundancy](./redundancy.md)
49-
* [Pre-Releases](./advanced-pre-releases.md)
5049
* [Release Candidates](./advanced-release-candidates.md)
51-
* [MEV and Lighthouse](./builders.md)
50+
* [Maximal Extractable Value (MEV)](./builders.md)
5251
* [Merge Migration](./merge-migration.md)
5352
* [Late Block Re-orgs](./late-block-re-orgs.md)
5453
* [Contributing](./contributing.md)

book/src/advanced-pre-releases.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

book/src/advanced-release-candidates.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[`v1.4.0`]: https://github.com/sigp/lighthouse/releases/tag/v1.4.0
88

99
From time-to-time, Lighthouse *release candidates* will be published on the [sigp/lighthouse]
10-
repository. These releases have passed the usual automated testing, however the developers would
10+
repository. Release candidates are previously known as Pre-Releases. These releases have passed the usual automated testing, however the developers would
1111
like to see it running "in the wild" in a variety of configurations before declaring it an official,
1212
stable release. Release candidates are also used by developers to get feedback from users regarding the
1313
ergonomics of new features or changes.
@@ -36,8 +36,9 @@ Users may wish to try a release candidate for the following reasons:
3636
- To help detect bugs and regressions before they reach production.
3737
- To provide feedback on annoyances before they make it into a release and become harder to change or revert.
3838

39+
There can also be a scenario that a bug has been found and requires an urgent fix. An example of incidence is [v4.0.2-rc.0](https://github.com/sigp/lighthouse/releases/tag/v4.0.2-rc.0) which contains a hot-fix to address high CPU usage experienced after the [Capella](https://ethereum.org/en/history/#capella) upgrade on 12<sup>th</sup> April 2023. In this scenario, we will announce the release candidate on [Github](https://github.com/sigp/lighthouse/releases) and also on [Discord](https://discord.gg/cyAszAh) to recommend users to update to the release candidate version.
40+
3941
## When *not* to use a release candidate
4042

41-
It is not recommended to use release candidates for any critical tasks on mainnet (e.g., staking).
42-
To test critical features, try one of the testnets (e.g., Prater).
43+
Other than the above scenarios, it is generally not recommended to use release candidates for any critical tasks on mainnet (e.g., staking). To test new release candidate features, try one of the testnets (e.g., Goerli).
4344

book/src/advanced.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,18 @@ elsewhere?
66
This section provides detailed information about configuring Lighthouse for specific use cases, and
77
tips about how things work under the hood.
88

9-
* [Advanced Database Configuration](./advanced_database.md): understanding space-time trade-offs in the database.
9+
* [Checkpoint Sync](./checkpoint-sync.md): quickly sync the beacon chain to perform validator duties.
10+
* [Custom Data Directories](./advanced-datadir.md): modify the data directory to your preferred location.
11+
* [Proposer Only Beacon Nodes](./advanced-proposer-only.md): beacon node only for proposer duty for increased anonymity.
12+
* [Remote Signing with Web3Signer](./validator-web3signer.md): don't want to store your keystore in local node? Use web3signer.
13+
* [Database Configuration](./advanced_database.md): understanding space-time trade-offs in the database.
14+
* [Database Migrations](./database-migrations.md): have a look at all previous Lighthouse database scheme versions.
15+
* [Key Management](./key-management.md): explore how to generate wallet with Lighthouse.
16+
* [Key Recovery](./key-recovery.md): explore how to recover wallet and validator with Lighthouse.
17+
* [Advanced Networking](./advanced_networking.md): open your ports to have a diverse and healthy set of peers.
18+
* [Running a Slasher](./slasher.md): contribute to the health of the network by running a slasher.
19+
* [Redundancy](./redundancy.md): want to have more than one beacon node as backup? This is for you.
20+
* [Release Candidates](./advanced-release-candidates.md): latest release of Lighthouse to get feedback from users.
21+
* [Maximal Extractable Value](./builders.md): use external builders for a potential higher rewards during block proposals
22+
* [Merge Migration](./merge-migration.md): look at what you need to do during a significant network upgrade: The Merge
23+
* [Late Block Re-orgs](./late-block-re-orgs.md): read information about Lighthouse late block re-orgs.

book/src/advanced_database.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ states to slow down dramatically. A lower _slots per restore point_ value (SPRP)
2323
frequent restore points, while a higher SPRP corresponds to less frequent. The table below shows
2424
some example values.
2525

26-
| Use Case | SPRP | Yearly Disk Usage | Load Historical State |
27-
|--------------------------|------|-------------------|-----------------------|
28-
| Block explorer/analysis | 32 | 1.4 TB | 155 ms |
29-
| Hobbyist (prev. default) | 2048 | 23.1 GB | 10.2 s |
30-
| Validator only (default) | 8192 | 5.7 GB | 41 s |
26+
| Use Case | SPRP | Yearly Disk Usage* | Load Historical State |
27+
|----------------------------|------|-------------------|-----------------------|
28+
| Research | 32 | 3.4 TB | 155 ms |
29+
| Block explorer/analysis | 128 | 851 GB | 620 ms |
30+
| Enthusiast (prev. default) | 2048 | 53.6 GB | 10.2 s |
31+
| EHobbyist | 4096 | 26.8 GB | 20.5 s |
32+
| Validator only (default) | 8192 | 8.1 GB | 41 s |
3133

32-
As you can see, it's a high-stakes trade-off! The relationships to disk usage and historical state
34+
*Last update: May 2023.
35+
36+
As we can see, it's a high-stakes trade-off! The relationships to disk usage and historical state
3337
load time are both linear – doubling SPRP halves disk usage and doubles load time. The minimum SPRP
3438
is 32, and the maximum is 8192.
3539

@@ -38,9 +42,11 @@ The default value is 8192 for databases synced from scratch using Lighthouse v2.
3842

3943
The values shown in the table are approximate, calculated using a simple heuristic: each
4044
`BeaconState` consumes around 18MB of disk space, and each block replayed takes around 5ms. The
41-
**Yearly Disk Usage** column shows the approx size of the freezer DB _alone_ (hot DB not included),
42-
and the **Load Historical State** time is the worst-case load time for a state in the last slot
43-
before a restore point.
45+
**Yearly Disk Usage** column shows the approximate size of the freezer DB _alone_ (hot DB not included), calculated proportionally using the total freezer database disk usage.
46+
The **Load Historical State** time is the worst-case load time for a state in the last slot
47+
before a restore point.
48+
49+
As an example, we use an SPRP of 4096 to calculate the total size of the freezer database until May 2023. It has been about 900 days since the genesis, the total disk usage by the freezer database is therefore: 900/365*26.8 GB = 66 GB.
4450

4551
### Defaults
4652

@@ -68,6 +74,8 @@ The historical state cache size can be specified with the flag `--historic-state
6874
lighthouse beacon_node --historic-state-cache-size 4
6975
```
7076

77+
> Note: This feature will cause high memory usage.
78+
7179
## Glossary
7280

7381
* _Freezer DB_: part of the database storing finalized states. States are stored in a sparser

book/src/advanced_networking.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ peers for your node and overall improve the Ethereum consensus network.
5151
Lighthouse currently supports UPnP. If UPnP is enabled on your router,
5252
Lighthouse will automatically establish the port mappings for you (the beacon
5353
node will inform you of established routes in this case). If UPnP is not
54-
enabled, we recommend you manually set up port mappings to both of Lighthouse's
54+
enabled, we recommend you to manually set up port mappings to both of Lighthouse's
5555
TCP and UDP ports (9000 by default).
5656

5757
> Note: Lighthouse needs to advertise its publicly accessible ports in
@@ -63,6 +63,28 @@ TCP and UDP ports (9000 by default).
6363
> explicitly specify them using the `--enr-tcp-port` and `--enr-udp-port` as
6464
> explained in the following section.
6565
66+
### How to Open Ports
67+
68+
The steps to do port forwarding depends on the router, but the general steps are given below:
69+
1. Determine the default gateway IP:
70+
- On Linux: open a terminal and run `ip route | grep default`, the result should look something similar to `default via 192.168.50.1 dev wlp2s0 proto dhcp metric 600`. The `192.168.50.1` is your router management default gateway IP.
71+
- On MacOS: open a terminal and run `netstat -nr|grep default` and it should return the default gateway IP.
72+
- On Windows: open a command prompt and run `ipconfig` and look for the `Default Gateway` which will show you the gateway IP.
73+
74+
The default gateway IP usually looks like 192.168.X.X. Once you obtain the IP, enter it to a web browser and it will lead you to the router management page.
75+
76+
2. Login to the router management page. The login credentials are usually available in the manual or the router, or it can be found on a sticker underneath the router. You can also try the login credentials for some common router brands listed [here](https://www.noip.com/support/knowledgebase/general-port-forwarding-guide/).
77+
78+
3. Navigate to the port forward settings in your router. The exact step depends on the router, but typically it will fall under the "Advanced" section, under the name "port forwarding" or "virtual server".
79+
80+
4. Configure a port forwarding rule as below:
81+
- Protocol: select `TCP/UDP` or `BOTH`
82+
- External port: `9000`
83+
- Internal port: `9000`
84+
- IP address: Usually there is a dropdown list for you to select the device. Choose the device that is running Lighthouse
85+
86+
5. To check that you have successfully open the ports, go to [yougetsignal](https://www.yougetsignal.com/tools/open-ports/) and enter `9000` in the `port number`. If it shows "open", then you have successfully set up port forwarding. If it shows "closed", double check your settings, and also check that you have allowed firewall rules on port 9000.
87+
6688

6789
### ENR Configuration
6890

@@ -81,7 +103,7 @@ and if it is, it will update your ENR to the correct public IP and port address
81103
(meaning you do not need to set it manually). Lighthouse persists its ENR, so
82104
on reboot it will re-load the settings it had discovered previously.
83105

84-
Modifying the ENR settings can degrade the discovery of your node making it
106+
Modifying the ENR settings can degrade the discovery of your node, making it
85107
harder for peers to find you or potentially making it harder for other peers to
86108
find each other. We recommend not touching these settings unless for a more
87109
advanced use case.

book/src/api-bn.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ specification][OpenAPI]. Please follow that link for a full description of each
55

66
## Starting the server
77

8-
A Lighthouse beacon node can be configured to expose a HTTP server by supplying the `--http` flag. The default listen address is `127.0.0.1:5052`.
8+
A Lighthouse beacon node can be configured to expose an HTTP server by supplying the `--http` flag. The default listen address is `http://127.0.0.1:5052`.
99

1010
The following CLI flags control the HTTP server:
1111

@@ -55,11 +55,8 @@ Additional risks to be aware of include:
5555

5656
## CLI Example
5757

58-
Start the beacon node with the HTTP server listening on [http://localhost:5052](http://localhost:5052):
58+
Start a beacon node and an execution node according to [Run a node](./run_a_node.md). Note that since [The Merge](https://ethereum.org/en/roadmap/merge/), an execution client is required to be running along with a beacon node. Hence, the query on Beacon Node APIs requires users to run both. While there are some Beacon Node APIs that you can query with only the beacon node, such as the [node version](https://ethereum.github.io/beacon-APIs/#/Node/getNodeVersion), in general an execution client is required to get the updated information about the beacon chain, such as [state root](https://ethereum.github.io/beacon-APIs/#/Beacon/getStateRoot), [headers](https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockHeaders) and many others, which are dynamically progressing with time.
5959

60-
```bash
61-
lighthouse bn --http
62-
```
6360

6461
## HTTP Request/Response Examples
6562

@@ -77,40 +74,46 @@ curl -X GET "http://localhost:5052/eth/v1/beacon/headers/head" -H "accept: appl
7774

7875
```json
7976
{
77+
"execution_optimistic": false,
78+
"finalized": false,
8079
"data": {
81-
"root": "0x4381454174fc28c7095077e959dcab407ae5717b5dca447e74c340c1b743d7b2",
80+
"root": "0x9059bbed6b8891e0ba2f656dbff93fc40f8c7b2b7af8fea9df83cfce5ee5e3d8",
8281
"canonical": true,
8382
"header": {
8483
"message": {
85-
"slot": "3199",
86-
"proposer_index": "19077",
87-
"parent_root": "0xf1934973041c5896d0d608e52847c3cd9a5f809c59c64e76f6020e3d7cd0c7cd",
88-
"state_root": "0xe8e468f9f5961655dde91968f66480868dab8d4147de9498111df2b7e4e6fe60",
89-
"body_root": "0x6f183abc6c4e97f832900b00d4e08d4373bfdc819055d76b0f4ff850f559b883"
84+
"slot": "6271829",
85+
"proposer_index": "114398",
86+
"parent_root": "0x1d2b4fa8247f754a7a86d36e1d0283a5e425491c431533716764880a7611d225",
87+
"state_root": "0x2b48adea290712f56b517658dde2da5d36ee01c41aebe7af62b7873b366de245",
88+
"body_root": "0x6fa74c995ce6f397fa293666cde054d6a9741f7ec280c640bee51220b4641e2d"
9089
},
91-
"signature": "0x988064a2f9cf13fe3aae051a3d85f6a4bca5a8ff6196f2f504e32f1203b549d5f86a39c6509f7113678880701b1881b50925a0417c1c88a750c8da7cd302dda5aabae4b941e3104d0cf19f5043c4f22a7d75d0d50dad5dbdaf6991381dc159ab"
90+
"signature": "0x8258e64fea426033676a0045c50543978bf173114ba94822b12188e23cbc8d8e89e0b5c628a881bf3075d325bc11341105a4e3f9332ac031d89a93b422525b79e99325928a5262f17dfa6cc3ddf84ca2466fcad86a3c168af0d045f79ef52036"
9291
}
9392
}
9493
}
9594
```
9695

96+
The `jq` tool is used to format the JSON data properly. If it returns `jq: command not found`, then you can install `jq` with `sudo apt install -y jq`. After that, run the command again, and it should return the head state of the beacon chain.
97+
9798
### View the status of a validator
9899

99100
Shows the status of validator at index `1` at the `head` state.
100101

101102
```bash
102-
curl -X GET "http://localhost:5052/eth/v1/beacon/states/head/validators/1" -H "accept: application/json" | jq
103+
curl -X GET "http://localhost:5052/eth/v1/beacon/states/head/validators/1" -H "accept: application/json"
103104
```
104105

105106
```json
106107
{
108+
"execution_optimistic": false,
109+
"finalized": false,
107110
"data": {
108111
"index": "1",
109-
"balance": "63985937939",
110-
"status": "Active",
112+
"balance": "32004587169",
113+
"status": "active_ongoing",
111114
"validator": {
112-
"pubkey": "0x873e73ee8b3e4fcf1d2fb0f1036ba996ac9910b5b348f6438b5f8ef50857d4da9075d0218a9d1b99a9eae235a39703e1",
113-
"withdrawal_credentials": "0x00b8cdcf79ba7e74300a07e9d8f8121dd0d8dd11dcfd6d3f2807c45b426ac968",
115+
"pubkey": "0xa1d1ad0714035353258038e964ae9675dc0252ee22cea896825c01458e1807bfad2f9969338798548d9858a571f7425c",
116+
"withdrawal_credentials": "0x01000000000000000000000015f4b914a0ccd14333d850ff311d6dafbfbaa32b",
114117
"effective_balance": "32000000000",
115118
"slashed": false,
116119
"activation_eligibility_epoch": "0",
@@ -121,6 +124,7 @@ curl -X GET "http://localhost:5052/eth/v1/beacon/states/head/validators/1" -H "
121124
}
122125
}
123126
```
127+
You can replace `1` in the above command with the validator index that you would like to query. Other API query can be done similarly by changing the link according to the Beacon API.
124128

125129
## Serving the HTTP API over TLS
126130
> **Warning**: This feature is currently experimental.
@@ -147,9 +151,18 @@ openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 36
147151
Note that currently Lighthouse only accepts keys that are not password protected.
148152
This means we need to run with the `-nodes` flag (short for 'no DES').
149153

150-
Once generated, we can run Lighthouse:
154+
Once generated, we can run Lighthouse and an execution node according to [Run a node](./run_a_node.md). In addition, add the flags `--http-enable-tls --http-tls-cert cert.pem --http-tls-key key.pem` to Lighthouse, the command should look like:
155+
151156
```bash
152-
lighthouse bn --http --http-enable-tls --http-tls-cert cert.pem --http-tls-key key.pem
157+
lighthouse bn \
158+
--network mainnet \
159+
--execution-endpoint http://localhost:8551 \
160+
--execution-jwt /secrets/jwt.hex \
161+
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
162+
--http \
163+
--http-enable-tls \
164+
--http-tls-cert cert.pem \
165+
--http-tls-key key.pem
153166
```
154167
Note that the user running Lighthouse must have permission to read the
155168
certificate and key.
@@ -159,6 +172,7 @@ The API is now being served at `https://localhost:5052`.
159172
To test connectivity, you can run the following:
160173
```bash
161174
curl -X GET "https://localhost:5052/eth/v1/node/version" -H "accept: application/json" --cacert cert.pem | jq
175+
162176
```
163177
### Connecting a validator client
164178
In order to connect a validator client to a beacon node over TLS, the validator
@@ -201,13 +215,13 @@ Ensure the `--http` flag has been supplied at the CLI.
201215
You can quickly check that the HTTP endpoint is up using `curl`:
202216

203217
```bash
204-
curl -X GET "http://localhost:5052/eth/v1/node/version" -H "accept: application/json" | jq
218+
curl -X GET "http://localhost:5052/eth/v1/node/version" -H "accept:application/json"
205219
```
206220

207221
The beacon node should respond with its version:
208222

209223
```json
210-
{"data":{"version":"Lighthouse/v0.2.9-6f7b4768a/x86_64-linux"}}
224+
{"data":{"version":"Lighthouse/v4.1.0-693886b/x86_64-linux"}
211225
```
212226

213227
If this doesn't work, the server might not be started or there might be a

0 commit comments

Comments
 (0)