[NOD-255] When adding orphans during netsync process - report only to debug log, unless number of orphans > k*2 (#357)

* [NOD-255] When orphan blocks arrive from netsync - don't write log unless we are in Debug

* [NOD-255] If there are more than K*2 orphans in pool - report as a potential problem anyway

* [NOD-255] Update comment to explain the K*2 figure
This commit is contained in:
Svarog 2019-08-07 11:30:32 +03:00 committed by stasatdaglabs
parent 49ac97c7db
commit 9981ce7adb
2 changed files with 19 additions and 1 deletions

View File

@ -37,6 +37,10 @@ const (
// in the future, just finished the delay
BFAfterDelay
// BFIsSync may be set to indicate that the block was sent as part of the
// netsync process
BFIsSync
// BFNone is a convenience value to specifically indicate no flags.
BFNone BehaviorFlags = 0
)
@ -189,7 +193,18 @@ func (dag *BlockDAG) ProcessBlock(block *util.Block, flags BehaviorFlags) (isOrp
}
if !allParentsExist {
log.Infof("Adding orphan block %s", blockHash)
// Some orphans during netsync are a normal part of the process, since the anticone
// of the chain-split is never explicitly requested.
// Therefore, if we are during netsync - don't report orphans to default logs.
//
// The number K*2 was chosen since in peace times anticone is limited to K blocks,
// while some red block can make it a bit bigger, but much more than that indicates
// there might be some problem with the netsync process.
if flags&BFIsSync == BFIsSync && uint32(len(dag.orphans)) < dag.dagParams.K*2 {
log.Debugf("Adding orphan block %s. This is normal part of netsync process", blockHash)
} else {
log.Infof("Adding orphan block %s", blockHash)
}
dag.addOrphanBlock(block)
return true, 0, nil

View File

@ -552,6 +552,9 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
if bmsg.isDelayedBlock {
behaviorFlags |= blockdag.BFAfterDelay
}
if bmsg.peer == sm.syncPeer {
behaviorFlags |= blockdag.BFIsSync
}
// Process the block to include validation, orphan handling, etc.
isOrphan, delay, err := sm.dag.ProcessBlock(bmsg.block, behaviorFlags)