Merge pull request #78 from status-im/FixZeroSizeSha3

add subcase of yellow paper equation (297) for zero-length memory ranges
This commit is contained in:
Yuriy Glukhov 2018-07-24 12:15:41 +03:00 committed by GitHub
commit e8453e3876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -669,14 +669,14 @@ OK: 0/17 Fail: 0/17 Skip: 17/17
+ sha3_bigSize.json OK
+ sha3_memSizeNoQuadraticCost31.json OK
+ sha3_memSizeQuadraticCost32.json OK
- sha3_memSizeQuadraticCost32_zeroSize.json Fail
+ sha3_memSizeQuadraticCost32_zeroSize.json OK
+ sha3_memSizeQuadraticCost33.json OK
+ sha3_memSizeQuadraticCost63.json OK
+ sha3_memSizeQuadraticCost64.json OK
+ sha3_memSizeQuadraticCost64_2.json OK
+ sha3_memSizeQuadraticCost65.json OK
```
OK: 17/18 Fail: 1/18 Skip: 0/18
OK: 18/18 Fail: 0/18 Skip: 0/18
## vmSystemOperations
```diff
ABAcalls0.json Skip

View File

@ -120,6 +120,17 @@ template gasCosts(FeeSchedule: GasFeeSchedule, prefix, ResultGasCostsName: untyp
# μ'i is the memory size after opcode execution
# Cmem(a) ≡ Gmemory · a + a² / 512
#
# Except when memLength = 0, where per eq (297),
# M(currentMemSize, f, l) = currentMemSize
if memLength == 0:
# Special subcase of memory-expansion cost
# currentMemSize - currentMemSize = 0
# "Referencing a zero length range ... does not require memory to be extended
# to the beginning of the range."
return 0
let
prev_words = currentMemSize.wordCount
prev_cost = prev_words * static(FeeSchedule[GasMemory]) +