Fix native protocol reorganized handler: extract header_t not height_t#784
Open
echennells wants to merge 1 commit into
Open
Fix native protocol reorganized handler: extract header_t not height_t#784echennells wants to merge 1 commit into
echennells wants to merge 1 commit into
Conversation
protocol_native::handle_chase's `reorganized` case extracted the event payload as node::height_t, but chaser_confirm::set_reorganized posts a header_link (node::header_t), as documented in chase.hpp and as the sibling `organized` case and do_top(node::header_t) already assume. node::header_t (header_link::integer = uint32_t) and node::height_t (size_t) are distinct alternatives of the event_value variant, so std::get<node::height_t> on a header_t-holding variant throws std::bad_variant_access. handle_chase is NOEXCEPT, so the throw becomes std::terminate: any chain reorganization while a client holds a native `top` subscription crashes the node. Extract node::header_t instead, matching the emitter, the chase.hpp doc comment, the organized sibling, and do_top's signature. Adds two regression tests to test/protocols/native/native_block.cpp: - a non-throwing get_if guard that the reorganized payload is header_t; - a behavioral test driving the reorganized event through the running server (mirrors native__ws_top_subscribe__progressive_notify__expected). Pre-fix the behavioral case aborts via bad_variant_access; post-fix it passes, so the fix and test land in the same commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #783
protocol_native::handle_chase's
reorganizedcase extracted the event payload as node::height_t, but chaser_confirm::set_reorganized posts a header_link (node::header_t), as documented in chase.hpp and as the siblingorganizedcase and do_top(node::header_t) already assume.node::header_t (header_link::integer = uint32_t) and node::height_t (size_t) are distinct alternatives of the event_value variant, so std::getnode::height_t on a header_t-holding variant throws std::bad_variant_access. handle_chase is NOEXCEPT, so the throw becomes std::terminate: any chain reorganization while a client holds a native
topsubscription crashes the node.Extract node::header_t instead, matching the emitter, the chase.hpp doc comment, the organized sibling, and do_top's signature.
Adds two regression tests to test/protocols/native/native_block.cpp: