diff --git a/test/state/precompiles.cpp b/test/state/precompiles.cpp index aec0f5c3db..81c1d3576e 100644 --- a/test/state/precompiles.cpp +++ b/test/state/precompiles.cpp @@ -46,18 +46,17 @@ int64_t bls_msm_cost(size_t k, int64_t multiplication_cost) noexcept { assert(k > 0); - constexpr auto MAX_DISCOUNT = 174; - constexpr int64_t MULTIPLIER = 1000; - constexpr int16_t discount[128] = {1200, 888, 764, 641, 594, 547, 500, 453, 438, 423, 408, 394, - 379, 364, 349, 334, 330, 326, 322, 318, 314, 310, 306, 302, 298, 294, 289, 285, 281, 277, - 273, 269, 268, 266, 265, 263, 262, 260, 259, 257, 256, 254, 253, 251, 250, 248, 247, 245, - 244, 242, 241, 239, 238, 236, 235, 233, 232, 231, 229, 228, 226, 225, 223, 222, 221, 220, - 219, 219, 218, 217, 216, 216, 215, 214, 213, 213, 212, 211, 211, 210, 209, 208, 208, 207, - 206, 205, 205, 204, 203, 202, 202, 201, 200, 199, 199, 198, 197, 196, 196, 195, 194, 193, - 193, 192, 191, 191, 190, 189, 188, 188, 187, 186, 185, 185, 184, 183, 182, 182, 181, 180, - 179, 179, 178, 177, 176, 176, 175, 174}; - - const auto d = k <= 128 ? discount[k - 1] : MAX_DISCOUNT; + static constexpr int64_t MULTIPLIER = 1000; + static constexpr int16_t DISCOUNT[128] = {1200, 888, 764, 641, 594, 547, 500, 453, 438, 423, + 408, 394, 379, 364, 349, 334, 330, 326, 322, 318, 314, 310, 306, 302, 298, 294, 289, 285, + 281, 277, 273, 269, 268, 266, 265, 263, 262, 260, 259, 257, 256, 254, 253, 251, 250, 248, + 247, 245, 244, 242, 241, 239, 238, 236, 235, 233, 232, 231, 229, 228, 226, 225, 223, 222, + 221, 220, 219, 219, 218, 217, 216, 216, 215, 214, 213, 213, 212, 211, 211, 210, 209, 208, + 208, 207, 206, 205, 205, 204, 203, 202, 202, 201, 200, 199, 199, 198, 197, 196, 196, 195, + 194, 193, 193, 192, 191, 191, 190, 189, 188, 188, 187, 186, 185, 185, 184, 183, 182, 182, + 181, 180, 179, 179, 178, 177, 176, 176, 175, 174}; + + const auto d = DISCOUNT[std::min(k, std::size(DISCOUNT)) - 1]; return (static_cast(k) * multiplication_cost * d) / MULTIPLIER; }