-
Notifications
You must be signed in to change notification settings - Fork 695
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
Add scaffolding to declare Facade APIs #6396
base: master
Are you sure you want to change the base?
Conversation
@@ -576,6 +577,7 @@ runtime = [ | |||
"sp-crypto-hashing-proc-macro", | |||
"sp-debug-derive", | |||
"sp-externalities", | |||
"sp-facade-apis/decl-runtime-apis", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether this should be in the "runtime" feature or else in "runtime_full" or kept entirely separate.
/cmd prdoc --audience runtime_dev |
Looking at the "Check publish" error, I assume I need to manually publish these crates to crates.io before I can merge this, since they are new. In that case, I'll wait for reviews and if we are happy with things, I can go and manually publish etc so that it's all good to go. |
I don't get why we need this. I can come up with millions of ways to still change the trait without the macro being able to detect this. The only thing it would detect is that the thing it is named IMO it would be much better to just have these interfaces declared with proper documentation around them and how versioning works. Or even create a separate document explaining the versioning etc. Anyone writing software should be aware on "what a stable interface" is and that you can not just change it etc. You want a social consensus and not this macro. |
We could definitely just have a I considered this, but ultimately I saw enough benefits to writing a small wrapper around the
|
A node doesn't implement any facade API. A runtime, but not a node. Also to check the version you just need to check the version of the runtime api.
Use external tooling. You really want to shove all this stuff into some macro? How should that work? Should that generate python, js and whatever examples? Doesn't sound reasonable to me.
Could be a custom linter that also has much more context etc.
Please just no. So you want people to lookup this hash somewhere and then fetch the system version manually to find out if this hash is part of it? Provide a tool |
Yup fair; I was thinking only about connecting to a node via RPC and using its metadata to check the compatibility of the runtime the node is using. And yeah, checking the version of the runtime API can be done just with
I indeed would use external tooling for that and not shove it in a macro; because the macro generates some metadata it's easy to write some external lib which takes that metadata and uses it to hand back docs or whatever.
Having the hash would make it a little easier for devs to check things in the case of issues, but I agree that having a proper tool or way to check it would be nicer. That's why the main thing of this facade macro is handing back metadata: we can write this sort of tool without manually redefining somewhere else what the facade APIs should look like and having to keep that in sync with reality. If you're generally against the facade macro and metadata it creates then we can strip it out and just use |
But what is this extra metadata that the macro could generate? The macro has exactly access to the same information as the |
Ah yeah I'm being dumb; I did this stuff before digging into The metadata I generate directly in
For using in eg Subxt, I'd rather avoid bringing that many dependencies in, but I could look into adding some feature flag so that I can obtain the metadata without pulling in all of these other crates ( What do you reckon? |
A final thought is that if I rely on the |
|
My thoughts on the features of this facade crate were:
Sorry; I don't really follow this bit? 😅 if I generate the metadata locally as I am now then I only pull in If I make use of the
Yup that's an interesting thought! I'm unsure how much apps care about this, but having eg This would make checking compat with facade APIs easy too (if we trust that the facade APIs have indeed remained stable), so potentially the facade metadata we spit out here could be simplified to just method names and versions and no scale-info stuff (trusting that the types are stable and line up). I'm easy either way on this bit though; some part of me likes checking the full type signatures to be 100% confident things match up! |
This PR adds two new crates:
sp-facade-apis
: A crate to define Facade Runtime APIs. This has two purposes:sp-facade-apis-macro
: A supporting macro to enable the above.The Facade APIs are not actually populated yet, except with an example showing the syntax (same as
decl_runtime_apis
basically).I wonder whether I should also "implement" the example APi in the kitchensink runtime just to show it working (my current plan is to have an example runtime in a separate crate along with a compatibility tool etc which shows the usage and allows trying out things).
\cc @kianenigma