Skip to content

Commit

Permalink
test: set expected root
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang committed Apr 15, 2024
1 parent 211a1a0 commit 643379a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,14 +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)
}
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
1 change: 1 addition & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ func (w *worker) resultLoop() {
}
// Commit block and state to database.
task.state.SetExpectedStateRoot(block.Root())
log.Error("miner pre write block", "root", block.Root())
_, err := w.chain.WriteBlockAndSetHead(block, receipts, logs, task.state, true)
if err != nil {
log.Error("Failed writing block to chain", "err", err)
Expand Down

0 comments on commit 643379a

Please sign in to comment.