CertiK virtual machine (CVM) handles the underlying gas calculation and corresponding error handling for contract deployments and calls.
These are some differences in behavior between CVM and EVM.
- GASPRICE operation
- In EVM,
tx.gasprice
(triggers GASPRICE opcode) returns the gasprice for the transaction. - Instead, CVM returns 0. It has to do with the opcode
GASPRICE_DEPRECATED
. Relevant handling can be found invm.go
. - They consume the same amount of gas.
- This might change in the future.
- In EVM,
- DIFFICULTY operation
- In EVM,
DIFFICULTY
returns the current mining difficulty of the chain. - Instead, CVM returns 0. This is due to the consensus model difference.
- Will not be changed in the future (might need update when Ethereum goes POS).
- In EVM,
- COINBASE operation
- In EVM,
COINBASE
pushes the miner address to the stack. - Instaed, CVM pushes 0 to the stack, as there is no concept of mining.
- Will not change in the future.
- In EVM,
These are some differences in gas cost between CVM and EVM.
- SSTORE opcode gas calculation
- CVM does not implement EIP-1283 or EIP-2200.
- Instead, it adds a simple NOOP gas (200) case to the original Petersburg gas calculation logic, for the case where the new value is equal to the original value.
- SELFDESTRUCT opcode gas calculation
- as CVM doesn't have the identical access structure as EVM, EIP-158 is ignored.
- However, EIP 150 is taken account, so if
selfdestruct()
is called to an unexisting address, it will consumeCreateBySelfDestruct
amount of gas.
These are some differences that do not affect behavior or gas cost.
- BLOCKHEIGHT operation
- BLOCKHEIGHT is named
NUMBER
in EVM. - They do the same thing, consume the same gas.
- BLOCKHEIGHT is named
- There are some missing opcodes in Burrow compared to Geth
- COINBASE
- NUMBER (Block height)
- CHAINID