Skip to content
25 changes: 10 additions & 15 deletions addons/rescue_node/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ import (
"github.com/rocket-pool/smartnode/addons/rescue_node/pb"
"github.com/rocket-pool/smartnode/shared/types/addons"
cfgtypes "github.com/rocket-pool/smartnode/shared/types/config"
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
)

const (
colorReset string = "\033[0m"
colorRed string = "\033[31m"
colorGreen string = "\033[32m"
colorYellow string = "\033[33m"
colorBlue string = "\033[36m"

soloAuthValidity = 10 * time.Hour * 24
rpAuthValidity = 15 * time.Hour * 24
)
Expand Down Expand Up @@ -129,33 +124,33 @@ func (r *RescueNode) PrintStatusText(nodeAddr common.Address) {
return
}

fmt.Printf("%s=== Rescue Node Add-on Enabled ===%s\n", colorYellow, colorReset)
color.YellowPrintln("=== Rescue Node Add-on Enabled ===")
// Check the Username
usernameNodeAddr, err := r.getCredentialNodeId()
if err != nil {
fmt.Printf("%s%v%s\n", colorRed, err, colorReset)
color.RedPrintln(err.Error())
} else {
fmt.Printf("Using a credential issued to %s%s%s.\n", colorBlue, usernameNodeAddr.String(), colorReset)
fmt.Printf("Using a credential issued to %s.\n", color.LightBlue(usernameNodeAddr.String()))
if !bytes.Equal(usernameNodeAddr.Bytes(), nodeAddr.Bytes()) {
fmt.Printf("%s - WARNING: This does not match the Node Account!%s\n", colorYellow, colorReset)
color.YellowPrintln(" - WARNING: This does not match the Node Account!")
}
}

credentialDetails, err := r.getCredentialDetails()
if err != nil {
fmt.Printf("%s%v%s\n", colorRed, err, colorReset)
color.RedPrintln(err.Error())
} else {
if credentialDetails.solo {
fmt.Printf("%s - WARNING: This credential was issued to a solo staker!%s\n", colorYellow, colorReset)
color.YellowPrintln(" - WARNING: This credential was issued to a solo staker!")
}

timeLeft := credentialDetails.GetTimeLeft().Truncate(time.Second)
if timeLeft < 0 {
fmt.Printf("%sWARNING: This credential expired %s ago!%s\n", colorRed, timeLeft.String(), colorReset)
color.RedPrintf("WARNING: This credential expired %s ago!\n", timeLeft.String())
} else if timeLeft < time.Hour*24 {
fmt.Printf("%sWARNING: This credential expires in %s!%s\n", colorYellow, timeLeft.String(), colorReset)
color.YellowPrintf("WARNING: This credential expires in %s!\n", timeLeft.String())
} else {
fmt.Printf("%sThis credential expires in %s.%s\n", colorGreen, timeLeft.String(), colorReset)
color.GreenPrintf("This credential expires in %s.\n", timeLeft.String())
}
}
}
Expand Down
240 changes: 131 additions & 109 deletions rocketpool-cli/claims/claim-all.go

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions rocketpool-cli/megapool/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ import (
"github.com/rocket-pool/smartnode/shared/services/rocketpool"
"github.com/rocket-pool/smartnode/shared/types/api"
cliutils "github.com/rocket-pool/smartnode/shared/utils/cli"
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
"github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
"github.com/rocket-pool/smartnode/shared/utils/math"
)

// Config
const (
colorReset string = "\033[0m"
colorRed string = "\033[31m"
colorGreen string = "\033[32m"
colorYellow string = "\033[33m"
maxCount uint64 = 35
maxCount uint64 = 35
)

func nodeMegapoolDeposit(c *cli.Context) error {
Expand Down Expand Up @@ -138,7 +135,10 @@ func nodeMegapoolDeposit(c *cli.Context) error {
fmt.Printf("The total bond requirement is %.2f ETH.\n", totalBondRequirementEth)
fmt.Println()

if !(c.Bool("yes") || prompt.Confirm("%sNOTE: You are about to create %d new megapool validator(s), requiring a total of: %.2f ETH).%s\nWould you like to continue?", colorYellow, count, totalBondRequirementEth, colorReset)) {
if !(c.Bool("yes") || prompt.Confirm("%s%s",
color.YellowSprintf("NOTE: You are about to create %d new megapool validator(s), requiring a total of: %.2f ETH).\n", count, totalBondRequirementEth),
"Would you like to continue?",
)) {
fmt.Println("Cancelled.")
return nil
}
Expand Down Expand Up @@ -230,9 +230,10 @@ func nodeMegapoolDeposit(c *cli.Context) error {
fmt.Printf("This deposit will use %.6f ETH from your credit balance plus ETH staked on your behalf and will not require any ETH from your node wallet.\n\n", eth.WeiToEth(usableCredit))
}
} else {
fmt.Printf("%sNOTE: Your credit balance cannot currently be used to create a new megapool validator.\n"+
"This may be because the deposit pool has insufficient ETH or the credit balance is not enough to cover any part of the deposit.%s\n"+
"If you want to continue the deposit now, you will have to pay the full bond amount from your wallet.\n\n", colorYellow, colorReset)
color.YellowPrintln("NOTE: Your credit balance cannot currently be used to create a new megapool validator.")
color.YellowPrintln("This may be because the deposit pool has insufficient ETH or the credit balance is not enough to cover any part of the deposit.")
color.YellowPrintln("If you want to continue the deposit now, you will have to pay the full bond amount from your wallet.")
fmt.Println()
}
// Prompt for confirmation
if !(c.Bool("yes") || prompt.Confirm("Would you like to continue?")) {
Expand All @@ -243,24 +244,23 @@ func nodeMegapoolDeposit(c *cli.Context) error {
}

// Check to see if eth2 is synced
colorReset := "\033[0m"
colorRed := "\033[31m"
colorYellow := "\033[33m"
syncResponse, err := rp.NodeSync()
if err != nil {
fmt.Printf("%s**WARNING**: Can't verify the sync status of your consensus client.\nYOU WILL LOSE ETH if your megapool validator is activated before it is fully synced.\n"+
"Reason: %s\n%s", colorRed, err, colorReset)
color.RedPrintln("**WARNING**: Can't verify the sync status of your consensus client.")
color.RedPrintln("YOU WILL LOSE ETH if your megapool validator is activated before it is fully synced.")
color.RedPrintf("Reason: %s\n", err)
} else {
if syncResponse.BcStatus.PrimaryClientStatus.IsSynced {
fmt.Printf("Your consensus client is synced, you may safely create a megapool validator.\n")
fmt.Println("Your consensus client is synced, you may safely create a megapool validator.")
} else if syncResponse.BcStatus.FallbackEnabled {
if syncResponse.BcStatus.FallbackClientStatus.IsSynced {
fmt.Printf("Your fallback consensus client is synced, you may safely create a megapool validator.\n")
fmt.Println("Your fallback consensus client is synced, you may safely create a megapool validator.")
} else {
fmt.Printf("%s**WARNING**: neither your primary nor fallback consensus clients are fully synced.\nYOU WILL LOSE ETH if your megapool validator is activated before they are fully synced.\n%s", colorRed, colorReset)
color.RedPrintln("**WARNING**: neither your primary nor fallback consensus clients are fully synced.")
color.RedPrintln("YOU WILL LOSE ETH if your megapool validator is activated before they are fully synced.")
}
} else {
fmt.Printf("%s**WARNING**: your primary consensus client is either not fully synced or offline and you do not have a fallback client configured.\nYOU WILL LOSE ETH if your megapool validator is activated before it is fully synced.\n%s", colorRed, colorReset)
color.RedPrintln("**WARNING**: your primary consensus client is either not fully synced or offline and you do not have a fallback client configured.")
}
}

Expand All @@ -272,13 +272,11 @@ func nodeMegapoolDeposit(c *cli.Context) error {

// Prompt for confirmation

if !(c.Bool("yes") || prompt.Confirm(
"You are about to deposit %.6f ETH to create %d new megapool validator(s).\n"+
"%sARE YOU SURE YOU WANT TO DO THIS? %s\n",
if !(c.Bool("yes") || prompt.Confirm("You are about to deposit %.6f ETH to create %d new megapool validator(s).\n%s",
math.RoundDown(eth.WeiToEth(totalBondRequirement), 6),
count,
colorYellow,
colorReset)) {
color.Yellow("ARE YOU SURE YOU WANT TO DO THIS?"),
)) {
fmt.Println("Cancelled.")
return nil
}
Expand Down
13 changes: 8 additions & 5 deletions rocketpool-cli/megapool/exit-validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/rocket-pool/smartnode/shared/services/rocketpool"
"github.com/rocket-pool/smartnode/shared/types/api"
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
"github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -76,11 +77,13 @@ func exitValidator(c *cli.Context) error {
}

// Show a warning message
fmt.Printf("%sNOTE:\n", colorYellow)
fmt.Println("You are about to exit a validator. This will tell each the validator to stop all activities on the Beacon Chain.")
fmt.Println("Please continue to run your validators until each one you've exited has been processed by the exit queue.\nYou can watch their progress on the https://beaconcha.in explorer.")
fmt.Println("Your funds will be locked on the Beacon Chain until they've been withdrawn, which will happen automatically (this may take a few days).")
fmt.Printf("Once your funds have been withdrawn, you can run `rocketpool megapool notify-validator-exit` to distribute them to your withdrawal address.\n\n%s", colorReset)
color.YellowPrintln("NOTE:")
color.YellowPrintln("You are about to exit a validator. This will tell each the validator to stop all activities on the Beacon Chain.")
color.YellowPrintln("Please continue to run your validators until each one you've exited has been processed by the exit queue.")
color.YellowPrintln("You can watch their progress on the https://beaconcha.in explorer.")
color.YellowPrintln("Your funds will be locked on the Beacon Chain until they've been withdrawn, which will happen automatically (this may take a few days).")
color.YellowPrintln("Once your funds have been withdrawn, you can run `rocketpool megapool notify-validator-exit` to distribute them to your withdrawal address.")
fmt.Println()

// Prompt for confirmation
if !(c.Bool("yes") || prompt.Confirm("Are you sure you want to EXIT validator id %d?", validatorId)) {
Expand Down
3 changes: 2 additions & 1 deletion rocketpool-cli/megapool/notify-final-balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/rocket-pool/smartnode/shared/types/api"
cfgtypes "github.com/rocket-pool/smartnode/shared/types/config"
cliutils "github.com/rocket-pool/smartnode/shared/utils/cli"
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
"github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -89,7 +90,7 @@ func notifyFinalBalance(c *cli.Context) error {
}
}

fmt.Printf("%sFetching the beacon state to craft a final balance proof. This process can take several minutes and is CPU and memory intensive.%s", colorYellow, colorReset)
color.YellowPrintln("Fetching the beacon state to craft a final balance proof. This process can take several minutes and is CPU and memory intensive.")
fmt.Println()

response, err := rp.CanNotifyFinalBalance(validatorId, slot)
Expand Down
30 changes: 15 additions & 15 deletions rocketpool-cli/megapool/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

"github.com/rocket-pool/smartnode/shared/services/rocketpool"
cliutils "github.com/rocket-pool/smartnode/shared/utils/cli"
"github.com/rocket-pool/smartnode/shared/utils/cli/color"
"github.com/rocket-pool/smartnode/shared/utils/math"
"github.com/urfave/cli"
)

const (
TimeFormat = "2006-01-02, 15:04 -0700 MST"
colorBlue string = "\033[36m"
TimeFormat = "2006-01-02, 15:04 -0700 MST"
)

func getStatus(c *cli.Context) error {
Expand Down Expand Up @@ -59,10 +59,10 @@ func getStatus(c *cli.Context) error {
}

// Address, express tickets, validator count
fmt.Printf("%s=== Megapool ===%s\n", colorGreen, colorReset)
fmt.Printf("The node has a megapool deployed at %s%s%s\n", colorBlue, status.Megapool.Address, colorReset)
color.GreenPrintln("=== Megapool ===")
fmt.Printf("The node has a megapool deployed at %s\n", color.LightBlue(status.Megapool.Address.String()))
if status.Megapool.DelegateExpired {
fmt.Printf("%sThe megapool delegate is expired.%s\n", colorRed, colorReset)
color.RedPrintln("The megapool delegate is expired.")
fmt.Println("Upgrade your megapool delegate using 'rocketpool megapool delegate-upgrade' to view the express ticket and validator count.")
} else {
fmt.Printf("The node has %d express ticket(s).\n", status.Megapool.NodeExpressTicketCount)
Expand All @@ -71,33 +71,33 @@ func getStatus(c *cli.Context) error {
fmt.Println()

// Delegate addresses
fmt.Printf("%s=== Megapool Delegate ===%s\n", colorGreen, colorReset)
color.GreenPrintln("=== Megapool Delegate ===")
if status.Megapool.DelegateExpired {
fmt.Printf("%sThe megapool delegate is expired.%s\n", colorRed, colorReset)
fmt.Printf("The megapool is using an expired delegate at %s%s%s\n", colorBlue, status.Megapool.DelegateAddress, colorReset)
fmt.Printf("The megapool can be upgraded to delegate %s%s%s using 'rocketpool megapool delegate-upgrade'.\n", colorBlue, status.LatestDelegate, colorReset)
color.RedPrintln("The megapool delegate is expired.")
fmt.Printf("The megapool is using an expired delegate at %s\n", color.LightBlue(status.Megapool.DelegateAddress.String()))
fmt.Printf("The megapool can be upgraded to delegate %s using 'rocketpool megapool delegate-upgrade'.\n", color.LightBlue(status.LatestDelegate.String()))
} else {
if status.Megapool.EffectiveDelegateAddress == status.LatestDelegate {
fmt.Println("The megapool is using the latest delegate.")
} else {
fmt.Printf("The megapool is using an outdated delegate at %s%s%s\n", colorBlue, status.Megapool.DelegateAddress, colorReset)
fmt.Printf("The megapool can be upgraded to delegate %s%s%s using 'rocketpool megapool delegate-upgrade'.\n", colorBlue, status.LatestDelegate, colorReset)
fmt.Printf("The megapool is using an outdated delegate at %s\n", color.LightBlue(status.Megapool.DelegateAddress.String()))
fmt.Printf("The megapool can be upgraded to delegate %s using 'rocketpool megapool delegate-upgrade'.\n", color.LightBlue(status.LatestDelegate.String()))
}
fmt.Printf("The megapool's effective delegate address is %s%s%s\n", colorBlue, status.Megapool.EffectiveDelegateAddress, colorReset)
fmt.Printf("The megapool's effective delegate address is %s\n", color.LightBlue(status.Megapool.EffectiveDelegateAddress.String()))
}

if status.Megapool.UseLatestDelegate {
fmt.Println("The megapool is set to automatically upgrade to the latest delegate. You can toggle this setting using 'rocketpool megapool set-use-latest-delegate'.")
} else {
fmt.Println("The megapool has automatic delegate upgrades disabled. You can toggle this setting using 'rocketpool megapool set-use-latest-delegate'.")
if status.Megapool.DelegateExpiry > 0 {
fmt.Printf("Your current megapool delegate expires at %sblock %d%s.\n", colorBlue, status.Megapool.DelegateExpiry, colorReset)
fmt.Printf("Your current megapool delegate expires at %s.\n", color.LightBlueSprintf("block %d", status.Megapool.DelegateExpiry))
}
}
fmt.Println()

// Balance and network commission
fmt.Printf("%s=== Megapool Balance ===%s\n", colorGreen, colorReset)
color.GreenPrintln("=== Megapool Balance ===")
if !status.Megapool.DelegateExpired {
totalBond := new(big.Int).Mul(status.Megapool.NodeBond, big.NewInt(8))
rpBond := new(big.Int).Sub(totalBond, status.Megapool.NodeBond)
Expand Down Expand Up @@ -172,7 +172,7 @@ func getValidatorStatus(c *cli.Context) error {

// Return if delegate is expired
if status.Megapool.DelegateExpired {
fmt.Printf("%sThe megapool delegate is expired.%s\n", colorRed, colorReset)
color.RedPrintln("The megapool delegate is expired.")
fmt.Println("Upgrade your megapool delegate using 'rocketpool megapool delegate-upgrade' to view the validator info.")
return nil
}
Expand Down
Loading
Loading