Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

impl_runtime_apis does not work if sp-api is not in scope #14145

Closed
kianenigma opened this issue May 15, 2023 · 6 comments
Closed

impl_runtime_apis does not work if sp-api is not in scope #14145

kianenigma opened this issue May 15, 2023 · 6 comments
Labels
I3-bug The node fails to follow expected behavior.

Comments

@kianenigma
Copy link
Contributor

Somewhat similar to paritytech/polkadot-sdk#173, it seems like this macro also does not work if sp-api is not directly in scope as a dependency. The error message is very cryptic:

error: proc macro panicked
   --> staging-runtime/src/lib.rs:114:1
    |
114 | / impl_runtime_apis! {
115 | |     impl frame_runtime::runtime_apis::Core<Block> for Runtime {
116 | |         fn version() -> RuntimeVersion {
117 | |             VERSION
...   |
177 | |     }
178 | | }
    | |_^
    |
    = help: message: unexpected token

This prevents eg. #14137 to re-export sp_api::Core and impl_runtime_apis in a way that is meaningfully usable.

Note that for rest of the APIs, like sp_block_builder you can import it from a 3rd party re-export them from somewhere else and it works. Although, you need make sure to re-export them like pub use sp_block_builder::* to re-export some magic generated by decl_runtime_apis! as well.

@kianenigma kianenigma added the I3-bug The node fails to follow expected behavior. label May 15, 2023
@github-project-automation github-project-automation bot moved this to Backlog 🗒 in SDK Node May 15, 2023
@bkchr
Copy link
Member

bkchr commented May 15, 2023

It should for sure not panic, but otherwise it uses the same logic as in FRAME.

@kianenigma
Copy link
Contributor Author

Moreover, if sp-api is imported without any notion of disabling default features, like:

sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "kiz-frame-api" }

we get the following error:

error[E0425]: cannot find function `to_substrate_wasm_fn_return_value` in crate `sp_api`
   --> staging-runtime-native/src/lib.rs:114:1
    |
114 | / impl_runtime_apis! {
115 | |     impl frame_runtime::runtime_apis::Core<Block> for Runtime {
116 | |         fn version() -> RuntimeVersion {
117 | |             VERSION
...   |
177 | |     }
178 | | }
    | |_^ not found in `sp_api`
    |
    = note: this error originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

@kianenigma
Copy link
Contributor Author

Can this be fixed in a timely fashion? if we can fix it sooner, I won't need to go and refactor infinite number of branches in the tutorial late 🙈

@bkchr
Copy link
Member

bkchr commented May 24, 2023

we get the following error:

Did you read what I have written in element? The same applies for all FRAME macros as well...

@kianenigma
Copy link
Contributor Author

kianenigma commented Jun 23, 2023

@bkchr do you have any plans to address this? I initially thought the #14267 is going to fix this, but I was wrong.

Saw your comment here #14267 (comment).

@kianenigma
Copy link
Contributor Author

closed in 7d912d0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I3-bug The node fails to follow expected behavior.
Projects
Status: done
Development

No branches or pull requests

2 participants