Skip to content

Commit

Permalink
Merge branch 'rocket-pool:master' into benv666/metrics-env-override
Browse files Browse the repository at this point in the history
  • Loading branch information
benv666 authored Jul 14, 2022
2 parents 023af1d + 680a37a commit e44ea47
Show file tree
Hide file tree
Showing 26 changed files with 881 additions and 324 deletions.
19 changes: 15 additions & 4 deletions rocketpool-cli/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ ______ _ _ ______ _
fmt.Printf("%s=== Voting Support ===%s\n", colorGreen, colorReset)
fmt.Println("`rocketpool node set-voting-delegate` can be used to specify an Ethereum address you would like represent your node when voting on Rocket Pool DAO governance proposals.\nThis should be something you can safely use with a browser.\nA full write-up of DAO voting, Snapshot, and this command will be released soon - stay tuned!\n")

fmt.Printf("%s=== Nethermind Pruning ===%s\n", colorGreen, colorReset)
fmt.Println("You can now use `rocketpool service prune-eth1` to prune Nethermind when your disk space is running low.\n")

fmt.Printf("%s=== Custom Validator Key Importing ===%s\n", colorGreen, colorReset)
fmt.Println("`rocketpool wallet recover` now lets you recover validator keys for your minipools that were generated outside of the Smartnode stack (e.g. via Allnodes). You can use this to migrate them to your own self-managed node!\nTake a look at the guides to learn more: https://docs.rocketpool.net/guides/node/recovering-rp.html\n")

fmt.Printf("%s=== Light Client Deprecation ===%s\n", colorGreen, colorReset)
fmt.Println("Infura and Pocket are now deprecated because light clients will not be compatible with the upcoming Ethereum Merge. They will be removed in a later version. If you're running one of these, either as your primary or your fallback client, you should prepare to move away from them and use a full Execution client instead.")

Expand Down Expand Up @@ -891,10 +897,8 @@ func pruneExecutionClient(c *cli.Context) error {
if cfg.IsNativeMode {
fmt.Println("You are using Native Mode.\nThe Smartnode cannot prune your Execution client for you, you'll have to do it manually.")
}
switch cfg.ExecutionClient.Value.(config.ExecutionClient) {
case config.ExecutionClient_Nethermind:
fmt.Println("You are using Nethermind as your Execution client.\nNethermind pruning is not supported yet.")
return nil
selectedEc := cfg.ExecutionClient.Value.(config.ExecutionClient)
switch selectedEc {
case config.ExecutionClient_Besu:
fmt.Println("You are using Besu as your Execution client.\nBesu does not need pruning.")
return nil
Expand Down Expand Up @@ -1004,6 +1008,13 @@ func pruneExecutionClient(c *cli.Context) error {
return fmt.Errorf("Unexpected output while starting main execution client: %s", result)
}

if selectedEc == config.ExecutionClient_Nethermind {
err = rp.RunNethermindPruneStarter(executionContainerName)
if err != nil {
return err
}
}

fmt.Printf("\nDone! Your main execution client is now pruning. You can follow its progress with `rocketpool service logs eth1`.\n")
fmt.Println("Once it's done, it will restart automatically and resume normal operation.")

Expand Down
25 changes: 12 additions & 13 deletions rocketpool-cli/wallet/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
},

{
Name: "test-mnemonic",
Name: "test-recovery",
Aliases: []string{"t"},
Usage: "Test recovering a node wallet from a mnemonic phrase to ensure the phrase is correct",
UsageText: "rocketpool wallet test-mnemonic [options]",
Usage: "Test recovering a node wallet without actually generating any of the node wallet or validator key files to ensure the process works as expected",
UsageText: "rocketpool wallet test-recovery [options]",
Flags: []cli.Flag{
cli.StringFlag{
Name: "password, p",
Usage: "The password to secure the wallet with (if not already set)",
},
cli.StringFlag{
Name: "mnemonic, m",
Usage: "The mnemonic phrase to recover the wallet from",
},
cli.BoolFlag{
Name: "skip-validator-key-recovery, k",
Usage: "Recover the node wallet, but do not regenerate its validator keys",
},
cli.StringFlag{
Name: "derivation-path, d",
Usage: "Specify the derivation path for the wallet.\nOmit this flag (or leave it blank) for the default of \"m/44'/60'/0'/0/%d\" (where %d is the index).\nSet this to \"ledgerLive\" to use Ledger Live's path of \"m/44'/60'/%d/0/0\".\nSet this to \"mew\" to use MyEtherWallet's path of \"m/44'/60'/0'/%d\".\nFor custom paths, simply enter them here.",
Expand All @@ -169,6 +169,10 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
Usage: "Specify the index to use with the derivation path when recovering your wallet",
Value: 0,
},
cli.StringFlag{
Name: "address, a",
Usage: "If you are recovering a wallet that was not generated by the Smartnode and don't know the derivation path or index of it, enter the address here. The Smartnode will search through its library of paths and indices to try to find it.",
},
},
Action: func(c *cli.Context) error {

Expand All @@ -178,19 +182,14 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
}

// Validate flags
if c.String("password") != "" {
if _, err := cliutils.ValidateNodePassword("password", c.String("password")); err != nil {
return err
}
}
if c.String("mnemonic") != "" {
if _, err := cliutils.ValidateWalletMnemonic("mnemonic", c.String("mnemonic")); err != nil {
return err
}
}

// Run
return testMnemonic(c)
return testRecovery(c)

},
},
Expand Down
11 changes: 11 additions & 0 deletions rocketpool-cli/wallet/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ func initWallet(c *cli.Context) error {
confirmMnemonic(response.Mnemonic)
}

// Do a recover to save the wallet
recoverResponse, err := rp.RecoverWallet(response.Mnemonic, true, derivationPath, 0)
if err != nil {
return fmt.Errorf("error saving wallet: %w", err)
}

// Sanity check the addresses
if recoverResponse.AccountAddress != response.AccountAddress {
return fmt.Errorf("Expected %s, but generated %s upon saving", response.AccountAddress, recoverResponse.AccountAddress)
}

// Clear terminal output
_ = term.Clear()

Expand Down
27 changes: 27 additions & 0 deletions rocketpool-cli/wallet/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallet

import (
"fmt"
"os"

"github.com/urfave/cli"

Expand All @@ -18,6 +19,12 @@ func rebuildWallet(c *cli.Context) error {
}
defer rp.Close()

// Load the config
cfg, _, err := rp.LoadConfig()
if err != nil {
return err
}

// Check and assign the EC status
err = cliutils.CheckExecutionClientStatus(rp)
if err != nil {
Expand All @@ -34,6 +41,26 @@ func rebuildWallet(c *cli.Context) error {
return nil
}

// Check for custom keys
customKeyPasswordFile, err := promptForCustomKeyPasswords(rp, cfg, false)
if err != nil {
return err
}
if customKeyPasswordFile != "" {
// Defer deleting the custom keystore password file
defer func(customKeyPasswordFile string) {
_, err := os.Stat(customKeyPasswordFile)
if os.IsNotExist(err) {
return
}

err = os.Remove(customKeyPasswordFile)
if err != nil {
fmt.Printf("*** WARNING ***\nAn error occurred while removing the custom keystore password file: %s\n\nThis file contains the passwords to your custom validator keys.\nYou *must* delete it manually as soon as possible so nobody can read it.\n\nThe file is located here:\n\n\t%s\n\n", err.Error(), customKeyPasswordFile)
}
}(customKeyPasswordFile)
}

// Log
fmt.Println("Rebuilding node validator keystores...")

Expand Down
32 changes: 32 additions & 0 deletions rocketpool-cli/wallet/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallet

import (
"fmt"
"os"
"strings"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -20,6 +21,12 @@ func recoverWallet(c *cli.Context) error {
}
defer rp.Close()

// Load the config
cfg, _, err := rp.LoadConfig()
if err != nil {
return err
}

// Get & check wallet status
status, err := rp.WalletStatus()
if err != nil {
Expand All @@ -30,6 +37,9 @@ func recoverWallet(c *cli.Context) error {
return nil
}

// Prompt a notice about test recovery
fmt.Printf("%sNOTE:\nThis command will fully regenerate your node wallet's private key and (unless explicitly disabled) the validator keys for your minipools.\nIf you just want to test recovery to ensure it works without actually regenerating the files, please use `rocketpool wallet test-recovery` instead.%s\n\n", colorYellow, colorReset)

// Set password if not set
if !status.PasswordSet {
var password string
Expand All @@ -55,6 +65,28 @@ func recoverWallet(c *cli.Context) error {
// Handle validator key recovery skipping
skipValidatorKeyRecovery := c.Bool("skip-validator-key-recovery")

// Check for custom keys
if !skipValidatorKeyRecovery {
customKeyPasswordFile, err := promptForCustomKeyPasswords(rp, cfg, false)
if err != nil {
return err
}
if customKeyPasswordFile != "" {
// Defer deleting the custom keystore password file
defer func(customKeyPasswordFile string) {
_, err := os.Stat(customKeyPasswordFile)
if os.IsNotExist(err) {
return
}

err = os.Remove(customKeyPasswordFile)
if err != nil {
fmt.Printf("*** WARNING ***\nAn error occurred while removing the custom keystore password file: %s\n\nThis file contains the passwords to your custom validator keys.\nYou *must* delete it manually as soon as possible so nobody can read it.\n\nThe file is located here:\n\n\t%s\n\n", err.Error(), customKeyPasswordFile)
}
}(customKeyPasswordFile)
}
}

// Check for a search-by-address operation
addressString := c.String("address")
if addressString != "" {
Expand Down
Loading

0 comments on commit e44ea47

Please sign in to comment.