fix DelegateCall gasCost, GST +6

This commit is contained in:
andri lim 2019-03-18 17:24:25 +07:00
parent a7c6531f08
commit 36fb75d042
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 24 additions and 34 deletions

View File

@ -156,11 +156,11 @@ OK: 63/79 Fail: 0/79 Skip: 16/79
Call1024BalanceTooLow.json Skip
Call1024OOG.json Skip
Call1024PreCalls.json Skip
CallLoseGasOOG.json Skip
+ CallLoseGasOOG.json OK
CallRecursiveBombPreCall.json Skip
+ Callcode1024BalanceTooLow.json OK
Callcode1024OOG.json Skip
CallcodeLoseGasOOG.json Skip
+ CallcodeLoseGasOOG.json OK
+ callOutput1.json OK
+ callOutput2.json OK
+ callOutput3.json OK
@ -176,7 +176,7 @@ OK: 63/79 Fail: 0/79 Skip: 16/79
+ callcodeOutput3.json OK
+ callcodeOutput3Fail.json OK
+ callcodeOutput3partial.json OK
callcodeOutput3partialFail.json Skip
+ callcodeOutput3partialFail.json OK
+ callcodeWithHighValue.json OK
+ callcodeWithHighValueAndGasOOG.json OK
+ createFailBalanceTooLow.json OK
@ -193,7 +193,7 @@ OK: 63/79 Fail: 0/79 Skip: 16/79
+ createNameRegistratorPreStore1NotEnoughGas.json OK
+ createNameRegistratorendowmentTooHigh.json OK
```
OK: 31/39 Fail: 0/39 Skip: 8/39
OK: 34/39 Fail: 0/39 Skip: 5/39
## stCallDelegateCodesCallCodeHomestead
```diff
callcallcallcode_001.json Skip
@ -403,9 +403,9 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
Call1024BalanceTooLow.json Skip
Call1024OOG.json Skip
Call1024PreCalls.json Skip
CallLoseGasOOG.json Skip
+ CallLoseGasOOG.json OK
CallRecursiveBombPreCall.json Skip
CallcodeLoseGasOOG.json Skip
+ CallcodeLoseGasOOG.json OK
Delegatecall1024.json Skip
Delegatecall1024OOG.json Skip
+ callOutput1.json OK
@ -420,7 +420,7 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
+ callcodeOutput3.json OK
+ callcodeOutput3Fail.json OK
+ callcodeOutput3partial.json OK
callcodeOutput3partialFail.json Skip
+ callcodeOutput3partialFail.json OK
+ callcodeWithHighValueAndGasOOG.json OK
deleagateCallAfterValueTransfer.json Skip
+ delegatecallAndOOGatTxLevel.json OK
@ -435,7 +435,7 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
delegatecodeDynamicCode.json Skip
delegatecodeDynamicCode2SelfCall.json Skip
```
OK: 18/34 Fail: 0/34 Skip: 16/34
OK: 21/34 Fail: 0/34 Skip: 13/34
## stEIP150Specific
```diff
CallAndCallcodeConsumeMoreGasThenTransactionHas.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: 1381/2334 Fail: 0/2334 Skip: 953/2334
OK: 1387/2334 Fail: 0/2334 Skip: 947/2334

View File

@ -64,14 +64,13 @@ type
case kind*: Op
of Sstore:
s_isStorageEmpty*: bool
of Call:
of Call, CallCode, DelegateCall, StaticCall:
c_isNewAccount*: bool
c_gasBalance*: GasInt
c_contractGas*: Gasint
c_currentMemSize*: Natural
c_memOffset*: Natural
c_memLength*: Natural
c_opCode*: Op
of Create:
cr_currentMemSize*: Natural
cr_memOffset*: Natural
@ -303,7 +302,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
)
# Cnew_account
if gasParams.c_isNewAccount and gasParams.c_opCode == Call:
if gasParams.c_isNewAccount and gasParams.kind == Call:
if fork < FkSpurious:
# Pre-EIP161 all account creation calls consumed 25000 gas.
result.gasCost += static(FeeSchedule[GasNewAccount])
@ -315,7 +314,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
result.gasCost += static(FeeSchedule[GasNewAccount])
# Cxfer
if not value.isZero:
if not value.isZero and gasParams.kind in {Call, CallCode}:
result.gasCost += static(FeeSchedule[GasCallValue])
# Cextra
@ -338,7 +337,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
result.gasCost += result.gasRefund
# Ccallgas - Gas sent to the child message
if not value.isZero:
if not value.isZero and gasParams.kind in {Call, CallCode}:
result.gasRefund += static(FeeSchedule[GasCallStipend])
func `prefix gasHalt`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =

View File

@ -700,17 +700,15 @@ template genCall(callName: untyped, opCode: Op): untyped =
let (childGasFee, childGasLimit) = computation.gasCosts[opCode].c_handler(
value,
GasParams(kind: Call,
GasParams(kind: opCode,
c_isNewAccount: isNewAccount,
c_gasBalance: computation.gasMeter.gasRemaining,
c_contractGas: gas.truncate(GasInt),
c_currentMemSize: computation.memory.len,
c_memOffset: memOffset,
c_memLength: memLength,
c_opCode: opCode
c_memLength: memLength
))
#trace "Call (" & callNameStr & ")", childGasLimit, childGasFee
if childGasFee >= 0:
computation.gasMeter.consumeGas(childGasFee, reason = $opCode)

View File

@ -75,21 +75,14 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"callcallcallcode_001_OOGMAfter_2.json",
# Failed in homestead but OK in Frontier
"callcallcallcode_001.json",
"callcallcode_01.json",
"callcallcodecall_010.json",
"callcallcodecallcode_011.json",
"callcallcallcode_001.json",
"callcallcode_01.json",
"callcallcodecall_010.json",
"callcallcodecallcode_011.json",
"callcodecallcall_100.json",
"callcodecallcallcode_101.json",
"callcodecallcode_11.json",
"callcodecallcodecall_110.json",
"callcodecallcodecallcode_111.json",
"CallLoseGasOOG.json",
"CallcodeLoseGasOOG.json",
"callcodeOutput3partialFail.json"
"callcallcode_01.json",
"callcodecallcall_100.json",
"callcodecallcode_11.json",
"callcallcallcode_001.json",
"callcodecallcodecall_110.json",
"callcallcodecall_010.json",
"callcodecallcallcode_101.json"
]
result = name in allowedFailingGeneralStateTests