-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd, consensus, core, eth, tests: return memorized state error #26671
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,9 +341,6 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. | |
amount = amount.Mul(amount, big.NewInt(params.GWei)) | ||
state.AddBalance(w.Address, amount) | ||
} | ||
// The block reward is no longer handled here. It's done by the | ||
// external consensus engine. | ||
header.Root = state.IntermediateRoot(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You removed the IntermediateRoot from
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In
In block insertion, the real hash comparison is happened in block validation, // Validate the state root against the received state root and throw
// an error if they don't match.
root, err := statedb.IntermediateRoot(v.config.IsEIP158(header.Number))
if err != nil {
return fmt.Errorf("failed to derive state root %v", err)
}
if header.Root != root {
return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In summary, the behavior is identical with old code, but just emphasize
|
||
} | ||
|
||
// FinalizeAndAssemble implements consensus.Engine, setting the final state and | ||
|
@@ -367,6 +364,15 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea | |
} | ||
// Finalize and assemble the block. | ||
beacon.Finalize(chain, header, state, txs, uncles, withdrawals) | ||
|
||
// Assign the final state root to header. | ||
root, err := state.IntermediateRoot(true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
header.Root = root | ||
|
||
// Assemble and return the final block. | ||
return types.NewBlockWithWithdrawals(header, txs, uncles, receipts, withdrawals, trie.NewStackTrie(nil)), nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you drop this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we will do a commit afterwards, https://github.com/ethereum/go-ethereum/pull/26671/files/a63b92c933e707f1f87b9040da3a32bae90a9061#diff-06c63748460168e12cbf03984f37c000908e0b7ff50ca0dfe28db286a1dfd36eR267
It's unnecessary to do it, unless for some strong reasons?