Remove pre and post opcode handlers from EVM (#2409)

This commit is contained in:
andri lim 2024-06-24 12:58:15 +07:00 committed by GitHub
parent 9521582005
commit 6a10dfd0fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 177 additions and 288 deletions

View File

@ -97,7 +97,7 @@ const
# #
# to pick right function when <op> is a variable . Using # to pick right function when <op> is a variable . Using
# #
# VmOpHandlers[fork][op].exec.run # VmOpHandlers[fork][op].exec
# #
# only works when <op> is a constant. There seems to be some optimisation # only works when <op> is a constant. There seems to be some optimisation
# that garbles the <exec> sub-structures elements <prep>, <run>, and <post>. # that garbles the <exec> sub-structures elements <prep>, <run>, and <post>.
@ -113,7 +113,7 @@ const
for op in Op: for op in Op:
rc[fork][op].name = tab[op].name rc[fork][op].name = tab[op].name
rc[fork][op].info = tab[op].info rc[fork][op].info = tab[op].info
rc[fork][op].run = tab[op].exec.run rc[fork][op].run = tab[op].exec
rc rc
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -290,179 +290,157 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "add", name: "add",
info: "Addition operation", info: "Addition operation",
exec: (prep: VmOpIgnore, exec: VmOpFn addOp),
run: VmOpFn addOp,
post: VmOpIgnore)),
(opCode: Mul, ## 0x02, Multiplication (opCode: Mul, ## 0x02, Multiplication
forks: VmOpAllForks, forks: VmOpAllForks,
name: "mul", name: "mul",
info: "Multiplication operation", info: "Multiplication operation",
exec: (prep: VmOpIgnore, exec: mulOp),
run: mulOp,
post: VmOpIgnore)),
(opCode: Sub, ## 0x03, Subtraction (opCode: Sub, ## 0x03, Subtraction
forks: VmOpAllForks, forks: VmOpAllForks,
name: "sub", name: "sub",
info: "Subtraction operation", info: "Subtraction operation",
exec: (prep: VmOpIgnore, exec: subOp),
run: subOp,
post: VmOpIgnore)),
(opCode: Div, ## 0x04, Division (opCode: Div, ## 0x04, Division
forks: VmOpAllForks, forks: VmOpAllForks,
name: "divide", name: "divide",
info: "Integer division operation", info: "Integer division operation",
exec: (prep: VmOpIgnore, exec: divideOp),
run: divideOp,
post: VmOpIgnore)),
(opCode: Sdiv, ## 0x05, Signed division (opCode: Sdiv, ## 0x05, Signed division
forks: VmOpAllForks, forks: VmOpAllForks,
name: "sdiv", name: "sdiv",
info: "Signed integer division operation (truncated)", info: "Signed integer division operation (truncated)",
exec: (prep: VmOpIgnore, exec: sdivOp),
run: sdivOp,
post: VmOpIgnore)),
(opCode: Mod, ## 0x06, Modulo (opCode: Mod, ## 0x06, Modulo
forks: VmOpAllForks, forks: VmOpAllForks,
name: "modulo", name: "modulo",
info: "Modulo remainder operation", info: "Modulo remainder operation",
exec: (prep: VmOpIgnore, exec: moduloOp),
run: moduloOp,
post: VmOpIgnore)),
(opCode: Smod, ## 0x07, Signed modulo (opCode: Smod, ## 0x07, Signed modulo
forks: VmOpAllForks, forks: VmOpAllForks,
name: "smod", name: "smod",
info: "Signed modulo remainder operation", info: "Signed modulo remainder operation",
exec: (prep: VmOpIgnore, exec: smodOp),
run: smodOp,
post: VmOpIgnore)),
(opCode: Addmod, ## 0x08, Modulo addition, Intermediate (opCode: Addmod, ## 0x08, Modulo addition, Intermediate
## computations do not roll over at 2^256 ## computations do not roll over at 2^256
forks: VmOpAllForks, forks: VmOpAllForks,
name: "addmod", name: "addmod",
info: "Modulo addition operation", info: "Modulo addition operation",
exec: (prep: VmOpIgnore, exec: addmodOp),
run: addmodOp,
post: VmOpIgnore)),
(opCode: Mulmod, ## 0x09, Modulo multiplication, Intermediate (opCode: Mulmod, ## 0x09, Modulo multiplication, Intermediate
## computations do not roll over at 2^256 ## computations do not roll over at 2^256
forks: VmOpAllForks, forks: VmOpAllForks,
name: "mulmod", name: "mulmod",
info: "Modulo multiplication operation", info: "Modulo multiplication operation",
exec: (prep: VmOpIgnore, exec: mulmodOp),
run: mulmodOp,
post: VmOpIgnore)),
(opCode: Exp, ## 0x0a, Exponentiation (opCode: Exp, ## 0x0a, Exponentiation
forks: VmOpAllForks, forks: VmOpAllForks,
name: "exp", name: "exp",
info: "Exponentiation operation", info: "Exponentiation operation",
exec: (prep: VmOpIgnore, exec: expOp),
run: expOp,
post: VmOpIgnore)),
(opCode: SignExtend, ## 0x0b, Extend 2's complemet length (opCode: SignExtend, ## 0x0b, Extend 2's complemet length
forks: VmOpAllForks, forks: VmOpAllForks,
name: "signExtend", name: "signExtend",
info: "Extend length of twos complement signed integer", info: "Extend length of twos complement signed integer",
exec: (prep: VmOpIgnore, exec: signExtendOp),
run: signExtendOp,
post: VmOpIgnore)),
(opCode: Lt, ## 0x10, Less-than (opCode: Lt, ## 0x10, Less-than
forks: VmOpAllForks, forks: VmOpAllForks,
name: "lt", name: "lt",
info: "Less-than comparison", info: "Less-than comparison",
exec: (prep: VmOpIgnore, exec: ltOp),
run: ltOp,
post: VmOpIgnore)),
(opCode: Gt, ## 0x11, Greater-than (opCode: Gt, ## 0x11, Greater-than
forks: VmOpAllForks, forks: VmOpAllForks,
name: "gt", name: "gt",
info: "Greater-than comparison", info: "Greater-than comparison",
exec: (prep: VmOpIgnore, exec: gtOp),
run: gtOp,
post: VmOpIgnore)),
(opCode: Slt, ## 0x12, Signed less-than (opCode: Slt, ## 0x12, Signed less-than
forks: VmOpAllForks, forks: VmOpAllForks,
name: "slt", name: "slt",
info: "Signed less-than comparison", info: "Signed less-than comparison",
exec: (prep: VmOpIgnore, exec: sltOp),
run: sltOp,
post: VmOpIgnore)),
(opCode: Sgt, ## 0x13, Signed greater-than (opCode: Sgt, ## 0x13, Signed greater-than
forks: VmOpAllForks, forks: VmOpAllForks,
name: "sgt", name: "sgt",
info: "Signed greater-than comparison", info: "Signed greater-than comparison",
exec: (prep: VmOpIgnore, exec: sgtOp),
run: sgtOp,
post: VmOpIgnore)),
(opCode: Eq, ## 0x14, Equality (opCode: Eq, ## 0x14, Equality
forks: VmOpAllForks, forks: VmOpAllForks,
name: "eq", name: "eq",
info: "Equality comparison", info: "Equality comparison",
exec: (prep: VmOpIgnore, exec: eqOp),
run: eqOp,
post: VmOpIgnore)),
(opCode: IsZero, ## 0x15, Not operator (opCode: IsZero, ## 0x15, Not operator
forks: VmOpAllForks, forks: VmOpAllForks,
name: "isZero", name: "isZero",
info: "Simple not operator (Note: real Yellow Paper description)", info: "Simple not operator (Note: real Yellow Paper description)",
exec: (prep: VmOpIgnore, exec: isZeroOp),
run: isZeroOp,
post: VmOpIgnore)),
(opCode: And, ## 0x16, AND (opCode: And, ## 0x16, AND
forks: VmOpAllForks, forks: VmOpAllForks,
name: "andOp", name: "andOp",
info: "Bitwise AND operation", info: "Bitwise AND operation",
exec: (prep: VmOpIgnore, exec: andOp),
run: andOp,
post: VmOpIgnore)),
(opCode: Or, ## 0x17, OR (opCode: Or, ## 0x17, OR
forks: VmOpAllForks, forks: VmOpAllForks,
name: "orOp", name: "orOp",
info: "Bitwise OR operation", info: "Bitwise OR operation",
exec: (prep: VmOpIgnore, exec: orOp),
run: orOp,
post: VmOpIgnore)),
(opCode: Xor, ## 0x18, XOR (opCode: Xor, ## 0x18, XOR
forks: VmOpAllForks, forks: VmOpAllForks,
name: "xorOp", name: "xorOp",
info: "Bitwise XOR operation", info: "Bitwise XOR operation",
exec: (prep: VmOpIgnore, exec: xorOp),
run: xorOp,
post: VmOpIgnore)),
(opCode: Not, ## 0x19, NOT (opCode: Not, ## 0x19, NOT
forks: VmOpAllForks, forks: VmOpAllForks,
name: "notOp", name: "notOp",
info: "Bitwise NOT operation", info: "Bitwise NOT operation",
exec: (prep: VmOpIgnore, exec: notOp),
run: notOp,
post: VmOpIgnore)),
(opCode: Byte, ## 0x1a, Retrieve byte (opCode: Byte, ## 0x1a, Retrieve byte
forks: VmOpAllForks, forks: VmOpAllForks,
name: "byteOp", name: "byteOp",
info: "Retrieve single byte from word", info: "Retrieve single byte from word",
exec: (prep: VmOpIgnore, exec: byteOp),
run: byteOp,
post: VmOpIgnore)),
# Constantinople's new opcodes # Constantinople's new opcodes
@ -470,25 +448,21 @@ const
forks: VmOpConstantinopleAndLater, forks: VmOpConstantinopleAndLater,
name: "shlOp", name: "shlOp",
info: "Shift left", info: "Shift left",
exec: (prep: VmOpIgnore, exec: shlOp),
run: shlOp,
post: VmOpIgnore)),
(opCode: Shr, ## 0x1c, Shift right logical (opCode: Shr, ## 0x1c, Shift right logical
forks: VmOpConstantinopleAndLater, forks: VmOpConstantinopleAndLater,
name: "shrOp", name: "shrOp",
info: "Logical shift right", info: "Logical shift right",
exec: (prep: VmOpIgnore, exec: shrOp),
run: shrOp,
post: VmOpIgnore)),
(opCode: Sar, ## 0x1d, Shift right arithmetic (opCode: Sar, ## 0x1d, Shift right arithmetic
forks: VmOpConstantinopleAndLater, forks: VmOpConstantinopleAndLater,
name: "sarOp", name: "sarOp",
info: "Arithmetic shift right", info: "Arithmetic shift right",
exec: (prep: VmOpIgnore, exec: sarOp)]
run: sarOp,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -100,89 +100,77 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "blockhash", name: "blockhash",
info: "Get the hash of one of the 256 most recent complete blocks", info: "Get the hash of one of the 256 most recent complete blocks",
exec: (prep: VmOpIgnore, exec: blockhashOp),
run: blockhashOp,
post: VmOpIgnore)),
(opCode: Coinbase, ## 0x41, Beneficiary address (opCode: Coinbase, ## 0x41, Beneficiary address
forks: VmOpAllForks, forks: VmOpAllForks,
name: "coinbase", name: "coinbase",
info: "Get the block's beneficiary address", info: "Get the block's beneficiary address",
exec: (prep: VmOpIgnore, exec: coinBaseOp),
run: coinBaseOp,
post: VmOpIgnore)),
(opCode: Timestamp, ## 0x42, Block timestamp. (opCode: Timestamp, ## 0x42, Block timestamp.
forks: VmOpAllForks, forks: VmOpAllForks,
name: "timestamp", name: "timestamp",
info: "Get the block's timestamp", info: "Get the block's timestamp",
exec: (prep: VmOpIgnore, exec: timestampOp),
run: timestampOp,
post: VmOpIgnore)),
(opCode: Number, ## 0x43, Block number (opCode: Number, ## 0x43, Block number
forks: VmOpAllForks, forks: VmOpAllForks,
name: "blockNumber", name: "blockNumber",
info: "Get the block's number", info: "Get the block's number",
exec: (prep: VmOpIgnore, exec: blocknumberOp),
run: blocknumberOp,
post: VmOpIgnore)),
(opCode: Difficulty, ## 0x44, Block difficulty (opCode: Difficulty, ## 0x44, Block difficulty
forks: VmOpAllForks, forks: VmOpAllForks,
name: "difficulty", name: "difficulty",
info: "Get the block's difficulty", info: "Get the block's difficulty",
exec: (prep: VmOpIgnore, exec: difficultyOp),
run: difficultyOp,
post: VmOpIgnore)),
(opCode: GasLimit, ## 0x45, Block gas limit (opCode: GasLimit, ## 0x45, Block gas limit
forks: VmOpAllForks, forks: VmOpAllForks,
name: "gasLimit", name: "gasLimit",
info: "Get the block's gas limit", info: "Get the block's gas limit",
exec: (prep: VmOpIgnore, exec: gasLimitOp),
run: gasLimitOp,
post: VmOpIgnore)),
(opCode: ChainIdOp, ## 0x46, EIP-155 chain identifier (opCode: ChainIdOp, ## 0x46, EIP-155 chain identifier
forks: VmOpIstanbulAndLater, forks: VmOpIstanbulAndLater,
name: "chainId", name: "chainId",
info: "Get current chains EIP-155 unique identifier", info: "Get current chains EIP-155 unique identifier",
exec: (prep: VmOpIgnore, exec: chainIdOp),
run: chainIdOp,
post: VmOpIgnore)),
(opCode: SelfBalance, ## 0x47, Contract balance. (opCode: SelfBalance, ## 0x47, Contract balance.
forks: VmOpIstanbulAndLater, forks: VmOpIstanbulAndLater,
name: "selfBalance", name: "selfBalance",
info: "Get current contract's balance", info: "Get current contract's balance",
exec: (prep: VmOpIgnore, exec: selfBalanceOp),
run: selfBalanceOp,
post: VmOpIgnore)),
(opCode: BaseFee, ## 0x48, EIP-1559 Block base fee. (opCode: BaseFee, ## 0x48, EIP-1559 Block base fee.
forks: VmOpLondonAndLater, forks: VmOpLondonAndLater,
name: "baseFee", name: "baseFee",
info: "Get current block's EIP-1559 base fee", info: "Get current block's EIP-1559 base fee",
exec: (prep: VmOpIgnore, exec: baseFeeOp),
run: baseFeeOp,
post: VmOpIgnore)),
(opCode: BlobHash, ## 0x49, EIP-4844 Transaction versioned hash (opCode: BlobHash, ## 0x49, EIP-4844 Transaction versioned hash
forks: VmOpCancunAndLater, forks: VmOpCancunAndLater,
name: "blobHash", name: "blobHash",
info: "Get current transaction's EIP-4844 versioned hash", info: "Get current transaction's EIP-4844 versioned hash",
exec: (prep: VmOpIgnore, exec: blobHashOp),
run: blobHashOp,
post: VmOpIgnore)),
(opCode: BlobBaseFee, ## 0x4a, EIP-7516 Returns the current data-blob base-fee (opCode: BlobBaseFee, ## 0x4a, EIP-7516 Returns the current data-blob base-fee
forks: VmOpCancunAndLater, forks: VmOpCancunAndLater,
name: "blobBaseFee", name: "blobBaseFee",
info: "Returns the current data-blob base-fee", info: "Returns the current data-blob base-fee",
exec: (prep: VmOpIgnore, exec: blobBaseFeeOp)]
run: blobBaseFeeOp,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -514,34 +514,29 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "call", name: "call",
info: "Message-Call into an account", info: "Message-Call into an account",
exec: (prep: VmOpIgnore, exec: callOp),
run: callOp,
post: VmOpIgnore)),
(opCode: CallCode, ## 0xf2, Message-Call with alternative code (opCode: CallCode, ## 0xf2, Message-Call with alternative code
forks: VmOpAllForks, forks: VmOpAllForks,
name: "callCode", name: "callCode",
info: "Message-call into this account with alternative account's code", info: "Message-call into this account with alternative account's code",
exec: (prep: VmOpIgnore, exec: callCodeOp),
run: callCodeOp,
post: VmOpIgnore)),
(opCode: DelegateCall, ## 0xf4, CallCode with persisting sender and value (opCode: DelegateCall, ## 0xf4, CallCode with persisting sender and value
forks: VmOpHomesteadAndLater, forks: VmOpHomesteadAndLater,
name: "delegateCall", name: "delegateCall",
info: "Message-call into this account with an alternative account's " & info: "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.",
exec: (prep: VmOpIgnore, exec: delegateCallOp),
run: delegateCallOp,
post: VmOpIgnore)),
(opCode: StaticCall, ## 0xfa, Static message-call into an account (opCode: StaticCall, ## 0xfa, Static message-call into an account
forks: VmOpByzantiumAndLater, forks: VmOpByzantiumAndLater,
name: "staticCall", name: "staticCall",
info: "Static message-call into an account", info: "Static message-call into an account",
exec: (prep: VmOpIgnore, exec: staticCallOp)]
run: staticCallOp,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -255,17 +255,14 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "create", name: "create",
info: "Create a new account with associated code", info: "Create a new account with associated code",
exec: (prep: VmOpIgnore, exec: createOp),
run: createOp,
post: VmOpIgnore)),
(opCode: Create2, ## 0xf5, Create using keccak256 (opCode: Create2, ## 0xf5, Create using keccak256
forks: VmOpConstantinopleAndLater, forks: VmOpConstantinopleAndLater,
name: "create2", name: "create2",
info: "Behaves identically to CREATE, except using keccak256", info: "Behaves identically to CREATE, except using keccak256",
exec: (prep: VmOpIgnore, exec: create2Op)]
run: create2Op,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -28,20 +28,12 @@ type
## back via argument descriptor ``k`` ## back via argument descriptor ``k``
proc(k: var VmCtx): EvmResultVoid {.nimcall, gcsafe, raises:[].} proc(k: var VmCtx): EvmResultVoid {.nimcall, gcsafe, raises:[].}
VmOpHanders* = tuple ## three step op code execution, typically
## only the ``run`` entry is activated
prep: VmOpFn
run: VmOpFn
post: VmOpFn
VmOpExec* = tuple ## op code handler entry VmOpExec* = tuple ## op code handler entry
opCode: Op ## index back-reference opCode: Op ## index back-reference
forks: set[EVMFork] ## forks applicable for this operation forks: set[EVMFork] ## forks applicable for this operation
name: string ## handler name name: string ## handler name
info: string ## handter info, explainer info: string ## handter info, explainer
exec: VmOpHanders exec: VmOpFn
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Public # Public

View File

@ -253,163 +253,142 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "address", name: "address",
info: "Get address of currently executing account", info: "Get address of currently executing account",
exec: (prep: VmOpIgnore, exec: VmOpFn addressOp),
run: VmOpFn addressOp,
post: VmOpIgnore)),
(opCode: Balance, ## 0x31, Balance (opCode: Balance, ## 0x31, Balance
forks: VmOpAllForks - VmOpBerlinAndLater, forks: VmOpAllForks - VmOpBerlinAndLater,
name: "balance", name: "balance",
info: "Get balance of the given account", info: "Get balance of the given account",
exec: (prep: VmOpIgnore, exec: balanceOp),
run: balanceOp,
post: VmOpIgnore)),
(opCode: Balance, ## 0x31, Balance for Berlin and later (opCode: Balance, ## 0x31, Balance for Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "balanceEIP2929", name: "balanceEIP2929",
info: "EIP2929: Get balance of the given account", info: "EIP2929: Get balance of the given account",
exec: (prep: VmOpIgnore, exec: balanceEIP2929Op),
run: balanceEIP2929Op,
post: VmOpIgnore)),
(opCode: Origin, ## 0x32, Origination address (opCode: Origin, ## 0x32, Origination address
forks: VmOpAllForks, forks: VmOpAllForks,
name: "origin", name: "origin",
info: "Get execution origination address", info: "Get execution origination address",
exec: (prep: VmOpIgnore, exec: originOp),
run: originOp,
post: VmOpIgnore)),
(opCode: Caller, ## 0x33, Caller address (opCode: Caller, ## 0x33, Caller address
forks: VmOpAllForks, forks: VmOpAllForks,
name: "caller", name: "caller",
info: "Get caller address", info: "Get caller address",
exec: (prep: VmOpIgnore, exec: callerOp),
run: callerOp,
post: VmOpIgnore)),
(opCode: CallValue, ## 0x34, Execution deposited value (opCode: CallValue, ## 0x34, Execution deposited value
forks: VmOpAllForks, forks: VmOpAllForks,
name: "callValue", name: "callValue",
info: "Get deposited value by the instruction/transaction " & info: "Get deposited value by the instruction/transaction " &
"responsible for this execution", "responsible for this execution",
exec: (prep: VmOpIgnore, exec: callValueOp),
run: callValueOp,
post: VmOpIgnore)),
(opCode: CallDataLoad, ## 0x35, Input data (opCode: CallDataLoad, ## 0x35, Input data
forks: VmOpAllForks, forks: VmOpAllForks,
name: "callDataLoad", name: "callDataLoad",
info: "Get input data of current environment", info: "Get input data of current environment",
exec: (prep: VmOpIgnore, exec: callDataLoadOp),
run: callDataLoadOp,
post: VmOpIgnore)),
(opCode: CallDataSize, ## 0x36, Size of input data (opCode: CallDataSize, ## 0x36, Size of input data
forks: VmOpAllForks, forks: VmOpAllForks,
name: "callDataSize", name: "callDataSize",
info: "Get size of input data in current environment", info: "Get size of input data in current environment",
exec: (prep: VmOpIgnore, exec: callDataSizeOp),
run: callDataSizeOp,
post: VmOpIgnore)),
(opCode: CallDataCopy, ## 0x37, Copy input data to memory. (opCode: CallDataCopy, ## 0x37, Copy input data to memory.
forks: VmOpAllForks, forks: VmOpAllForks,
name: "callDataCopy", name: "callDataCopy",
info: "Copy input data in current environment to memory", info: "Copy input data in current environment to memory",
exec: (prep: VmOpIgnore, exec: callDataCopyOp),
run: callDataCopyOp,
post: VmOpIgnore)),
(opCode: CodeSize, ## 0x38, Size of code (opCode: CodeSize, ## 0x38, Size of code
forks: VmOpAllForks, forks: VmOpAllForks,
name: "codeSize", name: "codeSize",
info: "Get size of code running in current environment", info: "Get size of code running in current environment",
exec: (prep: VmOpIgnore, exec: codeSizeOp),
run: codeSizeOp,
post: VmOpIgnore)),
(opCode: CodeCopy, ## 0x39, Copy code to memory. (opCode: CodeCopy, ## 0x39, Copy code to memory.
forks: VmOpAllForks, forks: VmOpAllForks,
name: "codeCopy", name: "codeCopy",
info: "Copy code running in current environment to memory", info: "Copy code running in current environment to memory",
exec: (prep: VmOpIgnore, exec: codeCopyOp),
run: codeCopyOp,
post: VmOpIgnore)),
(opCode: GasPrice, ## 0x3a, Gas price (opCode: GasPrice, ## 0x3a, Gas price
forks: VmOpAllForks, forks: VmOpAllForks,
name: "gasPrice", name: "gasPrice",
info: "Get price of gas in current environment", info: "Get price of gas in current environment",
exec: (prep: VmOpIgnore, exec: gasPriceOp),
run: gasPriceOp,
post: VmOpIgnore)),
(opCode: ExtCodeSize, ## 0x3b, Account code size (opCode: ExtCodeSize, ## 0x3b, Account code size
forks: VmOpAllForks - VmOpBerlinAndLater, forks: VmOpAllForks - VmOpBerlinAndLater,
name: "extCodeSize", name: "extCodeSize",
info: "Get size of an account's code", info: "Get size of an account's code",
exec: (prep: VmOpIgnore, exec: extCodeSizeOp),
run: extCodeSizeOp,
post: VmOpIgnore)),
(opCode: ExtCodeSize, ## 0x3b, Account code size for Berlin and later (opCode: ExtCodeSize, ## 0x3b, Account code size for Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "extCodeSizeEIP2929", name: "extCodeSizeEIP2929",
info: "EIP2929: Get size of an account's code", info: "EIP2929: Get size of an account's code",
exec: (prep: VmOpIgnore, exec: extCodeSizeEIP2929Op),
run: extCodeSizeEIP2929Op,
post: VmOpIgnore)),
(opCode: ExtCodeCopy, ## 0x3c, Account code copy to memory. (opCode: ExtCodeCopy, ## 0x3c, Account code copy to memory.
forks: VmOpAllForks - VmOpBerlinAndLater, forks: VmOpAllForks - VmOpBerlinAndLater,
name: "extCodeCopy", name: "extCodeCopy",
info: "Copy an account's code to memory", info: "Copy an account's code to memory",
exec: (prep: VmOpIgnore, exec: extCodeCopyOp),
run: extCodeCopyOp,
post: VmOpIgnore)),
(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin and later (opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "extCodeCopyEIP2929", name: "extCodeCopyEIP2929",
info: "EIP2929: Copy an account's code to memory", info: "EIP2929: Copy an account's code to memory",
exec: (prep: VmOpIgnore, exec: extCodeCopyEIP2929Op),
run: extCodeCopyEIP2929Op,
post: VmOpIgnore)),
(opCode: ReturnDataSize, ## 0x3d, Previous call output data size (opCode: ReturnDataSize, ## 0x3d, Previous call output data size
forks: VmOpByzantiumAndLater, forks: VmOpByzantiumAndLater,
name: "returnDataSize", name: "returnDataSize",
info: "Get size of output data from the previous call " & info: "Get size of output data from the previous call " &
"from the current environment", "from the current environment",
exec: (prep: VmOpIgnore, exec: returnDataSizeOp),
run: returnDataSizeOp,
post: VmOpIgnore)),
(opCode: ReturnDataCopy, ## 0x3e, Previous call output data copy to memory (opCode: ReturnDataCopy, ## 0x3e, Previous call output data copy to memory
forks: VmOpByzantiumAndLater, forks: VmOpByzantiumAndLater,
name: "returnDataCopy", name: "returnDataCopy",
info: "Copy output data from the previous call to memory", info: "Copy output data from the previous call to memory",
exec: (prep: VmOpIgnore, exec: returnDataCopyOp),
run: returnDataCopyOp,
post: VmOpIgnore)),
(opCode: ExtCodeHash, ## 0x3f, Contract hash (opCode: ExtCodeHash, ## 0x3f, Contract hash
forks: VmOpConstantinopleAndLater - VmOpBerlinAndLater, forks: VmOpConstantinopleAndLater - VmOpBerlinAndLater,
name: "extCodeHash", name: "extCodeHash",
info: "Returns the keccak256 hash of a contracts code", info: "Returns the keccak256 hash of a contracts code",
exec: (prep: VmOpIgnore, exec: extCodeHashOp),
run: extCodeHashOp,
post: VmOpIgnore)),
(opCode: ExtCodeHash, ## 0x3f, Contract hash for berlin and later (opCode: ExtCodeHash, ## 0x3f, Contract hash for berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "extCodeHashEIP2929", name: "extCodeHashEIP2929",
info: "EIP2929: Returns the keccak256 hash of a contracts code", info: "EIP2929: Returns the keccak256 hash of a contracts code",
exec: (prep: VmOpIgnore, exec: extCodeHashEIP2929Op)]
run: extCodeHashEIP2929Op,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -99,10 +99,7 @@ macro genOphList*(runHandler: static[OphNumToTextFn];
"info".asText(n.handlerInfo), "info".asText(n.handlerInfo),
nnkExprColonExpr.newTree( nnkExprColonExpr.newTree(
newIdentNode("exec"), newIdentNode("exec"),
nnkPar.newTree( newIdentNode(n.runHandler)))
"prep".asIdent("VmOpIgnore"),
"run".asIdent(n.runHandler),
"post".asIdent("VmOpIgnore"))))
# => const <varName>*: seq[VmOpExec] = @[ <records> ] # => const <varName>*: seq[VmOpExec] = @[ <records> ]
result = nnkStmtList.newTree( result = nnkStmtList.newTree(

View File

@ -62,9 +62,7 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "sha3", name: "sha3",
info: "Compute Keccak-256 hash", info: "Compute Keccak-256 hash",
exec: (prep: VmOpIgnore, exec: sha3Op)]
run: sha3Op,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -324,164 +324,143 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "pop", name: "pop",
info: "Remove item from stack", info: "Remove item from stack",
exec: (prep: VmOpIgnore, exec: VmOpFn popOp),
run: VmOpFn popOp,
post: VmOpIgnore)),
(opCode: Mload, ## 0x51, Load word from memory (opCode: Mload, ## 0x51, Load word from memory
forks: VmOpAllForks, forks: VmOpAllForks,
name: "mload", name: "mload",
info: "Load word from memory", info: "Load word from memory",
exec: (prep: VmOpIgnore, exec: mloadOp),
run: mloadOp,
post: VmOpIgnore)),
(opCode: Mstore, ## 0x52, Save word to memory (opCode: Mstore, ## 0x52, Save word to memory
forks: VmOpAllForks, forks: VmOpAllForks,
name: "mstore", name: "mstore",
info: "Save word to memory", info: "Save word to memory",
exec: (prep: VmOpIgnore, exec: mstoreOp),
run: mstoreOp,
post: VmOpIgnore)),
(opCode: Mstore8, ## 0x53, Save byte to memory (opCode: Mstore8, ## 0x53, Save byte to memory
forks: VmOpAllForks, forks: VmOpAllForks,
name: "mstore8", name: "mstore8",
info: "Save byte to memory", info: "Save byte to memory",
exec: (prep: VmOpIgnore, exec: mstore8Op),
run: mstore8Op,
post: VmOpIgnore)),
(opCode: Sload, ## 0x54, Load word from storage (opCode: Sload, ## 0x54, Load word from storage
forks: VmOpAllForks - VmOpBerlinAndLater, forks: VmOpAllForks - VmOpBerlinAndLater,
name: "sload", name: "sload",
info: "Load word from storage", info: "Load word from storage",
exec: (prep: VmOpIgnore, exec: sloadOp),
run: sloadOp,
post: VmOpIgnore)),
(opCode: Sload, ## 0x54, sload for Berlin and later (opCode: Sload, ## 0x54, sload for Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "sloadEIP2929", name: "sloadEIP2929",
info: "EIP2929: sload for Berlin and later", info: "EIP2929: sload for Berlin and later",
exec: (prep: VmOpIgnore, exec: sloadEIP2929Op),
run: sloadEIP2929Op,
post: VmOpIgnore)),
(opCode: Sstore, ## 0x55, Save word (opCode: Sstore, ## 0x55, Save word
forks: VmOpAllForks - VmOpConstantinopleAndLater, forks: VmOpAllForks - VmOpConstantinopleAndLater,
name: "sstore", name: "sstore",
info: "Save word to storage", info: "Save word to storage",
exec: (prep: VmOpIgnore, exec: sstoreOp),
run: sstoreOp,
post: VmOpIgnore)),
(opCode: Sstore, ## 0x55, sstore for Constantinople and later (opCode: Sstore, ## 0x55, sstore for Constantinople and later
forks: VmOpConstantinopleAndLater - VmOpPetersburgAndLater, forks: VmOpConstantinopleAndLater - VmOpPetersburgAndLater,
name: "sstoreEIP1283", name: "sstoreEIP1283",
info: "EIP1283: sstore for Constantinople and later", info: "EIP1283: sstore for Constantinople and later",
exec: (prep: VmOpIgnore, exec: sstoreEIP1283Op),
run: sstoreEIP1283Op,
post: VmOpIgnore)),
(opCode: Sstore, ## 0x55, sstore for Petersburg and later (opCode: Sstore, ## 0x55, sstore for Petersburg and later
forks: VmOpPetersburgAndLater - VmOpIstanbulAndLater, forks: VmOpPetersburgAndLater - VmOpIstanbulAndLater,
name: "sstore", name: "sstore",
info: "sstore for Constantinople and later", info: "sstore for Constantinople and later",
exec: (prep: VmOpIgnore, exec: sstoreOp),
run: sstoreOp,
post: VmOpIgnore)),
(opCode: Sstore, ## 0x55, sstore for Istanbul and later (opCode: Sstore, ## 0x55, sstore for Istanbul and later
forks: VmOpIstanbulAndLater - VmOpBerlinAndLater, forks: VmOpIstanbulAndLater - VmOpBerlinAndLater,
name: "sstoreEIP2200", name: "sstoreEIP2200",
info: "EIP2200: sstore for Istanbul and later", info: "EIP2200: sstore for Istanbul and later",
exec: (prep: VmOpIgnore, exec: sstoreEIP2200Op),
run: sstoreEIP2200Op,
post: VmOpIgnore)),
(opCode: Sstore, ## 0x55, sstore for Berlin and later (opCode: Sstore, ## 0x55, sstore for Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "sstoreEIP2929", name: "sstoreEIP2929",
info: "EIP2929: sstore for Istanbul and later", info: "EIP2929: sstore for Istanbul and later",
exec: (prep: VmOpIgnore, exec: sstoreEIP2929Op),
run: sstoreEIP2929Op,
post: VmOpIgnore)),
(opCode: Jump, ## 0x56, Jump (opCode: Jump, ## 0x56, Jump
forks: VmOpAllForks, forks: VmOpAllForks,
name: "jump", name: "jump",
info: "Alter the program counter", info: "Alter the program counter",
exec: (prep: VmOpIgnore, exec: jumpOp),
run: jumpOp,
post: VmOpIgnore)),
(opCode: JumpI, ## 0x57, Conditional jump (opCode: JumpI, ## 0x57, Conditional jump
forks: VmOpAllForks, forks: VmOpAllForks,
name: "jumpI", name: "jumpI",
info: "Conditionally alter the program counter", info: "Conditionally alter the program counter",
exec: (prep: VmOpIgnore, exec: jumpIOp),
run: jumpIOp,
post: VmOpIgnore)),
(opCode: Pc, ## 0x58, Program counter prior to instruction (opCode: Pc, ## 0x58, Program counter prior to instruction
forks: VmOpAllForks, forks: VmOpAllForks,
name: "pc", name: "pc",
info: "Get the value of the program counter prior to the increment "& info: "Get the value of the program counter prior to the increment "&
"corresponding to this instruction", "corresponding to this instruction",
exec: (prep: VmOpIgnore, exec: pcOp),
run: pcOp,
post: VmOpIgnore)),
(opCode: Msize, ## 0x59, Memory size (opCode: Msize, ## 0x59, Memory size
forks: VmOpAllForks, forks: VmOpAllForks,
name: "msize", name: "msize",
info: "Get the size of active memory in bytes", info: "Get the size of active memory in bytes",
exec: (prep: VmOpIgnore, exec: msizeOp),
run: msizeOp,
post: VmOpIgnore)),
(opCode: Gas, ## 0x5a, Get available gas (opCode: Gas, ## 0x5a, Get available gas
forks: VmOpAllForks, forks: VmOpAllForks,
name: "gas", name: "gas",
info: "Get the amount of available gas, including the corresponding "& info: "Get the amount of available gas, including the corresponding "&
"reduction for the cost of this instruction", "reduction for the cost of this instruction",
exec: (prep: VmOpIgnore, exec: gasOp),
run: gasOp,
post: VmOpIgnore)),
(opCode: JumpDest, ## 0x5b, Mark jump target. This operation has no effect (opCode: JumpDest, ## 0x5b, Mark jump target. This operation has no effect
## on machine state during execution ## on machine state during execution
forks: VmOpAllForks, forks: VmOpAllForks,
name: "jumpDest", name: "jumpDest",
info: "Mark a valid destination for jumps", info: "Mark a valid destination for jumps",
exec: (prep: VmOpIgnore, exec: jumpDestOp),
run: jumpDestOp,
post: VmOpIgnore)),
(opCode: Tload, ## 0x5c, Load word from transient storage. (opCode: Tload, ## 0x5c, Load word from transient storage.
forks: VmOpCancunAndLater, forks: VmOpCancunAndLater,
name: "tLoad", name: "tLoad",
info: "Load word from transient storage", info: "Load word from transient storage",
exec: (prep: VmOpIgnore, exec: tloadOp),
run: tloadOp,
post: VmOpIgnore)),
(opCode: Tstore, ## 0x5d, Save word to transient storage. (opCode: Tstore, ## 0x5d, Save word to transient storage.
forks: VmOpCancunAndLater, forks: VmOpCancunAndLater,
name: "tStore", name: "tStore",
info: "Save word to transient storage", info: "Save word to transient storage",
exec: (prep: VmOpIgnore, exec: tstoreOp),
run: tstoreOp,
post: VmOpIgnore)),
(opCode: Mcopy, ## 0x5e, Copy memory (opCode: Mcopy, ## 0x5e, Copy memory
forks: VmOpCancunAndLater, forks: VmOpCancunAndLater,
name: "MCopy", name: "MCopy",
info: "Copy memory", info: "Copy memory",
exec: (prep: VmOpIgnore, exec: mCopyOp)]
run: mCopyOp,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -76,9 +76,7 @@ const
forks: VmOpShanghaiAndLater, forks: VmOpShanghaiAndLater,
name: "Push0", name: "Push0",
info: "Push 0 on the stack", info: "Push 0 on the stack",
exec: (prep: VmOpIgnore, exec: push0Op)]
run: push0Op,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End

View File

@ -164,58 +164,50 @@ const
forks: VmOpAllForks, forks: VmOpAllForks,
name: "returnOp", name: "returnOp",
info: "Halt execution returning output data", info: "Halt execution returning output data",
exec: (prep: VmOpIgnore, exec: returnOp),
run: returnOp,
post: VmOpIgnore)),
(opCode: Revert, ## 0xfd, Halt and revert state changes (opCode: Revert, ## 0xfd, Halt and revert state changes
forks: VmOpByzantiumAndLater, forks: VmOpByzantiumAndLater,
name: "revert", name: "revert",
info: "Halt execution reverting state changes but returning data " & info: "Halt execution reverting state changes but returning data " &
"and remaining gas", "and remaining gas",
exec: (prep: VmOpIgnore, exec: revertOp),
run: revertOp,
post: VmOpIgnore)),
(opCode: Invalid, ## 0xfe, invalid instruction. (opCode: Invalid, ## 0xfe, invalid instruction.
forks: VmOpAllForks, forks: VmOpAllForks,
name: "invalidInstruction", name: "invalidInstruction",
info: "Designated invalid instruction", info: "Designated invalid instruction",
exec: (prep: VmOpIgnore, exec: invalidOp),
run: invalidOp,
post: VmOpIgnore)),
(opCode: SelfDestruct, ## 0xff, Halt execution, prep for later deletion (opCode: SelfDestruct, ## 0xff, Halt execution, prep for later deletion
forks: VmOpAllForks - VmOpTangerineAndLater, forks: VmOpAllForks - VmOpTangerineAndLater,
name: "selfDestruct", name: "selfDestruct",
info: "Halt execution and register account for later deletion", info: "Halt execution and register account for later deletion",
exec: (prep: VmOpIgnore, exec: selfDestructOp),
run: selfDestructOp,
post: VmOpIgnore)),
(opCode: SelfDestruct, ## 0xff, EIP150: self destruct, Tangerine (opCode: SelfDestruct, ## 0xff, EIP150: self destruct, Tangerine
forks: VmOpTangerineAndLater - VmOpSpuriousAndLater, forks: VmOpTangerineAndLater - VmOpSpuriousAndLater,
name: "selfDestructEIP150", name: "selfDestructEIP150",
info: "EIP150: Halt execution and register account for later deletion", info: "EIP150: Halt execution and register account for later deletion",
exec: (prep: VmOpIgnore, exec: selfDestructEIP150Op),
run: selfDestructEIP150Op,
post: VmOpIgnore)),
(opCode: SelfDestruct, ## 0xff, EIP161: self destruct, Spurious and later (opCode: SelfDestruct, ## 0xff, EIP161: self destruct, Spurious and later
forks: VmOpSpuriousAndLater - VmOpBerlinAndLater, forks: VmOpSpuriousAndLater - VmOpBerlinAndLater,
name: "selfDestructEIP161", name: "selfDestructEIP161",
info: "EIP161: Halt execution and register account for later deletion", info: "EIP161: Halt execution and register account for later deletion",
exec: (prep: VmOpIgnore, exec: selfDestructEIP161Op),
run: selfDestructEIP161Op,
post: VmOpIgnore)),
(opCode: SelfDestruct, ## 0xff, EIP2929: self destruct, Berlin and later (opCode: SelfDestruct, ## 0xff, EIP2929: self destruct, Berlin and later
forks: VmOpBerlinAndLater, forks: VmOpBerlinAndLater,
name: "selfDestructEIP2929", name: "selfDestructEIP2929",
info: "EIP2929: Halt execution and register account for later deletion", info: "EIP2929: Halt execution and register account for later deletion",
exec: (prep: VmOpIgnore, exec: selfDestructEIP2929Op)]
run: selfDestructEIP2929Op,
post: VmOpIgnore))]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End