Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: u512 on reward computation (#10909)
Fix overflow found at https://near.zulipchat.com/#narrow/stream/422293-core.2Fstake-wars-iv/topic/StatelessNet.20v84.20issue/near/430321806. It happened with values ``` epoch_validator_reward = 1303530277894885217220048460336356 uptime_numer = 5149480000 stake = 19417599724822422137067484572677335 ``` and `log2(epoch_validator_reward * uptime_numer * stake) is ~= 256.17`, so it couldn't fit in `U256`. However, it can fit in U512, because epoch_validator_reward and stake are Balances = u128; uptime_numer fits in u64. Note that final conversion to u128 is valid because uptime_numer/uptime_denom and stake/total_stake are <= 1. Co-authored-by: Longarithm <the.aleksandr.logunov@gmail.com>
- Loading branch information