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: StringImplementations§
§impl VMBridge
impl VMBridge
pub fn new(config: &RuntimeConfig) -> Result<Self, RuntimeError>
pub fn new(config: &RuntimeConfig) -> Result<Self, RuntimeError>
Create new VM bridge
§impl VMBridge
impl VMBridge
pub fn execute(
&mut self,
context: &mut ExecutionContext,
_state: &mut StateManager,
storage: &mut StorageManager,
gas: &mut GasTracker,
) -> Result<ExecutionResult, RuntimeError>
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
impl VMBridge
pub fn handle_instruction(
&mut self,
opcode: u8,
context: &mut ExecutionContext,
state: &mut StateManager,
storage: &mut StorageManager,
gas: &mut GasTracker,
) -> Result<(), VMBridgeError>
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
impl VMBridge
pub fn call_system_function(
&mut self,
name: &str,
args: &[StackItem],
) -> Result<Vec<StackItem>, VMBridgeError>
pub fn call_system_function( &mut self, name: &str, args: &[StackItem], ) -> Result<Vec<StackItem>, VMBridgeError>
Call system function
§impl VMBridge
impl VMBridge
fn initialize_instruction_mapping(&mut self)
fn initialize_system_calls(&mut self)
§impl VMBridge
impl VMBridge
fn apply_storage_overlay( &self, context: &mut ExecutionContext, storage: &mut StorageManager, ) -> Result<Vec<String>, RuntimeError>
§impl VMBridge
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
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
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
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
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
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
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
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
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
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
fn add_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn sub_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn mul_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn div_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn mod_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn modmul_stack_items( a: StackItem, b: StackItem, modulus: StackItem, ) -> Result<StackItem, VMBridgeError>
fn modpow_stack_items( base: StackItem, exponent: StackItem, modulus: StackItem, ) -> Result<StackItem, VMBridgeError>
§impl VMBridge
impl VMBridge
fn lt_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn gt_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn eq_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
§impl VMBridge
impl VMBridge
fn and_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn or_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
fn xor_stack_items( a: StackItem, b: StackItem, ) -> Result<StackItem, VMBridgeError>
§impl VMBridge
impl VMBridge
fn shift_left_value( value: StackItem, shift: StackItem, ) -> Result<StackItem, VMBridgeError>
fn shift_right_value( value: StackItem, shift: StackItem, ) -> Result<StackItem, VMBridgeError>
fn extract_shift_amount(item: StackItem) -> Result<u32, VMBridgeError>
§impl VMBridge
impl VMBridge
fn extract_return_data( &self, context: &ExecutionContext, ) -> Result<Vec<u8>, RuntimeError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VMBridge
impl RefUnwindSafe for VMBridge
impl Send for VMBridge
impl Sync for VMBridge
impl Unpin for VMBridge
impl UnwindSafe for VMBridge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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