Skip to content

Commit

Permalink
test: change set expected root
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang committed Apr 15, 2024
1 parent 643379a commit ddd3ef2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
// Make sure no inconsistent state is leaked during insertion
externTd := new(big.Int).Add(block.Difficulty(), ptd)

state.SetExpectedStateRoot(block.Root())
// Irrelevant of the canonical status, write the block itself to the database.
//
// Note all the components of block(td, hash->number map, header, body, receipts)
Expand Down
18 changes: 9 additions & 9 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,19 +1233,19 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
nodes = trienode.NewMergedNodeSet()
incomplete map[common.Address]struct{}
)
if s.stateRoot = s.StateIntermediateRoot(); s.expectedRoot != s.stateRoot {
s.expectedRoot = s.stateRoot
//log.Error("Invalid merkle root", "remote", s.expectedRoot, "local", s.stateRoot)
//return fmt.Errorf("invalid merkle root (remote: %x local: %x)", s.expectedRoot, s.stateRoot)
}
//if s.stateRoot = s.StateIntermediateRoot(); s.expectedRoot != s.stateRoot {
// s.expectedRoot = s.stateRoot
// //log.Error("Invalid merkle root", "remote", s.expectedRoot, "local", s.stateRoot)
// //return fmt.Errorf("invalid merkle root (remote: %x local: %x)", s.expectedRoot, s.stateRoot)
//}
commmitTrie := func() error {
if metrics.EnabledExpensive {
defer func(start time.Time) { s.TrieAllCommits += time.Since(start) }(time.Now())
}
//if s.stateRoot = s.StateIntermediateRoot(); s.expectedRoot != s.stateRoot {
// log.Error("Invalid merkle root", "remote", s.expectedRoot, "local", s.stateRoot)
// return fmt.Errorf("invalid merkle root (remote: %x local: %x)", s.expectedRoot, s.stateRoot)
//}
if s.stateRoot = s.StateIntermediateRoot(); s.expectedRoot != s.stateRoot {
log.Error("Invalid merkle root", "remote", s.expectedRoot, "local", s.stateRoot)
return fmt.Errorf("invalid merkle root (remote: %x local: %x)", s.expectedRoot, s.stateRoot)
}

var err error
// Handle all state deletions first
Expand Down

0 comments on commit ddd3ef2

Please sign in to comment.