Resolves #6767 This PR implements a basic version of validator custody. - It introduces a new `CustodyContext` object which contains info regarding number of validators attached to a node and the custody count they contribute to the cgc. - The `CustodyContext` is added in the da_checker and has methods for returning the current cgc and the number of columns to sample at head. Note that the logic for returning the cgc existed previously in the network globals. - To estimate the number of validators attached, we use the `beacon_committee_subscriptions` endpoint. This might overestimate the number of validators actually publishing attestations from the node in the case of multi BN setups. We could also potentially use the `publish_attestations` endpoint to get a more conservative estimate at a later point. - Anytime there's a change in the `custody_group_count` due to addition/removal of validators, the custody context should send an event on a broadcast channnel. The only subscriber for the channel exists in the network service which simply subscribes to more subnets. There can be additional subscribers in sync that will start a backfill once the cgc changes. TODO - [ ] **NOT REQUIRED:** Currently, the logic only handles an increase in validator count and does not handle a decrease. We should ideally unsubscribe from subnets when the cgc has decreased. - [ ] **NOT REQUIRED:** Add a service in the `CustodyContext` that emits an event once `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS ` passes after updating the current cgc. This event should be picked up by a subscriber which updates the enr and metadata. - [x] Add more tests
Simple Local Testnet
These scripts allow for running a small local testnet with a default of 4 beacon nodes, 4 validator clients and 4 Geth execution clients using Kurtosis. This setup can be useful for testing and development.
Installation
-
Install Docker. Verify that Docker has been successfully installed by running
sudo docker run hello-world. -
Install Kurtosis. Verify that Kurtosis has been successfully installed by running
kurtosis versionwhich should display the version. -
Install
yq. If you are on Ubuntu, you can installyqby runningsnap install yq.
Starting the testnet
To start a testnet, from the Lighthouse root repository:
cd ./scripts/local_testnet
./start_local_testnet.sh
It will build a Lighthouse docker image from the root of the directory and will take an approximately 12 minutes to complete. Once built, the testing will be started automatically. You will see a list of services running and "Started!" at the end.
You can also select your own Lighthouse docker image to use by specifying it in network_params.yml under the cl_image key.
Full configuration reference for Kurtosis is specified here.
To view all running services:
kurtosis enclave inspect local-testnet
To view the logs:
kurtosis service logs local-testnet $SERVICE_NAME
where $SERVICE_NAME is obtained by inspecting the running services above. For example, to view the logs of the first beacon node, validator client and Geth:
kurtosis service logs local-testnet -f cl-1-lighthouse-geth
kurtosis service logs local-testnet -f vc-1-geth-lighthouse
kurtosis service logs local-testnet -f el-1-geth-lighthouse
If you would like to save the logs, use the command:
kurtosis dump $OUTPUT_DIRECTORY
This will create a folder named $OUTPUT_DIRECTORY in the present working directory that contains all logs and other information. If you want the logs for a particular service and saved to a file named logs.txt:
kurtosis service logs local-testnet $SERVICE_NAME -a > logs.txt
where $SERVICE_NAME can be viewed by running kurtosis enclave inspect local-testnet.
Kurtosis comes with a Dora explorer which can be opened with:
open $(kurtosis port print local-testnet dora http)
Some testnet parameters can be varied by modifying the network_params.yaml file. Kurtosis also comes with a web UI which can be open with kurtosis web.
Stopping the testnet
To stop the testnet, from the Lighthouse root repository:
cd ./scripts/local_testnet
./stop_local_testnet.sh
You will see "Local testnet stopped." at the end.
CLI options
The script comes with some CLI options, which can be viewed with ./start_local_testnet.sh --help. One of the CLI options is to avoid rebuilding Lighthouse each time the testnet starts, which can be configured with the command:
./start_local_testnet.sh -b false
Further reading about Kurtosis
You may refer to this article for information about Kurtosis.