Skip to content

Commit

Permalink
Problem: dependencies in store is not consistent (cosmos#235)
Browse files Browse the repository at this point in the history
* Revert "build(deps): Bump github.com/cosmos/iavl from 1.0.1 to 1.1.1 in store (cosmos#19770)"

This reverts commit ff30f6e.

* Problem: store package has dependency issues

Solution:
- revert the iavl bump, v1.0.2 is the version referenced by outer packages
  • Loading branch information
yihuang authored and mmsqe committed Dec 12, 2024
1 parent 31ccfee commit 33e9f84
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 67 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ require (

// Below are the long-lived replace of the Cosmos SDK
replace (
cosmossdk.io/store => ./store
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
cosmossdk.io/x/tx v0.13.6-0.20241003112805-ff8789a02871 h1:+lRwWQRVvB3jgRgdqrgeFUJ45BoXZh/UeeAV5f/m2Gk=
cosmossdk.io/x/tx v0.13.6-0.20241003112805-ff8789a02871/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
Expand Down
1 change: 1 addition & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ require (

// Below are the long-lived replace of the SimApp
replace (
cosmossdk.io/store => ../store
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// Simapp always use the latest version of the cosmos-sdk
Expand Down
2 changes: 0 additions & 2 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8=
cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ=
cosmossdk.io/x/circuit v0.1.1 h1:KPJCnLChWrxD4jLwUiuQaf5mFD/1m7Omyo7oooefBVQ=
Expand Down
4 changes: 0 additions & 4 deletions store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

## v1.1.0 (March 20, 2024)

### Improvements

* [#19770](https://github.com/cosmos/cosmos-sdk/pull/19770) Upgrade IAVL to IAVL v1.1.1.

## v1.0.2 (January 10, 2024)

### Bug Fixes
Expand Down
11 changes: 5 additions & 6 deletions store/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import (
"cosmossdk.io/store/cachekv"
iavlstore "cosmossdk.io/store/iavl"
"cosmossdk.io/store/types"
"cosmossdk.io/store/wrapper"
)

func TestGetOrSetStoreCache(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize)

sKey := types.NewKVStoreKey("test")
Expand All @@ -30,7 +29,7 @@ func TestGetOrSetStoreCache(t *testing.T) {
}

func TestUnwrap(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize)

sKey := types.NewKVStoreKey("test")
Expand All @@ -43,7 +42,7 @@ func TestUnwrap(t *testing.T) {
}

func TestStoreCache(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize)

sKey := types.NewKVStoreKey("test")
Expand All @@ -69,7 +68,7 @@ func TestStoreCache(t *testing.T) {
}

func TestReset(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize)

sKey := types.NewKVStoreKey("test")
Expand All @@ -89,7 +88,7 @@ func TestReset(t *testing.T) {
}

func TestCacheWrap(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
mngr := cache.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize)

sKey := types.NewKVStoreKey("test")
Expand Down
3 changes: 1 addition & 2 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cosmossdk.io/store/metrics"
pruningtypes "cosmossdk.io/store/pruning/types"
"cosmossdk.io/store/types"
"cosmossdk.io/store/wrapper"
)

const (
Expand Down Expand Up @@ -50,7 +49,7 @@ func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.Commit
// provided DB. An error is returned if the version fails to load, or if called with a positive
// version on an empty tree.
func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, initialVersion uint64, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error) {
tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, disableFastNode, logger, iavl.InitialVersionOption(initialVersion))
tree := iavl.NewMutableTree(db, cacheSize, disableFastNode, logger, iavl.InitialVersionOption(initialVersion))

isUpgradeable, err := tree.IsUpgradeable()
if err != nil {
Expand Down
21 changes: 10 additions & 11 deletions store/iavl/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"cosmossdk.io/store/internal/kv"
"cosmossdk.io/store/metrics"
"cosmossdk.io/store/types"
"cosmossdk.io/store/wrapper"
)

var (
Expand All @@ -38,7 +37,7 @@ func randBytes(numBytes int) []byte {
// make a tree with data from above and save it
func newAlohaTree(t *testing.T, db dbm.DB) (*iavl.MutableTree, types.CommitID) {
t.Helper()
tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, false, log.NewNopLogger())
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

for k, v := range treeData {
_, err := tree.Set([]byte(k), []byte(v))
Expand Down Expand Up @@ -286,7 +285,7 @@ func TestIAVLIterator(t *testing.T) {
}

func TestIAVLReverseIterator(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()

tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

Expand Down Expand Up @@ -320,7 +319,7 @@ func TestIAVLReverseIterator(t *testing.T) {
}

func TestIAVLPrefixIterator(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)
Expand Down Expand Up @@ -383,7 +382,7 @@ func TestIAVLPrefixIterator(t *testing.T) {
}

func TestIAVLReversePrefixIterator(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)
Expand Down Expand Up @@ -450,7 +449,7 @@ func nextVersion(iavl *Store) {
}

func TestIAVLNoPrune(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)
Expand All @@ -468,7 +467,7 @@ func TestIAVLNoPrune(t *testing.T) {
}

func TestIAVLStoreQuery(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

iavlStore := UnsafeNewStore(tree)
Expand Down Expand Up @@ -580,7 +579,7 @@ func TestIAVLStoreQuery(t *testing.T) {

func BenchmarkIAVLIteratorNext(b *testing.B) {
b.ReportAllocs()
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
treeSize := 1000
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())

Expand Down Expand Up @@ -616,7 +615,7 @@ func TestSetInitialVersion(t *testing.T) {
{
"works with a mutable tree",
func(db *dbm.MemDB) *Store {
tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, false, log.NewNopLogger())
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())
store := UnsafeNewStore(tree)

return store
Expand All @@ -625,7 +624,7 @@ func TestSetInitialVersion(t *testing.T) {
{
"throws error on immutable tree",
func(db *dbm.MemDB) *Store {
tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, false, log.NewNopLogger())
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())
store := UnsafeNewStore(tree)
_, version, err := store.tree.SaveVersion()
require.NoError(t, err)
Expand Down Expand Up @@ -670,7 +669,7 @@ func TestChangeSets(t *testing.T) {
treeSize := 1000
treeVersion := int64(10)
targetVersion := int64(6)
tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, false, log.NewNopLogger(), iavl.FlushThresholdOption(math.MaxInt))
tree := iavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger(), iavl.FlushThresholdOption(math.MaxInt))

for j := int64(0); j < treeVersion; j++ {
keys := [][]byte{}
Expand Down
5 changes: 3 additions & 2 deletions store/iavl/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"fmt"

"github.com/cosmos/iavl"
idb "github.com/cosmos/iavl/db"

"cosmossdk.io/store/types"
)

var (
Expand All @@ -31,7 +32,7 @@ type (
GetVersioned(key []byte, version int64) ([]byte, error)
GetImmutable(version int64) (*iavl.ImmutableTree, error)
SetInitialVersion(version uint64)
Iterator(start, end []byte, ascending bool) (idb.Iterator, error)
Iterator(start, end []byte, ascending bool) (types.Iterator, error)
AvailableVersions() []int
LoadVersionForOverwriting(targetVersion int64) error
TraverseStateChanges(startVersion, endVersion int64, fn func(version int64, changeSet *iavl.ChangeSet) error) error
Expand Down
3 changes: 1 addition & 2 deletions store/iavl/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/log"
"cosmossdk.io/store/wrapper"
)

func TestImmutableTreePanics(t *testing.T) {
t.Parallel()
immTree := iavl.NewImmutableTree(wrapper.NewDBWrapper(dbm.NewMemDB()), 100, false, log.NewNopLogger())
immTree := iavl.NewImmutableTree(dbm.NewMemDB(), 100, false, log.NewNopLogger())
it := &immutableTree{immTree}
require.Panics(t, func() {
_, err := it.Set([]byte{}, []byte{})
Expand Down
3 changes: 1 addition & 2 deletions store/prefix/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"cosmossdk.io/store/gaskv"
"cosmossdk.io/store/iavl"
"cosmossdk.io/store/types"
"cosmossdk.io/store/wrapper"
)

// copied from iavl/store_test.go
Expand Down Expand Up @@ -91,7 +90,7 @@ func testPrefixStore(t *testing.T, baseStore types.KVStore, prefix []byte) {
}

func TestIAVLStorePrefix(t *testing.T) {
db := wrapper.NewDBWrapper(dbm.NewMemDB())
db := dbm.NewMemDB()
tree := tiavl.NewMutableTree(db, cacheSize, false, log.NewNopLogger())
iavlStore := iavl.UnsafeNewStore(tree)

Expand Down
34 changes: 0 additions & 34 deletions store/wrapper/wrapper.go

This file was deleted.

0 comments on commit 33e9f84

Please sign in to comment.