Skip to content

Commit

Permalink
added LastResultsHash loading in alignStoreWithApp
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Jun 26, 2023
1 parent 99557c3 commit 3ba9353
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,7 @@ func (m *Manager) alignStoreWithApp(ctx context.Context, block *types.Block) (bo
// Validate incosistency in height wasn't caused by a crash and if so handle it.
proxyAppInfo, err := m.executor.GetAppInfo()
if err != nil {
m.logger.Error("Failed to get app info", "error", err)
return isRequired, err
return isRequired, errors.Wrap(err, "failed to get app info")
}
if uint64(proxyAppInfo.LastBlockHeight) == block.Header.Height {
isRequired = true
Expand All @@ -575,10 +574,16 @@ func (m *Manager) alignStoreWithApp(ctx context.Context, block *types.Block) (bo
m.lastState.AppHash = *(*[32]byte)(proxyAppInfo.LastBlockAppHash)
m.lastState.LastStoreHeight = block.Header.Height
m.lastState.LastValidators = m.lastState.Validators.Copy()
_, err := m.store.UpdateState(m.lastState, nil)

resp, err := m.store.LoadBlockResponses(block.Header.Height)
if err != nil {
return isRequired, errors.Wrap(err, "failed to load block responses")
}
copy(m.lastState.LastResultsHash[:], tmtypes.NewResults(resp.DeliverTxs).Hash())

_, err = m.store.UpdateState(m.lastState, nil)
if err != nil {
m.logger.Error("Failed to update state", "error", err)
return isRequired, err
return isRequired, errors.Wrap(err, "failed to update state")
}
m.store.SetHeight(block.Header.Height)
return isRequired, nil
Expand Down

0 comments on commit 3ba9353

Please sign in to comment.