rust: support evmc_revision in execute()

This commit is contained in:
Alex Beregszaszi 2019-07-23 22:32:48 +01:00
parent 1d22d68293
commit 61805cf4d2
5 changed files with 19 additions and 5 deletions

View File

@ -19,6 +19,7 @@ impl EvmcVm for FooVM {
fn execute(
&self,
_revision: evmc_sys::evmc_revision,
_code: &[u8],
_message: &ExecutionMessage,
_context: &ExecutionContext,

View File

@ -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() {

View File

@ -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::<TestVm>::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::<TestVm>::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
);

View File

@ -20,6 +20,7 @@ pub trait EvmcVm {
fn init() -> Self;
fn execute(
&self,
revision: ffi::evmc_revision,
code: &[u8],
message: &ExecutionMessage,
context: &ExecutionContext,

View File

@ -16,6 +16,7 @@ impl EvmcVm for ExampleRustVM {
fn execute(
&self,
_revision: evmc_sys::evmc_revision,
_code: &[u8],
message: &ExecutionMessage,
_context: &ExecutionContext,