API

Application Entry Point

std::shared_ptr<enclave::RpcHandler> ccfapp::get_rpc_handler(ccf::NetworkTables &nwt, ccf::AbstractNotifier &notifier)

RPCs

See Supported RPCs

eEVM

struct eevm::Account

Abstract interface for interacting with EVM accounts

Subclassed by eevm::SimpleAccount, evm4ccf::AccountProxy

Public Types

using Nonce = size_t

Public Functions

~Account()
Address get_address() const = 0
uint256_t get_balance() const = 0
void set_balance(const uint256_t &b) = 0
void pay_to(Account &other, const uint256_t &amount)
Nonce get_nonce() const = 0
void increment_nonce() = 0
Code get_code() const = 0
void set_code(Code &&code) = 0
bool has_code()
struct eevm::GlobalState

Abstract interface for interacting with EVM world state

Subclassed by eevm::SimpleGlobalState, evm4ccf::EthereumState

Public Functions

void remove(const Address &addr) = 0
AccountState get(const Address &addr) = 0

Creates a new zero-initialized account under the given address if none exists

AccountState create(const Address &addr, const uint256_t &balance, const Code &code) = 0
const Block &get_current_block() = 0
uint256_t get_block_hash(uint8_t offset) = 0
class eevm::Processor

Ethereum bytecode processor.

Public Functions

Processor(GlobalState &gs)
ExecResult run(Transaction &tx, const Address &caller, AccountState callee, const std::vector<uint8_t> &input, const uint256_t &call_value, Trace *tr = nullptr)

The main entry point for the EVM.

Runs the callee’s code in the caller’s context. VM exceptions (ie, eevm::Exception) will be caught and returned in the result.

Return

ExecResult the execution result

Parameters
  • tx: the transaction

  • caller: the caller’s address

  • callee: the callee’s account state

  • input: the raw byte input

  • call_value: the call value

  • tr: [optional] a pointer to a trace object. If given, a trace of the execution will be collected.

Ethereum App

class evm4ccf::EthereumState : public eevm::GlobalState

Public Functions

eevm::AccountState get(const eevm::Address &address) override

Creates a new zero-initialized account under the given address if none exists

class evm4ccf::EVMForCCFFrontend : public UserRpcFrontend

Public Functions

EVMForCCFFrontend(NetworkTables &nwt, AbstractNotifier &notifier)

Private Functions

EthereumState make_state(Store::Tx &tx)
void install_standard_rpcs()
pair<bool, nlohmann::json> execute_transaction(CallerId caller_id, const rpcparams::MessageCall &call_data, Store::Tx &tx)

Private Members

tables::Accounts accounts
tables::Storage &storage
tables::Results &tx_results

Private Static Functions

std::pair<ExecResult, AccountState> run_in_evm(const rpcparams::MessageCall &call_data, EthereumState &es, LogHandler &log_handler)
pair<ExecResult, AccountState> run_in_evm(const rpcparams::MessageCall &call_data, EthereumState &es)
std::tuple<ExecResult, TxHash, Address> execute_transaction(const rpcparams::MessageCall &call_data, EthereumState &es, LogHandler &log_handler)