Ethereum virtual machine opcodes
根据以太坊主网最新分叉Cancun的定义,目前操作码共150个,可分为11类
进度记录: 10/11, 97/150
- arith 12
- dup 16
- push 33
- exchange 16
- compare and bitwise 14
- sha3 1
- logging 5
- control flow 15
- system 10
- env 17
Stop and Arithmetic Operations
共12个,已完成
python spec:https://github.com/ethereum/execution-specs/blob/master/src/ethereum/cancun/vm/instructions/arithmetic.py
Environmental Information
共16个
- address: return the receiver address in evm cmd
- balance:
- evm —debug —gas 0xffffff —nomemory=false —json —code 731c7cd2d37ffd63856a5bd56a9af1643f2bcf545f3160005260406000f3 —prestate ./genesis.json run
- weird, when sender == balance(address), outputs = 0
- origin
- caller
- callvalue
- calldataload
- calldatasize: fixed wrong setting in sealevm
- calldatacopy
- codesize
- codecopy
- gasprice: fixed pyevm gas price error
extcodesize:
- sealevm issue: for non-existent address should return 0
extcodecopy
- jsevm 2500 gas difference
- fixed pyevm wrong init
returndatasize: left with call
- returndatacopy: left with call
Block Information
- number: only pyevm return value
- timestamp: geth and js return nothing
- gaslimit: besu does not recognize the setting in genesis.json
- prevnrandao: only besu outputs
- chainid: of besu
- coinbase: can’t set in ethereumjs/evm
- blockhash
- blobhash
- blobbaseefee
- basefee
Logging Operations
finished 5 opcodes
Duplication Operations
finished 16 opcodes
Exchange Operations
python definition in https://github.com/ethereum/execution-specs/blob/master/src/ethereum/cancun/vm/instructions/stack.py
finished 16 opcodes
SHA3
finished 1 opcode
Push Operations
finished 33 opcodes
System operations
create:seal的地址输出与以太坊标准偏离,见https://github.com/SealSC/SealEVM/blob/a3860afcd00913af730eb98274e70c5b9a797464/example/memStorage.go#L48,create2相同
create2
return
call
callcode
delegatecall
staticcall
revert
invalid
selfdstruct
- balance!=0, besu charges 5000
- balance=0, besu charges 30000
Comparison & Bitwise Logic Operations
14个,已完成
定义分别在
- https://github.com/ethereum/execution-specs/blob/master/src/ethereum/cancun/vm/instructions/bitwise.py
- https://github.com/ethereum/execution-specs/blob/master/src/ethereum/cancun/vm/instructions/bitwise.py
Stack Memory Storage and Flow Operations
15个,已完成
pop
mload
mstore
mstore8
sload
sstore
tload
tstore
pc
msize : sealevm has wrong memory expansion with ethereum spec, also opened an issue in execution-spec reppo.
gas
mcopy
jump
jumpi
jumpdest
TO DO
- exec-spec issue: check all expand the memory opcodes.