/evmstar

WIP: stand-alone EVM implementation with Ethereum mainnet configuration

Primary LanguageRustApache License 2.0Apache-2.0

EVM star

Toy Example

let mut emulator = EvmEmulator::new_transient_with(TxContext::default());
let code = Code::builder()
    .append(OpCode::PUSH1)  // OpCode
    .append("02")           // hex character
    .append(OpCode::PUSH1)
    .append(0x03)           // u8
    .append(OpCode::ADD)
    .append(OpCode::PUSH1)
    .append("00")
    .append(OpCode::MSTORE)
    .append("60206000")     // hex string
    .append(OpCode::RETURN);
    .clone();

let result = emulator.run_code(code);

result.expect_status(StatusCode::Success)
    .expect_gas(24)
    .expect_output("0000000000000000000000000000000000000000000000000000000000000005");

Progress

  • push,pop,dup
  • arithmetic opcodes
  • memory opcode (mload, mstore, mstore8)
  • return
  • storage opcode (sload, sstore)
  • context opcode
  • call
  • revert
  • delegatecall, staticcall, callcode
  • create
  • create2
  • selfdestruct
  • sha3, precompiles