diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 6fd1ac07c3..3df9d32ce4 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -548,19 +548,20 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro } // Finalize implements consensus.Engine, ensuring no uncles are set, nor block -// rewards given, and returns the final block. +// rewards given. func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) { // No block rewards in PoA, so the state remains as is and uncles are dropped header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) header.UncleHash = types.CalcUncleHash(nil) } -// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block -// rewards given, and returns the final block. +// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, +// nor block rewards given, and returns the final block. func (c *Clique) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { // No block rewards in PoA, so the state remains as is and uncles are dropped header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) header.UncleHash = types.CalcUncleHash(nil) + // Assemble and return the final block for sealing return types.NewBlock(header, txs, nil, receipts), nil } diff --git a/consensus/consensus.go b/consensus/consensus.go index efb0ddf28c..f753af550c 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -81,13 +81,15 @@ type Engine interface { // Finalize runs any post-transaction state modifications (e.g. block rewards) // but does not assemble the block. + // // Note: The block header and state database might be updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). Finalize(chain ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) - // FinalizeAndAssemble runs any post-transaction state modifications (e.g. block rewards) - // and assembles the final block. + // FinalizeAndAssemble runs any post-transaction state modifications (e.g. block + // rewards) and assembles the final block. + // // Note: The block header and state database might be updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). FinalizeAndAssemble(chain ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index c41181a839..9541f8f5f9 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -570,8 +570,8 @@ func (ethash *Ethash) Finalize(chain consensus.ChainReader, header *types.Header header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) } -// Finalize implements consensus.Engine, accumulating the block and uncle rewards, -// setting the final state and assembling the block. +// FinalizeAndAssemble implements consensus.Engine, accumulating the block and +// uncle rewards, setting the final state and assembling the block. func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { // Accumulate any block and uncle rewards and commit the final state root accumulateRewards(chain.Config(), state, header, uncles)