fix evmc_host.set_storage

This commit is contained in:
jangko 2020-07-21 19:58:17 +07:00
parent 95f6711304
commit 2f3a22d840
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,9 @@ proc hostAccountExistsImpl(ctx: Computation, address: EthAddress): bool {.cdecl.
proc hostGetStorageImpl(ctx: Computation, address: EthAddress, key: var evmc_bytes32): evmc_bytes32 {.cdecl.} =
ctx.vmState.accountDB.getStorage(address, Uint256.fromEvmc(key)).toEvmc()
proc sstoreNetGasMetering(ctx: Computation): bool {.inline.} =
ctx.fork in {FkConstantinople, FkIstanbul}
proc hostSetStorageImpl(ctx: Computation, address: EthAddress,
key, value: var evmc_bytes32): evmc_storage_status {.cdecl.} =
let
@ -51,7 +54,7 @@ proc hostSetStorageImpl(ctx: Computation, address: EthAddress,
status = EVMC_STORAGE_UNCHANGED
else:
origValue = statedb.getCommittedStorage(address, slot)
if origValue == currValue or ctx.fork < FkIstanbul:
if origValue == currValue or not ctx.sstoreNetGasMetering():
if currValue == 0:
status = EVMC_STORAGE_ADDED
elif newValue == 0: