From c33be0a4106fcefe77bf67eef020a3f32932341f Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 21 Mar 2022 11:28:42 -0400 Subject: [PATCH] state: propogate error from state store (#8171) * state: propogate error from state store * fix lint --- internal/state/errors.go | 8 +++++++- internal/state/store.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/state/errors.go b/internal/state/errors.go index 6e0cdfa47..e8ad776f4 100644 --- a/internal/state/errors.go +++ b/internal/state/errors.go @@ -39,6 +39,7 @@ type ( ErrNoValSetForHeight struct { Height int64 + Err error } ErrNoConsensusParamsForHeight struct { @@ -89,9 +90,14 @@ func (e ErrStateMismatch) Error() string { } func (e ErrNoValSetForHeight) Error() string { - return fmt.Sprintf("could not find validator set for height #%d", e.Height) + if e.Err == nil { + return fmt.Sprintf("could not find validator set for height #%d", e.Height) + } + return fmt.Sprintf("could not find validator set for height #%d: %s", e.Height, e.Err.Error()) } +func (e ErrNoValSetForHeight) Unwrap() error { return e.Err } + func (e ErrNoConsensusParamsForHeight) Error() string { return fmt.Sprintf("could not find consensus params for height #%d", e.Height) } diff --git a/internal/state/store.go b/internal/state/store.go index 93bd3eb2b..87f5e0c4f 100644 --- a/internal/state/store.go +++ b/internal/state/store.go @@ -488,7 +488,7 @@ func (store dbStore) LoadValidators(height int64) (*types.ValidatorSet, error) { valInfo, err := loadValidatorsInfo(store.db, height) if err != nil { - return nil, ErrNoValSetForHeight{height} + return nil, ErrNoValSetForHeight{Height: height, Err: err} } if valInfo.ValidatorSet == nil { lastStoredHeight := lastStoredHeightFor(height, valInfo.LastHeightChanged)