diff --git a/common/constants.go b/common/constants.go index 842cfba422..900829a64c 100644 --- a/common/constants.go +++ b/common/constants.go @@ -23,6 +23,7 @@ const ( MergeSignRange = 15 RangeReturnSigner = 150 MinimunMinerBlockPerEpoch = 1 + IgnoreSignerCheckBlock = uint64(27307800) ) var TIP2019Block = big.NewInt(1) diff --git a/consensus/XDPoS/XDPoS.go b/consensus/XDPoS/XDPoS.go index 48b491d45c..e7979626b4 100644 --- a/consensus/XDPoS/XDPoS.go +++ b/consensus/XDPoS/XDPoS.go @@ -417,20 +417,11 @@ func (c *XDPoS) verifyCascadingFields(chain consensus.ChainReader, header *types if err == nil { return c.verifySeal(chain, header, parents, fullVerify) } - - // try again the progress with signers querying from smart contract - // for example the checkpoint is 886500 -> the start gap block is 886495 - startGapBlockHeader := header - for step := uint64(1); step <= chain.Config().XDPoS.Gap; step++ { - startGapBlockHeader = chain.GetHeader(startGapBlockHeader.ParentHash, number-step) - } - signers, err = c.HookGetSignersFromContract(startGapBlockHeader.Hash()) + signers, err = c.GetSignersFromContract(chain, header) if err != nil { - log.Debug("Can't get signers from Smart Contract ", err) return err } - err = c.checkSignersOnCheckpoint(chain, header, signers) if err == nil { return c.verifySeal(chain, header, parents, fullVerify) } @@ -440,6 +431,10 @@ func (c *XDPoS) verifyCascadingFields(chain consensus.ChainReader, header *types func (c *XDPoS) checkSignersOnCheckpoint(chain consensus.ChainReader, header *types.Header, signers []common.Address) error { number := header.Number.Uint64() + // ignore signerCheck at checkpoint block 27307800 due to wrong snapshot at gap 27307799 + if number == common.IgnoreSignerCheckBlock { + return nil + } penPenalties := []common.Address{} if c.HookPenalty != nil || c.HookPenaltyTIPSigning != nil { var err error @@ -1281,3 +1276,16 @@ func (c *XDPoS) CheckMNTurn(chain consensus.ChainReader, parent *types.Header, s } return false } + +func (c *XDPoS) GetSignersFromContract(chain consensus.ChainReader, checkpointHeader *types.Header) ([]common.Address, error) { + startGapBlockHeader := checkpointHeader + number := checkpointHeader.Number.Uint64() + for step := uint64(1); step <= chain.Config().XDPoS.Gap; step++ { + startGapBlockHeader = chain.GetHeader(startGapBlockHeader.ParentHash, number-step) + } + signers, err := c.HookGetSignersFromContract(startGapBlockHeader.Hash()) + if err != nil { + return []common.Address{}, fmt.Errorf("Can't get signers from Smart Contract . Err: %v", err) + } + return signers, nil +} diff --git a/core/blockchain.go b/core/blockchain.go index cf6ed1f457..0b4c70f7fe 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1271,7 +1271,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty stats.processed++ stats.usedGas += usedGas stats.report(chain, i, bc.stateCache.TrieDB().Size()) - if status == CanonStatTy && bc.chainConfig.XDPoS != nil { + if bc.chainConfig.XDPoS != nil { // epoch block if (chain[i].NumberU64() % bc.chainConfig.XDPoS.Epoch) == 0 { CheckpointCh <- 1 diff --git a/params/version.go b/params/version.go index 2125f94074..b3f510f330 100644 --- a/params/version.go +++ b/params/version.go @@ -22,7 +22,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release - VersionMinor = 0 // Minor version component of the current release + VersionMinor = 1 // Minor version component of the current release VersionPatch = 1 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string )