Based on:

I understand that I should be able to:

  1. have a crate that is not wasm/no-std friendly, e.g. relies on std library
  2. put its functionalities under a trait with #[sp_runtime_interface::runtime_interface] attribute
  3. register corresponding host function in the node's executor
  4. 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 default-features and /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.

  • @bkchr you have answered with You just need to call dvm_ext::evm_event(events), but I couldn't even find a module with trait_ext name May 17, 2023 at 8:45

2 Answers 2


Substrate provide sp-std and sp-io for std calls in a no_std environment. By the error I can understand you are using std instead of sp-std or sp-io so it is giving you the error duplicate lang item in crate. I hope this helps.

  • well, I'm using 3rd party library that uses std things, so there's no way that I can substitute std with sp-std; is this the case that I can use std-based code in a host function only if it delegates std things to sp-std? May 17, 2023 at 10:03
  • Yes it should work like this May 17, 2023 at 12:58

If you have registered the HostFunctions in your host code, you should just include the sp_your_runtime_interface in your pallet to call the host function. Including your std-required crate in pallet will cause importing std.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.