diff --git a/crates/iroha_core/src/smartcontracts/wasm.rs b/crates/iroha_core/src/smartcontracts/wasm.rs index b121ae0f966..9bb603514bb 100644 --- a/crates/iroha_core/src/smartcontracts/wasm.rs +++ b/crates/iroha_core/src/smartcontracts/wasm.rs @@ -5,7 +5,7 @@ use std::{borrow::Borrow, num::NonZeroU64}; use error::*; -use import::traits::{ExecuteOperations as _, GetExecutorPayloads as _, SetDataModel as _}; +use import::traits::{ExecuteOperations as _, SetDataModel as _}; use iroha_data_model::{ account::AccountId, executor::{self, ExecutorDataModel}, @@ -13,21 +13,30 @@ use iroha_data_model::{ parameter::SmartContractParameters as Config, prelude::*, query::{parameters::QueryId, AnyQueryBox, QueryOutput, QueryRequest, QueryResponse}, - smart_contract::payloads::{self, Validate}, + smart_contract::payloads, Level as LogLevel, ValidationFail, }; use iroha_logger::debug; // NOTE: Using error_span so that span info is logged on every event use iroha_logger::{error_span as wasm_log_span, prelude::tracing::Span}; use iroha_wasm_codec::{self as codec, WasmUsize}; +use parity_scale_codec::Encode; use wasmtime::{ - Caller, Config as WasmtimeConfig, Engine, Linker, Module, Store, StoreLimits, + Caller, Config as WasmtimeConfig, Engine, Instance, Linker, Module, Store, StoreLimits, StoreLimitsBuilder, TypedFunc, }; use crate::{ query::store::LiveQueryStoreHandle, - smartcontracts::{query::ValidQueryRequest, Execute}, + smartcontracts::{ + query::ValidQueryRequest, + wasm::state::{ + chain_state::WithMut, + specific::executor::{Migrate, Validate}, + CommonState, + }, + Execute, + }, state::{StateReadOnly, StateTransaction, WorldReadOnly}, }; @@ -40,10 +49,6 @@ mod export { pub const EXECUTE_QUERY: &str = "execute_query"; pub const GET_SMART_CONTRACT_PAYLOAD: &str = "get_smart_contract_payload"; pub const GET_TRIGGER_PAYLOAD: &str = "get_trigger_payload"; - pub const GET_MIGRATE_PAYLOAD: &str = "get_migrate_payload"; - pub const GET_VALIDATE_TRANSACTION_PAYLOAD: &str = "get_validate_transaction_payload"; - pub const GET_VALIDATE_INSTRUCTION_PAYLOAD: &str = "get_validate_instruction_payload"; - pub const GET_VALIDATE_QUERY_PAYLOAD: &str = "get_validate_query_payload"; pub const SET_DATA_MODEL: &str = "set_data_model"; pub const DBG: &str = "dbg"; @@ -65,10 +70,7 @@ mod import { pub mod traits { //! Traits which some [Runtime]s should implement to import functions from Iroha to WASM - use iroha_data_model::{ - query::{QueryRequest, QueryResponse}, - smart_contract::payloads::Validate, - }; + use iroha_data_model::query::{QueryRequest, QueryResponse}; use super::super::*; @@ -88,20 +90,6 @@ mod import { ) -> Result<(), ValidationFail>; } - pub trait GetExecutorPayloads { - #[codec::wrap_trait_fn] - fn get_migrate_payload(state: &S) -> payloads::Migrate; - - #[codec::wrap_trait_fn] - fn get_validate_transaction_payload(state: &S) -> Validate; - - #[codec::wrap_trait_fn] - fn get_validate_instruction_payload(state: &S) -> Validate; - - #[codec::wrap_trait_fn] - fn get_validate_query_payload(state: &S) -> Validate; - } - pub trait SetDataModel { #[codec::wrap_trait_fn] fn set_data_model(data_model: ExecutorDataModel, state: &mut S); @@ -674,6 +662,23 @@ impl Runtime { Ok(()) } + fn encode_payload( + instance: &Instance, + store: &mut Store, + payload: T, + ) -> WasmUsize { + let memory = + Self::get_memory(&mut (instance, &mut *store)).expect("Checked at instantiation step"); + let alloc_fn = Self::get_typed_func::( + instance, + &mut *store, + import::SMART_CONTRACT_ALLOC, + ) + .expect("Checked at instantiation step"); + iroha_wasm_codec::encode_into_memory(&payload, &memory, &alloc_fn, &mut *store) + .expect("Can't encode payload") + } + /// Host-defined function which prints the given string. When this function /// is called, the module serializes the string to linear memory and /// provides offset and length as parameters @@ -749,21 +754,25 @@ impl Runtime> { } } -impl Runtime> { +impl Runtime>> +where + payloads::Validate: Encode, +{ fn execute_executor_validate_internal( &self, module: &wasmtime::Module, - state: state::CommonState, + state: state::CommonState>, validate_fn_name: &'static str, ) -> Result { let mut store = self.create_store(state); let instance = self.instantiate_module(module, &mut store)?; let validate_fn = Self::get_typed_func(&instance, &mut store, validate_fn_name)?; + let payload = Self::get_validate_payload(&instance, &mut store); // NOTE: This function takes ownership of the pointer let offset = validate_fn - .call(&mut store, ()) + .call(&mut store, payload) .map_err(ExportFnCallError::from)?; let memory = @@ -784,6 +793,19 @@ impl Runtime> { Ok(validation_res) } + + fn get_validate_payload( + instance: &Instance, + store: &mut Store>>, + ) -> WasmUsize { + let state = store.data(); + let payload = payloads::Validate { + authority: state.authority.clone(), + block_height: state.state.state().height() as u64, + target: state.specific_state.to_validate.clone(), + }; + Runtime::encode_payload(instance, store, payload) + } } impl Runtime> @@ -1133,43 +1155,6 @@ impl<'wrld> ExecuteOperationsAsExecutorMut - import::traits::GetExecutorPayloads> - for Runtime> -{ - #[codec::wrap] - fn get_migrate_payload( - _state: &state::executor::ValidateTransaction<'wrld, 'block, 'state>, - ) -> payloads::Migrate { - panic!("Executor `validate_transaction()` entrypoint should not query payload for `migrate()` entrypoint") - } - - #[codec::wrap] - fn get_validate_transaction_payload( - state: &state::executor::ValidateTransaction<'wrld, 'block, 'state>, - ) -> Validate { - Validate { - authority: state.authority.clone(), - block_height: state.state.0.height() as u64, - target: state.specific_state.to_validate.clone(), - } - } - - #[codec::wrap] - fn get_validate_instruction_payload( - _state: &state::executor::ValidateTransaction<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `validate_transaction()` entrypoint should not query payload for `validate_instruction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_query_payload( - _state: &state::executor::ValidateTransaction<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `validate_transaction()` entrypoint should not query payload for `validate_query()` entrypoint") - } -} - impl<'wrld> FakeSetExecutorDataModel> for Runtime> { @@ -1213,43 +1198,6 @@ impl<'wrld> ExecuteOperationsAsExecutorMut - import::traits::GetExecutorPayloads> - for Runtime> -{ - #[codec::wrap] - fn get_migrate_payload( - _state: &state::executor::ValidateInstruction<'wrld, 'block, 'state>, - ) -> payloads::Migrate { - panic!("Executor `validate_instruction()` entrypoint should not query payload for `migrate()` entrypoint") - } - - #[codec::wrap] - fn get_validate_transaction_payload( - _state: &state::executor::ValidateInstruction<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `validate_instruction()` entrypoint should not query payload for `validate_transaction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_instruction_payload( - state: &state::executor::ValidateInstruction<'wrld, 'block, 'state>, - ) -> Validate { - Validate { - authority: state.authority.clone(), - block_height: state.state.0.height() as u64, - target: state.specific_state.to_validate.clone(), - } - } - - #[codec::wrap] - fn get_validate_query_payload( - _state: &state::executor::ValidateInstruction<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `validate_instruction()` entrypoint should not query payload for `validate_query()` entrypoint") - } -} - impl<'wrld> FakeSetExecutorDataModel> for Runtime> { @@ -1311,41 +1259,6 @@ impl<'wrld, S: StateReadOnly> } } -impl<'wrld, S: StateReadOnly> - import::traits::GetExecutorPayloads> - for Runtime> -{ - #[codec::wrap] - fn get_migrate_payload(_state: &state::executor::ValidateQuery<'wrld, S>) -> payloads::Migrate { - panic!("Executor `validate_query()` entrypoint should not query payload for `migrate()` entrypoint") - } - - #[codec::wrap] - fn get_validate_transaction_payload( - _state: &state::executor::ValidateQuery<'wrld, S>, - ) -> Validate { - panic!("Executor `validate_query()` entrypoint should not query payload for `validate_transaction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_instruction_payload( - _state: &state::executor::ValidateQuery<'wrld, S>, - ) -> Validate { - panic!("Executor `validate_query()` entrypoint should not query payload for `validate_instruction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_query_payload( - state: &state::executor::ValidateQuery<'wrld, S>, - ) -> Validate { - Validate { - authority: state.authority.clone(), - block_height: state.state.0.height() as u64, - target: state.specific_state.to_validate.clone(), - } - } -} - impl<'wrld, S: StateReadOnly> FakeSetExecutorDataModel> for Runtime> { @@ -1378,15 +1291,26 @@ impl<'wrld, 'block, 'state> Runtime = + let migrate_fn: TypedFunc = Self::get_typed_func(&instance, &mut store, import::EXECUTOR_MIGRATE)?; + let payload = Self::get_migrate_payload(&instance, &mut store); migrate_fn - .call(&mut store, ()) + .call(&mut store, payload) .map_err(ExportFnCallError::from)?; Ok(()) } + + fn get_migrate_payload( + instance: &Instance, + store: &mut Store, Migrate>>, + ) -> WasmUsize { + let payload = payloads::Migrate { + block_height: store.data().state.0.height() as u64, + }; + Self::encode_payload(instance, store, payload) + } } impl<'wrld> ExecuteOperationsAsExecutorMut> @@ -1394,50 +1318,6 @@ impl<'wrld> ExecuteOperationsAsExecutorMut - import::traits::GetExecutorPayloads> - for Runtime> -{ - #[codec::wrap] - fn get_migrate_payload( - state: &state::executor::Migrate<'wrld, 'block, 'state>, - ) -> payloads::Migrate { - payloads::Migrate { - block_height: state.state.0.height() as u64, - } - } - - #[codec::wrap] - fn get_validate_transaction_payload( - _state: &state::executor::Migrate<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `migrate()` entrypoint should not query payload for `validate_transaction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_instruction_payload( - _state: &state::executor::Migrate<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `migrate()` entrypoint should not query payload for `validate_instruction()` entrypoint") - } - - #[codec::wrap] - fn get_validate_query_payload( - _state: &state::executor::Migrate<'wrld, 'block, 'state>, - ) -> Validate { - panic!("Executor `migrate()` entrypoint should not query payload for `validate_query()` entrypoint") - } -} - impl<'wrld, 'block, 'state> import::traits::SetDataModel> for Runtime> @@ -1590,10 +1470,6 @@ impl<'wrld, 'block, 'state> create_imports!(linker, state::executor::ValidateTransaction<'wrld, 'block, 'state>, export::EXECUTE_ISI => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_instruction(caller, offset, len), export::EXECUTE_QUERY => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_query(caller, offset, len), - export::GET_MIGRATE_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_migrate_payload(caller), - export::GET_VALIDATE_TRANSACTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_transaction_payload(caller), - export::GET_VALIDATE_INSTRUCTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_instruction_payload(caller), - export::GET_VALIDATE_QUERY_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_query_payload(caller), export::SET_DATA_MODEL => |caller: ::wasmtime::Caller>, offset, len| Runtime::set_data_model(caller, offset, len), )?; Ok(linker) @@ -1618,10 +1494,6 @@ impl<'wrld, 'block, 'state> create_imports!(linker, state::executor::ValidateInstruction<'wrld, 'block, 'state>, export::EXECUTE_ISI => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_instruction(caller, offset, len), export::EXECUTE_QUERY => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_query(caller, offset, len), - export::GET_MIGRATE_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_migrate_payload(caller), - export::GET_VALIDATE_TRANSACTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_transaction_payload(caller), - export::GET_VALIDATE_INSTRUCTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_instruction_payload(caller), - export::GET_VALIDATE_QUERY_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_query_payload(caller), export::SET_DATA_MODEL => |caller: ::wasmtime::Caller>, offset, len| Runtime::set_data_model(caller, offset, len), )?; Ok(linker) @@ -1643,10 +1515,6 @@ impl<'wrld, S: StateReadOnly> RuntimeBuilder, export::EXECUTE_ISI => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_instruction(caller, offset, len), export::EXECUTE_QUERY => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_query(caller, offset, len), - export::GET_MIGRATE_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_migrate_payload(caller), - export::GET_VALIDATE_TRANSACTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_transaction_payload(caller), - export::GET_VALIDATE_INSTRUCTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_instruction_payload(caller), - export::GET_VALIDATE_QUERY_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_query_payload(caller), export::SET_DATA_MODEL => |caller: ::wasmtime::Caller>, offset, len| Runtime::set_data_model(caller, offset, len), )?; Ok(linker) @@ -1668,10 +1536,6 @@ impl<'wrld, 'block, 'state> RuntimeBuilder, export::EXECUTE_ISI => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_instruction(caller, offset, len), export::EXECUTE_QUERY => |caller: ::wasmtime::Caller>, offset, len| Runtime::execute_query(caller, offset, len), - export::GET_MIGRATE_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_migrate_payload(caller), - export::GET_VALIDATE_TRANSACTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_transaction_payload(caller), - export::GET_VALIDATE_INSTRUCTION_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_instruction_payload(caller), - export::GET_VALIDATE_QUERY_PAYLOAD => |caller: ::wasmtime::Caller>| Runtime::get_validate_query_payload(caller), export::SET_DATA_MODEL => |caller: ::wasmtime::Caller>, offset, len| Runtime::set_data_model(caller, offset, len), )?; Ok(linker) diff --git a/crates/iroha_executor/src/lib.rs b/crates/iroha_executor/src/lib.rs index 11f7ccda712..456a85e60eb 100644 --- a/crates/iroha_executor/src/lib.rs +++ b/crates/iroha_executor/src/lib.rs @@ -31,51 +31,35 @@ pub mod log { } /// Get payload for `validate_transaction()` entrypoint. -/// -/// # Traps -/// -/// Host side will generate a trap if this function was called not from a -/// executor `validate_transaction()` entrypoint. #[cfg(not(test))] -pub fn get_validate_transaction_payload() -> payloads::Validate { - // Safety: ownership of the returned result is transferred into `_decode_from_raw` - unsafe { decode_with_length_prefix_from_raw(host::get_validate_transaction_payload()) } +pub fn decode_validate_transaction_payload( + payload: *const u8, +) -> payloads::Validate { + // Safety: ownership of the provided payload is transferred into `_decode_from_raw` + unsafe { decode_with_length_prefix_from_raw(payload) } } /// Get payload for `validate_instruction()` entrypoint. -/// -/// # Traps -/// -/// Host side will generate a trap if this function was called not from a -/// executor `validate_instruction()` entrypoint. #[cfg(not(test))] -pub fn get_validate_instruction_payload() -> payloads::Validate { - // Safety: ownership of the returned result is transferred into `_decode_from_raw` - unsafe { decode_with_length_prefix_from_raw(host::get_validate_instruction_payload()) } +pub fn decode_validate_instruction_payload( + payload: *const u8, +) -> payloads::Validate { + // Safety: ownership of the provided payload is transferred into `_decode_from_raw` + unsafe { decode_with_length_prefix_from_raw(payload) } } /// Get payload for `validate_query()` entrypoint. -/// -/// # Traps -/// -/// Host side will generate a trap if this function was called not from a -/// executor `validate_query()` entrypoint. #[cfg(not(test))] -pub fn get_validate_query_payload() -> payloads::Validate { - // Safety: ownership of the returned result is transferred into `_decode_from_raw` - unsafe { decode_with_length_prefix_from_raw(host::get_validate_query_payload()) } +pub fn decode_validate_query_payload(payload: *const u8) -> payloads::Validate { + // Safety: ownership of the provided payload is transferred into `_decode_from_raw` + unsafe { decode_with_length_prefix_from_raw(payload) } } /// Get payload for `migrate()` entrypoint. -/// -/// # Traps -/// -/// Host side will generate a trap if this function was called not from a -/// executor `migrate()` entrypoint. #[cfg(not(test))] -pub fn get_migrate_payload() -> payloads::Migrate { - // Safety: ownership of the returned result is transferred into `_decode_from_raw` - unsafe { decode_with_length_prefix_from_raw(host::get_migrate_payload()) } +pub fn decode_migrate_payload(payload: *const u8) -> payloads::Migrate { + // Safety: ownership of the provided payload is transferred into `_decode_from_raw` + unsafe { decode_with_length_prefix_from_raw(payload) } } /// Set new [`ExecutorDataModel`]. @@ -98,34 +82,6 @@ pub fn set_data_model(data_model: &ExecutorDataModel) { mod host { #[link(wasm_import_module = "iroha")] extern "C" { - /// Get payload for `validate_transaction()` entrypoint. - /// - /// # Warning - /// - /// This function does transfer ownership of the result to the caller - pub(super) fn get_validate_transaction_payload() -> *const u8; - - /// Get payload for `validate_instruction()` entrypoint. - /// - /// # Warning - /// - /// This function does transfer ownership of the result to the caller - pub(super) fn get_validate_instruction_payload() -> *const u8; - - /// Get payload for `validate_query()` entrypoint. - /// - /// # Warning - /// - /// This function does transfer ownership of the result to the caller - pub(super) fn get_validate_query_payload() -> *const u8; - - /// Get payload for `migrate()` entrypoint. - /// - /// # Warning - /// - /// This function does transfer ownership of the result to the caller - pub(super) fn get_migrate_payload() -> *const u8; - /// Set new [`ExecutorDataModel`]. pub(super) fn set_data_model(ptr: *const u8, len: usize); } diff --git a/crates/iroha_executor_derive/src/entrypoint.rs b/crates/iroha_executor_derive/src/entrypoint.rs index c833407e687..2a6dc59b437 100644 --- a/crates/iroha_executor_derive/src/entrypoint.rs +++ b/crates/iroha_executor_derive/src/entrypoint.rs @@ -14,9 +14,9 @@ mod export { } mod import { - pub const GET_VALIDATE_TRANSACTION_PAYLOAD: &str = "get_validate_transaction_payload"; - pub const GET_VALIDATE_INSTRUCTION_PAYLOAD: &str = "get_validate_instruction_payload"; - pub const GET_VALIDATE_QUERY_PAYLOAD: &str = "get_validate_query_payload"; + pub const DECODE_VALIDATE_TRANSACTION_PAYLOAD: &str = "decode_validate_transaction_payload"; + pub const DECODE_VALIDATE_INSTRUCTION_PAYLOAD: &str = "decode_validate_instruction_payload"; + pub const DECODE_VALIDATE_QUERY_PAYLOAD: &str = "decode_validate_query_payload"; } /// [`executor_entrypoint`](crate::executor_entrypoint()) macro implementation @@ -25,7 +25,7 @@ pub fn impl_entrypoint(emitter: &mut Emitter, item: syn::ItemFn) -> TokenStream macro_rules! match_entrypoints { (validate: { $($user_entrypoint_name:ident => - $generated_entrypoint_name:ident ($query_validating_object_fn_name:ident)),* $(,)? + $generated_entrypoint_name:ident ($decode_validation_payload_fn_name:ident)),* $(,)? } other: { $($other_user_entrypoint_name:ident => $branch:block),* $(,)? @@ -36,7 +36,7 @@ pub fn impl_entrypoint(emitter: &mut Emitter, item: syn::ItemFn) -> TokenStream item, stringify!($user_entrypoint_name), export::$generated_entrypoint_name, - import::$query_validating_object_fn_name, + import::$decode_validation_payload_fn_name, ) })* $(fn_name if fn_name == stringify!($other_user_entrypoint_name) => $branch),* @@ -57,9 +57,9 @@ pub fn impl_entrypoint(emitter: &mut Emitter, item: syn::ItemFn) -> TokenStream match_entrypoints! { validate: { - validate_transaction => EXECUTOR_VALIDATE_TRANSACTION(GET_VALIDATE_TRANSACTION_PAYLOAD), - validate_instruction => EXECUTOR_VALIDATE_INSTRUCTION(GET_VALIDATE_INSTRUCTION_PAYLOAD), - validate_query => EXECUTOR_VALIDATE_QUERY(GET_VALIDATE_QUERY_PAYLOAD), + validate_transaction => EXECUTOR_VALIDATE_TRANSACTION(DECODE_VALIDATE_TRANSACTION_PAYLOAD), + validate_instruction => EXECUTOR_VALIDATE_INSTRUCTION(DECODE_VALIDATE_INSTRUCTION_PAYLOAD), + validate_query => EXECUTOR_VALIDATE_QUERY(DECODE_VALIDATE_QUERY_PAYLOAD), } other: { migrate => { impl_migrate_entrypoint(item) } @@ -71,7 +71,7 @@ fn impl_validate_entrypoint( fn_item: syn::ItemFn, user_entrypoint_name: &'static str, generated_entrypoint_name: &'static str, - get_validation_payload_fn_name: &'static str, + decode_validation_payload_fn_name: &'static str, ) -> TokenStream { let syn::ItemFn { attrs, @@ -96,8 +96,8 @@ fn impl_validate_entrypoint( let generated_entrypoint_ident: syn::Ident = syn::parse_str(generated_entrypoint_name) .expect("Provided entrypoint name to generate is not a valid Ident, this is a bug"); - let get_validation_payload_fn_ident: syn::Ident = - syn::parse_str(get_validation_payload_fn_name).expect( + let decode_validation_payload_fn_ident: syn::Ident = + syn::parse_str(decode_validation_payload_fn_name).expect( "Provided function name to query validating object is not a valid Ident, this is a bug", ); @@ -110,8 +110,8 @@ fn impl_validate_entrypoint( /// [`Result`](::iroha_executor::data_model::executor::Result) #[no_mangle] #[doc(hidden)] - unsafe extern "C" fn #generated_entrypoint_ident() -> *const u8 { - let payload = ::iroha_executor::#get_validation_payload_fn_ident(); + unsafe extern "C" fn #generated_entrypoint_ident(payload: *const u8) -> *const u8 { + let payload = ::iroha_executor::#decode_validation_payload_fn_ident(payload); let verdict: ::iroha_executor::data_model::executor::Result = #fn_name(payload.authority, payload.target, payload.block_height); let bytes_box = ::core::mem::ManuallyDrop::new(::iroha_executor::utils::encode_with_length_prefix(&verdict)); @@ -147,8 +147,8 @@ fn impl_migrate_entrypoint(fn_item: syn::ItemFn) -> TokenStream { /// This function transfers the ownership of allocated [`Vec`](alloc::vec::Vec). #[no_mangle] #[doc(hidden)] - unsafe extern "C" fn #migrate_fn_name() { - let payload = ::iroha_executor::get_migrate_payload(); + unsafe extern "C" fn #migrate_fn_name(payload: *const u8) { + let payload = ::iroha_executor::decode_migrate_payload(payload); #fn_name(payload.block_height); }