VMBridge

Struct VMBridge 

Source
pub struct VMBridge {
    config: RuntimeConfig,
    instruction_mapping: HashMap<u8, fn(&mut VMBridge, &mut ExecutionContext, &mut StateManager, &mut StorageManager, &mut GasTracker) -> Result<(), VMBridgeError>>,
    system_calls: HashMap<String, fn(&mut VMBridge, &[StackItem]) -> Result<Vec<StackItem>, VMBridgeError>>,
    contract_account: String,
}
Expand description

VM Bridge for EVM-to-NeoVM translation

Fields§

§config: RuntimeConfig§instruction_mapping: HashMap<u8, fn(&mut VMBridge, &mut ExecutionContext, &mut StateManager, &mut StorageManager, &mut GasTracker) -> Result<(), VMBridgeError>>§system_calls: HashMap<String, fn(&mut VMBridge, &[StackItem]) -> Result<Vec<StackItem>, VMBridgeError>>§contract_account: String

Implementations§

§

impl VMBridge

pub fn new(config: &RuntimeConfig) -> Result<Self, RuntimeError>

Create new VM bridge

§

impl VMBridge

pub fn execute( &mut self, context: &mut ExecutionContext, _state: &mut StateManager, storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<ExecutionResult, RuntimeError>

Execute bytecode through the bridge

§

impl VMBridge

pub fn handle_instruction( &mut self, opcode: u8, context: &mut ExecutionContext, state: &mut StateManager, storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

Handle EVM instruction in NeoVM context

§

impl VMBridge

pub fn call_system_function( &mut self, name: &str, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

Call system function

§

impl VMBridge

§

impl VMBridge

fn apply_storage_overlay( &self, context: &mut ExecutionContext, storage: &mut StorageManager, ) -> Result<Vec<String>, RuntimeError>

§

impl VMBridge

fn handle_add( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_sub( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_mul( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_div( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_mod( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_modmul( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_modpow( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_lt( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_gt( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_eq( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_ne( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_and( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_or( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_xor( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_shl( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_shr( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_push0( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_push1( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_drop( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_dup( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_swap( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_ret( _bridge: &mut VMBridge, _context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, _gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_jmp( _bridge: &mut VMBridge, _context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, _gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_jmpif( _bridge: &mut VMBridge, _context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, _gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_jmpifnot( _bridge: &mut VMBridge, _context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, _gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_mload( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_mstore( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_mstore8( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, _storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn handle_sload( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

fn handle_sstore( _bridge: &mut VMBridge, context: &mut ExecutionContext, _state: &mut StateManager, storage: &mut StorageManager, gas: &mut GasTracker, ) -> Result<(), VMBridgeError>

§

impl VMBridge

fn syscall_keccak256( bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn syscall_sha256( _bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn syscall_ecrecover( bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn syscall_verify( _bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn syscall_blake2f( _bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn syscall_modexp( _bridge: &mut VMBridge, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>

fn keccak256(&self, data: &[u8]) -> [u8; 32]

§

impl VMBridge

§

impl VMBridge

§

impl VMBridge

§

impl VMBridge

§

impl VMBridge

Trait Implementations§

Source§

impl Debug for VMBridge

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.