docs(chain): fix merge_chains documentation on genesis block replacement#2117
Open
gyanranjanpanda wants to merge 1 commit intobitcoindevkit:masterfrom
Open
Conversation
Fixes bitcoindevkit#2095 (Issue bitcoindevkit#1) The documentation incorrectly stated that replacing the genesis block always causes a CannotConnectError. However, the implementation and existing tests demonstrate that genesis block replacement is allowed when the update forms a consistent chain with a point of agreement at a higher height. Updated the merge_chains documentation to: - Remove the incorrect statement about genesis replacement - Clarify when CannotConnectError actually occurs - Add explicit note explaining when genesis replacement is allowed - Improve overall clarity and readability This is a documentation-only change with no behavioral modifications. All existing tests pass, including the 'fix blockhash before agreement point' test case that validates genesis block replacement.
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.
Fix incorrect documentation about genesis block replacement
Fixes #2095 (part 1)
The Problem
I noticed the docs for
merge_chainssaid that trying to replace the genesis block would always fail with aCannotConnectError. But when I looked at the tests, there's actually a test case called "fix blockhash before agreement point" that does exactly that - it replaces the genesis block and expects it to succeed!Here's the test:
So the docs were misleading - genesis replacement is actually allowed as long as there's agreement at a higher block.
What I Changed
I updated the documentation to match what the code actually does:
Before: Said genesis replacement always fails
After: Explains that genesis replacement is fine when the update is consistent and has a point of agreement at a higher height
I also cleaned up the wording to make it clearer when
CannotConnectErroractually happens.Testing
Ran the full test suite:
cargo test -p bdk_chainAll 58 tests pass ✅
Impact
This is just a documentation fix - no code changes, no breaking changes. Just making the docs match reality so developers aren't confused.
Note
Issue #2095 mentioned two problems. This PR fixes the first one (genesis block docs). The second issue about chain reorgs is a known limitation that's being worked on in #2091.