Skip to content

Align BlockFetch.Decision and ClientMetrics namespaces with what is emitted - #6669

Open
pucedoteth wants to merge 1 commit into
IntersectMBO:masterfrom
pucedoteth:fix-blockfetch-decision-namespaces
Open

Align BlockFetch.Decision and ClientMetrics namespaces with what is emitted#6669
pucedoteth wants to merge 1 commit into
IntersectMBO:masterfrom
pucedoteth:fix-blockfetch-decision-namespaces

Conversation

@pucedoteth

Copy link
Copy Markdown

Description

Fixes #6667, taking the localized approach @mgmeier suggested there — restoring consistency across usage, documentation and configuration inside the existing pattern, rather than deriving all three from one place.

BlockFetch.Decision. Consensus.blockFetchDecisionTracer has carried TraceDecisionEvent since ouroboros-consensus-4.1.0.0, and Tracers.hs:385 wires that field, so the node emits PeersFetch and PeerStarvedUs. Both declaration sites still spelled the pre-TraceDecisionEvent type by hand:

Logging.Trace IO [BlockFetch.TraceLabelPeer remotePeer (FetchDecision [Point (Header blk)])]

whose namespaces are EmptyPeersFetch, Accept and Decline. So the three documented namespaces can never fire, and the two that do fire are unknown to checkTraceConfiguration — they cannot be re-levelled or silenced from a config file.

BlockFetch.Client.ClientMetrics had the mirror-image problem: composed onto the blockfetch client tracer in Tracers.hs:389 and documented at the ["BlockFetch","Client"] prefix, but absent from getAllNamespaces, so naming it in a configuration produced a Config namespace error.

Both sites are now annotated with the record's own type, ClientMetrics is added at the BlockFetch.Client prefix, and newNamespaces.txt is updated accordingly (Accept/Decline/EmptyPeersFetch out, PeerStarvedUs/PeersFetch in; the file stays C-locale sorted).

The Ouroboros.Network.BlockFetch.Decision import is dropped from both modules, since FetchDecision was its only use in either and cabal.project sets -Werror.

Notes for the reviewer

I could not build this. I have no GHC/cabal toolchain available, and a cardano-node build needs libsodium/secp256k1/blst besides. Rather than guess, here is what I did check statically — please let CI be the judge:

  • ClientMetrics is exported from Cardano.Node.Tracing.Tracers.Consensus (export list line 21), so the new import in Consistency.hs resolves.
  • No import cycle: Tracers.Consensus does not import Consistency, and it was already reachable via Consistency -> Documentation -> Tracers.Consensus.
  • Dropping the Decision import is safe in both modules: FetchDecision was its only symbol in use, while Point (from Ouroboros.Network.Block) and the qualified BlockFetch. (from BlockFetch.ClientState) are still used 12x/7x and 26x respectively, so those imports stay live.
  • TraceDecisionEvent is spelled exactly as Tracers/Consensus.hs:79 imports it, and applied at the arity used by the MetaTrace instance at line 657 and the consensus record field.
  • Import lines follow the surrounding stylish-haskell alignment.

I have not run hlint or stylish-haskell either, for the same reason.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
    • The namespace consistency check is itself the test here: checkTraceConfiguration compares getAllNamespaces against the configuration, and newNamespaces.txt is the golden list this PR updates.
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated — not applicable, no dependency change
  • CI passes. See note above: I could not run the build or the linters locally.

…mitted

blockFetchDecisionTracer has carried TraceDecisionEvent since
ouroboros-consensus-4.1.0.0, and Tracers.hs wires that field, so the node
emits PeersFetch and PeerStarvedUs under BlockFetch.Decision. Both
declaration sites still spelled the pre-TraceDecisionEvent type by hand,
so documentation and the config check knew only EmptyPeersFetch, Accept
and Decline.

The effect is that the three documented namespaces can never fire, while
the two that do fire are unknown to checkTraceConfiguration and so cannot
be re-levelled or silenced from a config file.

BlockFetch.Client.ClientMetrics had the mirror-image problem: it is
composed onto the blockfetch client tracer and documented, but
getAllNamespaces never mentioned it, so naming it in a configuration
produced a Config namespace error.

Annotate both sites with the record's own type and add a ClientMetrics
entry at the BlockFetch.Client prefix, then regenerate the namespace
list. The now-unused Ouroboros.Network.BlockFetch.Decision import goes
with it, since FetchDecision was its only use in either module.

Fixes IntersectMBO#6667
@pucedoteth
pucedoteth requested review from a team as code owners August 29, 2026 01:58
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.

[BUG] - BlockFetch.Decision documents namespaces that can never fire, and BlockFetch.Client.ClientMetrics is unknown to the config check

1 participant