diff --git a/cli/actions/actions.go b/cli/actions/actions.go index 09669a843..92d57af6f 100644 --- a/cli/actions/actions.go +++ b/cli/actions/actions.go @@ -25,6 +25,7 @@ import ( //go:generate mockgen -package=sedge_mocks -destination=../../mocks/sedgeActions.go github.com/NethermindEth/sedge/cli/actions SedgeActions type SedgeActions interface { GetCommandRunner() commands.CommandRunner + GetCustomConfigs(GetCustomConfigsOptions) (CustomConfigsResults, error) ImportSlashingInterchangeData(SlashingImportOptions) error ExportSlashingInterchangeData(SlashingExportOptions) error SetupContainers(SetupContainersOptions) error diff --git a/cli/actions/generation.go b/cli/actions/generation.go index c5357663a..2dbb797f1 100644 --- a/cli/actions/generation.go +++ b/cli/actions/generation.go @@ -38,21 +38,6 @@ func (s *sedgeActions) Generate(options GenerateOptions) (generate.GenData, erro } } - // Setup custom configs files if needed - customConfigsPaths, err := generate.CustomNetworkConfigs(options.GenerationPath, options.GenerationData.Network, generate.CustomConfigsSources{ - ChainSpecSrc: options.GenerationData.CustomChainSpecPath, - NetworkConfigSrc: options.GenerationData.CustomNetworkConfigPath, - GenesisSrc: options.GenerationData.CustomGenesisPath, - DeployBlockSrc: options.GenerationData.CustomDeployBlockPath, - }) - if err != nil { - return options.GenerationData, err - } - options.GenerationData.CustomChainSpecPath = customConfigsPaths.ChainSpecPath - options.GenerationData.CustomNetworkConfigPath = customConfigsPaths.NetworkConfigPath - options.GenerationData.CustomGenesisPath = customConfigsPaths.GenesisPath - options.GenerationData.CustomDeployBlockPath = customConfigsPaths.DeployBlockPath - log.Info(configs.GeneratingDockerComposeScript) // open output file out, err := os.Create(filepath.Join(options.GenerationPath, configs.DefaultDockerComposeScriptName)) diff --git a/cli/actions/getCustomConfigs.go b/cli/actions/getCustomConfigs.go new file mode 100644 index 000000000..7be0f52c4 --- /dev/null +++ b/cli/actions/getCustomConfigs.go @@ -0,0 +1,375 @@ +/* +Copyright 2023 Nethermind + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package actions + +import ( + "encoding/json" + "fmt" + "net/url" + "os" + "path" + "strings" + + "github.com/NethermindEth/sedge/configs" + "github.com/NethermindEth/sedge/internal/pkg/generate" + "github.com/NethermindEth/sedge/internal/utils" + "github.com/google/go-github/v54/github" + log "github.com/sirupsen/logrus" +) + +type GetCustomConfigsOptions struct { + GenerationPath string + CustomConfigSource string // a file or github url to folder +} + +type CustomConfigsResults struct { + NetworkID string + DeployBlockValue string + Path string + CustomConfigs map[string]string + ExecutionBootnodes []string + ConsensusBootnodes []string +} + +func (results CustomConfigsResults) ToCustomNetworkData() generate.CustomNetworkData { + return generate.CustomNetworkData{ + // General + Path: results.Path, + NetworkID: results.NetworkID, + // Execution + NethermindChainspec: results.CustomConfigs[configs.NethermindChainspecFileName], + GethGenesis: results.CustomConfigs[configs.GethGenesisFileName], + BesuGenesis: results.CustomConfigs[configs.BesuGenesisFileName], + // Consensus + ConsensusConfig: results.CustomConfigs[configs.ConsensusConfigFileName], + GenesisState: results.CustomConfigs[configs.GenesisStateFileName], + DeployBlock: results.CustomConfigs[configs.DeployBlockFileName], + DeployBlockValue: results.DeployBlockValue, + DepositContract: results.CustomConfigs[configs.DepositContractFileName], + DepositContractBlock: results.CustomConfigs[configs.DepositContractBlockFileName], + DepositContractBlockHash: results.CustomConfigs[configs.DepositContractBlockHashFileName], + TrustedSetupTxt: results.CustomConfigs[configs.TrustedSetupTxtFileName], + TrustedSetupJson: results.CustomConfigs[configs.TrustedSetupJsonFileName], + } +} + +type customConfigItem struct { + fileName string + allowedSourceNames []string +} + +func (s *sedgeActions) GetCustomConfigs(options GetCustomConfigsOptions) (CustomConfigsResults, error) { + log.Info("Getting custom network configs") + results := CustomConfigsResults{} + results.CustomConfigs = map[string]string{} + + sourcePath, err := s.getCustomConfigsSourcePath(options.CustomConfigSource) + if err != nil { + return results, err + } + + customConfigTargets := []customConfigItem{ + // Execution clients custom configs + { + fileName: configs.NethermindChainspecFileName, + allowedSourceNames: []string{ + "nethermind_chainspec.json", + "chainspec.json", + }, + }, + { + fileName: configs.GethGenesisFileName, + allowedSourceNames: []string{ + "geth_genesis.json", + "genesis.json", + }, + }, + { + fileName: configs.BesuGenesisFileName, + allowedSourceNames: []string{ + "besu_genesis.json", + "besu.json", + }, + }, + // Consensus clients custom configs + { + fileName: configs.ConsensusConfigFileName, + allowedSourceNames: []string{ + "config.yaml", + "config.yml", + }, + }, + { + fileName: configs.GenesisStateFileName, + allowedSourceNames: []string{ + "genesis.ssz", + }, + }, + { + fileName: configs.DeployBlockFileName, + allowedSourceNames: []string{ + "deploy_block.txt", + }, + }, + { + fileName: configs.DepositContractFileName, + allowedSourceNames: []string{ + "deposit_contract.txt", + }, + }, + { + fileName: configs.DepositContractBlockFileName, + allowedSourceNames: []string{ + "deposit_contract_block.txt", + }, + }, + { + fileName: configs.DepositContractBlockHashFileName, + allowedSourceNames: []string{ + "deposit_contract_block_hash.txt", + }, + }, + { + fileName: configs.TrustedSetupTxtFileName, + allowedSourceNames: []string{ + "trusted_setup.txt", + }, + }, + { + fileName: configs.TrustedSetupJsonFileName, + allowedSourceNames: []string{ + "trusted_setup.json", + }, + }, + } + + results.Path = path.Join(options.GenerationPath, configs.CustomNetworkConfigsFolder) + err = s.copyCustomConfigs( + sourcePath, + results.Path, + &results, + customConfigTargets, + []string{ + "bootnode.txt", + "bootstrap_nodes_execution.txt", + }, + []string{ + "bootstrap_nodes.txt", + }, + ) + if err != nil { + return results, err + } + + // Get network id + gethPath, gethOk := results.CustomConfigs[configs.GethGenesisFileName] + besuPath, besuOk := results.CustomConfigs[configs.BesuGenesisFileName] + if gethOk && gethPath != "" { + results.NetworkID, err = getNetworkIDFrom(gethPath) + if err != nil { + return results, err + } + } else if besuOk && besuPath != "" { + results.NetworkID, err = getNetworkIDFrom(besuPath) + if err != nil { + return results, err + } + } else { + log.Warn("Network ID not found in custom configs. This is required for some execution clients.") + } + + // Get deploy block + deployBlockFile, ok := results.CustomConfigs[configs.DeployBlockFileName] + if ok && deployBlockFile != "" { + data, err := os.ReadFile(deployBlockFile) + if err != nil { + return results, err + } + results.DeployBlockValue = string(data) + } else { + log.Warn("Deploy Block not found in custom configs. This is required for some consensus clients.") + } + + // Clean temp directory if downloaded + if sourcePath != options.CustomConfigSource { + err = os.RemoveAll(sourcePath) + if err != nil { + return results, err + } + } + + return results, nil +} + +// Get or download custom configs files from source. returns a folder path +func (s sedgeActions) getCustomConfigsSourcePath( + source string, +) (string, error) { + newSourcePath := "" + err := utils.HandleUrlOrPath( + source, + func(rawUrl string) error { + // Download github folder link + // TODO: Non github urls not supported yet + uri, err := url.ParseRequestURI(rawUrl) + if err != nil { + return err + } + if uri.Scheme != "https" { + return fmt.Errorf("invalid url scheme") + } + if uri.Hostname() != "github.com" { + return fmt.Errorf("invalid url hostname") + } + + pathParts := strings.Split(uri.Path, "/") + if len(pathParts) < 5 { + fmt.Println("invalid url path") + } + owner := pathParts[1] + repo := pathParts[2] + ref := pathParts[4] + path := strings.Join(pathParts[5:], "/") + client := github.NewClient(nil) + newSourcePath = os.TempDir() + + err = utils.DownloadGithubObject( + client, + newSourcePath, + owner, + repo, + path, + ref, + ) + return err + }, + func(path string) error { + // Get local folder path + newSourcePath = path + return nil + }, + ) + return newSourcePath, err +} + +// Copy custom configs files from source +func (s sedgeActions) copyCustomConfigs( + sourcePath string, + destPath string, + results *CustomConfigsResults, + copyTargets []customConfigItem, + executionBootnodesAllowedNames []string, + consensusBootnodesAllowedNames []string, +) error { + contents, err := os.ReadDir(sourcePath) + if err != nil { + return err + } + + for _, item := range contents { + if item.IsDir() { + continue + } + // Execution bootnodes + for _, allowedName := range executionBootnodesAllowedNames { + if item.Name() == allowedName { + bootnodes, err := s.extractBootnodesFromFile(path.Join(sourcePath, item.Name())) + if err != nil { + return fmt.Errorf("error extracting bootnodes from file %s: %v", item.Name(), err) + } + results.ExecutionBootnodes = append(results.ExecutionBootnodes, bootnodes...) + break + } + } + // Consensus bootnodes + for _, allowedName := range consensusBootnodesAllowedNames { + if item.Name() == allowedName { + bootnodes, err := s.extractBootnodesFromFile(path.Join(sourcePath, item.Name())) + if err != nil { + return fmt.Errorf("error extracting bootnodes from file %s: %v", item.Name(), err) + } + results.ConsensusBootnodes = append(results.ConsensusBootnodes, bootnodes...) + break + } + } + // Other custom config file + targetsLoop: + for _, target := range copyTargets { + _, ok := results.CustomConfigs[target.fileName] + if ok { + continue + } + for _, allowedName := range target.allowedSourceNames { + if item.Name() == allowedName { + srcPath := path.Join(sourcePath, item.Name()) + dstPath := path.Join(destPath, target.fileName) + if err = utils.CopyFile(srcPath, dstPath); err != nil { + return fmt.Errorf(configs.ErrorCopyingFile, srcPath, err) + } + results.CustomConfigs[target.fileName] = dstPath + break targetsLoop + } + } + } + } + + return nil +} + +// Extract bootnodes from file +func (s sedgeActions) extractBootnodesFromFile( + filePath string, +) ([]string, error) { + bootnodes := []string{} + + bytes, err := os.ReadFile(filePath) + if err != nil { + return bootnodes, err + } + + rawBootnodes := string(bytes) + for _, line := range strings.Split(rawBootnodes, "\n") { + trimmedLine := strings.TrimSpace(line) + for _, part := range strings.Split(trimmedLine, " ") { + if part != "" && (strings.HasPrefix(part, "enode://") || strings.HasPrefix(part, "enr:")) { + bootnodes = append(bootnodes, part) + } + } + } + + return bootnodes, nil +} + +func getNetworkIDFrom( + gethGenesisFile string, +) (string, error) { + data, err := os.ReadFile(gethGenesisFile) + if err != nil { + return "", err + } + + var genesis struct { + Config struct { + ChainID int `json:"chainId"` + } `json:"config"` + } + + if err = json.Unmarshal(data, &genesis); err != nil { + return "", err + } + + return fmt.Sprintf("%d", genesis.Config.ChainID), nil +} diff --git a/cli/cli.go b/cli/cli.go index 4a9096e11..00ac45cbc 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -63,6 +63,7 @@ var ErrCancelled = errors.New("cancelled by the user") type CliCmdOptions struct { genData generate.GenData + customConfigsSource string generationPath string nodeType string withValidator bool @@ -133,11 +134,7 @@ func setupFullNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, deps } if o.genData.Network == NetworkCustom { if err := runPromptActions(p, o, - inputCustomNetworkConfig, - inputCustomChainSpec, - inputCustomGenesis, - inputCustomTTD, - inputCustomDeployBlock, + inputCustomConfigSource, inputExecutionBootNodes, inputConsensusBootNodes, ); err != nil { @@ -190,6 +187,25 @@ func setupFullNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, deps if err := setupJWT(p, o, false); err != nil { return err } + // Handle custom config source + customConfigsSource := o.customConfigsSource + if customConfigsSource == "" { + customConfigsSource = configs.NetworksConfigs()[network].DefaultCustomConfigSrc + } + if customConfigsSource != "" { + customNetworkData, err := a.GetCustomConfigs( + actions.GetCustomConfigsOptions{ + GenerationPath: generationPath, + CustomConfigSource: customConfigsSource, + }, + ) + if err != nil { + return fmt.Errorf(configs.ErrLoadingCustomConfigs, err) + } + o.genData.CustomNetwork = customNetworkData.ToCustomNetworkData() + o.genData.ECBootnodes = append(o.genData.ECBootnodes, customNetworkData.ExecutionBootnodes...) + o.genData.CCBootnodes = append(o.genData.CCBootnodes, customNetworkData.ConsensusBootnodes...) + } // Call generate action o.genData, err = a.Generate(actions.GenerateOptions{ GenerationData: o.genData, @@ -208,8 +224,7 @@ func setupExecutionNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, } if o.genData.Network == NetworkCustom { if err := runPromptActions(p, o, - inputCustomChainSpec, - inputCustomTTD, + inputCustomConfigSource, inputExecutionBootNodes, ); err != nil { return err @@ -221,6 +236,25 @@ func setupExecutionNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, if err := setupJWT(p, o, true); err != nil { return err } + // Handle custom config source + customConfigsSource := o.customConfigsSource + if customConfigsSource == "" { + customConfigsSource = configs.NetworksConfigs()[network].DefaultCustomConfigSrc + } + if customConfigsSource != "" { + customNetworkData, err := a.GetCustomConfigs( + actions.GetCustomConfigsOptions{ + GenerationPath: generationPath, + CustomConfigSource: customConfigsSource, + }, + ) + if err != nil { + return fmt.Errorf(configs.ErrLoadingCustomConfigs, err) + } + o.genData.CustomNetwork = customNetworkData.ToCustomNetworkData() + o.genData.ECBootnodes = append(o.genData.ECBootnodes, customNetworkData.ExecutionBootnodes...) + o.genData.CCBootnodes = append(o.genData.CCBootnodes, customNetworkData.ConsensusBootnodes...) + } o.genData, err = a.Generate(actions.GenerateOptions{ GenerationData: o.genData, GenerationPath: o.generationPath, @@ -238,9 +272,7 @@ func setupConsensusNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, } if o.genData.Network == NetworkCustom { if err := runPromptActions(p, o, - inputCustomNetworkConfig, - inputCustomGenesis, - inputCustomDeployBlock, + inputCustomConfigSource, inputConsensusBootNodes, ); err != nil { return err @@ -266,6 +298,25 @@ func setupConsensusNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, if err := setupJWT(p, o, true); err != nil { return err } + // Handle custom config source + customConfigsSource := o.customConfigsSource + if customConfigsSource == "" { + customConfigsSource = configs.NetworksConfigs()[network].DefaultCustomConfigSrc + } + if customConfigsSource != "" { + customNetworkData, err := a.GetCustomConfigs( + actions.GetCustomConfigsOptions{ + GenerationPath: generationPath, + CustomConfigSource: customConfigsSource, + }, + ) + if err != nil { + return fmt.Errorf(configs.ErrLoadingCustomConfigs, err) + } + o.genData.CustomNetwork = customNetworkData.ToCustomNetworkData() + o.genData.ECBootnodes = append(o.genData.ECBootnodes, customNetworkData.ExecutionBootnodes...) + o.genData.CCBootnodes = append(o.genData.CCBootnodes, customNetworkData.ConsensusBootnodes...) + } o.genData, err = a.Generate(actions.GenerateOptions{ GenerationData: o.genData, GenerationPath: o.generationPath, @@ -283,9 +334,7 @@ func setupValidatorNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, } if o.genData.Network == NetworkCustom { if err := runPromptActions(p, o, - inputCustomNetworkConfig, - inputCustomGenesis, - inputCustomDeployBlock, + inputCustomConfigSource, ); err != nil { return err } @@ -304,6 +353,25 @@ func setupValidatorNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, } o.genData.MevBoostOnValidator = o.withMevBoost } + // Handle custom config source + customConfigsSource := o.customConfigsSource + if customConfigsSource == "" { + customConfigsSource = configs.NetworksConfigs()[network].DefaultCustomConfigSrc + } + if customConfigsSource != "" { + customNetworkData, err := a.GetCustomConfigs( + actions.GetCustomConfigsOptions{ + GenerationPath: generationPath, + CustomConfigSource: customConfigsSource, + }, + ) + if err != nil { + return fmt.Errorf(configs.ErrLoadingCustomConfigs, err) + } + o.genData.CustomNetwork = customNetworkData.ToCustomNetworkData() + o.genData.ECBootnodes = append(o.genData.ECBootnodes, customNetworkData.ExecutionBootnodes...) + o.genData.CCBootnodes = append(o.genData.CCBootnodes, customNetworkData.ConsensusBootnodes...) + } o.genData, err = a.Generate(actions.GenerateOptions{ GenerationData: o.genData, GenerationPath: o.generationPath, @@ -535,9 +603,9 @@ func generateKeystore(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, d From: o.keystorePath, ContainerTag: o.genData.ContainerTag, CustomConfig: actions.ImportValidatorKeysCustomOptions{ - NetworkConfigPath: o.genData.CustomNetworkConfigPath, - GenesisPath: o.genData.CustomGenesisPath, - DeployBlockPath: o.genData.CustomDeployBlockPath, + NetworkConfigPath: o.genData.CustomNetwork.ConsensusConfig, + GenesisPath: o.genData.CustomNetwork.GenesisState, + DeployBlockPath: o.genData.CustomNetwork.DeployBlock, }, }) if err != nil { @@ -802,38 +870,12 @@ func confirmEnableMEVBoost(p ui.Prompter, o *CliCmdOptions) (err error) { return } -func inputCustomNetworkConfig(p ui.Prompter, o *CliCmdOptions) (err error) { - o.genData.CustomNetworkConfigPath, err = p.InputFilePath("Custom network config file path", "", true, ".yml", ".yaml") - if err != nil { - return err - } - return absPathInPlace(&o.genData.CustomNetworkConfigPath) -} - -func inputCustomChainSpec(p ui.Prompter, o *CliCmdOptions) (err error) { - o.genData.CustomChainSpecPath, err = p.InputFilePath("File path or url to use as custom network chainSpec for execution client", "", true, ".json") - if err != nil { - return err - } - return absPathInPlace(&o.genData.CustomChainSpecPath) -} - -func inputCustomGenesis(p ui.Prompter, o *CliCmdOptions) (err error) { - o.genData.CustomGenesisPath, err = p.InputFilePath("File path or URL to use as custom network genesis for consensus client", "", true, ".ssz") +func inputCustomConfigSource(p ui.Prompter, o *CliCmdOptions) (err error) { + o.customConfigsSource, err = p.InputFilePath("Custom network configs sources file path or url", "", true) if err != nil { return err } - return absPathInPlace(&o.genData.CustomGenesisPath) -} - -func inputCustomTTD(p ui.Prompter, o *CliCmdOptions) (err error) { - o.genData.CustomTTD, err = p.Input("Custom TTD (Terminal Total Difficulty)", "0", false, ui.DigitsStringValidator) - return -} - -func inputCustomDeployBlock(p ui.Prompter, o *CliCmdOptions) (err error) { - o.genData.CustomDeployBlock, err = p.Input("Custom deploy block", "0", false, ui.DigitsStringValidator) - return + return absPathInPlace(&o.customConfigsSource) } func inputExecutionBootNodes(p ui.Prompter, o *CliCmdOptions) (err error) { diff --git a/cli/generate.go b/cli/generate.go index 5c30a866c..f06c5b030 100644 --- a/cli/generate.go +++ b/cli/generate.go @@ -48,41 +48,33 @@ const ( execution, consensus, validator, mevBoost = "execution", "consensus", "validator", "mev-boost" ) -type CustomFlags struct { - customTTD string - customChainSpec string - customNetworkConfig string - customGenesis string - customDeployBlock string -} - // GenCmdFlags is a struct that holds the flags of the generate command type GenCmdFlags struct { - CustomFlags - executionName string - consensusName string - validatorName 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 - relayURLs []string - mevBoostUrl string - executionApiUrl string - executionAuthUrl string - consensusApiUrl string - waitEpoch int - customEnodes []string - customEnrs []string + executionName string + consensusName string + validatorName 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 + relayURLs []string + mevBoostUrl string + executionApiUrl string + executionAuthUrl string + consensusApiUrl string + waitEpoch int + customConfigsSource string + customEnodes []string + customEnrs []string } func GenerateCmd(sedgeAction actions.SedgeActions) *cobra.Command { @@ -264,42 +256,56 @@ func runGenCmd(out io.Writer, flags *GenCmdFlags, sedgeAction actions.SedgeActio vlStartGracePeriod := configs.NetworkEpochTime(network) * time.Duration(flags.waitEpoch) + // Handle custom config source + customConfigsSource := flags.customConfigsSource + if customConfigsSource == "" { + customConfigsSource = configs.NetworksConfigs()[network].DefaultCustomConfigSrc + } + var customNetworkData actions.CustomConfigsResults + if customConfigsSource != "" { + customNetworkData, err = sedgeAction.GetCustomConfigs( + actions.GetCustomConfigsOptions{ + GenerationPath: generationPath, + CustomConfigSource: customConfigsSource, + }, + ) + if err != nil { + return fmt.Errorf(configs.ErrLoadingCustomConfigs, err) + } + } + // Generate docker-compose scripts gd := generate.GenData{ - ExecutionClient: combinedClients.Execution, - ConsensusClient: combinedClients.Consensus, - ValidatorClient: combinedClients.Validator, - Network: network, - CheckpointSyncUrl: flags.checkpointSyncUrl, - FeeRecipient: flags.feeRecipient, - JWTSecretPath: flags.jwtPath, - Graffiti: flags.graffiti, - FallbackELUrls: flags.fallbackEL, - ElExtraFlags: flags.elExtraFlags, - ClExtraFlags: flags.clExtraFlags, - VlExtraFlags: flags.vlExtraFlags, - MapAllPorts: flags.mapAllPorts, - Mev: !flags.noMev && utils.Contains(services, validator) && utils.Contains(services, consensus) && !flags.noValidator, - MevImage: flags.mevImage, - LoggingDriver: configs.GetLoggingDriver(logging), - RelayURLs: flags.relayURLs, - MevBoostService: utils.Contains(services, mevBoost), - MevBoostEndpoint: flags.mevBoostUrl, - Services: services, - VLStartGracePeriod: uint(vlStartGracePeriod.Seconds()), - ExecutionApiUrl: flags.executionApiUrl, - ExecutionAuthUrl: flags.executionAuthUrl, - ConsensusApiUrl: flags.consensusApiUrl, - ECBootnodes: flags.customEnodes, - CCBootnodes: flags.customEnrs, - CustomTTD: flags.customTTD, - CustomChainSpecPath: flags.CustomFlags.customChainSpec, - CustomNetworkConfigPath: flags.CustomFlags.customNetworkConfig, - CustomGenesisPath: flags.CustomFlags.customGenesis, - CustomDeployBlock: flags.customDeployBlock, - CustomDeployBlockPath: flags.CustomFlags.customDeployBlock, - MevBoostOnValidator: flags.mevBoostOnVal, - ContainerTag: containerTag, + ExecutionClient: combinedClients.Execution, + ConsensusClient: combinedClients.Consensus, + ValidatorClient: combinedClients.Validator, + Network: network, + CheckpointSyncUrl: flags.checkpointSyncUrl, + FeeRecipient: flags.feeRecipient, + JWTSecretPath: flags.jwtPath, + Graffiti: flags.graffiti, + FallbackELUrls: flags.fallbackEL, + ElExtraFlags: flags.elExtraFlags, + ClExtraFlags: flags.clExtraFlags, + VlExtraFlags: flags.vlExtraFlags, + MapAllPorts: flags.mapAllPorts, + Mev: !flags.noMev && utils.Contains(services, validator) && utils.Contains(services, consensus) && !flags.noValidator, + MevImage: flags.mevImage, + LoggingDriver: configs.GetLoggingDriver(logging), + RelayURLs: flags.relayURLs, + MevBoostService: utils.Contains(services, mevBoost), + MevBoostEndpoint: flags.mevBoostUrl, + Services: services, + VLStartGracePeriod: uint(vlStartGracePeriod.Seconds()), + ExecutionApiUrl: flags.executionApiUrl, + ExecutionAuthUrl: flags.executionAuthUrl, + ConsensusApiUrl: flags.consensusApiUrl, + ECBootnodes: append(flags.customEnodes, customNetworkData.ExecutionBootnodes...), + CCBootnodes: append(flags.customEnrs, customNetworkData.ConsensusBootnodes...), + MevBoostOnValidator: flags.mevBoostOnVal, + ContainerTag: containerTag, + // Custom Network Data + CustomNetwork: customNetworkData.ToCustomNetworkData(), } _, err = sedgeAction.Generate(actions.GenerateOptions{ GenerationData: gd, diff --git a/cli/generate_test.go b/cli/generate_test.go index d43fff0a3..5ae2c337b 100644 --- a/cli/generate_test.go +++ b/cli/generate_test.go @@ -126,20 +126,8 @@ func (flags *GenCmdFlags) argsList() []string { if flags.mapAllPorts { s = append(s, "--map-all") } - if flags.customTTD != "" { - s = append(s, "--custom-ttd", flags.customTTD) - } - if flags.customChainSpec != "" { - s = append(s, "--custom-chainSpec", flags.customChainSpec) - } - if flags.customNetworkConfig != "" { - s = append(s, "--custom-config", flags.customNetworkConfig) - } - if flags.customGenesis != "" { - s = append(s, "--custom-genesis", flags.customGenesis) - } - if flags.customDeployBlock != "" { - s = append(s, "--custom-deploy-block", flags.customDeployBlock) + if flags.customConfigsSource != "" { + s = append(s, "--custom-configs", flags.customConfigsSource) } if len(flags.customEnodes) > 0 { s = append(s, "--execution-bootnodes", strings.Join(flags.customEnodes, ",")) @@ -1037,9 +1025,7 @@ func TestGenerateCmd(t *testing.T) { name: "full-node", }, GenCmdFlags{ - CustomFlags: CustomFlags{ - customTTD: "some", - }, + customConfigsSource: "some", }, globalFlags{ network: "mainnet", @@ -1052,10 +1038,8 @@ func TestGenerateCmd(t *testing.T) { name: "full-node", }, GenCmdFlags{ - feeRecipient: "0x0000000000000000000000000000000000000000", - CustomFlags: CustomFlags{ - customTTD: "some", - }, + feeRecipient: "0x0000000000000000000000000000000000000000", + customConfigsSource: "some", }, globalFlags{ network: "custom", @@ -1068,9 +1052,7 @@ func TestGenerateCmd(t *testing.T) { name: "execution", }, GenCmdFlags{ - CustomFlags: CustomFlags{ - customTTD: "some", - }, + customConfigsSource: "some", }, globalFlags{ network: "custom", @@ -1083,9 +1065,7 @@ func TestGenerateCmd(t *testing.T) { name: "execution", }, GenCmdFlags{ - CustomFlags: CustomFlags{ - customTTD: "some", - }, + customConfigsSource: "some", }, globalFlags{ network: "mainnet", @@ -1098,10 +1078,8 @@ func TestGenerateCmd(t *testing.T) { name: "full-node", }, GenCmdFlags{ - feeRecipient: "0x0000000000000000000000000000000000000000", - CustomFlags: CustomFlags{ - customTTD: "some", - }, + feeRecipient: "0x0000000000000000000000000000000000000000", + customConfigsSource: "some", }, globalFlags{ network: "custom", diff --git a/cli/sub_gen.go b/cli/sub_gen.go index faed841c4..04a95d10b 100644 --- a/cli/sub_gen.go +++ b/cli/sub_gen.go @@ -24,10 +24,9 @@ import ( var ErrCustomFlagsUsedWithoutCustomNetwork = errors.New("custom flags used without --network custom") -func validateCustomNetwork(flags *CustomFlags, net string) error { +func validateCustomNetwork(flags *GenCmdFlags, net string) error { if net != "custom" { - if len(flags.customTTD) != 0 || len(flags.customChainSpec) != 0 || len(flags.customNetworkConfig) != 0 || - len(flags.customGenesis) != 0 || len(flags.customDeployBlock) != 0 { + if len(flags.customConfigsSource) != 0 { // TODO add error on expected place return ErrCustomFlagsUsedWithoutCustomNetwork } @@ -52,7 +51,7 @@ If you don't provide a execution, consensus or validator client, it will be chos Additionally, you can use this syntax ':' to override the docker image used for the client, for example 'sedge generate full-node --execution nethermind:docker.image'. If you want to use the default docker image, just use the client name`, Args: cobra.NoArgs, PreRunE: func(cmd *cobra.Command, args []string) error { - if err := validateCustomNetwork(&flags.CustomFlags, network); err != nil { + if err := validateCustomNetwork(&flags, network); err != nil { return err } return preValidationGenerateCmd(network, logging, &flags) @@ -90,11 +89,7 @@ Additionally, you can use this syntax ':' to override the cmd.Flags().StringArrayVar(&flags.elExtraFlags, "el-extra-flag", []string{}, "Additional flag to configure the execution client service in the generated docker-compose script. Example: 'sedge generate full-node --el-extra-flag \"=value1\" --el-extra-flag \"=\\\"value2\\\"\"'") cmd.Flags().StringArrayVar(&flags.clExtraFlags, "cl-extra-flag", []string{}, "Additional flag to configure the consensus client service in the generated docker-compose script. Example: 'sedge generate full-node --cl-extra-flag \"=value1\" --cl-extra-flag \"=\\\"value2\\\"\"'") cmd.Flags().StringArrayVar(&flags.vlExtraFlags, "vl-extra-flag", []string{}, "Additional flag to configure the validator client service in the generated docker-compose script. Example: 'sedge generate full-node --vl-extra-flag \"=value1\" --vl-extra-flag \"=\\\"value2\\\"\"'") - cmd.Flags().StringVar(&flags.customTTD, "custom-ttd", "", "Custom Terminal Total Difficulty to use for the execution client") - cmd.Flags().StringVar(&flags.customChainSpec, "custom-chainSpec", "", "File path or url to use as custom network chainSpec for execution client.") - cmd.Flags().StringVar(&flags.customNetworkConfig, "custom-config", "", "File path or url to use as custom network config file for consensus client.") - cmd.Flags().StringVar(&flags.customGenesis, "custom-genesis", "", "File path or url to use as custom network genesis for consensus client.") - cmd.Flags().StringVar(&flags.customDeployBlock, "custom-deploy-block", "", "Custom network deploy block to use for consensus client.") + cmd.Flags().StringVar(&flags.customConfigsSource, "custom-configs", "", "Path or Github url to custom network configs. The github url must be a url to the folder containing the custom network configs in the format 'https://github.com///tree//path/to/folder'.") cmd.Flags().IntVar(&flags.waitEpoch, "wait-epoch", 1, "Number of epochs to wait before starting and restarting of the validator client.") cmd.Flags().StringSliceVar(&flags.customEnodes, "execution-bootnodes", []string{}, "List of comma separated enodes to use as custom network peers for execution client.") cmd.Flags().StringSliceVar(&flags.customEnrs, "consensus-bootnodes", []string{}, "List of comma separated enrs to use as custom network peers for consensus client.") @@ -122,7 +117,7 @@ func ExecutionSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { return nil }, PreRunE: func(cmd *cobra.Command, args []string) error { - if err := validateCustomNetwork(&flags.CustomFlags, network); err != nil { + if err := validateCustomNetwork(&flags, network); err != nil { return err } return preValidationGenerateCmd(network, logging, &flags) @@ -135,8 +130,7 @@ func ExecutionSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { // Bind flags cmd.Flags().StringVar(&flags.jwtPath, "jwt-secret-path", "", "Path to the JWT secret file") cmd.Flags().BoolVar(&flags.mapAllPorts, "map-all", false, "Map all clients ports to host. Use with care. Useful to allow remote access to the clients") - cmd.Flags().StringVar(&flags.customTTD, "custom-ttd", "", "Custom Terminal Total Difficulty to use for the execution client") - cmd.Flags().StringVar(&flags.customChainSpec, "custom-chainSpec", "", "File path or url to use as custom network chainSpec for execution client.") + cmd.Flags().StringVar(&flags.customConfigsSource, "custom-configs", "", "Path or Github url to custom network configs. The github url must be a url to the folder containing the custom network configs in the format 'https://github.com///tree//path/to/folder'.") cmd.Flags().StringSliceVar(&flags.customEnodes, "execution-bootnodes", []string{}, "List of comma separated enodes to use as custom network peers for execution client.") cmd.Flags().StringArrayVar(&flags.elExtraFlags, "el-extra-flag", []string{}, "Additional flag to configure the execution client service in the generated docker-compose script. Example: 'sedge generate consensus--el-extra-flag \"=value1\" --el-extra-flag \"=\\\"value2\\\"\"'") cmd.Flags().SortFlags = false @@ -167,7 +161,7 @@ func ConsensusSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { return nil }, PreRunE: func(cmd *cobra.Command, args []string) error { - if err := validateCustomNetwork(&flags.CustomFlags, network); err != nil { + if err := validateCustomNetwork(&flags, network); err != nil { return err } return preValidationGenerateCmd(network, logging, &flags) @@ -186,9 +180,7 @@ func ConsensusSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { cmd.Flags().BoolVar(&flags.mapAllPorts, "map-all", false, "Map all clients ports to host. Use with care. Useful to allow remote access to the clients") cmd.Flags().StringSliceVar(&flags.fallbackEL, "fallback-execution-urls", []string{}, "Fallback/backup execution endpoints for the consensus client. Not supported by Teku. Example: 'sedge generate consensus --fallback-execution=https://mainnet.infura.io/v3/YOUR-PROJECT-ID,https://eth-mainnet.alchemyapi.io/v2/YOUR-PROJECT-ID'") cmd.Flags().StringArrayVar(&flags.clExtraFlags, "cl-extra-flag", []string{}, "Additional flag to configure the consensus client service in the generated docker-compose script. Example: 'sedge generate consensus --cl-extra-flag \"=value1\" --cl-extra-flag \"=\\\"value2\\\"\"'") - cmd.Flags().StringVar(&flags.customNetworkConfig, "custom-config", "", "File path or url to use as custom network config file for consensus client.") - cmd.Flags().StringVar(&flags.customGenesis, "custom-genesis", "", "File path or url to use as custom network genesis for consensus client.") - cmd.Flags().StringVar(&flags.customDeployBlock, "custom-deploy-block", "", "Custom network deploy block to use for consensus client.") + cmd.Flags().StringVar(&flags.customConfigsSource, "custom-configs", "", "Path or Github url to custom network configs. The github url must be a url to the folder containing the custom network configs in the format 'https://github.com///tree//path/to/folder'.") cmd.Flags().StringSliceVar(&flags.customEnrs, "consensus-bootnodes", []string{}, "List of comma separated enrs to use as custom network peers for consensus client.") err := cmd.MarkFlagRequired("execution-api-url") if err != nil { @@ -225,7 +217,7 @@ func ValidatorSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { return nil }, PreRunE: func(cmd *cobra.Command, args []string) error { - if err := validateCustomNetwork(&flags.CustomFlags, network); err != nil { + if err := validateCustomNetwork(&flags, network); err != nil { return err } return preValidationGenerateCmd(network, logging, &flags) @@ -240,9 +232,7 @@ func ValidatorSubCmd(sedgeAction actions.SedgeActions) *cobra.Command { 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") cmd.Flags().StringVar(&flags.graffiti, "graffiti", "", "Graffiti to be used by the validator") cmd.Flags().BoolVar(&flags.mevBoostOnVal, "mev-boost", false, "Use mev-boost while turning on validator node") - cmd.Flags().StringVar(&flags.customNetworkConfig, "custom-config", "", "File path or url to use as custom network config file for consensus client.") - cmd.Flags().StringVar(&flags.customGenesis, "custom-genesis", "", "File path or url to use as custom network genesis for consensus client.") - cmd.Flags().StringVar(&flags.customDeployBlock, "custom-deploy-block", "", "Custom network deploy block to use for consensus client.") + cmd.Flags().StringVar(&flags.customConfigsSource, "custom-configs", "", "Path or Github url to custom network configs. The github url must be a url to the folder containing the custom network configs in the format 'https://github.com///tree//path/to/folder'.") cmd.Flags().IntVar(&flags.waitEpoch, "wait-epoch", 1, "Number of epochs to wait before starting and restarting of the validator client.") cmd.Flags().StringArrayVar(&flags.vlExtraFlags, "vl-extra-flag", []string{}, "Additional flag to configure the validator client service in the generated docker-compose script. Example: 'sedge generate validator --vl-extra-flag \"=value1\" --vl-extra-flag \"=\\\"value2\\\"\"'") err := cmd.MarkFlagRequired("consensus-url") diff --git a/configs/errors.go b/configs/errors.go index abdedcae5..625289130 100644 --- a/configs/errors.go +++ b/configs/errors.go @@ -84,4 +84,5 @@ const ( ErrDuplicatedBootNode = "duplicated boot node" ErrGraffitiLength = "graffiti must have 16 characters at most. Provided graffiti %s has %d characters" ErrCMDArgsNotSupported = "command %s does not support arguments. Please use flags instead" + ErrLoadingCustomConfigs = "error loading custom configs: %w" ) diff --git a/configs/init.go b/configs/init.go index 3ccb97447..d6586d0d3 100644 --- a/configs/init.go +++ b/configs/init.go @@ -22,7 +22,6 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ NetworkService: "merge", GenesisForkVersion: "0x00000000", SupportsMEVBoost: true, - DefaultTTD: "", DefaultECBootnodes: []string{ "enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303", "enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303", @@ -51,7 +50,6 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ NetworkService: "merge", GenesisForkVersion: "0x00001020", SupportsMEVBoost: true, - DefaultTTD: "10790000", DefaultECBootnodes: []string{ "enode://011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a@51.141.78.53:30303", "enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303", @@ -82,7 +80,6 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ NetworkService: "merge", GenesisForkVersion: "0x90000069", SupportsMEVBoost: false, - DefaultTTD: "17000000000000000", DefaultCCBootnodes: []string{ "enr:-Iq4QMCTfIMXnow27baRUb35Q8iiFHSIDBJh6hQM5Axohhf4b6Kr_cOCu0htQ5WvVqKvFgY28893DHAg8gnBAXsAVqmGAX53x8JggmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk", "enr:-Ly4QFoZTWR8ulxGVsWydTNGdwEESueIdj-wB6UmmjUcm-AOPxnQi7wprzwcdo7-1jBW_JxELlUKJdJES8TDsbl1EdNlh2F0dG5ldHOI__78_v2bsV-EZXRoMpA2-lATkAAAcf__________gmlkgnY0gmlwhBLYJjGJc2VjcDI1NmsxoQI0gujXac9rMAb48NtMqtSTyHIeNYlpjkbYpWJw46PmYYhzeW5jbmV0cw-DdGNwgiMog3VkcIIjKA", @@ -95,14 +92,11 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ }, }, NetworkChiado: { - Name: NetworkChiado, - RequireJWT: true, - NetworkService: "merge", - GenesisForkVersion: "0x0000006f", - DefaultTTD: "231707791542740786049188744689299064356246512", - DefaultCustomConfigSrc: "https://github.com/gnosischain/configs/raw/main/chiado/config.yaml", - DefaultCustomGenesisSrc: "https://github.com/gnosischain/configs/raw/main/chiado/genesis.ssz", - DefaultCustomDeployBlock: "0", + Name: NetworkChiado, + RequireJWT: true, + NetworkService: "merge", + GenesisForkVersion: "0x0000006f", + DefaultCustomConfigSrc: "https://github.com/gnosischain/configs/tree/main/chiado", DefaultCCBootnodes: []string{ "enr:-L64QOijsdi9aVIawMb5h5PWueaPM9Ai6P17GNPFlHzz7MGJQ8tFMdYrEx8WQitNKLG924g2Q9cCdzg54M0UtKa3QIKCMxaHYXR0bmV0c4j__________4RldGgykDE2cEMCAABv__________-CaWSCdjSCaXCEi5AaWYlzZWNwMjU2azGhA8CjTkD4m1s8FbKCN18LgqlYcE65jrT148vFtwd9U62SiHN5bmNuZXRzD4N0Y3CCIyiDdWRwgiMo", "enr:-L64QKYKGQj5ybkfBxyFU5IEVzP7oJkGHJlie4W8BCGAYEi4P0mmMksaasiYF789mVW_AxYVNVFUjg9CyzmdvpyWQ1KCMlmHYXR0bmV0c4j__________4RldGgykDE2cEMCAABv__________-CaWSCdjSCaXCEi5CtNolzZWNwMjU2azGhAuA7BAwIijy1z81AO9nz_MOukA1ER68rGA67PYQ5pF1qiHN5bmNuZXRzD4N0Y3CCIyiDdWRwgiMo", @@ -118,7 +112,6 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ RequireJWT: true, NetworkService: "merge", GenesisForkVersion: "0x00000064", - DefaultTTD: "8626000000000000000000058750000000000000000000", DefaultECBootnodes: []string{ "enode://ea6d67eb3277d8ae9292fc700fa757ef6d2127c4db9712bcd5eb1341b1d937ac71cc2b15efe3a8496f4fc9fc12156d7ac73d82eb3c0f68928442116030b76f48@3.135.122.4:30303", "enode://c5e1e38709a2eb402557e82e071ccec1c6e2adedb01f7d6afdc80d25f7e9287f954fa9b742f01b1b74a5c532de9476afeb6efdcf5a683672a663204eadb15e45@3.17.46.220:30303", @@ -139,7 +132,7 @@ var networksConfigs map[string]NetworkConfig = map[string]NetworkConfig{ Name: NetworkCustom, RequireJWT: true, NetworkService: "merge", - GenesisForkVersion: "0x00000000", // TODO: only affects keystores generation, ensure the deposit method does not conflict over this. + GenesisForkVersion: "0x00000000", // FIXME: only affects keystores generation, ensure the deposit method does not conflict over this. }, } diff --git a/configs/paths.go b/configs/paths.go index 1912a04c2..8bd085e6e 100644 --- a/configs/paths.go +++ b/configs/paths.go @@ -16,15 +16,25 @@ limitations under the License. package configs const ( - ConfigFileName = ".sedge" - CustomNetworkConfigsFolder = "./custom_configs" - DefaultDockerComposeScriptName = "docker-compose.yml" - ExecutionNetworkConfigFileName = "chainSpec.json" - ConsensusNetworkConfigFileName = "config.yaml" - ConsensusNetworkGenesisFileName = "genesis.ssz" - ConsensusNetworkDeployBlockFileName = "deploy_block.txt" - ExecutionDir = "execution-data" - ConsensusDir = "consensus-data" - ValidatorDir = "validator-data" - KeystoreDir = "keystore" + ConfigFileName = ".sedge" + DefaultDockerComposeScriptName = "docker-compose.yml" + ExecutionDir = "execution-data" + ConsensusDir = "consensus-data" + ValidatorDir = "validator-data" + KeystoreDir = "keystore" + // Custom network configs file names + CustomNetworkConfigsFolder = "custom-configs" + // Execution clients custom configs file names + NethermindChainspecFileName = "nethermind_chainspec.json" + GethGenesisFileName = "geth_genesis.json" + BesuGenesisFileName = "besu_genesis.json" + // Consensus clients custom configs file names + ConsensusConfigFileName = "config.yaml" + GenesisStateFileName = "genesis.ssz" + DeployBlockFileName = "deploy_block.txt" + DepositContractFileName = "deposit_contract.txt" + DepositContractBlockFileName = "deposit_contract_block.txt" + DepositContractBlockHashFileName = "deposit_contract_block_hash.txt" + TrustedSetupTxtFileName = "trusted_setup.txt" + TrustedSetupJsonFileName = "trusted_setup.json" ) diff --git a/configs/types.go b/configs/types.go index 3726aab09..b974cab7a 100644 --- a/configs/types.go +++ b/configs/types.go @@ -21,18 +21,14 @@ type LogConfig struct { } type NetworkConfig struct { - Name string - RequireJWT bool - NetworkService string - GenesisForkVersion string - DefaultTTD string - DefaultECBootnodes []string - DefaultCCBootnodes []string - DefaultCustomChainSpecSrc string - DefaultCustomConfigSrc string - DefaultCustomGenesisSrc string - DefaultCustomDeployBlock string - SupportsMEVBoost bool - CheckpointSyncURL string - RelayURLs []string + Name string + RequireJWT bool + NetworkService string + GenesisForkVersion string + DefaultECBootnodes []string + DefaultCCBootnodes []string + DefaultCustomConfigSrc string + SupportsMEVBoost bool + CheckpointSyncURL string + RelayURLs []string } diff --git a/go.mod b/go.mod index e199967e2..1d167094f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/compose-spec/compose-go v1.12.0 github.com/docker/docker v23.0.3+incompatible github.com/golang/mock v1.6.0 - github.com/google/go-github/v47 v47.1.0 + github.com/google/go-github/v54 v54.0.0 github.com/google/uuid v1.3.0 github.com/herumi/bls-eth-go-binary v1.29.1 github.com/jarcoal/httpmock v1.2.0 @@ -34,6 +34,8 @@ require ( require ( github.com/Microsoft/go-winio v0.6.0 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/creack/pty v1.1.18 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/distribution/v3 v3.0.0-20230223072852-e5d5810851d1 // indirect @@ -42,6 +44,7 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/ferranbt/fastssz v0.1.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/holiman/uint256 v1.2.1 // indirect @@ -70,12 +73,15 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - golang.org/x/crypto v0.6.0 // indirect + golang.org/x/crypto v0.12.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/term v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/oauth2 v0.11.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/term v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect golang.org/x/tools v0.6.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index 943480dea..fc22196cb 100644 --- a/go.sum +++ b/go.sum @@ -5,12 +5,18 @@ github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2y github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= +github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= +github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= github.com/alexeyco/simpletable v1.0.0 h1:ZQ+LvJ4bmoeHb+dclF64d0LX+7QAi7awsfCrptZrpHk= github.com/alexeyco/simpletable v1.0.0/go.mod h1:VJWVTtGUnW7EKbMRH8cE13SigKGx/1fO2SeeOiGeBkk= github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= +github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/compose-spec/compose-go v1.12.0 h1:MSyWW//yijispnqmTqJSMv1ptRTlKU1sLPHJdc2ACnA= github.com/compose-spec/compose-go v1.12.0/go.mod h1:0/X/dTehChV+KBB696nOOl+HYzKn+XaIm4i12phUB5U= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -37,13 +43,17 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v47 v47.1.0 h1:Cacm/WxQBOa9lF0FT0EMjZ2BWMetQ1TQfyurn4yF1z8= -github.com/google/go-github/v47 v47.1.0/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnWzC/YjGw/oFKi0= +github.com/google/go-github/v54 v54.0.0 h1:OZdXwow4EAD5jEo5qg+dGFH2DpkyZvVsAehjvJuUL/c= +github.com/google/go-github/v54 v54.0.0/go.mod h1:Sw1LXWHhXRZtzJ9LI5fyJg9wbQzYvFhW8W5P2yaAQ7s= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -172,21 +182,25 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= +golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -203,19 +217,21 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20220609170525-579cf78fd858 h1:Dpdu/EMxGMFgq0CeYMh4fazTD2vtlZRYE7wyynxJb9U= golang.org/x/time v0.0.0-20220609170525-579cf78fd858/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -230,6 +246,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/internal/pkg/env/check_variable_test.go b/internal/pkg/env/check_variable_test.go index 2a55105fb..026e49276 100644 --- a/internal/pkg/env/check_variable_test.go +++ b/internal/pkg/env/check_variable_test.go @@ -36,7 +36,7 @@ func TestCheckVariable(t *testing.T) { isErr bool }{ { - "Test case 1, mainnet, no TTD", + "Test case 1, mainnet", ReMEV, "mainnet", "execution", diff --git a/internal/pkg/env/get_variable.go b/internal/pkg/env/get_variable.go index 48baaab66..96160da54 100644 --- a/internal/pkg/env/get_variable.go +++ b/internal/pkg/env/get_variable.go @@ -86,31 +86,3 @@ func GetCCBootnodes(envFilePath string) ([]string, error) { log.Warnf(configs.NoBootnodesFound, envFilePath) return nil, nil } - -/* -GetTTD : -Get TTD from the environment variables in .env. - -params :- -a. path to generated env file - -returns :- -a. []string -List of bootnodes -b. error -Error if any -*/ -func GetTTD(envFilePath string) (string, error) { - content, err := os.ReadFile(envFilePath) - if err != nil { - return "", err - } - - if m := ReTTD.FindStringSubmatch(string(content)); m != nil { - m[1] = strings.ReplaceAll(m[1], "\"", "") - return strings.Trim(m[1], "\r\n "), nil - } - - log.Warnf(configs.NoBootnodesFound, envFilePath) - return "", nil -} diff --git a/internal/pkg/env/get_variable_test.go b/internal/pkg/env/get_variable_test.go index a457049b1..bb5a6831f 100644 --- a/internal/pkg/env/get_variable_test.go +++ b/internal/pkg/env/get_variable_test.go @@ -101,46 +101,6 @@ func TestGetECBootnodes(t *testing.T) { } } -func TestGetTTD(t *testing.T) { - t.Parallel() - - tcs := []struct { - name string - testdataCase string - want string - isErr bool - }{ - { - name: "Test case 1, no TTD", - testdataCase: "case_1", - want: "", - isErr: false, - }, - { - name: "Test case 2, TTD", - testdataCase: "case_2", - want: "8000000000000000000000001000000000000", - isErr: false, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - testCaseEnvFilePath := filepath.Join("testdata", tc.testdataCase, ".env") - got, err := GetTTD(testCaseEnvFilePath) - - descr := fmt.Sprintf("GetTTD(%s)", testCaseEnvFilePath) - if err = utils.CheckErr(descr, tc.isErr, err); err != nil { - t.Error(err) - } - - if got != tc.want { - t.Errorf("Expected %v, got %v. Function call: %s", tc.want, got, descr) - } - }) - } -} - func TestCheckVariableBase(t *testing.T) { t.Parallel() diff --git a/internal/pkg/env/regex.go b/internal/pkg/env/regex.go index bddcadc98..4d4eb7885 100644 --- a/internal/pkg/env/regex.go +++ b/internal/pkg/env/regex.go @@ -18,7 +18,6 @@ package env import "regexp" var ( - ReTTD = regexp.MustCompile(`TTD=(.*)`) ReMEV = regexp.MustCompile(`MEV=(.*)`) ReXEEV = regexp.MustCompile(`XEE_VERSION=(.*)`) ReClBOOTNODES = regexp.MustCompile(`CC_BOOTNODES=(.*)`) diff --git a/internal/pkg/env/testdata/case_2/.env b/internal/pkg/env/testdata/case_2/.env index e17c80e21..65ec66915 100644 --- a/internal/pkg/env/testdata/case_2/.env +++ b/internal/pkg/env/testdata/case_2/.env @@ -1,3 +1,2 @@ -TTD=8000000000000000000000001000000000000 EC_BOOTNODES="enode://011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a@51.141.78.53:30303,enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303,enode://46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291@94.237.54.114:30313,enode://b5948a2d3e9d486c4d75bf32713221c2bd6cf86463302339299bd227dc2e276cd5a1c7ca4f43a0e9122fe9af884efed563bd2a1fd28661f3b5f5ad7bf1de5949@18.218.250.66:30303" CC_BOOTNODES="enr:-LK4QH1xnjotgXwg25IDPjrqRGFnH1ScgNHA3dv1Z8xHCp4uP3N3Jjl_aYv_WIxQRdwZvSukzbwspXZ7JjpldyeVDzMCh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhIe1te-Jc2VjcDI1NmsxoQOkcGXqbCJYbcClZ3z5f6NWhX_1YPFRYRRWQpJjwSHpVIN0Y3CCIyiDdWRwgiMo,enr:-KG4QCIzJZTY_fs_2vqWEatJL9RrtnPwDCv-jRBuO5FQ2qBrfJubWOWazri6s9HsyZdu-fRUfEzkebhf1nvO42_FVzwDhGV0aDKQed8EKAAAECD__________4JpZIJ2NIJpcISHtbYziXNlY3AyNTZrMaED4m9AqVs6F32rSCGsjtYcsyfQE2K8nDiGmocUY_iq-TSDdGNwgiMog3VkcIIjKA,enr:-Ku4QFmUkNp0g9bsLX2PfVeIyT-9WO-PZlrqZBNtEyofOOfLMScDjaTzGxIb1Ns9Wo5Pm_8nlq-SZwcQfTH2cgO-s88Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDkvpOTAAAQIP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQLV_jMOIxKbjHFKgrkFvwDvpexo6Nd58TK5k7ss4Vt0IoN1ZHCCG1g,enr:-LK4QLINdtobGquK7jukLDAKmsrH2ZuHM4k0TklY5jDTD4ZgfxR9weZmo5Jwu81hlKu3qPAvk24xHGBDjYs4o8f1gZ0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhDRN_P6Jc2VjcDI1NmsxoQJuNujTgsJUHUgVZML3pzrtgNtYg7rQ4K1tkWERgl0DdoN0Y3CCIyiDdWRwgiMo,enr:-LK4QMzPq4Q7w5R-rnGQDcI8BYky6oPVBGQTbS1JJLVtNi_8PzBLV7Bdzsoame9nJK5bcJYpGHn4SkaDN2CM6tR5G_4Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhAN4yvyJc2VjcDI1NmsxoQKa8Qnp_P2clLIP6VqLKOp_INvEjLszalEnW0LoBZo4YYN0Y3CCI4yDdWRwgiOM,enr:-LK4QLM_pPHa78R8xlcU_s40Y3XhFjlb3kPddW9lRlY67N5qeFE2Wo7RgzDgRs2KLCXODnacVHMFw1SfpsW3R474RZEBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhANBY-yJc2VjcDI1NmsxoQNsZkFXgKbTzuxF7uwxlGauTGJelE6HD269CcFlZ_R7A4N0Y3CCI4yDdWRwgiOM,enr:-KK4QH0RsNJmIG0EX9LSnVxMvg-CAOr3ZFF92hunU63uE7wcYBjG1cFbUTvEa5G_4nDJkRhUq9q2ck9xY-VX1RtBsruBtIRldGgykIL0pysBABAg__________-CaWSCdjSCaXCEEnXQ0YlzZWNwMjU2azGhA1grTzOdMgBvjNrk-vqWtTZsYQIi0QawrhoZrsn5Hd56g3RjcIIjKIN1ZHCCIyg" diff --git a/internal/pkg/generate/generate_scripts.go b/internal/pkg/generate/generate_scripts.go index 8b86272de..654e57fa0 100644 --- a/internal/pkg/generate/generate_scripts.go +++ b/internal/pkg/generate/generate_scripts.go @@ -19,7 +19,6 @@ import ( "fmt" "io" "os" - "path/filepath" "strings" "text/template" @@ -29,7 +28,6 @@ import ( "github.com/NethermindEth/sedge/internal/pkg/clients" "github.com/NethermindEth/sedge/internal/utils" "github.com/NethermindEth/sedge/templates" - log "github.com/sirupsen/logrus" ) const ( @@ -216,11 +214,6 @@ func ComposeFile(gd *GenData, at io.Writer) error { } } - ttd := gd.CustomTTD - if len(ttd) == 0 { - ttd = configs.NetworksConfigs()[gd.Network].DefaultTTD - } - // Check for CL Bootnode nodes if len(gd.CCBootnodes) == 0 { gd.CCBootnodes = configs.NetworksConfigs()[gd.Network].DefaultCCBootnodes @@ -251,7 +244,6 @@ func ComposeFile(gd *GenData, at io.Writer) error { data := DockerComposeData{ Services: gd.Services, Network: gd.Network, - TTD: ttd, XeeVersion: xeeVersion, Mev: gd.MevBoostService || (mevSupported && gd.Mev), MevBoostOnValidator: gd.MevBoostService || (mevSupported && gd.Mev) || gd.MevBoostOnValidator, @@ -282,17 +274,10 @@ func ComposeFile(gd *GenData, at io.Writer) error { ClCheckpointSyncUrl: clCheckpointSyncUrl, LoggingDriver: gd.LoggingDriver, VLStartGracePeriod: gd.VLStartGracePeriod, - CustomNetwork: gd.Network == configs.NetworkCustom, // Used custom templates - CustomConsensusConfigs: gd.CustomNetworkConfigPath != "" || - gd.CustomGenesisPath != "" || - gd.CustomDeployBlockPath != "", // Have custom configs paths - CustomChainSpecPath: gd.CustomChainSpecPath, // Path to chainspec.json - CustomNetworkConfigPath: gd.CustomNetworkConfigPath, // Path to config.yaml - CustomGenesisPath: gd.CustomGenesisPath, // Path to genesis.ssz - CustomDeployBlockPath: gd.CustomDeployBlockPath, // Path to deploy_block.txt - UID: os.Geteuid(), - GID: os.Getegid(), - ContainerTag: gd.ContainerTag, + CustomNetwork: gd.CustomNetwork, + UID: os.Geteuid(), + GID: os.Getegid(), + ContainerTag: gd.ContainerTag, } // Save to writer @@ -450,96 +435,6 @@ type CustomNetworkConfigsData struct { DeployBlockPath string } -func CustomNetworkConfigs(generationPath, network string, sources CustomConfigsSources) (CustomNetworkConfigsData, error) { - var customNetworkConfigsData CustomNetworkConfigsData - networkData, ok := configs.NetworksConfigs()[network] - if !ok { - return customNetworkConfigsData, fmt.Errorf(configs.UnknownNetworkError, network) - } - valueOrDefault := func(value, def string) string { - if value != "" { - return value - } - return def - } - chainSpecSrc := valueOrDefault(sources.ChainSpecSrc, networkData.DefaultCustomChainSpecSrc) - networkConfigSrc := valueOrDefault(sources.NetworkConfigSrc, networkData.DefaultCustomConfigSrc) - genesisSrc := valueOrDefault(sources.GenesisSrc, networkData.DefaultCustomGenesisSrc) - deployBlock := valueOrDefault(sources.DeployBlockSrc, networkData.DefaultCustomDeployBlock) - - // Check if any custom config is needed - if chainSpecSrc == "" && networkConfigSrc == "" && genesisSrc == "" && deployBlock == "" { - return customNetworkConfigsData, nil - } - - // Setup destination folder - destFolder := filepath.Join(generationPath, configs.CustomNetworkConfigsFolder) - if _, err := os.Stat(destFolder); err != nil { - if os.IsNotExist(err) { - err = os.Mkdir(destFolder, os.ModePerm) - if err != nil { - return customNetworkConfigsData, err - } - } else { - return customNetworkConfigsData, err - } - } - - if chainSpecSrc != "" { - customNetworkConfigsData.ChainSpecPath = filepath.Join(destFolder, configs.ExecutionNetworkConfigFileName) - log.Info(configs.GettingCustomChainSpec) - err := utils.DownloadOrCopy(chainSpecSrc, customNetworkConfigsData.ChainSpecPath, true) - if err != nil { - return customNetworkConfigsData, err - } - customNetworkConfigsData.ChainSpecPath, err = filepath.Abs(customNetworkConfigsData.ChainSpecPath) - if err != nil { - return customNetworkConfigsData, err - } - } - - if networkConfigSrc != "" { - customNetworkConfigsData.NetworkConfigPath = filepath.Join(destFolder, configs.ConsensusNetworkConfigFileName) - log.Info(configs.GettingCustomNetworkConfig) - err := utils.DownloadOrCopy(networkConfigSrc, customNetworkConfigsData.NetworkConfigPath, true) - if err != nil { - return customNetworkConfigsData, err - } - customNetworkConfigsData.NetworkConfigPath, err = filepath.Abs(customNetworkConfigsData.NetworkConfigPath) - if err != nil { - return customNetworkConfigsData, err - } - } - - if genesisSrc != "" { - customNetworkConfigsData.GenesisPath = filepath.Join(destFolder, configs.ConsensusNetworkGenesisFileName) - log.Info(configs.GettingCustomGenesis) - err := utils.DownloadOrCopy(genesisSrc, customNetworkConfigsData.GenesisPath, true) - if err != nil { - return customNetworkConfigsData, err - } - customNetworkConfigsData.GenesisPath, err = filepath.Abs(customNetworkConfigsData.GenesisPath) - if err != nil { - return customNetworkConfigsData, err - } - } - - if deployBlock != "" { - customNetworkConfigsData.DeployBlockPath = filepath.Join(destFolder, configs.ConsensusNetworkDeployBlockFileName) - log.Info(configs.WritingCustomDeployBlock) - err := os.WriteFile(customNetworkConfigsData.DeployBlockPath, []byte(deployBlock), os.ModePerm) - if err != nil { - return customNetworkConfigsData, fmt.Errorf(configs.ErrorWritingDeployBlockFile, customNetworkConfigsData.DeployBlockPath, err) - } - customNetworkConfigsData.DeployBlockPath, err = filepath.Abs(customNetworkConfigsData.DeployBlockPath) - if err != nil { - return customNetworkConfigsData, err - } - } - - return customNetworkConfigsData, nil -} - // endpointOrEmpty returns the endpoint of the client if it is not nil, otherwise returns an empty string func endpointOrEmpty(cls *clients.Client) string { if cls != nil { diff --git a/internal/pkg/generate/generate_scripts_test.go b/internal/pkg/generate/generate_scripts_test.go index b1720eb23..f0faa5ad4 100644 --- a/internal/pkg/generate/generate_scripts_test.go +++ b/internal/pkg/generate/generate_scripts_test.go @@ -104,26 +104,6 @@ func checkCCBootnodesOnConsensus(t *testing.T, data *GenData, compose, env io.Re return nil } -func checkTTDOnExecution(t *testing.T, data *GenData, compose, env io.Reader) error { - composeData := retrieveComposeData(t, compose) - customTTD := data.CustomTTD - if customTTD == "" { - customTTD = configs.NetworksConfigs()[data.Network].DefaultTTD - } - if customTTD != "" { - if composeData.Services.Execution != nil && data.ExecutionClient.Name == "besu" { - checkFlagOnCommands(t, composeData.Services.Execution.Command, "--override-genesis-config=terminalTotalDifficulty="+customTTD) - } - if composeData.Services.Execution != nil && data.ExecutionClient.Name == "nethermind" { - checkFlagOnCommands(t, composeData.Services.Execution.Command, "--Merge.TerminalTotalDifficulty="+customTTD) - } - if composeData.Services.Execution != nil && data.ExecutionClient.Name == "geth" { - checkFlagOnCommands(t, composeData.Services.Execution.Command, "--override.terminaltotaldifficulty="+customTTD) - } - } - return nil -} - func checkECBootnodesOnExecution(t *testing.T, data *GenData, compose, env io.Reader) error { composeData := retrieveComposeData(t, compose) if len(data.ECBootnodes) == 0 { @@ -451,17 +431,6 @@ func customFlagsTestCases(t *testing.T) (tests []genTestData) { for _, consensusCl := range consensusClients { if utils.Contains(validatorClients, consensusCl) { tests = append(tests, - genTestData{ - Description: fmt.Sprintf(baseDescription+"customTTD tests, execution: %s, consensus: %s, validator: %s, network: %s, all", executionCl, consensusCl, consensusCl, network), - GenerationData: &GenData{ - ExecutionClient: &clients.Client{Name: executionCl}, - ConsensusClient: &clients.Client{Name: consensusCl}, - ValidatorClient: &clients.Client{Name: consensusCl}, - Network: network, - Services: []string{execution, consensus, validator}, - }, - CheckFunctions: []CheckFunc{checkTTDOnExecution, defaultFunc, checkECBootnodesOnExecution, checkValidatorBlocker}, - }, genTestData{ Description: fmt.Sprintf(baseDescription+"ecBootnodes tests, execution: %s, consensus: %s, validator: %s, network: %s, no validator", executionCl, consensusCl, consensusCl, network), GenerationData: &GenData{ @@ -471,7 +440,7 @@ func customFlagsTestCases(t *testing.T) (tests []genTestData) { ConsensusClient: &clients.Client{Name: consensusCl}, Network: network, }, - CheckFunctions: []CheckFunc{defaultFunc, checkECBootnodesOnExecution, checkTTDOnExecution, checkValidatorBlocker}, + CheckFunctions: []CheckFunc{defaultFunc, checkECBootnodesOnExecution, checkValidatorBlocker}, }, genTestData{ Description: fmt.Sprintf(baseDescription+"ccBootnodes tests, execution: %s, consensus: %s, validator: %s, network: %s, Execution Client not Valid", executionCl, consensusCl, consensusCl, network), diff --git a/internal/pkg/generate/types.go b/internal/pkg/generate/types.go index ead35407b..7897c1378 100644 --- a/internal/pkg/generate/types.go +++ b/internal/pkg/generate/types.go @@ -19,6 +19,27 @@ import ( "github.com/NethermindEth/sedge/internal/pkg/clients" ) +// CustomNetworkData: Struct Data object to contain paths used to load custom network configs +type CustomNetworkData struct { + // General + Path string + NetworkID string + // Execution + NethermindChainspec string + GethGenesis string + BesuGenesis string + // Consensus + ConsensusConfig string + GenesisState string + DeployBlock string + DeployBlockValue string + DepositContract string + DepositContractBlock string + DepositContractBlockHash string + TrustedSetupTxt string + TrustedSetupJson string +} + // EnvData : Struct Data object to be applied to the docker-compose script environment (.env) template type EnvData struct { Services []string @@ -45,88 +66,76 @@ type EnvData struct { // GenData : Struct Data object for script's generation type GenData struct { - Services []string - ExecutionClient *clients.Client - ConsensusClient *clients.Client - ValidatorClient *clients.Client - Network string - CheckpointSyncUrl string - FeeRecipient string - JWTSecretPath string - FallbackELUrls []string - ElExtraFlags []string - ClExtraFlags []string - VlExtraFlags []string - MapAllPorts bool - Mev bool - RelayURLs []string - MevImage string - MevBoostService bool - MevBoostEndpoint string - MevBoostOnValidator bool - Ports map[string]uint16 - Graffiti string - LoggingDriver string - ECBootnodes []string - CCBootnodes []string - CustomTTD string - CustomChainSpecPath string - CustomNetworkConfigPath string - CustomGenesisPath string - CustomDeployBlock string - CustomDeployBlockPath string - VLStartGracePeriod uint - ExecutionApiUrl string - ExecutionAuthUrl string - ConsensusApiUrl string - ContainerTag string + Services []string + ExecutionClient *clients.Client + ConsensusClient *clients.Client + ValidatorClient *clients.Client + Network string + CheckpointSyncUrl string + FeeRecipient string + JWTSecretPath string + FallbackELUrls []string + ElExtraFlags []string + ClExtraFlags []string + VlExtraFlags []string + MapAllPorts bool + Mev bool + RelayURLs []string + MevImage string + MevBoostService bool + MevBoostEndpoint string + MevBoostOnValidator bool + Ports map[string]uint16 + Graffiti string + LoggingDriver string + ECBootnodes []string + CCBootnodes []string + CustomNetwork CustomNetworkData + VLStartGracePeriod uint + ExecutionApiUrl string + ExecutionAuthUrl string + ConsensusApiUrl string + ContainerTag string } // DockerComposeData : Struct Data object to be applied to docker-compose script type DockerComposeData struct { - Services []string - Network string - TTD string - XeeVersion bool - Mev bool - MevBoostOnValidator bool - MevPort uint16 - MevImage string - MevBoostEndpoint string - CheckpointSyncUrl string - FeeRecipient string - ElDiscoveryPort uint16 - ElMetricsPort uint16 - ElApiPort uint16 - ElAuthPort uint16 - ElWsPort uint16 - ClDiscoveryPort uint16 - ClMetricsPort uint16 - ClApiPort uint16 - ClAdditionalApiPort uint16 - VlMetricsPort uint16 - FallbackELUrls []string - ElExtraFlags []string - ClExtraFlags []string - VlExtraFlags []string - ECBootnodes string - CCBootnodes string - CCBootnodesList []string - MapAllPorts bool - SplittedNetwork bool - ClCheckpointSyncUrl bool - LoggingDriver string - CustomConsensusConfigs bool - CustomNetwork bool - CustomChainSpecPath string - CustomNetworkConfigPath string - CustomGenesisPath string - CustomDeployBlock bool - CustomDeployBlockPath string // Needed for lighthouse - VLStartGracePeriod uint - UID int // Needed for teku - GID int // Needed for teku - ContainerTag string + Services []string + Network string + XeeVersion bool + Mev bool + MevBoostOnValidator bool + MevPort uint16 + MevImage string + MevBoostEndpoint string + CheckpointSyncUrl string + FeeRecipient string + ElDiscoveryPort uint16 + ElMetricsPort uint16 + ElApiPort uint16 + ElAuthPort uint16 + ElWsPort uint16 + ClDiscoveryPort uint16 + ClMetricsPort uint16 + ClApiPort uint16 + ClAdditionalApiPort uint16 + VlMetricsPort uint16 + FallbackELUrls []string + ElExtraFlags []string + ClExtraFlags []string + VlExtraFlags []string + ECBootnodes string + CCBootnodes string + CCBootnodesList []string + MapAllPorts bool + SplittedNetwork bool + ClCheckpointSyncUrl bool + LoggingDriver string + CustomNetwork CustomNetworkData + VLStartGracePeriod uint + UID int // Needed for teku + GID int // Needed for teku + ContainerTag string } // WithConsensusClient returns true if the consensus client is set diff --git a/internal/ui/prompterValidators.go b/internal/ui/prompterValidators.go index a5f272608..c403725ac 100644 --- a/internal/ui/prompterValidators.go +++ b/internal/ui/prompterValidators.go @@ -113,8 +113,8 @@ func fileExtensionValidator(extensions []string) func(ans interface{}) error { } // DigitsStringValidator validates that the input is a valid string with only digits -func DigitsStringValidator(ttd string) error { - if !digitsString.MatchString(ttd) { +func DigitsStringValidator(str string) error { + if !digitsString.MatchString(str) { return ErrInvalidDigitString } return nil diff --git a/internal/utils/github_utils.go b/internal/utils/github_utils.go new file mode 100644 index 000000000..736debe7b --- /dev/null +++ b/internal/utils/github_utils.go @@ -0,0 +1,119 @@ +package utils + +import ( + "context" + "io" + "os" + "path/filepath" + "strings" + + "github.com/google/go-github/v54/github" +) + +func DownloadGithubFile( + client *github.Client, + dest, + owner, + repository, + path, + ref string, +) (err error) { + stream, _, err := client.Repositories.DownloadContents( + context.Background(), + owner, + repository, + path, + &github.RepositoryContentGetOptions{ + Ref: ref, + }, + ) + if err != nil { + return + } + + file, err := os.Create(dest) + if err != nil { + return + } + defer func() { + closeErr := file.Close() + if err == nil { + err = closeErr + } + }() + + _, err = io.Copy(file, stream) + if err != nil { + return + } + + return nil +} + +func DownloadGithubObject( + client *github.Client, + dest, + owner, + repository, + path, + ref string, +) error { + filedata, dirdata, _, err := client.Repositories.GetContents( + context.Background(), + owner, + repository, + path, + &github.RepositoryContentGetOptions{ + Ref: ref, + }, + ) + if err != nil { + return err + } + + if filedata != nil { + err = DownloadGithubFile( + client, + strings.Join([]string{dest, filedata.GetName()}, "/"), + owner, + repository, + path, + ref, + ) + if err != nil { + return err + } + } + + if dirdata != nil { + err = os.MkdirAll( + dest, + 0o755, + ) + if err != nil { + return err + } + + for _, content := range dirdata { + if content != nil { + newDest := dest + if content.GetType() != "file" { + filepath.Join(newDest, content.GetName()) + } + err = DownloadGithubObject( + client, + dest, + owner, + repository, + content.GetPath(), + ref, + ) + if err != nil { + return err + } + } + } + } + + return nil +} diff --git a/internal/utils/version.go b/internal/utils/version.go index 9c95dc8ed..a7833387a 100644 --- a/internal/utils/version.go +++ b/internal/utils/version.go @@ -22,7 +22,7 @@ import ( "text/template" "github.com/NethermindEth/sedge/internal/pkg/commands" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v54/github" ) const ( diff --git a/templates/envs/custom/execution/besu.tmpl b/templates/envs/custom/execution/besu.tmpl new file mode 100644 index 000000000..b9c05f713 --- /dev/null +++ b/templates/envs/custom/execution/besu.tmpl @@ -0,0 +1,8 @@ +{{/* besu.tmpl */}} +{{ define "execution" }} +# --- Execution Layer - Execution Node - configuration --- +EC_IMAGE_VERSION={{.ElImage}} +EC_ENABLED_MODULES=ETH,NET,CLIQUE,DEBUG,MINER,NET,PERM,ADMIN,EEA,TXPOOL,PRIV,WEB3 +EC_DATA_DIR={{.ElDataDir}} +EC_JWT_SECRET_PATH={{.JWTSecretPath}} +{{ end }} \ No newline at end of file diff --git a/templates/envs/custom/execution/erigon.tmpl b/templates/envs/custom/execution/erigon.tmpl new file mode 100644 index 000000000..d59695f92 --- /dev/null +++ b/templates/envs/custom/execution/erigon.tmpl @@ -0,0 +1,7 @@ +{{/* erigon.tmpl */}} +{{ define "execution" }} +# --- Execution Layer - Execution Node - configuration --- +EC_IMAGE_VERSION={{.ElImage}} +EC_DATA_DIR={{.ElDataDir}} +EC_JWT_SECRET_PATH={{.JWTSecretPath}} +{{ end }} diff --git a/templates/envs/custom/execution/geth.tmpl b/templates/envs/custom/execution/geth.tmpl new file mode 100644 index 000000000..84d69323e --- /dev/null +++ b/templates/envs/custom/execution/geth.tmpl @@ -0,0 +1,9 @@ +{{/* geth.tmpl */}} +{{ define "execution" }} +# --- Execution Layer - Execution Node - configuration --- +EC_IMAGE_VERSION={{.ElImage}} +GETH_LOG_LEVEL=3 +EC_DATA_DIR={{.ElDataDir}} +EC_SYNC_MODE=snap +EC_JWT_SECRET_PATH={{.JWTSecretPath}} +{{ end }} \ No newline at end of file diff --git a/templates/envs/custom/execution/nethermind.tmpl b/templates/envs/custom/execution/nethermind.tmpl index 74071e4aa..e6092b35f 100644 --- a/templates/envs/custom/execution/nethermind.tmpl +++ b/templates/envs/custom/execution/nethermind.tmpl @@ -1,7 +1,7 @@ {{/* nethermind.tmpl */}} {{ define "execution" }} # --- Execution Layer - Execution Node - configuration --- -EC_IMAGE_VERSION={{if .ElImage}}{{.ElImage}}{{else}}nethermind/nethermind:1.14.6{{end}} +EC_IMAGE_VERSION={{.ElImage}} NETHERMIND_LOG_LEVEL=INFO EC_DATA_DIR={{.ElDataDir}} EC_JWT_SECRET_PATH={{.JWTSecretPath}} diff --git a/templates/services/merge/consensus/lighthouse.tmpl b/templates/services/merge/consensus/lighthouse.tmpl index eac17f87d..dee4b690b 100644 --- a/templates/services/merge/consensus/lighthouse.tmpl +++ b/templates/services/merge/consensus/lighthouse.tmpl @@ -12,10 +12,8 @@ - sedge volumes: - ${CC_DATA_DIR}:/var/lib/lighthouse - - ${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}} + - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomNetwork.Path}} + - {{ .CustomNetwork.Path }}:/custom-config{{end}} ports: - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/tcp" - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/udp" @@ -24,22 +22,21 @@ expose: - {{.ClApiPort}} command: - - lighthouse{{if .CustomConsensusConfigs}} - - --testnet-dir=/network_config{{end}} + - lighthouse - bn - --disable-upnp - - --datadir=/var/lib/lighthouse + - --datadir=/var/lib/lighthouse{{if .CustomNetwork.Path}} + - --testnet-dir=/custom-config{{ else }} + - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --port={{.ClDiscoveryPort}} - --http - --http-address=0.0.0.0 - - --http-port={{.ClApiPort}}{{if not .CustomConsensusConfigs}} - - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} + - --http-port={{.ClApiPort}} - --target-peers=${CC_PEER_COUNT}{{if .CCBootnodes}} - --boot-nodes={{.CCBootnodes}}{{end}} - --execution-endpoints=${EC_AUTH_URL} - --execution-jwt=/tmp/jwt/jwtsecret - - --eth1-endpoints=${EC_API_URL}{{range $url := .FallbackELUrls}},{{$url}}{{end}}{{if .TTD}} - - --terminal-total-difficulty-override={{.TTD}}{{end}} + - --eth1-endpoints=${EC_API_URL}{{range $url := .FallbackELUrls}},{{$url}}{{end}} - --debug-level=${CC_LOG_LEVEL}{{with .FeeRecipient}} - --suggested-fee-recipient=${FEE_RECIPIENT}{{end}} - --validator-monitor-auto diff --git a/templates/services/merge/consensus/lodestar.tmpl b/templates/services/merge/consensus/lodestar.tmpl index 86a074abb..096ea45f2 100644 --- a/templates/services/merge/consensus/lodestar.tmpl +++ b/templates/services/merge/consensus/lodestar.tmpl @@ -9,9 +9,10 @@ - sedge volumes: - ${CC_DATA_DIR}:/var/lib/lodestar/consensus - - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{if .CustomGenesisPath}} - - {{.CustomGenesisPath}}:/network_config/genesis.ssz{{end}}{{end}} + - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}}{{if .CustomNetwork.GenesisState}} + - {{.CustomNetwork.GenesisState}}:/custom-config/genesis.ssz{{end}}{{if .CustomNetwork.TrustedSetupTxt}} + - {{.CustomNetwork.TrustedSetupTxt}}:/custom-config/trusted_setup.txt{{end}} ports: - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/tcp" - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/udp" @@ -24,15 +25,15 @@ command: - beacon - --preset=${CC_LODESTAR_PRESET} - - --dataDir=/var/lib/lodestar/consensus{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - --paramsFile=/network_config/config.yml{{end}}{{if .CustomGenesisPath}} - - --genesisStateFile=/network_config/genesis.ssz{{end}}{{if .CustomDeployBlock}} - - --eth1.depositContractDeployBlock={{.CustomDeployBlock}}{{end}}{{else}} + - --dataDir=/var/lib/lodestar/consensus{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --paramsFile=/custom-config/config.yaml{{end}}{{if .CustomNetwork.GenesisState}} + - --genesisStateFile=/custom-config/genesis.ssz{{end}}{{if .CustomNetwork.DeployBlockValue}} + - --eth1.depositContractDeployBlock={{.CustomNetwork.DeployBlockValue}}{{end}}{{if .CustomNetwork.TrustedSetupTxt}} + - --chain.trustedSetup=/custom-config/trusted_setup.txt{{end}}{{else}} - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --eth1=true - --eth1.providerUrls=${EC_API_URL}{{range $url := .FallbackELUrls}},{{$url}}{{end}} - - --execution.urls=${EC_AUTH_URL}{{if .TTD}} - - --terminal-total-difficulty-override={{.TTD}}{{end}} + - --execution.urls=${EC_AUTH_URL} - --logFile=/var/lib/lodestart/consensus/logs/beacon.log - --logFileLevel=${CC_LOG_LEVEL}{{with .FeeRecipient}} - --suggestedFeeRecipient=${FEE_RECIPIENT}{{end}} diff --git a/templates/services/merge/consensus/prysm.tmpl b/templates/services/merge/consensus/prysm.tmpl index c41a45545..acef19dfd 100644 --- a/templates/services/merge/consensus/prysm.tmpl +++ b/templates/services/merge/consensus/prysm.tmpl @@ -9,9 +9,9 @@ - sedge volumes: - ${CC_DATA_DIR}:/var/lib/prysm - - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{if .CustomGenesisPath}} - - {{.CustomGenesisPath}}:/network_config/genesis.ssz{{end}}{{end}} + - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}}{{if .CustomNetwork.GenesisState}} + - {{.CustomNetwork.GenesisState}}:/custom-config/genesis.ssz{{end}} ports: - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/tcp" - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/udp" @@ -21,13 +21,12 @@ expose: - {{.ClApiPort}} - {{.ClAdditionalApiPort}} - command:{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - --chain-config-file=/network_config/config.yml{{end}}{{if .CustomDeployBlock}} - - --contract-deployment-block={{.CustomDeployBlock}}{{end}}{{if .CustomGenesisPath}} - - --genesis-state=/network_config/genesis.ssz{{end}}{{else}} + command:{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --chain-config-file=/custom-config/config.yaml{{end}}{{if .CustomNetwork.DeployBlockValue}} + - --contract-deployment-block={{.CustomNetwork.DeployBlockValue}}{{end}}{{if .CustomNetwork.GenesisState}} + - --genesis-state=/custom-config/genesis.ssz{{end}}{{else}} - --{{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}}{{range $enr := .CCBootnodesList}} - - --bootstrap-node={{$enr}}{{end}}{{if .TTD}} - - --terminal-total-difficulty-override={{.TTD}}{{end}} + - --bootstrap-node={{$enr}}{{end}} - --p2p-tcp-port={{.ClDiscoveryPort}} - --p2p-udp-port={{.ClDiscoveryPort}} - --jwt-secret=/tmp/jwt/jwtsecret diff --git a/templates/services/merge/consensus/teku.tmpl b/templates/services/merge/consensus/teku.tmpl index 52e8531f5..ea4e798c8 100644 --- a/templates/services/merge/consensus/teku.tmpl +++ b/templates/services/merge/consensus/teku.tmpl @@ -13,9 +13,10 @@ - sedge volumes: - ${CC_DATA_DIR}:/var/lib/teku - - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{if .CustomGenesisPath}} - - {{.CustomGenesisPath}}:/network_config/genesis.ssz{{end}}{{end}} + - ${CC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}}{{if .CustomNetwork.GenesisState}} + - {{.CustomNetwork.GenesisState}}:/custom-config/genesis.ssz{{end}}{{if .CustomNetwork.TrustedSetupTxt}} + - {{.CustomNetwork.TrustedSetupTxt}}:/custom-config/trusted_setup.txt{{end}} ports: - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/tcp" - "{{.ClDiscoveryPort}}:{{.ClDiscoveryPort}}/udp" @@ -25,10 +26,11 @@ - {{.ClApiPort}} command: - --log-destination=CONSOLE - - --logging=${CC_LOG_LEVEL}{{if not .CustomConsensusConfigs}} - - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{else}}{{if .CustomGenesisPath}} - - --initial-state=/network_config/genesis.ssz{{end}}{{if .CustomNetworkConfigPath}} - - --network=/network_config/config.yml{{end}}{{end}}{{if .CCBootnodes}} + - --logging=${CC_LOG_LEVEL}{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --network=/custom-config/config.yaml{{end}}{{if .CustomNetwork.GenesisState}} + - --initial-state=/custom-config/genesis.ssz{{end}}{{if .CustomNetwork.TrustedSetupTxt}} + - --Xtrusted-setup=/custom-config/trusted_setup.txt{{end}}{{else}} + - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}}{{if .CCBootnodes}} - --p2p-discovery-bootnodes={{.CCBootnodes}}{{end}} - --p2p-enabled=true - --p2p-port={{.ClDiscoveryPort}} @@ -46,8 +48,7 @@ - --data-storage-non-canonical-blocks-enabled=false - --ee-endpoint=${EC_AUTH_URL}{{with .FeeRecipient}} - --validators-proposer-default-fee-recipient=${FEE_RECIPIENT}{{end}} - - --ee-jwt-secret-file=/tmp/jwt/jwtsecret{{if .TTD}} - - --Xnetwork-total-terminal-difficulty-override={{.TTD}}{{end}} + - --ee-jwt-secret-file=/tmp/jwt/jwtsecret - --metrics-enabled=true - --metrics-host-allowlist=* - --metrics-interface=0.0.0.0 diff --git a/templates/services/merge/execution/besu.tmpl b/templates/services/merge/execution/besu.tmpl index 4d7084927..cceb9ca17 100644 --- a/templates/services/merge/execution/besu.tmpl +++ b/templates/services/merge/execution/besu.tmpl @@ -9,8 +9,8 @@ - sedge volumes: - ${EC_DATA_DIR}:/var/lib/besu/data - - ${EC_JWT_SECRET_PATH}:/var/lib/besu/jwtsecret{{if .CustomChainSpecPath}} - - {{.CustomChainSpecPath}}:/nethermind/custom_config/chainspec.json{{end}} + - ${EC_JWT_SECRET_PATH}:/var/lib/besu/jwtsecret{{if .CustomNetwork.BesuGenesis }} + - {{ .CustomNetwork.BesuGenesis }}:/custom-config/besu.json{{end}} user: root ports: - "{{.ElDiscoveryPort}}:{{.ElDiscoveryPort}}/tcp" @@ -21,11 +21,10 @@ expose: - {{.ElApiPort}} - {{.ElAuthPort}} - command:{{if .TTD}} - - --override-genesis-config=terminalTotalDifficulty={{.TTD}}{{end}} + command: - --sync-mode=X_SNAP - - --data-storage-format=BONSAI{{if .CustomChainSpecPath}} - - --genesis-file=/nethermind/custom_config/chainspec.json{{else}} + - --data-storage-format=BONSAI{{if .CustomNetwork.BesuGenesis }} + - --genesis-file=/custom-config/besu.json{{else}} - --network={{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --data-path=/var/lib/besu/data{{if .ECBootnodes}} - --bootnodes={{.ECBootnodes}}{{end}} diff --git a/templates/services/merge/execution/empty.tmpl b/templates/services/merge/execution/empty.tmpl index 2e1540929..17e798b38 100644 --- a/templates/services/merge/execution/empty.tmpl +++ b/templates/services/merge/execution/empty.tmpl @@ -1,3 +1 @@ -{{/* empty.tmpl */}} -{{ define "execution" }} -{{ end }} \ No newline at end of file +{{/* empty.tmpl */}}{{ define "execution" }}{{ end }} \ No newline at end of file diff --git a/templates/services/merge/execution/erigon.tmpl b/templates/services/merge/execution/erigon.tmpl index 46e159ec7..1eaea4a2d 100644 --- a/templates/services/merge/execution/erigon.tmpl +++ b/templates/services/merge/execution/erigon.tmpl @@ -1,5 +1,26 @@ {{/* erigon.tmpl */}} -{{ define "execution" }} +{{ define "execution" }}{{ if .CustomNetwork.GethGenesis }} + execution-init: + container_name: sedge-execution-init{{if .ContainerTag}}-{{.ContainerTag}}{{end}} + restart: no + image: ${EC_IMAGE_VERSION} + networks: + - sedge + volumes: + - ${EC_DATA_DIR}:/var/lib/erigon + - {{ .CustomNetwork.GethGenesis }}:/custom-config/genesis.json + entrypoint: /bin/sh + command >- + stat var/lib/erigon/chaindata || + erigon + --datadir=/var/lib/erigon + init + /custom-config/genesis.json + logging: + driver: "{{.LoggingDriver}}"{{if eq .LoggingDriver "json-file"}} + options: + max-size: "10m" + max-file: "10"{{end}}{{end}} execution: stop_grace_period: 30m container_name: sedge-execution-client{{if .ContainerTag}}-{{.ContainerTag}}{{end}} @@ -20,28 +41,29 @@ - {{.ElApiPort}} - {{.ElAuthPort}} user: root - command: - - --private.api.addr=0.0.0.0:9090 - - --nat=any - - --http - - --http.addr=0.0.0.0 - - --http.port={{.ElApiPort}} - - --http.vhosts=* - - --http.corsdomain=* - - --http.api=web3,eth,net,engine - - --txpool.disable - - --chain={{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}}{{if .ECBootnodes}} - - --bootnodes={{.ECBootnodes}}{{end}} - - --authrpc.addr=0.0.0.0 - - --authrpc.port={{.ElAuthPort}} - - --authrpc.vhosts=* - - --authrpc.jwtsecret=/var/lib/erigon/jwtsecret - - --datadir=/var/lib/erigon - - --healthcheck - - --metrics - - --metrics.addr=0.0.0.0 - - --metrics.port={{.ElMetricsPort}}{{range $flag := .ElExtraFlags}} - - --{{$flag}}{{end}}{{if .LoggingDriver}} + command:{{ if .CustomNetwork.NetworkID }} + - --networkid={{.CustomNetwork.NetworkID}}{{else}} + - --chain={{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} + - --private.api.addr=0.0.0.0:9090 + - --nat=any + - --http + - --http.addr=0.0.0.0 + - --http.port={{.ElApiPort}} + - --http.vhosts=* + - --http.corsdomain=* + - --http.api=web3,eth,net,engine + - --txpool.disable{{if .ECBootnodes}} + - --bootnodes={{.ECBootnodes}}{{end}} + - --authrpc.addr=0.0.0.0 + - --authrpc.port={{.ElAuthPort}} + - --authrpc.vhosts=* + - --authrpc.jwtsecret=/var/lib/erigon/jwtsecret + - --datadir=/var/lib/erigon + - --healthcheck + - --metrics + - --metrics.addr=0.0.0.0 + - --metrics.port={{.ElMetricsPort}}{{range $flag := .ElExtraFlags}} + - --{{$flag}}{{end}}{{if .LoggingDriver}} logging: driver: "{{.LoggingDriver}}"{{if eq .LoggingDriver "json-file"}} options: diff --git a/templates/services/merge/execution/geth.tmpl b/templates/services/merge/execution/geth.tmpl index 4d0db7f60..d6020d292 100644 --- a/templates/services/merge/execution/geth.tmpl +++ b/templates/services/merge/execution/geth.tmpl @@ -1,5 +1,26 @@ {{/* geth.tmpl */}} -{{ define "execution" }} +{{ define "execution" }}{{ if .CustomNetwork.GethGenesis }} + execution-init: + container_name: sedge-execution-init{{if .ContainerTag}}-{{.ContainerTag}}{{end}} + restart: no + image: ${EC_IMAGE_VERSION} + networks: + - sedge + volumes: + - ${EC_DATA_DIR}:/var/lib/goethereum + - {{ .CustomNetwork.GethGenesis }}:/custom-config/genesis.json + entrypoint: /bin/sh + command >- + stat /var/lib/goethereum/geth/chaindata || + geth + --datadir=/var/lib/goethereum + init + /custom-config/genesis.json + logging: + driver: "{{.LoggingDriver}}"{{if eq .LoggingDriver "json-file"}} + options: + max-size: "10m" + max-file: "10"{{end}}{{end}} execution: stop_grace_period: 30m container_name: sedge-execution-client{{if .ContainerTag}}-{{.ContainerTag}}{{end}} @@ -21,8 +42,9 @@ - {{.ElApiPort}} - {{.ElWsPort}} - {{.ElAuthPort}} - command:{{if .TTD}} - - --override.terminaltotaldifficulty={{.TTD}}{{end}}{{if .ECBootnodes}} + command:{{ if .CustomNetwork.NetworkID }} + - --networkid={{.CustomNetwork.NetworkID}}{{else}} + - --{{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}}{{end}}{{if .ECBootnodes}} - --bootnodes={{.ECBootnodes}}{{end}} - --syncmode=${EC_SYNC_MODE} - --http @@ -34,7 +56,6 @@ - --datadir=/var/lib/goethereum - --port={{.ElDiscoveryPort}} - --http.port={{.ElApiPort}} - - --{{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}} - --verbosity - ${GETH_LOG_LEVEL} - --ws diff --git a/templates/services/merge/execution/nethermind.tmpl b/templates/services/merge/execution/nethermind.tmpl index 1440240c9..b9e1efca1 100644 --- a/templates/services/merge/execution/nethermind.tmpl +++ b/templates/services/merge/execution/nethermind.tmpl @@ -13,8 +13,8 @@ - sedge volumes: - ${EC_DATA_DIR}:/nethermind/data - - ${EC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{if .CustomChainSpecPath}} - - {{.CustomChainSpecPath}}:/nethermind/custom_config/chainspec.json{{end}} + - ${EC_JWT_SECRET_PATH}:/tmp/jwt/jwtsecret{{ if .CustomNetwork.NethermindChainspec }} + - {{ .CustomNetwork.NethermindChainspec }}:/custom-config/chainspec.json{{end}} ports: - "{{.ElDiscoveryPort}}:{{.ElDiscoveryPort}}/tcp" - "{{.ElDiscoveryPort}}:{{.ElDiscoveryPort}}/udp" @@ -24,12 +24,12 @@ expose: - {{.ElApiPort}} - {{.ElAuthPort}} - command:{{if .CustomChainSpecPath}} - - --Init.ChainSpecPath=/nethermind/custom_config/chainspec.json{{end}} - - --config={{if .CustomNetwork}}none{{else}}{{if .SplittedNetwork}}${EL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} + command:{{ if .CustomNetwork.NethermindChainspec }} + - --config=none + - --Init.ChainSpecPath=/custom-config/chainspec.json{{ else }} + - --config={{ if .SplittedNetwork }}${EL_NETWORK}{{ else }}${NETWORK}{{ end }}{{ end }} - --datadir=/nethermind/data - - --log=${NETHERMIND_LOG_LEVEL}{{if .TTD}} - - --Merge.TerminalTotalDifficulty={{.TTD}}{{end}} + - --log=${NETHERMIND_LOG_LEVEL} - --JsonRpc.Enabled=true - --JsonRpc.Host=0.0.0.0 - --JsonRpc.Port={{.ElApiPort}} diff --git a/templates/services/merge/validator/lighthouse.tmpl b/templates/services/merge/validator/lighthouse.tmpl index c815c1718..e17e5c453 100644 --- a/templates/services/merge/validator/lighthouse.tmpl +++ b/templates/services/merge/validator/lighthouse.tmpl @@ -11,14 +11,12 @@ ports: - "{{.VlMetricsPort}}:{{.VlMetricsPort}}" volumes: - - ${VL_DATA_DIR}:/data{{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}} + - ${VL_DATA_DIR}:/data{{if .CustomNetwork.Path}} + - {{ .CustomNetwork.Path }}:/custom-config{{end}} command: - - lighthouse{{if .CustomConsensusConfigs}} - - --testnet-dir=/network_config{{end}} - - vc{{if not .CustomConsensusConfigs}} + - lighthouse + - vc{{if .CustomNetwork.Path}} + - --testnet-dir=/custom-config{{ else }} - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --beacon-nodes=${CC_API_URL} - --graffiti=${GRAFFITI} diff --git a/templates/services/merge/validator/lodestar.tmpl b/templates/services/merge/validator/lodestar.tmpl index e5855ebfb..5f724c28a 100644 --- a/templates/services/merge/validator/lodestar.tmpl +++ b/templates/services/merge/validator/lodestar.tmpl @@ -11,11 +11,11 @@ ports: - "{{.VlMetricsPort}}:{{.VlMetricsPort}}" volumes: - - ${VL_DATA_DIR}:/data{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{end}} + - ${VL_DATA_DIR}:/data{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}} command: - - validator{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - --paramsFile=/network_config/config.yml{{end}}{{else}} + - validator{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --paramsFile=/custom-config/config.yaml{{end}}{{else}} - --preset=${VL_LODESTAR_PRESET} - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --dataDir=/data diff --git a/templates/services/merge/validator/prysm.tmpl b/templates/services/merge/validator/prysm.tmpl index 9f2ca8680..9174291a2 100644 --- a/templates/services/merge/validator/prysm.tmpl +++ b/templates/services/merge/validator/prysm.tmpl @@ -12,13 +12,13 @@ - "{{.VlMetricsPort}}:{{.VlMetricsPort}}" volumes: - ${VL_DATA_DIR}:/data - - ${KEYSTORE_DIR}/keystore_password.txt:/keystore/keystore_password.txt{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{end}} + - ${KEYSTORE_DIR}/keystore_password.txt:/keystore/keystore_password.txt{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}} command: - --datadir=/data - --wallet-dir=/data/wallet - - --wallet-password-file=/keystore/keystore_password.txt{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - --chain-config-file=/network_config/config.yml{{end}}{{else}} + - --wallet-password-file=/keystore/keystore_password.txt{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --chain-config-file=/custom-config/config.yaml{{end}}{{else}} - --{{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --beacon-rpc-provider=${CC_ADD_API_URL} - --graffiti=${GRAFFITI} diff --git a/templates/services/merge/validator/teku.tmpl b/templates/services/merge/validator/teku.tmpl index ad7b34703..963b39a29 100644 --- a/templates/services/merge/validator/teku.tmpl +++ b/templates/services/merge/validator/teku.tmpl @@ -12,11 +12,12 @@ ports: - "{{.VlMetricsPort}}:{{.VlMetricsPort}}" volumes: - - ${VL_DATA_DIR}:/data{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - {{.CustomNetworkConfigPath}}:/network_config/config.yml{{end}}{{end}} + - ${VL_DATA_DIR}:/data{{if .CustomNetwork.ConsensusConfig}} + - {{.CustomNetwork.ConsensusConfig}}:/custom-config/config.yaml{{end}} command: - - validator-client{{if .CustomConsensusConfigs}}{{if .CustomNetworkConfigPath}} - - --network=/network_config/config.yml{{end}}{{end}} + - validator-client{{if .CustomNetwork.Path}}{{if .CustomNetwork.ConsensusConfig}} + - --network=/custom-config/config.yaml{{end}}{{else}} + - --network={{if .SplittedNetwork}}${CL_NETWORK}{{else}}${NETWORK}{{end}}{{end}} - --beacon-node-api-endpoint=${CC_API_URL} - --data-path=/data - --log-destination=CONSOLE diff --git a/test/data.go b/test/data.go index 15ac4a017..0c9743618 100644 --- a/test/data.go +++ b/test/data.go @@ -20,7 +20,6 @@ package test import ( "io" "io/fs" - "io/ioutil" "os" "path/filepath" ) @@ -42,7 +41,7 @@ type copyOperation struct { } // Create copyOperations for every file on any subdirectory in "srcPath" to "dstPath". -func getAllFiles(entries []fs.FileInfo, srcPath, dstPath string) ([]copyOperation, error) { +func getAllFiles(entries []fs.DirEntry, srcPath, dstPath string) ([]copyOperation, error) { ops := []copyOperation{} for _, entry := range entries { // loop through files infos if entry.IsDir() && entry.Name() != "." && entry.Name() != ".." { // entry is a directory @@ -56,7 +55,7 @@ func getAllFiles(entries []fs.FileInfo, srcPath, dstPath string) ([]copyOperatio return nil, err } // get new entries from new source directory - newEntries, err := ioutil.ReadDir(newSrc) + newEntries, err := os.ReadDir(newSrc) if err != nil { return nil, err } @@ -90,7 +89,7 @@ func getAllFiles(entries []fs.FileInfo, srcPath, dstPath string) ([]copyOperatio // Copy all sub directory and files from "srcPath" to "dstPath" // maintaining the same structure. func PrepareTestCaseDir(srcPath, dstPath string) error { - srcDirs, err := ioutil.ReadDir(srcPath) + srcDirs, err := os.ReadDir(srcPath) if err != nil { return err }