From 0e51a6d76ea35124af30fc81017ea8ac3775c54c Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 27 Mar 2019 13:17:22 +0800 Subject: core: fix finalize logic (#302) --- consensus/dexcon/dexcon.go | 6 ++++-- core/blockchain.go | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/consensus/dexcon/dexcon.go b/consensus/dexcon/dexcon.go index 0b6fa192f..4e474bfa3 100644 --- a/consensus/dexcon/dexcon.go +++ b/consensus/dexcon/dexcon.go @@ -208,8 +208,10 @@ func (d *Dexcon) Finalize(chain consensus.ChainReader, header *types.Header, sta gs.MiningHalved() } - // Record last proposed height. - gs.PutLastProposedHeight(header.Coinbase, header.Number) + if header.Coinbase != (common.Address{}) { + // Record last proposed height. + gs.PutLastProposedHeight(header.Coinbase, header.Number) + } header.Root = state.IntermediateRoot(true) return types.NewBlock(header, txs, uncles, receipts), nil diff --git a/core/blockchain.go b/core/blockchain.go index 7a695ac38..3f0e7203e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1827,10 +1827,6 @@ func (bc *BlockChain) ProcessEmptyBlock(block *types.Block) (*common.Hash, error header.ParentHash = parentBlock.Hash() newBlock, err := bc.engine.Finalize(bc, header, currentState, nil, nil, nil) - if header.Root != parentBlock.Root() { - return nil, fmt.Errorf("empty block state root must same as parent") - } - root := newBlock.Root() if _, ok := bc.GetRoundHeight(newBlock.Round()); !ok { bc.storeRoundHeight(newBlock.Round(), newBlock.NumberU64()) -- cgit v1.2.3