avoid intermediate const in opcodes (#2381)
The extra layer of `const` makes the function name harder to see a debugger / profiler
This commit is contained in:
parent
2aaab1cb4a
commit
135ef222a2
|
@ -37,23 +37,22 @@ func slt(x, y: UInt256): bool =
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc addOp (k: var VmCtx): EvmResultVoid =
|
||||||
addOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x01, Addition
|
## 0x01, Addition
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs + rhs)
|
k.cpt.stack.push(lhs + rhs)
|
||||||
|
|
||||||
mulOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc mulOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x02, Multiplication
|
## 0x02, Multiplication
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs * rhs)
|
k.cpt.stack.push(lhs * rhs)
|
||||||
|
|
||||||
subOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc subOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x03, Substraction
|
## 0x03, Substraction
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs - rhs)
|
k.cpt.stack.push(lhs - rhs)
|
||||||
|
|
||||||
divideOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc divideOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x04, Division
|
## 0x04, Division
|
||||||
let
|
let
|
||||||
(lhs, rhs) = ? k.cpt.stack.popInt(2)
|
(lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
|
@ -66,7 +65,7 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
sdivOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc sdivOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x05, Signed division
|
## 0x05, Signed division
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ const
|
||||||
k.cpt.stack.push(r)
|
k.cpt.stack.push(r)
|
||||||
|
|
||||||
|
|
||||||
moduloOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc moduloOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x06, Modulo
|
## 0x06, Modulo
|
||||||
let
|
let
|
||||||
(lhs, rhs) = ? k.cpt.stack.popInt(2)
|
(lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
|
@ -94,7 +93,7 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
smodOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc smodOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x07, Signed modulo
|
## 0x07, Signed modulo
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -110,7 +109,7 @@ const
|
||||||
k.cpt.stack.push(r)
|
k.cpt.stack.push(r)
|
||||||
|
|
||||||
|
|
||||||
addmodOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc addmodOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x08, Modulo addition
|
## 0x08, Modulo addition
|
||||||
## Intermediate computations do not roll over at 2^256
|
## Intermediate computations do not roll over at 2^256
|
||||||
let
|
let
|
||||||
|
@ -123,7 +122,7 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
mulmodOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc mulmodOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x09, Modulo multiplication
|
## 0x09, Modulo multiplication
|
||||||
## Intermediate computations do not roll over at 2^256
|
## Intermediate computations do not roll over at 2^256
|
||||||
let
|
let
|
||||||
|
@ -136,7 +135,7 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
expOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc expOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x0A, Exponentiation
|
## 0x0A, Exponentiation
|
||||||
let (base, exponent) = ? k.cpt.stack.popInt(2)
|
let (base, exponent) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
signExtendOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc signExtendOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x0B, Sign extend
|
## 0x0B, Sign extend
|
||||||
## Extend length of two’s complement signed integer.
|
## Extend length of two’s complement signed integer.
|
||||||
let (bits, value) = ? k.cpt.stack.popInt(2)
|
let (bits, value) = ? k.cpt.stack.popInt(2)
|
||||||
|
@ -178,58 +177,58 @@ const
|
||||||
k.cpt.stack.push res
|
k.cpt.stack.push res
|
||||||
|
|
||||||
|
|
||||||
ltOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc ltOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x10, Less-than comparison
|
## 0x10, Less-than comparison
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push((lhs < rhs).uint.u256)
|
k.cpt.stack.push((lhs < rhs).uint.u256)
|
||||||
|
|
||||||
gtOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc gtOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x11, Greater-than comparison
|
## 0x11, Greater-than comparison
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push((lhs > rhs).uint.u256)
|
k.cpt.stack.push((lhs > rhs).uint.u256)
|
||||||
|
|
||||||
sltOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc sltOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x12, Signed less-than comparison
|
## 0x12, Signed less-than comparison
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(slt(lhs, rhs).uint.u256)
|
k.cpt.stack.push(slt(lhs, rhs).uint.u256)
|
||||||
|
|
||||||
sgtOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc sgtOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x13, Signed greater-than comparison
|
## 0x13, Signed greater-than comparison
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
# Arguments are swapped and SLT is used.
|
# Arguments are swapped and SLT is used.
|
||||||
k.cpt.stack.push(slt(rhs, lhs).uint.u256)
|
k.cpt.stack.push(slt(rhs, lhs).uint.u256)
|
||||||
|
|
||||||
eqOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc eqOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x14, Equality comparison
|
## 0x14, Equality comparison
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push((lhs == rhs).uint.u256)
|
k.cpt.stack.push((lhs == rhs).uint.u256)
|
||||||
|
|
||||||
isZeroOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc isZeroOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x15, Check if zero
|
## 0x15, Check if zero
|
||||||
let value = ? k.cpt.stack.popInt()
|
let value = ? k.cpt.stack.popInt()
|
||||||
k.cpt.stack.push(value.isZero.uint.u256)
|
k.cpt.stack.push(value.isZero.uint.u256)
|
||||||
|
|
||||||
andOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc andOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x16, Bitwise AND
|
## 0x16, Bitwise AND
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs and rhs)
|
k.cpt.stack.push(lhs and rhs)
|
||||||
|
|
||||||
orOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc orOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x17, Bitwise OR
|
## 0x17, Bitwise OR
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs or rhs)
|
k.cpt.stack.push(lhs or rhs)
|
||||||
|
|
||||||
xorOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc xorOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x18, Bitwise XOR
|
## 0x18, Bitwise XOR
|
||||||
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
let (lhs, rhs) = ? k.cpt.stack.popInt(2)
|
||||||
k.cpt.stack.push(lhs xor rhs)
|
k.cpt.stack.push(lhs xor rhs)
|
||||||
|
|
||||||
notOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc notOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x19, Check if zero
|
## 0x19, Check if zero
|
||||||
let value = ? k.cpt.stack.popInt()
|
let value = ? k.cpt.stack.popInt()
|
||||||
k.cpt.stack.push(value.not)
|
k.cpt.stack.push(value.not)
|
||||||
|
|
||||||
byteOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc byteOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0x20, Retrieve single byte from word.
|
## 0x20, Retrieve single byte from word.
|
||||||
let
|
let
|
||||||
(position, value) = ? k.cpt.stack.popInt(2)
|
(position, value) = ? k.cpt.stack.popInt(2)
|
||||||
|
@ -247,7 +246,7 @@ const
|
||||||
|
|
||||||
# Constantinople's new opcodes
|
# Constantinople's new opcodes
|
||||||
|
|
||||||
shlOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc shlOp(k: var VmCtx): EvmResultVoid =
|
||||||
let (shift, num) = ? k.cpt.stack.popInt(2)
|
let (shift, num) = ? k.cpt.stack.popInt(2)
|
||||||
let shiftLen = shift.safeInt
|
let shiftLen = shift.safeInt
|
||||||
if shiftLen >= 256:
|
if shiftLen >= 256:
|
||||||
|
@ -255,7 +254,7 @@ const
|
||||||
else:
|
else:
|
||||||
k.cpt.stack.push(num shl shiftLen)
|
k.cpt.stack.push(num shl shiftLen)
|
||||||
|
|
||||||
shrOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc shrOp(k: var VmCtx): EvmResultVoid =
|
||||||
let (shift, num) = ? k.cpt.stack.popInt(2)
|
let (shift, num) = ? k.cpt.stack.popInt(2)
|
||||||
let shiftLen = shift.safeInt
|
let shiftLen = shift.safeInt
|
||||||
if shiftLen >= 256:
|
if shiftLen >= 256:
|
||||||
|
@ -264,7 +263,7 @@ const
|
||||||
# uint version of `shr`
|
# uint version of `shr`
|
||||||
k.cpt.stack.push(num shr shiftLen)
|
k.cpt.stack.push(num shr shiftLen)
|
||||||
|
|
||||||
sarOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc sarOp(k: var VmCtx): EvmResultVoid =
|
||||||
let
|
let
|
||||||
shiftLen = ? k.cpt.stack.popSafeInt()
|
shiftLen = ? k.cpt.stack.popSafeInt()
|
||||||
num256 = ? k.cpt.stack.popInt()
|
num256 = ? k.cpt.stack.popInt()
|
||||||
|
@ -292,7 +291,7 @@ const
|
||||||
name: "add",
|
name: "add",
|
||||||
info: "Addition operation",
|
info: "Addition operation",
|
||||||
exec: (prep: VmOpIgnore,
|
exec: (prep: VmOpIgnore,
|
||||||
run: addOp,
|
run: VmOpFn addOp,
|
||||||
post: VmOpIgnore)),
|
post: VmOpIgnore)),
|
||||||
|
|
||||||
(opCode: Mul, ## 0x02, Multiplication
|
(opCode: Mul, ## 0x02, Multiplication
|
||||||
|
|
|
@ -29,8 +29,7 @@ when not defined(evmc_enabled):
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc blockhashOp (k: var VmCtx): EvmResultVoid =
|
||||||
blockhashOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x40, Get the hash of one of the 256 most recent complete blocks.
|
## 0x40, Get the hash of one of the 256 most recent complete blocks.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -39,40 +38,40 @@ const
|
||||||
|
|
||||||
cpt.stack.push blockHash
|
cpt.stack.push blockHash
|
||||||
|
|
||||||
coinBaseOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc coinBaseOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x41, Get the block's beneficiary address.
|
## 0x41, Get the block's beneficiary address.
|
||||||
k.cpt.stack.push k.cpt.getCoinbase
|
k.cpt.stack.push k.cpt.getCoinbase
|
||||||
|
|
||||||
timestampOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc timestampOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x42, Get the block's timestamp.
|
## 0x42, Get the block's timestamp.
|
||||||
k.cpt.stack.push k.cpt.getTimestamp
|
k.cpt.stack.push k.cpt.getTimestamp
|
||||||
|
|
||||||
blocknumberOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc blocknumberOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x43, Get the block's number.
|
## 0x43, Get the block's number.
|
||||||
k.cpt.stack.push k.cpt.getBlockNumber
|
k.cpt.stack.push k.cpt.getBlockNumber
|
||||||
|
|
||||||
difficultyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc difficultyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x44, Get the block's difficulty
|
## 0x44, Get the block's difficulty
|
||||||
k.cpt.stack.push k.cpt.getDifficulty
|
k.cpt.stack.push k.cpt.getDifficulty
|
||||||
|
|
||||||
gasLimitOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc gasLimitOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x45, Get the block's gas limit
|
## 0x45, Get the block's gas limit
|
||||||
k.cpt.stack.push k.cpt.getGasLimit
|
k.cpt.stack.push k.cpt.getGasLimit
|
||||||
|
|
||||||
chainIdOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc chainIdOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x46, Get current chain’s EIP-155 unique identifier.
|
## 0x46, Get current chain’s EIP-155 unique identifier.
|
||||||
k.cpt.stack.push k.cpt.getChainId
|
k.cpt.stack.push k.cpt.getChainId
|
||||||
|
|
||||||
selfBalanceOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc selfBalanceOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x47, Get current contract's balance.
|
## 0x47, Get current contract's balance.
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
cpt.stack.push cpt.getBalance(cpt.msg.contractAddress)
|
cpt.stack.push cpt.getBalance(cpt.msg.contractAddress)
|
||||||
|
|
||||||
baseFeeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc baseFeeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x48, Get the block's base fee.
|
## 0x48, Get the block's base fee.
|
||||||
k.cpt.stack.push k.cpt.getBaseFee
|
k.cpt.stack.push k.cpt.getBaseFee
|
||||||
|
|
||||||
blobHashOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc blobHashOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x49, Get current transaction's EIP-4844 versioned hash.
|
## 0x49, Get current transaction's EIP-4844 versioned hash.
|
||||||
let
|
let
|
||||||
index = ? k.cpt.stack.popSafeInt()
|
index = ? k.cpt.stack.popSafeInt()
|
||||||
|
@ -83,7 +82,7 @@ const
|
||||||
else:
|
else:
|
||||||
k.cpt.stack.push 0
|
k.cpt.stack.push 0
|
||||||
|
|
||||||
blobBaseFeeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc blobBaseFeeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x4a, Get the block's base fee.
|
## 0x4a, Get the block's base fee.
|
||||||
k.cpt.stack.push k.cpt.getBlobBaseFee
|
k.cpt.stack.push k.cpt.getBlobBaseFee
|
||||||
|
|
||||||
|
|
|
@ -198,8 +198,7 @@ else:
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc callOp(k: var VmCtx): EvmResultVoid =
|
||||||
callOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0xf1, Message-Call into an account
|
## 0xf1, Message-Call into an account
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
|
|
||||||
|
@ -283,7 +282,7 @@ const
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
callCodeOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc callCodeOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xf2, Message-call into this account with an alternative account's code.
|
## 0xf2, Message-call into this account with an alternative account's code.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -360,7 +359,7 @@ const
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
delegateCallOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc delegateCallOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xf4, Message-call into this account with an alternative account's
|
## 0xf4, Message-call into this account with an alternative account's
|
||||||
## code, but persisting the current values for sender and value.
|
## code, but persisting the current values for sender and value.
|
||||||
let
|
let
|
||||||
|
@ -432,7 +431,7 @@ const
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
staticCallOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc staticCallOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xfa, Static message-call into an account.
|
## 0xfa, Static message-call into an account.
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
@ -81,8 +81,8 @@ else:
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
|
||||||
createOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc createOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xf0, Create a new account with associated code
|
## 0xf0, Create a new account with associated code
|
||||||
? checkInStaticContext(k.cpt)
|
? checkInStaticContext(k.cpt)
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ const
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
||||||
create2Op: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc create2Op(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xf5, Behaves identically to CREATE, except using keccak256
|
## 0xf5, Behaves identically to CREATE, except using keccak256
|
||||||
? checkInStaticContext(k.cpt)
|
? checkInStaticContext(k.cpt)
|
||||||
|
|
||||||
|
|
|
@ -35,21 +35,20 @@ when not defined(evmc_enabled):
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc addressOp (k: var VmCtx): EvmResultVoid =
|
||||||
addressOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x30, Get address of currently executing account.
|
## 0x30, Get address of currently executing account.
|
||||||
k.cpt.stack.push k.cpt.msg.contractAddress
|
k.cpt.stack.push k.cpt.msg.contractAddress
|
||||||
|
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
balanceOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc balanceOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x31, Get balance of the given account.
|
## 0x31, Get balance of the given account.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
address = ? cpt.stack.popAddress
|
address = ? cpt.stack.popAddress
|
||||||
cpt.stack.push cpt.getBalance(address)
|
cpt.stack.push cpt.getBalance(address)
|
||||||
|
|
||||||
balanceEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc balanceEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x31, EIP292: Get balance of the given account for Berlin and later
|
## 0x31, EIP292: Get balance of the given account for Berlin and later
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -61,20 +60,20 @@ const
|
||||||
|
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
originOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc originOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x32, Get execution origination address.
|
## 0x32, Get execution origination address.
|
||||||
k.cpt.stack.push k.cpt.getOrigin()
|
k.cpt.stack.push k.cpt.getOrigin()
|
||||||
|
|
||||||
callerOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc callerOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x33, Get caller address.
|
## 0x33, Get caller address.
|
||||||
k.cpt.stack.push k.cpt.msg.sender
|
k.cpt.stack.push k.cpt.msg.sender
|
||||||
|
|
||||||
callValueOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc callValueOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x34, Get deposited value by the instruction/transaction
|
## 0x34, Get deposited value by the instruction/transaction
|
||||||
## responsible for this execution
|
## responsible for this execution
|
||||||
k.cpt.stack.push k.cpt.msg.value
|
k.cpt.stack.push k.cpt.msg.value
|
||||||
|
|
||||||
callDataLoadOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc callDataLoadOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x35, Get input data of current environment
|
## 0x35, Get input data of current environment
|
||||||
let
|
let
|
||||||
startPos = ? k.cpt.stack.popInt()
|
startPos = ? k.cpt.stack.popInt()
|
||||||
|
@ -94,12 +93,12 @@ const
|
||||||
k.cpt.stack.push value
|
k.cpt.stack.push value
|
||||||
|
|
||||||
|
|
||||||
callDataSizeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc callDataSizeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x36, Get size of input data in current environment.
|
## 0x36, Get size of input data in current environment.
|
||||||
k.cpt.stack.push k.cpt.msg.data.len.u256
|
k.cpt.stack.push k.cpt.msg.data.len.u256
|
||||||
|
|
||||||
|
|
||||||
callDataCopyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc callDataCopyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x37, Copy input data in current environment to memory.
|
## 0x37, Copy input data in current environment to memory.
|
||||||
let (memStartPos, copyStartPos, size) = ? k.cpt.stack.popInt(3)
|
let (memStartPos, copyStartPos, size) = ? k.cpt.stack.popInt(3)
|
||||||
|
|
||||||
|
@ -115,13 +114,13 @@ const
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
|
||||||
codeSizeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc codeSizeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x38, Get size of code running in current environment.
|
## 0x38, Get size of code running in current environment.
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
cpt.stack.push cpt.code.len
|
cpt.stack.push cpt.code.len
|
||||||
|
|
||||||
|
|
||||||
codeCopyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc codeCopyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x39, Copy code running in current environment to memory.
|
## 0x39, Copy code running in current environment to memory.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -138,13 +137,13 @@ const
|
||||||
cpt.memory.writePadded(cpt.code.bytes, memPos, copyPos, len)
|
cpt.memory.writePadded(cpt.code.bytes, memPos, copyPos, len)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
gasPriceOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc gasPriceOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3A, Get price of gas in current environment.
|
## 0x3A, Get price of gas in current environment.
|
||||||
k.cpt.stack.push k.cpt.getGasPrice()
|
k.cpt.stack.push k.cpt.getGasPrice()
|
||||||
|
|
||||||
# -----------
|
# -----------
|
||||||
|
|
||||||
extCodeSizeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeSizeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3b, Get size of an account's code
|
## 0x3b, Get size of an account's code
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -152,7 +151,7 @@ const
|
||||||
|
|
||||||
cpt.stack.push cpt.getCodeSize(address)
|
cpt.stack.push cpt.getCodeSize(address)
|
||||||
|
|
||||||
extCodeSizeEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeSizeEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3b, Get size of an account's code
|
## 0x3b, Get size of an account's code
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -164,7 +163,7 @@ const
|
||||||
|
|
||||||
# -----------
|
# -----------
|
||||||
|
|
||||||
extCodeCopyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeCopyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3c, Copy an account's code to memory.
|
## 0x3c, Copy an account's code to memory.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -182,7 +181,7 @@ const
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
|
||||||
extCodeCopyEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeCopyEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3c, Copy an account's code to memory.
|
## 0x3c, Copy an account's code to memory.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -201,13 +200,13 @@ const
|
||||||
|
|
||||||
# -----------
|
# -----------
|
||||||
|
|
||||||
returnDataSizeOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc returnDataSizeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3d, Get size of output data from the previous call from the
|
## 0x3d, Get size of output data from the previous call from the
|
||||||
## current environment.
|
## current environment.
|
||||||
k.cpt.stack.push k.cpt.returnData.len
|
k.cpt.stack.push k.cpt.returnData.len
|
||||||
|
|
||||||
|
|
||||||
returnDataCopyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc returnDataCopyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3e, Copy output data from the previous call to memory.
|
## 0x3e, Copy output data from the previous call to memory.
|
||||||
let
|
let
|
||||||
(memStartPos, copyStartPos, size) = ? k.cpt.stack.popInt(3)
|
(memStartPos, copyStartPos, size) = ? k.cpt.stack.popInt(3)
|
||||||
|
@ -225,7 +224,7 @@ const
|
||||||
|
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|
||||||
extCodeHashOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeHashOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3f, Returns the keccak256 hash of a contract’s code
|
## 0x3f, Returns the keccak256 hash of a contract’s code
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -233,7 +232,7 @@ const
|
||||||
|
|
||||||
cpt.stack.push cpt.getCodeHash(address)
|
cpt.stack.push cpt.getCodeHash(address)
|
||||||
|
|
||||||
extCodeHashEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc extCodeHashEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x3f, EIP2929: Returns the keccak256 hash of a contract’s code
|
## 0x3f, EIP2929: Returns the keccak256 hash of a contract’s code
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -255,7 +254,7 @@ const
|
||||||
name: "address",
|
name: "address",
|
||||||
info: "Get address of currently executing account",
|
info: "Get address of currently executing account",
|
||||||
exec: (prep: VmOpIgnore,
|
exec: (prep: VmOpIgnore,
|
||||||
run: addressOp,
|
run: VmOpFn addressOp,
|
||||||
post: VmOpIgnore)),
|
post: VmOpIgnore)),
|
||||||
|
|
||||||
(opCode: Balance, ## 0x31, Balance
|
(opCode: Balance, ## 0x31, Balance
|
||||||
|
|
|
@ -30,8 +30,7 @@ import
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc sha3Op(k: var VmCtx): EvmResultVoid =
|
||||||
sha3Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x20, Compute Keccak-256 hash.
|
## 0x20, Compute Keccak-256 hash.
|
||||||
let
|
let
|
||||||
(startPos, length) = ? k.cpt.stack.popInt(2)
|
(startPos, length) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
|
@ -122,14 +122,13 @@ func jumpImpl(c: Computation; jumpTarget: UInt256): EvmResultVoid =
|
||||||
# Private, op handlers implementation
|
# Private, op handlers implementation
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc popOp(k: var VmCtx): EvmResultVoid =
|
||||||
popOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x50, Remove item from stack.
|
## 0x50, Remove item from stack.
|
||||||
k.cpt.stack.popInt.isOkOr:
|
k.cpt.stack.popInt.isOkOr:
|
||||||
return err(error)
|
return err(error)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
mloadOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc mloadOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x51, Load word from memory
|
## 0x51, Load word from memory
|
||||||
let memStartPos = ? k.cpt.stack.popInt()
|
let memStartPos = ? k.cpt.stack.popInt()
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ const
|
||||||
k.cpt.stack.push k.cpt.memory.read32Bytes(memPos)
|
k.cpt.stack.push k.cpt.memory.read32Bytes(memPos)
|
||||||
|
|
||||||
|
|
||||||
mstoreOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc mstoreOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x52, Save word to memory
|
## 0x52, Save word to memory
|
||||||
let (memStartPos, value) = ? k.cpt.stack.popInt(2)
|
let (memStartPos, value) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ const
|
||||||
k.cpt.memory.write(memPos, value.toBytesBE)
|
k.cpt.memory.write(memPos, value.toBytesBE)
|
||||||
|
|
||||||
|
|
||||||
mstore8Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc mstore8Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x53, Save byte to memory
|
## 0x53, Save byte to memory
|
||||||
let (memStartPos, value) = ? k.cpt.stack.popInt(2)
|
let (memStartPos, value) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -170,14 +169,14 @@ const
|
||||||
|
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
sloadOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sloadOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x54, Load word from storage.
|
## 0x54, Load word from storage.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
slot = ? cpt.stack.popInt()
|
slot = ? cpt.stack.popInt()
|
||||||
cpt.stack.push cpt.getStorage(slot)
|
cpt.stack.push cpt.getStorage(slot)
|
||||||
|
|
||||||
sloadEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sloadEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x54, EIP2929: Load word from storage for Berlin and later
|
## 0x54, EIP2929: Load word from storage for Berlin and later
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -188,7 +187,7 @@ const
|
||||||
|
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
sstoreOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sstoreOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x55, Save word to storage.
|
## 0x55, Save word to storage.
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -198,7 +197,7 @@ const
|
||||||
sstoreEvmcOrSstore(cpt, slot, newValue)
|
sstoreEvmcOrSstore(cpt, slot, newValue)
|
||||||
|
|
||||||
|
|
||||||
sstoreEIP1283Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sstoreEIP1283Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x55, EIP1283: sstore for Constantinople and later
|
## 0x55, EIP1283: sstore for Constantinople and later
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -208,7 +207,7 @@ const
|
||||||
sstoreEvmcOrNetGasMetering(cpt, slot, newValue)
|
sstoreEvmcOrNetGasMetering(cpt, slot, newValue)
|
||||||
|
|
||||||
|
|
||||||
sstoreEIP2200Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sstoreEIP2200Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x55, EIP2200: sstore for Istanbul and later
|
## 0x55, EIP2200: sstore for Istanbul and later
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -223,7 +222,7 @@ const
|
||||||
sstoreEvmcOrNetGasMetering(cpt, slot, newValue)
|
sstoreEvmcOrNetGasMetering(cpt, slot, newValue)
|
||||||
|
|
||||||
|
|
||||||
sstoreEIP2929Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc sstoreEIP2929Op (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x55, EIP2929: sstore for Berlin and later
|
## 0x55, EIP2929: sstore for Berlin and later
|
||||||
let
|
let
|
||||||
cpt = k.cpt
|
cpt = k.cpt
|
||||||
|
@ -251,46 +250,46 @@ const
|
||||||
|
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
jumpOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc jumpOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x56, Alter the program counter
|
## 0x56, Alter the program counter
|
||||||
let jumpTarget = ? k.cpt.stack.popInt()
|
let jumpTarget = ? k.cpt.stack.popInt()
|
||||||
jumpImpl(k.cpt, jumpTarget)
|
jumpImpl(k.cpt, jumpTarget)
|
||||||
|
|
||||||
|
|
||||||
jumpIOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc jumpIOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x57, Conditionally alter the program counter.
|
## 0x57, Conditionally alter the program counter.
|
||||||
let (jumpTarget, testedValue) = ? k.cpt.stack.popInt(2)
|
let (jumpTarget, testedValue) = ? k.cpt.stack.popInt(2)
|
||||||
if testedValue.isZero:
|
if testedValue.isZero:
|
||||||
return ok()
|
return ok()
|
||||||
jumpImpl(k.cpt, jumpTarget)
|
jumpImpl(k.cpt, jumpTarget)
|
||||||
|
|
||||||
pcOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc pcOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x58, Get the value of the program counter prior to the increment
|
## 0x58, Get the value of the program counter prior to the increment
|
||||||
## corresponding to this instruction.
|
## corresponding to this instruction.
|
||||||
k.cpt.stack.push max(k.cpt.code.pc - 1, 0)
|
k.cpt.stack.push max(k.cpt.code.pc - 1, 0)
|
||||||
|
|
||||||
msizeOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc msizeOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x59, Get the size of active memory in bytes.
|
## 0x59, Get the size of active memory in bytes.
|
||||||
k.cpt.stack.push k.cpt.memory.len
|
k.cpt.stack.push k.cpt.memory.len
|
||||||
|
|
||||||
gasOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc gasOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x5a, Get the amount of available gas, including the corresponding
|
## 0x5a, Get the amount of available gas, including the corresponding
|
||||||
## reduction for the cost of this instruction.
|
## reduction for the cost of this instruction.
|
||||||
k.cpt.stack.push k.cpt.gasMeter.gasRemaining
|
k.cpt.stack.push k.cpt.gasMeter.gasRemaining
|
||||||
|
|
||||||
jumpDestOp: VmOpFn = func (k: var VmCtx): EvmResultVoid =
|
proc jumpDestOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x5b, Mark a valid destination for jumps. This operation has no effect
|
## 0x5b, Mark a valid destination for jumps. This operation has no effect
|
||||||
## on machine state during execution.
|
## on machine state during execution.
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
tloadOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc tloadOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x5c, Load word from transient storage.
|
## 0x5c, Load word from transient storage.
|
||||||
let
|
let
|
||||||
slot = ? k.cpt.stack.popInt()
|
slot = ? k.cpt.stack.popInt()
|
||||||
val = k.cpt.getTransientStorage(slot)
|
val = k.cpt.getTransientStorage(slot)
|
||||||
k.cpt.stack.push val
|
k.cpt.stack.push val
|
||||||
|
|
||||||
tstoreOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc tstoreOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x5d, Save word to transient storage.
|
## 0x5d, Save word to transient storage.
|
||||||
? checkInStaticContext(k.cpt)
|
? checkInStaticContext(k.cpt)
|
||||||
|
|
||||||
|
@ -300,7 +299,7 @@ const
|
||||||
k.cpt.setTransientStorage(slot, val)
|
k.cpt.setTransientStorage(slot, val)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
mCopyOp: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
proc mCopyOp (k: var VmCtx): EvmResultVoid =
|
||||||
## 0x5e, Copy memory
|
## 0x5e, Copy memory
|
||||||
let (dst, src, size) = ? k.cpt.stack.popInt(3)
|
let (dst, src, size) = ? k.cpt.stack.popInt(3)
|
||||||
|
|
||||||
|
@ -326,7 +325,7 @@ const
|
||||||
name: "pop",
|
name: "pop",
|
||||||
info: "Remove item from stack",
|
info: "Remove item from stack",
|
||||||
exec: (prep: VmOpIgnore,
|
exec: (prep: VmOpIgnore,
|
||||||
run: popOp,
|
run: VmOpFn popOp,
|
||||||
post: VmOpIgnore)),
|
post: VmOpIgnore)),
|
||||||
|
|
||||||
(opCode: Mload, ## 0x51, Load word from memory
|
(opCode: Mload, ## 0x51, Load word from memory
|
||||||
|
|
|
@ -65,11 +65,11 @@ genOphList fnName, fnInfo, inxRange, "VmOpExecPush", opName
|
||||||
# about which opcodes are for which forks, but that seems uglier than
|
# about which opcodes are for which forks, but that seems uglier than
|
||||||
# just adding Push0 here as a special case.)
|
# just adding Push0 here as a special case.)
|
||||||
|
|
||||||
const
|
proc push0Op(k: var VmCtx): EvmResultVoid =
|
||||||
push0Op: VmOpFn = proc (k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0x5f, push 0 onto the stack
|
## 0x5f, push 0 onto the stack
|
||||||
k.cpt.stack.push(0)
|
k.cpt.stack.push(0)
|
||||||
|
|
||||||
|
const
|
||||||
VmOpExecPushZero*: seq[VmOpExec] = @[
|
VmOpExecPushZero*: seq[VmOpExec] = @[
|
||||||
|
|
||||||
(opCode: Push0, ## 0x5f, push 0 onto the stack
|
(opCode: Push0, ## 0x5f, push 0 onto the stack
|
||||||
|
|
|
@ -37,8 +37,7 @@ when not defined(evmc_enabled):
|
||||||
# Private
|
# Private
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
proc returnOp(k: var VmCtx): EvmResultVoid =
|
||||||
returnOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
|
||||||
## 0xf3, Halt execution returning output data.
|
## 0xf3, Halt execution returning output data.
|
||||||
let (startPos, size) = ? k.cpt.stack.popInt(2)
|
let (startPos, size) = ? k.cpt.stack.popInt(2)
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ const
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
|
||||||
revertOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc revertOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xfd, Halt execution reverting state changes but returning data
|
## 0xfd, Halt execution reverting state changes but returning data
|
||||||
## and remaining gas.
|
## and remaining gas.
|
||||||
let (startPos, size) = ? k.cpt.stack.popInt(2)
|
let (startPos, size) = ? k.cpt.stack.popInt(2)
|
||||||
|
@ -67,12 +66,12 @@ const
|
||||||
k.cpt.setError(EVMC_REVERT, "REVERT opcode executed", false)
|
k.cpt.setError(EVMC_REVERT, "REVERT opcode executed", false)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
invalidOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc invalidOp(k: var VmCtx): EvmResultVoid =
|
||||||
err(opErr(InvalidInstruction))
|
err(opErr(InvalidInstruction))
|
||||||
|
|
||||||
# -----------
|
# -----------
|
||||||
|
|
||||||
selfDestructOp: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc selfDestructOp(k: var VmCtx): EvmResultVoid =
|
||||||
## 0xff, Halt execution and register account for later deletion.
|
## 0xff, Halt execution and register account for later deletion.
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
let beneficiary = ? cpt.stack.popAddress()
|
let beneficiary = ? cpt.stack.popAddress()
|
||||||
|
@ -84,7 +83,7 @@ const
|
||||||
cpt.selfDestruct(beneficiary)
|
cpt.selfDestruct(beneficiary)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
selfDestructEIP150Op: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc selfDestructEIP150Op(k: var VmCtx): EvmResultVoid =
|
||||||
## selfDestructEip150 (auto generated comment)
|
## selfDestructEip150 (auto generated comment)
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
let beneficiary = ? cpt.stack.popAddress()
|
let beneficiary = ? cpt.stack.popAddress()
|
||||||
|
@ -99,7 +98,7 @@ const
|
||||||
cpt.selfDestruct(beneficiary)
|
cpt.selfDestruct(beneficiary)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
selfDestructEIP161Op: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc selfDestructEIP161Op(k: var VmCtx): EvmResultVoid =
|
||||||
## selfDestructEip161 (auto generated comment)
|
## selfDestructEip161 (auto generated comment)
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
? checkInStaticContext(cpt)
|
? checkInStaticContext(cpt)
|
||||||
|
@ -120,7 +119,7 @@ const
|
||||||
cpt.selfDestruct(beneficiary)
|
cpt.selfDestruct(beneficiary)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
selfDestructEIP2929Op: VmOpFn = proc(k: var VmCtx): EvmResultVoid =
|
proc selfDestructEIP2929Op(k: var VmCtx): EvmResultVoid =
|
||||||
## selfDestructEIP2929 (auto generated comment)
|
## selfDestructEIP2929 (auto generated comment)
|
||||||
let cpt = k.cpt
|
let cpt = k.cpt
|
||||||
? checkInStaticContext(cpt)
|
? checkInStaticContext(cpt)
|
||||||
|
|
Loading…
Reference in New Issue