Skip to content

consensus: anchor checkpoint fast-add - #103

Merged
wolf31o2 merged 1 commit into
mainfrom
fix/checkpoint-anchored-fastadd
Jul 30, 2026
Merged

consensus: anchor checkpoint fast-add#103
wolf31o2 merged 1 commit into
mainfrom
fix/checkpoint-anchored-fastadd

Conversation

@wolf31o2

@wolf31o2 wolf31o2 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • enable checkpoint fast-add only after the configured checkpoint header is known in the valid best-header chain
  • keep full block validation active when a peer stops its header chain before the checkpoint
  • make addblock imports use full consensus validation instead of unconditionally requesting fast-add
  • add regression coverage with a valid-PoW block whose coinbase height is consensus-invalid

Validation

  • make unit unit-race unit-cover build integration hsd-interop lint vuln workers=2
  • go mod verify in the root module, hnsutil, hnsutil/psbt, and chaincfg/chainhash
  • release Docker builds and --version smoke tests for linux/amd64 and linux/arm64

The validation used Go 1.26.5, pinned hsd v8.0.0, and a freshly compiled govulncheck v1.6.0.


Summary by cubic

Anchors fast-add to a known checkpoint header and enforces full consensus validation for addblock imports to prevent bypassing rules with partial header chains.

  • Bug Fixes
    • netsync: Enable fast-add only after the checkpoint header is in the best-header view; keep full validation if a peer stops headers before the checkpoint.
    • addblock: Use blockchain.BFNone for imports instead of BFFastAdd.
    • Tests: Added regression for valid-PoW block with invalid coinbase height; updated header path tests to verify fast-add gating.

Written for commit aab8c57. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Block imports now perform complete validation, rejecting blocks with invalid coinbase information.
    • Improved checkpoint handling during blockchain synchronization to prevent fast processing when checkpoint headers are unavailable or invalid.
    • Enhanced reliability when distinguishing valid main-chain blocks from orphaned blocks during import and synchronization.
  • Tests

    • Added coverage for invalid block imports and checkpoint-based synchronization scenarios.

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c69d4dc7-13f2-494a-ac89-07f6b2004bd7

📥 Commits

Reviewing files that changed from the base of the PR and between 7aa7481 and aab8c57.

📒 Files selected for processing (4)
  • cmd/addblock/import.go
  • cmd/addblock/import_test.go
  • netsync/manager.go
  • netsync/manager_test.go

📝 Walkthrough

Walkthrough

The block importer now processes imported blocks with normal validation flags instead of fast-add. A regression test constructs a proof-of-work-valid block with an invalid coinbase height and verifies rejection with ErrBadCoinbaseHeight. Header synchronization now validates the next checkpoint header before enabling fast-add. Updated IBD tests cover behavior before and after the checkpoint and verify main-chain anchoring.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: tightening checkpoint fast-add behavior and anchoring it to the known checkpoint chain.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/checkpoint-anchored-fastadd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wolf31o2

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@wolf31o2
wolf31o2 merged commit eebc9dd into main Jul 30, 2026
15 checks passed
@wolf31o2
wolf31o2 deleted the fix/checkpoint-anchored-fastadd branch July 30, 2026 15:05
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.

1 participant