Repository navigation
fix(indexer): index the configured start height on a fresh database - #66
Open
setavenger wants to merge 1 commit into
Open
setavenger wants to merge 1 commit into
setavenger wants to merge 1 commit into
Conversation
InitialSyncToTip started at max(dbTip, SyncStartHeight)+1. On an empty database GetChainTip reports height 0, so the first pulled height was SyncStartHeight+1 and the configured start height itself was never indexed; a regtest oracle logged "syncTip=1" and answered height 1 with an empty hash. The same +1 skipped the start height whenever the database tip was below it. The start height is now the configured height on an empty database and max(tip+1, configured) otherwise. Tests run the initial sync against a fake Bitcoin Core REST server on an in-memory pebble store and require every height from the start height to the tip to carry the node's hash. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a fresh database
InitialSyncToTipcomputedsyncTip = max(dbTip, SyncStartHeight)and then synced fromsyncTip+1.GetChainTipreports height 0 for an empty database, so the configured start height itself was never pulled. A fresh regtest oracle logsStarting initial sync chaintip=101 syncTip=1, never indexes height 1, and answers height 1 with an empty hash.Clients that refuse to scan past an unindexed height (blindbit-rs #20) therefore never get past height 1, which breaks the testkit's regtest (T2) stack. The same
+1also skipped the start height when the database tip was below it.Fix
The new
initialSyncStartHeight(internal/indexer/builder.go) returns:GetChainTipreturned no hash)max(tip+1, configured)otherwiseTests
internal/indexer/fakechain_test.goadds a fake Bitcoin Core REST server. It serveschaininfo,blockhashbyheight,blockandspenttxoutsfrom an in-memory chain. Two tests use it with an in-memory pebble store:TestInitialSyncIndexesConfiguredStartHeightruns the realInitialSyncToTipwith start heights 1 and 3. It requires every height from the start height to the tip to carry the node's hash, and nothing below the start height to be indexed.TestInitialSyncStartHeightis a table test of the rule, covering the empty database, resuming after the tip, and a tip below the configured start.Both tests fail on
integration:go build ./... && go vet ./... && go test ./...passes, both with the default build and withCGO_ENABLED=1 -tags libsecp256k1.Overlap
internal/server/.🤖 Generated with Claude Code