Skip to content

Commit

Permalink
Merge branch 'issues/352/state_sync' into issues/829/state_sync_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Jul 24, 2023
2 parents 608826a + 6856feb commit d76cd0e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
4 changes: 1 addition & 3 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ Optionally activate changelog pre-commit hook
cp .githooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
```

_Please note that the Github workflow will still prevent this from merging
unless the CHANGELOG is updated._
_**NOTE**: The pre-commit changelog verification has been disabled during the developement of V1 as of 2023-05-16 to unblock development velocity; see more details [here](https://github.com/pokt-network/pocket/assets/1892194/394fdb09-e388-44aa-820d-e9d5a23578cf). This check is no longer done in the CI and is not recommended for local development either currently._

### Pocket Network CLI

Expand Down
2 changes: 1 addition & 1 deletion ibc/ibc_handle_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestHandleEvent_FlushCaches(t *testing.T) {
require.NoError(t, cache.Stop())

// flush the cache
err = ibcHost.GetBus().GetBulkStoreCacher().FlushAllEntries()
err = ibcHost.GetBus().GetBulkStoreCacher().FlushCachesToStore()
require.NoError(t, err)

cache, err = kvstore.NewKVStore(tmpDir)
Expand Down
2 changes: 1 addition & 1 deletion ibc/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (m *ibcModule) HandleEvent(event *anypb.Any) error {
}
// Flush all caches to disk for last height
bsc := m.GetBus().GetBulkStoreCacher()
if err := bsc.FlushAllEntries(); err != nil {
if err := bsc.FlushCachesToStore(); err != nil {
return err
}
// Prune old cache entries
Expand Down
6 changes: 3 additions & 3 deletions ibc/store/bulk_store_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (s *bulkStoreCache) GetAllStores() map[string]modules.ProvableStore {
return s.ls.stores
}

// FlushAllEntries caches all the entries for all stores in the bulkStoreCache
func (s *bulkStoreCache) FlushAllEntries() error {
// FlushdCachesToStore caches all the entries for all stores in the bulkStoreCache
func (s *bulkStoreCache) FlushCachesToStore() error {
s.ls.m.Lock()
defer s.ls.m.Unlock()
s.logger.Info().Msg("🚽 Flushing All Cache Entries to Disk 🚽")
Expand All @@ -134,7 +134,7 @@ func (s *bulkStoreCache) FlushAllEntries() error {
return err
}
for _, store := range s.ls.stores {
if err := store.FlushEntries(disk); err != nil {
if err := store.FlushCache(disk); err != nil {
s.logger.Error().Err(err).Str("store", string(store.GetCommitmentPrefix())).Msg("🚨 Error Flushing Cache 🚨")
return err
}
Expand Down
4 changes: 2 additions & 2 deletions ibc/store/provable_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (p *provableStore) Root() ics23.CommitmentRoot {
return root
}

// FlushEntries writes all local changes to disk and clears the in-memory cache
func (p *provableStore) FlushEntries(store kvstore.KVStore) error {
// FlushCache writes all local changes to disk and clears the in-memory cache
func (p *provableStore) FlushCache(store kvstore.KVStore) error {
p.m.Lock()
defer p.m.Unlock()
for _, entry := range p.cache {
Expand Down
12 changes: 6 additions & 6 deletions ibc/store/provable_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestProvableStore_GetAndProve(t *testing.T) {
}
}

func TestProvableStore_FlushEntries(t *testing.T) {
func TestProvableStore_FlushCache(t *testing.T) {
provableStore := newTestProvableStore(t)
kvs := []struct {
key []byte
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestProvableStore_FlushEntries(t *testing.T) {
}
}
cache := kvstore.NewMemKVStore()
require.NoError(t, provableStore.FlushEntries(cache))
require.NoError(t, provableStore.FlushCache(cache))
keys, values, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, keys, 3)
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestProvableStore_PruneCache(t *testing.T) {
}
}
cache := kvstore.NewMemKVStore()
require.NoError(t, provableStore.FlushEntries(cache))
require.NoError(t, provableStore.FlushCache(cache))
keys, _, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, keys, 3) // 3 entries in cache should be flushed to disk
Expand Down Expand Up @@ -264,12 +264,12 @@ func TestProvableStore_RestoreCache(t *testing.T) {
}

cache := kvstore.NewMemKVStore()
require.NoError(t, provableStore.FlushEntries(cache))
require.NoError(t, provableStore.FlushCache(cache))
keys, values, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, keys, 3)
require.NoError(t, cache.ClearAll())
require.NoError(t, provableStore.FlushEntries(cache))
require.NoError(t, provableStore.FlushCache(cache))
newKeys, _, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, newKeys, 0)
Expand All @@ -284,7 +284,7 @@ func TestProvableStore_RestoreCache(t *testing.T) {
newKeys, _, err = cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, newKeys, 0)
require.NoError(t, provableStore.FlushEntries(cache))
require.NoError(t, provableStore.FlushCache(cache))
newKeys, newValues, err := cache.GetAll([]byte{}, false)
require.NoError(t, err)
require.Len(t, newKeys, 3)
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/ibc/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func baseBulkStoreCacherMock(t gocuke.TestingT, bus modules.Bus) *mockModules.Mo
storeMock.EXPECT().AddStore(gomock.Any()).Return(nil).AnyTimes()
storeMock.EXPECT().GetStore(gomock.Any()).Return(provableStoreMock, nil).AnyTimes()
storeMock.EXPECT().RemoveStore(gomock.Any()).Return(nil).AnyTimes()
storeMock.EXPECT().FlushAllEntries().Return(nil).AnyTimes()
storeMock.EXPECT().FlushCachesToStore().Return(nil).AnyTimes()
storeMock.EXPECT().PruneCaches(gomock.Any()).Return(nil).AnyTimes()
storeMock.EXPECT().RestoreCaches(gomock.Any()).Return(nil).AnyTimes()

Expand Down
4 changes: 2 additions & 2 deletions shared/modules/ibc_store_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type BulkStoreCacher interface {
GetStore(name string) (ProvableStore, error)
RemoveStore(name string) error
GetAllStores() map[string]ProvableStore
FlushAllEntries() error
FlushCachesToStore() error
PruneCaches(height uint64) error
RestoreCaches(height uint64) error
}
Expand All @@ -44,7 +44,7 @@ type ProvableStore interface {
Delete(key []byte) error
GetCommitmentPrefix() coreTypes.CommitmentPrefix
Root() ics23.CommitmentRoot
FlushEntries(kvstore.KVStore) error
FlushCache(kvstore.KVStore) error
PruneCache(store kvstore.KVStore, height uint64) error
RestoreCache(store kvstore.KVStore, height uint64) error
}

0 comments on commit d76cd0e

Please sign in to comment.