Skip to content

Research: Testing plan for #4 (reputation-adjusted weight) and #5 (circuit breaker + probe recovery) #11

Description

@mingles-agent

Background

Goal

Design a comprehensive, layered test plan for issues #4 and #5 before they go to implementation. The plan must give confidence that the changes work correctly in isolation AND in the live network scenario.

Changes Being Tested

Issue #4 — Reputation-adjusted selection weight

  • addEpochMembers in module.go: selection weight = stakeWeight * reputation / 100 (floor 1%)
  • New helper calculateSelectionWeight
  • Affects: which nodes get how much executor traffic each epoch

Issue #5 — Intra-epoch circuit breaker + cooldown/probe recovery

  • New state machine: HEALTHY → EXCLUDED → PROBE → HEALTHY/re-EXCLUDED
  • createHealthFilterFn in query_get_random_executor.go
  • New keeper: CircuitBreakerState per-participant, cleared on epoch boundary
  • Feedback hooks in MsgFinishInference and EndBlock/handleInferenceExpiry
  • New ValidationParams: miss threshold (25%), min samples (4), initial cooldown (50 blocks), max cooldown (500 blocks)

Test Infrastructure Available

Unit tests (Go): inference-chain/x/inference/keeper/*_test.go

  • Pattern: keepertest.InferenceKeeper(t) gives keeper + context
  • Mock-based, fast, no chain needed
  • Example: participant_test.go, participant_status_test.go

Integration/E2E tests (Kotlin/Testermint): testermint/src/test/kotlin/

  • Full cluster spun up via initCluster(reboot = true)
  • Real epoch transitions, real inference flows
  • Relevant existing tests: InferenceTests.kt, InferenceFailureAccountingTests.kt, ValidationTests.kt, MultiNodeTests.kt, ParticipantPowerTests.kt
  • Test isolation via genesis spec overrides (e.g. ValidationParams can be set in genesis for test params)

What to Investigate

1. Unit test scenarios for #4 (reputation weight)

Map out test cases for calculateSelectionWeight and addEpochMembers:

  • reputation=100 → weight = stakeWeight (no change)
  • reputation=50 → weight = stakeWeight * 0.5
  • reputation=0 → weight = floor (1% of stakeWeight)
  • reputation=1 → weight = floor or 1% (boundary)
  • Multiple participants with different reputations: verify relative selection probability distribution
  • Does existing GetRandomMemberForModel test cover weighted selection? Check inference-chain/x/inference/keeper/ for existing random executor tests

2. Unit test scenarios for #5 (circuit breaker)

Map out all state machine transitions:

  • HEALTHY → EXCLUDED: miss rate > 25%, ≥4 samples triggers exclusion
  • HEALTHY: miss rate > 25% but <4 samples → NOT excluded (insufficient data)
  • HEALTHY: miss rate ≤ 25% with any sample count → stays HEALTHY
  • EXCLUDED: cooldown not passed → still excluded from filter
  • EXCLUDED: cooldown passed → promoted to PROBE
  • PROBE → HEALTHY: successful inference recorded
  • PROBE → EXCLUDED: miss → doubles cooldown
  • PROBE → EXCLUDED (3rd time): cooldown = initial × 4, capped at max
  • All-degraded fallback: all nodes excluded → filter returns original list (no empty pool)
  • Epoch boundary: all CB state cleared regardless of current state

3. Integration test scenarios (Testermint)

Examine existing tests to understand how to set up controlled miss scenarios:

  • How does InferenceFailureAccountingTests.kt simulate node failures?
  • How does ValidationTests.kt verify participant status changes?
  • How are ValidationParams overridden in test genesis specs?

Propose Testermint test scenarios:

  • Scenario A (reputation weight): Two nodes, different reputation histories (manipulate EpochPerformanceSummary). Verify over 100 inference requests that high-reputation node receives ~2× more requests than 50-reputation node
  • Scenario B (fast exclusion): One node starts missing inferences (simulate via node shutdown or mock). Verify it stops receiving requests within 4 misses, not after SPRT threshold
  • Scenario C (probe recovery): Excluded node's cooldown expires → verify it receives exactly one probe inference → bring node back up → verify HEALTHY state and normal traffic resumes
  • Scenario D (exponential backoff): Node keeps failing probes → verify cooldown doubles each time up to max
  • Scenario E (network resilience): All nodes briefly offline → verify filter fallback prevents empty pool, traffic resumes when any node recovers

4. Param testing

How to test with non-default params (e.g., lower min_samples=2 for faster test execution):

  • Identify if ValidationParams can be overridden in Testermint genesis spec (check SpecTests.kt and TestUtils.kt)
  • What's the minimum epoch length for integration tests? (affects cooldown block counts — may need to set health_cb_initial_cooldown_blocks very low, e.g. 5 blocks for tests)

5. Regression risks

What existing behavior could break:

  • GetRandomExecutor returning empty result (most critical — network stops)
  • Nodes incorrectly excluded due to param misconfiguration
  • CB state not cleared on epoch boundary (nodes permanently excluded)
  • Reputation calculation regression affecting existing nodes' weights
  • Interaction between Reputation-adjusted executor selection weight at epoch start #4 weight changes and SPRT (SPRT removes nodes entirely, weight system just reduces probability — ensure they don't conflict)

Check: are there existing tests for GetRandomExecutor that need updating?

Key Files

  • inference-chain/x/inference/keeper/participant_test.go — unit test patterns
  • inference-chain/x/inference/keeper/participant_status_test.go — SPRT test patterns
  • testermint/src/test/kotlin/InferenceFailureAccountingTests.kt — failure simulation
  • testermint/src/test/kotlin/ValidationTests.kt — participant status E2E
  • testermint/src/test/kotlin/MultiNodeTests.kt — multi-node scenarios
  • testermint/src/test/kotlin/ParticipantPowerTests.kt — power/weight tests
  • testermint/src/test/kotlin/TestUtils.kt — test helpers

Deliverables

  1. Unit test specification: exact test function names + inputs/assertions for all cases in Reputation-adjusted executor selection weight at epoch start #4 and Intra-epoch fast circuit breaker with cooldown + probe traffic recovery #5
  2. Testermint integration test specification: test class names, setup, assertions, required genesis param overrides
  3. Regression test checklist: which existing tests to run + any that need updating
  4. Test execution order: what to run in CI vs manual validation
  5. Create implementation task: "Write tests for Reputation-adjusted executor selection weight at epoch start #4 and Intra-epoch fast circuit breaker with cooldown + probe traffic recovery #5 per test plan"

Focus Areas

  • unit test patterns in keeper_test
  • testermint integration test setup
  • controlled miss simulation
  • genesis param overrides for test
  • regression risks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions