fix precompiles selection, GST +5
This commit is contained in:
parent
112d2219df
commit
26b40f41e3
|
@ -2377,13 +2377,13 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
|
|||
ecpairing_two_point_match_5.json Skip
|
||||
ecpairing_two_point_oog.json Skip
|
||||
ecpairing_two_points_with_one_g2_zero.json Skip
|
||||
pairingTest.json Skip
|
||||
pointAdd.json Skip
|
||||
pointAddTrunc.json Skip
|
||||
pointMulAdd.json Skip
|
||||
pointMulAdd2.json Skip
|
||||
+ pairingTest.json OK
|
||||
+ pointAdd.json OK
|
||||
+ pointAddTrunc.json OK
|
||||
+ pointMulAdd.json OK
|
||||
+ pointMulAdd2.json OK
|
||||
```
|
||||
OK: 0/133 Fail: 0/133 Skip: 133/133
|
||||
OK: 5/133 Fail: 0/133 Skip: 128/133
|
||||
## stZeroKnowledge2
|
||||
```diff
|
||||
ecadd_0-0_0-0_21000_0.json Skip
|
||||
|
@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133
|
|||
OK: 0/130 Fail: 0/130 Skip: 130/130
|
||||
|
||||
---TOTAL---
|
||||
OK: 1433/2334 Fail: 0/2334 Skip: 901/2334
|
||||
OK: 1438/2334 Fail: 0/2334 Skip: 896/2334
|
||||
|
|
|
@ -182,15 +182,17 @@ proc applyMessage*(computation: var BaseComputation, opCode: static[Op]) =
|
|||
if computation.gasMeter.gasRemaining < 0:
|
||||
computation.commit()
|
||||
return
|
||||
|
||||
|
||||
let fork = computation.getFork
|
||||
|
||||
try:
|
||||
executeOpcodes(computation)
|
||||
if not computation.execPrecompiles(fork):
|
||||
executeOpcodes(computation)
|
||||
except:
|
||||
let msg = getCurrentExceptionMsg()
|
||||
computation.setError(&"applyMessage Error msg={msg}, depth={computation.msg.depth}", true)
|
||||
|
||||
if computation.isSuccess and computation.msg.isCreate:
|
||||
let fork = computation.getFork
|
||||
if computation.isSuccess and computation.msg.isCreate:
|
||||
let contractFailed = not computation.writeContract(fork)
|
||||
if contractFailed and fork == FkHomestead:
|
||||
computation.setError(&"writeContract failed, depth={computation.msg.depth}", true)
|
||||
|
|
|
@ -247,12 +247,10 @@ macro genHomesteadDispatch(computation: BaseComputation): untyped =
|
|||
result = opTableToCaseStmt(HomesteadOpDispatch, computation)
|
||||
|
||||
proc frontierVM(computation: var BaseComputation) =
|
||||
if not computation.execPrecompiles:
|
||||
genFrontierDispatch(computation)
|
||||
genFrontierDispatch(computation)
|
||||
|
||||
proc homesteadVM(computation: var BaseComputation) =
|
||||
if not computation.execPrecompiles:
|
||||
genHomesteadDispatch(computation)
|
||||
genHomesteadDispatch(computation)
|
||||
|
||||
proc executeOpcodes(computation: var BaseComputation) =
|
||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import
|
||||
../vm_types, interpreter/[gas_meter, gas_costs, utils/utils_numeric],
|
||||
../vm_types, interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks],
|
||||
../errors, stint, eth/[keys, common], chronicles, tables, macros,
|
||||
message, math, nimcrypto, bncurve/[fields, groups]
|
||||
|
||||
type
|
||||
PrecompileAddresses* = enum
|
||||
# Frontier to Spurious Dragron
|
||||
paEcRecover = 1,
|
||||
paSha256,
|
||||
paRipeMd160,
|
||||
paIdentity,
|
||||
#
|
||||
# Byzantium onward
|
||||
paModExp,
|
||||
paEcAdd,
|
||||
paEcMul,
|
||||
|
@ -274,12 +275,13 @@ proc bn256ecPairing*(computation: var BaseComputation) =
|
|||
# computation.gasMeter.consumeGas(gasFee, reason="ecPairing Precompile")
|
||||
computation.rawOutput = @output
|
||||
|
||||
proc execPrecompiles*(computation: var BaseComputation): bool {.inline.} =
|
||||
proc execPrecompiles*(computation: var BaseComputation, fork: Fork): bool {.inline.} =
|
||||
for i in 0..18:
|
||||
if computation.msg.codeAddress[i] != 0: return
|
||||
|
||||
let lb = computation.msg.codeAddress[19]
|
||||
if lb in PrecompileAddresses.low.byte .. PrecompileAddresses.high.byte:
|
||||
let maxPrecompileAddr = if fork < FkByzantium: paIdentity else: PrecompileAddresses.high
|
||||
if lb in PrecompileAddresses.low.byte .. maxPrecompileAddr.byte:
|
||||
result = true
|
||||
let precompile = PrecompileAddresses(lb)
|
||||
trace "Call precompile", precompile = precompile, codeAddr = computation.msg.codeAddress
|
||||
|
|
|
@ -13,14 +13,8 @@
|
|||
# being mostly used for short-term regression prevention.
|
||||
func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
||||
let allowedFailingGeneralStateTests = @[
|
||||
"randomStatetest14.json",
|
||||
"randomStatetest85.json",
|
||||
# 2019-02-17:
|
||||
"pairingTest.json",
|
||||
"pointAdd.json",
|
||||
"pointAddTrunc.json",
|
||||
"pointMulAdd.json",
|
||||
"pointMulAdd2.json",
|
||||
"randomStatetest14.json", # SHA3 offset
|
||||
"randomStatetest85.json", # CALL* memoffset
|
||||
# Homestead recursives
|
||||
"ContractCreationSpam.json",
|
||||
"Call1024OOG.json",
|
||||
|
|
Loading…
Reference in New Issue