Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add check for uneven stores' height #14410

Merged
merged 38 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
49e770c
add store height check in loadVersion(); add test for that
catShaark Dec 23, 2022
a16b35f
minor
catShaark Dec 23, 2022
248a816
Merge branch 'main' into uneven-height
faddat Dec 24, 2022
cfea0f8
Merge branch 'main' into uneven-height
catShaark Dec 25, 2022
c2a1777
Merge branch 'main' into uneven-height
faddat Dec 25, 2022
da1456c
Merge branch 'main' into uneven-height
catShaark Dec 26, 2022
5c2095e
Merge branch 'main' into uneven-height
tac0turtle Dec 27, 2022
6c9ec1e
Merge branch 'main' into uneven-height
faddat Dec 28, 2022
62942cf
Merge branch 'main' into uneven-height
catShaark Dec 28, 2022
8cba224
update
catShaark Dec 30, 2022
57033e9
NewStoreParams
catShaark Dec 30, 2022
59d2d35
use NewStoreParams
catShaark Dec 30, 2022
343e7b5
Merge branch 'main' into uneven-height
tac0turtle Jan 2, 2023
ebc8f08
Merge branch 'main' into uneven-height
catShaark Jan 10, 2023
a821cbd
Update store/rootmulti/store.go
catShaark Jan 11, 2023
7f23d14
Update store/rootmulti/store.go
catShaark Jan 11, 2023
d0fa186
Merge branch 'main' into uneven-height
tac0turtle Jan 16, 2023
cf71697
update loadVersion
catShaark Jan 18, 2023
0352c08
fix tests in store_test.go
catShaark Jan 18, 2023
2929387
Merge branch 'main' into uneven-height
catShaark Jan 18, 2023
a55ba07
changes to commitStores()
catShaark Jan 18, 2023
8308d59
Merge branch 'uneven-height' of https://github.com/notional-labs/cosm…
catShaark Jan 18, 2023
c65287d
Merge branch 'main' into uneven-height
catShaark Jan 21, 2023
54fddbe
revert commitStores changes
catShaark Jan 21, 2023
c11e0da
update TestSetLoader
catShaark Jan 21, 2023
db95ddd
add nolint for NewStoreParams
catShaark Jan 21, 2023
4d12c11
Merge branch 'main' into uneven-height
catShaark Jan 25, 2023
f40a22f
add go doc to TestUnevenStoresHeightCheck
catShaark Jan 25, 2023
7fe88ab
Merge branch 'main' into uneven-height
tac0turtle Jan 25, 2023
ea288e3
Merge branch 'main' into uneven-height
catShaark Jan 25, 2023
527583d
NewStoreParams -> newStoreParams
catShaark Jan 27, 2023
a322fd2
Merge branch 'main' into uneven-height
catShaark Jan 27, 2023
0f9e7a8
update CL
catShaark Jan 27, 2023
712d795
Update store/rootmulti/store.go
catShaark Jan 27, 2023
56fdd42
Merge branch 'main' into uneven-height
catShaark Jan 28, 2023
d948f31
Merge branch 'main' into uneven-height
catShaark Jan 28, 2023
3eaf5c5
Merge branch 'main' into uneven-height
catShaark Jan 30, 2023
22c0d95
Merge branch 'main' into uneven-height
catShaark Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {
// If it has been added, set the initial version
if upgrades.IsAdded(key.Name()) {
storeParams.initialVersion = uint64(ver) + 1
} else if commitID.Version != ver {
Fixed Show fixed Hide fixed
return fmt.Errorf("version of store %s mismatch root store's version", key.Name())
catShaark marked this conversation as resolved.
Show resolved Hide resolved
}

store, err := rs.loadCommitStoreFromParams(key, commitID, storeParams)
Expand Down
24 changes: 24 additions & 0 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,30 @@ func TestMultiStore_PruningRestart(t *testing.T) {
}
}

func TestUnevenStoresHeightCheck(t *testing.T) {
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
var db dbm.DB = dbm.NewMemDB()
store := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
err := store.LoadLatestVersion()
require.Nil(t, err)

// commit to increment store's height
store.Commit()

// mount store4 to root store
store.MountStoreWithDB(types.NewKVStoreKey("store4"), types.StoreTypeIAVL, nil)

// load the stores without upgrades
err = store.LoadLatestVersion()
require.Error(t, err)
catShaark marked this conversation as resolved.
Show resolved Hide resolved

// now, let's load with upgrades...
upgrades := &types.StoreUpgrades{
Added: []string{"store4"},
}
err = store.LoadLatestVersionAndUpgrade(upgrades)
require.Nil(t, err)
}

func TestSetInitialVersion(t *testing.T) {
db := dbm.NewMemDB()
multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
Expand Down