Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nimbus as consensus client #223

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support for Nimbus as Consensus Client.
- Documentation for all supported networks and clients.
- Support for custom networks
- When generating new mnemonic, show it without a trace.
Expand Down
15 changes: 11 additions & 4 deletions cli/cli_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

func randomizeClients(allClients clients.OrderedClients) (clients.Clients, error) {
var executionClient, consensusClient *clients.Client
var executionClient, consensusClient, validatorClient *clients.Client
var combinedClients clients.Clients

executionClient, err := clients.RandomChoice(allClients[execution])
Expand All @@ -44,11 +44,12 @@ func randomizeClients(allClients clients.OrderedClients) (clients.Clients, error
if err != nil {
return combinedClients, err
}
validatorClient, err = clients.RandomChoice(allClients[validator])

combinedClients = clients.Clients{
Execution: executionClient,
Consensus: consensusClient,
Validator: consensusClient,
Validator: validatorClient,
}
return combinedClients, nil
}
Expand Down Expand Up @@ -154,7 +155,11 @@ func validateClients(allClients clients.OrderedClients, w io.Writer, flags *CliC
} else if flags.validatorName == "" {
log.Warn(configs.ValidatorClientNotSpecifiedWarn)
// TODO: avoid flag edition
flags.validatorName = flags.consensusName
if flags.consensusName == "nimbus" {
flags.validatorName = randomizedClients.Validator.Name
} else {
flags.validatorName = flags.consensusName
}
}

exec, ok := allClients[execution][flags.executionName]
Expand All @@ -167,7 +172,9 @@ func validateClients(allClients clients.OrderedClients, w io.Writer, flags *CliC
}
val, ok := allClients[validator][flags.validatorName]
if !ok {
val.Name = flags.validatorName
val = &clients.Client{
Name: flags.validatorName,
}
}
if !utils.Contains(*flags.services, execution) && len(*flags.services) > 0 && (*flags.services)[0] != "all" {
exec = nil
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/clients/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestClients(t *testing.T) {
inputs := [...]clientsTestCase{
{
map[string][]string{
"consensus": {"lighthouse", "prysm", "teku", "lodestar"},
"consensus": {"lighthouse", "prysm", "teku", "lodestar", "nimbus"},
"validator": {"lighthouse", "prysm", "teku", "lodestar"},
"execution": {"nethermind", "geth", "besu", "erigon"},
},
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestClients(t *testing.T) {
{
map[string][]string{
"validator": {"lighthouse", "teku", "lodestar"},
"consensus": {"lighthouse", "teku", "lodestar"},
"consensus": {"lighthouse", "teku", "lodestar", "nimbus"},
"execution": {"nethermind"},
},
[]string{"consensus", "execution", "validator"},
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/generate/generate_scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func ComposeFile(gd *GenData, at io.Writer) error {
}
// If consensus is running with the validator, and the MevBoostEndpoint is not set, set it to the default value
if cls[consensus] != nil && cls[validator] != nil && gd.MevBoostEndpoint == "" && gd.Mev {
mevSupported, err = env.CheckVariable(env.ReMEV, gd.Network, "validator", gd.ConsensusClient.Name)
mevSupported, err = env.CheckVariable(env.ReMEV, gd.Network, "validator", gd.ValidatorClient.Name)
if err != nil {
return err
}
Expand Down Expand Up @@ -390,7 +390,7 @@ func EnvFile(gd *GenData, at io.Writer) error {
}
// If consensus is running with the validator, and the MevBoostEndpoint is not set, set it to the default value
if cls[consensus] != nil && cls[validator] != nil && gd.MevBoostEndpoint == "" && gd.Mev {
mevSupported, err = env.CheckVariable(env.ReMEV, gd.Network, "validator", gd.ConsensusClient.Name)
mevSupported, err = env.CheckVariable(env.ReMEV, gd.Network, "validator", gd.ValidatorClient.Name)
if err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions internal/pkg/generate/generate_scripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,18 @@ func generateTestCases(t *testing.T) (tests []genTestData) {
},
CheckFunctions: []CheckFunc{defaultFunc, checkOnlyConsensus},
},
genTestData{
Description: fmt.Sprintf(baseDescription+"validator: %s, network: %s, only validator", consensusCl, network),
GenerationData: &GenData{
ValidatorClient: &clients.Client{Name: consensusCl},
Network: network,
Services: []string{validator},
},
CheckFunctions: []CheckFunc{defaultFunc, checkOnlyValidator},
},
)
if utils.Contains(validatorClients, consensusCl) {
tests = append(tests,
genTestData{
Description: fmt.Sprintf(baseDescription+"validator: %s, network: %s, only validator", consensusCl, network),
GenerationData: &GenData{
ValidatorClient: &clients.Client{Name: consensusCl},
Network: network,
Services: []string{validator},
},
CheckFunctions: []CheckFunc{defaultFunc, checkOnlyValidator},
},
genTestData{
Description: fmt.Sprintf(baseDescription+"execution: %s, consensus: %s, validator: %s, network: %s, all", executionCl, consensusCl, consensusCl, network),
GenerationData: &GenData{
Expand Down
13 changes: 13 additions & 0 deletions templates/envs/custom/consensus/nimbus.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/* nimbus.tmpl */}}
{{ define "consensus" }}
# --- Consensus Layer - Beacon Node - configuration ---
CC_PEER_COUNT=50
CC_LOG_LEVEL=info
EC_API_URL={{.ExecutionApiURL}}
EC_AUTH_URL={{.ExecutionAuthURL}}
CC_INSTANCE_NAME=Nimbus
CC_IMAGE_VERSION={{if .CcImage}}{{.CcImage}}{{else}}statusim/nimbus-eth2:amd64-latest{{end}}
CC_DATA_DIR={{.CcDataDir}}
CC_JWT_SECRET_PATH={{.JWTSecretPath}}
CC_FEE_RECIPIENT={{.FeeRecipient}}
{{ end }}
14 changes: 14 additions & 0 deletions templates/envs/goerli/consensus/nimbus.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* nimbus.tmpl */}}
{{ define "consensus" }}
# --- Consensus Layer - Beacon Node - configuration ---
CC_PEER_COUNT=50
CC_LOG_LEVEL=info
EC_API_URL={{.ExecutionApiURL}}
EC_AUTH_URL={{.ExecutionAuthURL}}
CC_INSTANCE_NAME=Nimbus
CC_IMAGE_VERSION={{if .CcImage}}{{.CcImage}}{{else}}statusim/nimbus-eth2:amd64-latest{{end}}
CC_DATA_DIR={{.CcDataDir}}
CC_JWT_SECRET_PATH={{.JWTSecretPath}}
CC_FEE_RECIPIENT={{.FeeRecipient}}
CHECKPOINT_SYNC_URL=https://goerli.beaconstate.ethstaker.cc/
{{ end }}
14 changes: 14 additions & 0 deletions templates/envs/mainnet/consensus/nimbus.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* nimbus.tmpl */}}
{{ define "consensus" }}
# --- Consensus Layer - Beacon Node - configuration ---
CC_PEER_COUNT=50
CC_LOG_LEVEL=info
EC_API_URL={{.ExecutionApiURL}}
EC_AUTH_URL={{.ExecutionAuthURL}}
CC_INSTANCE_NAME=Nimbus
CC_IMAGE_VERSION={{if .CcImage}}{{.CcImage}}{{else}}statusim/nimbus-eth2:amd64-latest{{end}}
CC_DATA_DIR={{.CcDataDir}}
CC_JWT_SECRET_PATH={{.JWTSecretPath}}
CC_FEE_RECIPIENT={{.FeeRecipient}}
CHECKPOINT_SYNC_URL=https://beaconstate.ethstaker.cc
{{ end }}
14 changes: 14 additions & 0 deletions templates/envs/sepolia/consensus/nimbus.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* nimbus.tmpl */}}
{{ define "consensus" }}
# --- Consensus Layer - Beacon Node - configuration ---
CC_PEER_COUNT=50
CC_LOG_LEVEL=info
EC_API_URL={{.ExecutionApiURL}}
EC_AUTH_URL={{.ExecutionAuthURL}}
CC_INSTANCE_NAME=Nimbus
CC_IMAGE_VERSION={{if .CcImage}}{{.CcImage}}{{else}}statusim/nimbus-eth2:amd64-latest{{end}}
CC_DATA_DIR={{.CcDataDir}}
CC_JWT_SECRET_PATH={{.JWTSecretPath}}
CC_FEE_RECIPIENT={{.FeeRecipient}}
CHECKPOINT_SYNC_URL=https://sepolia.checkpoint-sync.ethpandaops.io
{{ end }}
90 changes: 90 additions & 0 deletions templates/services/merge/consensus/nimbus.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{/* nimbus.tmpl */}}
{{ define "consensus" }}{{if or .ClCheckpointSyncUrl .CheckpointSyncUrl}}
consensus-sync:{{if and (ge .UID 0) (ge .GID 0)}}
user: "{{.UID}}:{{.GID}}"{{end}}
stop_grace_period: 30s
container_name: sedge-consensus-trusted-sync
image: ${CC_IMAGE_VERSION}
networks:
- sedge
volumes:
- ${CC_DATA_DIR}:/var/lib/nimbus
- ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}}
- {{.CustomNetworkConfigPath}}:/network_config/config.yaml{{end}}{{if .CustomGenesisPath}}
- {{.CustomGenesisPath}}:/network_config/genesis.ssz{{end}}{{if .CustomDeployBlockPath}}
- {{.CustomDeployBlockPath}}:/network_config/deploy_block.txt{{end}}{{end}}
command:
- trustedNodeSync
- --network:{{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}
- --data-dir=/var/lib/nimbus
- --trusted-node-url={{if .CheckpointSyncUrl}}{{ .CheckpointSyncUrl }}{{else}}${CHECKPOINT_SYNC_URL}{{end}}{{if .LoggingDriver}}
logging:
driver: "{{.LoggingDriver}}"{{if eq .LoggingDriver "json-file"}}
options:
max-size: "10m"
max-file: "10"{{end}}{{end}}{{end}}

consensus:{{if and (ge .UID 0) (ge .GID 0)}}
user: "{{.UID}}:{{.GID}}"{{end}}
stop_grace_period: 30s
container_name: consensus-client
restart: unless-stopped
image: ${CC_IMAGE_VERSION}{{if or .ClCheckpointSyncUrl .CheckpointSyncUrl .Mev}}
depends_on:{{if .Mev}}
mevboost:
condition: service_started{{end}}{{if or .ClCheckpointSyncUrl .CheckpointSyncUrl}}
consensus-sync:
condition: service_completed_successfully{{end}}{{end}}
healthcheck:
test: "(curl -s -o /dev/null -w \"%{http_code}\" -X GET http://127.0.0.1:4000/eth/v1/node/health | grep -q 200) || exit 1"
interval: 5m
retries: 4032
start_period: 1m
networks:
- sedge
volumes:
- ${CC_DATA_DIR}:/var/lib/nimbus
- ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}}
- {{.CustomNetworkConfigPath}}:/network_config/config.yaml{{end}}{{if .CustomGenesisPath}}
- {{.CustomGenesisPath}}:/network_config/genesis.ssz{{end}}{{if .CustomDeployBlockPath}}
- {{.CustomDeployBlockPath}}:/network_config/deploy_block.txt{{end}}{{end}}
ports:
- "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/tcp"
- "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/udp"
- "{{.ClMetricsPort}}:{{.ClMetricsPort}}/tcp"{{if .MapAllPorts}}
- "{{.ClApiPort}}:{{.ClApiPort}}"{{end}}
expose:
- {{.ClApiPort}}
command:
- --non-interactive=true
- --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}
- --max-peers=${CC_PEER_COUNT}
- --data-dir="/var/lib/nimbus"
- --web3-url=${EC_AUTH_URL}{{range $url := .FallbackELUrls}} --web3-url={{$url}}{{end}}
- --bootstrap-node={{.CCBootnodes}}
- --udp-port={{.ClDiscoveryPort}}
- --tcp-port={{.ClDiscoveryPort}}
- --listen-address=0.0.0.0
- --enr-auto-update=false
- --subscribe-all-subnets
- --rest
- --rest-port={{.ClApiPort}}
- --rest-address=0.0.0.0{{if .FeeRecipient}}
- --suggested-fee-recipient=${CC_FEE_RECIPIENT}{{end}}
- --metrics
- --metrics-port={{.ClMetricsPort}}
- --metrics-address=0.0.0.0
- --doppelganger-detection=off{{if .TTD}}
- --terminal-total-difficulty-override={{.TTD}}{{end}}
- --jwt-secret=/tmp/jwt/jwtsecret
- --log-level=${CC_LOG_LEVEL}
- --dump:on{{range $flag := .ClExtraFlags}}
- --{{$flag}}{{end}}{{if .MevBoostEndpoint}}
- --payload-builder
- --payload-builder-url={{.MevBoostEndpoint}}{{end}}{{if .LoggingDriver}}
logging:
driver: "{{.LoggingDriver}}"{{if eq .LoggingDriver "json-file"}}
options:
max-size: "10m"
max-file: "10"{{end}}{{end}}
{{ end }}