diff --git a/src/build_upgrade.rs b/src/build_upgrade.rs index 677888b..efe5e59 100644 --- a/src/build_upgrade.rs +++ b/src/build_upgrade.rs @@ -19,8 +19,8 @@ pub(crate) struct UpgradeArgs { #[clap(long = "asset-hub")] asset_hub: Option, - /// 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, @@ -29,6 +29,16 @@ pub(crate) struct UpgradeArgs { #[clap(long = "collectives")] collectives: Option, + /// 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, + + /// 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, + /// Optional. The runtime version of Encointer to which to upgrade. If not provided, it will use /// the Relay Chain's version. #[clap(long = "encointer")] @@ -90,6 +100,16 @@ fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails { } 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" => { @@ -122,13 +142,21 @@ fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails { 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() } }, @@ -198,6 +226,8 @@ async fn download_runtimes(upgrade_details: &UpgradeDetails) { 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", @@ -267,6 +297,42 @@ fn generate_authorize_upgrade_calls(upgrade_details: &UpgradeDetails) -> Vec { + use kusama_people::runtime_types::cumulus_pallet_parachain_system::pallet::Call; + 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; + 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!( @@ -275,7 +341,7 @@ fn generate_authorize_upgrade_calls(upgrade_details: &UpgradeDetails) -> Vec { + 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); }, @@ -456,8 +530,11 @@ async fn construct_polkadot_batch( 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); diff --git a/src/types.rs b/src/types.rs index 0205cb5..ef134d7 100644 --- a/src/types.rs +++ b/src/types.rs @@ -18,6 +18,14 @@ pub(super) use kusama_asset_hub::runtime_types::asset_hub_kusama_runtime::Runtim 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; + +#[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; + #[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; @@ -55,6 +63,8 @@ pub(super) enum Network { Kusama, KusamaAssetHub, KusamaBridgeHub, + KusamaPeople, + KusamaCoretime, KusamaEncointer, Polkadot, PolkadotAssetHub, @@ -68,8 +78,10 @@ impl Network { 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), @@ -135,6 +147,8 @@ pub(super) enum NetworkRuntimeCall { Kusama(KusamaRuntimeCall), KusamaAssetHub(KusamaAssetHubRuntimeCall), KusamaBridgeHub(KusamaBridgeHubRuntimeCall), + KusamaPeople(KusamaPeopleRuntimeCall), + KusamaCoretime(KusamaCoretimeRuntimeCall), KusamaEncointer(KusamaEncointerRuntimeCall), Polkadot(PolkadotRuntimeCall), PolkadotAssetHub(PolkadotAssetHubRuntimeCall), @@ -178,6 +192,8 @@ impl CallInfo { 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()), @@ -260,6 +276,36 @@ impl CallInfo { } } + // Strip the outer enum and return a Kusama People `RuntimeCall`. + #[allow(dead_code)] + pub(super) fn get_kusama_people_call(&self) -> Result { + match &self.network { + Network::KusamaPeople => { + let bytes = &self.encoded; + Ok(::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 { + match &self.network { + Network::KusamaCoretime => { + let bytes = &self.encoded; + Ok(::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 { match &self.network { @@ -333,6 +379,8 @@ impl CallInfo { 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",