Skip to content

Commit

Permalink
fix: disable pre deliver when raw db store is used (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: zjubfd <[email protected]>
  • Loading branch information
forcodedancing and unclezoro authored Aug 24, 2023
1 parent 259b456 commit 47fbf33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,10 @@ func (app *BaseApp) PreBeginBlock(req abci.RequestPreBeginBlock) (res abci.Respo
app.cms.SetTracingContext(map[string]interface{}{"blockHeight": req.Header.Height})
}

// Initialize the preDeliverTx state.
app.setPreState(req.StateNumber, req.Header)
if app.IsIavlStore() {
// Initialize the preDeliverTx state.
app.setPreState(req.StateNumber, req.Header)
}

res = abci.ResponsePrefetch{Code: abci.CodeTypeOK}
return
Expand All @@ -559,6 +561,10 @@ func (app *BaseApp) PreDeliverTx(req abci.RequestPreDeliverTx) {
}
}()

if !app.IsIavlStore() {
return
}

preState := app.preDeliverStates[req.StateIndex]
if preState == nil {
return
Expand All @@ -580,7 +586,9 @@ func (app *BaseApp) PreCommit(req abci.RequestPreCommit) (res abci.ResponsePrefe
}
}()

app.preDeliverStates[req.StateIndex].ms.Write()
if app.IsIavlStore() {
app.preDeliverStates[req.StateIndex].ms.Write()
}

res = abci.ResponsePrefetch{Code: abci.CodeTypeOK}
return
Expand Down
4 changes: 2 additions & 2 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func (rs *Store) DeepCopyAndCache() types.CacheMultiStore {
} else if _, ok := v.(*transient.Store); ok {
stores[k] = transient.NewStore()
} else if dbStore, ok := v.(commitDBStoreAdapter); ok {
stores[k] = commitDBStoreAdapter{Store: dbadapter.Store{DB: dbStore.Store.DB}}
stores[k] = cache.NewCommitKVStoreCache(commitDBStoreAdapter{Store: dbadapter.Store{DB: dbStore.Store.DB}}, 1000).CommitKVStore
}
}
return cachemulti.NewStore(rs.db, stores, rs.keysByName, rs.traceWriter, rs.getTracingContext())
Expand All @@ -598,7 +598,7 @@ func (rs *Store) DeepCopy() *Store {
} else if _, ok := v.(*transient.Store); ok {
stores[k] = transient.NewStore()
} else if dbStore, ok := v.(commitDBStoreAdapter); ok {
stores[k] = commitDBStoreAdapter{Store: dbadapter.Store{DB: dbStore.Store.DB}}
stores[k] = cache.NewCommitKVStoreCache(commitDBStoreAdapter{Store: dbadapter.Store{DB: dbStore.Store.DB}}, 1000).CommitKVStore
}
}

Expand Down

0 comments on commit 47fbf33

Please sign in to comment.