Repository navigation
Conversation
Collaborator
Author
|
NOTE: there is still some flakiness with tests that I will address in my next PR (which will resolve the underlying/fundamental cause of some test flakiness) |
Collaborator
|
Code looks good to me. Going to rebase this on #360 and if it passes (ignoring unrelated failures), merging this tomorrow. |
Move block_checked.state assertions from inside the match body into if-let guard conditions so the callback skips non-matching events instead of panicking on a legitimate but unexpected state value.
Bitcoin Core's LogError() and LogWarning() emit [error] and [warning] bracket tokens. The log parser was misidentifying these as threadnames or debug categories. Strip known log level markers from metadata items before threadname/category assignment.
0xB10C
force-pushed
the
fix/log-level-filter-and-state-guards
branch
from
March 5, 2026 16:54
5bea68f to
0e35bdb
Compare
Collaborator
|
Collaborator
|
Re-triggering CI (which didn't run due to yesterdays outage) |
Collaborator
|
Thank you! Another intermittent failure squashed! |
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.
Summary
The log line parser in
shared/src/log_matchers.rstreats all[bracketed]metadata tokens as either thread names or debug categories. This breaks when Bitcoin Core emits log level markers viaLogError()andLogWarning(), which produce lines like:The parser would interpret
[error]as a thread name (in the first case) or a debug category (in the second). This is incorrect - it's a severity level emitted byGetLogPrefix()in Bitcoin Core'slogging.cpp.When
-logthreadnames=1is enabled, the thread name bracket and the level bracket appear as two separate tokens (e.g.[msghand] [error]as above), so both cases need handling.This is the root cause behind the flaky
BlockCheckedLogtest failures reported in #366. The nix-coverage CI job captured logs showingthreadname: "error",with[error]having been misinterpreted as a thread name! I also hit this locally while working on #338.This PR adds an
is_standalone_log_level()filter that strips[error]and[warning]from the parsed metadata items before thread name/category assignment. The function is scoped to only these two levels because they are the only ones that appear as standalone bracket tokens under default Bitcoin Core configuration (see the linkedlogging.cpp):LogInfo()produces no bracket at all (GetLogPrefixreturns empty for uncategorised info-level messages)LogDebug()/LogTrace()both require a category argument so they produce[category]or[category:trace]as single bracket tokens, never standalone[debug]or[trace]In a separate commit, the integration tests for
BlockCheckedLogevents are tightened using the same pattern as #354: the state value check (e.g."Valid","bad-witness-nonce-size","bad-txnmrklroot") is moved from anassert_eq!inside the match body into anif-letguard condition. This prevents the callback from panicking on a legitimate but unexpected state value arriving first (it skips non-matching events and waits for the correct one).Fixes #366 🥳
Testing
Four new tests in
shared/src/log_matchers.rs:test_log_matcher_error_level_not_treated_as_threadname- standalone[error]is filtered, not assigned as thread nametest_log_matcher_error_level_with_threadname-[msghand] [error]preserves the real thread name and filters the leveltest_log_matcher_warning_level_filtered- standalone[warning]is filteredtest_is_standalone_log_level- exercises the filter against known levels, non-standalone levels (info,debug,trace), and known non-levels (categories and thread names likenet,validation,msghand)Existing integration tests (
test_integration_logextractor_block_checked,test_integration_logextractor_mutated_block_bad_witness_nonce_size,test_integration_logextractor_mutated_block_bad_txnmrklroot) continue to pass with the guard-style predicates.Full pre-push quality gate (fmt, clippy, unit tests, NATS integration tests) passes.
See green CI via PR opened against my fork: https://github.com/deadmanoz/peer-observer/actions/runs/22381839058