subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Check for disallowed values

Open Mananitade opened this issue 1 year ago • 1 comments

https://github.com/opentensor/subtensor/blob/b8364014f36b6a72357881cacb0f3462a3fde5a0/pallets/subtensor/src/epoch.rs#L839

The condition "consensus_high <= consensus_low || alpha_low == 0 || alpha_high == 0" is to check for disallowed values, not for division by zero; moreover, division by zero is handled by saturation arithmetic operators.

Mananitade avatar Jun 24 '24 11:06 Mananitade

Saturation maths would not prevent division by zero, as this check helps enforce the sanity checks . I would rather enforce more restrictions (i.e. program defensively) , as in the rare chance a 0 division does get past , the runtime will panic

distributedstatemachine avatar Jun 24 '24 11:06 distributedstatemachine