Skip to content

Commit

Permalink
Fix to check state root at first loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonLewis committed Jul 14, 2024
1 parent b6bd6a9 commit 7b38759
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions consensus/istanbul/backend/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,12 @@ func preloadStakingInfo(headers []*types.Header, engine governance.HeaderEngine)
database.TrieDB().ReferenceRoot(root)
if !common.EmptyHash(parent) {
database.TrieDB().Dereference(parent)
if current.Root() != root {
err = fmt.Errorf("mistmatching state root block expected %x reexecuted %x", current.Root(), root)
// Logging here because something went wrong when the state roots disagree even if the execution was successful.
logger.Error("incorrectly regenerated historical state", "block", current.NumberU64(), "err", err)
return nil, fmt.Errorf("incorrectly regenerated historical state for block %d: %v", current.NumberU64(), err)
}
}
if current.Root() != root {
err = fmt.Errorf("mistmatching state root block expected %x reexecuted %x", current.Root(), root)
// Logging here because something went wrong when the state roots disagree even if the execution was successful.
logger.Error("incorrectly regenerated historical state", "block", current.NumberU64(), "err", err)
return nil, fmt.Errorf("incorrectly regenerated historical state for block %d: %v", current.NumberU64(), err)
}
parent = root
}
Expand Down
12 changes: 6 additions & 6 deletions node/cn/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func (cn *CN) stateAtBlock(block *types.Block, reexec uint64, base *state.StateD
database.TrieDB().ReferenceRoot(root)
if !common.EmptyHash(parent) {
database.TrieDB().Dereference(parent)
if current.Header().Root != root {
err = fmt.Errorf("mistmatching state root block expected %x reexecuted %x", current.Header().Root, root)
// Logging here because something went wrong when the state roots disagree even if the execution was successful.
logger.Error("incorrectly regenerated historical state", "block", current.NumberU64(), "err", err)
return nil, fmt.Errorf("incorrectly regenerated historical state for block %d: %v", current.NumberU64(), err)
}
}
if current.Header().Root != root {
err = fmt.Errorf("mistmatching state root block expected %x reexecuted %x", current.Header().Root, root)
// Logging here because something went wrong when the state roots disagree even if the execution was successful.
logger.Error("incorrectly regenerated historical state", "block", current.NumberU64(), "err", err)
return nil, fmt.Errorf("incorrectly regenerated historical state for block %d: %v", current.NumberU64(), err)
}
parent = root
}
Expand Down

0 comments on commit 7b38759

Please sign in to comment.