Skip to content

feat: add validator sync-lag duty gate#708

Open
shariqnaiyer wants to merge 4 commits intoleanEthereum:mainfrom
shariqnaiyer:feature/shariqnaiyer/lean-gates
Open

feat: add validator sync-lag duty gate#708
shariqnaiyer wants to merge 4 commits intoleanEthereum:mainfrom
shariqnaiyer:feature/shariqnaiyer/lean-gates

Conversation

@shariqnaiyer
Copy link
Copy Markdown
Collaborator

@shariqnaiyer shariqnaiyer commented May 5, 2026

🗒️ Description

Fixes: #689

🔗 Related Issues or PRs

✅ Checklist

  • Ran tox checks to avoid unnecessary CI fails:
    uvx tox
  • Considered adding appropriate tests for the changes.
  • Considered updating the online docs in the ./docs/ directory.

@tcoratger
Copy link
Copy Markdown
Collaborator

@shariqnaiyer Is it ready to review?

@shariqnaiyer shariqnaiyer marked this pull request as ready for review May 11, 2026 01:01
@shariqnaiyer shariqnaiyer force-pushed the feature/shariqnaiyer/lean-gates branch from f7bb8c9 to de3c8f3 Compare May 11, 2026 01:02
@shariqnaiyer
Copy link
Copy Markdown
Collaborator Author

Ready for review

shariqnaiyer and others added 3 commits May 10, 2026 19:52
Address review findings on the sync-lag duty gate.

Decision logic
- Replace peer-reported head-slot signal with local-store evidence:
  the freshest slot across blocks already validated into the store.
  Drops the unauthenticated peer.status.head.slot path entirely.
- Add NETWORK_STALL_THRESHOLD (= 2 * SYNC_LAG_THRESHOLD) distinct
  from the local threshold so jitter at the local boundary cannot
  also trip the network-wide branch.
- Add HYSTERESIS_BAND so a closed gate reopens only when lag drops
  to threshold - band, preventing slot-over-slot flap.
- Persist gate state on the service; log only on state transitions
  instead of every query.
- Saturate the future-head case at zero lag rather than trusting
  the chain unconditionally.

API and types
- duty parameter typed as Literal["block", "attestation"].
- Split _duties_skipped_lag into _blocks_skipped_lag and
  _attestations_skipped_lag, owned by the run loop. Attribution
  flattened so wrong-interval slots never tick the gate counter.
- Drop redundant int(slot) casts where Slot arithmetic suffices.
- Remove PeerManager.get_network_head_slot and its tests now that
  no caller remains.

Tests
- Replace patch.object(PeerManager, ...) mocks with real
  PeerManager and store manipulation, matching repo policy.
- New helpers preserve the block-map key-equals-root invariant.
- Add hysteresis flap test, split-counter test, transition-only
  log assertion. Use substring checks instead of exact log strings.

Documentation
- Constants, gate method, properties, fields, and inline comments
  rewritten per /doc rules: structured Why/Effect/Decision matrix
  labels, one idea per line, no function or variable names in
  prose, concrete numbers throughout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Add validator sync-lag duty gate

2 participants