Skip to content

Commit

Permalink
individual runtime versions (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
joepetrowski authored Feb 1, 2024
1 parent 218d437 commit 1438e81
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ Generate a single call that will upgrade a Relay Chain and all of its system par
Usage: opengov-cli build-upgrade [OPTIONS] --network <NETWORK> --relay-version <RELAY_VERSION>
Options:
-n, --network <NETWORK>
Network on which to submit the referendum. `polkadot` or `kusama`
--relay-version <RELAY_VERSION>
The Fellowship release version. Should be semver and correspond to the release published
--parachain-version <PARACHAIN_VERSION>
Optional. The runtime version of the system parachains to which to upgrade. If not provided, it will use the Relay Chain's version
--filename <FILENAME>
Name of the file to which to write the output. If not provided, a default will be constructed
-h, --help
Print help
-n, --network <NETWORK> Network on which to submit the referendum. `polkadot` or `kusama`
--relay-version <RELAY_VERSION> The Fellowship release version. Should be semver and correspond to the release published
--asset-hub <ASSET_HUB> Optional. The runtime version of Asset Hub to which to upgrade. If not provided, it will use the Relay Chain's version
--bridge-hub <BRIDGE_HUB> Optional. The runtime version of Bridge Hub to which to upgrade. If not provided, it will use the Relay Chain's version
--collectives <COLLECTIVES> Optional. The runtime version of Collectives to which to upgrade. If not provided, it will use the Relay Chain's version
--filename <FILENAME> Name of the file to which to write the output. If not provided, a default will be constructed
-h, --help Print help
```

## Examples
Expand Down
42 changes: 31 additions & 11 deletions src/build_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ pub(crate) struct UpgradeArgs {
#[clap(long = "relay-version")]
relay_version: String,

/// Optional. The runtime version of the system parachains to which to upgrade. If not provided,
/// it will use the Relay Chain's version.
#[clap(long = "parachain-version")]
parachain_version: Option<String>,
/// Optional. The runtime version of Asset Hub to which to upgrade. If not provided, it will use
/// the Relay Chain's version.
#[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.
#[clap(long = "bridge-hub")]
bridge_hub: Option<String>,

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

/// Name of the file to which to write the output. If not provided, a default will be
/// constructed.
Expand Down Expand Up @@ -51,8 +61,18 @@ pub(crate) async fn build_upgrade(prefs: UpgradeArgs) {
fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails {
let mut networks = Vec::new();
let relay_version = String::from(prefs.relay_version.trim_start_matches('v'));
let paras_version = if let Some(user_para_version) = prefs.parachain_version {
String::from(user_para_version.trim_start_matches('v'))
let asset_hub_version = if let Some(v) = prefs.asset_hub {
String::from(v.trim_start_matches('v'))
} else {
relay_version.clone()
};
let bridge_hub_version = if let Some(v) = prefs.bridge_hub {
String::from(v.trim_start_matches('v'))
} else {
relay_version.clone()
};
let collectives_version = if let Some(v) = prefs.collectives {
String::from(v.trim_start_matches('v'))
} else {
relay_version.clone()
};
Expand All @@ -66,15 +86,15 @@ fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails {
});
networks.push(VersionedNetwork {
network: Network::PolkadotAssetHub,
version: paras_version.clone(),
version: asset_hub_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::PolkadotCollectives,
version: paras_version.clone(),
version: collectives_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::PolkadotBridgeHub,
version: paras_version.clone(),
version: bridge_hub_version.clone(),
});
VersionedNetwork { network: Network::Polkadot, version: relay_version.clone() }
},
Expand All @@ -86,11 +106,11 @@ fn parse_inputs(prefs: UpgradeArgs) -> UpgradeDetails {
});
networks.push(VersionedNetwork {
network: Network::KusamaAssetHub,
version: paras_version.clone(),
version: asset_hub_version.clone(),
});
networks.push(VersionedNetwork {
network: Network::KusamaBridgeHub,
version: paras_version.clone(),
version: bridge_hub_version.clone(),
});
VersionedNetwork { network: Network::Kusama, version: relay_version.clone() }
},
Expand Down

0 comments on commit 1438e81

Please sign in to comment.