mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 05:41:35 +00:00
When a database failure occurs, bubble it up a into statedb, and report it in suitable places, such as during a 'bad block' report. Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
parent
cb888541c5
commit
1d9fd6bdd2
3 changed files with 6 additions and 7 deletions
|
|
@ -103,7 +103,7 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
|
|||
// Validate the state root against the received state root and throw
|
||||
// an error if they don't match.
|
||||
if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root {
|
||||
return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root)
|
||||
return fmt.Errorf("invalid merkle root (remote: %x local: %x) dberr: %w", header.Root, root, statedb.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ type StateDB struct {
|
|||
// DB error.
|
||||
// State objects are used by the consensus core and VM which are
|
||||
// unable to deal with database-level errors. Any error that occurs
|
||||
// during a database read is memoized here and will eventually be returned
|
||||
// by StateDB.Commit.
|
||||
// during a database read is memoized here and will eventually be
|
||||
// returned by StateDB.Commit. Notably, this error is also shared
|
||||
// by all cached state objects in case the database failure occurs
|
||||
// when accessing state of accounts.
|
||||
dbErr error
|
||||
|
||||
// The refund counter, also used by state transitioning.
|
||||
|
|
@ -134,6 +136,7 @@ func (s *StateDB) setError(err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Error returns the memorized database failure occurred earlier.
|
||||
func (s *StateDB) Error() error {
|
||||
return s.dbErr
|
||||
}
|
||||
|
|
@ -459,13 +462,11 @@ func (s *StateDB) SetTransientState(addr common.Address, key, value common.Hash)
|
|||
if prev == value {
|
||||
return
|
||||
}
|
||||
|
||||
s.journal.append(transientStorageChange{
|
||||
account: &addr,
|
||||
key: key,
|
||||
prevalue: prev,
|
||||
})
|
||||
|
||||
s.setTransientState(addr, key, value)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,6 @@ type StateDB interface {
|
|||
|
||||
AddLog(*types.Log)
|
||||
AddPreimage(common.Hash, []byte)
|
||||
|
||||
ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) error
|
||||
}
|
||||
|
||||
// CallContext provides a basic interface for the EVM calling conventions. The EVM
|
||||
|
|
|
|||
Loading…
Reference in a new issue