inkdevhub / drink

De-chained Ready-to-play ink! playground
Apache License 2.0
69 stars 15 forks source link

Support non-local contracts #102

Closed kroist closed 8 months ago

kroist commented 8 months ago

Tried to import another smart contract as dependency in Cargo.toml: psp22 = { git = "https://github.com/Cardinal-Cryptography/PSP22.git", branch = "ink5", default-features = false, features = ["contract", "ink-as-dependency"] }

when running cargo test --release I get following errors:

Stacktrace ``` error: linking with `cc` failed: exit status: 1 | = note: LC_ALL="C" PATH="......" = note: /usr/bin/ld: /home/user/.cargo/git/checkouts/psp22-38a68ab568348ac0/2330b07/target/ink/release/deps/metadata_gen-bf7ddbc074b5cbec.metadata_gen.12ff4bc3d4a64004-cgu.5.rcgu.o: in function `metadata_gen::main': metadata_gen.12ff4bc3d4a64004-cgu.5:(.text._ZN12metadata_gen4main17hec59d71e2f886443E+0x11): undefined reference to `__ink_generate_metadata' collect2: error: ld returned 1 exit status = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified = note: use the `-l` flag to specify native libraries to link = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname) error: could not compile `metadata-gen` (bin "metadata-gen") due to previous error error: custom attribute panicked --> drink_tests/mod.rs:10:1 | 10 | #[drink::contract_bundle_provider] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: message: Error building contract: command ["/home/user/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/bin/cargo", "run", "--color=always", "--package", "metadata-gen", "--manifest-path=/tmp/cargo-contract_fLH7zx/Cargo.toml", "--target-dir", "/home/user/.cargo/git/checkouts/psp22-38a68ab568348ac0/2330b07/target/ink", "--release"] exited with code 101 Stack backtrace: 0: anyhow::error:: for anyhow::Error>::from 1: as core::ops::try_trait::FromResidual>>::from_residual 2: contract_build::metadata::execute::{{closure}} 3: contract_build::workspace::Workspace::using_temp 4: contract_build::metadata::execute 5: contract_build::execute 6: drink_test_macro::contract_building::build_contract_crate 7: core::ops::function::FnMut::call_mut 8: core::iter::adapters::map::map_fold::{{closure}} 9: core::iter::adapters::map::map_fold::{{closure}} 10: core::iter::adapters::filter::filter_fold::{{closure}} 11: as core::iter::traits::iterator::Iterator>::fold 12: as core::iter::traits::iterator::Iterator>::fold 13: as core::iter::traits::iterator::Iterator>::fold 14: as core::iter::traits::iterator::Iterator>::fold 15: as core::iter::traits::iterator::Iterator>::fold 16: as core::iter::traits::iterator::Iterator>::fold 17: core::iter::traits::iterator::Iterator::for_each 18: as core::iter::traits::collect::Extend<(K,V)>>::extend 19: as core::iter::traits::collect::FromIterator<(K,V)>>::from_iter 20: drink_test_macro::bundle_provision::BundleProviderGenerator::new 21: drink_test_macro::contract_building::build_contracts 22: drink_test_macro::contract_bundle_provider_internal 23: drink_test_macro::contract_bundle_provider 24: core::ops::function::Fn::call 25: proc_macro::bridge::client::Client<(proc_macro::TokenStream,proc_macro::TokenStream),proc_macro::TokenStream>::expand2::{{closure}}::{{closure}} 26: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}::{{closure}} 27: proc_macro::bridge::scoped_cell::ScopedCell::set::{{closure}} 28: proc_macro::bridge::scoped_cell::ScopedCell::replace 29: proc_macro::bridge::client::run_client::{{closure}}::{{closure}} 30: std::thread::local::LocalKey::try_with 31: proc_macro::bridge::client::run_client::{{closure}} 32: as core::ops::function::FnOnce<()>>::call_once 33: std::panicking::try::do_call 34: __rust_try 35: std::panicking::try 36: proc_macro::bridge::client::run_client 37: proc_macro::bridge::client::Client<(proc_macro::TokenStream,proc_macro::TokenStream),proc_macro::TokenStream>::expand2::{{closure}} 38: proc_macro::bridge::selfless_reify::reify_to_extern_c_fn_hrt_bridge::wrapper 39: > as proc_macro::bridge::server::ExecutionStrategy>::run_bridge_and_client::>> 40: ::expand 41: ::fully_expand_fragment 42: ::expand_crate 43: rustc_interface::passes::resolver_for_lowering 44: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 45: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 46: rustc_query_impl::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace 47: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0} 48: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 49: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 50: as core::ops::function::FnOnce>::call_once at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9 51: as core::ops::function::FnOnce>::call_once at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9 52: std::sys::unix::thread::Thread::new::thread_start at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17 53: start_thread at ./nptl/pthread_create.c:442:8 54: __GI___clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 error: custom attribute panicked --> drink_tests/mod.rs:13:1 | 13 | #[drink::test] | ^^^^^^^^^^^^^^ | = help: message: Error locking mutex: PoisonError { .. } error: custom attribute panicked --> drink_tests/mod.rs:74:1 | 74 | #[drink::test] | ^^^^^^^^^^^^^^ | = help: message: Error locking mutex: PoisonError { .. } ```
pmikolajczyk41 commented 8 months ago

this is not a problem with non-local contracts, but with the fact, that psp22 lib is built by drink macros without the contract feature

closing this issue, as it seems non-local contracts are supported; I will support build feature in a separate issue