change devnet switch block for large scale test (#205)

* change switch block

* use mainnet masternode

* update mining and timeout time

* add timer on round number

* remove bug code
This commit is contained in:
Liam 2022-11-12 12:19:28 +08:00 committed by GitHub
parent fb7234c93f
commit f9c0c40515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View file

@ -60,6 +60,8 @@ type XDPoS_v2 struct {
HookPenalty func(chain consensus.ChainReader, number *big.Int, parentHash common.Hash, candidates []common.Address) ([]common.Address, error) HookPenalty func(chain consensus.ChainReader, number *big.Int, parentHash common.Hash, candidates []common.Address) ([]common.Address, error)
ForensicsProcessor *Forensics ForensicsProcessor *Forensics
votePoolCollectionTime time.Time
} }
func New(config *params.XDPoSConfig, db ethdb.Database, waitPeriodCh chan int) *XDPoS_v2 { func New(config *params.XDPoSConfig, db ethdb.Database, waitPeriodCh chan int) *XDPoS_v2 {
@ -756,6 +758,7 @@ func (x *XDPoS_v2) verifyQC(blockChainReader consensus.ChainReader, quorumCert *
log.Warn("[verifyHeader] Invalid QC Signature is nil or empty", "QC", quorumCert, "QCNumber", quorumCert.ProposedBlockInfo.Number, "Signatures len", len(signatures)) log.Warn("[verifyHeader] Invalid QC Signature is nil or empty", "QC", quorumCert, "QCNumber", quorumCert.ProposedBlockInfo.Number, "Signatures len", len(signatures))
return utils.ErrInvalidQC return utils.ErrInvalidQC
} }
start := time.Now()
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(signatures)) wg.Add(len(signatures))
@ -781,6 +784,8 @@ func (x *XDPoS_v2) verifyQC(blockChainReader consensus.ChainReader, quorumCert *
}(signature) }(signature)
} }
wg.Wait() wg.Wait()
elapsed := time.Since(start)
log.Info("[verifyQC] time verify message signatures of qc", "elapsed", elapsed)
if haveError != nil { if haveError != nil {
return haveError return haveError
} }

View file

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time"
"github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/consensus" "github.com/XinFinOrg/XDPoSChain/consensus"
@ -54,7 +55,6 @@ func (x *XDPoS_v2) sendVote(chainReader consensus.ChainReader, blockInfo *types.
} }
func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote) error { func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote) error {
// checkRoundNumber // checkRoundNumber
if (voteMsg.ProposedBlockInfo.Round != x.currentRound) && (voteMsg.ProposedBlockInfo.Round != x.currentRound+1) { if (voteMsg.ProposedBlockInfo.Round != x.currentRound) && (voteMsg.ProposedBlockInfo.Round != x.currentRound+1) {
return &utils.ErrIncomingMessageRoundTooFarFromCurrentRound{ return &utils.ErrIncomingMessageRoundTooFarFromCurrentRound{
@ -64,6 +64,11 @@ func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote)
} }
} }
if x.votePoolCollectionTime.IsZero() {
log.Info("[voteHandler] set vote pool time", "round", x.currentRound)
x.votePoolCollectionTime = time.Now()
}
// Collect vote // Collect vote
thresholdReached, numberOfVotesInPool, pooledVotes := x.votePool.Add(voteMsg) thresholdReached, numberOfVotesInPool, pooledVotes := x.votePool.Add(voteMsg)
log.Debug("[voteHandler] collect votes", "number", numberOfVotesInPool) log.Debug("[voteHandler] collect votes", "number", numberOfVotesInPool)
@ -87,6 +92,9 @@ func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote)
if err != nil { if err != nil {
return err return err
} }
elapsed := time.Since(x.votePoolCollectionTime)
log.Info("[voteHandler] time cost from receive first vote under QC create", "elapsed", elapsed)
x.votePoolCollectionTime = time.Time{}
} }
return nil return nil
@ -99,7 +107,7 @@ func (x *XDPoS_v2) voteHandler(chain consensus.ChainReader, voteMsg *types.Vote)
func (x *XDPoS_v2) onVotePoolThresholdReached(chain consensus.ChainReader, pooledVotes map[common.Hash]utils.PoolObj, currentVoteMsg utils.PoolObj, proposedBlockHeader *types.Header) error { func (x *XDPoS_v2) onVotePoolThresholdReached(chain consensus.ChainReader, pooledVotes map[common.Hash]utils.PoolObj, currentVoteMsg utils.PoolObj, proposedBlockHeader *types.Header) error {
masternodes := x.GetMasternodes(chain, proposedBlockHeader) masternodes := x.GetMasternodes(chain, proposedBlockHeader)
start := time.Now()
// Filter out non-Master nodes signatures // Filter out non-Master nodes signatures
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(pooledVotes)) wg.Add(len(pooledVotes))
@ -121,6 +129,8 @@ func (x *XDPoS_v2) onVotePoolThresholdReached(chain consensus.ChainReader, poole
counter++ counter++
} }
wg.Wait() wg.Wait()
elapsed := time.Since(start)
log.Info("[onVotePoolThresholdReached] verify message signatures of vote pool took", "elapsed", elapsed)
// The signature list may contain empty entey. we only care the ones with values // The signature list may contain empty entey. we only care the ones with values
var validSignatureSlice []types.Signature var validSignatureSlice []types.Signature

View file

@ -54,12 +54,12 @@ var (
SkipV2Validation: true, SkipV2Validation: true,
} }
DevnetXDPoSV2Config = &V2{ DevnetXDPoSV2Config = &V2{
SwitchBlock: big.NewInt(7060500), SwitchBlock: big.NewInt(7074000),
CertThreshold: 4, CertThreshold: common.MaxMasternodesV2*2/3 + 1,
TimeoutSyncThreshold: 5, TimeoutSyncThreshold: 5,
TimeoutPeriod: 10, TimeoutPeriod: 25,
WaitPeriod: 5, WaitPeriod: 10,
MinePeriod: 5, MinePeriod: 10,
} }
// XDPoSChain mainnet config // XDPoSChain mainnet config