refactor: drop Container.to_hex and write-only validator lag counters#760
Open
tcoratger wants to merge 1 commit into
Open
refactor: drop Container.to_hex and write-only validator lag counters#760tcoratger wants to merge 1 commit into
tcoratger wants to merge 1 commit into
Conversation
Two more audit deletes. types/container.py: Container.to_hex had one production caller in xmss/containers.py inside the JSON field serializer; that single call inlines to value.encode_bytes().hex(). Eleven test sites in test_containers.py rewritten the same way. from_hex stays — two production callers depend on it. validator/service.py: _blocks_skipped_lag and _attestations_skipped_lag were write-only counters incremented in the duty loop and never read in production. Their public properties already left in an earlier pass, and the audit's expose-vs-delete question lands on delete since there is no metrics surface for them. The _duty_gate_closed flag stays — it is a real state-machine reader. The dedicated test_counters_split_block_and_attestation retires with the counters; the two run-loop tests keep their block_calls / attest_calls assertions, which are the actual behavioural checks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Two audit-delete items.
types/container.py—Container.to_hexremovedOnly one production caller (
xmss/containers.py:162inside the JSON field serializer). Inlined tovalue.encode_bytes().hex()at that site; eleven test sites intest_containers.pyrewritten the same way.from_hexstays — it has two production callers in the same file.subspecs/validator/service.py— write-only lag counters removed_blocks_skipped_lagand_attestations_skipped_lagwere incremented in the duty loop but never read in production. Their public property wrappers retired in PR #757; the audit's expose-vs-delete question lands on delete because there's no metrics surface for them. The_duty_gate_closedflag stays — it's a real state-machine reader.Test impact:
test_counters_split_block_and_attestationretires with the counters (its entire purpose was the gate-doesn't-move-counters invariant).test_run_loop_skips_*tests keep theirblock_calls == []/attest_calls == []assertions, which verify the actual behaviour; the counter-equality assertions retire.Skipped audit items (with reasons)
IntFieldElement+ JSON branchFpa Pydantic core schema with a plain serializer. Same conclusion as PR #757 — deferred._htr_bytes/bytearray/memoryviewoverloadsbytesfields inside containers. Deleting them broke 84 fixture tests._NullObserver+ public re-export_NullObserverand no longer insubspecs/observability/__init__.py.Spec*TypeProtocols_buffered_eventsconnect()awaits the handshake event, then yields beforeprotocol.connection = connduring which more events can arrive. The server already uses_on_handshaketo assign the wrapper synchronously; the client doesn't. Removing the buffer is the architectural refactor deferred in PR #756.Test plan
ruff check,ruff format --check,ty check— all clean.uv run pytest tests/lean_spec/subspecs/xmss/test_containers.py tests/lean_spec/subspecs/validator/test_service.py— 71 tests pass.uv run fill tests/consensus/lstar/fc/test_tick_system.py::test_tick_interval_progression_through_full_slot --fork=Lstar— 1 passed in 9.16s.🤖 Generated with Claude Code