Skip to content
Snippets Groups Projects
Unverified Commit 8255dedc authored by Javier Viola's avatar Javier Viola Committed by GitHub
Browse files

[fix] Use node as arg for upgrade (#262)

parent 02eeb166
Branches
No related merge requests found
Pipeline #498119 passed with stage
in 15 minutes and 35 seconds
......@@ -43,20 +43,20 @@ impl Relaychain {
options: RuntimeUpgradeOptions,
) -> Result<(), anyhow::Error> {
// check if the node is valid first
let ws_url = if let Some(node_name) = options.node_name {
let node = if let Some(node_name) = options.node_name {
if let Some(node) = self
.nodes()
.into_iter()
.find(|node| node.name() == node_name)
{
node.ws_uri()
node
} else {
return Err(anyhow!("Node: {} is not part of the relaychain", node_name));
}
} else {
// take the first node
if let Some(node) = self.nodes().first() {
node.ws_uri()
node
} else {
return Err(anyhow!("Relaychain doesn't have any node!"));
}
......@@ -72,7 +72,7 @@ impl Relaychain {
let wasm_data = options.wasm.get_asset().await?;
tx_helper::runtime_upgrade::upgrade(ws_url, &wasm_data, &sudo).await?;
tx_helper::runtime_upgrade::upgrade(node, &wasm_data, &sudo).await?;
Ok(())
}
......
......@@ -2,15 +2,18 @@ use subxt::{dynamic::Value, tx::TxStatus, OnlineClient, SubstrateConfig};
use subxt_signer::sr25519::Keypair;
use tracing::{debug, info};
use crate::network::node::NetworkNode;
pub async fn upgrade(
// options: RuntimeUpgradeOptions,
ws_url: &str,
node: &NetworkNode,
wasm_data: &[u8],
sudo: &Keypair,
// scoped_fs: &ScopedFilesystem<'_, impl FileSystem>,
) -> Result<(), anyhow::Error> {
debug!("Upgrading runtime, using {} as endpoint ", ws_url);
let api = OnlineClient::<SubstrateConfig>::from_url(ws_url).await?;
debug!(
"Upgrading runtime, using node: {} with endpoting {}",
node.name, node.ws_uri
);
let api: OnlineClient<SubstrateConfig> = node.client().await?;
let upgrade = subxt::dynamic::tx(
"System",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment