From 549dc2548240a7a73c0f88ad60d67148cbbe78be Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Fri, 14 May 2021 15:26:45 -0400 Subject: [PATCH] fix(lib/babe): call AddBlock in BABE synchronously (#1585) --- dot/core/service.go | 7 +------ lib/babe/babe.go | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dot/core/service.go b/dot/core/service.go index cf72bdfe65..c7bce45155 100644 --- a/dot/core/service.go +++ b/dot/core/service.go @@ -284,12 +284,7 @@ func (s *Service) handleReceivedBlock(block *types.Block) (err error) { return ErrNilBlockState } - err = s.blockState.AddBlock(block) - if err != nil { - return err - } - - logger.Debug("added block from BABE", "header", block.Header, "body", block.Body) + logger.Debug("got block from BABE", "header", block.Header, "body", block.Body) msg := &network.BlockAnnounceMessage{ ParentHash: block.Header.ParentHash, diff --git a/lib/babe/babe.go b/lib/babe/babe.go index 8d640be386..072d22ada0 100644 --- a/lib/babe/babe.go +++ b/lib/babe/babe.go @@ -505,6 +505,11 @@ func (b *Service) handleSlot(slotNum uint64) error { logger.Info("built block", "hash", hash.String(), "number", block.Header.Number, "slot", slotNum) logger.Debug("built block", "header", block.Header, "body", block.Body, "parent", parent.Hash()) + err = b.blockState.AddBlock(block) + if err != nil { + return err + } + err = b.safeSend(*block) if err != nil { logger.Error("failed to send block to core", "error", err)