From d369f542c5d881879e37e968493b3fba7ac3d9fb Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 9 Sep 2020 23:17:09 +0300 Subject: [PATCH] warn when optimal selection fails to pack a block and we fall back to random selection --- chain/messagepool/selection.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index 8bb32eb1d..2ddbed0ad 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -309,8 +309,10 @@ tailLoop: // if we have gasLimit to spare, pick some random (non-negative) chains to fill the block // we pick randomly so that we minimize the probability of duplication among all miners - startRandom := time.Now() if gasLimit >= minGas { + randomCount := 0 + + startRandom := time.Now() shuffleChains(chains) for _, chain := range chains { @@ -359,15 +361,23 @@ tailLoop: curChain := chainDeps[i] curChain.merged = true result = append(result, curChain.msgs...) + randomCount += len(curChain.msgs) } chain.merged = true result = append(result, chain.msgs...) + randomCount += len(chain.msgs) gasLimit -= chainGasLimit } - } - if dt := time.Since(startRandom); dt > time.Millisecond { - log.Infow("pack random tail chains done", "took", dt) + + if dt := time.Since(startRandom); dt > time.Millisecond { + log.Infow("pack random tail chains done", "took", dt) + } + + if randomCount > 0 { + log.Warnf("optimal selection failed to pack a block; picked %d messages with random selection", + randomCount) + } } return result, nil