From 100d370f712bd79e4088ab4268c8f7b320097dc7 Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Thu, 2 May 2024 06:47:23 +0200 Subject: [PATCH] authorize on relay --- src/build_upgrade.rs | 53 ++++++++++++++++++++++++++++++++++++++------ src/types.rs | 2 ++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/build_upgrade.rs b/src/build_upgrade.rs index 04c9d93..319179c 100644 --- a/src/build_upgrade.rs +++ b/src/build_upgrade.rs @@ -14,6 +14,13 @@ pub(crate) struct UpgradeArgs { #[clap(long = "only")] pub(crate) only: bool, + /// Construct a call that will call `set_code` directly on the Relay Chain. This is generally + /// not recommended, as it involves submitting a large preimage (and therefore paying a large + /// fee). The default (false) uses `authorize_upgrade` instead, which only requires submitting + /// the hash. Anyone can then submit the actual runtime after it has been authorized. + #[clap(long = "set-relay-directly")] + pub(crate) set_relay_directly: bool, + /// The Fellowship release version. Should be semver and correspond to the release published. #[clap(long = "relay-version")] pub(crate) relay_version: Option, @@ -162,12 +169,16 @@ pub(crate) fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails { None => None, }; + let set_relay_directly = prefs.set_relay_directly; + + // Get a version from one of the args. (This still feels dirty.) let version = relay_version.clone().unwrap_or(asset_hub_version.unwrap_or( bridge_hub_version.unwrap_or(encointer_version.unwrap_or( collectives_version.unwrap_or(coretime_version.unwrap_or(String::from("no-version"))), )), )); + // Set up a directory to store information fetched/written during this program. let directory = format!("./upgrade-{}-{}/", &prefs.network, &version); let output_file = if let Some(user_filename) = prefs.filename { format!("{}{}", directory, user_filename) @@ -177,7 +188,15 @@ pub(crate) fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails { make_version_directory(directory.as_str()); - UpgradeDetails { relay, relay_version, networks, directory, output_file, additional } + UpgradeDetails { + relay, + relay_version, + networks, + directory, + output_file, + additional, + set_relay_directly, + } } // Create a directory into which to place runtime blobs and the final call data. @@ -400,9 +419,19 @@ fn generate_relay_upgrade_call(upgrade_details: &UpgradeDetails) -> Option { use polkadot_relay::runtime_types::frame_system::pallet::Call as SystemCall; @@ -415,9 +444,19 @@ fn generate_relay_upgrade_call(upgrade_details: &UpgradeDetails) -> Option panic!("Not a Relay Chain"), } diff --git a/src/types.rs b/src/types.rs index 1de6763..8bf8457 100644 --- a/src/types.rs +++ b/src/types.rs @@ -140,6 +140,8 @@ pub(super) struct UpgradeDetails { pub(super) output_file: String, // An additional call to be enacted in the same batch as the system upgrade. pub(super) additional: Option, + // Call `set_code` directly on the Relay Chain. + pub(super) set_relay_directly: bool, } // A network and the version to which it will upgrade.