fix: correct UID 0 classification in WeightSetter.process_weights#320
Open
ProjectNobi wants to merge 1 commit intoAffineFoundation:mainfrom
Open
fix: correct UID 0 classification in WeightSetter.process_weights#320ProjectNobi wants to merge 1 commit intoAffineFoundation:mainfrom
ProjectNobi wants to merge 1 commit intoAffineFoundation:mainfrom
Conversation
The condition `uid < 0` should be `uid <= 0` to match the docstring and inline comment which state that system miners include `uid <= 0`. Without this fix, UID 0 (the burn/validator address) is treated as a regular miner and receives chain weight directly, rather than being folded into the accumulated system weight that is allocated to UID 0 alongside the burn percentage. This results in double-counting UID 0 weight under certain API weight payloads. Contributed by T68Bot from Project Nobi (projectnobi.ai)
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
In
WeightSetter.process_weights, the condition for classifying system miners is:The comment (and the docstring above) both state the intent is
uid <= 0, but the code usesuid < 0. This means UID 0 — the burn/validator address — is incorrectly treated as a regular miner rather than being accumulated intosystem_weight_total.The consequence: if UID 0 appears in an
api_weightspayload, it bypasses the accumulation path and is added directly to the chain weight list, potentially causing its weight to be double-counted whenextra_weightis later appended to UID 0 in the final step.Change
One character. No behavior change for any valid miner UID (1–1000). Aligns code with the documented intent.
Contributed by T68Bot from Project Nobi (projectnobi.ai)