Merge pull request #79 from status-im/FixExtCodeCopyCost

ExtCodeCopy is a memory expansion operation for gas computation purposes
This commit is contained in:
Yuriy Glukhov 2018-07-24 12:19:04 +03:00 committed by GitHub
commit 473140f586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View File

@ -323,10 +323,10 @@ OK: 11/12 Fail: 1/12 Skip: 0/12
- codecopy_DataIndexTooHigh.json Fail
+ codesize.json OK
- env1.json Fail
- extcodecopy0.json Fail
- extcodecopy0AddressTooBigLeft.json Fail
- extcodecopy0AddressTooBigRight.json Fail
- extcodecopyZeroMemExpansion.json Fail
+ extcodecopy0.json OK
+ extcodecopy0AddressTooBigLeft.json OK
+ extcodecopy0AddressTooBigRight.json OK
+ extcodecopyZeroMemExpansion.json OK
- extcodecopy_DataIndexTooHigh.json Fail
+ extcodesize0.json OK
+ extcodesize1.json OK
@ -334,7 +334,7 @@ OK: 11/12 Fail: 1/12 Skip: 0/12
+ gasprice.json OK
+ origin.json OK
```
OK: 29/52 Fail: 8/52 Skip: 15/52
OK: 33/52 Fail: 4/52 Skip: 15/52
## vmIOandFlowOperations
```diff
+ BlockNumberDynamicJump0_AfterJumpdest.json OK

View File

@ -174,11 +174,10 @@ template gasCosts(FeeSchedule: GasFeeSchedule, prefix, ResultGasCostsName: untyp
static(FeeSchedule[GasCopy]) * memLength.wordCount
result += `prefix gasMemoryExpansion`(currentMemSize, memOffset, memLength)
func `prefix gasExtCodeCopy`(value: Uint256): GasInt {.nimcall.} =
## Value is the size of the input to the CallDataCopy/CodeCopy/ReturnDataCopy function
result = static(FeeSchedule[GasVeryLow]) +
static(FeeSchedule[GasCopy]) * value.toInt.wordCount
func `prefix gasExtCodeCopy`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
result = static(FeeSchedule[GasExtCode]) +
static(FeeSchedule[GasCopy]) * memLength.wordCount
result += `prefix gasMemoryExpansion`(currentMemSize, memOffset, memLength)
func `prefix gasLoadStore`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
result = static(FeeSchedule[GasVeryLow])
@ -386,7 +385,7 @@ template gasCosts(FeeSchedule: GasFeeSchedule, prefix, ResultGasCostsName: untyp
CodeCopy: memExpansion `prefix gasCopy`,
GasPrice: fixed GasBase,
ExtCodeSize: fixed GasExtcode,
ExtCodeCopy: dynamic `prefix gasExtCodeCopy`,
ExtCodeCopy: memExpansion `prefix gasExtCodeCopy`,
ReturnDataSize: fixed GasBase,
ReturnDataCopy: memExpansion `prefix gasCopy`,

View File

@ -319,7 +319,7 @@ op extCodeCopy, inline = true:
let (memPos, codePos, len) = (memStartPos.toInt, codeStartPos.toInt, size.toInt)
computation.gasMeter.consumeGas(
computation.gasCosts[CodeCopy].m_handler(memPos, codePos, len),
computation.gasCosts[ExtCodeCopy].m_handler(memPos, codePos, len),
reason="ExtCodeCopy fee")
let codeBytes = computation.vmState.readOnlyStateDB.getCode(account)