fix calcMemSize bug
This commit is contained in:
parent
213fb3b971
commit
f809a864b1
|
@ -1013,13 +1013,13 @@ OK: 95/96 Fail: 0/96 Skip: 1/96
|
||||||
+ CallSha256_4.json OK
|
+ CallSha256_4.json OK
|
||||||
+ CallSha256_4_gas99.json OK
|
+ CallSha256_4_gas99.json OK
|
||||||
+ CallSha256_5.json OK
|
+ CallSha256_5.json OK
|
||||||
modexpRandomInput.json Skip
|
+ modexpRandomInput.json OK
|
||||||
+ modexp_0_0_0_20500.json OK
|
+ modexp_0_0_0_20500.json OK
|
||||||
+ modexp_0_0_0_22000.json OK
|
+ modexp_0_0_0_22000.json OK
|
||||||
+ modexp_0_0_0_25000.json OK
|
+ modexp_0_0_0_25000.json OK
|
||||||
+ modexp_0_0_0_35000.json OK
|
+ modexp_0_0_0_35000.json OK
|
||||||
```
|
```
|
||||||
OK: 96/97 Fail: 0/97 Skip: 1/97
|
OK: 97/97 Fail: 0/97 Skip: 0/97
|
||||||
## stQuadraticComplexityTest
|
## stQuadraticComplexityTest
|
||||||
```diff
|
```diff
|
||||||
Call1MB1024Calldepth.json Skip
|
Call1MB1024Calldepth.json Skip
|
||||||
|
@ -1083,7 +1083,7 @@ OK: 0/16 Fail: 0/16 Skip: 16/16
|
||||||
+ randomStatetest137.json OK
|
+ randomStatetest137.json OK
|
||||||
+ randomStatetest138.json OK
|
+ randomStatetest138.json OK
|
||||||
+ randomStatetest139.json OK
|
+ randomStatetest139.json OK
|
||||||
randomStatetest14.json Skip
|
+ randomStatetest14.json OK
|
||||||
+ randomStatetest142.json OK
|
+ randomStatetest142.json OK
|
||||||
+ randomStatetest143.json OK
|
+ randomStatetest143.json OK
|
||||||
+ randomStatetest144.json OK
|
+ randomStatetest144.json OK
|
||||||
|
@ -1357,7 +1357,7 @@ OK: 0/16 Fail: 0/16 Skip: 16/16
|
||||||
+ randomStatetest82.json OK
|
+ randomStatetest82.json OK
|
||||||
+ randomStatetest83.json OK
|
+ randomStatetest83.json OK
|
||||||
+ randomStatetest84.json OK
|
+ randomStatetest84.json OK
|
||||||
randomStatetest85.json Skip
|
+ randomStatetest85.json OK
|
||||||
+ randomStatetest87.json OK
|
+ randomStatetest87.json OK
|
||||||
+ randomStatetest88.json OK
|
+ randomStatetest88.json OK
|
||||||
+ randomStatetest89.json OK
|
+ randomStatetest89.json OK
|
||||||
|
@ -1370,7 +1370,7 @@ OK: 0/16 Fail: 0/16 Skip: 16/16
|
||||||
+ randomStatetest97.json OK
|
+ randomStatetest97.json OK
|
||||||
+ randomStatetest98.json OK
|
+ randomStatetest98.json OK
|
||||||
```
|
```
|
||||||
OK: 321/327 Fail: 0/327 Skip: 6/327
|
OK: 323/327 Fail: 0/327 Skip: 4/327
|
||||||
## stRandom2
|
## stRandom2
|
||||||
```diff
|
```diff
|
||||||
+ 201503110226PYTHON_DUP6.json OK
|
+ 201503110226PYTHON_DUP6.json OK
|
||||||
|
@ -1834,11 +1834,11 @@ OK: 16/16 Fail: 0/16 Skip: 0/16
|
||||||
+ gasPrice0.json OK
|
+ gasPrice0.json OK
|
||||||
+ makeMoney.json OK
|
+ makeMoney.json OK
|
||||||
push32withoutByte.json Skip
|
push32withoutByte.json Skip
|
||||||
sha3_deja.json Skip
|
+ sha3_deja.json OK
|
||||||
+ txCost-sec73.json OK
|
+ txCost-sec73.json OK
|
||||||
+ tx_e1c174e2.json OK
|
+ tx_e1c174e2.json OK
|
||||||
```
|
```
|
||||||
OK: 10/14 Fail: 0/14 Skip: 4/14
|
OK: 11/14 Fail: 0/14 Skip: 3/14
|
||||||
## stStackTests
|
## stStackTests
|
||||||
```diff
|
```diff
|
||||||
+ shallowStack.json OK
|
+ shallowStack.json OK
|
||||||
|
@ -2485,11 +2485,11 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
|
||||||
+ ecpairing_one_point_with_g2_zero.json OK
|
+ ecpairing_one_point_with_g2_zero.json OK
|
||||||
+ ecpairing_one_point_with_g2_zero_and_g1_invalid.json OK
|
+ ecpairing_one_point_with_g2_zero_and_g1_invalid.json OK
|
||||||
+ ecpairing_perturb_g2_by_curve_order.json OK
|
+ ecpairing_perturb_g2_by_curve_order.json OK
|
||||||
ecpairing_perturb_g2_by_field_modulus.json Skip
|
+ ecpairing_perturb_g2_by_field_modulus.json OK
|
||||||
ecpairing_perturb_g2_by_field_modulus_again.json Skip
|
+ ecpairing_perturb_g2_by_field_modulus_again.json OK
|
||||||
+ ecpairing_perturb_g2_by_one.json OK
|
+ ecpairing_perturb_g2_by_one.json OK
|
||||||
+ ecpairing_perturb_zeropoint_by_curve_order.json OK
|
+ ecpairing_perturb_zeropoint_by_curve_order.json OK
|
||||||
ecpairing_perturb_zeropoint_by_field_modulus.json Skip
|
+ ecpairing_perturb_zeropoint_by_field_modulus.json OK
|
||||||
+ ecpairing_perturb_zeropoint_by_one.json OK
|
+ ecpairing_perturb_zeropoint_by_one.json OK
|
||||||
+ ecpairing_three_point_fail_1.json OK
|
+ ecpairing_three_point_fail_1.json OK
|
||||||
+ ecpairing_three_point_match_1.json OK
|
+ ecpairing_three_point_match_1.json OK
|
||||||
|
@ -2508,7 +2508,7 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
|
||||||
+ pointMulAdd.json OK
|
+ pointMulAdd.json OK
|
||||||
+ pointMulAdd2.json OK
|
+ pointMulAdd2.json OK
|
||||||
```
|
```
|
||||||
OK: 130/133 Fail: 0/133 Skip: 3/133
|
OK: 133/133 Fail: 0/133 Skip: 0/133
|
||||||
## stZeroKnowledge2
|
## stZeroKnowledge2
|
||||||
```diff
|
```diff
|
||||||
+ ecadd_0-0_0-0_21000_0.json OK
|
+ ecadd_0-0_0-0_21000_0.json OK
|
||||||
|
@ -2645,4 +2645,4 @@ OK: 130/133 Fail: 0/133 Skip: 3/133
|
||||||
OK: 130/130 Fail: 0/130 Skip: 0/130
|
OK: 130/130 Fail: 0/130 Skip: 0/130
|
||||||
|
|
||||||
---TOTAL---
|
---TOTAL---
|
||||||
OK: 2245/2447 Fail: 0/2447 Skip: 202/2447
|
OK: 2252/2447 Fail: 0/2447 Skip: 195/2447
|
||||||
|
|
|
@ -195,12 +195,7 @@ op byteOp, inline = true, position, value:
|
||||||
|
|
||||||
op sha3, inline = true, startPos, length:
|
op sha3, inline = true, startPos, length:
|
||||||
## 0x20, Compute Keccak-256 hash.
|
## 0x20, Compute Keccak-256 hash.
|
||||||
let (pos, len) = (startPos.toInt, length.toInt)
|
let (pos, len) = (startPos.safeInt, length.safeInt)
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# "randomStatetest14.json", # SHA3 offset
|
|
||||||
# "sha3_deja.json", # SHA3 startPos
|
|
||||||
# both test require Uint256 to calculate startpos/offset
|
|
||||||
|
|
||||||
if pos < 0 or len < 0 or pos > 2147483648:
|
if pos < 0 or len < 0 or pos > 2147483648:
|
||||||
raise newException(OutOfBoundsRead, "Out of bounds memory access")
|
raise newException(OutOfBoundsRead, "Out of bounds memory access")
|
||||||
|
@ -708,7 +703,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
||||||
else:
|
else:
|
||||||
not computation.vmState.readOnlyStateDb.accountExists(to)
|
not computation.vmState.readOnlyStateDb.accountExists(to)
|
||||||
|
|
||||||
let (memOffset, memLength) = if memInPos + memInLen > memOutPos + memOutLen:
|
let (memOffset, memLength) = if calcMemSize(memInPos, memInLen) > calcMemSize(memOutPos, memOutLen):
|
||||||
(memInPos, memInLen)
|
(memInPos, memInLen)
|
||||||
else:
|
else:
|
||||||
(memOutPos, memOutLen)
|
(memOutPos, memOutLen)
|
||||||
|
|
|
@ -69,3 +69,13 @@ proc rangeToPadded*[T: StUint](x: openarray[byte], first, last: int): T =
|
||||||
x.toOpenArray(lo, hi),
|
x.toOpenArray(lo, hi),
|
||||||
allowPadding = true
|
allowPadding = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# calculates the memory size required for a step
|
||||||
|
func calcMemSize*(offset, length: int): int {.inline.} =
|
||||||
|
if length.isZero: return 0
|
||||||
|
result = offset + length
|
||||||
|
|
||||||
|
func safeInt*(x: Uint256): int {.inline.} =
|
||||||
|
result = x.truncate(int)
|
||||||
|
if x > high(int32).u256 or result < 0:
|
||||||
|
result = high(int32)
|
||||||
|
|
|
@ -211,9 +211,9 @@ proc modExp*(computation: BaseComputation) =
|
||||||
template rawMsg: untyped {.dirty.} =
|
template rawMsg: untyped {.dirty.} =
|
||||||
computation.msg.data
|
computation.msg.data
|
||||||
let # lengths Base, Exponent, Modulus
|
let # lengths Base, Exponent, Modulus
|
||||||
base_len = rawMsg.rangeToPadded[:Uint256](0, 31).truncate(int)
|
base_len = rawMsg.rangeToPadded[:Uint256](0, 31).safeInt
|
||||||
exp_len = rawMsg.rangeToPadded[:Uint256](32, 63).truncate(int)
|
exp_len = rawMsg.rangeToPadded[:Uint256](32, 63).safeInt
|
||||||
mod_len = rawMsg.rangeToPadded[:Uint256](64, 95).truncate(int)
|
mod_len = rawMsg.rangeToPadded[:Uint256](64, 95).safeInt
|
||||||
|
|
||||||
let maxBytes = max(base_len, max(exp_len, mod_len))
|
let maxBytes = max(base_len, max(exp_len, mod_len))
|
||||||
|
|
||||||
|
|
|
@ -13,23 +13,10 @@
|
||||||
# being mostly used for short-term regression prevention.
|
# being mostly used for short-term regression prevention.
|
||||||
func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
||||||
let allowedFailingGeneralStateTests = @[
|
let allowedFailingGeneralStateTests = @[
|
||||||
# a family of UInt256 truncated to int problems
|
|
||||||
"randomStatetest14.json", # SHA3 offset
|
|
||||||
"randomStatetest85.json", # CALL* memoffset
|
|
||||||
"sha3_deja.json", # SHA3 startPos
|
|
||||||
# modexp exp_len & friends truncated to int
|
|
||||||
# and not OOG where it should OOG
|
|
||||||
"modexpRandomInput.json",
|
|
||||||
|
|
||||||
"CreateOOGafterInitCodeReturndataSize.json",
|
"CreateOOGafterInitCodeReturndataSize.json",
|
||||||
"RevertInCreateInInit.json",
|
"RevertInCreateInInit.json",
|
||||||
"modexp.json",
|
"modexp.json",
|
||||||
|
|
||||||
# see precompiles getPoint[G2]
|
|
||||||
"ecpairing_perturb_g2_by_field_modulus_again.json",
|
|
||||||
"ecpairing_perturb_zeropoint_by_field_modulus.json",
|
|
||||||
"ecpairing_perturb_g2_by_field_modulus.json",
|
|
||||||
|
|
||||||
# 29/04/2019
|
# 29/04/2019
|
||||||
"RevertPrecompiledTouch.json",
|
"RevertPrecompiledTouch.json",
|
||||||
"RevertPrecompiledTouch_storage.json",
|
"RevertPrecompiledTouch_storage.json",
|
||||||
|
|
Loading…
Reference in New Issue