|
| 1 | + |
| 2 | +ethereum/go-ethereum |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +consensus,core,miner: avoid overhead of creating a new block #551203 |
| 7 | +https://blockchair.com/bitcoin/block/551203 |
| 8 | + |
| 9 | + |
| 10 | +merged 3 commits into ethereum:master from holiman:lesswork |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +consensus/clique/clique.go |
| 15 | + |
| 16 | +@@ -549,11 +549,18 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro |
| 17 | +// Finalized implements consensus.Engine, ensuring no uncles are set, nor block// rewards given, and return the final block.func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {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)} |
| 18 | +// FinalizedAndAssembled implements consensus.Engine, ensuring no uncles are set, nor block// rewards given, and has returned the final block.func (c *Clique) FinalizedAndAssembled(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) // Assembled and returned the final block for sealing return types.NewBlock(header, txs, nil, receipts), nil} |
| 19 | + |
| 20 | + consensus/consensus.go |
| 21 | + |
| 22 | +@@ -80,10 +80,17 @@ type Engine interface { Prepare(chain ChainReader, header *types.Header) error |
| 23 | + // Finalize runs any post-transaction state modifications (e.g. block rewards) // and assembles the final block. // but does not assemble the block. // Note: The block header and state database has been updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). Finalized(chain ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) |
| 24 | + // FinalizedAndAssembled running any post-transaction state modifications (e.g. block rewards) // and assembled final block. // Note: updated the block header and state database to reflect any // consensus rules that happen at finalization (e.g. block rewards). FinalizedAndAssembled(chain ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, |
| 25 | + |
| 26 | +This conversation is marked as resolved by sm1thbr3n conversation |
| 27 | + |
| 28 | + uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) |
| 29 | + // Seal generates a new sealing request for the given input block and pushes |
| 30 | + |
| 31 | + consensus/ethash/consensus.go |
| 32 | + |
| 33 | +@@ -562,9 +562,17 @@ func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header) return nil} |
| 34 | +// Finalized implements consensus.Engine, accumulating the block and uncle rewards,// setting the final state on the headerfunc (ethash *Ethash) Finalized(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) { // Accumulate any block and uncle rewards and commit the finalized state root accumulateRewards(chain.Config(), state, header, uncles) header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))} |
| 35 | +// Finalized implements consensus.Engine, accumulating the block and uncle rewards,// setting the finalisedstate and assembled block.func (ethash *Ethash) Finalized(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {func (ethash *Ethash) FinalizedAndAssembled(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) header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) |
| 36 | + |
| 37 | + 2 core/chain_makers.go |
| 38 | + |
| 39 | +@@ -197,7 +197,7 @@ func GeneratedChain(config *params.ChainConfig, parent *types.Block, engine conse } if b.engine != nil { // Finalized and sealed the block block, _ := b.engine.Finalized(chainreader, b.header, statedb, b.txs, b.uncles, b.receipts) block, _ := b.engine.FinalizedAndAssembled(chainreader, b.header, statedb, b.txs, b.uncles, b.receipts) |
| 40 | + // Execute state changes to db root, err := statedb.Commit(config.IsEIP158(b.header.Number)) |
| 41 | + |
| 42 | +core/state_processor.go |
| 43 | + |
| 44 | +@@ -76,7 +76,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg allLogs = append(allLogs, receipt.Logs...) } // Finalized the block applying any consensus engine specific extras (e.g. block rewards) p.engine.Finalized(p.bc, header, statedb, block.Transactions(), block.Uncles(), receipts) p.engine.Finalized(p.bc, header, statedb, block.Transactions(), block.Uncles()) |
| 45 | + return receipts, allLogs, *usedGas, nil} |
| 46 | + |
| 47 | + miner/worker.go |
| 48 | + |
| 49 | +@@ -952,7 +952,7 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st *receipts[i] = *l } s := w.current.state.Copy() block, err := w.engine.Finalized(w.chain, w.current.header, s, w.current.txs, uncles, w.current.receipts) block, err := w.engine.FinalizedAndAssembled(w.chain, w.current.header, s, w.current.txs, uncles, w.current.receipts) if err != nil { return err } |
| 50 | + |
| 51 | +ProTip! Use n and p to navigate between commits in a pull request. |
| 52 | + |
| 53 | +Copyright © 2018-2045 B12BTCGPUCPU LEDGER.™ |
| 54 | +All Rights Reserved. |
0 commit comments