Skip to content

Commit c49aae9

Browse files
author
Mr-Leshiy
authored
consensus: refactor FinalizeAndAssemble to use Finalize (#21993)
1 parent efe6dd2 commit c49aae9

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎consensus/clique/clique.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,8 @@ func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
561561
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
562562
// nor block rewards given, and returns the final block.
563563
func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
564-
// No block rewards in PoA, so the state remains as is and uncles are dropped
565-
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
566-
header.UncleHash = types.CalcUncleHash(nil)
564+
// Finalize block
565+
c.Finalize(chain, header, state, txs, uncles)
567566

568567
// Assemble and return the final block for sealing
569568
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie)), nil

‎consensus/ethash/consensus.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,8 @@ func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.
584584
// FinalizeAndAssemble implements consensus.Engine, accumulating the block and
585585
// uncle rewards, setting the final state and assembling the block.
586586
func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
587-
// Accumulate any block and uncle rewards and commit the final state root
588-
accumulateRewards(chain.Config(), state, header, uncles)
589-
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
587+
// Finalize block
588+
ethash.Finalize(chain, header, state, txs, uncles)
590589

591590
// Header seems complete, assemble into a block and return
592591
return types.NewBlock(header, txs, uncles, receipts, new(trie.Trie)), nil

0 commit comments

Comments
 (0)