From 9981ce7adbadc988adf1a964c97f1555f4f1ddb2 Mon Sep 17 00:00:00 2001 From: Svarog Date: Wed, 7 Aug 2019 11:30:32 +0300 Subject: [PATCH] [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 --- blockdag/process.go | 17 ++++++++++++++++- netsync/manager.go | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/blockdag/process.go b/blockdag/process.go index 514e8cdf1..9ae456bf8 100644 --- a/blockdag/process.go +++ b/blockdag/process.go @@ -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 diff --git a/netsync/manager.go b/netsync/manager.go index 940e21ad8..e4554585c 100644 --- a/netsync/manager.go +++ b/netsync/manager.go @@ -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)