Skip to content

bft: restore in-flight proposal kept by a view record - #748

Merged
HagarMeir merged 1 commit into
hyperledger:mainfrom
pfi79:restore-inflight-before-view-record
Nov 4, 2026
Merged

HagarMeir merged 1 commit into
hyperledger:mainfrom
pfi79:restore-inflight-before-view-record

Conversation

@pfi79

@pfi79 pfi79 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

A ViewChange or NewView record written with truncateTo=false keeps the preceding ProposedRecord/Commit in the WAL because the in-flight proposal is still needed. Restore only looked at the last entry: when it was NewView or ViewChange, Restore returned nil and left InFlightProposal empty. A restart then lost the proposal that the non-truncating record had preserved.

Scan backwards from the trailing view record for the latest proposal pair and restore only InFlightData. The view record defines the current view, so the view phase, number and sequence stay unchanged.

Fixes #749

@pfi79
pfi79 requested a review from HagarMeir November 3, 2026 09:43

@HagarMeir HagarMeir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Two small requests, neither of them a blocker:

  • The inline one below asks for an integration test.
  • Could you link or open an issue for this? It's a separate bug from #736 (it's about what a restarted node reports in a view change, not WAL growth), and it'd be good to have it on record.

(Written by Claude Code.)

Comment thread internal/bft/state.go
// ViewChange record kept in the WAL because it was still needed for a view change.
// Only the in-flight data is restored: the view record defines the current view, so
// the view phase, number and sequence stay as they are.
func (ps *PersistedState) restoreInFlightBeforeViewRecord(v *View) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker: could this get an integration test too? A node that prepares, goes through a view change, restarts, and then sends ViewData that still reports the prepared proposal. The unit tests cover the WAL parsing, but not that the restored state reaches the ViewData.

(Written by Claude Code.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

A ViewChange or NewView record written with truncateTo=false keeps the
preceding ProposedRecord/Commit in the WAL because the in-flight proposal is
still needed. Restore only looked at the last entry: when it was NewView or
ViewChange, Restore returned nil and left InFlightProposal empty. A restart
then lost the proposal that the non-truncating record had preserved.

Scan backwards from the trailing view record for the latest proposal pair and
restore only InFlightData. The view record defines the current view, so the
view phase, number and sequence stay unchanged.

Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
@pfi79
pfi79 force-pushed the restore-inflight-before-view-record branch from fd76997 to 5f5d792 Compare November 3, 2026 13:40
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.

A restarted node loses the prepared in-flight proposal when the WAL ends with a view record

2 participants