Skip to content

Guard against trimmed chain_start in TryLowWorkHeadersSync#1565

Open
tomt1664 wants to merge 1 commit into
ElementsProject:masterfrom
tomt1664:trim_headers_untrim_guard
Open

Guard against trimmed chain_start in TryLowWorkHeadersSync#1565
tomt1664 wants to merge 1 commit 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.

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