mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Set R/WococoBridgeHub bundle runtime version (#1756)
* Define SimpleRuntimeVersion * Set R/WococoBridgeHub bundle runtime version
This commit is contained in:
committed by
Bastian Köcher
parent
70eb076ab2
commit
b4c338f77d
@@ -20,7 +20,7 @@ use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_rialto_parachain::RIALTO_PARACHAIN_ID;
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_millau_client::Millau;
|
||||
use sp_version::RuntimeVersion;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
use xcm::latest::prelude::*;
|
||||
|
||||
impl CliEncodeMessage for Millau {
|
||||
@@ -53,5 +53,6 @@ impl CliEncodeMessage for Millau {
|
||||
}
|
||||
|
||||
impl CliChain for Millau {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION);
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion::from_runtime_version(&millau_runtime::VERSION));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_rialto_client::Rialto;
|
||||
use sp_version::RuntimeVersion;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
use xcm::latest::prelude::*;
|
||||
|
||||
impl CliEncodeMessage for Rialto {
|
||||
@@ -45,5 +45,6 @@ impl CliEncodeMessage for Rialto {
|
||||
}
|
||||
|
||||
impl CliChain for Rialto {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION);
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion::from_runtime_version(&rialto_runtime::VERSION));
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use bridge_runtime_common::CustomNetworkId;
|
||||
use relay_rialto_parachain_client::RialtoParachain;
|
||||
use relay_substrate_client::calls::XcmCall;
|
||||
use sp_version::RuntimeVersion;
|
||||
use relay_substrate_client::{calls::XcmCall, SimpleRuntimeVersion};
|
||||
use xcm::latest::prelude::*;
|
||||
|
||||
impl CliEncodeMessage for RialtoParachain {
|
||||
@@ -45,5 +44,5 @@ impl CliEncodeMessage for RialtoParachain {
|
||||
}
|
||||
|
||||
impl CliChain for RialtoParachain {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
use crate::cli::CliChain;
|
||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
use relay_rococo_client::Rococo;
|
||||
use sp_version::RuntimeVersion;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
|
||||
impl CliChain for Rococo {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
impl CliChain for BridgeHubRococo {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion { spec_version: 9302, transaction_version: 1 });
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl SubstrateFinalitySyncPipeline for RococoFinalityToBridgeHubWococo {
|
||||
if enable_version_guard {
|
||||
relay_substrate_client::guard::abort_on_spec_version_change(
|
||||
target_client.clone(),
|
||||
target_client.simple_runtime_version().await?.0,
|
||||
target_client.simple_runtime_version().await?.spec_version,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
//! Westend chain specification for CLI.
|
||||
|
||||
use crate::cli::CliChain;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
use relay_westend_client::{Westend, Westmint};
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
impl CliChain for Westend {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
impl CliChain for Westmint {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
use crate::cli::CliChain;
|
||||
use relay_bridge_hub_wococo_client::BridgeHubWococo;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
use relay_wococo_client::Wococo;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
impl CliChain for Wococo {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
|
||||
impl CliChain for BridgeHubWococo {
|
||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion { spec_version: 9302, transaction_version: 1 });
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl SubstrateFinalitySyncPipeline for WococoFinalityToBridgeHubRococo {
|
||||
if enable_version_guard {
|
||||
relay_substrate_client::guard::abort_on_spec_version_change(
|
||||
target_client.clone(),
|
||||
target_client.simple_runtime_version().await?.0,
|
||||
target_client.simple_runtime_version().await?.spec_version,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -20,7 +20,7 @@ use structopt::StructOpt;
|
||||
use strum::{EnumString, EnumVariantNames};
|
||||
|
||||
use crate::cli::CliChain;
|
||||
pub use relay_substrate_client::ChainRuntimeVersion;
|
||||
pub use relay_substrate_client::{ChainRuntimeVersion, SimpleRuntimeVersion};
|
||||
use substrate_relay_helper::TransactionParams;
|
||||
|
||||
#[doc = "Runtime version params."]
|
||||
@@ -57,25 +57,24 @@ macro_rules! declare_chain_runtime_version_params_cli_schema {
|
||||
/// Converts self into `ChainRuntimeVersion`.
|
||||
pub fn into_runtime_version(
|
||||
self,
|
||||
bundle_runtime_version: Option<sp_version::RuntimeVersion>,
|
||||
bundle_runtime_version: Option<SimpleRuntimeVersion>,
|
||||
) -> anyhow::Result<ChainRuntimeVersion> {
|
||||
Ok(match self.[<$chain_prefix _version_mode>] {
|
||||
RuntimeVersionType::Auto => ChainRuntimeVersion::Auto,
|
||||
RuntimeVersionType::Custom => {
|
||||
let except_spec_version = self.[<$chain_prefix _spec_version>]
|
||||
let custom_spec_version = self.[<$chain_prefix _spec_version>]
|
||||
.ok_or_else(|| anyhow::Error::msg(format!("The {}-spec-version is required when choose custom mode", stringify!($chain_prefix))))?;
|
||||
let except_transaction_version = self.[<$chain_prefix _transaction_version>]
|
||||
let custom_transaction_version = self.[<$chain_prefix _transaction_version>]
|
||||
.ok_or_else(|| anyhow::Error::msg(format!("The {}-transaction-version is required when choose custom mode", stringify!($chain_prefix))))?;
|
||||
ChainRuntimeVersion::Custom(
|
||||
except_spec_version,
|
||||
except_transaction_version
|
||||
SimpleRuntimeVersion {
|
||||
spec_version: custom_spec_version,
|
||||
transaction_version: custom_transaction_version
|
||||
}
|
||||
)
|
||||
},
|
||||
RuntimeVersionType::Bundle => match bundle_runtime_version {
|
||||
Some(runtime_version) => ChainRuntimeVersion::Custom(
|
||||
runtime_version.spec_version,
|
||||
runtime_version.transaction_version
|
||||
),
|
||||
Some(runtime_version) => ChainRuntimeVersion::Custom(runtime_version),
|
||||
None => ChainRuntimeVersion::Auto
|
||||
},
|
||||
})
|
||||
|
||||
@@ -28,6 +28,7 @@ use structopt::{clap::arg_enum, StructOpt};
|
||||
use strum::{EnumString, EnumVariantNames};
|
||||
|
||||
use bp_messages::LaneId;
|
||||
use relay_substrate_client::SimpleRuntimeVersion;
|
||||
|
||||
pub(crate) mod bridge;
|
||||
pub(crate) mod encode_message;
|
||||
@@ -194,7 +195,7 @@ pub trait CliChain: relay_substrate_client::Chain {
|
||||
/// Current version of the chain runtime, known to relay.
|
||||
///
|
||||
/// can be `None` if relay is not going to submit transactions to that chain.
|
||||
const RUNTIME_VERSION: Option<sp_version::RuntimeVersion>;
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion>;
|
||||
}
|
||||
|
||||
/// Lane id.
|
||||
|
||||
@@ -403,7 +403,7 @@ async fn update_transaction_tip<C: ChainWithTransactions>(
|
||||
})?;
|
||||
let old_tip = unsigned_tx.tip;
|
||||
|
||||
let (spec_version, transaction_version) = client.simple_runtime_version().await?;
|
||||
let runtime_version = client.simple_runtime_version().await?;
|
||||
while current_priority < target_priority {
|
||||
let next_tip = unsigned_tx.tip + tip_step;
|
||||
if next_tip > tip_limit {
|
||||
@@ -425,8 +425,8 @@ async fn update_transaction_tip<C: ChainWithTransactions>(
|
||||
at_block.1,
|
||||
C::sign_transaction(
|
||||
SignParam {
|
||||
spec_version,
|
||||
transaction_version,
|
||||
spec_version: runtime_version.spec_version,
|
||||
transaction_version: runtime_version.transaction_version,
|
||||
genesis_hash: *client.genesis_hash(),
|
||||
signer: transaction_params.signer.clone(),
|
||||
},
|
||||
@@ -449,8 +449,8 @@ async fn update_transaction_tip<C: ChainWithTransactions>(
|
||||
old_tip != unsigned_tx.tip,
|
||||
C::sign_transaction(
|
||||
SignParam {
|
||||
spec_version,
|
||||
transaction_version,
|
||||
spec_version: runtime_version.spec_version,
|
||||
transaction_version: runtime_version.transaction_version,
|
||||
genesis_hash: *client.genesis_hash(),
|
||||
signer: transaction_params.signer.clone(),
|
||||
},
|
||||
|
||||
@@ -75,15 +75,32 @@ pub struct Subscription<T>(pub(crate) Mutex<futures::channel::mpsc::Receiver<Opt
|
||||
/// Opaque GRANDPA authorities set.
|
||||
pub type OpaqueGrandpaAuthoritiesSet = Vec<u8>;
|
||||
|
||||
/// A simple runtime version. It only includes the `spec_version` and `transaction_version`.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct SimpleRuntimeVersion {
|
||||
/// Version of the runtime specification.
|
||||
pub spec_version: u32,
|
||||
/// All existing dispatches are fully compatible when this number doesn't change.
|
||||
pub transaction_version: u32,
|
||||
}
|
||||
|
||||
impl SimpleRuntimeVersion {
|
||||
/// Create a new instance of `SimpleRuntimeVersion` from a `RuntimeVersion`.
|
||||
pub const fn from_runtime_version(runtime_version: &RuntimeVersion) -> Self {
|
||||
Self {
|
||||
spec_version: runtime_version.spec_version,
|
||||
transaction_version: runtime_version.transaction_version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Chain runtime version in client
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ChainRuntimeVersion {
|
||||
/// Auto query from chain.
|
||||
Auto,
|
||||
/// Custom runtime version, defined by user.
|
||||
/// the first is `spec_version`
|
||||
/// the second is `transaction_version`
|
||||
Custom(u32, u32),
|
||||
Custom(SimpleRuntimeVersion),
|
||||
}
|
||||
|
||||
/// Substrate client type.
|
||||
@@ -213,16 +230,14 @@ impl<C: Chain> Client<C> {
|
||||
|
||||
impl<C: Chain> Client<C> {
|
||||
/// Return simple runtime version, only include `spec_version` and `transaction_version`.
|
||||
pub async fn simple_runtime_version(&self) -> Result<(u32, u32)> {
|
||||
let (spec_version, transaction_version) = match self.chain_runtime_version {
|
||||
pub async fn simple_runtime_version(&self) -> Result<SimpleRuntimeVersion> {
|
||||
Ok(match &self.chain_runtime_version {
|
||||
ChainRuntimeVersion::Auto => {
|
||||
let runtime_version = self.runtime_version().await?;
|
||||
(runtime_version.spec_version, runtime_version.transaction_version)
|
||||
SimpleRuntimeVersion::from_runtime_version(&runtime_version)
|
||||
},
|
||||
ChainRuntimeVersion::Custom(spec_version, transaction_version) =>
|
||||
(spec_version, transaction_version),
|
||||
};
|
||||
Ok((spec_version, transaction_version))
|
||||
ChainRuntimeVersion::Custom(version) => *version,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns true if client is connected to at least one peer and is in synced state.
|
||||
@@ -430,10 +445,10 @@ impl<C: Chain> Client<C> {
|
||||
where
|
||||
C: ChainWithTransactions,
|
||||
{
|
||||
let (spec_version, transaction_version) = self.simple_runtime_version().await?;
|
||||
let runtime_version = self.simple_runtime_version().await?;
|
||||
Ok(SignParam::<C> {
|
||||
spec_version,
|
||||
transaction_version,
|
||||
spec_version: runtime_version.spec_version,
|
||||
transaction_version: runtime_version.transaction_version,
|
||||
genesis_hash: self.genesis_hash,
|
||||
signer,
|
||||
})
|
||||
|
||||
@@ -40,8 +40,8 @@ pub use crate::{
|
||||
UnsignedTransaction, UtilityPallet,
|
||||
},
|
||||
client::{
|
||||
ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet, Subscription,
|
||||
ANCIENT_BLOCK_THRESHOLD,
|
||||
ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet, SimpleRuntimeVersion,
|
||||
Subscription, ANCIENT_BLOCK_THRESHOLD,
|
||||
},
|
||||
error::{Error, Result},
|
||||
rpc::{SubstrateBeefyFinalityClient, SubstrateFinalityClient, SubstrateGrandpaFinalityClient},
|
||||
|
||||
@@ -36,7 +36,7 @@ where
|
||||
if enable_version_guard {
|
||||
relay_substrate_client::guard::abort_on_spec_version_change(
|
||||
target_client.clone(),
|
||||
target_client.simple_runtime_version().await?.0,
|
||||
target_client.simple_runtime_version().await?.spec_version,
|
||||
);
|
||||
}
|
||||
relay_substrate_client::guard::abort_when_account_balance_decreased(
|
||||
|
||||
Reference in New Issue
Block a user