Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lib/babe): call AddBlock in BABE synchronously after block is built #1585

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions lib/babe/babe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down