From 892ed0ca3c100b7c5bc84bb41a47dc7017782426 Mon Sep 17 00:00:00 2001 From: thomaspanf Date: Wed, 25 Feb 2026 21:36:24 -0800 Subject: [PATCH] Fix nil pointers by returning errors instead of logging --- rocketpool/node/notify-final-balance.go | 2 +- rocketpool/watchtower/dissolve-invalid-credentials.go | 3 ++- rocketpool/watchtower/submit-network-balances.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rocketpool/node/notify-final-balance.go b/rocketpool/node/notify-final-balance.go index 060b2d378..3fab917ce 100644 --- a/rocketpool/node/notify-final-balance.go +++ b/rocketpool/node/notify-final-balance.go @@ -194,7 +194,7 @@ func (t *notifyFinalBalance) createFinalBalanceProof(rp *rocketpool.RocketPool, withdrawalProof, proofSlot, stateUsed, err := services.GetWithdrawalProofForSlot(t.c, slot, validatorIndex) if err != nil { - fmt.Printf("An error occurred: %s\n", err) + return fmt.Errorf("error getting withdrawal proof for validator 0x%s (index: %d): %w", validatorPubkey.String(), validatorIndex, err) } t.log.Printlnf("The Beacon WithdrawalSlot for validator ID %d is: %d", validatorInfo.ValidatorId, withdrawalProof.WithdrawalSlot) diff --git a/rocketpool/watchtower/dissolve-invalid-credentials.go b/rocketpool/watchtower/dissolve-invalid-credentials.go index 653557112..fabb95193 100644 --- a/rocketpool/watchtower/dissolve-invalid-credentials.go +++ b/rocketpool/watchtower/dissolve-invalid-credentials.go @@ -97,7 +97,8 @@ func (t *dissolveInvalidCredentials) dissolveInvalidCredentialValidators(state * // Fetch the validator from the beacon state to compare credentials validatorFromState, err := t.bc.GetValidatorStatus(types.ValidatorPubkey(validator.Pubkey), nil) if err != nil { - t.log.Printlnf("Error fetching validator %s from beacon state: %s", validatorFromState.Index, err) + pubkey := types.BytesToValidatorPubkey(validator.Pubkey).String() + t.log.Printlnf("error getting the beacon state for validator 0x%s on megapool %s: %s", pubkey, validator.MegapoolAddress, err) continue } if !validatorFromState.Exists { diff --git a/rocketpool/watchtower/submit-network-balances.go b/rocketpool/watchtower/submit-network-balances.go index 1f3933151..933594325 100644 --- a/rocketpool/watchtower/submit-network-balances.go +++ b/rocketpool/watchtower/submit-network-balances.go @@ -536,11 +536,11 @@ func (t *submitNetworkBalances) getMegapoolBalanceDetails(megapoolAddress common // Convert the validator index to a uint64 validatorIndex, err := strconv.ParseUint(megapoolValidatorDetails.Index, 10, 64) if err != nil { - fmt.Printf("An error occurred while converting the validator index to a uint64: %s\n", err) + return megapoolBalanceDetails, fmt.Errorf("error converting validator index %s to uint64: %w", megapoolValidatorDetails.Index, err) } _, _, _, withdrawal, _, err := services.FindWithdrawalBlockAndArrayPosition(searchWithdrawSlot, validatorIndex, t.bc) if err != nil { - fmt.Printf("An error occurred while searching for the withdrawn balance: %s\n", err) + return megapoolBalanceDetails, fmt.Errorf("error finding withdrawal for validator %d: %w", validatorIndex, err) } // Track the withdrawn balance so we can discount it from the pending rewards on the contract totalWithdrawnBalance.Add(totalWithdrawnBalance, eth.GweiToWei(float64(withdrawal.Amount)))