From 16a911bc39085c545f0c67f26a13dc9555d8f9be Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 23 Oct 2020 19:30:42 +0200 Subject: [PATCH] Fix random test failures If block 1 was a null block then blockSet would include genesis which would lead to us trying to load parent of a genesis block. Signed-off-by: Jakub Sztandera --- chain/sync.go | 5 +++++ miner/miner.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/chain/sync.go b/chain/sync.go index d05a3d8bb5c..8da093cb6f4 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -1396,6 +1396,11 @@ loop: } base := blockSet[len(blockSet)-1] + if base.Equals(known) { + blockSet = blockSet[:len(blockSet)-1] + base = blockSet[len(blockSet)-1] + } + if base.IsChildOf(known) { // common case: receiving blocks that are building on top of our best tipset return blockSet, nil diff --git a/miner/miner.go b/miner/miner.go index 7de7f5b734b..f2468a91153 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -280,7 +280,7 @@ minerLoop: m.minedBlockHeights.Add(blkKey, true) if err := m.api.SyncSubmitBlock(ctx, b); err != nil { - log.Errorf("failed to submit newly mined block: %s", err) + log.Errorf("failed to submit newly mined block: %+v", err) } } else { base.NullRounds++