Skip to content

fix: correct UID 0 classification in WeightSetter.process_weights#320

Open
ProjectNobi wants to merge 1 commit intoAffineFoundation:mainfrom
ProjectNobi:fix/weight-setter-uid-zero-classification
Open

fix: correct UID 0 classification in WeightSetter.process_weights#320
ProjectNobi wants to merge 1 commit intoAffineFoundation:mainfrom
ProjectNobi:fix/weight-setter-uid-zero-classification

Conversation

@ProjectNobi
Copy link
Copy Markdown

Summary

In WeightSetter.process_weights, the condition for classifying system miners is:

if uid < 0 or uid > 1000:
    # System miner (uid <= 0 or uid > 1000): accumulate weight for UID 0

The comment (and the docstring above) both state the intent is uid <= 0, but the code uses uid < 0. This means UID 0 — the burn/validator address — is incorrectly treated as a regular miner rather than being accumulated into system_weight_total.

The consequence: if UID 0 appears in an api_weights payload, it bypasses the accumulation path and is added directly to the chain weight list, potentially causing its weight to be double-counted when extra_weight is later appended to UID 0 in the final step.

Change

-if uid < 0 or uid > 1000:
+if uid <= 0 or uid > 1000:

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)

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)
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.

1 participant