EVM Compatibility Layer

The EVM Compatibility Layer implements the Ethereum Virtual Machine specification to enable Solidity smart contracts to run on IBVM.

EVM Implementation

IBVM implements the full EVM instruction set as specified in the Ethereum Yellow Paper, with the following modifications:

  1. Gas costs denominated in BTC (satoshis) instead of ETH

  2. Block gas limit calibrated for Bitcoin block times

  3. Modified precompiled contracts for Bitcoin-specific operations

Instruction Set Support

The EVM implementation supports all standard EVM opcodes including:

  • Stack manipulation (PUSH, POP, DUP, SWAP)

  • Arithmetic operations (ADD, MUL, SUB, DIV, etc.)

  • Bitwise operations (AND, OR, XOR, NOT)

  • Comparison operations (LT, GT, EQ, etc.)

  • Environmental information (CALLER, CALLVALUE, etc.)

  • Block information (BLOCKHASH, COINBASE, etc.)

  • Memory operations (MLOAD, MSTORE, etc.)

  • Storage operations (SLOAD, SSTORE)

  • Program control flow (JUMP, JUMPI, etc.)

  • System operations (CREATE, CALL, etc.)

Gas Computation

Gas cost in IBVM is calculated similarly to Ethereum but denominated in satoshis:

$gas_cost = \sum_{op \in tx} gas(op) \times gas_price$

Where:

  • $gas(op)$ is the base gas cost of each operation

  • $gas_price$ is the user-specified gas price in satoshis/gas unit

State Representation

The IBVM state is organized as a Merkle Patricia Trie, similar to Ethereum:

  1. Account State: A mapping of addresses to account states

    1. Each account has: nonce, balance, storageRoot, codeHash

    2. $AccountState = (nonce, balance, storageRoot, codeHash)$

  2. Storage Trie: For each account, a separate trie maps 256-bit keys to 256-bit values

    1. $Storage: 2^{256} \rightarrow 2^{256}$

  3. State Root: A 256-bit hash that uniquely identifies the entire state

    1. $StateRoot = H(AccountState_1 || AccountState_2 || ... || AccountState_n)$

Account Representation

Each account in IBVM is represented as:

$Account = (nonce, balance, storageRoot, codeHash)$

Where:

  • $nonce$: Counter used to ensure each transaction is processed only once

  • $balance$: Amount of BTC held by the account (in satoshis)

  • $storageRoot$: Root hash of the storage trie

  • $codeHash$: Hash of the account's contract code (or 0 if not a contract)

Last updated