From 2f3a22d840848cfb55819b203c778128fa0e6368 Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 21 Jul 2020 19:58:17 +0700 Subject: [PATCH] fix evmc_host.set_storage --- nimbus/vm/evmc_host.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nimbus/vm/evmc_host.nim b/nimbus/vm/evmc_host.nim index e0f05669b..5a28d289d 100644 --- a/nimbus/vm/evmc_host.nim +++ b/nimbus/vm/evmc_host.nim @@ -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: