From 52311160e96f3e207d97b4b145e458d18164f024 Mon Sep 17 00:00:00 2001 From: Miguel Tenorio <46824157+AntiD2ta@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:27:52 +0200 Subject: [PATCH] fix(cli): Mev-boost not being generated for holesky (#393) --- cli/cli_test.go | 79 +++++++++++++++++++ internal/pkg/generate/generate_scripts.go | 2 + .../envs/holesky/validator/lighthouse.tmpl | 1 + .../envs/holesky/validator/lodestar.tmpl | 1 + templates/envs/holesky/validator/prysm.tmpl | 1 + templates/envs/holesky/validator/teku.tmpl | 1 + 6 files changed, 85 insertions(+) diff --git a/cli/cli_test.go b/cli/cli_test.go index 033503fcc..5c6f68385 100644 --- a/cli/cli_test.go +++ b/cli/cli_test.go @@ -40,6 +40,7 @@ func TestCli(t *testing.T) { log.SetOutput(io.Discard) mevboostRelayListUris, _ := mevboostrelaylist.RelaysURI("mainnet") + holeskyMevboostRelayListUris, _ := mevboostrelaylist.RelaysURI("holesky") ETHClients := map[string][]string{ "execution": clients.AllClients["execution"], @@ -594,6 +595,84 @@ func TestCli(t *testing.T) { ) }, }, + { + name: "full node with Lido, holesky", + setup: func(t *testing.T, sedgeActions *sedge_mocks.MockSedgeActions, prompter *sedge_mocks.MockPrompter, depsMgr *sedge_mocks.MockDependenciesManager) { + generationPath := t.TempDir() + genData := generate.GenData{ + Services: []string{"execution", "consensus", "validator", "mev-boost"}, + ExecutionClient: &clients.Client{ + Name: "nethermind", + Type: "execution", + Image: configs.ClientImages.Execution.Nethermind.String(), + }, + ConsensusClient: &clients.Client{ + Name: "prysm", + Type: "consensus", + Image: configs.ClientImages.Consensus.Prysm.String(), + }, + ValidatorClient: &clients.Client{ + Name: "prysm", + Type: "validator", + Image: configs.ClientImages.Validator.Prysm.String(), + }, + Network: "holesky", + CheckpointSyncUrl: "http://checkpoint.sync", + FeeRecipient: "0xE73a3602b99f1f913e72F8bdcBC235e206794Ac8", + MapAllPorts: true, + Graffiti: "test graffiti", + VLStartGracePeriod: 840, + Mev: true, + MevImage: "flashbots/mev-boost:latest", + RelayURLs: holeskyMevboostRelayListUris, + ContainerTag: "tag", + JWTSecretPath: filepath.Join(generationPath, "jwtsecret"), + } + sedgeActions.EXPECT().GetCommandRunner().Return(&test.SimpleCMDRunner{}) + gomock.InOrder( + prompter.EXPECT().Select("Select node setup", "", []string{sedgeOpts.EthereumNode, sedgeOpts.LidoNode}).Return(1, nil), + prompter.EXPECT().Select("Select network", "", []string{NetworkMainnet, NetworkHolesky, NetworkSepolia}).Return(1, nil), + prompter.EXPECT().Select("Select node type", "", []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}).Return(0, nil), + prompter.EXPECT().Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil).Return(generationPath, nil), + prompter.EXPECT().Input("Container tag, sedge will add to each container and the network, a suffix with the tag", "", false, nil).Return("tag", nil), + prompter.EXPECT().Confirm("Do you want to set up a validator?", true).Return(true, nil), + prompter.EXPECT().Input("Mev-Boost image", "flashbots/mev-boost:latest", false, nil).Return("flashbots/mev-boost:latest", nil), + prompter.EXPECT().Select("Select execution client", "", ETHClients["execution"]).Return(0, nil), + prompter.EXPECT().Select("Select consensus client", "", ETHClients["consensus"]).Return(1, nil), + prompter.EXPECT().Select("Select validator client", "", ETHClients["validator"]).Return(1, nil), + prompter.EXPECT().InputInt64("Validator grace period. This is the number of epochs the validator will wait for security reasons before starting", int64(1)).Return(int64(2), nil), + prompter.EXPECT().Input("Graffiti to be used by the validator (press enter to skip it)", "", false, gomock.AssignableToTypeOf(ui.GraffitiValidator)).Return("test graffiti", nil), + prompter.EXPECT().InputURL("Checkpoint sync URL", configs.NetworksConfigs()[genData.Network].CheckpointSyncURL, false).Return("http://checkpoint.sync", nil), + prompter.EXPECT().Confirm("Do you want to expose all ports?", false).Return(true, nil), + prompter.EXPECT().Select("Select JWT source", "", []string{SourceTypeCreate, SourceTypeExisting}).Return(0, nil), + sedgeActions.EXPECT().Generate(gomock.Eq(actions.GenerateOptions{ + GenerationPath: generationPath, + GenerationData: genData, + })).Return(genData, nil), + prompter.EXPECT().Select("Select keystore source", "", []string{SourceTypeCreate, SourceTypeExisting, SourceTypeSkip}).Return(0, nil), + prompter.EXPECT().Select("Select mnemonic source", "", []string{SourceTypeCreate, SourceTypeExisting}).Return(0, nil), + prompter.EXPECT().Select("Select passphrase source", "", []string{SourceTypeRandom, SourceTypeExisting, SourceTypeCreate}).Return(0, nil), + prompter.EXPECT().InputInt64("Number of validators", int64(1)).Return(int64(1), nil), + prompter.EXPECT().InputInt64("Existing validators. This number will be used as the initial index for the generated keystores.", int64(0)).Return(int64(0), nil), + depsMgr.EXPECT().Check([]string{dependencies.Docker}).Return([]string{dependencies.Docker}, nil), + depsMgr.EXPECT().DockerEngineIsOn().Return(nil), + depsMgr.EXPECT().DockerComposeIsInstalled().Return(nil), + sedgeActions.EXPECT().SetupContainers(actions.SetupContainersOptions{ + GenerationPath: generationPath, + Services: []string{"validator"}, + }), + sedgeActions.EXPECT().ImportValidatorKeys(actions.ImportValidatorKeysOptions{ + ValidatorClient: "prysm", + Network: NetworkHolesky, + GenerationPath: generationPath, + From: filepath.Join(generationPath, "keystore"), + ContainerTag: "tag", + }).Return(nil), + prompter.EXPECT().Confirm("Do you want to import slashing protection data?", false).Return(false, nil), + prompter.EXPECT().Confirm("Run services now?", false).Return(false, nil), + ) + }, + }, } for _, tt := range tests { diff --git a/internal/pkg/generate/generate_scripts.go b/internal/pkg/generate/generate_scripts.go index 424bd4bc9..c904e1c08 100644 --- a/internal/pkg/generate/generate_scripts.go +++ b/internal/pkg/generate/generate_scripts.go @@ -20,6 +20,7 @@ import ( "io" "os" "path/filepath" + "slices" "strings" "text/template" @@ -242,6 +243,7 @@ func ComposeFile(gd *GenData, at io.Writer) error { gd.MevBoostEndpoint = fmt.Sprintf("%s:%v", configs.DefaultMevBoostEndpoint, gd.Ports["MevPort"]) } } + gd.MevBoostService = slices.Contains(gd.Services, "mev-boost") data := DockerComposeData{ Services: gd.Services, diff --git a/templates/envs/holesky/validator/lighthouse.tmpl b/templates/envs/holesky/validator/lighthouse.tmpl index 49b040fdd..f3e2e3b70 100644 --- a/templates/envs/holesky/validator/lighthouse.tmpl +++ b/templates/envs/holesky/validator/lighthouse.tmpl @@ -8,4 +8,5 @@ VL_INSTANCE_NAME=LighthouseValidator VL_IMAGE_VERSION={{.VlImage}} KEYSTORE_DIR={{.KeystoreDir}} VL_DATA_DIR={{.VlDataDir}} +MEV=true {{ end }} \ No newline at end of file diff --git a/templates/envs/holesky/validator/lodestar.tmpl b/templates/envs/holesky/validator/lodestar.tmpl index 3b1ab5cba..814672410 100644 --- a/templates/envs/holesky/validator/lodestar.tmpl +++ b/templates/envs/holesky/validator/lodestar.tmpl @@ -9,4 +9,5 @@ VL_IMAGE_VERSION={{.VlImage}} KEYSTORE_DIR={{.KeystoreDir}} VL_DATA_DIR={{.VlDataDir}} VL_LODESTAR_PRESET=mainnet +MEV=true {{ end }} diff --git a/templates/envs/holesky/validator/prysm.tmpl b/templates/envs/holesky/validator/prysm.tmpl index 91122fbf1..3e73ead0b 100644 --- a/templates/envs/holesky/validator/prysm.tmpl +++ b/templates/envs/holesky/validator/prysm.tmpl @@ -10,4 +10,5 @@ VL_IMAGE_VERSION={{.VlImage}} KEYSTORE_DIR={{.KeystoreDir}} WALLET_DIR=./wallet VL_DATA_DIR={{.VlDataDir}} +MEV=true {{ end }} diff --git a/templates/envs/holesky/validator/teku.tmpl b/templates/envs/holesky/validator/teku.tmpl index 7ca5f6461..49cd6863c 100644 --- a/templates/envs/holesky/validator/teku.tmpl +++ b/templates/envs/holesky/validator/teku.tmpl @@ -8,4 +8,5 @@ VL_INSTANCE_NAME=TekuValidator VL_IMAGE_VERSION={{.VlImage}} KEYSTORE_DIR={{.KeystoreDir}} VL_DATA_DIR={{.VlDataDir}} +MEV=true {{ end }} \ No newline at end of file