Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions rocketpool-cli/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,25 @@ func PrintDepositMismatchError(rpNetwork, beaconNetwork uint64, rpDepositAddress
}

// Prints what network you're currently on
func PrintNetwork(currentNetwork cfgtypes.Network, isNew bool) error {
func PrintNetwork(info *cfgtypes.NetworkInfo, isNew bool) error {
if isNew {
return fmt.Errorf("Settings file not found. Please run `rocketpool service config` to set up your Smart Node.")
}

var networkName string

switch currentNetwork {
case cfgtypes.Network_Mainnet:
networkName = color.Green("Ethereum Mainnet")
case cfgtypes.Network_Devnet:
networkName = color.Yellow("Development Network")
case cfgtypes.Network_Testnet:
networkName = color.Yellow("Hoodi Test Network")
default:
color.YellowPrintf("You are on an unexpected network [%v].\n", currentNetwork)
if info == nil {
color.YellowPrintf("You are on an unexpected network.\n")
fmt.Println()
return nil
}

fmt.Printf("Your Smart Node is currently using the %s.\n", networkName)
networkName := info.Label
if info.IsProduction {
networkName = color.Green(networkName)
} else {
networkName = color.Yellow(networkName)
}

fmt.Printf("Your Smart Node is currently using the %s network.\n", networkName)
fmt.Println()

return nil
Expand Down
13 changes: 3 additions & 10 deletions rocketpool-cli/megapool/notify-final-balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/rocket-pool/smartnode/shared/services/gas"
"github.com/rocket-pool/smartnode/shared/services/rocketpool"
"github.com/rocket-pool/smartnode/shared/types/api"
cfgtypes "github.com/rocket-pool/smartnode/shared/types/config"
)

func getNotifiableValidator() (uint64, uint64, bool, error) {
Expand Down Expand Up @@ -242,17 +241,11 @@ func notifyFinalBalance(validatorId, validatorIndex, slot uint64, yes bool) erro

// returns the Beaconcha.in withdrawals URL for a validator index.
func getBeaconChainURL(index uint64, cfg *config.RocketPoolConfig) string {
network := cfg.GetNetwork()

var baseURL string
switch network {
case cfgtypes.Network_Mainnet:
baseURL = "https://beaconcha.in"
case cfgtypes.Network_Devnet, cfgtypes.Network_Testnet:
baseURL = "https://hoodi.beaconcha.in"
default:
info := cfg.GetNetworkInfo()
if info == nil || info.BeaconExplorerUrl == "" {
return ""
}
baseURL := info.BeaconExplorerUrl

return fmt.Sprintf("%s/validator/%d#withdrawals", baseURL, index)
}
4 changes: 2 additions & 2 deletions rocketpool-cli/megapool/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getStatus() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func getValidatorStatus() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/network/dao-proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getActiveDAOProposals() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/node/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func getStatus() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/node/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func getSyncProgress() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/pdao/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func getStatus() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion rocketpool-cli/service/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ func createFlagsFromConfigParams(sectionName string, params []*cfgtypes.Paramete
// Register commands
func RegisterCommands(app *cli.Command, name string, aliases []string) {

cfgTemplate := config.NewRocketPoolConfig("", false)
cfgTemplate, err := config.NewRocketPoolConfig("", false)
if err != nil {
panic(err)
}
network := cfgTemplate.Smartnode.Network.Value.(cfgtypes.Network)

// Root params
Expand Down
3 changes: 1 addition & 2 deletions rocketpool-cli/service/config/step-finished.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func createFinishedStep(wiz *wizard, currentStep int, totalSteps int) *choiceWiz
}

back := func() {
if wiz.md.Config.Smartnode.Network.Value == cfgtypes.Network_Testnet || wiz.md.Config.Smartnode.Network.Value == cfgtypes.Network_Devnet {
// Skip MEV for testnet/devnet
if !wiz.md.Config.SupportsMevBoost() {
wiz.metricsModal.show()
} else {
wiz.mevModeModal.show()
Expand Down
5 changes: 1 addition & 4 deletions rocketpool-cli/service/config/step-metrics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package config

import "github.com/rocket-pool/smartnode/shared/types/config"

func createMetricsStep(wiz *wizard, currentStep int, totalSteps int) *choiceWizardStep {

helperText := "Would you like to enable the Smart Node's metrics monitoring system? This will monitor things such as hardware stats (CPU usage, RAM usage, free disk space), your minipool stats, stats about your node such as total RPL and ETH rewards, and much more. It also enables the Grafana dashboard to quickly and easily view these metrics (see https://docs.rocketpool.net/node-staking/grafana for an example).\n\nNone of this information will be sent to any remote servers for collection an analysis; this is purely for your own usage on your node."
Expand All @@ -21,8 +19,7 @@ func createMetricsStep(wiz *wizard, currentStep int, totalSteps int) *choiceWiza
} else {
wiz.md.Config.EnableMetrics.Value = false
}
if wiz.md.Config.Smartnode.Network.Value == config.Network_Testnet || wiz.md.Config.Smartnode.Network.Value == config.Network_Devnet {
// Skip MEV for Testnet/Devnet
if !wiz.md.Config.SupportsMevBoost() {
wiz.finishedModal.show()
} else {
wiz.mevModeModal.show()
Expand Down
5 changes: 1 addition & 4 deletions rocketpool-cli/service/config/step-native-finished.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"strings"

"github.com/rivo/tview"

"github.com/rocket-pool/smartnode/shared/types/config"
)

func createNativeFinishedStep(wiz *wizard, currentStep int, totalSteps int) *choiceWizardStep {
Expand Down Expand Up @@ -33,8 +31,7 @@ func createNativeFinishedStep(wiz *wizard, currentStep int, totalSteps int) *cho
}

back := func() {
if wiz.md.Config.Smartnode.Network.Value == config.Network_Testnet || wiz.md.Config.Smartnode.Network.Value == config.Network_Devnet {
// Skip MEV for Testnet/Devnet
if !wiz.md.Config.SupportsMevBoost() {
wiz.nativeMetricsModal.show()
} else {
wiz.nativeMevModal.show()
Expand Down
5 changes: 1 addition & 4 deletions rocketpool-cli/service/config/step-native-metrics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package config

import "github.com/rocket-pool/smartnode/shared/types/config"

func createNativeMetricsStep(wiz *wizard, currentStep int, totalSteps int) *choiceWizardStep {

helperText := "Would you like to enable the daemon's metrics feature? This will allow you to access the Rocket Pool network's metrics and the metrics for your own node wallet in the Grafana dashboard."
Expand All @@ -21,8 +19,7 @@ func createNativeMetricsStep(wiz *wizard, currentStep int, totalSteps int) *choi
} else {
wiz.md.Config.EnableMetrics.Value = false
}
if wiz.md.Config.Smartnode.Network.Value == config.Network_Testnet || wiz.md.Config.Smartnode.Network.Value == config.Network_Devnet {
// Skip MEV for Testnet/Devnet
if !wiz.md.Config.SupportsMevBoost() {
wiz.nativeFinishedModal.show()
} else {
wiz.nativeMevModal.show()
Expand Down
11 changes: 7 additions & 4 deletions rocketpool-cli/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func serviceStatus(composeFiles []string) error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ func pruneExecutionClient(yes bool) error {
}
freeSpaceHuman := humanize.IBytes(diskUsage.Free)
pruneFreeSpaceRequired := PruneFreeSpaceRequired
if cfg.GetNetwork() == cfgtypes.Network_Mainnet && selectedEc == cfgtypes.ExecutionClient_Nethermind {
if info := cfg.GetNetworkInfo(); info != nil && info.IsProduction && selectedEc == cfgtypes.ExecutionClient_Nethermind {
pruneFreeSpaceRequired = NethermindPruneFreeSpaceRequired
}
if diskUsage.Free < pruneFreeSpaceRequired {
Expand Down Expand Up @@ -1381,7 +1381,7 @@ func serviceVersion() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down Expand Up @@ -1752,7 +1752,10 @@ func resyncEth2(yes bool, composeFiles []string) error {

// Generate a YAML file that shows the current configuration schema, including all of the parameters and their descriptions
func getConfigYaml() error {
cfg := config.NewRocketPoolConfig("", false)
cfg, err := config.NewRocketPoolConfig("", false)
if err != nil {
return fmt.Errorf("error creating configuration schema: %w", err)
}
bytes, err := yaml.Marshal(cfg)
if err != nil {
return fmt.Errorf("error serializing configuration schema: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/wallet/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func getStatus() error {
}

// Print what network we're on
err = cliutils.PrintNetwork(cfg.GetNetwork(), isNew)
err = cliutils.PrintNetwork(cfg.GetNetworkInfo(), isNew)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions rocketpool/api/node/create-vacant-minipool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/beacon"
"github.com/rocket-pool/smartnode/shared/types/api"
cfgtypes "github.com/rocket-pool/smartnode/shared/types/config"
)

func canCreateVacantMinipool(c *cli.Command, amountWei *big.Int, minNodeFee float64, salt *big.Int, pubkey rptypes.ValidatorPubkey) (*api.CanCreateVacantMinipoolResponse, error) {
Expand Down Expand Up @@ -136,7 +135,7 @@ func canCreateVacantMinipool(c *cli.Command, amountWei *big.Int, minNodeFee floa
if validatorStatus.Status != beacon.ValidatorState_ActiveOngoing {
return nil, fmt.Errorf("validator %s must be in the active_ongoing state to be migrated, but it is currently in %s.", pubkey.Hex(), string(validatorStatus.Status))
}
if cfg.Smartnode.Network.Value.(cfgtypes.Network) != cfgtypes.Network_Devnet && validatorStatus.WithdrawalCredentials[0] != 0x00 {
if info := cfg.GetNetworkInfo(); (info == nil || !info.AllowNonBlsWithdrawalCredentials) && validatorStatus.WithdrawalCredentials[0] != 0x00 {
return nil, fmt.Errorf("validator %s already has withdrawal credentials [%s], which are not BLS credentials.", pubkey.Hex(), validatorStatus.WithdrawalCredentials.Hex())
}

Expand Down Expand Up @@ -245,7 +244,7 @@ func createVacantMinipool(c *cli.Command, amountWei *big.Int, minNodeFee float64
if validatorStatus.Status != beacon.ValidatorState_ActiveOngoing {
return nil, fmt.Errorf("validator %s must be in the active_ongoing state to be migrated, but it is currently in %s.", pubkey.Hex(), string(validatorStatus.Status))
}
if cfg.Smartnode.Network.Value.(cfgtypes.Network) != cfgtypes.Network_Devnet && validatorStatus.WithdrawalCredentials[0] != 0x00 {
if info := cfg.GetNetworkInfo(); (info == nil || !info.AllowNonBlsWithdrawalCredentials) && validatorStatus.WithdrawalCredentials[0] != 0x00 {
return nil, fmt.Errorf("validator %s already has withdrawal credentials [%s], which are not BLS credentials.", pubkey.Hex(), validatorStatus.WithdrawalCredentials.Hex())
}

Expand Down
7 changes: 0 additions & 7 deletions rocketpool/node/auto-tx-gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ func loadAutoTxGas(cfg *config.RocketPoolConfig, logger *log.ColorLogger) autoTx
maxPriorityFee = math.GweiToWei(priorityFeeGwei)
}

maxFeeGweiLog := 0.0
if maxFee != nil {
maxFeeGweiLog = math.WeiToGwei(maxFee)
}
logger.Printlnf("Loaded auto-tx gas: threshold=%.4f gwei, maxFee=%.4f gwei (0=oracle), priorityFee=%.4f gwei",
thresholdGwei, maxFeeGweiLog, math.WeiToGwei(maxPriorityFee))

return autoTxGas{
thresholdGwei: thresholdGwei,
maxFee: maxFee,
Expand Down
5 changes: 4 additions & 1 deletion rocketpool/watchtower/submit-network-balances-state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func TestGetNetworkBalancesFromState(t *testing.T) {
}

logger := log.NewColorLogger(0)
cfg := config.NewRocketPoolConfig("", false)
cfg, err := config.NewRocketPoolConfig("", false)
if err != nil {
t.Fatal(err)
}
rewardCalc := &stubRewardSplitCalculator{}
spCalc := &stubSmoothingPoolCalculator{}
wFinder := &stubWithdrawalFinder{}
Expand Down
5 changes: 4 additions & 1 deletion shared/services/alerting/alerting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func makeTestConfig(serverURL string) (*config.RocketPoolConfig, error) {
return nil, fmt.Errorf("parsing test server port: %w", err)
}

cfg := config.NewRocketPoolConfig("", true /* isNativeMode */)
cfg, err := config.NewRocketPoolConfig("", true /* isNativeMode */)
if err != nil {
return nil, err
}
cfg.Alertmanager.EnableAlerting.Value = true
cfg.Alertmanager.NativeModeHost.Value = u.Hostname()
cfg.Alertmanager.NativeModePort.Value = uint16(port)
Expand Down
10 changes: 5 additions & 5 deletions shared/services/config/api-config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestGetNodeOpenPorts(t *testing.T) {
cfg := NewRocketPoolConfig("/tmp/rp-test", false)
cfg := mustNewRocketPoolConfig(t, "/tmp/rp-test", false)

cfg.Api.OpenApiPort.Value = cfgtypes.RPC_Closed
if got := cfg.GetNodeOpenPorts(); got != "" {
Expand Down Expand Up @@ -41,15 +41,15 @@ func TestTokenPathExpandsTilde(t *testing.T) {
}

func TestDefaultRateLimit(t *testing.T) {
cfg := NewRocketPoolConfig("/tmp/rp-test", false)
cfg := mustNewRocketPoolConfig(t, "/tmp/rp-test", false)
got, ok := cfg.Api.RateLimit.Value.(uint16)
if !ok || got != 0 {
t.Fatalf("default rate limit %v (%T), want 0", cfg.Api.RateLimit.Value, cfg.Api.RateLimit.Value)
}
}

func TestSensitiveTokenNotSerialized(t *testing.T) {
cfg := NewRocketPoolConfig("/tmp/rp-test", false)
cfg := mustNewRocketPoolConfig(t, "/tmp/rp-test", false)
cfg.Api.APIToken.Value = "rpsn_secret"
cfg.Api.TokenComment.Value = "not in yaml"
serialized := cfg.Serialize()
Expand All @@ -62,7 +62,7 @@ func TestSensitiveTokenNotSerialized(t *testing.T) {
}

func TestTokenPathUsesCLIFlag(t *testing.T) {
cfg := NewRocketPoolConfig("/tmp/rp-cli", false)
cfg := mustNewRocketPoolConfig(t, "/tmp/rp-cli", false)
cfg.IsCLI = true
got := cfg.Api.GetAPITokenPath()
if filepath.Base(got) != "api-tokens.json" {
Expand All @@ -72,7 +72,7 @@ func TestTokenPathUsesCLIFlag(t *testing.T) {
t.Fatal("CLI should not use the in-container data path")
}

daemon := NewRocketPoolConfig("/tmp/rp-daemon", false)
daemon := mustNewRocketPoolConfig(t, "/tmp/rp-daemon", false)
if daemon.Api.GetAPITokenPath() != tokenPath(DaemonDataPath) {
t.Fatalf("docker daemon path %q", daemon.Api.GetAPITokenPath())
}
Expand Down
14 changes: 5 additions & 9 deletions shared/services/config/besu-params.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ func NewBesuConfig(cfg *RocketPoolConfig) *BesuConfig {
},

ContainerTag: config.Parameter{
ID: "containerTag",
Name: "Container Tag",
Description: "The tag name of the Besu container you want to use on Docker Hub.",
Type: config.ParameterType_String,
Default: map[config.Network]interface{}{
config.Network_Mainnet: besuTagProd,
config.Network_Devnet: besuTagTest,
config.Network_Testnet: besuTagTest,
},
ID: "containerTag",
Name: "Container Tag",
Description: "The tag name of the Besu container you want to use on Docker Hub.",
Type: config.ParameterType_String,
Default: clientTagDefaults(cfg.networks, besuTagProd, besuTagTest),
AffectsContainers: []config.ContainerID{config.ContainerID_Eth1},
CanBeBlank: false,
OverwriteOnUpgrade: true,
Expand Down
Loading
Loading