diff --git a/nimbus/vm/precompiles.nim b/nimbus/vm/precompiles.nim index 19c41d651..0dd2aed07 100644 --- a/nimbus/vm/precompiles.nim +++ b/nimbus/vm/precompiles.nim @@ -138,10 +138,12 @@ proc modExpInternal(computation: var BaseComputation, base_len, exp_len, mod_len max(adj_exp_len, 1) ) div GasQuadDivisor + computation.gasMeter.consumeGas(gasFee, reason="ModExp Precompile") + block: # Processing # TODO: specs mentions that we should return in "M" format - # i.e. if Base and exp are uint512 and Modulo an uint256 - # we should return a 256-bit big-endian byte array + # i.e. if Base and exp are uint512 and Modulo an uint256 + # we should return a 256-bit big-endian byte array # Force static evaluation func zero(): static array[T.bits div 8, byte] = discard diff --git a/tests/test_precompiles.nim b/tests/test_precompiles.nim index 763683e88..2ed291f09 100644 --- a/tests/test_precompiles.nim +++ b/tests/test_precompiles.nim @@ -39,18 +39,17 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped = proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) = for label, child in fixtures: case toLowerAscii(label) - # of "ecrecover": child.doTest(paEcRecover.ord, ecRecover) - # of "sha256": child.doTest(paSha256.ord, sha256) - # of "ripemd": child.doTest(paRipeMd160.ord, ripemd160) - # of "identity": child.doTest(paIdentity.ord, identity) + of "ecrecover": child.doTest(paEcRecover.ord, ecRecover) + of "sha256": child.doTest(paSha256.ord, sha256) + of "ripemd": child.doTest(paRipeMd160.ord, ripemd160) + of "identity": child.doTest(paIdentity.ord, identity) of "modexp": child.doTest(paModExp.ord, modexp) - # of "bn256add": child.doTest(paEcAdd.ord, bn256ECAdd) - # of "bn256mul": child.doTest(paEcMul.ord, bn256ECMul) - # of "ecpairing": child.doTest(paPairing.ord, bn256ecPairing) + of "bn256add": child.doTest(paEcAdd.ord, bn256ECAdd) + of "bn256mul": child.doTest(paEcMul.ord, bn256ECMul) + of "ecpairing": child.doTest(paPairing.ord, bn256ecPairing) else: #raise newException(ValueError, "Unknown test vector '" & $label & "'") - # echo "Unknown test vector '" & $label & "'" - discard + echo "Unknown test vector '" & $label & "'" suite "Precompiles": jsonTest("PrecompileTests", testFixture)