Skip to content

fix(bft): return error when committee loading fails - #596

Open
yasinlex wants to merge 1 commit into
canopy-network:mainfrom
yasinlex:fix/error-swallowing-in-bft-committee-loading
Open

fix(bft): return error when committee loading fails#596
yasinlex wants to merge 1 commit into
canopy-network:mainfrom
yasinlex:fix/error-swallowing-in-bft-committee-loading

Conversation

@yasinlex

@yasinlex yasinlex commented Sep 5, 2026

Copy link
Copy Markdown

Problem

In bft/bft.go Start() function, errors from LoadCommittee() and LoadCommitteeData() were only logged as warnings:

b.ValidatorSet, err = b.Controller.LoadCommittee(...)
if err != nil {
    b.log.Warn(err.Error())  // Just a warning!
}

This allowed the BFT to continue with a potentially nil validator set, which would cause panics when:

  • GetValidator() is called (line 242)
  • SendToReplicas() is called (lines 270, 346, 446, etc.)
  • SelectProposerFromCandidates() is called (line 291)

Fix

Changed from logging warnings to returning errors:

b.ValidatorSet, err = b.Controller.LoadCommittee(...)
if err != nil {
    b.log.Error(err.Error())
    return  // Stop BFT initialization
}

Impact

  • Before: Committee loading failure → BFT continues with nil validator set → panic
  • After: Committee loading failure → BFT stops initialization → error logged

Previously, errors from LoadCommittee() and LoadCommitteeData() were
only logged as warnings, allowing the BFT to continue with a potentially
nil validator set. This could lead to panics when the validator set is
used later.

Now returns from Start() on committee loading failures, preventing
the BFT from running with an invalid state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants