Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conditional compilation in decl_runtime_apis and frame_support::pallet #1533

Open
nazar-pc opened this issue Sep 13, 2023 · 4 comments

Comments

@nazar-pc
Copy link
Contributor

While paritytech/substrate#14709 supposedly added conditional compilation in impl_runtime_apis, I can't really leverage that for one of use cases where depending on feature flags provided different parts of pallet and runtime API should be provided.

In particular I'm interested in methods of runtime API and storage items in pallet, but ideally all things would be equally supported.

As a workaround right now I put conditional compilation on the whole decl_runtime_apis/impl_runtime_apis, which results in large code duplication and for pallet I have to carry both useful and useless storage items, etc.

@bkchr
Copy link
Member

bkchr commented Sep 13, 2023

Could you please give concrete examples on what is not working.

@nazar-pc
Copy link
Contributor Author

I was trying to get this to compile and then similarly conditionally implement in runtimes:

sp_api::decl_runtime_apis! {
    pub trait SubspaceApi<RewardAddress: Encode + Decode> {
        fn slot_duration() -> SlotDuration;

        #[cfg(feature = "pot")]
        fn pot_parameters() -> PotParameters;

        #[cfg(not(feature = "pot"))]
        fn global_randomnesses() -> GlobalRandomnesses;
    }
}

@bkchr
Copy link
Member

bkchr commented Sep 13, 2023

But then you would not know on the node side if these functions are available without calling and the executor screaming about you that the functions are missing.

With the PR linked above you can handle this in a much better way.

@nazar-pc
Copy link
Contributor Author

I'm working on new incompatible revision of the consensus in the same codebase. I either compile everything with the feature or without, it is 100% expected that a mix of those things will not work together and it was never my expectation that it would.

bkchr pushed a commit that referenced this issue Apr 10, 2024
* splitted Substrate RPC trait

* introduce subscription methods

* removed commented code

* removed commented code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants