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

Add People and Coretime #21

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 85 additions & 8 deletions src/build_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#[clap(long = "asset-hub")]
asset_hub: Option<String>,

/// Optional. The runtime version of Bridge Hub to which to upgrade. If not provided, it will use
/// the Relay Chain's version.
/// Optional. The runtime version of Bridge Hub to which to upgrade. If not provided, it will
/// use the Relay Chain's version.
#[clap(long = "bridge-hub")]
bridge_hub: Option<String>,

Expand All @@ -29,6 +29,16 @@
#[clap(long = "collectives")]
collectives: Option<String>,

/// Optional. The runtime version of People to which to upgrade. If not provided, it will use
/// the Relay Chain's version.
#[clap(long = "people")]
people: Option<String>,

/// Optional. The runtime version of Coretime to which to upgrade. If not provided, it will use
/// the Relay Chain's version.
#[clap(long = "coretime")]
coretime: Option<String>,

/// Optional. The runtime version of Encointer to which to upgrade. If not provided, it will use
/// the Relay Chain's version.
#[clap(long = "encointer")]
Expand Down Expand Up @@ -90,6 +100,16 @@
} else {
relay_version.clone()
};
let people_version = if let Some(v) = prefs.people {
String::from(v.trim_start_matches('v'))
} else {
relay_version.clone()
};
let coretime_version = if let Some(v) = prefs.coretime {
String::from(v.trim_start_matches('v'))
} else {
relay_version.clone()
};

let relay = match prefs.network.to_ascii_lowercase().as_str() {
"polkadot" => {
Expand Down Expand Up @@ -122,13 +142,21 @@
network: Network::KusamaAssetHub,
version: asset_hub_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::KusamaEncointer,
version: encointer_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::KusamaBridgeHub,
version: bridge_hub_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::KusamaEncointer,
version: encointer_version.clone(),
network: Network::KusamaPeople,
version: people_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::KusamaCoretime,
version: coretime_version.clone(),
});
VersionedNetwork { network: Network::Kusama, version: relay_version.clone() }
},
Expand Down Expand Up @@ -198,6 +226,8 @@
Network::Polkadot => "polkadot",
Network::KusamaAssetHub => "asset-hub-kusama",
Network::KusamaBridgeHub => "bridge-hub-kusama",
Network::KusamaPeople => "people-kusama",
Network::KusamaCoretime => "coretime-kusama",
Network::KusamaEncointer => "encointer-kusama",
Network::PolkadotAssetHub => "asset-hub-polkadot",
Network::PolkadotCollectives => "collectives-polkadot",
Expand Down Expand Up @@ -267,6 +297,42 @@
));
authorization_calls.push(call);
},
Network::KusamaPeople => {
use kusama_people::runtime_types::cumulus_pallet_parachain_system::pallet::Call;

Check failure on line 301 in src/build_upgrade.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `kusama_people`

error[E0433]: failed to resolve: use of undeclared crate or module `kusama_people` --> src/build_upgrade.rs:301:9 | 301 | use kusama_people::runtime_types::cumulus_pallet_parachain_system::pallet::Call; | ^^^^^^^^^^^^^ use of undeclared crate or module `kusama_people`
let path = format!(
"{}people-kusama_runtime-v{}.compact.compressed.wasm",
upgrade_details.directory, runtime_version
);
let runtime = fs::read(path).expect("Should give a valid file path");
let runtime_hash = blake2_256(&runtime);
println!("Kusama People Runtime Hash: 0x{}", hex::encode(runtime_hash));

let call = CallInfo::from_runtime_call(NetworkRuntimeCall::KusamaPeople(
KusamaPeopleRuntimeCall::ParachainSystem(Call::authorize_upgrade {
code_hash: H256(runtime_hash),
check_version: true,
}),
));
authorization_calls.push(call);
},
Network::KusamaCoretime => {
use kusama_coretime::runtime_types::cumulus_pallet_parachain_system::pallet::Call;

Check failure on line 319 in src/build_upgrade.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `kusama_coretime`

error[E0433]: failed to resolve: use of undeclared crate or module `kusama_coretime` --> src/build_upgrade.rs:319:9 | 319 | use kusama_coretime::runtime_types::cumulus_pallet_parachain_system::pallet::Call; | ^^^^^^^^^^^^^^^ use of undeclared crate or module `kusama_coretime`
let path = format!(
"{}coretime-kusama_runtime-v{}.compact.compressed.wasm",
upgrade_details.directory, runtime_version
);
let runtime = fs::read(path).expect("Should give a valid file path");
let runtime_hash = blake2_256(&runtime);
println!("Kusama Coretime Runtime Hash: 0x{}", hex::encode(runtime_hash));

let call = CallInfo::from_runtime_call(NetworkRuntimeCall::KusamaCoretime(
KusamaCoretimeRuntimeCall::ParachainSystem(Call::authorize_upgrade {
code_hash: H256(runtime_hash),
check_version: true,
}),
));
authorization_calls.push(call);
},
Network::KusamaEncointer => {
use kusama_encointer::runtime_types::cumulus_pallet_parachain_system::pallet::Call;
let path = format!(
Expand All @@ -275,7 +341,7 @@
);
let runtime = fs::read(path).expect("Should give a valid file path");
let runtime_hash = blake2_256(&runtime);
println!("Kusama Encointer Runtime Hash: 0x{}", hex::encode(runtime_hash));
println!("Kusama Encointer Runtime Hash: 0x{}", hex::encode(runtime_hash));

let call = CallInfo::from_runtime_call(NetworkRuntimeCall::KusamaEncointer(
KusamaEncointerRuntimeCall::ParachainSystem(Call::authorize_upgrade {
Expand Down Expand Up @@ -423,11 +489,19 @@
let send_auth = send_as_superuser_from_kusama(&auth).await;
batch_calls.push(send_auth);
},
Network::KusamaEncointer => {
let send_auth = send_as_superuser_from_kusama(&auth).await;
batch_calls.push(send_auth);
},
Network::KusamaBridgeHub => {
let send_auth = send_as_superuser_from_kusama(&auth).await;
batch_calls.push(send_auth);
},
Network::KusamaEncointer => {
Network::KusamaPeople => {
let send_auth = send_as_superuser_from_kusama(&auth).await;
batch_calls.push(send_auth);
},
Network::KusamaCoretime => {
let send_auth = send_as_superuser_from_kusama(&auth).await;
batch_calls.push(send_auth);
},
Expand Down Expand Up @@ -456,8 +530,11 @@
match auth.network {
Network::Kusama | Network::Polkadot =>
panic!("para calls should not contain relay calls"),
Network::KusamaAssetHub | Network::KusamaBridgeHub | Network::KusamaEncointer =>
panic!("not polkadot parachains"),
Network::KusamaAssetHub
| Network::KusamaBridgeHub
| Network::KusamaPeople
| Network::KusamaCoretime
| Network::KusamaEncointer => panic!("not polkadot parachains"),
Network::PolkadotAssetHub => {
let send_auth = send_as_superuser_from_polkadot(&auth).await;
batch_calls.push(send_auth);
Expand Down
50 changes: 49 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
pub mod kusama_bridge_hub {}
pub(super) use kusama_bridge_hub::runtime_types::bridge_hub_kusama_runtime::RuntimeCall as KusamaBridgeHubRuntimeCall;

#[subxt::subxt(runtime_metadata_insecure_url = "wss://kusama-people-rpc.polkadot.io:443")]
pub mod kusama_people {}
pub(super) use kusama_people::runtime_types::people_kusama_runtime::RuntimeCall as KusamaPeopleRuntimeCall;

Check failure on line 23 in src/types.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `kusama_people`

error[E0433]: failed to resolve: use of undeclared crate or module `kusama_people` --> src/types.rs:23:16 | 23 | pub(super) use kusama_people::runtime_types::people_kusama_runtime::RuntimeCall as KusamaPeopleRuntimeCall; | ^^^^^^^^^^^^^ use of undeclared crate or module `kusama_people`

#[subxt::subxt(runtime_metadata_insecure_url = "wss://kusama-coretime-rpc.polkadot.io:443")]
pub mod kusama_coretime {}
pub(super) use kusama_coretime::runtime_types::coretime_kusama_runtime::RuntimeCall as KusamaCoretimeRuntimeCall;

Check failure on line 27 in src/types.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `kusama_coretime`

error[E0433]: failed to resolve: use of undeclared crate or module `kusama_coretime` --> src/types.rs:27:16 | 27 | pub(super) use kusama_coretime::runtime_types::coretime_kusama_runtime::RuntimeCall as KusamaCoretimeRuntimeCall; | ^^^^^^^^^^^^^^^ use of undeclared crate or module `kusama_coretime`

#[subxt::subxt(runtime_metadata_insecure_url = "wss://kusama.api.encointer.org:443")]
pub mod kusama_encointer {}
pub(super) use kusama_encointer::runtime_types::encointer_runtime::RuntimeCall as KusamaEncointerRuntimeCall;
Expand Down Expand Up @@ -55,6 +63,8 @@
Kusama,
KusamaAssetHub,
KusamaBridgeHub,
KusamaPeople,
KusamaCoretime,
KusamaEncointer,
Polkadot,
PolkadotAssetHub,
Expand All @@ -68,8 +78,10 @@
match &self {
Kusama => Err("relay chain"),
KusamaAssetHub => Ok(1_000),
KusamaBridgeHub => Ok(1_002),
KusamaEncointer => Ok(1_001),
KusamaBridgeHub => Ok(1_002),
KusamaPeople => Ok(1_004),
KusamaCoretime => Ok(1_005),
Polkadot => Err("relay chain"),
PolkadotAssetHub => Ok(1_000),
PolkadotCollectives => Ok(1_001),
Expand Down Expand Up @@ -135,6 +147,8 @@
Kusama(KusamaRuntimeCall),
KusamaAssetHub(KusamaAssetHubRuntimeCall),
KusamaBridgeHub(KusamaBridgeHubRuntimeCall),
KusamaPeople(KusamaPeopleRuntimeCall),
KusamaCoretime(KusamaCoretimeRuntimeCall),
KusamaEncointer(KusamaEncointerRuntimeCall),
Polkadot(PolkadotRuntimeCall),
PolkadotAssetHub(PolkadotAssetHubRuntimeCall),
Expand Down Expand Up @@ -174,10 +188,12 @@
impl CallInfo {
// Construct `Self` from a `NetworkRuntimeCall`.
pub(super) fn from_runtime_call(call: NetworkRuntimeCall) -> Self {
let (network, encoded) = match &call {

Check failure on line 191 in src/types.rs

View workflow job for this annotation

GitHub Actions / lint

the size for values of type `[u8]` cannot be known at compilation time

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> src/types.rs:191:17 | 191 | let (network, encoded) = match &call { | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature
NetworkRuntimeCall::Kusama(cc) => (Network::Kusama, cc.encode()),
NetworkRuntimeCall::KusamaAssetHub(cc) => (Network::KusamaAssetHub, cc.encode()),
NetworkRuntimeCall::KusamaBridgeHub(cc) => (Network::KusamaBridgeHub, cc.encode()),
NetworkRuntimeCall::KusamaPeople(cc) => (Network::KusamaPeople, cc.encode()),
NetworkRuntimeCall::KusamaCoretime(cc) => (Network::KusamaCoretime, cc.encode()),
NetworkRuntimeCall::KusamaEncointer(cc) => (Network::KusamaEncointer, cc.encode()),
NetworkRuntimeCall::Polkadot(cc) => (Network::Polkadot, cc.encode()),
NetworkRuntimeCall::PolkadotAssetHub(cc) => (Network::PolkadotAssetHub, cc.encode()),
Expand Down Expand Up @@ -260,6 +276,36 @@
}
}

// Strip the outer enum and return a Kusama People `RuntimeCall`.
#[allow(dead_code)]
pub(super) fn get_kusama_people_call(&self) -> Result<KusamaPeopleRuntimeCall, &'static str> {
match &self.network {
Network::KusamaPeople => {
let bytes = &self.encoded;
Ok(<KusamaPeopleRuntimeCall as parity_scale_codec::Decode>::decode(&mut &bytes[..])
.unwrap())
},
_ => Err("not a kusama people call"),
}
}

// Strip the outer enum and return a Kusama Coretime `RuntimeCall`.
#[allow(dead_code)]
pub(super) fn get_kusama_coretime_call(
&self,
) -> Result<KusamaCoretimeRuntimeCall, &'static str> {
match &self.network {
Network::KusamaCoretime => {
let bytes = &self.encoded;
Ok(<KusamaCoretimeRuntimeCall as parity_scale_codec::Decode>::decode(
&mut &bytes[..],
)
.unwrap())
},
_ => Err("not a kusama coretime call"),
}
}

// Strip the outer enum and return a Polkadot Relay `RuntimeCall`.
pub(super) fn get_polkadot_call(&self) -> Result<PolkadotRuntimeCall, &'static str> {
match &self.network {
Expand Down Expand Up @@ -333,6 +379,8 @@
Network::Kusama => "wss://kusama-rpc.dwellir.com:443",
Network::KusamaAssetHub => "wss://kusama-asset-hub-rpc.polkadot.io:443",
Network::KusamaBridgeHub => "wss://kusama-bridge-hub-rpc.polkadot.io:443",
Network::KusamaPeople => "wss://kusama-people-rpc.polkadot.io:443",
Network::KusamaCoretime => "wss://kusama-coretime-rpc.polkadot.io:443",
Network::KusamaEncointer => "wss://kusama.api.encointer.org:443",
Network::Polkadot => "wss://polkadot-rpc.dwellir.com:443",
Network::PolkadotAssetHub => "wss://polkadot-asset-hub-rpc.polkadot.io:443",
Expand Down
Loading