3

I'm trying to implement this xcm chain extension mvp to send a XCM call from a simple contract.

The problem i'm facing is when i try to compile the contract with the given Cargo.toml, i get the following compilation error:

➜  ink git:(master) ✗ cargo +nightly contract build

....

error: the `#[global_allocator]` in ink_allocator conflicts with global allocator in: sp_io

error: duplicate lang item in crate `sp_io` (which `sp_application_crypto` depends on): `panic_impl`.
  |
  = note: the lang item is first defined in crate `ink_env` (which `flipper` depends on)
  = note: first definition in `ink_env` loaded from /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libink_env-0acca4fc7a95b368.rlib
  = note: second definition in `sp_io` loaded from /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libsp_io-7276ad9650247190.rlib, /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libsp_io-7276ad9650247190.rmeta

error: duplicate lang item in crate `sp_io` (which `sp_application_crypto` depends on): `oom`.
  |
  = note: the lang item is first defined in crate `ink_allocator` (which `ink_env` depends on)
  = note: first definition in `ink_allocator` loaded from /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libink_allocator-f7c621310e573610.rlib, /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libink_allocator-f7c621310e573610.rmeta
  = note: second definition in `sp_io` loaded from /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libsp_io-7276ad9650247190.rlib, /Users/hectorb/blockchain/pallet-contracts-xcm/ink/target/ink/wasm32-unknown-unknown/release/deps/libsp_io-7276ad9650247190.rmeta

error: could not compile `extension-xcm` due to 3 previous errors

Is there anything i'm not taking into account when building the contract? I have tried with many variants adding the xcm crate dependency from a new project using cargo contract new ..., but the error is the same.

Also it would be nice to know if there is there any working example of this extension where i can take references?

Github issue: https://github.com/paritytech/pallet-contracts-xcm/issues/1

2

1 Answer 1

6

The xcm crate at some point imports the sp-io that contains its own implementation of the allocator making conflicts with the global_allocator of ink!

This can be solved importing the sp-io as well and use a set of specific features that explicitly excludes th:

sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }

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