-
Notifications
You must be signed in to change notification settings - Fork 248
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
Example: How to connect to parachain #1043
Example: How to connect to parachain #1043
Conversation
14f990e
to
4a632f1
Compare
//! as the polkadot.js link to the parachain (e.g. "collator01") in the zombienet output. Here `41955` refers to the port, | ||
//! which we will need shortly. | ||
//! | ||
//! In this example we use the _uniques_ pallet of the polakdot asset hub parachain. |
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.
//! In this example we use the _uniques_ pallet of the polakdot asset hub parachain. | |
//! In this example we use the _uniques_ pallet of the polkadot asset hub parachain. |
//! | ||
//! We use [zombienet](https://github.com/paritytech/zombienet) to start up a local asset hub. | ||
//! | ||
//! ## 1. Install necessary tools |
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.
It would useful if you add bash script/docker image that installs everything and runs it.
It's super complicated to run this :P
//! Polkadot / Kusama / Rococo have different epoch times of `24h` / `2h` / `2min` respectively. | ||
//! The parachain is only registered after the first epoch. So we need to wait 2 minutes, until the parachain becomes interactive and produces blocks. | ||
//! | ||
//! |
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.
//! |
//! | ||
//! # Running the example | ||
//! | ||
//! After you have the network running, you should see something like [https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:41955#/explorer] |
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.
can't we instruct zoombienet to use a specific port to avoid more configurations to run this example?
[relaychain] | ||
default_image = "docker.io/parity/polkadot:latest" | ||
default_command = "polkadot" | ||
default_args = [ "-lparachain=debug" ] |
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.
default_args = [ "-lparachain=debug" ] | |
default_args = ["-lparachain=debug"] |
// Third Config (using the Substrate and Polkadot Config) | ||
//////////////////////////////////////////////////////////// | ||
|
||
pub enum StatemintConfig3 {} |
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 don't see why you need to duplicate this config, it would be better to just to call this PolkadotConfig
via type alias or something.
This example contains already plenty of code :)
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.
Just because the ExtrinsicParams are from Substrate instead of from Polkadot here. So it would be inaccurate to take just the PolkadotConfig.
// Second Config (just using subxt types) | ||
//////////////////////////////////////////////////////////// | ||
|
||
pub enum StatemintConfig2 {} |
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.
maybe you could rename this to StatemintConfigAssetTip
// First Config (verbose and detailed) | ||
//////////////////////////////////////////////////////////// | ||
|
||
pub enum StatemintConfig {} |
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.
maybe you could rename this to StatemintConfigChargeAssetTxPayment
//! - Address: [sp_runtime::MultiAddress<Self::AccountId, ()>](sp_runtime::MultiAddress) | ||
//! - Signature: [sp_runtime::MultiSignature] | ||
//! | ||
//! #### ExtrinsicParams |
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.
This is really great information but I think it's a bit too much for my taste in such example.
Like, we could say "subxt exposes a Config
trait that mimics the frame_system::Config
and how to construct extrinsic for a given runtime (ExtrinsicParams).
Such as if your parachain runtime has different SignedExtra
then the default runtime in Substrate/Polkadot then you need provide a custom type for ExtrinsicParams
in order to construct valid extrinsics.
The same applies to all associated types in the trait subxt::Config
Ideally, subxt could parse these types from the metadata/wasm blob that could be extracted when subxt connects to the node but that doesn't work currently and you have provide this yourself.
For more information regarding the SignedExtra
see documentation at some link ^^
2038884
to
a9901a5
Compare
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.
The restructuring looks good to me, I like how you broken down the type replacements into different sections and the example is now more slim.
Ah one mo; hit a compilation error with the example; need to add CI or something and fix it |
@@ -109,7 +109,7 @@ jobs: | |||
# Check WASM examples, which aren't a part of the workspace and so are otherwise missed: | |||
- name: Cargo check WASM examples | |||
run: | | |||
cargo check --manifest-path examples/wasm-example/Cargo.toml | |||
cargo check --manifest-path examples/wasm-example/Cargo.toml --target wasm32-unknown-unknown |
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.
Nit: I think this should already be the case since target: wasm32-unknown-unknown
means that it's the only target that will be installed, but nothing wrong with having some extra reassurance (I've done similar!)
The example shows how someone might construct the subxt::Config and the metadata module for a certain parachain if they develop an application with subxt.
The example is using the Statemint (Polkadot Asset Hub) parachain as an example.