This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Runtime API compilation error after adding Runtime API metadata. #14250
Copy link
Copy link
Closed
Description
Is there an existing issue?
- I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- This is not a support question.
Description of bug
When I upgrade substrate version of my project ( polkadot-v0.9.39 ==> polkadot-v0.9.42 ), the runtime API I originally defined will compile with an error:
➜ api-demo git:(master) cargo build --release
Updating git repository `https://github.com/paritytech/substrate`
Updating crates.io index
Compiling api-demo v0.1.0 (/Users/koushiro/api-demo)
error[E0277]: the trait bound `C: ProposalConfig` is not satisfied
--> src/lib.rs:22:1
|
22 | / sp_api::decl_runtime_apis! {
23 | | pub trait DemoApi<C>
24 | | where
25 | | C: ProposalConfig,
... |
28 | | }
29 | | }
| |_^ the trait `ProposalConfig` is not implemented for `C`
|
= note: this error originates in the macro `sp_api::decl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting type parameter `C`
|
29 | }, C: ProposalConfig
| +++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `api-demo` due to previous error
I think it should be caused by #13302 .
Steps to reproduce
The simple repo to reproduce the issue.
stable-aarch64-apple-darwin (default)
rustc 1.69.0 (84c898d65 2023-04-16)
[package]
name = "api-demo"
version = "0.1.0"
edition = "2021"
[dependencies]
scale-codec = { package = "parity-scale-codec", version = "3.5.0", default-features = false }
scale-info = { version = "2.7.0", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
[features]
default = ["std"]
std = [
"scale-codec/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
]#![cfg_attr(not(feature = "std"), no_std)]
use scale_codec::{Codec, Decode, Encode};
use scale_info::TypeInfo;
// Substrate
use sp_runtime::{traits::Member, RuntimeDebug};
use sp_std::hash::Hash;
pub trait ProposalConfig {
type ProposalNumber: Member + Codec + Into<u64> + From<u32> + Copy + Hash + Ord;
}
pub type ProposalNumberOf<T> = <T as ProposalConfig>::ProposalNumber;
pub type VotingStatusOf<C> = VotingStatus<ProposalNumberOf<C>>;
#[derive(Clone, PartialEq, RuntimeDebug, Encode, Decode, TypeInfo)]
pub struct VotingStatus<PNumber> {
pub last_processed_number: Option<PNumber>,
}
sp_api::decl_runtime_apis! {
pub trait DemoApi<C>
where
C: ProposalConfig,
{
fn voting_status() -> VotingStatusOf<C>;
}
}Metadata
Metadata
Assignees
Labels
No labels