Skip to content

Commit

Permalink
Merge PR #4880: Fix IAVL Store Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Aug 11, 2019
1 parent 8f51fb3 commit a6e776c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .pending/bugfixes/store/_Fix-IAVL-Store-to-p
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[\#4880](https://github.com/cosmos/cosmos-sdk/pull/4880) Fix error check in
IAVL `Store#DeleteVersion`.
17 changes: 9 additions & 8 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a6e776c

Please sign in to comment.