diff --git a/.pending/bugfixes/store/_Fix-IAVL-Store-to-p b/.pending/bugfixes/store/_Fix-IAVL-Store-to-p new file mode 100644 index 000000000000..27c704e6f4d1 --- /dev/null +++ b/.pending/bugfixes/store/_Fix-IAVL-Store-to-p @@ -0,0 +1,2 @@ +[\#4880](https://github.com/cosmos/cosmos-sdk/pull/4880) Fix error check in +IAVL `Store#DeleteVersion`. diff --git a/store/iavl/store.go b/store/iavl/store.go index 3e495ee19c5b..01eed572990b 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -5,16 +5,17 @@ import ( "io" "sync" + "github.com/cosmos/cosmos-sdk/store/cachekv" + serrors "github.com/cosmos/cosmos-sdk/store/errors" + "github.com/cosmos/cosmos-sdk/store/tracekv" + "github.com/cosmos/cosmos-sdk/store/types" + + "github.com/pkg/errors" "github.com/tendermint/iavl" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/merkle" cmn "github.com/tendermint/tendermint/libs/common" dbm "github.com/tendermint/tm-db" - - "github.com/cosmos/cosmos-sdk/store/cachekv" - "github.com/cosmos/cosmos-sdk/store/errors" - "github.com/cosmos/cosmos-sdk/store/tracekv" - "github.com/cosmos/cosmos-sdk/store/types" ) const ( @@ -113,7 +114,7 @@ func (st *Store) Commit() types.CommitID { toRelease := previous - st.numRecent if st.storeEvery == 0 || toRelease%st.storeEvery != 0 { err := st.tree.DeleteVersion(toRelease) - if err != nil && err.(cmn.Error).Data() != iavl.ErrVersionDoesNotExist { + if errCause := errors.Cause(err); errCause != nil && errCause != iavl.ErrVersionDoesNotExist { panic(err) } } @@ -233,7 +234,7 @@ func getHeight(tree Tree, req abci.RequestQuery) int64 { func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { if len(req.Data) == 0 { msg := "Query cannot be zero length" - return errors.ErrTxDecode(msg).QueryResult() + return serrors.ErrTxDecode(msg).QueryResult() } tree := st.tree @@ -293,7 +294,7 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { default: msg := fmt.Sprintf("Unexpected Query path: %v", req.Path) - return errors.ErrUnknownRequest(msg).QueryResult() + return serrors.ErrUnknownRequest(msg).QueryResult() } return