Skip to content

fix: forkchoice checkpoint-sync init — defer justified/finalized, add initing/ready status (closes #608)#612

Merged
g11tech merged 3 commits intomainfrom
issue-608-forkchoice-checkpoint-sync-init
Mar 3, 2026
Merged

fix: forkchoice checkpoint-sync init — defer justified/finalized, add initing/ready status (closes #608)#612
g11tech merged 3 commits intomainfrom
issue-608-forkchoice-checkpoint-sync-init

Conversation

@zclawz
Copy link
Copy Markdown
Contributor

@zclawz zclawz commented Feb 27, 2026

Summary

Closes #608

Changes

pkgs/node/src/forkchoice.zig

  • Added ForkChoiceStatus enum (initing | ready)
  • Added status: ForkChoiceStatus field to ForkChoice
  • Genesis init (slot == 0): starts as ready (existing behaviour unchanged)
  • Checkpoint-sync / DB-restore init (slot > 0): starts as initinglatest_justified and latest_finalized still hold the anchor checkpoint for internal forkchoice computation, but the node does not participate in validator duties until the first real justified update arrives via onBlock
  • In onBlockUnlocked: when fcStore.update() advances latest_justified past the anchor slot, status transitions to ready and an [info] log is emitted
  • Added pub fn isReady() method for callers
  • Info log on init for both genesis and checkpoint-sync paths

pkgs/node/src/chain.zig

  • Added .fc_initing variant to SyncStatus
  • getSyncStatus() returns .fc_initing first when !forkChoice.isReady()

pkgs/node/src/validator_client.zig

  • maybeDoProposal and mayBeDoAttestation now handle .fc_initing — log and return null (skip duty)

pkgs/node/src/node.zig

  • Added .fc_initing to the exhaustive switch in the peer-status handler

Test Results

zig build test — 120/132 passed (12 pre-existing failures: IoUring PermissionDenied in sandbox + tree_visualizer — identical to main without changes)

@g11tech g11tech merged commit fd63f2c into main Mar 3, 2026
12 checks passed
@g11tech g11tech deleted the issue-608-forkchoice-checkpoint-sync-init branch March 3, 2026 10:54
gballet pushed a commit that referenced this pull request Mar 8, 2026
… initing/ready status (closes #608) (#612)

* fix: forkchoice checkpoint-sync init — defer justified/finalized, add initing/ready status (closes #608)

* lint

---------

Co-authored-by: zclawz <zclawz@users.noreply.github.com>
Co-authored-by: harkamal <gajinder@zeam.in>
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.

fix the checkpoint sync init for forkchoice

2 participants