Skip to content

Guard against trimmed chain_start in TryLowWorkHeadersSync#1565

Open
tomt1664 wants to merge 2 commits into
ElementsProject:masterfrom
tomt1664:trim_headers_untrim_guard
Open

Guard against trimmed chain_start in TryLowWorkHeadersSync#1565
tomt1664 wants to merge 2 commits into
ElementsProject:masterfrom
tomt1664:trim_headers_untrim_guard

Conversation

@tomt1664

Copy link
Copy Markdown
Member

When -trim_headers is enabled, TryLowWorkHeadersSync can receive a chain_start_header pointing to a trimmed block index entry. The HeadersSyncState constructor immediately calls GetBlockHeader() on it via the m_last_header_received initialiser, which hits assert_untrimmed() and aborts the node.

Conditional untrim_to guard added inside TryLowWorkHeadersSync, before HeadersSyncState.

For nodes running -trim_headers, in practice the crash path is not reachable on Elements because already_validated_work is always true on a federated chain (nChainWork == nMinimumChainWork == 0), so TryLowWorkHeadersSync is not entered. But this ensures consistency with guarded serving paths.

TryLowWorkHeadersSync and HeadersSyncState were introduced in Bitcoin v24 (bitcoin/bitcoin#25717) and so this is not applicable to Elements v23.

tomt1664 and others added 2 commits June 26, 2026 15:13
The trim_headers test was previously moved to extended tests, and only
worked with legacy wallets. Update it to work with descriptor wallets,
and move it back to base scripts in functional tests.

@delta1 delta1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK e151cad; tested locally

@psgreco

psgreco commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Does this fix #1106 ?

@delta1

delta1 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Does this fix #1106 ?

Yes I think so

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.

3 participants