fix(validator): align event watcher busy state with reservations and TTL#327
Open
thomascolden585-svg wants to merge 1 commit into
Open
Conversation
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
Closes ##326
Aligns
ContractEventWatcherbusy tracking with on-chain reservations as well as swaps:MinerReserved/ReservationCancelled, bootstrap fromget_miner_reserved_untilwhen there is no active swap row, and a synthetic busy-1atreserved_until + 1because the contract clears expired reservations lazily with no event.Crown-time replay now treats a reserved miner (including reservation-only episodes with no
SwapInitiated) as busy through the correct block range, so crown credit flows to the next eligible miner until the reservation lapses or is cancelled.Changes
allways/validator/event_watcher.pyMinerReserved,ReservationCancelled, andSwapInitiatedtransitions so reservation busy and swap busy do not double-count.RESERVATION_TTL_BLOCKS), withbootstrapped_reserved_minersso replay does not apply a second+1._apply_reservation_expiry_syntheticsduringsync_toto emit the missing busy-1at reservation expiry.reserved_untilonTimeoutExtensionFinalizedwhen the miner is in reservation-only busy state.tests/test_event_watcher.py: unit tests for reservation busy, cancel, swap handoff, and bootstrap replay.tests/test_scoring_v1.py: integration-style crown replay test where the best-rate miner is reserved without a swap and the runner-up receives crown share until expiry.How to test
(Full suite:
uv run pytest tests/)Checklist
uv run pytest tests/)uv run ruff check allways/ neurons/)Related