From 109aebb3f847982519bd179c657461308c93f854 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 14 Apr 2024 15:30:28 -0400 Subject: [PATCH 01/28] Add unit test workflow --- .github/workflows/unit-tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..aa511482a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,20 @@ +name: Smart Node Unit Tests +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - run: go test ./... From 70d8c55020eb67fbb03fc426682a5b066deed7ea Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 14 Apr 2024 16:02:52 -0400 Subject: [PATCH 02/28] Fix printfs and printlns --- rocketpool-cli/minipool/reduce-bond.go | 9 ++++++--- rocketpool-cli/minipool/rescue-dissolved.go | 8 +++++--- rocketpool-cli/node/create-vacant-minipool.go | 10 +++++++--- rocketpool-cli/node/deposit.go | 3 ++- rocketpool-cli/node/smoothing-pool.go | 14 ++++++++++++-- rocketpool-cli/node/status.go | 3 ++- rocketpool-cli/node/sync.go | 3 ++- rocketpool-cli/node/utils.go | 7 +++++-- rocketpool-cli/service/service.go | 12 ++++++++---- rocketpool-cli/wallet/export.go | 2 +- rocketpool-cli/wallet/utils.go | 4 +++- rocketpool/api/debug/validators.go | 6 ++++-- rocketpool/api/node/deposit.go | 2 +- rocketpool/node/collectors/node-collector.go | 2 +- rocketpool/watchtower/generate-rewards-tree.go | 6 +++--- shared/services/beacon/client/std-http-client.go | 4 ++-- shared/services/gas/gas.go | 4 ++-- shared/services/requirements.go | 2 +- shared/services/rocketpool/odao.go | 3 ++- shared/utils/cli/migration/import-key.go | 3 ++- shared/utils/cli/utils.go | 2 +- shared/utils/eth1/eth1.go | 4 ++-- 22 files changed, 74 insertions(+), 39 deletions(-) diff --git a/rocketpool-cli/minipool/reduce-bond.go b/rocketpool-cli/minipool/reduce-bond.go index 86f99a986..09b7f8e93 100644 --- a/rocketpool-cli/minipool/reduce-bond.go +++ b/rocketpool-cli/minipool/reduce-bond.go @@ -234,7 +234,8 @@ func reduceBondAmount(c *cli.Context) error { return err } - fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.\n") + fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.") + fmt.Println() // Get reduceable minipools reduceableMinipools := []api.MinipoolDetails{} @@ -360,10 +361,12 @@ func forceFeeDistribution(c *cli.Context, rp *rocketpool.Client) error { balance := eth.WeiToEth(canDistributeResponse.Balance) if balance == 0 { - fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.\n") + fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.") + fmt.Println() return nil } - fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.\n") + fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.") + fmt.Println() // Print info rEthShare := balance - canDistributeResponse.NodeShare diff --git a/rocketpool-cli/minipool/rescue-dissolved.go b/rocketpool-cli/minipool/rescue-dissolved.go index 63afa82e4..32989a3e3 100644 --- a/rocketpool-cli/minipool/rescue-dissolved.go +++ b/rocketpool-cli/minipool/rescue-dissolved.go @@ -34,7 +34,9 @@ func rescueDissolved(c *cli.Context) error { return err } - fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.\nPlease read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.\n") + fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.") + fmt.Println("Please read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.") + fmt.Println() // Validate the amount var depositAmount *big.Int @@ -90,14 +92,14 @@ func rescueDissolved(c *cli.Context) error { fmt.Printf("\nPlease upgrade the delegate for these minipools using `rocketpool minipool delegate-upgrade` before rescuing them.%s\n\n", colorReset) } if len(balanceCompletedMinipools) > 0 { - fmt.Printf("%NOTE: The following minipools already have 32 ETH or more deposited:\n", colorYellow) + fmt.Printf("%sNOTE: The following minipools already have 32 ETH or more deposited:\n", colorYellow) for _, mp := range balanceCompletedMinipools { fmt.Printf("\t%s\n", mp.Address) } fmt.Printf("\nThese minipools don't need to be rescued.%s\n\n", colorReset) } if len(invalidBeaconStateMinipools) > 0 { - fmt.Printf("%NOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", colorYellow) + fmt.Printf("%sNOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", colorYellow) for _, mp := range invalidBeaconStateMinipools { fmt.Printf("\t%s (%s)\n", mp.Address, mp.BeaconState) } diff --git a/rocketpool-cli/node/create-vacant-minipool.go b/rocketpool-cli/node/create-vacant-minipool.go index ff5585748..7523559ff 100644 --- a/rocketpool-cli/node/create-vacant-minipool.go +++ b/rocketpool-cli/node/create-vacant-minipool.go @@ -41,7 +41,8 @@ func createVacantMinipool(c *cli.Context, pubkey types.ValidatorPubkey) error { return nil } - fmt.Println("Your eth2 client is on the correct network.\n") + fmt.Println("Your eth2 client is on the correct network.") + fmt.Println() // Check if the fee distributor has been initialized isInitializedResponse, err := rp.IsFeeDistributorInitialized() @@ -240,7 +241,8 @@ func createVacantMinipool(c *cli.Context, pubkey types.ValidatorPubkey) error { if c.IsSet("mnemonic") { mnemonic = c.String("mnemonic") } else if !c.Bool("yes") { - fmt.Println("You have the option of importing your validator's private key into the Smartnode's Validator Client instead of running your own Validator Client separately. In doing so, the Smartnode will also automatically migrate your validator's withdrawal credentials from your BLS private key to the minipool you just created.\n") + fmt.Println("You have the option of importing your validator's private key into the Smartnode's Validator Client instead of running your own Validator Client separately. In doing so, the Smartnode will also automatically migrate your validator's withdrawal credentials from your BLS private key to the minipool you just created.") + fmt.Println() if cliutils.Confirm("Would you like to import your key and automatically migrate your withdrawal credentials?") { mnemonic = wallet.PromptMnemonic() } @@ -250,7 +252,9 @@ func createVacantMinipool(c *cli.Context, pubkey types.ValidatorPubkey) error { handleImport(c, rp, response.MinipoolAddress, mnemonic) } else { // Ignore importing / it errored out - fmt.Println("Since you're not importing your validator key, you will still be responsible for running and maintaining your own Validator Client with the validator's private key loaded, just as you are today.\n\n") + fmt.Println("Since you're not importing your validator key, you will still be responsible for running and maintaining your own Validator Client with the validator's private key loaded, just as you are today.") + fmt.Println() + fmt.Println() fmt.Printf("You must now upgrade your validator's withdrawal credentials manually, using as tool such as `ethdo` (https://github.com/wealdtech/ethdo), to the following minipool address:\n\n\t%s\n\n", response.MinipoolAddress) } diff --git a/rocketpool-cli/node/deposit.go b/rocketpool-cli/node/deposit.go index 51abc724d..080016055 100644 --- a/rocketpool-cli/node/deposit.go +++ b/rocketpool-cli/node/deposit.go @@ -42,7 +42,8 @@ func nodeDeposit(c *cli.Context) error { return nil } - fmt.Println("Your eth2 client is on the correct network.\n") + fmt.Println("Your eth2 client is on the correct network.") + fmt.Println() // Check if the fee distributor has been initialized isInitializedResponse, err := rp.IsFeeDistributorInitialized() diff --git a/rocketpool-cli/node/smoothing-pool.go b/rocketpool-cli/node/smoothing-pool.go index 183eed195..f4b083dbb 100644 --- a/rocketpool-cli/node/smoothing-pool.go +++ b/rocketpool-cli/node/smoothing-pool.go @@ -36,7 +36,12 @@ func joinSmoothingPool(c *cli.Context) error { } // Print some info - fmt.Println("You are about to opt into the Smoothing Pool.\nYour fee recipient will be changed to the Smoothing Pool contract.\nAll priority fees and MEV you earn via proposals will be shared equally with other members of the Smoothing Pool.\n\nIf you desire, you can opt back out after one full rewards interval has passed.\n") + fmt.Println("You are about to opt into the Smoothing Pool.") + fmt.Println("Your fee recipient will be changed to the Smoothing Pool contract.") + fmt.Println("All priority fees and MEV you earn via proposals will be shared equally with other members of the Smoothing Pool.") + fmt.Println() + fmt.Println("If you desire, you can opt back out after one full rewards interval has passed.") + fmt.Println() // Get the gas estimate canResponse, err := rp.CanNodeSetSmoothingPoolStatus(true) @@ -102,7 +107,12 @@ func leaveSmoothingPool(c *cli.Context) error { } // Print some info - fmt.Println("You are about to opt out of the Smoothing Pool.\nYour fee recipient will be changed back to your node's distributor contract once the next Epoch has been finalized.\nAll priority fees and MEV you earn via proposals will go directly to your distributor and will not be shared by the Smoothing Pool members.\n\nIf you desire, you can opt back in after one full rewards interval has passed.\n") + fmt.Println("You are about to opt out of the Smoothing Pool.") + fmt.Println("Your fee recipient will be changed back to your node's distributor contract once the next Epoch has been finalized.") + fmt.Println("All priority fees and MEV you earn via proposals will go directly to your distributor and will not be shared by the Smoothing Pool members.") + fmt.Println() + fmt.Println("If you desire, you can opt back in after one full rewards interval has passed.") + fmt.Println() // Get the gas estimate canResponse, err := rp.CanNodeSetSmoothingPoolStatus(false) diff --git a/rocketpool-cli/node/status.go b/rocketpool-cli/node/status.go index c01fce98e..1ef148307 100644 --- a/rocketpool-cli/node/status.go +++ b/rocketpool-cli/node/status.go @@ -231,7 +231,8 @@ func getStatus(c *cli.Context) error { // RPL stake details fmt.Printf("%s=== RPL Stake ===%s\n", colorGreen, colorReset) - fmt.Println("NOTE: The following figures take *any pending bond reductions* into account.\n") + fmt.Println("NOTE: The following figures take *any pending bond reductions* into account.") + fmt.Println() fmt.Printf( "The node has a total stake of %.6f RPL and an effective stake of %.6f RPL.\n", math.RoundDown(eth.WeiToEth(status.RplStake), 6), diff --git a/rocketpool-cli/node/sync.go b/rocketpool-cli/node/sync.go index 8d92f2190..e4aff91a2 100644 --- a/rocketpool-cli/node/sync.go +++ b/rocketpool-cli/node/sync.go @@ -84,7 +84,8 @@ func getSyncProgress(c *cli.Context) error { depositContractInfo.BeaconDepositContract) return nil } else { - fmt.Println("Your consensus client is on the correct network.\n") + fmt.Println("Your consensus client is on the correct network.") + fmt.Println() } // Get node status diff --git a/rocketpool-cli/node/utils.go b/rocketpool-cli/node/utils.go index 584c8aa09..52953dfc9 100644 --- a/rocketpool-cli/node/utils.go +++ b/rocketpool-cli/node/utils.go @@ -158,7 +158,10 @@ func promptTimezone() string { } } - fmt.Println("You will now be prompted to enter a timezone.\nFor a complete list of valid entries, please use one of the \"TZ database name\" entries listed here:\nhttps://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n") + fmt.Println("You will now be prompted to enter a timezone.") + fmt.Println("For a complete list of valid entries, please use one of the \"TZ database name\" entries listed here:") + fmt.Println("https://en.wikipedia.org/wiki/List_of_tz_database_time_zones") + fmt.Println() // Handle situations where we couldn't parse any timezone info from the OS if len(countryNames) == 0 { @@ -369,7 +372,7 @@ func promptForSoloKeyPassword(rp *rocketpool.Client, cfg *config.RocketPoolConfi } if len(pubkeyPasswords) == 0 { - 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") + 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.String()) } // Store it in the file diff --git a/rocketpool-cli/service/service.go b/rocketpool-cli/service/service.go index 0f6041b38..272c8a2d5 100644 --- a/rocketpool-cli/service/service.go +++ b/rocketpool-cli/service/service.go @@ -548,8 +548,10 @@ func startService(c *cli.Context, ignoreConfigSuggestion bool) error { fmt.Printf("%sWARNING: couldn't verify that the validator container can be safely restarted:\n\t%s\n", colorYellow, err.Error()) fmt.Println("If you are changing to a different ETH2 client, it may resubmit an attestation you have already submitted.") fmt.Println("This will slash your validator!") - fmt.Println("To prevent slashing, you must wait 15 minutes from the time you stopped the clients before starting them again.\n") - fmt.Println("**If you did NOT change clients, you can safely ignore this warning.**\n") + fmt.Println("To prevent slashing, you must wait 15 minutes from the time you stopped the clients before starting them again.") + fmt.Println() + fmt.Println("**If you did NOT change clients, you can safely ignore this warning.**") + fmt.Println() if !cliutils.Confirm(fmt.Sprintf("Press y when you understand the above warning, have waited, and are ready to start Rocket Pool:%s", colorReset)) { fmt.Println("Cancelled.") return nil @@ -1675,7 +1677,8 @@ func exportEcData(c *cli.Context, targetDir string) error { fmt.Println("This will export your execution client's chain data to an external directory, such as a portable hard drive.") fmt.Println("If your execution client is running, it will be shut down.") - fmt.Println("Once the export is complete, your execution client will restart automatically.\n") + fmt.Println("Once the export is complete, your execution client will restart automatically.") + fmt.Println() // Get the container prefix prefix, err := rp.GetContainerPrefix() @@ -1798,7 +1801,8 @@ func importEcData(c *cli.Context, sourceDir string) error { fmt.Println("This will import execution layer chain data that you previously exported into your execution client.") fmt.Println("If your execution client is running, it will be shut down.") - fmt.Println("Once the import is complete, your execution client will restart automatically.\n") + fmt.Println("Once the import is complete, your execution client will restart automatically.") + fmt.Println() // Get the volume to import into executionContainerName := prefix + ExecutionContainerSuffix diff --git a/rocketpool-cli/wallet/export.go b/rocketpool-cli/wallet/export.go index 5be237d6b..24f49c692 100644 --- a/rocketpool-cli/wallet/export.go +++ b/rocketpool-cli/wallet/export.go @@ -30,7 +30,7 @@ func exportWallet(c *cli.Context) error { // Check if stdout is interactive stat, err := os.Stdout.Stat() if err != nil { - fmt.Fprintf(os.Stderr, "An error occured while determining whether or not the output is a tty: %w\n"+ + fmt.Fprintf(os.Stderr, "An error occured while determining whether or not the output is a tty: %v\n"+ "Use \"rocketpool --secure-session wallet export\" to bypass.\n", err) os.Exit(1) } diff --git a/rocketpool-cli/wallet/utils.go b/rocketpool-cli/wallet/utils.go index d80628986..63c8e90da 100644 --- a/rocketpool-cli/wallet/utils.go +++ b/rocketpool-cli/wallet/utils.go @@ -152,7 +152,9 @@ func promptForCustomKeyPasswords(rp *rocketpool.Client, cfg *config.RocketPoolCo } // Notify the user - fmt.Println("It looks like you have some custom keystores for your minipool's validators.\nYou will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.\n") + fmt.Println("It looks like you have some custom keystores for your minipool's validators.") + fmt.Println("You will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.") + fmt.Println() // Get the passwords for each one pubkeyPasswords := map[string]string{} diff --git a/rocketpool/api/debug/validators.go b/rocketpool/api/debug/validators.go index f011c26e7..945b195c2 100644 --- a/rocketpool/api/debug/validators.go +++ b/rocketpool/api/debug/validators.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "strings" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -94,7 +95,7 @@ func ExportValidators(c *cli.Context) error { return err } - fmt.Printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + columns := []string{ "Minipool Address", "Validator Pub Key", "Activation Epoch", @@ -106,7 +107,8 @@ func ExportValidators(c *cli.Context) error { "Finalised", "Active", "Pending", - ) + } + fmt.Println(strings.Join(columns, "\t")) // Load details in batches for bsi := 0; bsi < len(addresses); bsi += MinipoolBalanceDetailsBatchSize { diff --git a/rocketpool/api/node/deposit.go b/rocketpool/api/node/deposit.go index 9d33ab42f..b3cb85f99 100644 --- a/rocketpool/api/node/deposit.go +++ b/rocketpool/api/node/deposit.go @@ -382,7 +382,7 @@ func nodeDeposit(c *cli.Context, amountWei *big.Int, minNodeFee float64, salt *b if status.Exists { return nil, fmt.Errorf("**** ALERT ****\n"+ "Your minipool %s has the following as a validator pubkey:\n\t%s\n"+ - "This key is already in use by validator %d on the Beacon chain!\n"+ + "This key is already in use by validator %s on the Beacon chain!\n"+ "Rocket Pool will not allow you to deposit this validator for your own safety so you do not get slashed.\n"+ "PLEASE REPORT THIS TO THE ROCKET POOL DEVELOPERS.\n"+ "***************\n", minipoolAddress.Hex(), pubKey.Hex(), status.Index) diff --git a/rocketpool/node/collectors/node-collector.go b/rocketpool/node/collectors/node-collector.go index c3f2ddde3..32ca59482 100644 --- a/rocketpool/node/collectors/node-collector.go +++ b/rocketpool/node/collectors/node-collector.go @@ -379,7 +379,7 @@ func (collector *NodeCollector) Collect(channel chan<- prometheus.Metric) { if err != nil { // NOTE: returning here causes the metric to not be emitted. the endpoint stays responsive, but also slightly more accurate (progress=nothing instead of 0) - fmt.Printf("error getting beacon chain sync status: %w", err) + fmt.Printf("error getting beacon chain sync status: %s", err.Error()) return nil } else { progress = syncStatus.Progress diff --git a/rocketpool/watchtower/generate-rewards-tree.go b/rocketpool/watchtower/generate-rewards-tree.go index af5ea6a09..fd6e2b62c 100644 --- a/rocketpool/watchtower/generate-rewards-tree.go +++ b/rocketpool/watchtower/generate-rewards-tree.go @@ -189,20 +189,20 @@ func (t *generateRewardsTree) generateRewardsTree(index uint64) { } client, err = rocketpool.NewRocketPool(ec, common.HexToAddress(t.cfg.Smartnode.GetStorageAddress())) if err != nil { - t.handleError(fmt.Errorf("%s Error creating Rocket Pool client connected to archive EC: %w", err)) + t.handleError(fmt.Errorf("Error creating Rocket Pool client connected to archive EC: %w", err)) return } // Get the rETH address from the archive EC address, err = client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) if err != nil { - t.handleError(fmt.Errorf("%s Error verifying rETH address with Archive EC: %w", err)) + t.handleError(fmt.Errorf("Error verifying rETH address with Archive EC: %w", err)) return } // Create the state manager with the archive EC stateManager, err = state.NewNetworkStateManager(client, t.cfg, ec, t.bc, &t.log) if err != nil { - t.handleError(fmt.Errorf("%s Error creating new NetworkStateManager with ARchive EC: %w", err)) + t.handleError(fmt.Errorf("Error creating new NetworkStateManager with ARchive EC: %w", err)) return } } else { diff --git a/shared/services/beacon/client/std-http-client.go b/shared/services/beacon/client/std-http-client.go index dabba3c28..a4517ea16 100644 --- a/shared/services/beacon/client/std-http-client.go +++ b/shared/services/beacon/client/std-http-client.go @@ -903,10 +903,10 @@ func (c *StandardHttpClient) postWithdrawalCredentialsChange(request BLSToExecut requestArray := []BLSToExecutionChangeRequest{request} // This route must be wrapped in an array responseBody, status, err := c.postRequest(RequestWithdrawalCredentialsChangePath, requestArray) if err != nil { - return fmt.Errorf("Could not broadcast withdrawal credentials change for validator %d: %w", request.Message.ValidatorIndex, err) + return fmt.Errorf("Could not broadcast withdrawal credentials change for validator %s: %w", request.Message.ValidatorIndex, err) } if status != http.StatusOK { - return fmt.Errorf("Could not broadcast withdrawal credentials change for validator %d: HTTP status %d; response body: '%s'", request.Message.ValidatorIndex, status, string(responseBody)) + return fmt.Errorf("Could not broadcast withdrawal credentials change for validator %s: HTTP status %d; response body: '%s'", request.Message.ValidatorIndex, status, string(responseBody)) } return nil } diff --git a/shared/services/gas/gas.go b/shared/services/gas/gas.go index f6b1fb8a2..3015eb74f 100644 --- a/shared/services/gas/gas.go +++ b/shared/services/gas/gas.go @@ -219,7 +219,7 @@ func handleEtherchainGasPrices(gasSuggestion etherchain.GasFeeSuggestion, gasInf desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64) if err != nil { - fmt.Println("Not a valid gas price (%s), try again.", err.Error()) + fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error()) continue } if desiredPriceFloat <= 0 { @@ -297,7 +297,7 @@ func handleEtherscanGasPrices(gasSuggestion etherscan.GasFeeSuggestion, gasInfo desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64) if err != nil { - fmt.Println("Not a valid gas price (%s), try again.", err.Error()) + fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error()) continue } if desiredPriceFloat <= 0 { diff --git a/shared/services/requirements.go b/shared/services/requirements.go index 70e390f6b..b59ab919f 100644 --- a/shared/services/requirements.go +++ b/shared/services/requirements.go @@ -531,7 +531,7 @@ func waitBeaconClientSynced(c *cli.Context, verbose bool, timeout int64) (bool, // Check sync status if syncStatus.Syncing { if verbose { - log.Println("Eth 2.0 node syncing: %.2f%%\n", syncStatus.Progress*100) + log.Printf("Eth 2.0 node syncing: %.2f%%\n", syncStatus.Progress*100) } } else { alerting.AlertBeaconClientSyncComplete(cfg) diff --git a/shared/services/rocketpool/odao.go b/shared/services/rocketpool/odao.go index 562a69fc3..faadb3c51 100644 --- a/shared/services/rocketpool/odao.go +++ b/shared/services/rocketpool/odao.go @@ -3,6 +3,7 @@ package rocketpool import ( "fmt" "math/big" + "strconv" "github.com/ethereum/go-ethereum/common" "github.com/goccy/go-json" @@ -66,7 +67,7 @@ func (c *Client) TNDAOProposals() (api.TNDAOProposalsResponse, error) { // Get a single oracle DAO proposal func (c *Client) TNDAOProposal(id uint64) (api.TNDAOProposalResponse, error) { - responseBytes, err := c.callAPI("odao proposal-details", string(id)) + responseBytes, err := c.callAPI("odao proposal-details", strconv.FormatUint(id, 10)) if err != nil { return api.TNDAOProposalResponse{}, fmt.Errorf("Could not get oracle DAO proposal: %w", err) } diff --git a/shared/utils/cli/migration/import-key.go b/shared/utils/cli/migration/import-key.go index aa5e4211f..fc5d472cc 100644 --- a/shared/utils/cli/migration/import-key.go +++ b/shared/utils/cli/migration/import-key.go @@ -52,7 +52,8 @@ func ImportKey(c *cli.Context, rp *rocketpool.Client, minipoolAddress common.Add fmt.Printf("failed!\n%sWARNING: error restarting validator client: %s\n\nPlease restart it manually so it picks up the new validator key for your minipool.%s", colorYellow, err.Error(), colorReset) return false } - fmt.Println("done!\n") + fmt.Println("done!") + fmt.Println() } return true diff --git a/shared/utils/cli/utils.go b/shared/utils/cli/utils.go index 8194318aa..d3c58a6e2 100644 --- a/shared/utils/cli/utils.go +++ b/shared/utils/cli/utils.go @@ -138,7 +138,7 @@ func PrintNetwork(currentNetwork cfgtypes.Network, isNew bool) error { case cfgtypes.Network_Mainnet: fmt.Printf("Your Smartnode is currently using the %sEthereum Mainnet.%s\n\n", colorGreen, colorReset) case cfgtypes.Network_Devnet: - fmt.Printf("Your Smartnode is currently using the %Holesky Development Network.%s\n\n", colorYellow, colorReset) + fmt.Printf("Your Smartnode is currently using the %sHolesky Development Network.%s\n\n", colorYellow, colorReset) case cfgtypes.Network_Holesky: fmt.Printf("Your Smartnode is currently using the %sHolesky Test Network.%s\n\n", colorYellow, colorReset) default: diff --git a/shared/utils/eth1/eth1.go b/shared/utils/eth1/eth1.go index 0718ee8ad..4e7799e29 100644 --- a/shared/utils/eth1/eth1.go +++ b/shared/utils/eth1/eth1.go @@ -89,13 +89,13 @@ func GetBestApiClient(primary *rocketpool.RocketPool, cfg *config.RocketPoolConf } client, err = rocketpool.NewRocketPool(ec, common.HexToAddress(cfg.Smartnode.GetStorageAddress())) if err != nil { - return nil, fmt.Errorf("%s Error creating Rocket Pool client connected to archive EC: %w", err) + return nil, fmt.Errorf("Error creating Rocket Pool client connected to archive EC: %w", err) } // Get the rETH address from the archive EC address, err = client.RocketStorage.GetAddress(opts, crypto.Keccak256Hash([]byte("contract.addressrocketTokenRETH"))) if err != nil { - return nil, fmt.Errorf("%s Error verifying rETH address with Archive EC: %w", err) + return nil, fmt.Errorf("Error verifying rETH address with Archive EC: %w", err) } } else { // No archive node specified From cf64b0451e887b70ae5b4a64dbdb89d89fcbf654 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 14 Apr 2024 16:05:07 -0400 Subject: [PATCH 03/28] Add build workflow --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..8b3fb0252 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Smart Node Build +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - run: cd ${GITHUB_WORKSPACE}/rocketpool-cli && go build . + - run: cd ${GITHUB_WORKSPACE}/rocketpool && go build . From df84f4d357dd8aa192156cdef9ff8d4ce6d5f230 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+fornax2@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:40:22 -0300 Subject: [PATCH 04/28] Fix claimable challenge states. --- rocketpool/api/pdao/claimable-bonds.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/rocketpool/api/pdao/claimable-bonds.go b/rocketpool/api/pdao/claimable-bonds.go index 12f50fe9f..17e826a03 100644 --- a/rocketpool/api/pdao/claimable-bonds.go +++ b/rocketpool/api/pdao/claimable-bonds.go @@ -203,16 +203,13 @@ func getClaimableBonds(c *cli.Context) (*api.PDAOGetClaimableBondsResponse, erro } // Make sure the prop and challenge are in the right states - if challengeInfo.State != types.ChallengeState_Challenged { - if propInfo.State == types.ProtocolDaoProposalState_Destroyed { - if challengeInfo.State != types.ChallengeState_Responded { - // If the proposal is destroyed, a challenge must be in the challenged or responded states - continue - } - } else { - // Only refund non-responded challenges if the proposal was destroyed - continue - } + if challengeInfo.State == types.ChallengeState_Paid { + // Ignore already paid challenges + continue; + } + if challengeInfo.State == types.ChallengeState_Responded && propInfo.State != types.ProtocolDaoProposalState_Destroyed { + // Only refund responded challenges if the proposal was destroyed + continue; } // Increment how many refundable challenges we made From 4414671e051b40bc047ede0fa4174251b907a987 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+fornax2@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:52:48 -0300 Subject: [PATCH 05/28] Don't list prelaunch minipools as closable --- rocketpool-cli/minipool/close.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rocketpool-cli/minipool/close.go b/rocketpool-cli/minipool/close.go index 727baba51..aee4b678f 100644 --- a/rocketpool-cli/minipool/close.go +++ b/rocketpool-cli/minipool/close.go @@ -54,6 +54,10 @@ func closeMinipools(c *cli.Context) error { // Ignore minipools that are already closed continue } + if mp.MinipoolStatus == types.Prelaunch { + // Ignore minipools that are currently in prelaunch + continue + } if mp.CanClose { closableMinipools = append(closableMinipools, mp) } else { From e7a45f1bd97f7f7bf6690cc2033ff6cc59c34dc2 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+fornax2@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:39:00 -0300 Subject: [PATCH 06/28] Add condition for the Challenged state --- rocketpool/api/pdao/claimable-bonds.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rocketpool/api/pdao/claimable-bonds.go b/rocketpool/api/pdao/claimable-bonds.go index 17e826a03..6da396305 100644 --- a/rocketpool/api/pdao/claimable-bonds.go +++ b/rocketpool/api/pdao/claimable-bonds.go @@ -205,11 +205,15 @@ func getClaimableBonds(c *cli.Context) (*api.PDAOGetClaimableBondsResponse, erro // Make sure the prop and challenge are in the right states if challengeInfo.State == types.ChallengeState_Paid { // Ignore already paid challenges - continue; + continue } if challengeInfo.State == types.ChallengeState_Responded && propInfo.State != types.ProtocolDaoProposalState_Destroyed { - // Only refund responded challenges if the proposal was destroyed - continue; + // Only refund responded challenges if the proposal was destroyed + continue + } + if challengeInfo.State == types.ChallengeState_Challenged && propInfo.State < types.ProtocolDaoProposalState_QuorumNotMet { + // Unresponded challenges may be claimed after the proposal is finished + continue } // Increment how many refundable challenges we made From 9993da92f31bcd019a63ca8839fd542511b9a310 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+fornax2@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:23:26 -0300 Subject: [PATCH 07/28] go mod tidy --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index 5a631794a..711ef770d 100644 --- a/go.sum +++ b/go.sum @@ -633,10 +633,6 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240325082735-98a1980d22f9 h1:tDVTNAQ4Q/kyPuziYaMb78O8VTLX1YI/5cV3a0v/VTE= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240325082735-98a1980d22f9/go.mod h1:f2TVsMOYmCwaJOhshG2zRoX89PZmvCkCD7UYJ9waRkI= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240409175422-8f300a60ec11 h1:TXPTWLrZwW6Fudq30h0txRlNA80urlFKlm/8dBvj5lU= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240409175422-8f300a60ec11/go.mod h1:f2TVsMOYmCwaJOhshG2zRoX89PZmvCkCD7UYJ9waRkI= github.com/rocket-pool/rocketpool-go v1.8.3-0.20240416035508-da70ba64fc1c h1:A+stnC3/2525T9PXwR9Bq0IOOm5mArQtpCwn8c3H9nM= github.com/rocket-pool/rocketpool-go v1.8.3-0.20240416035508-da70ba64fc1c/go.mod h1:f2TVsMOYmCwaJOhshG2zRoX89PZmvCkCD7UYJ9waRkI= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= From 8052c8dcfaf016bd917cdb8953654e6773b66a95 Mon Sep 17 00:00:00 2001 From: Fornax <23104993+fornax2@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:35:43 -0300 Subject: [PATCH 08/28] Update initializeVoting after contract changes --- go.mod | 2 +- go.sum | 4 ++-- rocketpool/api/pdao/initialize-voting.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index dc60a24fd..54005f1c5 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 github.com/prysmaticlabs/prysm/v5 v5.0.3 github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 - github.com/rocket-pool/rocketpool-go v1.8.3-0.20240416035508-da70ba64fc1c + github.com/rocket-pool/rocketpool-go v1.8.3-0.20240417033345-0062b73a02e4 github.com/sethvargo/go-password v0.2.0 github.com/shirou/gopsutil/v3 v3.23.1 github.com/tyler-smith/go-bip39 v1.1.0 diff --git a/go.sum b/go.sum index 711ef770d..06c755fea 100644 --- a/go.sum +++ b/go.sum @@ -633,8 +633,8 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240416035508-da70ba64fc1c h1:A+stnC3/2525T9PXwR9Bq0IOOm5mArQtpCwn8c3H9nM= -github.com/rocket-pool/rocketpool-go v1.8.3-0.20240416035508-da70ba64fc1c/go.mod h1:f2TVsMOYmCwaJOhshG2zRoX89PZmvCkCD7UYJ9waRkI= +github.com/rocket-pool/rocketpool-go v1.8.3-0.20240417033345-0062b73a02e4 h1:paBlzYJVOhx3ilxtK7WvHwU65/m2lw8uTMF/nmvMIGk= +github.com/rocket-pool/rocketpool-go v1.8.3-0.20240417033345-0062b73a02e4/go.mod h1:f2TVsMOYmCwaJOhshG2zRoX89PZmvCkCD7UYJ9waRkI= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= diff --git a/rocketpool/api/pdao/initialize-voting.go b/rocketpool/api/pdao/initialize-voting.go index 2a7f8e1e1..89cb6e85f 100644 --- a/rocketpool/api/pdao/initialize-voting.go +++ b/rocketpool/api/pdao/initialize-voting.go @@ -50,7 +50,7 @@ func canNodeInitializeVoting(c *cli.Context) (*api.PDAOCanInitializeVotingRespon return nil, err } - gasInfo, err := network.EstimateInitializeVotingGas(rp, nodeAccount.Address, opts) + gasInfo, err := network.EstimateInitializeVotingGas(rp, opts) if err != nil { return nil, fmt.Errorf("Could not estimate the gas required to claim RPL: %w", err) } @@ -104,7 +104,7 @@ func nodeInitializedVoting(c *cli.Context) (*api.PDAOInitializeVotingResponse, e return nil, fmt.Errorf("Error checking for nonce override: %w", err) } - hash, err := network.InitializeVoting(rp, nodeAccount.Address, opts) + hash, err := network.InitializeVoting(rp, opts) if err != nil { return nil, fmt.Errorf("Error initializing voting: %w", err) } From c3ede9e6be5ddf7c67fbdb7080a55506404df0f2 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Wed, 17 Apr 2024 09:09:46 -0400 Subject: [PATCH 09/28] Update v2.md --- v2.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/v2.md b/v2.md index 7249ef75c..a5efaaf69 100644 --- a/v2.md +++ b/v2.md @@ -82,6 +82,19 @@ The following is a list of what's changed from v1 so far, in no particular order Prior to installation, please note that Smart Node v2 will **only work with the Rocket Pool Houston upgrade**. It will not work with Atlas or any previous Rocket Pool protocol version. +### **IMPORTANT:** Migrating from Smart Node v1 + +If you have Smart Node v1 already installed on your machine, you will need to do a little bit of cleanup before installing v2. + +First, **back up your existing Rocket Pool directory (`~/.rocketpool` by default)** somewhere safe, just in case. Next, run the following command: +``` +rm -rf ~/bin/rocketpool ~/.rocketpool/scripts ~/.rocketpool/templates ~/.rocketpool/prometheus.tmpl +``` +This will delete the old v1 CLI and some accompanying installation files that are no longer stored in your home directory. Note that you **do not have to stop the service before upgrading**. Upgrading to v2 will handle that automatically. + +Now, follow the instructions in whichever of the below sections makes sense for your situation. + + ### Installing via `rocketpool service install` and GitHub This method was used by Smart Node v1, and is still available in v2. It is the "general purpose" method can be used for any release, including development prototypes, and will work on any system that Rocket Pool supports. At a high level it involves manually downloading the CLI, then running a command with it to install the rest of the service. From ec8f9632c1e9981ee2d58221c2987333eb0e9332 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Wed, 17 Apr 2024 10:37:31 -0400 Subject: [PATCH 10/28] Added some debug logs to network balances --- .../watchtower/submit-network-balances.go | 32 ++++++++++++++----- shared/keys/keys.go | 3 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/rocketpool-daemon/watchtower/submit-network-balances.go b/rocketpool-daemon/watchtower/submit-network-balances.go index a6d6c0894..67d048b76 100644 --- a/rocketpool-daemon/watchtower/submit-network-balances.go +++ b/rocketpool-daemon/watchtower/submit-network-balances.go @@ -95,12 +95,12 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { return nil } - // Make a new RP binding just for this portion - rp := t.sp.GetRocketPool() + // Log + t.logger.Info("Starting network balance check.") // Check the last submission block lastSubmissionBlock := state.NetworkDetails.BalancesBlock.Uint64() - networkMgr, err := network.NewNetworkManager(rp) + networkMgr, err := network.NewNetworkManager(t.rp) if err != nil { return fmt.Errorf("error creating network manager binding: %w", err) } @@ -114,16 +114,20 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { // Get the duration in seconds for the interval between submissions submissionIntervalDuration := time.Duration(state.NetworkDetails.BalancesSubmissionFrequency * uint64(time.Second)) eth2Config := state.BeaconConfig + t.logger.Debug("Got last submission block and interval duration.", + slog.Uint64(keys.BlockKey, lastSubmissionBlock), + slog.Duration(keys.IntervalKey, submissionIntervalDuration), + ) var nextSubmissionTime time.Time if !found { // The first submission after Houston is deployed won't find an event emitted by this contract // The submission time will be adjusted to align with the reward time - rewardsPool, err := rewards.NewRewardsPool(rp) + rewardsPool, err := rewards.NewRewardsPool(t.rp) if err != nil { return fmt.Errorf("error creating rewards pool binding: %w", err) } - err = rp.Query(nil, nil, + err = t.rp.Query(nil, nil, rewardsPool.IntervalStart, rewardsPool.IntervalDuration, ) @@ -141,22 +145,34 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { submissionsUntilNextCheckpoint := int(timeDifference/submissionIntervalDuration) + 1 nextSubmissionTime = nextCheckpoint.Add(-time.Duration(submissionsUntilNextCheckpoint) * submissionIntervalDuration) + + t.logger.Debug("Balances updated event not found, using rewards pool", + slog.Time(keys.StartKey, lastCheckpoint), + slog.Duration(keys.IntervalKey, rewardsInterval), + slog.Time(keys.NextKey, nextCheckpoint), + ) } else { // Get the last submission reference time lastSubmissionTime := event.SlotTimestamp // Next submission adds the interval time to the last submission time nextSubmissionTime = lastSubmissionTime.Add(submissionIntervalDuration) + + t.logger.Debug("Found balances updated event", + slog.Uint64(keys.SubmittedKey, event.BlockNumber), + ) } + t.logger.Debug("Checking next submission time", + slog.Time(keys.TimeKey, time.Now()), + slog.Time(keys.NextKey, nextSubmissionTime), + ) + // Return if the time to submit has not arrived if time.Now().Before(nextSubmissionTime) { return nil } - // Log - t.logger.Info("Starting network balance check.") - // Get the Beacon block corresponding to this time genesisTime := time.Unix(int64(eth2Config.GenesisTime), 0) timeSinceGenesis := nextSubmissionTime.Sub(genesisTime) diff --git a/shared/keys/keys.go b/shared/keys/keys.go index 021985f94..a6ce79998 100644 --- a/shared/keys/keys.go +++ b/shared/keys/keys.go @@ -74,4 +74,7 @@ const ( ExpectedKey string = "expected" PubkeyKey string = "pubkey" StateKey string = "state" + SubmittedKey string = "submitted" + NextKey string = "next" + TimeKey string = "time" ) From cdf5853d769d917efb053df99d074c00800d866c Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Wed, 17 Apr 2024 12:58:08 -0400 Subject: [PATCH 11/28] Updated balance and price submissions for Houston --- go.mod | 2 +- go.sum | 4 +- .../watchtower/submit-network-balances.go | 51 +++++++++++-------- .../watchtower/submit-rpl-price.go | 48 +++++++++-------- shared/config/resources.go | 16 +++--- shared/config/smartnode-config.go | 18 +++---- 6 files changed, 77 insertions(+), 62 deletions(-) diff --git a/go.mod b/go.mod index dfca43b00..00d254449 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/prysmaticlabs/prysm/v5 v5.0.3 github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8 - github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32 + github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f github.com/shirou/gopsutil/v3 v3.24.3 github.com/tyler-smith/go-bip39 v1.1.0 github.com/wealdtech/go-ens/v3 v3.6.0 diff --git a/go.sum b/go.sum index b77a67fc4..eef8ebcf1 100644 --- a/go.sum +++ b/go.sum @@ -469,8 +469,8 @@ github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9K github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8 h1:DpNHfImur7EplInBi1mV8ZK8zCBueGFuQWpoDfjJWbw= github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng= -github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32 h1:k+QY2qY5PyktCS9MAPKp6QWlM3sarJXIZ1U7CJtPZng= -github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714= +github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f h1:q+fFGJOhynxDu+ijlpuebVE3apwPCrrY7e1TZ7csFbE= +github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= diff --git a/rocketpool-daemon/watchtower/submit-network-balances.go b/rocketpool-daemon/watchtower/submit-network-balances.go index 67d048b76..01715d437 100644 --- a/rocketpool-daemon/watchtower/submit-network-balances.go +++ b/rocketpool-daemon/watchtower/submit-network-balances.go @@ -41,16 +41,17 @@ const ( // Submit network balances task type SubmitNetworkBalances struct { - ctx context.Context - sp *services.ServiceProvider - logger *slog.Logger - cfg *config.SmartNodeConfig - w *wallet.Wallet - ec eth.IExecutionClient - rp *rocketpool.RocketPool - bc beacon.IBeaconClient - lock *sync.Mutex - isRunning bool + ctx context.Context + sp *services.ServiceProvider + logger *slog.Logger + cfg *config.SmartNodeConfig + w *wallet.Wallet + ec eth.IExecutionClient + rp *rocketpool.RocketPool + bc beacon.IBeaconClient + eventLogInterval *big.Int + lock *sync.Mutex + isRunning bool } // Network balance info @@ -75,16 +76,17 @@ type minipoolBalanceDetails struct { func NewSubmitNetworkBalances(ctx context.Context, sp *services.ServiceProvider, logger *log.Logger) *SubmitNetworkBalances { lock := &sync.Mutex{} return &SubmitNetworkBalances{ - ctx: ctx, - sp: sp, - logger: logger.With(slog.String(keys.TaskKey, "Balance Report")), - cfg: sp.GetConfig(), - w: sp.GetWallet(), - ec: sp.GetEthClient(), - rp: sp.GetRocketPool(), - bc: sp.GetBeaconClient(), - lock: lock, - isRunning: false, + ctx: ctx, + sp: sp, + logger: logger.With(slog.String(keys.TaskKey, "Balance Report")), + cfg: sp.GetConfig(), + w: sp.GetWallet(), + ec: sp.GetEthClient(), + rp: sp.GetRocketPool(), + bc: sp.GetBeaconClient(), + eventLogInterval: big.NewInt(int64(config.EventLogInterval)), + lock: lock, + isRunning: false, } } @@ -106,7 +108,12 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { } // Get the last balances updated event - found, event, err := networkMgr.GetBalancesUpdatedEvent(lastSubmissionBlock, nil) + res := t.cfg.GetRocketPoolResources() + addresses := []common.Address{} + if res.V1_2_0_NetworkBalancesAddress != nil { + addresses = append(addresses, *res.V1_2_0_NetworkBalancesAddress) + } + found, event, err := networkMgr.GetBalancesUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, addresses, nil) if err != nil { return fmt.Errorf("error getting event for balances updated on block %d: %w", lastSubmissionBlock, err) } @@ -164,7 +171,7 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { } t.logger.Debug("Checking next submission time", - slog.Time(keys.TimeKey, time.Now()), + slog.Time(keys.TimeKey, time.Now().UTC()), slog.Time(keys.NextKey, nextSubmissionTime), ) diff --git a/rocketpool-daemon/watchtower/submit-rpl-price.go b/rocketpool-daemon/watchtower/submit-rpl-price.go index d8de1f299..df78f0993 100644 --- a/rocketpool-daemon/watchtower/submit-rpl-price.go +++ b/rocketpool-daemon/watchtower/submit-rpl-price.go @@ -43,31 +43,34 @@ const ( // Submit RPL price task type SubmitRplPrice struct { - ctx context.Context - sp *services.ServiceProvider - logger *slog.Logger - cfg *config.SmartNodeConfig - ec eth.IExecutionClient - w *wallet.Wallet - rp *rocketpool.RocketPool - bc beacon.IBeaconClient - lock *sync.Mutex - isRunning bool + ctx context.Context + sp *services.ServiceProvider + logger *slog.Logger + cfg *config.SmartNodeConfig + ec eth.IExecutionClient + w *wallet.Wallet + rp *rocketpool.RocketPool + bc beacon.IBeaconClient + eventLogInterval *big.Int + lock *sync.Mutex + isRunning bool } // Create submit RPL price task func NewSubmitRplPrice(ctx context.Context, sp *services.ServiceProvider, logger *log.Logger) *SubmitRplPrice { lock := &sync.Mutex{} return &SubmitRplPrice{ - ctx: ctx, - sp: sp, - logger: logger.With(slog.String(keys.TaskKey, "Price Report")), - cfg: sp.GetConfig(), - ec: sp.GetEthClient(), - w: sp.GetWallet(), - rp: sp.GetRocketPool(), - bc: sp.GetBeaconClient(), - lock: lock, + ctx: ctx, + sp: sp, + logger: logger.With(slog.String(keys.TaskKey, "Price Report")), + cfg: sp.GetConfig(), + ec: sp.GetEthClient(), + w: sp.GetWallet(), + rp: sp.GetRocketPool(), + bc: sp.GetBeaconClient(), + eventLogInterval: big.NewInt(int64(config.EventLogInterval)), + lock: lock, + isRunning: false, } } @@ -96,7 +99,12 @@ func (t *SubmitRplPrice) Run(state *state.NetworkState) error { } // Get the last prices updated event - found, event, err := networkMgr.GetPriceUpdatedEvent(lastSubmissionBlock, nil) + res := t.cfg.GetRocketPoolResources() + addresses := []common.Address{} + if res.V1_2_0_NetworkPricesAddress != nil { + addresses = append(addresses, *res.V1_2_0_NetworkPricesAddress) + } + found, event, err := networkMgr.GetPriceUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, addresses, nil) if err != nil { return fmt.Errorf("error getting event for price updated on block %d: %w", lastSubmissionBlock, err) } diff --git a/shared/config/resources.go b/shared/config/resources.go index fc98dcd3f..38f4da5f0 100644 --- a/shared/config/resources.go +++ b/shared/config/resources.go @@ -51,10 +51,10 @@ type RocketPoolResources struct { V1_1_0_MinipoolFactoryAddress *common.Address // The contract address of rocketNetworkPrices from v1.2.0 - v1_2_0_NetworkPricesAddress *common.Address + V1_2_0_NetworkPricesAddress *common.Address // The contract address of rocketNetworkBalances from v1.2.0 - v1_2_0_NetworkBalancesAddress *common.Address + V1_2_0_NetworkBalancesAddress *common.Address // The contract address for Snapshot delegation SnapshotDelegationAddress *common.Address @@ -120,8 +120,8 @@ func newRocketPoolResources(network config.Network) *RocketPoolResources { V1_1_0_NodeDepositAddress: hexToAddressPtr("0x1Cc9cF5586522c6F483E84A19c3C2B0B6d027bF0"), V1_1_0_MinipoolQueueAddress: hexToAddressPtr("0x5870dA524635D1310Dc0e6F256Ce331012C9C19E"), V1_1_0_MinipoolFactoryAddress: hexToAddressPtr("0x54705f80D7C51Fcffd9C659ce3f3C9a7dCCf5788"), - v1_2_0_NetworkPricesAddress: hexToAddressPtr("0x751826b107672360b764327631cC5764515fFC37"), - v1_2_0_NetworkBalancesAddress: hexToAddressPtr("0x07FCaBCbe4ff0d80c2b1eb42855C0131b6cba2F4"), + V1_2_0_NetworkPricesAddress: hexToAddressPtr("0x751826b107672360b764327631cC5764515fFC37"), + V1_2_0_NetworkBalancesAddress: hexToAddressPtr("0x07FCaBCbe4ff0d80c2b1eb42855C0131b6cba2F4"), SnapshotDelegationAddress: hexToAddressPtr("0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446"), SnapshotApiDomain: "hub.snapshot.org", PreviousRewardsPoolAddresses: []common.Address{ @@ -161,8 +161,8 @@ func newRocketPoolResources(network config.Network) *RocketPoolResources { V1_1_0_NodeDepositAddress: nil, V1_1_0_MinipoolQueueAddress: nil, V1_1_0_MinipoolFactoryAddress: nil, - v1_2_0_NetworkPricesAddress: hexToAddressPtr("0x029d946F28F93399a5b0D09c879FC8c94E596AEb"), - v1_2_0_NetworkBalancesAddress: hexToAddressPtr("0x9294Fc6F03c64Cc217f5BE8697EA3Ed2De77e2F8"), + V1_2_0_NetworkPricesAddress: hexToAddressPtr("0x029d946F28F93399a5b0D09c879FC8c94E596AEb"), + V1_2_0_NetworkBalancesAddress: hexToAddressPtr("0x9294Fc6F03c64Cc217f5BE8697EA3Ed2De77e2F8"), SnapshotDelegationAddress: nil, SnapshotApiDomain: "", PreviousRewardsPoolAddresses: []common.Address{}, @@ -200,8 +200,8 @@ func newRocketPoolResources(network config.Network) *RocketPoolResources { V1_1_0_NodeDepositAddress: nil, V1_1_0_MinipoolQueueAddress: nil, V1_1_0_MinipoolFactoryAddress: nil, - v1_2_0_NetworkPricesAddress: hexToAddressPtr("0xBba3FBCD4Bdbfc79118B1B31218602E5A71B426c"), - v1_2_0_NetworkBalancesAddress: hexToAddressPtr("0xBe8Dc8CA5f339c196Aef634DfcDFbA61E30DC743"), + V1_2_0_NetworkPricesAddress: hexToAddressPtr("0xBba3FBCD4Bdbfc79118B1B31218602E5A71B426c"), + V1_2_0_NetworkBalancesAddress: hexToAddressPtr("0xBe8Dc8CA5f339c196Aef634DfcDFbA61E30DC743"), SnapshotDelegationAddress: nil, SnapshotApiDomain: "", PreviousRewardsPoolAddresses: []common.Address{ diff --git a/shared/config/smartnode-config.go b/shared/config/smartnode-config.go index e652dc34e..2dbab50a1 100644 --- a/shared/config/smartnode-config.go +++ b/shared/config/smartnode-config.go @@ -198,7 +198,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.WatchtowerStatePath, Name: "Watchtower Path", Description: "The absolute path of the watchtower state folder that contains persistent state that is used by the watchtower process on trusted nodes. **Only relevant for trusted nodes.**", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: false, }, @@ -297,7 +297,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.RewardsTreeCustomUrlID, Name: "Rewards Tree Custom Download URLs", Description: "The Smartnode will automatically download missing rewards tree files from trusted sources like IPFS and Rocket Pool's repository on GitHub. Use this field if you would like to manually specify additional sources that host the rewards tree files, so the Smartnode can download from them as well.\nMultiple URLs can be provided using ';' as separator).\n\nUse '%s' to specify the location of the rewards file name in the URL - for example: `https://my-cool-domain.com/rewards-trees/mainnet/%s`.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: true, OverwriteOnUpgrade: false, }, @@ -311,7 +311,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.ArchiveEcUrlID, Name: "Archive-Mode EC URL", Description: "[orange]**For manual Merkle rewards tree generation only.**[white]\n\nGenerating the Merkle rewards tree files for past rewards intervals typically requires an Execution client with Archive mode enabled, which is usually disabled on your primary and fallback Execution clients to save disk space.\nIf you want to generate your own rewards tree files for intervals from a long time ago, you may enter the URL of an Execution client with Archive access here.\n\nFor a free light client with Archive access, you may use https://www.alchemy.com/supernode.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: true, OverwriteOnUpgrade: false, }, @@ -325,7 +325,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.WatchtowerMaxFeeOverrideID, Name: "Watchtower Max Fee Override", Description: fmt.Sprintf("[orange]**For Oracle DAO members only.**\n\n[white]Use this to override the max fee (in gwei) for watchtower transactions. Note that if you set it below %d, the setting will be ignored; it can only be used to set the max fee higher than %d during times of extreme network stress.", WatchtowerMaxFeeDefault, WatchtowerMaxFeeDefault), - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: true, }, @@ -339,7 +339,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.WatchtowerPriorityFeeOverrideID, Name: "Watchtower Priority Fee Override", Description: fmt.Sprintf("[orange]**For Oracle DAO members only.**\n\n[white]Use this to override the priority fee (in gwei) for watchtower transactions. Note that if you set it below %d, the setting will be ignored; it can only be used to set the priority fee higher than %d during times of extreme network stress.", WatchtowerPriorityFeeDefault, WatchtowerPriorityFeeDefault), - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: true, }, @@ -353,7 +353,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.UseRollingRecordsID, Name: "Use Rolling Records", Description: "Enable this to use the new rolling records feature, which stores attestation records for the entire Rocket Pool network in real time instead of collecting them all after a rewards period during tree generation.\n\nOnly useful for the Oracle DAO, or if you generate your own rewards trees.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: false, }, @@ -367,7 +367,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.RecordCheckpointIntervalID, Name: "Record Checkpoint Interval", Description: "The number of epochs that should pass before saving a new rolling record checkpoint. Used if Rolling Records is enabled.\n\nOnly useful for the Oracle DAO, or if you generate your own rewards trees.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: false, }, @@ -381,7 +381,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.CheckpointRetentionLimitID, Name: "Checkpoint Retention Limit", Description: "The number of checkpoint files to save on-disk before pruning old ones. Used if Rolling Records is enabled.\n\nOnly useful for the Oracle DAO, or if you generate your own rewards trees.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: false, }, @@ -395,7 +395,7 @@ func NewSmartNodeConfig(rpDir string, isNativeMode bool) *SmartNodeConfig { ID: ids.RecordsPathID, Name: "Records Path", Description: "The path of the folder to store rolling record checkpoints in during a rewards interval. Used if Rolling Records is enabled.\n\nOnly useful if you're an Oracle DAO member, or if you generate your own rewards trees.", - AffectsContainers: []config.ContainerID{}, + AffectsContainers: []config.ContainerID{config.ContainerID_Daemon}, CanBeBlank: false, OverwriteOnUpgrade: false, }, From 805ff69b97e168ed12e15dd9eba774b28d2723a3 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Wed, 17 Apr 2024 13:34:18 -0400 Subject: [PATCH 12/28] Next_account's reader now trims it before parsing --- go.mod | 2 +- go.sum | 4 ++-- rocketpool-daemon/common/validator/next-account.go | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 00d254449..8ab7a4885 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/prometheus/client_golang v1.19.0 github.com/prysmaticlabs/prysm/v5 v5.0.3 github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE - github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8 + github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f github.com/shirou/gopsutil/v3 v3.24.3 github.com/tyler-smith/go-bip39 v1.1.0 diff --git a/go.sum b/go.sum index eef8ebcf1..e6ac556af 100644 --- a/go.sum +++ b/go.sum @@ -467,8 +467,8 @@ github.com/rocket-pool/batch-query v1.0.0 h1:5HejmT1n1fIdLIqUhTNwbkG2PGOPl3IVjCp github.com/rocket-pool/batch-query v1.0.0/go.mod h1:d1CmxShzk0fioJ4yX0eFGhz2an1odnW/LZ2cp3eDGIQ= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s= github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= -github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8 h1:DpNHfImur7EplInBi1mV8ZK8zCBueGFuQWpoDfjJWbw= -github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng= +github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a h1:hBuBMT4XT1ne/6eUdnE3BIfnMsFmFPF7pIRud0aWod8= +github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng= github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f h1:q+fFGJOhynxDu+ijlpuebVE3apwPCrrY7e1TZ7csFbE= github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= diff --git a/rocketpool-daemon/common/validator/next-account.go b/rocketpool-daemon/common/validator/next-account.go index c50354da9..466906a8e 100644 --- a/rocketpool-daemon/common/validator/next-account.go +++ b/rocketpool-daemon/common/validator/next-account.go @@ -6,6 +6,7 @@ import ( "io/fs" "os" "strconv" + "strings" "github.com/rocket-pool/node-manager-core/node/wallet" ) @@ -28,6 +29,7 @@ func loadNextAccount(nextAccountPath string) (uint64, error) { // Parse the account nextAccountString := string(bytes) + nextAccountString = strings.TrimSpace(nextAccountString) nextAccount, err := strconv.ParseUint(nextAccountString, 10, 64) if err != nil { return 0, fmt.Errorf("error parsing next account data at [%s]: %w", nextAccountPath, err) From 00bed167c79a37da798cb59303c0c3245da60865 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Sun, 14 Apr 2024 15:30:28 -0400 Subject: [PATCH 13/28] Add unit test workflow --- .github/workflows/unit-tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..aa511482a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,20 @@ +name: Smart Node Unit Tests +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - run: go test ./... From 4466a16ec54b6d55e50c5f99227f21097eb83595 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Tue, 16 Apr 2024 21:00:36 -0400 Subject: [PATCH 14/28] Add goimports lint github action --- .github/workflows/lint.yml | 50 +++++++++++++++++++ .../watchtower/submit-rpl-price.go | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..eb58a30c0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,50 @@ +# Taken from https://github.com/golangci/golangci-lint-action +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # args: --issues-exit-code=0 + + # For now, Smart Node will only enforce goimports linting + args: --disable-all --enable goimports + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the all caching functionality will be complete disabled, + # takes precedence over all other caching options. + # skip-cache: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true diff --git a/rocketpool-daemon/watchtower/submit-rpl-price.go b/rocketpool-daemon/watchtower/submit-rpl-price.go index d8de1f299..5b4208ac3 100644 --- a/rocketpool-daemon/watchtower/submit-rpl-price.go +++ b/rocketpool-daemon/watchtower/submit-rpl-price.go @@ -82,7 +82,7 @@ func (t *SubmitRplPrice) Run(state *state.NetworkState) error { err := t.updateL2Prices(state) if err != nil { // Error is not fatal for this task so print and continue - t.logger.Error("Error updating L2 prices: %s", err.Error()) + t.logger.Error("Error updating L2 prices", log.Err(err)) } // Make a new RP binding just for this portion From d67b8992ea18b5b89c1677b04e9ad654d17a28db Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 11:51:57 -0400 Subject: [PATCH 15/28] Resolve go test action errors --- .github/workflows/lint.yml | 1 + .github/workflows/unit-tests.yml | 1 + rocketpool-cli/commands/minipool/reduce-bond.go | 12 ++++++++---- rocketpool-cli/commands/minipool/rescue-dissolved.go | 8 +++++--- rocketpool-cli/commands/service/export-ec-data.go | 3 ++- rocketpool-cli/commands/service/import-ec-data.go | 3 ++- rocketpool-cli/commands/service/sync.go | 3 ++- rocketpool-cli/commands/wallet/utils.go | 4 +++- rocketpool-cli/utils/gas/gas.go | 4 ++-- rocketpool-cli/utils/migration/import-key.go | 3 ++- rocketpool-daemon/api/node/deposit.go | 2 +- rocketpool-daemon/node/verify-pdao-props.go | 7 ++++--- .../watchtower/generate-rewards-tree.go | 2 +- 13 files changed, 34 insertions(+), 19 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eb58a30c0..2e6774195 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,6 +7,7 @@ on: branches: - master - main + - v2* pull_request: permissions: contents: read diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index aa511482a..535dd3db3 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -6,6 +6,7 @@ on: branches: - master - main + - v2* pull_request: permissions: contents: read diff --git a/rocketpool-cli/commands/minipool/reduce-bond.go b/rocketpool-cli/commands/minipool/reduce-bond.go index f42150378..26f83890c 100644 --- a/rocketpool-cli/commands/minipool/reduce-bond.go +++ b/rocketpool-cli/commands/minipool/reduce-bond.go @@ -24,11 +24,13 @@ func reduceBondAmount(c *cli.Context) error { // Check the fee distributor if !details.Data.IsFeeDistributorInitialized { - fmt.Println("Minipools cannot have their bonds reduced until your fee distributor has been initialized.\nPlease run `rocketpool node initialize-fee-distributor` first, then return here to reduce your bonds.") + fmt.Println("Minipools cannot have their bonds reduced until your fee distributor has been initialized.") + fmt.Println("Please run `rocketpool node initialize-fee-distributor` first, then return here to reduce your bonds.") return nil } - fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.\n") + fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.") + fmt.Println() // Get reduceable minipools reduceableMinipools := []api.MinipoolReduceBondDetails{} @@ -109,10 +111,12 @@ func forceFeeDistribution(c *cli.Context, rp *client.Client) error { balance := response.Data.Balance if balance.Cmp(common.Big0) == 0 { - fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.\n") + fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.") + fmt.Println() return nil } - fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.\n") + fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.") + fmt.Println() // Print info balanceFloat := eth.WeiToEth(response.Data.Balance) diff --git a/rocketpool-cli/commands/minipool/rescue-dissolved.go b/rocketpool-cli/commands/minipool/rescue-dissolved.go index 52a0cc936..749c573a1 100644 --- a/rocketpool-cli/commands/minipool/rescue-dissolved.go +++ b/rocketpool-cli/commands/minipool/rescue-dissolved.go @@ -29,7 +29,9 @@ func rescueDissolved(c *cli.Context) error { // Get RP client rp := client.NewClientFromCtx(c) - fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.\nPlease read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.\n") + fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.") + fmt.Println("Please read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.") + fmt.Println() // Get minipool statuses details, err := rp.Api.Minipool.GetRescueDissolvedDetails() @@ -91,14 +93,14 @@ func rescueDissolved(c *cli.Context) error { fmt.Printf("\nPlease upgrade the delegate for these minipools using `rocketpool minipool delegate-upgrade` before rescuing them.%s\n\n", terminal.ColorReset) } if len(balanceCompletedMinipools) > 0 { - fmt.Printf("%NOTE: The following minipools already have 32 ETH or more deposited:\n", terminal.ColorYellow) + fmt.Printf("%sNOTE: The following minipools already have 32 ETH or more deposited:\n", terminal.ColorYellow) for _, mp := range balanceCompletedMinipools { fmt.Printf("\t%s\n", mp.Address) } fmt.Printf("\nThese minipools don't need to be rescued.%s\n\n", terminal.ColorReset) } if len(invalidBeaconStateMinipools) > 0 { - fmt.Printf("%NOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", terminal.ColorYellow) + fmt.Printf("%sNOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", terminal.ColorYellow) for _, mp := range invalidBeaconStateMinipools { fmt.Printf("\t%s (%s)\n", mp.Address, mp.BeaconState) } diff --git a/rocketpool-cli/commands/service/export-ec-data.go b/rocketpool-cli/commands/service/export-ec-data.go index 88708d9e0..d3c6cbab8 100644 --- a/rocketpool-cli/commands/service/export-ec-data.go +++ b/rocketpool-cli/commands/service/export-ec-data.go @@ -57,7 +57,8 @@ func exportEcData(c *cli.Context, targetDir string) error { fmt.Println("This will export your execution client's chain data to an external directory, such as a portable hard drive.") fmt.Println("If your execution client is running, it will be shut down.") - fmt.Println("Once the export is complete, your execution client will restart automatically.\n") + fmt.Println("Once the export is complete, your execution client will restart automatically.") + fmt.Println() // Get the EC volume name executionContainerName := cfg.GetDockerArtifactName(config.ExecutionClientSuffix) diff --git a/rocketpool-cli/commands/service/import-ec-data.go b/rocketpool-cli/commands/service/import-ec-data.go index c5a597ada..55648e0fe 100644 --- a/rocketpool-cli/commands/service/import-ec-data.go +++ b/rocketpool-cli/commands/service/import-ec-data.go @@ -42,7 +42,8 @@ func importEcData(c *cli.Context, sourceDir string) error { fmt.Println("This will import execution layer chain data that you previously exported into your execution client.") fmt.Println("If your execution client is running, it will be shut down.") - fmt.Println("Once the import is complete, your execution client will restart automatically.\n") + fmt.Println("Once the import is complete, your execution client will restart automatically.") + fmt.Println() // Get the volume to import into executionContainerName := cfg.GetDockerArtifactName(config.ExecutionClientSuffix) diff --git a/rocketpool-cli/commands/service/sync.go b/rocketpool-cli/commands/service/sync.go index c356a00bc..3e1209a29 100644 --- a/rocketpool-cli/commands/service/sync.go +++ b/rocketpool-cli/commands/service/sync.go @@ -92,7 +92,8 @@ func getSyncProgress(c *cli.Context) error { depositContractInfo.Data.BeaconDepositContract) return nil } else { - fmt.Println("Your Beacon Node is on the correct network.\n") + fmt.Println("Your Beacon Node is on the correct network.") + fmt.Println() } // Get node status diff --git a/rocketpool-cli/commands/wallet/utils.go b/rocketpool-cli/commands/wallet/utils.go index 13eb8eec8..eee77fa57 100644 --- a/rocketpool-cli/commands/wallet/utils.go +++ b/rocketpool-cli/commands/wallet/utils.go @@ -194,7 +194,9 @@ func promptForCustomKeyPasswords(cfg *config.SmartNodeConfig, testOnly bool) (st } // Notify the user - fmt.Println("It looks like you have some custom keystores for your minipool's validators.\nYou will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.\n") + fmt.Println("It looks like you have some custom keystores for your minipool's validators.") + fmt.Println("You will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.") + fmt.Println() // Get the passwords for each one pubkeyPasswords := map[string]string{} diff --git a/rocketpool-cli/utils/gas/gas.go b/rocketpool-cli/utils/gas/gas.go index 525fe6249..5467bd954 100644 --- a/rocketpool-cli/utils/gas/gas.go +++ b/rocketpool-cli/utils/gas/gas.go @@ -193,7 +193,7 @@ func handleEtherchainGasPrices(gasSuggestion gas.EtherchainGasFeeSuggestion, gas desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64) if err != nil { - fmt.Println("Not a valid gas price (%s), try again.", err.Error()) + fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error()) continue } if desiredPriceFloat <= 0 { @@ -271,7 +271,7 @@ func handleEtherscanGasPrices(gasSuggestion gas.EtherscanGasFeeSuggestion, gasIn desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64) if err != nil { - fmt.Println("Not a valid gas price (%s), try again.", err.Error()) + fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error()) continue } if desiredPriceFloat <= 0 { diff --git a/rocketpool-cli/utils/migration/import-key.go b/rocketpool-cli/utils/migration/import-key.go index ef5d90bc5..4a593be8e 100644 --- a/rocketpool-cli/utils/migration/import-key.go +++ b/rocketpool-cli/utils/migration/import-key.go @@ -47,7 +47,8 @@ func ImportKey(c *cli.Context, rp *client.Client, minipoolAddress common.Address fmt.Printf("failed!\n%sWARNING: error restarting validator client: %s\n\nPlease restart it manually so it picks up the new validator key for your minipool.%s", terminal.ColorYellow, err.Error(), terminal.ColorReset) return false } - fmt.Println("done!\n") + fmt.Println("done!") + fmt.Println() } return true diff --git a/rocketpool-daemon/api/node/deposit.go b/rocketpool-daemon/api/node/deposit.go index 6321b61fc..0b5a9928d 100644 --- a/rocketpool-daemon/api/node/deposit.go +++ b/rocketpool-daemon/api/node/deposit.go @@ -267,7 +267,7 @@ func (c *nodeDepositContext) PrepareData(data *api.NodeDepositData, opts *bind.T if status.Exists { return types.ResponseStatus_InvalidChainState, fmt.Errorf("**** ALERT ****\n"+ "Your minipool %s has the following as a validator pubkey:\n\t%s\n"+ - "This key is already in use by validator %d on the Beacon chain!\n"+ + "This key is already in use by validator %s on the Beacon chain!\n"+ "Rocket Pool will not allow you to deposit this validator for your own safety so you do not get slashed.\n"+ "PLEASE REPORT THIS TO THE ROCKET POOL DEVELOPERS.\n"+ "***************\n", minipoolAddress.Hex(), pubkey.Hex(), status.Index) diff --git a/rocketpool-daemon/node/verify-pdao-props.go b/rocketpool-daemon/node/verify-pdao-props.go index dda9e90af..776b9cba1 100644 --- a/rocketpool-daemon/node/verify-pdao-props.go +++ b/rocketpool-daemon/node/verify-pdao-props.go @@ -299,15 +299,16 @@ func (t *VerifyPdaoProps) getChallengeOrDefeatForProposal(prop *protocol.Protoco } // Check if the index has been challenged yet - var state func() types.ChallengeState + var getState func() types.ChallengeState err = t.rp.Query(func(mc *batch.MultiCaller) error { - prop.GetChallengeState(mc, newChallengedIndex) + getState = prop.GetChallengeState(mc, newChallengedIndex) return nil }, opts) if err != nil { return nil, nil, fmt.Errorf("error checking challenge state for proposal %d, index %d: %w", prop.ID, challengedIndex, err) } - switch state() { + state := getState() + switch state { case types.ChallengeState_Unchallenged: // If it's unchallenged, this is the index to challenge return &challenge{ diff --git a/rocketpool-daemon/watchtower/generate-rewards-tree.go b/rocketpool-daemon/watchtower/generate-rewards-tree.go index 805ab7cc3..b5aa565dc 100644 --- a/rocketpool-daemon/watchtower/generate-rewards-tree.go +++ b/rocketpool-daemon/watchtower/generate-rewards-tree.go @@ -231,7 +231,7 @@ func (t *GenerateRewardsTree) generateRewardsTreeImpl(logger *slog.Logger, rp *r } rewardsFile, err := treegen.GenerateTree(t.ctx) if err != nil { - t.handleError(fmt.Errorf("%s Error generating Merkle tree: %w", err), logger) + t.handleError(fmt.Errorf("Error generating Merkle tree: %w", err), logger) return } header := rewardsFile.GetHeader() From 2b30a8f893d012b76e4df481ce83077d8f10106a Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 11:52:37 -0400 Subject: [PATCH 16/28] goimports format shared/types/rewards.go --- shared/types/rewards.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/types/rewards.go b/shared/types/rewards.go index 218ecdaf9..88ba0b1b6 100644 --- a/shared/types/rewards.go +++ b/shared/types/rewards.go @@ -149,7 +149,7 @@ type IntervalInfo struct { SmoothingPoolEthAmount *QuotedBigInt `json:"smoothingPoolEthAmount"` MerkleProof []common.Hash `json:"merkleProof"` - TotalNodeWeight *QuotedBigInt `json:"-"` + TotalNodeWeight *QuotedBigInt `json:"-"` } type QuotedBigInt struct { From 2aacabd7198e769cdd797e77fd7025ccf680b154 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 15:12:24 -0400 Subject: [PATCH 17/28] Add workflow which fails when fixup commits are present --- .github/workflows/commits.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/commits.yml diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml new file mode 100644 index 000000000..1c9df192c --- /dev/null +++ b/.github/workflows/commits.yml @@ -0,0 +1,14 @@ +# Taken from https://github.com/marketplace/actions/block-fixup-commit-merge?version=v2.0.0 +# Updated to use newer ubuntu and checkout action +name: Git Checks + +on: [pull_request] + +jobs: + block-fixup: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Block Fixup Commit Merge + uses: 13rac1/block-fixup-merge-action@v2.0.0 From 24ff3151706776516418ba5ba064d1fa29384d68 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Wed, 17 Apr 2024 15:38:39 -0400 Subject: [PATCH 18/28] Removed Atlas price / balance addresses from the watchtower check --- rocketpool-daemon/watchtower/submit-network-balances.go | 7 +------ rocketpool-daemon/watchtower/submit-rpl-price.go | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/rocketpool-daemon/watchtower/submit-network-balances.go b/rocketpool-daemon/watchtower/submit-network-balances.go index 01715d437..23b0bfb30 100644 --- a/rocketpool-daemon/watchtower/submit-network-balances.go +++ b/rocketpool-daemon/watchtower/submit-network-balances.go @@ -108,12 +108,7 @@ func (t *SubmitNetworkBalances) Run(state *state.NetworkState) error { } // Get the last balances updated event - res := t.cfg.GetRocketPoolResources() - addresses := []common.Address{} - if res.V1_2_0_NetworkBalancesAddress != nil { - addresses = append(addresses, *res.V1_2_0_NetworkBalancesAddress) - } - found, event, err := networkMgr.GetBalancesUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, addresses, nil) + found, event, err := networkMgr.GetBalancesUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, nil, nil) if err != nil { return fmt.Errorf("error getting event for balances updated on block %d: %w", lastSubmissionBlock, err) } diff --git a/rocketpool-daemon/watchtower/submit-rpl-price.go b/rocketpool-daemon/watchtower/submit-rpl-price.go index df78f0993..1adbecf38 100644 --- a/rocketpool-daemon/watchtower/submit-rpl-price.go +++ b/rocketpool-daemon/watchtower/submit-rpl-price.go @@ -99,12 +99,7 @@ func (t *SubmitRplPrice) Run(state *state.NetworkState) error { } // Get the last prices updated event - res := t.cfg.GetRocketPoolResources() - addresses := []common.Address{} - if res.V1_2_0_NetworkPricesAddress != nil { - addresses = append(addresses, *res.V1_2_0_NetworkPricesAddress) - } - found, event, err := networkMgr.GetPriceUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, addresses, nil) + found, event, err := networkMgr.GetPriceUpdatedEvent(lastSubmissionBlock, t.eventLogInterval, nil, nil) if err != nil { return fmt.Errorf("error getting event for price updated on block %d: %w", lastSubmissionBlock, err) } From a0802df45fede7676816a535d166196a08f5c39f Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 18 Apr 2024 09:36:02 -0400 Subject: [PATCH 19/28] Updated go lib --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8ab7a4885..5776c32f2 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/prysmaticlabs/prysm/v5 v5.0.3 github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a - github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f + github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7 github.com/shirou/gopsutil/v3 v3.24.3 github.com/tyler-smith/go-bip39 v1.1.0 github.com/wealdtech/go-ens/v3 v3.6.0 diff --git a/go.sum b/go.sum index e6ac556af..bb122050f 100644 --- a/go.sum +++ b/go.sum @@ -469,8 +469,8 @@ github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9K github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a h1:hBuBMT4XT1ne/6eUdnE3BIfnMsFmFPF7pIRud0aWod8= github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng= -github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f h1:q+fFGJOhynxDu+ijlpuebVE3apwPCrrY7e1TZ7csFbE= -github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417165413-7830e3c4104f/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714= +github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7 h1:liWy3ZNMhHmNOlbKfJXZbUgbBaGj4ZyEZJv+0mWaZ+k= +github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= From 64d15c3c138e1d4401597b31e119a4eee8f48b21 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 18 Apr 2024 11:05:09 -0400 Subject: [PATCH 20/28] Fixed a service-version misprint --- rocketpool-cli/commands/service/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpool-cli/commands/service/version.go b/rocketpool-cli/commands/service/version.go index 9ecdd8321..715cf315d 100644 --- a/rocketpool-cli/commands/service/version.go +++ b/rocketpool-cli/commands/service/version.go @@ -83,7 +83,7 @@ func serviceVersion(c *cli.Context) error { case config.ClientMode_External: // Execution client ec := cfg.ExternalExecutionClient.ExecutionClient.Value - ecFormat := "%s (Externally managed)\n\tImage: %s" + ecFormat := "%s (Externally managed)" switch ec { case config.ExecutionClient_Geth: executionClientString = fmt.Sprintf(ecFormat, "Geth") From cdce4c094787346463d20137b58e9ac2ec5675b2 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 18 Apr 2024 11:11:02 -0400 Subject: [PATCH 21/28] Updated build CI for v2 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b3fb0252..b714fed1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,4 +18,4 @@ jobs: with: go-version: 1.21.8 - run: cd ${GITHUB_WORKSPACE}/rocketpool-cli && go build . - - run: cd ${GITHUB_WORKSPACE}/rocketpool && go build . + - run: cd ${GITHUB_WORKSPACE}/rocketpool-daemon && go build . From 51ee9eef14bc3b5ba7e885c48cf2321829462f6b Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Thu, 18 Apr 2024 22:21:18 -0400 Subject: [PATCH 22/28] Remove sszgen.sh --- sszgen.sh | 6 ------ 1 file changed, 6 deletions(-) delete mode 100755 sszgen.sh diff --git a/sszgen.sh b/sszgen.sh deleted file mode 100755 index 660a35ffb..000000000 --- a/sszgen.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# Generates the ssz encoding methods for eth2 types with fastssz -# Install sszgen with `go get github.com/ferranbt/fastssz/sszgen` -rm -f ./shared/types/eth2/types_encoding.go -sszgen --path ./shared/types/eth2 \ No newline at end of file From 92d5b583417f98f60925d6eef732fb2918219aeb Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:00:10 -0400 Subject: [PATCH 23/28] Add staticcheck config --- staticcheck.conf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 staticcheck.conf diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 000000000..49c689e46 --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1,5 @@ +# Ignore ST1005 (error strings should not be capitalized) +# Ignore ST1020/ST1021/ST1022 (comment formatting for exported functions/types/vars) +# Ignore ST1000 (at least one package comment) +# Ignore ST1003 (allow underscores in names) +checks = ["all", "-ST1005", "-ST1020", "-ST1021", "-ST1022", "-ST1000", "-ST1003"] From 171ebf46aad54caba67852a5493f538118e80107 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:06:10 -0400 Subject: [PATCH 24/28] Enable and fix staticcheck issues --- .github/workflows/lint.yml | 2 +- rocketpool-cli/client/docker.go | 5 +++-- rocketpool-cli/rocketpool-cli.go | 2 +- rocketpool-daemon/api/node/rewards.go | 3 +++ rocketpool-daemon/common/proposals/proposal-manager.go | 3 +++ rocketpool-daemon/common/rewards/files_test.go | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2e6774195..b053fe4df 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: # args: --issues-exit-code=0 # For now, Smart Node will only enforce goimports linting - args: --disable-all --enable goimports + args: --disable-all --enable goimports --enable staticcheck # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true diff --git a/rocketpool-cli/client/docker.go b/rocketpool-cli/client/docker.go index c3af98a35..014ec02e0 100644 --- a/rocketpool-cli/client/docker.go +++ b/rocketpool-cli/client/docker.go @@ -10,6 +10,7 @@ import ( dt "github.com/docker/docker/api/types" dtc "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + dti "github.com/docker/docker/api/types/image" ) // Get the current Docker image used by the given container @@ -114,7 +115,7 @@ func (c *Client) DeleteImage(imageName string) error { return err } // TODO: handle the response here - _, err = d.ImageRemove(context.Background(), imageName, dt.ImageRemoveOptions{}) + _, err = d.ImageRemove(context.Background(), imageName, dti.RemoveOptions{}) return err } @@ -210,7 +211,7 @@ func (c *Client) GetAllDockerImages() ([]DockerImage, error) { return nil, err } - imageList, err := d.ImageList(context.Background(), dt.ImageListOptions{All: true}) + imageList, err := d.ImageList(context.Background(), dti.ListOptions{All: true}) if err != nil { return nil, fmt.Errorf("error getting image details: %w", err) } diff --git a/rocketpool-cli/rocketpool-cli.go b/rocketpool-cli/rocketpool-cli.go index 6bcf26f00..0822d8301 100644 --- a/rocketpool-cli/rocketpool-cli.go +++ b/rocketpool-cli/rocketpool-cli.go @@ -156,7 +156,7 @@ ______ _ _ ______ _ err := validateFlags(c) if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) + fmt.Fprint(os.Stderr, err.Error()) os.Exit(1) } return nil diff --git a/rocketpool-daemon/api/node/rewards.go b/rocketpool-daemon/api/node/rewards.go index 70c653550..903804d3a 100644 --- a/rocketpool-daemon/api/node/rewards.go +++ b/rocketpool-daemon/api/node/rewards.go @@ -91,6 +91,9 @@ func (c *nodeRewardsContext) PrepareData(data *api.NodeRewardsData, opts *bind.T pMgr.GetRewardsPercentages(mc, &percentages) return nil }, nil) + if err != nil { + return types.ResponseStatus_Error, fmt.Errorf("error getting RPL total supply and reward percentages: %w", err) + } // This thing is so complex it's easier to just get the state snapshot and go from there stateMgr, err := state.NewNetworkStateManager(ctx, rp, cfg, ec, bc, nil) diff --git a/rocketpool-daemon/common/proposals/proposal-manager.go b/rocketpool-daemon/common/proposals/proposal-manager.go index 73bb3e927..09c07037c 100644 --- a/rocketpool-daemon/common/proposals/proposal-manager.go +++ b/rocketpool-daemon/common/proposals/proposal-manager.go @@ -158,6 +158,9 @@ func (m *ProposalManager) GetNodeTree(blockNumber uint32, nodeIndex uint64, snap if tree != nil { return tree, nil } + if err != nil { + return nil, err + } // Try to load the voting info snapshot from disk or create it m.logger.Info("Creating node tree...", slog.Uint64(keys.BlockKey, uint64(blockNumber)), slog.Uint64(keys.NodeIndexKey, nodeIndex)) diff --git a/rocketpool-daemon/common/rewards/files_test.go b/rocketpool-daemon/common/rewards/files_test.go index 5222b8605..8cad3fd4f 100644 --- a/rocketpool-daemon/common/rewards/files_test.go +++ b/rocketpool-daemon/common/rewards/files_test.go @@ -60,7 +60,7 @@ func TestFilesFromTree(t *testing.T) { ) } - localMinipoolPerformanceFile, err = ReadLocalMinipoolPerformanceFile(path.Join(dir, "performance.json")) + _, err = ReadLocalMinipoolPerformanceFile(path.Join(dir, "performance.json")) if err != nil { t.Fatal(err) } From dffcfbaf9b91cf2a22d2828e987a146267f161c1 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:11:19 -0400 Subject: [PATCH 25/28] Enable and fix ineffassign issues --- .github/workflows/lint.yml | 2 +- rocketpool-cli/commands/node/utils.go | 2 -- rocketpool-cli/commands/odao/proposals.go | 3 +-- rocketpool-daemon/common/state/network-state.go | 3 ++- rocketpool-daemon/node/collectors/supply-collector.go | 3 +-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b053fe4df..106a34c8b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: # args: --issues-exit-code=0 # For now, Smart Node will only enforce goimports linting - args: --disable-all --enable goimports --enable staticcheck + args: --disable-all --enable goimports --enable staticcheck --enable ineffassign # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true diff --git a/rocketpool-cli/commands/node/utils.go b/rocketpool-cli/commands/node/utils.go index 8aafa4334..2d78df171 100644 --- a/rocketpool-cli/commands/node/utils.go +++ b/rocketpool-cli/commands/node/utils.go @@ -199,7 +199,6 @@ func promptTimezone() string { // Prompt for country country := "" for { - timezone = "" country = utils.Prompt("Please enter a country / continent from the list above:", "^.+$", "Please enter a country / continent from the list above:") exists := false @@ -259,7 +258,6 @@ func promptTimezone() string { // Prompt for region region := "" for { - timezone = "" region = utils.Prompt("Please enter a region from the list above:", "^.+$", "Please enter a region from the list above:") exists := false diff --git a/rocketpool-cli/commands/odao/proposals.go b/rocketpool-cli/commands/odao/proposals.go index 2feecd572..2703eee23 100644 --- a/rocketpool-cli/commands/odao/proposals.go +++ b/rocketpool-cli/commands/odao/proposals.go @@ -92,9 +92,8 @@ func getProposals(c *cli.Context, stateFilter string) error { if bytes.Equal(proposal.ProposerAddress.Bytes(), member.Address.Bytes()) { fmt.Printf("%d: %s - Proposed by: %s (%s)\n", proposal.ID, proposal.Message, member.ID, proposal.ProposerAddress) printed = true + break } - printed = true - break } if !printed { fmt.Printf("%d: %s - Proposed by: %s (no longer on the Oracle DAO)\n", proposal.ID, proposal.Message, proposal.ProposerAddress) diff --git a/rocketpool-daemon/common/state/network-state.go b/rocketpool-daemon/common/state/network-state.go index 3f111a2d3..d5f338862 100644 --- a/rocketpool-daemon/common/state/network-state.go +++ b/rocketpool-daemon/common/state/network-state.go @@ -337,7 +337,8 @@ func CreateNetworkStateForNode(cfg *config.SmartNodeConfig, rp *rocketpool.Rocke return nil, nil, fmt.Errorf("error getting Protocol DAO proposal details: %w", err) } logger.Info(fmt.Sprintf("%d/%d - Retrieved Protocol DAO proposals", currentStep, steps), slog.Duration(keys.TotalElapsedKey, time.Since(start))) - currentStep++ + // If adding more steps below, don't forget to increment currentStep: + // currentStep++ return state, totalEffectiveStake, nil } diff --git a/rocketpool-daemon/node/collectors/supply-collector.go b/rocketpool-daemon/node/collectors/supply-collector.go index 4aa0bc372..86f798312 100644 --- a/rocketpool-daemon/node/collectors/supply-collector.go +++ b/rocketpool-daemon/node/collectors/supply-collector.go @@ -86,7 +86,6 @@ func (c *SupplyCollector) Collect(channel chan<- prometheus.Metric) { } // Sync - nodeCount := float64(-1) nodeFee := state.NetworkDetails.NodeFee initializedCount := float64(-1) prelaunchCount := float64(-1) @@ -95,7 +94,7 @@ func (c *SupplyCollector) Collect(channel chan<- prometheus.Metric) { finalizedCount := float64(-1) // Get total number of Rocket Pool nodes - nodeCount = float64(len(state.NodeDetails)) + nodeCount := float64(len(state.NodeDetails)) // Get the total number of Rocket Pool minipools for _, mpd := range state.MinipoolDetails { From 28915282d5485f79100e418c4751876c34a4753e Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:17:17 -0400 Subject: [PATCH 26/28] Enable and fix gosimple issues --- .github/workflows/lint.yml | 2 +- rocketpool-cli/client/service.go | 2 +- .../commands/wallet/bip39/mnemonic-validator.go | 2 +- rocketpool-daemon/common/alerting/alerting.go | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 106a34c8b..b03208e9c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: # args: --issues-exit-code=0 # For now, Smart Node will only enforce goimports linting - args: --disable-all --enable goimports --enable staticcheck --enable ineffassign + args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true diff --git a/rocketpool-cli/client/service.go b/rocketpool-cli/client/service.go index 5bffa853c..d19621263 100644 --- a/rocketpool-cli/client/service.go +++ b/rocketpool-cli/client/service.go @@ -132,7 +132,7 @@ func (c *Client) InstallService(verbose bool, noDeps bool, version string, path func (c *Client) InstallUpdateTracker(verbose bool, version string, useLocalInstaller bool) error { // Get installation script flags flags := []string{ - "-v", fmt.Sprintf("%s", shellescape.Quote(version)), + "-v", shellescape.Quote(version), } var script []byte diff --git a/rocketpool-cli/commands/wallet/bip39/mnemonic-validator.go b/rocketpool-cli/commands/wallet/bip39/mnemonic-validator.go index 010ed2fa6..95f3b4adc 100644 --- a/rocketpool-cli/commands/wallet/bip39/mnemonic-validator.go +++ b/rocketpool-cli/commands/wallet/bip39/mnemonic-validator.go @@ -47,7 +47,7 @@ func (mv *MnemonicValidator) Filled() bool { func (mv *MnemonicValidator) Finalize() (string, error) { - if mv.Filled() == false { + if !mv.Filled() { return "", errors.New("Not enough words were entered.") } diff --git a/rocketpool-daemon/common/alerting/alerting.go b/rocketpool-daemon/common/alerting/alerting.go index 25458bf71..ad59ce956 100644 --- a/rocketpool-daemon/common/alerting/alerting.go +++ b/rocketpool-daemon/common/alerting/alerting.go @@ -45,7 +45,7 @@ func AlertFeeRecipientChanged(cfg *config.SmartNodeConfig, newFeeRecipient commo return nil } - if cfg.Alertmanager.AlertEnabled_FeeRecipientChanged.Value != true { + if !cfg.Alertmanager.AlertEnabled_FeeRecipientChanged.Value { logMessage("alert for FeeRecipientChanged is disabled, not sending.") return nil } @@ -71,7 +71,7 @@ func AlertMinipoolBondReduced(cfg *config.SmartNodeConfig, minipoolAddress commo return nil } - if cfg.Alertmanager.AlertEnabled_MinipoolBondReduced.Value != true { + if !cfg.Alertmanager.AlertEnabled_MinipoolBondReduced.Value { logMessage("alert for MinipoolBondReduced is disabled, not sending.") return nil } @@ -100,7 +100,7 @@ func AlertMinipoolBalanceDistributed(cfg *config.SmartNodeConfig, minipoolAddres return nil } - if cfg.Alertmanager.AlertEnabled_MinipoolBalanceDistributed.Value != true { + if !cfg.Alertmanager.AlertEnabled_MinipoolBalanceDistributed.Value { logMessage("alert for MinipoolBalanceDistributed is disabled, not sending.") return nil } @@ -128,7 +128,7 @@ func AlertMinipoolPromoted(cfg *config.SmartNodeConfig, minipoolAddress common.A return nil } - if cfg.Alertmanager.AlertEnabled_MinipoolPromoted.Value != true { + if !cfg.Alertmanager.AlertEnabled_MinipoolPromoted.Value { logMessage("alert for MinipoolPromoted is disabled, not sending.") return nil } @@ -156,7 +156,7 @@ func AlertMinipoolStaked(cfg *config.SmartNodeConfig, minipoolAddress common.Add return nil } - if cfg.Alertmanager.AlertEnabled_MinipoolStaked.Value != true { + if !cfg.Alertmanager.AlertEnabled_MinipoolStaked.Value { logMessage("alert for MinipoolStaked is disabled, not sending.") return nil } @@ -193,7 +193,7 @@ func getAlertSettingsForEvent(succeeded bool) (strfmt.DateTime, Severity, string } func AlertExecutionClientSyncComplete(cfg *config.SmartNodeConfig) error { - if cfg.Alertmanager.AlertEnabled_ExecutionClientSyncComplete.Value != true { + if !cfg.Alertmanager.AlertEnabled_ExecutionClientSyncComplete.Value { logMessage("alert for ExecutionClientSyncComplete is disabled, not sending.") return nil } @@ -201,7 +201,7 @@ func AlertExecutionClientSyncComplete(cfg *config.SmartNodeConfig) error { } func AlertBeaconClientSyncComplete(cfg *config.SmartNodeConfig) error { - if cfg.Alertmanager.AlertEnabled_BeaconClientSyncComplete.Value != true { + if !cfg.Alertmanager.AlertEnabled_BeaconClientSyncComplete.Value { logMessage("alert for BeaconClientSyncComplete is disabled, not sending.") return nil } From 02f151745d204d5a6861e18a80cf64c5313637ff Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:25:17 -0400 Subject: [PATCH 27/28] Enable and fix unused issues --- .github/workflows/lint.yml | 2 +- rocketpool-cli/client/utils.go | 14 -- rocketpool-cli/commands/node/utils.go | 77 ---------- .../commands/service/config/cfg-form.go | 2 + .../commands/service/config/pseudomodal.go | 6 - .../service/config/review-native-page.go | 7 - .../commands/service/config/step-random-bn.go | 37 ----- .../commands/service/config/types.go | 4 - .../commands/service/config/wizard.go | 1 - rocketpool-cli/commands/service/sync.go | 6 - rocketpool-cli/commands/wallet/utils.go | 11 -- .../minipool/can-change-withdrawal-creds.go | 1 - .../api/node/get-snapshot-proposals.go | 4 - .../api/node/get-snapshot-voting-power.go | 5 - rocketpool-daemon/api/pdao/utils.go | 22 --- .../api/wallet/delete-password.go | 4 +- rocketpool-daemon/api/wallet/initialize.go | 1 - .../api/wallet/search-and-recover.go | 1 - .../common/rewards/prater-events.go | 132 ------------------ .../node/collectors/trusted-node-collector.go | 3 - shared/config/smartnode-config.go | 19 --- 21 files changed, 4 insertions(+), 355 deletions(-) delete mode 100644 rocketpool-daemon/common/rewards/prater-events.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b03208e9c..a24cad5ce 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: # args: --issues-exit-code=0 # For now, Smart Node will only enforce goimports linting - args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple + args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple --enable unused # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true diff --git a/rocketpool-cli/client/utils.go b/rocketpool-cli/client/utils.go index 33b35d7c0..d97b88ffe 100644 --- a/rocketpool-cli/client/utils.go +++ b/rocketpool-cli/client/utils.go @@ -9,7 +9,6 @@ import ( "path/filepath" "github.com/alessio/shellescape" - "github.com/rocket-pool/node-manager-core/api/types" "github.com/rocket-pool/smartnode/v2/shared/config" "gopkg.in/yaml.v2" ) @@ -98,16 +97,3 @@ func SaveConfig(cfg *config.SmartNodeConfig, directory string, filename string) return nil } - -// Parse and augment the status of a client into a human-readable format -func getClientStatusString(clientStatus types.ClientStatus) string { - if clientStatus.IsSynced { - return "synced and ready" - } - - if clientStatus.IsWorking { - return fmt.Sprintf("syncing (%.2f%%)", SyncRatioToPercent(clientStatus.SyncProgress)) - } - - return fmt.Sprintf("unavailable (%s)", clientStatus.Error) -} diff --git a/rocketpool-cli/commands/node/utils.go b/rocketpool-cli/commands/node/utils.go index 2d78df171..79cd76ec3 100644 --- a/rocketpool-cli/commands/node/utils.go +++ b/rocketpool-cli/commands/node/utils.go @@ -15,19 +15,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/goccy/go-json" - "github.com/mitchellh/go-homedir" - "github.com/rocket-pool/node-manager-core/beacon" "github.com/urfave/cli/v2" - "gopkg.in/yaml.v2" "github.com/rocket-pool/node-manager-core/eth" - nmc_utils "github.com/rocket-pool/node-manager-core/utils" "github.com/rocket-pool/node-manager-core/utils/math" "github.com/rocket-pool/smartnode/v2/rocketpool-cli/client" "github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils" "github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils/tx" - "github.com/rocket-pool/smartnode/v2/shared/config" - "github.com/rocket-pool/smartnode/v2/shared/types/api" ) const ( @@ -326,77 +320,6 @@ func promptMinNodeFee(networkCurrentNodeFee, networkMinNodeFee float64) float64 } -// Prompt for the password to a solo validator key as part of migration -func promptForSoloKeyPassword(cfg *config.SmartNodeConfig, pubkey beacon.ValidatorPubkey) (string, error) { - - // Check for the custom key directory - customKeyDir, err := homedir.Expand(cfg.GetCustomKeyPath()) - if err != nil { - return "", fmt.Errorf("error expanding custom keys directory: %w", err) - } - info, err := os.Stat(customKeyDir) - if os.IsNotExist(err) || !info.IsDir() { - return "", nil - } - - // Get the custom keystore files - files, err := os.ReadDir(customKeyDir) - if err != nil { - return "", fmt.Errorf("error enumerating custom keystores: %w", err) - } - if len(files) == 0 { - return "", nil - } - - // Get the pubkeys for the custom keystores - pubkeyPasswords := map[string]string{} - for _, file := range files { - // Read the file - bytes, err := os.ReadFile(filepath.Join(customKeyDir, file.Name())) - if err != nil { - return "", fmt.Errorf("error reading custom keystore %s: %w", file.Name(), err) - } - - // Deserialize it - keystore := api.ValidatorKeystore{} - err = json.Unmarshal(bytes, &keystore) - if err != nil { - return "", fmt.Errorf("error deserializing custom keystore %s: %w", file.Name(), err) - } - - if keystore.Pubkey == pubkey { - // Found it, prompt for the password - password := utils.PromptPassword( - fmt.Sprintf("Please enter the password that the keystore for %s was encrypted with:", pubkey.Hex()), "^.*$", "", - ) - - formattedPubkey := strings.ToUpper(nmc_utils.RemovePrefix(pubkey.Hex())) - pubkeyPasswords[formattedPubkey] = password - - fmt.Println() - break - } - } - - if len(pubkeyPasswords) == 0 { - 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 Smart Node stack, you will need to put its keystore file into custom-keys first", pubkey.HexWithPrefix()) - } - - // Store it in the file - fileBytes, err := yaml.Marshal(pubkeyPasswords) - if err != nil { - return "", fmt.Errorf("error serializing keystore passwords file: %w", err) - } - passwordFile := cfg.GetCustomKeyPasswordFilePath() - err = os.WriteFile(passwordFile, fileBytes, 0600) - if err != nil { - return "", fmt.Errorf("error writing keystore passwords file: %w", err) - } - - return passwordFile, nil - -} - func SwapRpl(c *cli.Context, rp *client.Client, amountWei *big.Int) error { // Get the TX response, err := rp.Api.Node.SwapRpl(amountWei) diff --git a/rocketpool-cli/commands/service/config/cfg-form.go b/rocketpool-cli/commands/service/config/cfg-form.go index 1fbe2c95b..3898dbc84 100644 --- a/rocketpool-cli/commands/service/config/cfg-form.go +++ b/rocketpool-cli/commands/service/config/cfg-form.go @@ -16,6 +16,7 @@ type parameterizedFormItem struct { item tview.FormItem } +/* func registerEnableCheckbox(param *config.Parameter[bool], checkbox *tview.Checkbox, form *Form, items []*parameterizedFormItem) { checkbox.SetChangedFunc(func(checked bool) { param.Value = checked @@ -29,6 +30,7 @@ func registerEnableCheckbox(param *config.Parameter[bool], checkbox *tview.Check } }) } +*/ // Create a list of form items based on a set of parameters func createParameterizedFormItems(params []config.IParameter, descriptionBox *tview.TextView) []*parameterizedFormItem { diff --git a/rocketpool-cli/commands/service/config/pseudomodal.go b/rocketpool-cli/commands/service/config/pseudomodal.go index 327c9a1ed..624992582 100644 --- a/rocketpool-cli/commands/service/config/pseudomodal.go +++ b/rocketpool-cli/commands/service/config/pseudomodal.go @@ -36,12 +36,6 @@ type Pseudomodal struct { // The currently selected form (for vertical layouts) selected int - - // A fixed width for the description box (0 for auto) - descriptionWidth int - - // The collection of descriptions for each button, to be displayed in the description box - buttonDescriptions []string } // NewPseudomodal returns a new modal message window. diff --git a/rocketpool-cli/commands/service/config/review-native-page.go b/rocketpool-cli/commands/service/config/review-native-page.go index a7c047b82..7eb53077b 100644 --- a/rocketpool-cli/commands/service/config/review-native-page.go +++ b/rocketpool-cli/commands/service/config/review-native-page.go @@ -13,13 +13,6 @@ import ( // Constants const reviewNativePageID string = "review-native-settings" -// The changed settings review page -type ReviewNativePage struct { - md *mainDisplay - changedSettings []*config.ChangedSection - page *page -} - // Create a page to review any changes func NewReviewNativePage(md *mainDisplay, oldConfig *snCfg.SmartNodeConfig, newConfig *snCfg.SmartNodeConfig) *ReviewPage { var changedSettings []*config.ChangedSection diff --git a/rocketpool-cli/commands/service/config/step-random-bn.go b/rocketpool-cli/commands/service/config/step-random-bn.go index 84ea8ad8c..1850ccd82 100644 --- a/rocketpool-cli/commands/service/config/step-random-bn.go +++ b/rocketpool-cli/commands/service/config/step-random-bn.go @@ -9,43 +9,6 @@ import ( const randomBnPrysmID string = "step-random-bn-prysm" const randomBnID string = "step-random-bn" -func createRandomPrysmStep(wiz *wizard, currentStep int, totalSteps int, goodOptions []*config.ParameterOption[config.BeaconNode]) *choiceWizardStep { - 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." - - show := func(modal *choiceModalLayout) { - wiz.md.setPage(modal.page) - modal.focus(0) - } - - done := func(buttonIndex int, buttonLabel string) { - if buttonIndex == 0 { - selectRandomBn(goodOptions, false, wiz, currentStep, totalSteps) - } else { - wiz.checkpointSyncProviderModal.show() - } - } - - back := func() { - wiz.localBnModal.show() - } - - return newChoiceStep( - wiz, - currentStep, - totalSteps, - helperText, - []string{"Choose Another Random Client", "Keep Prysm"}, - []string{}, - 76, - "Beacon Node > Selection", - DirectionalModalHorizontal, - show, - done, - back, - randomBnPrysmID, - ) -} - func createRandomBnStep(wiz *wizard, currentStep int, totalSteps int, goodOptions []*config.ParameterOption[config.BeaconNode]) *choiceWizardStep { var selectedClientName string selectedClient := wiz.md.Config.LocalBeaconClient.BeaconNode.Value diff --git a/rocketpool-cli/commands/service/config/types.go b/rocketpool-cli/commands/service/config/types.go index e122ac3fe..f3bf3eedf 100644 --- a/rocketpool-cli/commands/service/config/types.go +++ b/rocketpool-cli/commands/service/config/types.go @@ -4,7 +4,3 @@ type settingsPage interface { handleLayoutChanged() getPage() *page } - -type wizardStep interface { - show() -} diff --git a/rocketpool-cli/commands/service/config/wizard.go b/rocketpool-cli/commands/service/config/wizard.go index b818396fa..f42506436 100644 --- a/rocketpool-cli/commands/service/config/wizard.go +++ b/rocketpool-cli/commands/service/config/wizard.go @@ -25,7 +25,6 @@ type wizard struct { // Step 5 - BN settings localBnModal *choiceWizardStep localBnRandomModal *choiceWizardStep - localBnRandomPrysmModal *choiceWizardStep localBnPrysmWarning *choiceWizardStep localBnTekuWarning *choiceWizardStep checkpointSyncProviderModal *textBoxWizardStep diff --git a/rocketpool-cli/commands/service/sync.go b/rocketpool-cli/commands/service/sync.go index 3e1209a29..7e27a444b 100644 --- a/rocketpool-cli/commands/service/sync.go +++ b/rocketpool-cli/commands/service/sync.go @@ -4,7 +4,6 @@ import ( "fmt" "math" "strings" - "time" "github.com/urfave/cli/v2" @@ -22,11 +21,6 @@ func SyncRatioToPercent(in float64) float64 { // TODO: INCORPORATE THIS } -// Settings -const ( - ethClientRecentBlockThreshold time.Duration = 5 * time.Minute -) - func printClientStatus(status *types.ClientStatus, name string) { if status.Error != "" { diff --git a/rocketpool-cli/commands/wallet/utils.go b/rocketpool-cli/commands/wallet/utils.go index 029803f2f..889a6c641 100644 --- a/rocketpool-cli/commands/wallet/utils.go +++ b/rocketpool-cli/commands/wallet/utils.go @@ -224,14 +224,3 @@ func promptForCustomKeyPasswords(cfg *config.SmartNodeConfig, testOnly bool) (st return passwordFile, nil } - -// Deletes the custom key password file -func deleteCustomKeyPasswordFile(passwordFile string) error { - _, err := os.Stat(passwordFile) - if os.IsNotExist(err) { - return nil - } - - err = os.Remove(passwordFile) - return err -} diff --git a/rocketpool-daemon/api/minipool/can-change-withdrawal-creds.go b/rocketpool-daemon/api/minipool/can-change-withdrawal-creds.go index 2a6b88d01..374ad64e6 100644 --- a/rocketpool-daemon/api/minipool/can-change-withdrawal-creds.go +++ b/rocketpool-daemon/api/minipool/can-change-withdrawal-creds.go @@ -62,7 +62,6 @@ type minipoolCanChangeCredsContext struct { mnemonic string minipoolAddress common.Address - mpMgr *minipool.MinipoolManager mpv3 *minipool.MinipoolV3 } diff --git a/rocketpool-daemon/api/node/get-snapshot-proposals.go b/rocketpool-daemon/api/node/get-snapshot-proposals.go index 9a4768994..8615fddbf 100644 --- a/rocketpool-daemon/api/node/get-snapshot-proposals.go +++ b/rocketpool-daemon/api/node/get-snapshot-proposals.go @@ -9,8 +9,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/gorilla/mux" batch "github.com/rocket-pool/batch-query" - "github.com/rocket-pool/rocketpool-go/v2/node" - "github.com/rocket-pool/rocketpool-go/v2/rocketpool" "github.com/rocket-pool/node-manager-core/api/server" "github.com/rocket-pool/node-manager-core/api/types" @@ -49,10 +47,8 @@ func (f *nodeGetSnapshotProposalsContextFactory) RegisterRoute(router *mux.Route type nodeGetSnapshotProposalsContext struct { handler *NodeHandler - rp *rocketpool.RocketPool activeOnly bool - node *node.Node } func (c *nodeGetSnapshotProposalsContext) PrepareData(data *api.NodeGetSnapshotProposalsData, opts *bind.TransactOpts) (types.ResponseStatus, error) { diff --git a/rocketpool-daemon/api/node/get-snapshot-voting-power.go b/rocketpool-daemon/api/node/get-snapshot-voting-power.go index 8830ccb6c..5156479db 100644 --- a/rocketpool-daemon/api/node/get-snapshot-voting-power.go +++ b/rocketpool-daemon/api/node/get-snapshot-voting-power.go @@ -5,8 +5,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/gorilla/mux" - "github.com/rocket-pool/rocketpool-go/v2/node" - "github.com/rocket-pool/rocketpool-go/v2/rocketpool" "github.com/rocket-pool/node-manager-core/api/server" "github.com/rocket-pool/node-manager-core/api/types" @@ -41,9 +39,6 @@ func (f *nodeGetSnapshotVotingPowerContextFactory) RegisterRoute(router *mux.Rou type nodeGetSnapshotVotingPowerContext struct { handler *NodeHandler - rp *rocketpool.RocketPool - - node *node.Node } func (c *nodeGetSnapshotVotingPowerContext) PrepareData(data *api.NodeGetSnapshotVotingPowerData, opts *bind.TransactOpts) (types.ResponseStatus, error) { diff --git a/rocketpool-daemon/api/pdao/utils.go b/rocketpool-daemon/api/pdao/utils.go index 979579b8b..0d35bfd72 100644 --- a/rocketpool-daemon/api/pdao/utils.go +++ b/rocketpool-daemon/api/pdao/utils.go @@ -32,25 +32,3 @@ func createPollard(context context.Context, logger *slog.Logger, rp *rocketpool. } return blockNumber, pollard, nil } - -// Loads (or regenerates) the pollard for a proposal from a block number -func getPollard(context context.Context, logger *slog.Logger, rp *rocketpool.RocketPool, cfg *config.SmartNodeConfig, bc beacon.IBeaconClient, blockNumber uint32) ([]types.VotingTreeNode, error) { - // Create a proposal manager - propMgr, err := proposals.NewProposalManager(context, logger, cfg, rp, bc) - if err != nil { - return nil, err - } - - // Get the pollard - pollardPtrs, err := propMgr.GetPollardForProposal(blockNumber) - if err != nil { - return nil, err - } - - // Make a slice of nodes from their pointers - pollard := make([]types.VotingTreeNode, len(pollardPtrs)) - for i := range pollardPtrs { - pollard[i] = *pollardPtrs[i] - } - return pollard, nil -} diff --git a/rocketpool-daemon/api/wallet/delete-password.go b/rocketpool-daemon/api/wallet/delete-password.go index 2cb5b94b1..471e66a20 100644 --- a/rocketpool-daemon/api/wallet/delete-password.go +++ b/rocketpool-daemon/api/wallet/delete-password.go @@ -37,9 +37,7 @@ func (f *walletDeletePasswordContextFactory) RegisterRoute(router *mux.Router) { // =============== type walletDeletePasswordContext struct { - handler *WalletHandler - password []byte - save bool + handler *WalletHandler } func (c *walletDeletePasswordContext) PrepareData(data *types.SuccessData, opts *bind.TransactOpts) (types.ResponseStatus, error) { diff --git a/rocketpool-daemon/api/wallet/initialize.go b/rocketpool-daemon/api/wallet/initialize.go index a09b24a44..3b411e741 100644 --- a/rocketpool-daemon/api/wallet/initialize.go +++ b/rocketpool-daemon/api/wallet/initialize.go @@ -53,7 +53,6 @@ type walletInitializeContext struct { derivationPath string index uint64 password string - passwordExists bool savePassword bool saveWallet bool } diff --git a/rocketpool-daemon/api/wallet/search-and-recover.go b/rocketpool-daemon/api/wallet/search-and-recover.go index cb06bbea9..5dd1d1113 100644 --- a/rocketpool-daemon/api/wallet/search-and-recover.go +++ b/rocketpool-daemon/api/wallet/search-and-recover.go @@ -57,7 +57,6 @@ type walletSearchAndRecoverContext struct { mnemonic string address common.Address password string - passwordExists bool savePassword bool } diff --git a/rocketpool-daemon/common/rewards/prater-events.go b/rocketpool-daemon/common/rewards/prater-events.go deleted file mode 100644 index b1f76dcda..000000000 --- a/rocketpool-daemon/common/rewards/prater-events.go +++ /dev/null @@ -1,132 +0,0 @@ -package rewards - -import ( - "fmt" - "math/big" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/rocket-pool/rocketpool-go/v2/rewards" -) - -// This file contains hardcoded events for Prater for the intervals before the contracts emitted rewards snapshot events, -// so the Smartnode has something to "look up" during events collection. -var praterPrehistoryIntervalEvents []rewards.RewardsEvent = []rewards.RewardsEvent{ - // TX: 0xe90cb89e2f83fb6577a9cb27421ec802df090fea1b156fea8444d57e0c41040a - { - Index: big.NewInt(0), - ExecutionBlock: big.NewInt(7279809), - ConsensusBlock: big.NewInt(3509855), - MerkleRoot: common.HexToHash("0xae2f4ca79cb5176e7262201486739c614fd9197a9d95b1a28da23498a25000c4"), - MerkleTreeCID: "bafybeifcixenfbmzsbaar7zowpiyn3rh42px2sgci3zhc3oecr5ixfm754", - IntervalsPassed: big.NewInt(2), - TreasuryRPL: parseBigInt("3389231943988237492628"), - TrustedNodeRPL: []*big.Int{parseBigInt("3389231943988237492032")}, - NodeRPL: []*big.Int{parseBigInt("15816415738611774962240")}, - NodeETH: []*big.Int{big.NewInt(0)}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1658107596, 0), - IntervalEndTime: time.Unix(1658625996, 0), - SubmissionTime: time.Unix(1658740664, 0), - }, - - // TX: 0x054bf4ca2c8649199b70f87ee6dec96eabb3184b77d8d396e85cb46c693acc19 - { - Index: big.NewInt(1), - ExecutionBlock: big.NewInt(7296892), - ConsensusBlock: big.NewInt(3531455), - MerkleRoot: common.HexToHash("0x76a5d0de3c7f92dab4d606c7a66246c07d4dc4003e330fc645541e828e8d11eb"), - MerkleTreeCID: "bafybeifhelxls7xsdeh4j7gokmqfherpzoyzo576s2j5gi42wl7zyhukeq", - IntervalsPassed: big.NewInt(1), - TreasuryRPL: parseBigInt("1134827945857665760894"), - TrustedNodeRPL: []*big.Int{parseBigInt("1134827945857665760312")}, - NodeRPL: []*big.Int{parseBigInt("5295863747335773547586")}, - NodeETH: []*big.Int{big.NewInt(565216198390830158)}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1658625996, 0), - IntervalEndTime: time.Unix(1658885196, 0), - SubmissionTime: time.Unix(1658887477, 0), - }, - - // TX: 0xb70877c8cb8f63f59f67a2460f261b317d122349d869fea0796b7c692751eba7 - { - Index: big.NewInt(2), - ExecutionBlock: big.NewInt(7314096), - ConsensusBlock: big.NewInt(3553055), - MerkleRoot: common.HexToHash("0x2ef194dbd254c797c263089f9aa49132843a4b2881a2e8aa9c7456a06a59e6a4"), - MerkleTreeCID: "bafybeihsny3shsgsgiaft3u5oceur2wwj2quyspws7wceqpo6rlinriu3q", - IntervalsPassed: big.NewInt(1), - TreasuryRPL: parseBigInt("1135283120200590076960"), - TrustedNodeRPL: []*big.Int{parseBigInt("1135283120200590076448")}, - NodeRPL: []*big.Int{parseBigInt("5297987894269420356281")}, - NodeETH: []*big.Int{big.NewInt(245851786378530887)}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1658885196, 0), - IntervalEndTime: time.Unix(1659144396, 0), - SubmissionTime: time.Unix(1659146709, 0), - }, - - // TX: 0x36baad3ecb07d9c1751b3f76f7378c23c0844296a333eafaa42d3fced5be0e93 - { - Index: big.NewInt(3), - ExecutionBlock: big.NewInt(7331289), - ConsensusBlock: big.NewInt(3574655), - MerkleRoot: common.HexToHash("0x64a1cba078633b82c12e32f5e6d94117c85bb41cfa1e237b60757d7e45d92ecb"), - MerkleTreeCID: "bafybeigbmzcdw2dbil5qkqiztqf3httceyd2fitwtk3aaf5x533x67dk2i", - IntervalsPassed: big.NewInt(1), - TreasuryRPL: parseBigInt("1135738477111879239196"), - TrustedNodeRPL: []*big.Int{parseBigInt("1135738477111879238408")}, - NodeRPL: []*big.Int{parseBigInt("5300112893188769778496")}, - NodeETH: []*big.Int{big.NewInt(106846466469715898)}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1659144396, 0), - IntervalEndTime: time.Unix(1659403596, 0), - SubmissionTime: time.Unix(1659406463, 0), - }, - - // TX: 0xbd46261e656c6f446a127ca58484e1c9c6a68e735e2cb32d90a290062cb4efd9 - { - Index: big.NewInt(4), - ExecutionBlock: big.NewInt(7382763), - ConsensusBlock: big.NewInt(3639455), - MerkleRoot: common.HexToHash("0x7ff29433dead5b3f4f289b7ecbede03e0b8a2377748191584471283035e93fed"), - MerkleTreeCID: "bafybeiezkea32s4npgwv3nlkjfn6er4ohhiamnkl2if5ugf7cqmd5dnjne", - IntervalsPassed: big.NewInt(3), - TreasuryRPL: parseBigInt("3409949399585607533077"), - TrustedNodeRPL: []*big.Int{parseBigInt("3409949399585607532568")}, - NodeRPL: []*big.Int{parseBigInt("15913097198066168484824")}, - NodeETH: []*big.Int{parseBigInt("23844561349772065836")}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1659403596, 0), - IntervalEndTime: time.Unix(1660181196, 0), - SubmissionTime: time.Unix(1660252236, 0), - }, - - // TX: 0xab81c7882d1646c31acab36145739ed87f76693e23eba50171a1dffd2d8aa4e0 - { - Index: big.NewInt(5), - ExecutionBlock: big.NewInt(7400317), - ConsensusBlock: big.NewInt(3661055), - MerkleRoot: common.HexToHash("0x9b6b9689f5638b3a86b356b3c5acdc44167c25415a3e3209c5c78a5f92567bb8"), - MerkleTreeCID: "bafybeiaukxxdzni6twjvebjamomtdkic4knccqdgdjwiunqfzfzohwtgq4", - IntervalsPassed: big.NewInt(1), - TreasuryRPL: parseBigInt("1137561731905671847934"), - TrustedNodeRPL: []*big.Int{parseBigInt("1137561731905671847312")}, - NodeRPL: []*big.Int{parseBigInt("5308621415559801953508")}, - NodeETH: []*big.Int{parseBigInt("10484778253257561700")}, - UserETH: big.NewInt(0), - IntervalStartTime: time.Unix(1660181196, 0), - IntervalEndTime: time.Unix(1660440396, 0), - SubmissionTime: time.Unix(1660609908, 0), - }, -} - -// Parses a string into a BigInt, panicking if it's not legal -func parseBigInt(number string) *big.Int { - result, success := big.NewInt(0).SetString(number, 10) - if !success { - panic(fmt.Sprintf("Error parsing Prater precompiled value %s", number)) - } - - return result -} diff --git a/rocketpool-daemon/node/collectors/trusted-node-collector.go b/rocketpool-daemon/node/collectors/trusted-node-collector.go index 83d08def0..0d6cdff89 100644 --- a/rocketpool-daemon/node/collectors/trusted-node-collector.go +++ b/rocketpool-daemon/node/collectors/trusted-node-collector.go @@ -3,7 +3,6 @@ package collectors import ( "log/slog" "strconv" - "time" "github.com/ethereum/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" @@ -42,8 +41,6 @@ type TrustedNodeCollector struct { // The logger logger *slog.Logger - // Cached data - cacheTime time.Time cachedMetrics []prometheus.Metric // The thread-safe locker for the network state diff --git a/shared/config/smartnode-config.go b/shared/config/smartnode-config.go index 2dbab50a1..ac3248c00 100644 --- a/shared/config/smartnode-config.go +++ b/shared/config/smartnode-config.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/alessio/shellescape" - "github.com/pbnjay/memory" "github.com/rocket-pool/node-manager-core/config" "github.com/rocket-pool/smartnode/v2/shared" "github.com/rocket-pool/smartnode/v2/shared/config/ids" @@ -753,24 +752,6 @@ func getNetworkOptions() []*config.ParameterOption[config.Network] { return options } -// Get a more verbose client description, including warnings -func getAugmentedEcDescription(client config.ExecutionClient, originalDescription string) string { - switch client { - case config.ExecutionClient_Nethermind: - totalMemoryGB := memory.TotalMemory() / 1024 / 1024 / 1024 - if totalMemoryGB < 9 { - return fmt.Sprintf("%s\n\n[red]WARNING: Nethermind currently requires over 8 GB of RAM to run smoothly. We do not recommend it for your system. This may be improved in a future release.", originalDescription) - } - case config.ExecutionClient_Besu: - totalMemoryGB := memory.TotalMemory() / 1024 / 1024 / 1024 - if totalMemoryGB < 9 { - return fmt.Sprintf("%s\n\n[red]WARNING: Besu currently requires over 8 GB of RAM to run smoothly. We do not recommend it for your system. This may be improved in a future release.", originalDescription) - } - } - - return originalDescription -} - // Get the default data directory func getDefaultDataDir(rpDir string) string { return filepath.Join(rpDir, "data") From ea7a83a3d82c6c8e8058eb00050e4377ae965dad Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Wed, 17 Apr 2024 17:33:59 -0400 Subject: [PATCH 28/28] Flip all linters on except errcheck --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a24cad5ce..45082bcb9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,8 +34,8 @@ jobs: # Optional: golangci-lint command line arguments. # args: --issues-exit-code=0 - # For now, Smart Node will only enforce goimports linting - args: --disable-all --enable goimports --enable staticcheck --enable ineffassign --enable gosimple --enable unused + # For now, Smart Node will enforce everything except errcheck + args: --disable errcheck # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true