Skip to content

scale down the common block jump #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/constant/blockchainSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const (
DefaultNumberOfForkConfirmations int32 = 1
PeerGetBlocksLimit uint32 = 1440
CommonMilestoneBlockIdsLimit int32 = 10
SafeBlockGap uint32 = 1440
SafeBlockGap uint32 = uint32(MinRollbackBlocks / 2)
// @iltoga change this to 2 for testing snapshots
MinRollbackBlocks uint32 = 720 // production 720
MaxCommonMilestoneRequestTrial uint32 = MinRollbackBlocks/uint32(CommonMilestoneBlockIdsLimit) + 1
MinimumPeersBlocksToDownload int32 = 2
)
2 changes: 1 addition & 1 deletion core/blockchainsync/downloadBlockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (bd *BlockchainDownloader) GetPeerBlockchainInfo() (*PeerBlockchainInfo, er
monitoring.IncrementMainchainDownloadCycleDebugger(bd.ChainType, 41)
chainBlockIds := bd.getBlockIdsAfterCommon(peer, commonMilestoneBlockID)
monitoring.IncrementMainchainDownloadCycleDebugger(bd.ChainType, 42)
if len(chainBlockIds) < 2 || !bd.PeerHasMore {
if int32(len(chainBlockIds)) < constant.MinimumPeersBlocksToDownload || !bd.PeerHasMore {
monitoring.IncrementMainchainDownloadCycleDebugger(bd.ChainType, 43)
return &PeerBlockchainInfo{
Peer: peer,
Expand Down
5 changes: 4 additions & 1 deletion core/blockchainsync/processFork.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (fp *ForkingProcessor) ProcessFork(forkBlocks []*model.Block, commonBlock *
// rebuilding the chain
monitoring.IncrementMainchainDownloadCycleDebugger(fp.ChainType, 88)
for _, block := range forkBlocks {
if block.ID == lastBlock.ID {
continue
}
monitoring.IncrementMainchainDownloadCycleDebugger(fp.ChainType, 89)
lastBlock, err = fp.BlockService.GetLastBlock()
monitoring.IncrementMainchainDownloadCycleDebugger(fp.ChainType, 90)
Expand Down Expand Up @@ -107,7 +110,7 @@ func (fp *ForkingProcessor) ProcessFork(forkBlocks []*model.Block, commonBlock *
if blacklistErr != nil {
fp.Logger.Errorf("Failed to add blacklist: %v\n", blacklistErr)
}
fp.Logger.Warnf("\n\nPushBlock err %v\n\n", err)
fp.Logger.Warnf("\n\nPushBlock of fork blocks err %v\n\n", err)
break
}

Expand Down