From 61805cf4d27eacb9264b37c6900631e093954626 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 23 Jul 2019 22:32:48 +0100 Subject: [PATCH] rust: support evmc_revision in execute() --- bindings/rust/evmc-declare-tests/src/lib.rs | 1 + bindings/rust/evmc-declare/src/lib.rs | 6 +++--- bindings/rust/evmc-vm/src/container.rs | 15 +++++++++++++-- bindings/rust/evmc-vm/src/lib.rs | 1 + examples/example-rust-vm/src/lib.rs | 1 + 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bindings/rust/evmc-declare-tests/src/lib.rs b/bindings/rust/evmc-declare-tests/src/lib.rs index 38fd2f3..dcb5c37 100644 --- a/bindings/rust/evmc-declare-tests/src/lib.rs +++ b/bindings/rust/evmc-declare-tests/src/lib.rs @@ -19,6 +19,7 @@ impl EvmcVm for FooVM { fn execute( &self, + _revision: evmc_sys::evmc_revision, _code: &[u8], _message: &ExecutionMessage, _context: &ExecutionContext, diff --git a/bindings/rust/evmc-declare/src/lib.rs b/bindings/rust/evmc-declare/src/lib.rs index f70e2c8..08a74d0 100644 --- a/bindings/rust/evmc-declare/src/lib.rs +++ b/bindings/rust/evmc-declare/src/lib.rs @@ -22,7 +22,7 @@ //! ExampleVM {} //! } //! -//! fn execute(&self, code: &[u8], message: &evmc_vm::ExecutionMessage, context: &evmc_vm::ExecutionContext) -> evmc_vm::ExecutionResult { +//! fn execute(&self, revision: evmc_vm::ffi::evmc_revision, code: &[u8], message: &evmc_vm::ExecutionMessage, context: &evmc_vm::ExecutionContext) -> evmc_vm::ExecutionResult { //! evmc_vm::ExecutionResult::success(1337, None) //! } //! } @@ -329,7 +329,7 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream { extern "C" fn __evmc_execute( instance: *mut ::evmc_vm::ffi::evmc_instance, context: *mut ::evmc_vm::ffi::evmc_context, - rev: ::evmc_vm::ffi::evmc_revision, + revision: ::evmc_vm::ffi::evmc_revision, msg: *const ::evmc_vm::ffi::evmc_message, code: *const u8, code_size: usize @@ -365,7 +365,7 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream { }; let result = ::std::panic::catch_unwind(|| { - container.execute(code_ref, &execution_message, &execution_context) + container.execute(revision, code_ref, &execution_message, &execution_context) }); let result = if result.is_err() { diff --git a/bindings/rust/evmc-vm/src/container.rs b/bindings/rust/evmc-vm/src/container.rs index 89f40f2..92d9e80 100644 --- a/bindings/rust/evmc-vm/src/container.rs +++ b/bindings/rust/evmc-vm/src/container.rs @@ -59,6 +59,7 @@ mod tests { } fn execute( &self, + _revision: evmc_sys::evmc_revision, _code: &[u8], _message: &ExecutionMessage, _context: &ExecutionContext, @@ -130,7 +131,12 @@ mod tests { let container = EvmcContainer::::new(instance); assert_eq!( container - .execute(&code, &message, &context) + .execute( + evmc_sys::evmc_revision::EVMC_PETERSBURG, + &code, + &message, + &context + ) .get_status_code(), ::evmc_sys::evmc_status_code::EVMC_FAILURE ); @@ -140,7 +146,12 @@ mod tests { let container = unsafe { EvmcContainer::::from_ffi_pointer(ptr) }; assert_eq!( container - .execute(&code, &message, &context) + .execute( + evmc_sys::evmc_revision::EVMC_PETERSBURG, + &code, + &message, + &context + ) .get_status_code(), ::evmc_sys::evmc_status_code::EVMC_FAILURE ); diff --git a/bindings/rust/evmc-vm/src/lib.rs b/bindings/rust/evmc-vm/src/lib.rs index a41f451..5311a2f 100644 --- a/bindings/rust/evmc-vm/src/lib.rs +++ b/bindings/rust/evmc-vm/src/lib.rs @@ -20,6 +20,7 @@ pub trait EvmcVm { fn init() -> Self; fn execute( &self, + revision: ffi::evmc_revision, code: &[u8], message: &ExecutionMessage, context: &ExecutionContext, diff --git a/examples/example-rust-vm/src/lib.rs b/examples/example-rust-vm/src/lib.rs index 5ddacec..c5bb472 100644 --- a/examples/example-rust-vm/src/lib.rs +++ b/examples/example-rust-vm/src/lib.rs @@ -16,6 +16,7 @@ impl EvmcVm for ExampleRustVM { fn execute( &self, + _revision: evmc_sys::evmc_revision, _code: &[u8], message: &ExecutionMessage, _context: &ExecutionContext,