Skip to content

Commit

Permalink
[R4R] fix: Incorrect merkle root issue when enabling pipecommit with …
Browse files Browse the repository at this point in the history
…miner (#1011)

[R4R] fix: Incorrect merkle root issue when enabling pipecommit with miner (#1011)
  • Loading branch information
j75689 authored Jul 22, 2022
1 parent 015c527 commit 403b19c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ func (s *StateDB) CorrectAccountsRoot(blockRoot common.Hash) {
if !obj.deleted && !obj.rootCorrected && obj.data.Root == dummyRoot {
if account, exist := accounts[crypto.Keccak256Hash(obj.address[:])]; exist {
obj.data.Root = common.BytesToHash(account.Root)
if obj.data.Root == (common.Hash{}) {
obj.data.Root = emptyRoot
}
obj.rootCorrected = true
}
}
Expand Down
11 changes: 6 additions & 5 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,14 +1197,15 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
}
env.state.CorrectAccountsRoot(w.chain.CurrentBlock().Root())

// Create a local environment copy, avoid the data race with snapshot state.
// https://github.com/ethereum/go-ethereum/issues/24299
env := env.copy()
s := env.state
block, receipts, err := w.engine.FinalizeAndAssemble(w.chain, types.CopyHeader(env.header), s, env.txs, env.unclelist(), env.receipts)
block, receipts, err := w.engine.FinalizeAndAssemble(w.chain, types.CopyHeader(env.header), env.state, env.txs, env.unclelist(), env.receipts)
if err != nil {
return err
}

// Create a local environment copy, avoid the data race with snapshot state.
// https://github.com/ethereum/go-ethereum/issues/24299
env := env.copy()

// If we're post merge, just ignore
if !w.isTTDReached(block.Header()) {
select {
Expand Down

0 comments on commit 403b19c

Please sign in to comment.