Skip to content

Commit

Permalink
Allow custom dv images, and few review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Aug 20, 2024
1 parent 3fefc3a commit 2179e31
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 55 deletions.
2 changes: 1 addition & 1 deletion cli/actions/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestGenerateDockerCompose(t *testing.T) {
t.Errorf("SupportedClients(\"validator\") failed: %v", err)
}
var distributedValidatorClients []string
if network == "goerli" || network == "holesky" {
if network == "holesky" {
distributedValidatorClients, err = c.SupportedClients("distributedValidator")
if err != nil {
t.Errorf("SupportedClients(\"distributedValidator\") failed: %v", err)
Expand Down
69 changes: 39 additions & 30 deletions cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,34 @@ type CustomFlags struct {
// GenCmdFlags is a struct that holds the flags of the generate command
type GenCmdFlags struct {
CustomFlags
executionName string
consensusName string
validatorName string
distributed bool
checkpointSyncUrl string
feeRecipient string
noMev bool
mevImage string
mevBoostOnVal bool
noValidator bool
jwtPath string
graffiti string
mapAllPorts bool
fallbackEL []string
elExtraFlags []string
clExtraFlags []string
vlExtraFlags []string
dvExtraFlags []string
relayURLs []string
mevBoostUrl string
executionApiUrl string
executionAuthUrl string
consensusApiUrl string
waitEpoch int
customEnodes []string
customEnrs []string
latestVersion bool
executionName string
consensusName string
validatorName string
distributed bool
distributedValidatorName string
checkpointSyncUrl string
feeRecipient string
noMev bool
mevImage string
mevBoostOnVal bool
noValidator bool
jwtPath string
graffiti string
mapAllPorts bool
fallbackEL []string
elExtraFlags []string
clExtraFlags []string
vlExtraFlags []string
dvExtraFlags []string
relayURLs []string
mevBoostUrl string
executionApiUrl string
executionAuthUrl string
consensusApiUrl string
waitEpoch int
customEnodes []string
customEnrs []string
latestVersion bool
}

func GenerateCmd(sedgeAction actions.SedgeActions) *cobra.Command {
Expand Down Expand Up @@ -415,9 +416,17 @@ func valClients(allClients clients.OrderedClients, flags *GenCmdFlags, services
// distributed validator client
if utils.Contains(services, distributedValidator) {
distributedValidatorClient, _ = clients.RandomChoice(allClients[distributedValidator])
//TODO: Add support for custom images,
distributedValidatorClient.Name = "charon"
distributedValidatorClient.SetImageOrDefault("")
if flags.distributedValidatorName != "" {
distributedValidatorParts := strings.Split(flags.distributedValidatorName, ":")
distributedValidatorClient.Name = distributedValidatorParts[0]
if len(distributedValidatorParts) > 1 {
distributedValidatorClient.Image = strings.Join(distributedValidatorParts[1:], ":")
}
distributedValidatorClient.SetImageOrDefault(strings.Join(distributedValidatorParts[1:], ":"))
} else {
distributedValidatorClient.Name = "charon"
distributedValidatorClient.SetImageOrDefault("")
}
if err = clients.ValidateClient(distributedValidatorClient, distributedValidator); err != nil {
return nil, err
}
Expand Down
32 changes: 30 additions & 2 deletions cli/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func (flags *GenCmdFlags) argsList() []string {
if flags.latestVersion {
s = append(s, "--latest")
}
if flags.distributed {
s = append(s, "--distributed")
}
if flags.distributedValidatorName != "" {
s = append(s, "--distributedValidator", flags.distributedValidatorName)
}
return s
}

Expand Down Expand Up @@ -1319,13 +1325,35 @@ func TestGenerateCmd(t *testing.T) {
{
"full-node random client Distributed",
subCmd{
name: "distributed",
name: "full-node",
args: []string{},
},
GenCmdFlags{
distributed: true,
validatorName: "lighthouse",
},
globalFlags{
network: "holesky",
},
nil,
},
{
"full-node Fixed clients with DV",
subCmd{
name: "full-node",
args: []string{},
},
GenCmdFlags{
distributed: true,
distributed: true,
executionName: "nethermind",
consensusName: "lighthouse",
validatorName: "lighthouse",
distributedValidatorName: "charon",
feeRecipient: "0x0000000000000000000000000000000000000000",
},
globalFlags{
install: false,
logging: "",
network: "holesky",
},
nil,
Expand Down
1 change: 1 addition & 0 deletions cli/sub_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the
cmd.Flags().StringVarP(&flags.executionName, "execution", "e", "", "Execution engine client, e.g. geth, nethermind, besu, erigon. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name")
cmd.Flags().StringVarP(&flags.validatorName, "validator", "v", "", "Validator engine client, e.g. teku, lodestar, prysm, lighthouse, Nimbus. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name")
cmd.Flags().BoolVar(&flags.distributed, "distributed", false, "Deploy a node configured to run as part of a Distributed Validator Cluster.")
cmd.Flags().StringVarP(&flags.distributedValidatorName, "distributedValidator", "d", "", "Distributed Validator client, e.g. charon. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name")
cmd.Flags().BoolVar(&flags.latestVersion, "latest", false, "Use the latest version of clients. This sets the \"latest\" tag on the client's docker images. Latest version might not work.")
cmd.Flags().StringVar(&flags.checkpointSyncUrl, "checkpoint-sync-url", "", "Initial state endpoint (trusted synced consensus endpoint) for the consensus client to sync from a finalized checkpoint. Provide faster sync process for the consensus client and protect it from long-range attacks affored by Weak Subjetivity. Each network has a default checkpoint sync url.")
cmd.Flags().StringVar(&flags.feeRecipient, "fee-recipient", "", "Suggested fee recipient. Is a 20-byte Ethereum address which the execution layer might choose to set as the coinbase and the recipient of other fees or rewards. There is no guarantee that an execution node will use the suggested fee recipient to collect fees, it may use any address it chooses. It is assumed that an honest execution node will use the suggested fee recipient, but users should note this trust assumption.\n"+
Expand Down
43 changes: 22 additions & 21 deletions configs/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,28 @@ Your full-node is up and running. If you set up new validator keys, you will hav
Happy Staking!
`
ExecutionClientNotSpecifiedWarn = "Execution client not provided. A random client will be selected. Random client: %s"
ConsensusClientNotSpecifiedWarn = "Consensus client not provided. Selecting same pair of clients for consensus and validator clients"
ValidatorClientNotSpecifiedWarn = "Validator client not provided. Selecting same pair of clients for consensus and validator clients"
CLNotSpecifiedWarn = "Consensus and validator clients not provided. Selecting same pair of clients for consensus and validator clients using a random client. Random client: %s"
GeneratingJWTSecret = "Generating JWT secret for client authentication"
JWTSecretGenerated = "JWT secret generated"
CreatingKeystorePassword = "Creating keystore_password.txt on keystore folder"
KeystorePasswordCreated = "keystore_password.txt on keystore folder created with provided password"
MnemonicTips = "The following mnemonic is going to be used to create the validator keystore. Please save it carefully. It can be used to generate the keystore folder again. If you lose the password and mnemonic, access to your keystore will be lost forever!"
GeneratingMnemonic = "Existing mnemonic not provided. Generating mnemonic for validator keystore:"
StoreMnemonic = "Make sure to store your mnemonic somewhere safe. Losing it could end in the lost of your validators. Press enter to continue" // TODO: improve warning message
PreparingTekuDatadir = "Preparing teku datadirs (must have full read/write/execute permissions to work)"
GettingContainersIP = "Proceeding to get execution and consensus containers IP address for the monitoring tool"
WaitingForNodesToStart = "Waiting a minute for nodes to start"
CustomExecutionImagesWarning = "You are using custom images for the execution client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
CustomConsensusImagesWarning = "You are using custom images for the consensus client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
CustomValidatorImagesWarning = "You are using custom images for the validator client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
MapAllPortsWarning = "You are mapping all ports for the clients!!! Make sure this is intended. This could make the clients vulnerable to attacks. Be sure to setup a firewall."
CheckpointUrlUsedWarning = "A Checkpoint Sync Url will be used for the consensus node. Using %s ."
NoBootnodesFound = "No bootnodes found in %s env file "
UnableToCheckVersion = "Unable to check for new Version. Please check manually at " +
ExecutionClientNotSpecifiedWarn = "Execution client not provided. A random client will be selected. Random client: %s"
ConsensusClientNotSpecifiedWarn = "Consensus client not provided. Selecting same pair of clients for consensus and validator clients"
ValidatorClientNotSpecifiedWarn = "Validator client not provided. Selecting same pair of clients for consensus and validator clients"
CLNotSpecifiedWarn = "Consensus and validator clients not provided. Selecting same pair of clients for consensus and validator clients using a random client. Random client: %s"
GeneratingJWTSecret = "Generating JWT secret for client authentication"
JWTSecretGenerated = "JWT secret generated"
CreatingKeystorePassword = "Creating keystore_password.txt on keystore folder"
KeystorePasswordCreated = "keystore_password.txt on keystore folder created with provided password"
MnemonicTips = "The following mnemonic is going to be used to create the validator keystore. Please save it carefully. It can be used to generate the keystore folder again. If you lose the password and mnemonic, access to your keystore will be lost forever!"
GeneratingMnemonic = "Existing mnemonic not provided. Generating mnemonic for validator keystore:"
StoreMnemonic = "Make sure to store your mnemonic somewhere safe. Losing it could end in the lost of your validators. Press enter to continue" // TODO: improve warning message
PreparingTekuDatadir = "Preparing teku datadirs (must have full read/write/execute permissions to work)"
GettingContainersIP = "Proceeding to get execution and consensus containers IP address for the monitoring tool"
WaitingForNodesToStart = "Waiting a minute for nodes to start"
CustomExecutionImagesWarning = "You are using custom images for the execution client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
CustomConsensusImagesWarning = "You are using custom images for the consensus client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
CustomValidatorImagesWarning = "You are using custom images for the validator client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
CustomDistributedValidatorImagesWarning = "You are using custom images for the distributed validator client!!! Make sure this is intended. Also check these images are correct and available from this device otherwise the setup will fail or have an unexpected behavior."
MapAllPortsWarning = "You are mapping all ports for the clients!!! Make sure this is intended. This could make the clients vulnerable to attacks. Be sure to setup a firewall."
CheckpointUrlUsedWarning = "A Checkpoint Sync Url will be used for the consensus node. Using %s ."
NoBootnodesFound = "No bootnodes found in %s env file "
UnableToCheckVersion = "Unable to check for new Version. Please check manually at " +
"https://github.com/NethermindEth/sedge/releases, with error:"
NeedVersionUpdate = "A new Version of sedge is available. Please update to the latest Version. See " +
"https://github.com/NethermindEth/sedge/releases for more information. Latest detected tag:"
Expand Down
1 change: 1 addition & 0 deletions docs/docs/commands/generate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Flags:
-e, --execution string Execution engine client, e.g. geth, nethermind, besu, erigon. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name
-v, --validator string Validator engine client, e.g. teku, lodestar, prysm, lighthouse, Nimbus. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name
--distributed boolean Deploy a node configured to run as part of a Distributed Validator Cluster.
-d --distributedValidator string Distributed Validator client, e.g. charon. Additionally, you can use this syntax '<CLIENT>:<DOCKER_IMAGE>' to override the docker image used for the client. If you want to use the default docker image, just use the client name
--latest Use the latest version of clients. This sets the "latest" tag on the client's docker images. Latest version might not work.
--checkpoint-sync-url string Initial state endpoint (trusted synced consensus endpoint) for the consensus client to sync from a finalized checkpoint. Provide faster sync process for the consensus client and protect it from long-range attacks affored by Weak Subjetivity. Each network has a default checkpoint sync url.
--fee-recipient string Suggested fee recipient. Is a 20-byte Ethereum address which the execution layer might choose to set as the coinbase and the recipient of other fees or rewards. There is no guarantee that an execution node will use the suggested fee recipient to collect fees, it may use any address it chooses. It is assumed that an honest execution node will use the suggested fee recipient, but users should note this trust assumption.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/quickstart/charon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $sedge % tree .charon
Once the DKG process is complete and `.charon` folder and its contents are generated, you can set up your full node using **Sedge**:

```bash
sedge generate full-node --validator=teku --consensus=prysm --execution=geth --network=holesky --distributed
sedge generate full-node --validator=teku --consensus=prysm --execution=nethermind --network=holesky --distributed
```

:::note
Expand Down

0 comments on commit 2179e31

Please sign in to comment.