Skip to content

chore: circuit breaker follow-up cleanup#32

Open
mingles-agent wants to merge 1 commit intomainfrom
feature/30-cleanup-circuit-breaker
Open

chore: circuit breaker follow-up cleanup#32
mingles-agent wants to merge 1 commit intomainfrom
feature/30-cleanup-circuit-breaker

Conversation

@mingles-agent
Copy link
Copy Markdown

Summary

Follow-up cleanup items from the reviewer's feedback on the circuit breaker + reputation-adjusted selection PR (reviewed in issue #30).

Changes

  1. Remove dead CircuitBreakerStatePrefix (types/keys.go) — The collections.NewPrefix(53) variable was defined but never referenced; all CB store access uses the string-based CircuitBreakerStateKey with KeyPrefix() consistently. A comment now reserves prefix 53 to prevent accidental reuse.

  2. Nil guard in buildSelectionWeightsMap (epochgroup/random.go) — Adds a defensive eg.GroupData == nil check to prevent a nil-pointer panic. In practice GroupData is always set by NewEpochGroup, but the guard is cheap and makes the invariant explicit.

  3. Document zero-value governance param caveat (keeper/circuit_breaker.go) — getCBParams treats zero as "unset" (falls back to compile-time defaults). This means operators cannot disable CB enforcement by setting a param to 0 via governance. The new comment explains why (0 would exclude every node) and recommends using large values instead.

Addresses issue #30

- Remove dead CircuitBreakerStatePrefix (prefix 53) from keys.go; the
  implementation already uses string-based CircuitBreakerStateKey with
  KeyPrefix() consistently. Reserved comment added so prefix 53 is not
  reused accidentally.

- Add nil guard in buildSelectionWeightsMap() for eg.GroupData == nil;
  defensive change to prevent a nil-dereference panic in the unlikely
  case EpochGroup is constructed without NewEpochGroup().

- Document zero-value governance param caveat in getCBParams(): setting
  any CB param to 0 via governance silently falls back to compile-time
  defaults. Prefer large values (e.g. CbMissThresholdPct=100) to disable
  threshold enforcement rather than zero.

Addresses reviewer follow-up from issue #30.
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.

1 participant