mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 11:47:59 +00:00
Remove deprecated host functions (#5038)
Sadly we need to keep one function `ext_blake2_256`. This function is manually defined in `sp-core`.
This commit is contained in:
@@ -105,23 +105,6 @@ pub trait TestApi {
|
||||
}
|
||||
}
|
||||
|
||||
/// Two random external functions from the old runtime interface.
|
||||
/// This ensures that we still inherently export these functions from the host and that we are still
|
||||
/// compatible with old wasm runtimes.
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern "C" {
|
||||
pub fn ext_clear_storage(key_data: *const u8, key_len: u32);
|
||||
pub fn ext_keccak_256(data: *const u8, len: u32, out: *mut u8);
|
||||
}
|
||||
|
||||
/// Make sure the old runtime interface needs to be imported.
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub fn force_old_runtime_interface_import() {
|
||||
unsafe { ext_clear_storage(sp_std::ptr::null(), 0); }
|
||||
unsafe { ext_keccak_256(sp_std::ptr::null(), 0, sp_std::ptr::null_mut()); }
|
||||
}
|
||||
|
||||
/// This function is not used, but we require it for the compiler to include `sp-io`.
|
||||
/// `sp-io` is required for its panic and oom handler.
|
||||
#[no_mangle]
|
||||
@@ -248,4 +231,14 @@ wasm_export_functions! {
|
||||
}
|
||||
assert_eq!(0, len);
|
||||
}
|
||||
|
||||
fn test_ext_blake2_256() {
|
||||
use sp_core::Hasher;
|
||||
|
||||
let data = "hey, hash me please!";
|
||||
let hash = sp_core::Blake2Hasher::hash(data.as_bytes());
|
||||
|
||||
let expected = sp_io::hashing::blake2_256(data.as_bytes());
|
||||
assert_eq!(&expected, hash.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
|
||||
(
|
||||
HF,
|
||||
sp_io::SubstrateHostFunctions,
|
||||
sc_executor::deprecated_host_interface::SubstrateExternals
|
||||
)
|
||||
>(
|
||||
method,
|
||||
@@ -128,3 +127,8 @@ fn test_encoded_return_value_memory_is_freed() {
|
||||
fn test_array_return_value_memory_is_freed() {
|
||||
call_wasm_method::<HostFunctions>("test_array_return_value_memory_is_freed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ext_blake2_256() {
|
||||
call_wasm_method::<HostFunctions>("test_ext_blake2_256");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user