Files
tendermint/internal/state/errors.go
Sergio Mena ce6485fa70 Remove the abci responses type - prune legacy responses (#8673)
Closes #8069 

* Type `ABCIResponses` was just wrapping type `ResponseFinalizeBlock`. This patch removes the former.
* Did some renaming to avoid confusion on the data structure we are working with.
* We also remove any stale ABCIResponses we may have in the state store at the time of pruning

**IMPORTANT**: There is an undesirable side-effect of the unwrapping. An empty `ResponseFinalizeBlock` yields a 0-length proto-buf serialized buffer. This was not the case with `ABCIResponses`. I have added an interim solution, but open for suggestions on more elegant ones.
2022-06-02 19:13:08 +00:00

108 lines
2.2 KiB
Go

package state
import "fmt"
type (
ErrInvalidBlock error
ErrProxyAppConn error
ErrUnknownBlock struct {
Height int64
}
ErrBlockHashMismatch struct {
CoreHash []byte
AppHash []byte
Height int64
}
ErrAppBlockHeightTooHigh struct {
CoreHeight int64
AppHeight int64
}
ErrAppBlockHeightTooLow struct {
AppHeight int64
StoreBase int64
}
ErrLastStateMismatch struct {
Height int64
Core []byte
App []byte
}
ErrStateMismatch struct {
Got *State
Expected *State
}
ErrNoValSetForHeight struct {
Height int64
Err error
}
ErrNoConsensusParamsForHeight struct {
Height int64
}
ErrNoFinalizeBlockResponsesForHeight struct {
Height int64
}
)
func (e ErrUnknownBlock) Error() string {
return fmt.Sprintf("could not find block #%d", e.Height)
}
func (e ErrBlockHashMismatch) Error() string {
return fmt.Sprintf(
"app block hash (%X) does not match core block hash (%X) for height %d",
e.AppHash,
e.CoreHash,
e.Height,
)
}
func (e ErrAppBlockHeightTooHigh) Error() string {
return fmt.Sprintf("app block height (%d) is higher than core (%d)", e.AppHeight, e.CoreHeight)
}
func (e ErrAppBlockHeightTooLow) Error() string {
return fmt.Sprintf("app block height (%d) is too far below block store base (%d)", e.AppHeight, e.StoreBase)
}
func (e ErrLastStateMismatch) Error() string {
return fmt.Sprintf(
"latest tendermint block (%d) LastAppHash (%X) does not match app's AppHash (%X)",
e.Height,
e.Core,
e.App,
)
}
func (e ErrStateMismatch) Error() string {
return fmt.Sprintf(
"state after replay does not match saved state. Got ----\n%v\nExpected ----\n%v\n",
e.Got,
e.Expected,
)
}
func (e ErrNoValSetForHeight) Error() string {
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)
}
func (e ErrNoFinalizeBlockResponsesForHeight) Error() string {
return fmt.Sprintf("could not find FinalizeBlock responses for height #%d", e.Height)
}