refactor(networking): drop tests-only PeerInfo fields#756
Merged
tcoratger merged 1 commit intoMay 22, 2026
Merged
Conversation
The last_seen field, update_last_seen method, and fork_digest property had no production callers. Grep confirmed every read or write came from test_peer.py; the spec code that needs a peer's fork-digest reads it from the cached ENR's eth2 data directly. Test file rewritten: - Three fork_digest tests retire along with the property. - Two duplicate update_last_seen tests retire along with the field. - The _make_enr_with_eth2 helper retires (only those tests used it). - Five now-unused imports drop (time, ENR, FAR_FUTURE_EPOCH, EnrKey, Bytes64, SeqNumber). - test_enr_and_status_fields and test_status_can_be_set stay since the enr and status fields stay. The audit's sibling item (transport/quic/connection.py _buffered_events / _replay_buffered_events) is a real architectural refactor with deep test impact; it stays for a separate PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PeerInfo.last_seen(field),PeerInfo.update_last_seen(method), andPeerInfo.fork_digest(property) had no production callers — every read or write came fromtest_peer.py. The spec code that needs a peer's fork-digest reads it from the cached ENR's eth2 data directly.src/lean_spec/subspecs/networking/peer.py(−19): three members removed plus the now-unusedfield/timeimports andForkDigestre-export.tests/lean_spec/subspecs/networking/test_peer.pyrewritten:test_fork_digest_*tests retire along with the property.test_update_last_seen*tests retire along with the field._make_enr_with_eth2helper retires (only those tests used it).time,ENR,FAR_FUTURE_EPOCH,EnrKey,Bytes64,SeqNumber).test_enr_and_status_fieldsandtest_status_can_be_setstay sinceenrandstatusfields stay.Why not the sibling audit item
The other half of the audit entry (
transport/quic/connection.py:208-256—_buffered_events/_replay_buffered_events) is annotated "refactor connection assignment to remove need". It is not a mechanical delete: the buffer exists to handle a real race where peer-initiated streams arrive betweenHandshakeCompletedand theQuicConnectionwrapper assignment on the client path. The proper fix is to mirror the server's pattern and assign the wrapper synchronously insidequic_event_receivedvia an_on_handshakecallback. That refactor would retire 5+ buffer-specific tests and rewrite ~6 others, so it belongs in its own PR.Test plan
ruff check src/lean_spec/subspecs/networking/peer.py tests/lean_spec/subspecs/networking/test_peer.py— clean.uv run pytest tests/lean_spec/subspecs/networking/test_peer.py— 12 tests pass.grep -rn "\.last_seen\|update_last_seen\|PeerInfo.*fork_digest"acrosssrc/,tests/,packages/— no remaining references outside the test file.🤖 Generated with Claude Code