diff --git a/consensus/XDPoS/XDPoS.go b/consensus/XDPoS/XDPoS.go index c86a4d4957..342e754399 100644 --- a/consensus/XDPoS/XDPoS.go +++ b/consensus/XDPoS/XDPoS.go @@ -130,6 +130,15 @@ func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS { return fakeEngine } +func (x *XDPoS) Initial(chain consensus.ChainReader, header *types.Header) error { + switch x.config.BlockConsensusVersion(header.Number) { + case params.ConsensusEngineVersion2: + return x.EngineV2.Initial(chain, header) + default: // Default "v1" + return nil + } +} + /* Eth Consensus engine interface implementation */ diff --git a/core/blockchain.go b/core/blockchain.go index bb597cbb6b..c9f83bf72b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -352,6 +352,13 @@ func (bc *BlockChain) loadLastState() error { } bc.hc.SetCurrentHeader(currentHeader) + if engine, ok := bc.Engine().(*XDPoS.XDPoS); ok { + err := engine.Initial(bc, currentHeader) + if err != nil { + return err + } + } + // Restore the last known head fast block bc.currentFastBlock.Store(currentBlock) if head := GetHeadFastBlockHash(bc.db); head != (common.Hash{}) {