Skip to content

anounciness metric for peer selection#53

Open
coot wants to merge 7 commits intomainfrom
coot/sig-metric
Open

anounciness metric for peer selection#53
coot wants to merge 7 commits intomainfrom
coot/sig-metric

Conversation

@coot
Copy link
Copy Markdown
Contributor

@coot coot commented Apr 21, 2026

List of changes

This PR introduces announcyness metric for peer selection which is used to
decide which hot peers we should demote.

For each peer we count how many valid signatures were announced before any
other peer announced it. This is implemented into two steps: first we account
at which time a peer announce a given signature id, then once we receive the
corresponding signature, and it turns out to be valid, we give a score of one
to the peer that announced it first. Each score is kept for an hour (the same
as churn rate).

Checklist

  • related issue
  • My changes generate no new warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

@github-project-automation github-project-automation Bot moved this to In Progress in Ouroboros Network Apr 21, 2026
@coot coot linked an issue Apr 21, 2026 that may be closed by this pull request
@coot coot force-pushed the coot/sig-metric branch 2 times, most recently from 6a60f59 to 24d0083 Compare April 21, 2026 15:07
@coot coot force-pushed the coot/sig-metric branch from 24d0083 to 6268bbd Compare May 8, 2026 14:47
@coot coot marked this pull request as ready for review May 8, 2026 14:47
coot and others added 6 commits May 8, 2026 17:12
Adds a property test that verifies `announciness peerMetric` agrees with
a standalone pure model at every metric-state snapshot emitted during the
simulation.

Key design choices:
- `runSigSubmissionV2WithMetric` (IOSim-specific, leaves the generic
  `runSigSubmissionV2` untouched) wires a real `PeerMetric` into each
  inbound peer and registers a `traceTVarIO` callback on the metric TVar.
- Both peer events (`TraceTxInboundReceivedTxIds`, `TraceTxInboundAddedToMempool`)
  and metric snapshots are emitted as a single `SimTraceEvent = Either
  SimInboundEvent SimMetricSnapshot` type.  A single
  `selectTraceEventsDynamicWithTime` call then extracts them in their
  original in-thread order, preserving the `sig_add → snapshot →
  sig_add → snapshot` interleaving that two separate extraction passes
  would destroy.
- The pure model (`PureModelState`, `updatePureModel`,
  `expectedAnnounciness`) is decoupled from the implementation and
  mirrors `reportSigImpl` independently.
- `peerMetricVar` (field accessor) exported from `PeerMetric` for
  testing; constructor remains unexported.
- `TraceTxInboundReceivedTxIds` trace added at both sigid-receipt sites
  in `sigSubmissionInbound`.
- `SimPeerAddr ~ Int` enforced via type equality so a type change causes
  a compile error rather than silently empty traces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coot coot force-pushed the coot/sig-metric branch from 6268bbd to eb59e7b Compare May 8, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Churn metric

1 participant