- Use std only rust library to extend substrate runtime interface？
- How to understand [runtime-interface] and `Externalities`?
I understand that I should be able to:
- have a crate that is not wasm/no-std friendly, e.g. relies on
- put its functionalities under a trait with
- register corresponding host function in the node's executor
- call the functionality from a pallet
However, when I'm trying to do so, I'm getting the classical error:
error[E0152]: duplicate lang item in crate `std` (which `serde` depends on): `panic_impl`. | = note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on) = note: first definition in `sp_io` loaded from /home/ec2-user/remote-builds/8351322047856898080/target/release/wbuild/aleph-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-adc573607c02c939.rmeta = note: second definition in `std` loaded from /home/ec2-user/.rustup/toolchains/nightly-2022-10-30-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-013c81c18ec4954a.rlib
I'm pretty sure that I have set up all
/std features correctly. The problem is gone when I remove the std-based dependencies from my crate, but that's the thing - I want to use them in my runtime.
Maybe the problem is in the way I should call the host function from the pallet. I have put my crate as a dependency and I'm calling it with
<crate_name>::<snake_case_trait_name>::<trait_method_name>. Is this the correct way or should I use some magic with externalities etc. I couldn't find any example in the Substrate repo, apart from
statement_store, which is actually is no-std/wasm compatible, so it doesn't help.