Skip to content

Commit c235da8

Browse files
committed
Enable and fix unused issues
1 parent a49f6ff commit c235da8

22 files changed

Lines changed: 2 additions & 390 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# args: --issues-exit-code=0
3636

3737
# For now, Smart Node will only enforce goimports linting
38-
args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple
38+
args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple --enable unused
3939

4040
# Optional: show only new issues if it's a pull request. The default value is `false`.
4141
# only-new-issues: true

rocketpool-cli/client/utils.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"path/filepath"
1010

1111
"github.com/alessio/shellescape"
12-
"github.com/rocket-pool/node-manager-core/api/types"
1312
"github.com/rocket-pool/smartnode/v2/shared/config"
1413
"gopkg.in/yaml.v2"
1514
)
@@ -98,16 +97,3 @@ func SaveConfig(cfg *config.SmartNodeConfig, directory string, filename string)
9897

9998
return nil
10099
}
101-
102-
// Parse and augment the status of a client into a human-readable format
103-
func getClientStatusString(clientStatus types.ClientStatus) string {
104-
if clientStatus.IsSynced {
105-
return "synced and ready"
106-
}
107-
108-
if clientStatus.IsWorking {
109-
return fmt.Sprintf("syncing (%.2f%%)", SyncRatioToPercent(clientStatus.SyncProgress))
110-
}
111-
112-
return fmt.Sprintf("unavailable (%s)", clientStatus.Error)
113-
}

rocketpool-cli/commands/node/utils.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@ import (
1515

1616
"github.com/ethereum/go-ethereum/common"
1717
"github.com/goccy/go-json"
18-
"github.com/mitchellh/go-homedir"
19-
"github.com/rocket-pool/node-manager-core/beacon"
2018
"github.com/urfave/cli/v2"
21-
"gopkg.in/yaml.v2"
2219

2320
"github.com/rocket-pool/node-manager-core/eth"
24-
nmc_utils "github.com/rocket-pool/node-manager-core/utils"
2521
"github.com/rocket-pool/node-manager-core/utils/math"
2622
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/client"
2723
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils"
2824
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils/tx"
29-
"github.com/rocket-pool/smartnode/v2/shared/config"
30-
"github.com/rocket-pool/smartnode/v2/shared/types/api"
3125
)
3226

3327
const (
@@ -324,77 +318,6 @@ func promptMinNodeFee(networkCurrentNodeFee, networkMinNodeFee float64) float64
324318

325319
}
326320

327-
// Prompt for the password to a solo validator key as part of migration
328-
func promptForSoloKeyPassword(cfg *config.SmartNodeConfig, pubkey beacon.ValidatorPubkey) (string, error) {
329-
330-
// Check for the custom key directory
331-
customKeyDir, err := homedir.Expand(cfg.GetCustomKeyPath())
332-
if err != nil {
333-
return "", fmt.Errorf("error expanding custom keys directory: %w", err)
334-
}
335-
info, err := os.Stat(customKeyDir)
336-
if os.IsNotExist(err) || !info.IsDir() {
337-
return "", nil
338-
}
339-
340-
// Get the custom keystore files
341-
files, err := os.ReadDir(customKeyDir)
342-
if err != nil {
343-
return "", fmt.Errorf("error enumerating custom keystores: %w", err)
344-
}
345-
if len(files) == 0 {
346-
return "", nil
347-
}
348-
349-
// Get the pubkeys for the custom keystores
350-
pubkeyPasswords := map[string]string{}
351-
for _, file := range files {
352-
// Read the file
353-
bytes, err := os.ReadFile(filepath.Join(customKeyDir, file.Name()))
354-
if err != nil {
355-
return "", fmt.Errorf("error reading custom keystore %s: %w", file.Name(), err)
356-
}
357-
358-
// Deserialize it
359-
keystore := api.ValidatorKeystore{}
360-
err = json.Unmarshal(bytes, &keystore)
361-
if err != nil {
362-
return "", fmt.Errorf("error deserializing custom keystore %s: %w", file.Name(), err)
363-
}
364-
365-
if keystore.Pubkey == pubkey {
366-
// Found it, prompt for the password
367-
password := utils.PromptPassword(
368-
fmt.Sprintf("Please enter the password that the keystore for %s was encrypted with:", pubkey.Hex()), "^.*$", "",
369-
)
370-
371-
formattedPubkey := strings.ToUpper(nmc_utils.RemovePrefix(pubkey.Hex()))
372-
pubkeyPasswords[formattedPubkey] = password
373-
374-
fmt.Println()
375-
break
376-
}
377-
}
378-
379-
if len(pubkeyPasswords) == 0 {
380-
return "", fmt.Errorf("couldn't find the keystore for validator %s in the custom-keys directory; if you want to import this key into the Smartnode stack, you will need to put its keystore file into custom-keys first", pubkey.HexWithPrefix())
381-
}
382-
383-
// Store it in the file
384-
fileBytes, err := yaml.Marshal(pubkeyPasswords)
385-
if err != nil {
386-
return "", fmt.Errorf("error serializing keystore passwords file: %w", err)
387-
}
388-
passwordFile := cfg.GetCustomKeyPasswordFilePath()
389-
err = os.WriteFile(passwordFile, fileBytes, 0600)
390-
if err != nil {
391-
return "", fmt.Errorf("error writing keystore passwords file: %w", err)
392-
}
393-
394-
return passwordFile, nil
395-
396-
}
397-
398321
func SwapRpl(c *cli.Context, rp *client.Client, amountWei *big.Int) error {
399322
// Get the TX
400323
response, err := rp.Api.Node.SwapRpl(amountWei)

rocketpool-cli/commands/service/config/cfg-form.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ type parameterizedFormItem struct {
1616
item tview.FormItem
1717
}
1818

19-
func registerEnableCheckbox(param *config.Parameter[bool], checkbox *tview.Checkbox, form *Form, items []*parameterizedFormItem) {
20-
checkbox.SetChangedFunc(func(checked bool) {
21-
param.Value = checked
22-
if !checked {
23-
form.Clear(true)
24-
form.AddFormItem(checkbox)
25-
} else {
26-
for _, item := range items {
27-
form.AddFormItem(item.item)
28-
}
29-
}
30-
})
31-
}
32-
3319
// Create a list of form items based on a set of parameters
3420
func createParameterizedFormItems(params []config.IParameter, descriptionBox *tview.TextView) []*parameterizedFormItem {
3521
formItems := []*parameterizedFormItem{}

rocketpool-cli/commands/service/config/pseudomodal.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ type Pseudomodal struct {
3636

3737
// The currently selected form (for vertical layouts)
3838
selected int
39-
40-
// A fixed width for the description box (0 for auto)
41-
descriptionWidth int
42-
43-
// The collection of descriptions for each button, to be displayed in the description box
44-
buttonDescriptions []string
4539
}
4640

4741
// NewPseudomodal returns a new modal message window.

rocketpool-cli/commands/service/config/review-native-page.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ import (
1313
// Constants
1414
const reviewNativePageID string = "review-native-settings"
1515

16-
// The changed settings review page
17-
type ReviewNativePage struct {
18-
md *mainDisplay
19-
changedSettings []*config.ChangedSection
20-
page *page
21-
}
22-
2316
// Create a page to review any changes
2417
func NewReviewNativePage(md *mainDisplay, oldConfig *snCfg.SmartNodeConfig, newConfig *snCfg.SmartNodeConfig) *ReviewPage {
2518
var changedSettings []*config.ChangedSection

rocketpool-cli/commands/service/config/step-random-bn.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,6 @@ import (
99
const randomBnPrysmID string = "step-random-bn-prysm"
1010
const randomBnID string = "step-random-bn"
1111

12-
func createRandomPrysmStep(wiz *wizard, currentStep int, totalSteps int, goodOptions []*config.ParameterOption[config.BeaconNode]) *choiceWizardStep {
13-
helperText := "You have been randomly assigned to Prysm for your Beacon Node.\n\n[orange]NOTE: Prysm currently has a very high representation of the Beacon Chain. For the health of the network and the overall safety of your funds, please consider choosing a client with a lower representation. Please visit https://clientdiversity.org to learn more."
14-
15-
show := func(modal *choiceModalLayout) {
16-
wiz.md.setPage(modal.page)
17-
modal.focus(0)
18-
}
19-
20-
done := func(buttonIndex int, buttonLabel string) {
21-
if buttonIndex == 0 {
22-
selectRandomBn(goodOptions, false, wiz, currentStep, totalSteps)
23-
} else {
24-
wiz.checkpointSyncProviderModal.show()
25-
}
26-
}
27-
28-
back := func() {
29-
wiz.localBnModal.show()
30-
}
31-
32-
return newChoiceStep(
33-
wiz,
34-
currentStep,
35-
totalSteps,
36-
helperText,
37-
[]string{"Choose Another Random Client", "Keep Prysm"},
38-
[]string{},
39-
76,
40-
"Beacon Node > Selection",
41-
DirectionalModalHorizontal,
42-
show,
43-
done,
44-
back,
45-
randomBnPrysmID,
46-
)
47-
}
48-
4912
func createRandomBnStep(wiz *wizard, currentStep int, totalSteps int, goodOptions []*config.ParameterOption[config.BeaconNode]) *choiceWizardStep {
5013
var selectedClientName string
5114
selectedClient := wiz.md.Config.LocalBeaconClient.BeaconNode.Value

rocketpool-cli/commands/service/config/types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ type settingsPage interface {
44
handleLayoutChanged()
55
getPage() *page
66
}
7-
8-
type wizardStep interface {
9-
show()
10-
}

rocketpool-cli/commands/service/config/wizard.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type wizard struct {
2525
// Step 5 - BN settings
2626
localBnModal *choiceWizardStep
2727
localBnRandomModal *choiceWizardStep
28-
localBnRandomPrysmModal *choiceWizardStep
2928
localBnPrysmWarning *choiceWizardStep
3029
localBnTekuWarning *choiceWizardStep
3130
checkpointSyncProviderModal *textBoxWizardStep

rocketpool-cli/commands/service/sync.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"math"
66
"strings"
7-
"time"
87

98
"github.com/urfave/cli/v2"
109

@@ -22,11 +21,6 @@ func SyncRatioToPercent(in float64) float64 {
2221
// TODO: INCORPORATE THIS
2322
}
2423

25-
// Settings
26-
const (
27-
ethClientRecentBlockThreshold time.Duration = 5 * time.Minute
28-
)
29-
3024
func printClientStatus(status *types.ClientStatus, name string) {
3125

3226
if status.Error != "" {

0 commit comments

Comments
 (0)