2021-04-13 17:12:47 +00:00
|
|
|
|
# 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: Environmental Information
|
|
|
|
|
## ==============================================
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
import
|
|
|
|
|
../../../errors,
|
2021-04-21 17:04:54 +00:00
|
|
|
|
../../code_stream,
|
2021-04-26 16:00:46 +00:00
|
|
|
|
../../computation,
|
2021-04-22 16:05:58 +00:00
|
|
|
|
../../memory,
|
2021-04-21 17:04:54 +00:00
|
|
|
|
../../stack,
|
2023-04-12 12:39:11 +00:00
|
|
|
|
../../async/operations,
|
2021-04-21 17:04:54 +00:00
|
|
|
|
../gas_costs,
|
|
|
|
|
../gas_meter,
|
|
|
|
|
../op_codes,
|
2021-04-22 16:05:58 +00:00
|
|
|
|
../utils/utils_numeric,
|
2021-04-13 17:12:47 +00:00
|
|
|
|
./oph_defs,
|
2021-04-15 16:42:19 +00:00
|
|
|
|
./oph_helpers,
|
2021-04-21 17:04:54 +00:00
|
|
|
|
eth/common,
|
2021-04-13 17:12:47 +00:00
|
|
|
|
sequtils,
|
2021-04-21 17:04:54 +00:00
|
|
|
|
stint,
|
|
|
|
|
strformat
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-02-14 14:37:21 +00:00
|
|
|
|
{.push raises: [CatchableError].} # basically the annotation type of a `Vm2OpFn`
|
|
|
|
|
|
2022-09-28 06:09:33 +00:00
|
|
|
|
when not defined(evmc_enabled):
|
|
|
|
|
import ../../state
|
|
|
|
|
|
2021-04-13 17:12:47 +00:00
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# Private helpers
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
proc writePaddedResult(mem: var Memory,
|
2022-04-08 04:54:11 +00:00
|
|
|
|
data: openArray[byte],
|
2021-04-13 17:12:47 +00:00
|
|
|
|
memPos, dataPos, len: Natural,
|
|
|
|
|
paddingValue = 0.byte) =
|
|
|
|
|
|
|
|
|
|
mem.extend(memPos, len)
|
|
|
|
|
let dataEndPosition = dataPos.int64 + len - 1
|
|
|
|
|
let sourceBytes =
|
|
|
|
|
data[min(dataPos, data.len) .. min(data.len - 1, dataEndPosition)]
|
|
|
|
|
|
2023-04-24 20:59:38 +00:00
|
|
|
|
mem.write(memPos, sourceBytes)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
# Don't duplicate zero-padding of mem.extend
|
|
|
|
|
let paddingOffset = min(memPos + sourceBytes.len, mem.len)
|
|
|
|
|
let numPaddingBytes = min(mem.len - paddingOffset, len - sourceBytes.len)
|
|
|
|
|
if numPaddingBytes > 0:
|
|
|
|
|
# TODO: avoid unnecessary memory allocation
|
2023-04-24 20:59:38 +00:00
|
|
|
|
mem.write(paddingOffset, repeat(paddingValue, numPaddingBytes))
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# Private, op handlers implementation
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const
|
2021-04-20 12:07:01 +00:00
|
|
|
|
addressOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x30, Get address of currently executing account.
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.msg.contractAddress
|
|
|
|
|
|
2021-04-15 16:42:19 +00:00
|
|
|
|
# ------------------
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
balanceOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x31, Get balance of the given account.
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
let address = cpt.stack.popAddress
|
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetAccount(cpt.vmState, address)):
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getBalance(address)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
balanceEIP2929Op: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-15 16:42:19 +00:00
|
|
|
|
## 0x31, EIP292: Get balance of the given account for Berlin and later
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
let address = cpt.stack.popAddress()
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetAccount(cpt.vmState, address)):
|
|
|
|
|
cpt.gasEip2929AccountCheck(address)
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getBalance(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
|
|
|
|
# ------------------
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
originOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x32, Get execution origination address.
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.getOrigin()
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
callerOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x33, Get caller address.
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.msg.sender
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
callValueOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x34, Get deposited value by the instruction/transaction
|
|
|
|
|
## responsible for this execution
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.msg.value
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
callDataLoadOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x35, Get input data of current environment
|
|
|
|
|
let (startPos) = k.cpt.stack.popInt(1)
|
|
|
|
|
let start = startPos.cleanMemRef
|
|
|
|
|
if start >= k.cpt.msg.data.len:
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
0
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# If the data does not take 32 bytes, pad with zeros
|
|
|
|
|
let endRange = min(k.cpt.msg.data.len - 1, start + 31)
|
|
|
|
|
let presentBytes = endRange - start
|
|
|
|
|
|
|
|
|
|
# We rely on value being initialized with 0 by default
|
|
|
|
|
var value: array[32, byte]
|
|
|
|
|
value[0 .. presentBytes] = k.cpt.msg.data.toOpenArray(start, endRange)
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
value
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
callDataSizeOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x36, Get size of input data in current environment.
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.msg.data.len.u256
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
callDataCopyOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x37, Copy input data in current environment to memory.
|
|
|
|
|
let (memStartPos, copyStartPos, size) = k.cpt.stack.popInt(3)
|
|
|
|
|
|
|
|
|
|
# TODO tests: https://github.com/status-im/nimbus/issues/67
|
|
|
|
|
let (memPos, copyPos, len) =
|
|
|
|
|
(memStartPos.cleanMemRef, copyStartPos.cleanMemRef, size.cleanMemRef)
|
|
|
|
|
|
2021-04-14 16:51:54 +00:00
|
|
|
|
k.cpt.gasMeter.consumeGas(
|
|
|
|
|
k.cpt.gasCosts[CallDataCopy].m_handler(k.cpt.memory.len, memPos, len),
|
|
|
|
|
reason = "CallDataCopy fee")
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
k.cpt.memory.writePaddedResult(k.cpt.msg.data, memPos, copyPos, len)
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
codeSizeOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x38, Get size of code running in current environment.
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, cpt.msg.contractAddress)):
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.code.len
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
codeCopyOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x39, Copy code running in current environment to memory.
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, cpt.msg.contractAddress)):
|
|
|
|
|
let (memStartPos, copyStartPos, size) = cpt.stack.popInt(3)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
# TODO tests: https://github.com/status-im/nimbus/issues/67
|
|
|
|
|
let (memPos, copyPos, len) =
|
|
|
|
|
(memStartPos.cleanMemRef, copyStartPos.cleanMemRef, size.cleanMemRef)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.gasMeter.consumeGas(
|
|
|
|
|
cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len),
|
|
|
|
|
reason = "CodeCopy fee")
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.memory.writePaddedResult(cpt.code.bytes, memPos, copyPos, len)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
gasPriceOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x3A, Get price of gas in current environment.
|
|
|
|
|
k.cpt.stack.push:
|
2021-04-15 16:42:19 +00:00
|
|
|
|
k.cpt.getGasPrice()
|
|
|
|
|
|
|
|
|
|
# -----------
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeSizeOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x3b, Get size of an account's code
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
2021-04-13 17:12:47 +00:00
|
|
|
|
let address = k.cpt.stack.popAddress()
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getCodeSize(address)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeSizeEIP2929Op: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-15 16:42:19 +00:00
|
|
|
|
## 0x3b, Get size of an account's code
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
let address = cpt.stack.popAddress()
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
cpt.gasEip2929AccountCheck(address)
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getCodeSize(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
|
|
|
|
# -----------
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeCopyOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x3c, Copy an account's code to memory.
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
let address = cpt.stack.popAddress()
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
let (memStartPos, codeStartPos, size) = cpt.stack.popInt(3)
|
|
|
|
|
let (memPos, codePos, len) =
|
|
|
|
|
(memStartPos.cleanMemRef, codeStartPos.cleanMemRef, size.cleanMemRef)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.gasMeter.consumeGas(
|
|
|
|
|
cpt.gasCosts[ExtCodeCopy].m_handler(cpt.memory.len, memPos, len),
|
|
|
|
|
reason = "ExtCodeCopy fee")
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let codeBytes = cpt.getCode(address)
|
|
|
|
|
cpt.memory.writePaddedResult(codeBytes, memPos, codePos, len)
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeCopyEIP2929Op: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-15 16:42:19 +00:00
|
|
|
|
## 0x3c, Copy an account's code to memory.
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
|
|
|
|
let address = cpt.stack.popAddress()
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
let (memStartPos, codeStartPos, size) = cpt.stack.popInt(3)
|
|
|
|
|
let (memPos, codePos, len) = (memStartPos.cleanMemRef,
|
|
|
|
|
codeStartPos.cleanMemRef, size.cleanMemRef)
|
|
|
|
|
cpt.gasMeter.consumeGas(
|
|
|
|
|
cpt.gasCosts[ExtCodeCopy].m_handler(cpt.memory.len, memPos, len),
|
|
|
|
|
reason = "ExtCodeCopy fee")
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.gasEip2929AccountCheck(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let codeBytes = cpt.getCode(address)
|
|
|
|
|
cpt.memory.writePaddedResult(codeBytes, memPos, codePos, len)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
|
|
|
|
# -----------
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
returnDataSizeOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x3d, Get size of output data from the previous call from the
|
|
|
|
|
## current environment.
|
|
|
|
|
k.cpt.stack.push:
|
|
|
|
|
k.cpt.returnData.len
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
returnDataCopyOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-13 17:12:47 +00:00
|
|
|
|
## 0x3e, Copy output data from the previous call to memory.
|
|
|
|
|
let (memStartPos, copyStartPos, size) = k.cpt.stack.popInt(3)
|
|
|
|
|
|
|
|
|
|
let (memPos, copyPos, len) =
|
|
|
|
|
(memStartPos.cleanMemRef, copyStartPos.cleanMemRef, size.cleanMemRef)
|
|
|
|
|
|
2021-04-14 16:51:54 +00:00
|
|
|
|
let gasCost = k.cpt.gasCosts[ReturnDataCopy].m_handler(
|
|
|
|
|
k.cpt.memory.len, memPos, len)
|
|
|
|
|
k.cpt.gasMeter.consumeGas(gasCost, reason = "returnDataCopy fee")
|
2021-04-13 17:12:47 +00:00
|
|
|
|
|
|
|
|
|
if copyPos + len > k.cpt.returnData.len:
|
|
|
|
|
raise newException(
|
|
|
|
|
OutOfBoundsRead,
|
|
|
|
|
"Return data length is not sufficient to satisfy request. Asked\n"&
|
|
|
|
|
&"for data from index {copyStartPos} to {copyStartPos + size}. "&
|
|
|
|
|
&"Return data is {k.cpt.returnData.len} in \n" &
|
|
|
|
|
"length")
|
|
|
|
|
k.cpt.memory.writePaddedResult(k.cpt.returnData, memPos, copyPos, len)
|
|
|
|
|
|
2021-04-15 16:42:19 +00:00
|
|
|
|
# ---------------
|
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeHashOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-15 16:42:19 +00:00
|
|
|
|
## 0x3f, Returns the keccak256 hash of a contract’s code
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
2021-04-15 16:42:19 +00:00
|
|
|
|
let address = k.cpt.stack.popAddress()
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getCodeHash(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2021-04-20 12:07:01 +00:00
|
|
|
|
extCodeHashEIP2929Op: Vm2OpFn = proc (k: var Vm2Ctx) =
|
2021-04-15 16:42:19 +00:00
|
|
|
|
## 0x3f, EIP2929: Returns the keccak256 hash of a contract’s code
|
2023-04-12 12:39:11 +00:00
|
|
|
|
let cpt = k.cpt
|
2021-04-15 16:42:19 +00:00
|
|
|
|
let address = k.cpt.stack.popAddress()
|
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.asyncChainTo(ifNecessaryGetCode(cpt.vmState, address)):
|
|
|
|
|
cpt.gasEip2929AccountCheck(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2023-04-12 12:39:11 +00:00
|
|
|
|
cpt.stack.push:
|
|
|
|
|
cpt.getCodeHash(address)
|
2021-04-15 16:42:19 +00:00
|
|
|
|
|
2021-04-13 17:12:47 +00:00
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# Public, op exec table entries
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
|
vm2OpExecEnvInfo*: seq[Vm2OpExec] = @[
|
|
|
|
|
|
|
|
|
|
(opCode: Address, ## 0x20, Address
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "address",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get address of currently executing account",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: addressOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: Balance, ## 0x31, Balance
|
2021-04-15 16:42:19 +00:00
|
|
|
|
forks: Vm2OpAllForks - Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "balance",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get balance of the given account",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: balanceOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-15 16:42:19 +00:00
|
|
|
|
(opCode: Balance, ## 0x31, Balance for Berlin and later
|
|
|
|
|
forks: Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "balanceEIP2929",
|
2021-04-15 16:42:19 +00:00
|
|
|
|
info: "EIP2929: Get balance of the given account",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: balanceEIP2929Op,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-13 17:12:47 +00:00
|
|
|
|
(opCode: Origin, ## 0x32, Origination address
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "origin",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get execution origination address",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: originOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: Caller, ## 0x33, Caller address
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "caller",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get caller address",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: callerOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CallValue, ## 0x34, Execution deposited value
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "callValue",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get deposited value by the instruction/transaction " &
|
|
|
|
|
"responsible for this execution",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: callValueOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CallDataLoad, ## 0x35, Input data
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "callDataLoad",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get input data of current environment",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: callDataLoadOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CallDataSize, ## 0x36, Size of input data
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "callDataSize",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get size of input data in current environment",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: callDataSizeOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CallDataCopy, ## 0x37, Copy input data to memory.
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "callDataCopy",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Copy input data in current environment to memory",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: callDataCopyOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CodeSize, ## 0x38, Size of code
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "codeSize",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get size of code running in current environment",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: codeSizeOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: CodeCopy, ## 0x39, Copy code to memory.
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "codeCopy",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Copy code running in current environment to memory",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: codeCopyOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: GasPrice, ## 0x3a, Gas price
|
|
|
|
|
forks: Vm2OpAllForks,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "gasPrice",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get price of gas in current environment",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: gasPriceOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: ExtCodeSize, ## 0x3b, Account code size
|
2021-04-15 16:42:19 +00:00
|
|
|
|
forks: Vm2OpAllForks - Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "extCodeSize",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get size of an account's code",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeSizeOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-15 16:42:19 +00:00
|
|
|
|
(opCode: ExtCodeSize, ## 0x3b, Account code size for Berlin and later
|
|
|
|
|
forks: Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "extCodeSizeEIP2929",
|
2021-04-15 16:42:19 +00:00
|
|
|
|
info: "EIP2929: Get size of an account's code",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeSizeEIP2929Op,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-13 17:12:47 +00:00
|
|
|
|
(opCode: ExtCodeCopy, ## 0x3c, Account code copy to memory.
|
2021-04-15 16:42:19 +00:00
|
|
|
|
forks: Vm2OpAllForks - Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "extCodeCopy",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Copy an account's code to memory",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeCopyOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-15 16:42:19 +00:00
|
|
|
|
(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin and later
|
|
|
|
|
forks: Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "extCodeCopyEIP2929",
|
2021-04-15 16:42:19 +00:00
|
|
|
|
info: "EIP2929: Copy an account's code to memory",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeCopyEIP2929Op,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
2021-04-13 17:12:47 +00:00
|
|
|
|
(opCode: ReturnDataSize, ## 0x3d, Previous call output data size
|
2021-04-19 09:15:35 +00:00
|
|
|
|
forks: Vm2OpByzantiumAndLater,
|
|
|
|
|
name: "returnDataSize",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Get size of output data from the previous call " &
|
|
|
|
|
"from the current environment",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: returnDataSizeOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: ReturnDataCopy, ## 0x3e, Previous call output data copy to memory
|
2021-04-19 09:15:35 +00:00
|
|
|
|
forks: Vm2OpByzantiumAndLater,
|
|
|
|
|
name: "returnDataCopy",
|
2021-04-13 17:12:47 +00:00
|
|
|
|
info: "Copy output data from the previous call to memory",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: returnDataCopyOp,
|
2021-04-15 16:42:19 +00:00
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: ExtCodeHash, ## 0x3f, Contract hash
|
2021-04-19 09:15:35 +00:00
|
|
|
|
forks: Vm2OpConstantinopleAndLater - Vm2OpBerlinAndLater,
|
|
|
|
|
name: "extCodeHash",
|
2021-04-15 16:42:19 +00:00
|
|
|
|
info: "Returns the keccak256 hash of a contract’s code",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeHashOp,
|
|
|
|
|
post: vm2OpIgnore)),
|
|
|
|
|
|
|
|
|
|
(opCode: ExtCodeHash, ## 0x3f, Contract hash for berlin and later
|
|
|
|
|
forks: Vm2OpBerlinAndLater,
|
2021-04-19 09:15:35 +00:00
|
|
|
|
name: "extCodeHashEIP2929",
|
2021-04-15 16:42:19 +00:00
|
|
|
|
info: "EIP2929: Returns the keccak256 hash of a contract’s code",
|
|
|
|
|
exec: (prep: vm2OpIgnore,
|
|
|
|
|
run: extCodeHashEIP2929Op,
|
2021-04-13 17:12:47 +00:00
|
|
|
|
post: vm2OpIgnore))]
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# End
|
|
|
|
|
# ------------------------------------------------------------------------------
|