consensus-specs
consensus-specs copied to clipboard
Simplify spec by adding safe math functions
The two that immediately come to mind, with multiple use cases already in the spec, are:
def safe_modulo_subtract(a, b, modulus):
return (a + modulus - b) % modulus
def safe_a_mul_b_div_c(a, b, c, increment):
return (a // increment) * b // (c // increment)