-
Notifications
You must be signed in to change notification settings - Fork 708
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
[tracking] Facade #6441
Comments
what is this facade project? |
I added the rough plan we had in mind now; I hope that helps! |
should XCQ be part of this? polkadot-fellows/RFCs#126 |
Fascade itself should be written in Rust. Rust itself can be integrated almost anywhere. Like you said into typescript via WASM or directly into |
I'm mostly onboard with that! Given that most people using it will write TS apps, I wonder if it would make sense though to write a separate TS and Rust impl of the Facade Client library. That way, the TS version will be very idiomatic, have a small bundle size and be written in PAPI, which already has the relevant primitives for decoding etc. It'll make sense for most dApps and such. The Rust version would then use Subxt and be the thing we bind to in other languages (and we could eventually maintain such bindings for a few langs). Both would likely rely on the Rust stuff for historic block decoding, but this would only need to be pulled in in TS land when needed to avoid the bloat of the WASM blob. |
You could probably still provide some idiomatic TS library that uses the interfaces of the Rust library in a more typescript way. Same is for example done in Rust when you wrap a C library, you also expose Rust interfaces while under the hood using the C functions. But still you only write glue code in Rust and the actual implementation is in C. Same principle could be applied here. |
Yep true; I guess my main argument was on the WASM bundle size. Josep reimplemented the merkleized-metadata stuff in TS for instance because of this, and I imagine importing a fair chunk of WASM may not appeal to some TS folks :D |
XCQ extension already handles the API definition part and it provides metadata so client can generate whatever code it needs from the metadata |
My understanding at the moment is that this and XCQ are complementory:
|
yes I just want to ensure this project is designed and built in mind of XCQ to ensure they can nicely integrate together and avoid duplicate work |
Yup that makes sense! I think it'll be a net win overall to have both the "easy" APIs that users can use to obtain basic data across chains, plus a more advanced way to obtain and aggregate more custom/complex queries via XCQ programs. I can also imagine that when XCQ is ready we might start using it to aggregate some of this data together in place of traditional Runtime APIs where it makes sense! Ultimately this work here shouldn't duplicate any XCQ related work. Instead. it'll provide the Pallet View Functions and new Runtime APIs which can then be fed into XCQ programs. |
This is a tracking issue which collects any issues that are releated to the Facade project.
Please add any facade related issues to this as needed.
Tasks
\cc @gui1117 @Jan-Jan
What is the Polkadot Facade?
Authors: @kianenigma, @jsdw
TL;DR
Terminology
Scope
The scope of this project includes all the beige items pictured below:
Diagram 2: A system view of the pieces of work (beige) that comprises the Polkadot Facade
Implementation
This work can be broken into the following streams. Streams 2 and 3 mainly involves work in
polkadot-sdk
. The rest of the work will mostly happen elsewhere.Steps 1-4 can roughly be worked on in parallel, and then as we define more APIs that we are ready to have a go at implementing in 1, we’ll be able to start progressing on 5.
More detail on each of these to follow:
Stream 1: Facade Client API Repository
This repository will contain a spec which defines the rough shape of the Facade Client APIs along with a reference implementation written using PAPI[^4]. We’ll:
In conjunction with creating a repository, we’ll gather feedback on which APIs to actually have. To this end, we’ve opened more issues like this to gather feedback from ecosystem developers.
Stream 2: Facade polkadot-sdk groundwork
This covers the changes we’d like to have in polkadot-sdk in order to support this Facade work. These are:
Stream 3: Facade Runtime API crates
We’ll create crates to house the Facade API definitions.
The MVP here is simply to expose some Facade Runtime APIs created with
decl_runtime_apis!
, once we start to know which APIs we want.Building on this, we also want to expose some metadata about the Facade APIs we've defined. This will allow for libraries/tools to check a runtimes compatibility with the Facade APIs (eg what versions of which APIs does some runtime support) or generate documentation about the Facade APIs.
We should also think about how we can make implementing the Facade APIs as easy as possible, since many of them will simply point at some crate(s) and call the relevant Pallet View Functions to retrieve/aggregate an answer. To that end, we might also build:
facade::view_impl_helpers::balances_total_balance_impl!(BalancesPallet, OtherBalancesPallet)
) which generate implementations of certain facade APIs (in this example,Balances::total_balance
) which rely on the relevant Pallet View Functions.Stream 4: Support historic decoding in TypeScript
Any Client Facade API that we create should also be able to point back in time to an older block and provide back an answer. This requires us to be able to decode the state in historic blocks and transform it into the “modern” format that we’ve defined for the API.
We want a Client Facade API implementation to exist in TypeScript, and we now have a crate written in Rust that is responsible for decoding extrinsics and storage keys/values from the past. In theory, this crate compiles to WASM, and we can decode things into the
scale_value::Value
type, which can be serialized to JSON to be passed from WASM into TS to then be worked with.Let’s:
frame-decode
to allow historic state to be decoded in TypeScript.Stream 5: Implement APIs E2E
Once the above has taken shape, we’ll start to settle on some APIs that we want to see implemented. To that end, we’ll:
This process is likely to be repeated as we settle on the definitions of more Facade Client APIs. We should also consider marking such APIs as unstable throughout the stack until we are happy with them and don’t intend to make any further changes.
The text was updated successfully, but these errors were encountered: