mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-28 21:16:29 +00:00
df1217b7ca
* Removed some Windows specific unit test annoyances details: + Short put()/get() cycles on persistent database have a race condition with vendor rocksdb. On a specific (and slow) qemu/win7 a 50ms `sleep()` in between will mostly do the job (i.e. unless heavy CPU load.) This issue was not observed on github/ci. + Removed annoyances when qemu/Win7 keeps the rocksdb database files locked even after closing the db. The problem is solved by strictly using fresh names for each test. No assumption made to be able to properly clean up. This issue was not observed on github/ci. * Silence some compiler gossip -- part 7, misc/non(sync or graphql) details: Adding some missing exception annotation
72 lines
2.2 KiB
Nim
72 lines
2.2 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2018 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
# http://opensource.org/licenses/MIT)
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
# according to those terms.
|
|
|
|
## EVM Opcode Handlers: Common Helper Functions
|
|
## ============================================
|
|
##
|
|
|
|
{.push raises: [CatchableError].} # basically the annotation type of a `Vm2OpFn`
|
|
|
|
import
|
|
../../../errors,
|
|
../../types,
|
|
../gas_costs,
|
|
../gas_meter,
|
|
eth/common,
|
|
eth/common/eth_types,
|
|
macros,
|
|
stint
|
|
|
|
when defined(evmc_enabled):
|
|
import ../../evmc_api, evmc/evmc
|
|
else:
|
|
import
|
|
../../state,
|
|
../../../db/accounts_cache
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Public
|
|
# ------------------------------------------------------------------------------
|
|
|
|
proc gasEip2929AccountCheck*(c: Computation; address: EthAddress) =
|
|
when defined(evmc_enabled):
|
|
let gasCost = if c.host.accessAccount(address) == EVMC_ACCESS_COLD:
|
|
ColdAccountAccessCost
|
|
else:
|
|
WarmStorageReadCost
|
|
c.gasMeter.consumeGas(
|
|
gasCost,
|
|
reason = "gasEIP2929AccountCheck")
|
|
else:
|
|
c.vmState.mutateStateDB:
|
|
let gasCost = if not db.inAccessList(address):
|
|
db.accessList(address)
|
|
ColdAccountAccessCost
|
|
else:
|
|
WarmStorageReadCost
|
|
|
|
c.gasMeter.consumeGas(
|
|
gasCost,
|
|
reason = "gasEIP2929AccountCheck")
|
|
|
|
template checkInStaticContext*(c: Computation) =
|
|
## Verify static context in handler function, raise an error otherwise
|
|
if emvcStatic == c.msg.flags:
|
|
# TODO: if possible, this check only appear
|
|
# when fork >= FkByzantium
|
|
raise newException(
|
|
StaticContextError,
|
|
"Cannot modify state while inside of STATICCALL context")
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# End
|
|
# ------------------------------------------------------------------------------
|
|
|