mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Work around for the issue "return wrong list signers from snapshot"
Update signers in snapshot Ignore signerCheck at checkpoint block 27307800 due to wrong snapshot at gap 27307799
This commit is contained in:
parent
a41658640f
commit
92ffe69ab4
4 changed files with 21 additions and 12 deletions
|
|
@ -23,6 +23,7 @@ const (
|
|||
MergeSignRange = 15
|
||||
RangeReturnSigner = 150
|
||||
MinimunMinerBlockPerEpoch = 1
|
||||
IgnoreSignerCheckBlock = uint64(27307800)
|
||||
)
|
||||
|
||||
var TIP2019Block = big.NewInt(1)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue