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

feat!: ADR-040: Refactor App to use v2.MultiStore #10174

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
a549522
[WIP] refactor multistore => root store
roysc Aug 31, 2021
ec5d41e
baseapp - disable snapshot tests
roysc Oct 27, 2021
9db21a5
store updates, fixes
roysc Jan 20, 2022
ceabd08
updates, rf
roysc Jan 18, 2022
ab531ff
changelog + docs
roysc Jan 20, 2022
47330c5
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Jan 20, 2022
929f5ad
fixes
roysc Jan 20, 2022
3876113
Merge branch 'master' into roysc/adr-040-refactor-multistore
roysc Jan 20, 2022
25d0a9f
changelog fix
roysc Jan 21, 2022
355f181
cleanup
roysc Jan 21, 2022
8cbf4b2
nit, StoreConfig =>StoreParams
roysc Jan 21, 2022
4e431eb
store doc
roysc Jan 21, 2022
861b24c
store rearrange
roysc Jan 21, 2022
f45ce0f
godoc nits
roysc Jan 27, 2022
79bea1d
rm StoreConstructor
roysc Jan 28, 2022
e912111
compatibility wrapper for original MultiStore interface
roysc Jan 27, 2022
704570b
rename BasicMultiStore -> MultiStore
roysc Feb 7, 2022
b36c8f5
patch multistore
roysc Feb 7, 2022
d035fb8
patch compat store
roysc Feb 7, 2022
bfa7b88
multi store- use StoreKey instances, not strings
roysc Feb 14, 2022
ccb908d
wrap v1 MultiStore in v2 interface; use in baseapp
roysc Feb 7, 2022
532a6ad
viewstore.CacheStore() replaces CacheMultiStoreWithVersion
roysc Feb 15, 2022
5f6fe12
test cleanup
roysc Feb 15, 2022
b200867
trace context fence
roysc Feb 15, 2022
9cdd990
get all versions
roysc Feb 15, 2022
2c59d34
Merge branch 'master' of github.com:cosmos/cosmos-sdk into refactor-m…
roysc Feb 15, 2022
2627ce3
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Feb 15, 2022
555be73
patches
roysc Feb 18, 2022
b631a9a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into refactor-m…
roysc Feb 18, 2022
83cd109
patches
roysc Feb 18, 2022
71a9bb9
fix v1asv2 commit
roysc Feb 18, 2022
78b0a12
PR revisions
roysc Feb 23, 2022
ddf8d0f
fix simd export
roysc Feb 23, 2022
3ddf675
open db at data/application/
roysc Feb 23, 2022
def4107
db cleanup
roysc Feb 23, 2022
880a4ee
badgerdb fix
roysc Feb 23, 2022
8f58686
Merge branch 'master' of github.com:cosmos/cosmos-sdk into refactor-m…
roysc Feb 25, 2022
fcb9ff9
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Feb 25, 2022
332c3e9
change rocksdb build tag to "rocksdb"
roysc Mar 2, 2022
d7a51f5
badgerdb - handle ErrTxnTooBig
roysc Mar 2, 2022
5102f92
remove multistore reverse index
roysc Mar 2, 2022
81642a5
rename tmdb adapter
roysc Mar 4, 2022
b33b162
GetAllVersions patch
roysc Mar 4, 2022
df2e47b
db/adapter - return discard error
roysc Mar 5, 2022
1dd7de8
multistore - minor additions
roysc Mar 10, 2022
4c34467
spelling
roysc Mar 16, 2022
44fafb2
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Mar 16, 2022
86929d3
badgerdb: fix versions file write
roysc Mar 25, 2022
4cdd5ee
version manager - DeleteAbove() & implement w/ slice
roysc Mar 24, 2022
e36e3ad
DBConnection.RevertTo
roysc Mar 24, 2022
f0d31ba
unit test badgerdb.versionmanager
roysc Mar 25, 2022
ae5c007
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Mar 25, 2022
620728f
refactor multistore: fix state sync
roysc Mar 25, 2022
9e2152e
refactor multistore: fix store migration
roysc Mar 27, 2022
68da759
fix rename store/{v2 => v2alpha1}
roysc Mar 27, 2022
bae2e7a
dbmapstore.Delete should raise smt.InvalidKeyError
roysc Mar 30, 2022
138bd43
Merge remote-tracking branch 'upstream/master' into refactor-multistore
roysc Apr 7, 2022
1295d81
dispatching db constructor
roysc Apr 7, 2022
fcf64ed
refactor server rollback cmd
roysc Apr 7, 2022
4dd37ca
go mod tidy
roysc Apr 7, 2022
7eb1f9e
fix app-db-backend config
roysc Apr 8, 2022
0499da2
comment typo
roysc Apr 12, 2022
924d2ec
reorg multistore tests
roysc Apr 12, 2022
7f747ab
check multistore key types
roysc Apr 12, 2022
7de3adf
fix v1asv2 methods
roysc Apr 12, 2022
47ab63f
tests and fixes for v1asv2 adapter
roysc Apr 12, 2022
1568198
force mem & transient stores to use bespoke key type
roysc Apr 12, 2022
bb15cd3
godoc copyedit
roysc Apr 19, 2022
e103a63
smt store test nits
roysc Apr 19, 2022
1a37cc2
[dev] update SMT library
roysc Apr 18, 2022
7b1e2f3
Merge remote-tracking branch 'upstream/main' into refactor-multistore
roysc May 30, 2022
db91469
Patch merge
roysc Jun 2, 2022
5c1b566
Patch simapp upgrade handler
roysc Jun 2, 2022
5f83976
Revert "[dev] update SMT library"
roysc May 31, 2022
2ad0ee0
Merge remote-tracking branch 'upstream/main' into refactor-multistore
roysc Jun 14, 2022
0b9aadc
put pruning manager into v2/multi store
roysc Jun 23, 2022
538bacb
fixup renames
roysc Jul 16, 2022
d7ff909
fix db creators - refactor packages/build directives
roysc Jul 4, 2022
04c832f
clean up v2 store re-exports
roysc Jun 27, 2022
1232d5a
v2 store additions
roysc Jun 28, 2022
f007704
add multi.Store.HasKVStore()
roysc Jun 24, 2022
bc67cfe
bank keeper: validate account store address
roysc Jun 29, 2022
e409ca3
fix typos, docs, rm redundant
roysc Jun 29, 2022
4823d1a
feat: list snapshots query (#246) (#252)
roysc Jul 20, 2022
69fd2f7
Restore baseapp pruning & snapshot tests
roysc Jun 22, 2022
d3f6289
pruning manager - decouple db, rm logger, fix test
roysc Jun 23, 2022
0f24e1e
Merge remote-tracking branch 'upstream/main' into refactor-multistore
roysc Jul 20, 2022
23d1a92
Merge branch 'main' into refactor-multistore
roysc Jul 21, 2022
db3c28a
fix merge
roysc Jul 20, 2022
eaa83be
go.mod/sum
roysc Jul 20, 2022
c1e800c
PR clean up
roysc Jul 21, 2022
1a9e194
v2 store: allow shared substore name prefixes
roysc Jul 21, 2022
24dd6c0
Merge remote-tracking branch 'upstream/main' into refactor-multistore
roysc Jul 22, 2022
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
Prev Previous commit
Next Next commit
Restore baseapp pruning & snapshot tests
  • Loading branch information
roysc committed Jul 20, 2022
commit 69fd2f7881c7abe9fcac02aba480c81cf416121e
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) abci.Res

responseValue, err := json.Marshal(response)
if err != nil {
sdkerrors.QueryResult(sdkerrors.Wrap(err, fmt.Sprintf("failed to marshal list snapshots response %v", response)))
sdkerrors.QueryResult(sdkerrors.Wrap(err, fmt.Sprintf("failed to marshal list snapshots response %v", response)), false)
}

return abci.ResponseQuery{
Expand Down
163 changes: 161 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1609,8 +1609,8 @@ func TestListSnapshots(t *testing.T) {
require.NoError(t, err)

expected := abci.ResponseListSnapshots{Snapshots: []*abci.Snapshot{
{Height: 4, Format: 1, Chunks: 2},
{Height: 2, Format: 1, Chunks: 1},
{Height: 4, Format: snapshottypes.CurrentFormat, Chunks: 2},
{Height: 2, Format: snapshottypes.CurrentFormat, Chunks: 1},
}}

resp := app.ListSnapshots(abci.RequestListSnapshots{})
Expand Down Expand Up @@ -2034,3 +2034,162 @@ func TestBaseApp_EndBlock(t *testing.T) {
require.Equal(t, int64(100), res.GetValidatorUpdates()[0].Power)
require.Equal(t, cp.Block.MaxGas, res.ConsensusParamUpdates.Block.MaxGas)
}

func TestBaseApp_Init(t *testing.T) {
db := memdb.NewDB()
name := t.Name()
logger := defaultLogger()

snapshotStore, err := snapshots.NewStore(memdb.NewDB(), testutil.GetTempDir(t))
require.NoError(t, err)

testCases := map[string]struct {
bapp *BaseApp
expectedPruning pruningtypes.PruningOptions
expectedSnapshot snapshottypes.SnapshotOptions
expectedErr error
}{
"snapshot but no pruning": {
NewBaseApp(name, logger, db, nil,
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningNothing),
snapshottypes.NewSnapshotOptions(1500, 2),
// if no pruning is set, the default is PruneNothing
nil,
},
"pruning everything only": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningEverything)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningEverything),
snapshottypes.NewSnapshotOptions(snapshottypes.SnapshotIntervalOff, 0),
nil,
},
"pruning nothing only": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningNothing),
snapshottypes.NewSnapshotOptions(snapshottypes.SnapshotIntervalOff, 0),
nil,
},
"pruning default only": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningDefault),
snapshottypes.NewSnapshotOptions(snapshottypes.SnapshotIntervalOff, 0),
nil,
},
"pruning custom only": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 10)),
),
pruningtypes.NewCustomPruningOptions(10, 10),
snapshottypes.NewSnapshotOptions(snapshottypes.SnapshotIntervalOff, 0),
nil,
},
"pruning everything and snapshots": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningEverything)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningEverything),
snapshottypes.NewSnapshotOptions(1500, 2),
nil,
},
"pruning nothing and snapshots": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningNothing),
snapshottypes.NewSnapshotOptions(1500, 2),
nil,
},
"pruning default and snapshots": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewPruningOptions(pruningtypes.PruningDefault),
snapshottypes.NewSnapshotOptions(1500, 2),
nil,
},
"pruning custom and snapshots": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 10)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewCustomPruningOptions(10, 10),
snapshottypes.NewSnapshotOptions(1500, 2),
nil,
},
"error custom pruning 0 interval": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 0)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewCustomPruningOptions(10, 0),
snapshottypes.NewSnapshotOptions(1500, 2),
pruningtypes.ErrPruningIntervalZero,
},
"error custom pruning too small interval": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 9)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewCustomPruningOptions(10, 9),
snapshottypes.NewSnapshotOptions(1500, 2),
pruningtypes.ErrPruningIntervalTooSmall,
},
"error custom pruning too small keep recent": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(9, 10)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 2)),
),
pruningtypes.NewCustomPruningOptions(9, 10),
snapshottypes.NewSnapshotOptions(1500, 2),
pruningtypes.ErrPruningKeepRecentTooSmall,
},
"snapshot zero interval - manager not set": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 10)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(0, 2)),
),
pruningtypes.NewCustomPruningOptions(10, 10),
snapshottypes.NewSnapshotOptions(snapshottypes.SnapshotIntervalOff, 0),
nil,
},
"snapshot zero keep recent - allowed": {
NewBaseApp(name, logger, db, nil,
SetPruning(pruningtypes.NewCustomPruningOptions(10, 10)),
SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(1500, 0)),
),
pruningtypes.NewCustomPruningOptions(10, 10),
snapshottypes.NewSnapshotOptions(1500, 0), // 0 snapshot-keep-recent means keep all
nil,
},
}

for _, tc := range testCases {
// Init and validate
require.Equal(t, tc.expectedErr, tc.bapp.Init())
if tc.expectedErr != nil {
continue
}

// Check that settings were set correctly
actualPruning := tc.bapp.store.GetPruning()
require.Equal(t, tc.expectedPruning, actualPruning)

if tc.expectedSnapshot.Interval == snapshottypes.SnapshotIntervalOff {
require.Nil(t, tc.bapp.snapshotManager)
continue
}

require.Equal(t, tc.expectedSnapshot.Interval, tc.bapp.snapshotManager.GetInterval())
require.Equal(t, tc.expectedSnapshot.KeepRecent, tc.bapp.snapshotManager.GetKeepRecent())
}
}