Skip to content

Commit

Permalink
feat(store): remove RawDB dependency from snapshot store (#19608)
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski authored Mar 1, 2024
1 parent 3d59013 commit 55370b0
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 94 deletions.
2 changes: 1 addition & 1 deletion store/migration/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func setupMigrationManager(t *testing.T) (*Manager, *commitment.CommitStore) {
commitStore, err := commitment.NewCommitStore(multiTrees, db, nil, log.NewNopLogger())
require.NoError(t, err)

snapshotsStore, err := snapshots.NewStore(db, t.TempDir())
snapshotsStore, err := snapshots.NewStore(t.TempDir())
require.NoError(t, err)

snapshotsManager := snapshots.NewManager(snapshotsStore, snapshots.NewSnapshotOptions(1500, 2), commitStore, nil, nil, log.NewNopLogger())
Expand Down
4 changes: 2 additions & 2 deletions store/snapshots/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/store/v2"
dbm "cosmossdk.io/store/v2/db"
"cosmossdk.io/store/v2/snapshots"
snapshotstypes "cosmossdk.io/store/v2/snapshots/types"
)
Expand Down Expand Up @@ -189,7 +188,7 @@ func (m *mockErrorCommitSnapshotter) SupportedFormats() []uint32 {
// The snapshot will complete when the returned closer is called.
func setupBusyManager(t *testing.T) *snapshots.Manager {
t.Helper()
store, err := snapshots.NewStore(dbm.NewMemDB(), t.TempDir())
store, err := snapshots.NewStore(t.TempDir())
require.NoError(t, err)
hung := newHungCommitSnapshotter()
mgr := snapshots.NewManager(store, opts, hung, &mockStorageSnapshotter{}, nil, log.NewNopLogger())
Expand Down Expand Up @@ -292,6 +291,7 @@ func (s *extSnapshotter) RestoreExtension(height uint64, format uint32, payloadR

// GetTempDir returns a writable temporary director for the test to use.
func GetTempDir(tb testing.TB) string {
//return "/tmp/snapshots"
tb.Helper()
// os.MkDir() is used instead of testing.T.TempDir()
// see https://github.com/cosmos/cosmos-sdk/pull/8475 and
Expand Down
5 changes: 1 addition & 4 deletions store/snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,4 @@ func (m *Manager) snapshot(height int64) {
}

// Close the snapshot database.
func (m *Manager) Close() error {
m.logger.Info("snapshotManager Close Database")
return m.store.db.Close()
}
func (m *Manager) Close() error { return nil }
3 changes: 1 addition & 2 deletions store/snapshots/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/log"
dbm "cosmossdk.io/store/v2/db"
"cosmossdk.io/store/v2/snapshots"
"cosmossdk.io/store/v2/snapshots/types"
)
Expand Down Expand Up @@ -237,7 +236,7 @@ func TestManager_Restore(t *testing.T) {

func TestManager_TakeError(t *testing.T) {
snapshotter := &mockErrorCommitSnapshotter{}
store, err := snapshots.NewStore(dbm.NewMemDB(), GetTempDir(t))
store, err := snapshots.NewStore(GetTempDir(t))
require.NoError(t, err)
manager := snapshots.NewManager(store, opts, snapshotter, &mockStorageSnapshotter{}, nil, log.NewNopLogger())

Expand Down
Loading

0 comments on commit 55370b0

Please sign in to comment.