reenable EIP-2565: modExp gas cost

now it's officially included in berlin hard fork
This commit is contained in:
jangko 2021-05-16 19:22:01 +07:00
parent 01a27ff328
commit 6fc3df637c
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 18 additions and 16 deletions

View File

@ -229,20 +229,20 @@ proc modExpFee(c: Computation, baseLen, expLen, modLen: Uint256, fork: Fork): Ga
max(adjExpLen, 1.u256)
) div divisor
# EIP2565: temporary disabled
#let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
#else: gasCalc(mulComplexity, GasQuadDivisor)
# EIP2565: modExp gas cost
let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
else: gasCalc(mulComplexity, GasQuadDivisor)
let gasFee = gasCalc(mulComplexity, GasQuadDivisor)
#let gasFee = gasCalc(mulComplexity, GasQuadDivisor)
if gasFee > high(GasInt).u256:
raise newException(OutOfGas, "modExp gas overflow")
result = gasFee.truncate(GasInt)
# EIP2565: temporary disabled
#if fork >= FkBerlin and result < 200.GasInt:
# result = 200.GasInt
# EIP2565: modExp gas cost
if fork >= FkBerlin and result < 200.GasInt:
result = 200.GasInt
proc modExp*(c: Computation, fork: Fork = FkByzantium) =
## Modular exponentiation precompiled contract

View File

@ -239,20 +239,20 @@ proc modExpFee(c: Computation, baseLen, expLen, modLen: Uint256, fork: Fork): Ga
max(adjExpLen, 1.u256)
) div divisor
# EIP2565: temporary disabled
#let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
#else: gasCalc(mulComplexity, GasQuadDivisor)
# EIP2565: modExp gas cost
let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
else: gasCalc(mulComplexity, GasQuadDivisor)
let gasFee = gasCalc(mulComplexity, GasQuadDivisor)
# let gasFee = gasCalc(mulComplexity, GasQuadDivisor)
if gasFee > high(GasInt).u256:
raise newException(OutOfGas, "modExp gas overflow")
result = gasFee.truncate(GasInt)
# EIP2565: temporary disabled
#if fork >= FkBerlin and result < 200.GasInt:
# result = 200.GasInt
# EIP2565: modExp gas cost
if fork >= FkBerlin and result < 200.GasInt:
result = 200.GasInt
proc modExp*(c: Computation, fork: Fork = FkByzantium) =
## Modular exponentiation precompiled contract

View File

@ -129,5 +129,7 @@ func skipNewBCTests*(folder: string, name: string): bool =
]
func skipPrecompilesTests*(folder: string, name: string): bool =
# EIP2565: temporary disabled
name == "modexp_eip2565.json"
# EIP2565: modExp gas cost
# reason: included in berlin
# name == "modexp_eip2565.json"
return false