From 2179e312814b9c5fd11cd9c79862f2257773a810 Mon Sep 17 00:00:00 2001 From: sugh01 Date: Tue, 20 Aug 2024 15:22:20 +0200 Subject: [PATCH] Allow custom dv images, and few review fixes --- cli/actions/generation_test.go | 2 +- cli/generate.go | 69 +++++++++++++++++++-------------- cli/generate_test.go | 32 ++++++++++++++- cli/sub_gen.go | 1 + configs/messages.go | 43 ++++++++++---------- docs/docs/commands/generate.mdx | 1 + docs/docs/quickstart/charon.mdx | 2 +- 7 files changed, 95 insertions(+), 55 deletions(-) diff --git a/cli/actions/generation_test.go b/cli/actions/generation_test.go index 39c95f08..3049dbd7 100644 --- a/cli/actions/generation_test.go +++ b/cli/actions/generation_test.go @@ -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) diff --git a/cli/generate.go b/cli/generate.go index dccf89e0..f58cb5ce 100644 --- a/cli/generate.go +++ b/cli/generate.go @@ -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 { @@ -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 } diff --git a/cli/generate_test.go b/cli/generate_test.go index 24a65512..535d5dba 100644 --- a/cli/generate_test.go +++ b/cli/generate_test.go @@ -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 } @@ -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, diff --git a/cli/sub_gen.go b/cli/sub_gen.go index 8b8149bb..4630443f 100644 --- a/cli/sub_gen.go +++ b/cli/sub_gen.go @@ -90,6 +90,7 @@ Additionally, you can use this syntax ':' 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 ':' 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 ':' 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 ':' 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"+ diff --git a/configs/messages.go b/configs/messages.go index d4b9be4f..4e758ab7 100644 --- a/configs/messages.go +++ b/configs/messages.go @@ -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:" diff --git a/docs/docs/commands/generate.mdx b/docs/docs/commands/generate.mdx index b62661ee..e5d5a5a9 100644 --- a/docs/docs/commands/generate.mdx +++ b/docs/docs/commands/generate.mdx @@ -87,6 +87,7 @@ Flags: -e, --execution string Execution engine client, e.g. geth, nethermind, besu, erigon. Additionally, you can use this syntax ':' 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 ':' 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 ':' 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. diff --git a/docs/docs/quickstart/charon.mdx b/docs/docs/quickstart/charon.mdx index 5607e28e..a4e69322 100644 --- a/docs/docs/quickstart/charon.mdx +++ b/docs/docs/quickstart/charon.mdx @@ -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