Skip to content

Commit

Permalink
Revert "Separate checkpoint url"
Browse files Browse the repository at this point in the history
This reverts commit a89452a.
  • Loading branch information
batphonghan committed Oct 16, 2023
1 parent e21855f commit 839f69c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 82 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ require (
github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf // indirect
github.com/sethvargo/go-password v0.2.0
github.com/shirou/gopsutil/v3 v3.23.1
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231013173524-71ae1fe3ea52
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231013173524-71ae1fe3ea52
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231010150025-cdbbe61da8dc
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231010150025-cdbbe61da8dc
github.com/tyler-smith/go-bip39 v1.1.0
github.com/urfave/cli v1.22.10
github.com/wealdtech/go-eth2-types/v2 v2.7.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1231,10 +1231,10 @@ github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7Sr
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc=
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231013173524-71ae1fe3ea52 h1:Y3ASJLiv/mBbqREUWgOUXLtoce23fsGnXXJrJ8Rw4kI=
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231013173524-71ae1fe3ea52/go.mod h1:gZcnx3O0sm+mEO2INhKDHw+iUzJH5tPaX4cv5SN5tsQ=
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231013173524-71ae1fe3ea52 h1:nK3eQ3qreZBPn7feJS15t31pBShhj1rCV01cBRLE+7k=
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231013173524-71ae1fe3ea52/go.mod h1:5ojn2lxD9wd5sF0KYaHBDcpUC3ACFgqr0XG1atCIeAs=
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231010150025-cdbbe61da8dc h1:vWFxcgi1WU9J2oY6rhUAAQS4R/c1Pbn63rcjyv4Bms4=
github.com/stader-labs/ethcli-ui/configuration v0.0.0-20231010150025-cdbbe61da8dc/go.mod h1:gZcnx3O0sm+mEO2INhKDHw+iUzJH5tPaX4cv5SN5tsQ=
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231010150025-cdbbe61da8dc h1:hXzsyqCaeqm0s22ocuzGxs2rflHOg/QoX7zMYHJdGSE=
github.com/stader-labs/ethcli-ui/wizard v0.0.0-20231010150025-cdbbe61da8dc/go.mod h1:5ojn2lxD9wd5sF0KYaHBDcpUC3ACFgqr0XG1atCIeAs=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 h1:Oo2KZNP70KE0+IUJSidPj/BFS/RXNHmKIJOdckzml2E=
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
Expand Down
35 changes: 0 additions & 35 deletions shared/services/config/consensus-common-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import (

// Param IDs
const GraffitiID string = "graffiti"

const CheckpointSyncUrlID string = "checkpointSyncUrl"
const CheckpointSyncUrlMainnetID string = "checkpointSyncUrlMainnet"
const CheckpointSyncUrlPraterID string = "checkpointSyncUrlPraters"
const P2pPortID string = "p2pPort"
const ApiPortID string = "apiPort"
const OpenApiPortID string = "openApiPort"
Expand All @@ -55,12 +52,6 @@ type ConsensusCommonConfig struct {
// The checkpoint sync URL if used
CheckpointSyncProvider config.Parameter `yaml:"checkpointSyncProvider,omitempty"`

// The checkpoint sync URL if used for mainnet
CheckpointSyncProviderMainnet config.Parameter `yaml:"checkpointSyncProviderMainnet,omitempty"`

// The checkpoint sync URL if used for the prater
CheckpointSyncProviderPrater config.Parameter `yaml:"checkpointSyncProviderPrater,omitempty"`

// The port to use for gossip traffic
P2pPort config.Parameter `yaml:"p2pPort,omitempty"`

Expand Down Expand Up @@ -105,30 +96,6 @@ func NewConsensusCommonConfig(cfg *StaderConfig) *ConsensusCommonConfig {
CanBeBlank: true,
OverwriteOnUpgrade: false,
},
CheckpointSyncProviderMainnet: config.Parameter{
ID: CheckpointSyncUrlMainnetID,
Name: "Checkpoint Sync URL Mainnet",
Description: "If you would like to instantly sync using an existing Beacon node, enter its URL.\n" +
"Example: https://<project ID>:<secret>@eth2-beacon-prater.infura.io\n" +
"Leave this blank if you want to sync normally from the start of the chain.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{config.Network_All: defaultCheckpointSyncProvider},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
CanBeBlank: true,
OverwriteOnUpgrade: false,
},
CheckpointSyncProviderPrater: config.Parameter{
ID: CheckpointSyncUrlPraterID,
Name: "Checkpoint Sync URL Prater",
Description: "If you would like to instantly sync using an existing Beacon node, enter its URL.\n" +
"Example: https://<project ID>:<secret>@eth2-beacon-prater.infura.io\n" +
"Leave this blank if you want to sync normally from the start of the chain.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{config.Network_All: defaultCheckpointSyncProvider},
AffectsContainers: []config.ContainerID{config.ContainerID_Eth2},
CanBeBlank: true,
OverwriteOnUpgrade: false,
},

P2pPort: config.Parameter{
ID: P2pPortID,
Expand Down Expand Up @@ -185,8 +152,6 @@ func (cfg *ConsensusCommonConfig) GetParameters() []*config.Parameter {
return []*config.Parameter{
&cfg.Graffiti,
&cfg.CheckpointSyncProvider,
&cfg.CheckpointSyncProviderMainnet,
&cfg.CheckpointSyncProviderPrater,
&cfg.P2pPort,
&cfg.ApiPort,
&cfg.OpenApiPort,
Expand Down
16 changes: 1 addition & 15 deletions stader-cli/service/configConsensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"strings"

stdCf "github.com/stader-labs/stader-node/shared/services/config"
"github.com/stader-labs/stader-node/shared/types/config"
cfgtypes "github.com/stader-labs/stader-node/shared/types/config"
)

Expand Down Expand Up @@ -73,14 +72,7 @@ func setUIConsensusClient(cfg *stdCf.StaderConfig, newSettings map[string]interf

// Local
newSettings[keys.E2cc_lc_common_graffiti] = cfg.ConsensusCommon.Graffiti.Value
network := newSettings[keys.Sn_node_network].(string)

if network == "Ethereum Mainnet" {
newSettings[keys.E2cc_lc_common_checkpoint_sync_url] = cfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value
} else {
newSettings[keys.E2cc_lc_common_checkpoint_sync_url] = cfg.ConsensusCommon.CheckpointSyncProviderPrater.Value
}

newSettings[keys.E2cc_lc_common_checkpoint_sync_url] = cfg.ConsensusCommon.CheckpointSyncProvider.Value
newSettings[keys.E2cc_lc_common_p2p_port] = format(cfg.ConsensusCommon.P2pPort.Value)
newSettings[keys.E2cc_lc_common_http_api_port] = format(cfg.ConsensusCommon.ApiPort.Value)
newSettings[keys.E2cc_lc_common_expose_api_port] = cfg.ConsensusCommon.OpenApiPort.Value.(bool)
Expand Down Expand Up @@ -190,12 +182,6 @@ func updateLocalConsensusClient(newCfg *stdCf.StaderConfig, settings map[string]
newCfg.ConsensusCommon.OpenApiPort.Value = settings[keys.E2cc_lc_common_expose_api_port]
newCfg.ConsensusCommon.DoppelgangerDetection.Value = settings[keys.E2cc_lc_common_doppelganger_detection]

if newCfg.StaderNode.Network.Value.(config.Network) == config.Network_Mainnet {
newCfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value = settings[keys.E2cc_lc_common_checkpoint_sync_url]
} else {
newCfg.ConsensusCommon.CheckpointSyncProviderPrater.Value = settings[keys.E2cc_lc_common_checkpoint_sync_url]
}

clientStr, ok := settings[keys.E2cc_lc_consensus_client].(string)
if !ok {
return fmt.Errorf("Invalid External client %+v", settings[keys.E1ec_lm_execution_client])
Expand Down
27 changes: 1 addition & 26 deletions stader-cli/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,7 @@ func UpdateConfig(_cfg *config.StaderConfig, newSettings *pages.SettingsType) (c
}
cfg.ConsensusCommon.DoppelgangerDetection.Value = ConvertStringToBool(newSettings.ConsensusClient.DoppelgangerProtection)
cfg.ConsensusCommon.Graffiti.Value = newSettings.ConsensusClient.Graffit

switch cfgtypes.Network(newSettings.Network) {
case cfgtypes.Network_Mainnet:
cfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value = newSettings.ConsensusClient.CheckpointUrlMainnet
cfg.ConsensusCommon.CheckpointSyncProvider.Value = newSettings.ConsensusClient.CheckpointUrlMainnet
case cfgtypes.Network_Prater:
cfg.ConsensusCommon.CheckpointSyncProviderPrater.Value = newSettings.ConsensusClient.CheckpointUrlPrater
cfg.ConsensusCommon.CheckpointSyncProvider.Value = newSettings.ConsensusClient.CheckpointUrlPrater
default:
panic("UNSUPPORT NETWORK")
}
cfg.ConsensusCommon.CheckpointSyncProvider.Value = newSettings.ConsensusClient.CheckpointUrl

cfg.UseFallbackClients.Value = ConvertStringToBool(newSettings.FallbackClients.SelectionOption)
// get the consensus client we are using for fallback
Expand Down Expand Up @@ -308,19 +298,6 @@ func UpdateConfig(_cfg *config.StaderConfig, newSettings *pages.SettingsType) (c

func NewSettingsType(cfg *config.StaderConfig) pages.SettingsType {

checkpointUrlPrater := cfg.ConsensusCommon.CheckpointSyncProviderPrater.Value.(string)
checkpointUrlMainnet := cfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value.(string)

// Set default for older version (< 1.4.0)
// After 1.4.0 w expected to mainnet or prater checkpoint is not empty
if checkpointUrlPrater == "" && checkpointUrlMainnet == "" {
if cfg.StaderNode.Network.Value.(cfgtypes.Network) == cfgtypes.Network_Mainnet {
cfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value = cfg.ConsensusCommon.CheckpointSyncProvider.Value
} else {
cfg.ConsensusCommon.CheckpointSyncProviderPrater.Value = cfg.ConsensusCommon.CheckpointSyncProvider.Value
}
}

currentSettings := pages.SettingsType{
Version: shared.StaderVersion,
Network: string(cfg.StaderNode.Network.Value.(cfgtypes.Network)),
Expand All @@ -337,8 +314,6 @@ func NewSettingsType(cfg *config.StaderConfig) pages.SettingsType {
ExternalSelection: string(cfg.ExternalConsensusClient.Value.(cfgtypes.ConsensusClient)),
Graffit: cfg.ConsensusCommon.Graffiti.Value.(string),
CheckpointUrl: cfg.ConsensusCommon.CheckpointSyncProvider.Value.(string),
CheckpointUrlMainnet: cfg.ConsensusCommon.CheckpointSyncProviderMainnet.Value.(string),
CheckpointUrlPrater: cfg.ConsensusCommon.CheckpointSyncProviderPrater.Value.(string),
DoppelgangerProtection: ConvertBoolToString(cfg.ConsensusCommon.DoppelgangerDetection.Value.(bool)),
External: pages.ConsensusClientExternalType{
Lighthouse: pages.ConsensusClientExternalSelectedLighthouseType{
Expand Down

0 comments on commit 839f69c

Please sign in to comment.