::SourceChain>>,
- SubstrateFinalityProof,
-);
-/// Vector of mandatory headers and their finality proofs.
-type HeadersAndProofs
= Vec>;
-
-/// Returns best finalized source header number known to the bridge GRANDPA pallet at the target
-/// chain.
-///
-/// This function works even if bridge GRANDPA pallet at the target chain is halted.
-async fn best_source_block_number_at_target(
- target_client: &Client,
-) -> anyhow::Result> {
- Ok(read_client_state::(
- target_client,
- None,
- P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD,
- )
- .await?
- .best_finalized_peer_at_best_self
- .0)
-}
-
-/// Verify that the bridge GRANDPA pallet at the target chain is either halted, or operational.
-async fn ensure_pallet_operating_mode(
- finality_target: &SubstrateFinalityTarget,
- operational: bool,
-) -> anyhow::Result<()> {
- match (operational, finality_target.ensure_pallet_active().await) {
- (true, Ok(())) => Ok(()),
- (false, Err(SubstrateError::BridgePalletIsHalted)) => Ok(()),
- _ => Err(anyhow::format_err!(
- "Bridge GRANDPA pallet at {} is expected to be {}, but it isn't",
- P::TargetChain::NAME,
- if operational { "operational" } else { "halted" },
- )),
- }
-}
-
-/// Returns list of all mandatory headers in given range.
-async fn find_mandatory_headers_in_range(
- finality_source: &SubstrateFinalitySource,
- range: (BlockNumberOf, BlockNumberOf),
-) -> anyhow::Result> {
- let mut mandatory_headers = Vec::new();
- let mut current = range.0;
- while current <= range.1 {
- let (header, proof) = finality_source.header_and_finality_proof(current).await?;
- if header.is_mandatory() {
- match proof {
- Some(proof) => mandatory_headers.push((header, proof)),
- None =>
- return Err(anyhow::format_err!(
- "Missing GRANDPA justification for {} header {}",
- P::SourceChain::NAME,
- current,
- )),
- }
- }
-
- current += One::one();
- }
-
- Ok(mandatory_headers)
-}
-
-/// Given list of mandatory headers, prepare batches of headers, so that every batch may fit into
-/// single transaction.
-fn make_mandatory_headers_batches<
- P: SubstrateFinalitySyncPipeline,
- F: Fn(&HeaderAndProof) -> Weight,
->(
- mut headers_to_submit: HeadersAndProofs
,
- submit_header_weight: F,
-) -> Vec> {
- // now that we have all mandatory headers, let's prepare transactions
- // (let's keep all our transactions below 2/3 of max tx size/weight to have some reserve
- // for utility overhead + for halting transaction)
- let maximal_tx_size = P::TargetChain::max_extrinsic_size() * 2 / 3;
- let maximal_tx_weight = P::TargetChain::max_extrinsic_weight() * 2 / 3;
- let mut current_batch_size: u32 = 0;
- let mut current_batch_weight: Weight = 0;
- let mut batches = Vec::new();
- let mut i = 0;
- while i < headers_to_submit.len() {
- let header_and_proof_size =
- headers_to_submit[i].0.encode().len() + headers_to_submit[i].1.encode().len();
- let header_and_proof_weight = submit_header_weight(&headers_to_submit[i]);
-
- let new_batch_size = current_batch_size
- .saturating_add(u32::try_from(header_and_proof_size).unwrap_or(u32::MAX));
- let new_batch_weight = current_batch_weight.saturating_add(header_and_proof_weight);
-
- let is_exceeding_tx_size = new_batch_size > maximal_tx_size;
- let is_exceeding_tx_weight = new_batch_weight > maximal_tx_weight;
- let is_new_batch_required = is_exceeding_tx_size || is_exceeding_tx_weight;
-
- if is_new_batch_required {
- // if `i` is 0 and we're here, it is a weird situation: even single header submission is
- // larger than we've planned for a bunch of headers. Let's be optimistic and hope that
- // the tx will still succeed.
- let spit_off_index = std::cmp::max(i, 1);
- let remaining_headers_to_submit = headers_to_submit.split_off(spit_off_index);
- batches.push(headers_to_submit);
-
- // we'll reiterate the same header again => so set `current_*` to zero
- current_batch_size = 0;
- current_batch_weight = 0;
- headers_to_submit = remaining_headers_to_submit;
- i = 0;
- } else {
- current_batch_size = new_batch_size;
- current_batch_weight = new_batch_weight;
- i += 1;
- }
- }
- if !headers_to_submit.is_empty() {
- batches.push(headers_to_submit);
- }
- batches
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use crate::cli::{RuntimeVersionType, SourceRuntimeVersionParams, TargetRuntimeVersionParams};
- use bp_header_chain::justification::GrandpaJustification;
- use bp_test_utils::{make_default_justification, test_header};
- use relay_polkadot_client::Polkadot;
- use sp_runtime::{traits::Header as _, DigestItem};
-
- fn make_header_and_justification(
- i: u32,
- size: u32,
- ) -> (SyncHeader, GrandpaJustification) {
- let size = size as usize;
- let mut header: bp_kusama::Header = test_header(i);
- let justification = make_default_justification(&header);
- let actual_size = header.encode().len() + justification.encode().len();
- // additional digest means some additional bytes, so let's decrease `additional_digest_size`
- // a bit
- let additional_digest_size = size.saturating_sub(actual_size).saturating_sub(100);
- header.digest_mut().push(DigestItem::Other(vec![0u8; additional_digest_size]));
- let justification = make_default_justification(&header);
- println!("{} {}", size, header.encode().len() + justification.encode().len());
- (header.into(), justification)
- }
-
- #[test]
- fn should_parse_cli_options() {
- // when
- let res = ReinitBridge::from_iter(vec![
- "reinit-bridge",
- "kusama-to-polkadot",
- "--source-host",
- "127.0.0.1",
- "--source-port",
- "42",
- "--target-host",
- "127.0.0.1",
- "--target-port",
- "43",
- "--target-signer",
- "//Alice",
- ]);
-
- // then
- assert_eq!(
- res,
- ReinitBridge {
- bridge: ReinitBridgeName::KusamaToPolkadot,
- source: SourceConnectionParams {
- source_host: "127.0.0.1".into(),
- source_port: 42,
- source_secure: false,
- source_runtime_version: SourceRuntimeVersionParams {
- source_version_mode: RuntimeVersionType::Bundle,
- source_spec_version: None,
- source_transaction_version: None,
- }
- },
- target: TargetConnectionParams {
- target_host: "127.0.0.1".into(),
- target_port: 43,
- target_secure: false,
- target_runtime_version: TargetRuntimeVersionParams {
- target_version_mode: RuntimeVersionType::Bundle,
- target_spec_version: None,
- target_transaction_version: None,
- }
- },
- target_sign: TargetSigningParams {
- target_signer: Some("//Alice".into()),
- target_signer_password: None,
- target_signer_file: None,
- target_signer_password_file: None,
- target_transactions_mortality: None,
- },
- }
- );
- }
-
- #[test]
- fn make_mandatory_headers_batches_and_empty_headers() {
- let batches = make_mandatory_headers_batches::(vec![], |_| 0);
- assert!(batches.is_empty());
- }
-
- #[test]
- fn make_mandatory_headers_batches_with_single_batch() {
- let headers_to_submit =
- vec![make_header_and_justification(10, Polkadot::max_extrinsic_size() / 3)];
- let batches =
- make_mandatory_headers_batches::(headers_to_submit, |_| 0);
- assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![1],);
- }
-
- #[test]
- fn make_mandatory_headers_batches_group_by_size() {
- let headers_to_submit = vec![
- make_header_and_justification(10, Polkadot::max_extrinsic_size() / 3),
- make_header_and_justification(20, Polkadot::max_extrinsic_size() / 3),
- make_header_and_justification(30, Polkadot::max_extrinsic_size() * 2 / 3),
- make_header_and_justification(40, Polkadot::max_extrinsic_size()),
- ];
- let batches =
- make_mandatory_headers_batches::(headers_to_submit, |_| 0);
- assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![2, 1, 1],);
- }
-
- #[test]
- fn make_mandatory_headers_batches_group_by_weight() {
- let headers_to_submit = vec![
- make_header_and_justification(10, 0),
- make_header_and_justification(20, 0),
- make_header_and_justification(30, 0),
- make_header_and_justification(40, 0),
- ];
- let batches = make_mandatory_headers_batches::(
- headers_to_submit,
- |(header, _)| {
- if header.number() == 10 || header.number() == 20 {
- Polkadot::max_extrinsic_weight() / 3
- } else if header.number() == 30 {
- Polkadot::max_extrinsic_weight() * 2 / 3
- } else {
- Polkadot::max_extrinsic_weight()
- }
- },
- );
- assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![2, 1, 1],);
- }
-}
diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers.rs b/bridges/relays/bin-substrate/src/cli/relay_headers.rs
index 4ad43c3c24..25bb3440c6 100644
--- a/bridges/relays/bin-substrate/src/cli/relay_headers.rs
+++ b/bridges/relays/bin-substrate/src/cli/relay_headers.rs
@@ -25,9 +25,8 @@ use substrate_relay_helper::finality::SubstrateFinalitySyncPipeline;
use crate::cli::{
bridge::{
- CliBridge, KusamaToPolkadotCliBridge, MillauToRialtoCliBridge,
- MillauToRialtoParachainCliBridge, PolkadotToKusamaCliBridge, RialtoToMillauCliBridge,
- RococoToWococoCliBridge, WestendToMillauCliBridge, WococoToRococoCliBridge,
+ CliBridge, MillauToRialtoCliBridge, MillauToRialtoParachainCliBridge,
+ RialtoToMillauCliBridge, WestendToMillauCliBridge,
},
PrometheusParams, SourceConnectionParams, TargetConnectionParams, TargetSigningParams,
};
@@ -59,10 +58,6 @@ pub enum RelayHeadersBridge {
MillauToRialto,
RialtoToMillau,
WestendToMillau,
- RococoToWococo,
- WococoToRococo,
- KusamaToPolkadot,
- PolkadotToKusama,
MillauToRialtoParachain,
}
@@ -106,10 +101,6 @@ where
impl HeadersRelayer for MillauToRialtoCliBridge {}
impl HeadersRelayer for RialtoToMillauCliBridge {}
impl HeadersRelayer for WestendToMillauCliBridge {}
-impl HeadersRelayer for RococoToWococoCliBridge {}
-impl HeadersRelayer for WococoToRococoCliBridge {}
-impl HeadersRelayer for KusamaToPolkadotCliBridge {}
-impl HeadersRelayer for PolkadotToKusamaCliBridge {}
impl HeadersRelayer for MillauToRialtoParachainCliBridge {}
impl RelayHeaders {
@@ -119,10 +110,6 @@ impl RelayHeaders {
RelayHeadersBridge::MillauToRialto => MillauToRialtoCliBridge::relay_headers(self),
RelayHeadersBridge::RialtoToMillau => RialtoToMillauCliBridge::relay_headers(self),
RelayHeadersBridge::WestendToMillau => WestendToMillauCliBridge::relay_headers(self),
- RelayHeadersBridge::RococoToWococo => RococoToWococoCliBridge::relay_headers(self),
- RelayHeadersBridge::WococoToRococo => WococoToRococoCliBridge::relay_headers(self),
- RelayHeadersBridge::KusamaToPolkadot => KusamaToPolkadotCliBridge::relay_headers(self),
- RelayHeadersBridge::PolkadotToKusama => PolkadotToKusamaCliBridge::relay_headers(self),
RelayHeadersBridge::MillauToRialtoParachain =>
MillauToRialtoParachainCliBridge::relay_headers(self),
}
diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs
index 51c863080f..3fb84caed2 100644
--- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs
+++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages.rs
@@ -28,15 +28,14 @@ use strum::VariantNames;
use async_std::sync::Arc;
use bp_polkadot_core::parachains::ParaHash;
-use codec::Encode;
use messages_relay::relay_strategy::MixStrategy;
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
use relay_substrate_client::{
- AccountIdOf, AccountKeyPairOf, BlockNumberOf, CallOf, Chain, ChainRuntimeVersion, Client,
- SignParam, TransactionSignScheme, UnsignedTransaction,
+ AccountIdOf, AccountKeyPairOf, BlockNumberOf, Chain, ChainRuntimeVersion, Client,
+ TransactionSignScheme,
};
use relay_utils::metrics::MetricsParams;
-use sp_core::{Bytes, Pair};
+use sp_core::Pair;
use substrate_relay_helper::{
finality::SubstrateFinalitySyncPipeline,
messages_lane::MessagesRelayParams,
@@ -68,8 +67,6 @@ pub(crate) const CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO: f64 = 0.05;
pub enum RelayHeadersAndMessages {
MillauRialto(MillauRialtoHeadersAndMessages),
MillauRialtoParachain(MillauRialtoParachainHeadersAndMessages),
- RococoWococo(RococoWococoHeadersAndMessages),
- KusamaPolkadot(KusamaPolkadotHeadersAndMessages),
}
/// Parameters that have the same names across all bridges.
@@ -309,168 +306,6 @@ macro_rules! select_bridge {
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
}
- $generic
- },
- RelayHeadersAndMessages::RococoWococo(_) => {
- type Params = RococoWococoHeadersAndMessages;
-
- type Left = relay_rococo_client::Rococo;
- type Right = relay_wococo_client::Wococo;
-
- type LeftAccountIdConverter = bp_rococo::AccountIdConverter;
- type RightAccountIdConverter = bp_wococo::AccountIdConverter;
-
- use crate::chains::{
- rococo_messages_to_wococo::RococoMessagesToWococo as LeftToRightMessageLane,
- wococo_messages_to_rococo::WococoMessagesToRococo as RightToLeftMessageLane,
- };
-
- async fn start_on_demand_relays(
- params: &Params,
- left_client: Client,
- right_client: Client,
- at_left_relay_accounts: &mut Vec>>,
- at_right_relay_accounts: &mut Vec>>,
- ) -> anyhow::Result<(
- Arc>>,
- Arc>>,
- )> {
- start_on_demand_relay_to_relay::<
- Left,
- Right,
- crate::chains::rococo_headers_to_wococo::RococoFinalityToWococo,
- crate::chains::wococo_headers_to_rococo::WococoFinalityToRococo,
- >(
- left_client,
- right_client,
- params.left_headers_to_right_sign_override.transaction_params_or::(¶ms.right_sign)?,
- params.right_headers_to_left_sign_override.transaction_params_or::(¶ms.left_sign)?,
- params.shared.only_mandatory_headers,
- params.shared.only_mandatory_headers,
- params.left.can_start_version_guard(),
- params.right.can_start_version_guard(),
- at_left_relay_accounts,
- at_right_relay_accounts,
- ).await
- }
-
- async fn left_create_account(
- left_client: Client,
- left_sign: ::AccountKeyPair,
- account_id: AccountIdOf,
- ) -> anyhow::Result<()> {
- submit_signed_extrinsic(
- left_client,
- left_sign,
- relay_rococo_client::runtime::Call::Balances(
- relay_rococo_client::runtime::BalancesCall::transfer(
- bp_rococo::AccountAddress::Id(account_id),
- bp_rococo::EXISTENTIAL_DEPOSIT.into(),
- ),
- ),
- )
- .await
- }
-
- async fn right_create_account(
- right_client: Client,
- right_sign: ::AccountKeyPair,
- account_id: AccountIdOf,
- ) -> anyhow::Result<()> {
- submit_signed_extrinsic(
- right_client,
- right_sign,
- relay_wococo_client::runtime::Call::Balances(
- relay_wococo_client::runtime::BalancesCall::transfer(
- bp_wococo::AccountAddress::Id(account_id),
- bp_wococo::EXISTENTIAL_DEPOSIT.into(),
- ),
- ),
- )
- .await
- }
-
- $generic
- },
- RelayHeadersAndMessages::KusamaPolkadot(_) => {
- type Params = KusamaPolkadotHeadersAndMessages;
-
- type Left = relay_kusama_client::Kusama;
- type Right = relay_polkadot_client::Polkadot;
-
- type LeftAccountIdConverter = bp_kusama::AccountIdConverter;
- type RightAccountIdConverter = bp_polkadot::AccountIdConverter;
-
- use crate::chains::{
- kusama_messages_to_polkadot::KusamaMessagesToPolkadot as LeftToRightMessageLane,
- polkadot_messages_to_kusama::PolkadotMessagesToKusama as RightToLeftMessageLane,
- };
-
- async fn start_on_demand_relays(
- params: &Params,
- left_client: Client,
- right_client: Client,
- at_left_relay_accounts: &mut Vec>>,
- at_right_relay_accounts: &mut Vec>>,
- ) -> anyhow::Result<(
- Arc>>,
- Arc>>,
- )> {
- start_on_demand_relay_to_relay::<
- Left,
- Right,
- crate::chains::kusama_headers_to_polkadot::KusamaFinalityToPolkadot,
- crate::chains::polkadot_headers_to_kusama::PolkadotFinalityToKusama,
- >(
- left_client,
- right_client,
- params.left_headers_to_right_sign_override.transaction_params_or::(¶ms.right_sign)?,
- params.right_headers_to_left_sign_override.transaction_params_or::(¶ms.left_sign)?,
- params.shared.only_mandatory_headers,
- params.shared.only_mandatory_headers,
- params.left.can_start_version_guard(),
- params.right.can_start_version_guard(),
- at_left_relay_accounts,
- at_right_relay_accounts,
- ).await
- }
-
- async fn left_create_account(
- left_client: Client,
- left_sign: ::AccountKeyPair,
- account_id: AccountIdOf,
- ) -> anyhow::Result<()> {
- submit_signed_extrinsic(
- left_client,
- left_sign,
- relay_kusama_client::runtime::Call::Balances(
- relay_kusama_client::runtime::BalancesCall::transfer(
- bp_kusama::AccountAddress::Id(account_id),
- bp_kusama::EXISTENTIAL_DEPOSIT.into(),
- ),
- ),
- )
- .await
- }
-
- async fn right_create_account(
- right_client: Client,
- right_sign: ::AccountKeyPair,
- account_id: AccountIdOf,
- ) -> anyhow::Result<()> {
- submit_signed_extrinsic(
- right_client,
- right_sign,
- relay_polkadot_client::runtime::Call::Balances(
- relay_polkadot_client::runtime::BalancesCall::transfer(
- bp_polkadot::AccountAddress::Id(account_id),
- bp_polkadot::EXISTENTIAL_DEPOSIT.into(),
- ),
- ),
- )
- .await
- }
-
$generic
},
}
@@ -481,24 +316,14 @@ macro_rules! select_bridge {
declare_chain_options!(Millau, millau);
declare_chain_options!(Rialto, rialto);
declare_chain_options!(RialtoParachain, rialto_parachain);
-declare_chain_options!(Rococo, rococo);
-declare_chain_options!(Wococo, wococo);
-declare_chain_options!(Kusama, kusama);
-declare_chain_options!(Polkadot, polkadot);
// Means to override signers of different layer transactions.
declare_chain_options!(MillauHeadersToRialto, millau_headers_to_rialto);
declare_chain_options!(MillauHeadersToRialtoParachain, millau_headers_to_rialto_parachain);
declare_chain_options!(RialtoHeadersToMillau, rialto_headers_to_millau);
declare_chain_options!(RialtoParachainsToMillau, rialto_parachains_to_millau);
-declare_chain_options!(WococoHeadersToRococo, wococo_headers_to_rococo);
-declare_chain_options!(RococoHeadersToWococo, rococo_headers_to_wococo);
-declare_chain_options!(KusamaHeadersToPolkadot, kusama_headers_to_polkadot);
-declare_chain_options!(PolkadotHeadersToKusama, polkadot_headers_to_kusama);
// All supported bridges.
declare_bridge_options!(Millau, Rialto);
declare_bridge_options!(Millau, RialtoParachain, Rialto);
-declare_bridge_options!(Rococo, Wococo);
-declare_bridge_options!(Kusama, Polkadot);
impl RelayHeadersAndMessages {
/// Run the command.
@@ -912,37 +737,6 @@ where
Ok((Arc::new(left_to_right_on_demand_headers), Arc::new(right_to_left_on_demand_parachains)))
}
-/// Sign and submit transaction with given call to the chain.
-async fn submit_signed_extrinsic>(
- client: Client,
- sign: C::AccountKeyPair,
- call: CallOf,
-) -> anyhow::Result<()>
-where
- AccountIdOf: From<<::AccountKeyPair as Pair>::Public>,
- CallOf: Send,
-{
- let genesis_hash = *client.genesis_hash();
- let (spec_version, transaction_version) = client.simple_runtime_version().await?;
- client
- .submit_signed_extrinsic(sign.public().into(), move |_, transaction_nonce| {
- Ok(Bytes(
- C::sign_transaction(SignParam {
- spec_version,
- transaction_version,
- genesis_hash,
- signer: sign,
- era: relay_substrate_client::TransactionEra::immortal(),
- unsigned: UnsignedTransaction::new(call.into(), transaction_nonce),
- })?
- .encode(),
- ))
- })
- .await
- .map(drop)
- .map_err(|e| anyhow::format_err!("{}", e))
-}
-
#[cfg(test)]
mod tests {
use super::*;
diff --git a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs b/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs
index f92c035082..62af6afe93 100644
--- a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs
+++ b/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs
@@ -62,8 +62,6 @@ pub struct ResubmitTransactions {
#[strum(serialize_all = "kebab_case")]
pub enum RelayChain {
Millau,
- Kusama,
- Polkadot,
}
/// Strategy to use for priority selection.
@@ -93,18 +91,6 @@ macro_rules! select_bridge {
type Target = relay_millau_client::Millau;
type TargetSign = relay_millau_client::Millau;
- $generic
- },
- RelayChain::Kusama => {
- type Target = relay_kusama_client::Kusama;
- type TargetSign = relay_kusama_client::Kusama;
-
- $generic
- },
- RelayChain::Polkadot => {
- type Target = relay_polkadot_client::Polkadot;
- type TargetSign = relay_polkadot_client::Polkadot;
-
$generic
},
}
diff --git a/bridges/relays/client-kusama/Cargo.toml b/bridges/relays/client-kusama/Cargo.toml
index f6aee9dae2..2efe62d8ec 100644
--- a/bridges/relays/client-kusama/Cargo.toml
+++ b/bridges/relays/client-kusama/Cargo.toml
@@ -6,23 +6,14 @@ edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
-codec = { package = "parity-scale-codec", version = "3.0.0" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
-scale-info = { version = "2.1.1", features = ["derive"] }
# Bridge dependencies
-bp-header-chain = { path = "../../primitives/header-chain" }
bp-kusama = { path = "../../primitives/chain-kusama" }
-bp-messages = { path = "../../primitives/messages" }
-bp-polkadot = { path = "../../primitives/chain-polkadot" }
-bp-polkadot-core = { path = "../../primitives/polkadot-core" }
-bp-runtime = { path = "../../primitives/runtime" }
-bridge-runtime-common = { path = "../../bin/runtime-common" }
# Substrate Dependencies
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs
index 31eb3f40e3..b076da7ab7 100644
--- a/bridges/relays/client-kusama/src/lib.rs
+++ b/bridges/relays/client-kusama/src/lib.rs
@@ -16,19 +16,11 @@
//! Types used to connect to the Kusama chain.
-use bp_messages::MessageNonce;
-use codec::Encode;
use frame_support::weights::Weight;
-use relay_substrate_client::{
- Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
- Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction,
-};
-use sp_core::{storage::StorageKey, Pair};
-use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
+use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
+use sp_core::storage::StorageKey;
use std::time::Duration;
-pub mod runtime;
-
/// Kusama header id.
pub type HeaderId = relay_utils::HeaderId;
@@ -65,7 +57,7 @@ impl Chain for Kusama {
const STORAGE_PROOF_OVERHEAD: u32 = bp_kusama::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = bp_kusama::SignedBlock;
- type Call = crate::runtime::Call;
+ type Call = ();
type WeightToFee = bp_kusama::WeightToFee;
}
@@ -73,80 +65,11 @@ impl ChainWithGrandpa for Kusama {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = bp_kusama::WITH_KUSAMA_GRANDPA_PALLET_NAME;
}
-impl ChainWithMessages for Kusama {
- const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
- bp_kusama::WITH_KUSAMA_MESSAGES_PALLET_NAME;
- const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_kusama::TO_KUSAMA_MESSAGE_DETAILS_METHOD;
- const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_kusama::FROM_KUSAMA_MESSAGE_DETAILS_METHOD;
- const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight =
- bp_kusama::PAY_INBOUND_DISPATCH_FEE_WEIGHT;
- const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
- bp_kusama::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
- const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
- bp_kusama::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
- type WeightInfo = ();
-}
-
impl ChainWithBalances for Kusama {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
StorageKey(bp_kusama::account_info_storage_key(account_id))
}
}
-impl TransactionSignScheme for Kusama {
- type Chain = Kusama;
- type AccountKeyPair = sp_core::sr25519::Pair;
- type SignedTransaction = crate::runtime::UncheckedExtrinsic;
-
- fn sign_transaction(param: SignParam) -> Result {
- let raw_payload = SignedPayload::new(
- param.unsigned.call.clone(),
- bp_kusama::SignedExtensions::new(
- param.spec_version,
- param.transaction_version,
- param.era,
- param.genesis_hash,
- param.unsigned.nonce,
- param.unsigned.tip,
- ),
- )
- .expect("SignedExtension never fails.");
-
- let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
- let signer: sp_runtime::MultiSigner = param.signer.public().into();
- let (call, extra, _) = raw_payload.deconstruct();
-
- Ok(bp_kusama::UncheckedExtrinsic::new_signed(
- call,
- sp_runtime::MultiAddress::Id(signer.into_account()),
- signature.into(),
- extra,
- ))
- }
-
- fn is_signed(tx: &Self::SignedTransaction) -> bool {
- tx.signature.is_some()
- }
-
- fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
- tx.signature
- .as_ref()
- .map(|(address, _, _)| {
- *address == bp_kusama::AccountId::from(*signer.public().as_array_ref()).into()
- })
- .unwrap_or(false)
- }
-
- fn parse_transaction(tx: Self::SignedTransaction) -> Option> {
- let extra = &tx.signature.as_ref()?.2;
- Some(UnsignedTransaction { call: tx.function, nonce: extra.nonce(), tip: extra.tip() })
- }
-}
-
/// Kusama header type used in headers sync.
pub type SyncHeader = relay_substrate_client::SyncHeader;
-
-/// Kusama signing params.
-pub type SigningParams = sp_core::sr25519::Pair;
diff --git a/bridges/relays/client-kusama/src/runtime.rs b/bridges/relays/client-kusama/src/runtime.rs
deleted file mode 100644
index 370486d1b8..0000000000
--- a/bridges/relays/client-kusama/src/runtime.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2019-2021 Parity Technologies (UK) Ltd.
-// This file is part of Parity Bridges Common.
-
-// Parity Bridges Common is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity Bridges Common is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity Bridges Common. If not, see .
-
-//! Types that are specific to the Kusama runtime.
-
-use bp_messages::{LaneId, UnrewardedRelayersState};
-use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike};
-use bp_runtime::Chain;
-use codec::{Compact, Decode, Encode};
-use frame_support::weights::Weight;
-use scale_info::TypeInfo;
-use sp_runtime::FixedU128;
-
-/// Unchecked Kusama extrinsic.
-pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic;
-
-/// Kusama Runtime `Call` enum.
-///
-/// The enum represents a subset of possible `Call`s we can send to Kusama chain.
-/// Ideally this code would be auto-generated from metadata, because we want to
-/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
-///
-/// All entries here (like pretty much in the entire file) must be kept in sync with Kusama
-/// `construct_runtime`, so that we maintain SCALE-compatibility.
-///
-/// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/kusama/src/lib.rs)
-#[allow(clippy::large_enum_variant)]
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum Call {
- /// System pallet.
- #[codec(index = 0)]
- System(SystemCall),
- /// Balances pallet.
- #[codec(index = 4)]
- Balances(BalancesCall),
- /// Utility pallet.
- #[codec(index = 24)]
- Utility(UtilityCall),
- /// Polkadot bridge pallet.
- #[codec(index = 110)]
- BridgePolkadotGrandpa(BridgePolkadotGrandpaCall),
- /// Polkadot messages pallet.
- #[codec(index = 111)]
- BridgePolkadotMessages(BridgePolkadotMessagesCall),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum SystemCall {
- #[codec(index = 1)]
- remark(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BalancesCall {
- #[codec(index = 0)]
- transfer(AccountAddress, Compact),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgePolkadotGrandpaCall {
- #[codec(index = 0)]
- submit_finality_proof(
- Box<::Header>,
- bp_header_chain::justification::GrandpaJustification<::Header>,
- ),
- #[codec(index = 1)]
- initialize(bp_header_chain::InitializationData<::Header>),
- #[codec(index = 3)]
- set_operational(bool),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgePolkadotMessagesCall {
- #[codec(index = 2)]
- update_pallet_parameter(BridgePolkadotMessagesParameter),
- #[codec(index = 3)]
- send_message(LaneId, Vec, bp_kusama::Balance),
- #[codec(index = 5)]
- receive_messages_proof(
- bp_polkadot::AccountId,
- bridge_runtime_common::messages::target::FromBridgedChainMessagesProof,
- u32,
- Weight,
- ),
- #[codec(index = 6)]
- receive_messages_delivery_proof(
- bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof<
- bp_polkadot::Hash,
- >,
- UnrewardedRelayersState,
- ),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum UtilityCall {
- #[codec(index = 2)]
- batch_all(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum BridgePolkadotMessagesParameter {
- #[codec(index = 0)]
- PolkadotToKusamaConversionRate(FixedU128),
-}
-
-impl sp_runtime::traits::Dispatchable for Call {
- type Origin = ();
- type Config = ();
- type Info = ();
- type PostInfo = ();
-
- fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo {
- unimplemented!("The Call is not expected to be dispatched.")
- }
-}
diff --git a/bridges/relays/client-polkadot/Cargo.toml b/bridges/relays/client-polkadot/Cargo.toml
index d52ddd9adf..aefbadfdd1 100644
--- a/bridges/relays/client-polkadot/Cargo.toml
+++ b/bridges/relays/client-polkadot/Cargo.toml
@@ -6,23 +6,14 @@ edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
-codec = { package = "parity-scale-codec", version = "3.0.0" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
-scale-info = { version = "2.1.1", features = ["derive"] }
# Bridge dependencies
-bp-header-chain = { path = "../../primitives/header-chain" }
-bp-kusama = { path = "../../primitives/chain-kusama" }
-bp-messages = { path = "../../primitives/messages" }
bp-polkadot = { path = "../../primitives/chain-polkadot" }
-bp-polkadot-core = { path = "../../primitives/polkadot-core" }
-bp-runtime = { path = "../../primitives/runtime" }
-bridge-runtime-common = { path = "../../bin/runtime-common" }
# Substrate Dependencies
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs
index 35d876f546..9327c76c4e 100644
--- a/bridges/relays/client-polkadot/src/lib.rs
+++ b/bridges/relays/client-polkadot/src/lib.rs
@@ -16,19 +16,11 @@
//! Types used to connect to the Polkadot chain.
-use bp_messages::MessageNonce;
-use codec::Encode;
use frame_support::weights::Weight;
-use relay_substrate_client::{
- Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
- Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction,
-};
-use sp_core::{storage::StorageKey, Pair};
-use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
+use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
+use sp_core::storage::StorageKey;
use std::time::Duration;
-pub mod runtime;
-
/// Polkadot header id.
pub type HeaderId = relay_utils::HeaderId;
@@ -65,7 +57,7 @@ impl Chain for Polkadot {
const STORAGE_PROOF_OVERHEAD: u32 = bp_polkadot::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = bp_polkadot::SignedBlock;
- type Call = crate::runtime::Call;
+ type Call = ();
type WeightToFee = bp_polkadot::WeightToFee;
}
@@ -74,80 +66,11 @@ impl ChainWithGrandpa for Polkadot {
bp_polkadot::WITH_POLKADOT_GRANDPA_PALLET_NAME;
}
-impl ChainWithMessages for Polkadot {
- const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
- bp_polkadot::WITH_POLKADOT_MESSAGES_PALLET_NAME;
- const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_polkadot::TO_POLKADOT_MESSAGE_DETAILS_METHOD;
- const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_polkadot::FROM_POLKADOT_MESSAGE_DETAILS_METHOD;
- const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight =
- bp_polkadot::PAY_INBOUND_DISPATCH_FEE_WEIGHT;
- const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
- bp_polkadot::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
- const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
- bp_polkadot::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
- type WeightInfo = ();
-}
-
impl ChainWithBalances for Polkadot {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
StorageKey(bp_polkadot::account_info_storage_key(account_id))
}
}
-impl TransactionSignScheme for Polkadot {
- type Chain = Polkadot;
- type AccountKeyPair = sp_core::sr25519::Pair;
- type SignedTransaction = crate::runtime::UncheckedExtrinsic;
-
- fn sign_transaction(param: SignParam) -> Result {
- let raw_payload = SignedPayload::new(
- param.unsigned.call.clone(),
- bp_polkadot::SignedExtensions::new(
- param.spec_version,
- param.transaction_version,
- param.era,
- param.genesis_hash,
- param.unsigned.nonce,
- param.unsigned.tip,
- ),
- )
- .expect("SignedExtension never fails.");
-
- let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
- let signer: sp_runtime::MultiSigner = param.signer.public().into();
- let (call, extra, _) = raw_payload.deconstruct();
-
- Ok(bp_polkadot::UncheckedExtrinsic::new_signed(
- call,
- sp_runtime::MultiAddress::Id(signer.into_account()),
- signature.into(),
- extra,
- ))
- }
-
- fn is_signed(tx: &Self::SignedTransaction) -> bool {
- tx.signature.is_some()
- }
-
- fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
- tx.signature
- .as_ref()
- .map(|(address, _, _)| {
- *address == bp_polkadot::AccountId::from(*signer.public().as_array_ref()).into()
- })
- .unwrap_or(false)
- }
-
- fn parse_transaction(tx: Self::SignedTransaction) -> Option> {
- let extra = &tx.signature.as_ref()?.2;
- Some(UnsignedTransaction { call: tx.function, nonce: extra.nonce(), tip: extra.tip() })
- }
-}
-
/// Polkadot header type used in headers sync.
pub type SyncHeader = relay_substrate_client::SyncHeader;
-
-/// Polkadot signing params.
-pub type SigningParams = sp_core::sr25519::Pair;
diff --git a/bridges/relays/client-polkadot/src/runtime.rs b/bridges/relays/client-polkadot/src/runtime.rs
deleted file mode 100644
index 15421d94c6..0000000000
--- a/bridges/relays/client-polkadot/src/runtime.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2019-2021 Parity Technologies (UK) Ltd.
-// This file is part of Parity Bridges Common.
-
-// Parity Bridges Common is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity Bridges Common is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity Bridges Common. If not, see .
-
-//! Types that are specific to the Polkadot runtime.
-
-use bp_messages::{LaneId, UnrewardedRelayersState};
-use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike};
-use bp_runtime::Chain;
-use codec::{Compact, Decode, Encode};
-use frame_support::weights::Weight;
-use scale_info::TypeInfo;
-use sp_runtime::FixedU128;
-
-/// Unchecked Polkadot extrinsic.
-pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic;
-
-/// Polkadot Runtime `Call` enum.
-///
-/// The enum represents a subset of possible `Call`s we can send to Polkadot chain.
-/// Ideally this code would be auto-generated from metadata, because we want to
-/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
-///
-/// All entries here (like pretty much in the entire file) must be kept in sync with Polkadot
-/// `construct_runtime`, so that we maintain SCALE-compatibility.
-///
-/// See: [link](https://github.com/paritytech/kusama/blob/master/runtime/kusam/src/lib.rs)
-#[allow(clippy::large_enum_variant)]
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum Call {
- /// System pallet.
- #[codec(index = 0)]
- System(SystemCall),
- /// Balances pallet.
- #[codec(index = 5)]
- Balances(BalancesCall),
- /// Utility pallet.
- #[codec(index = 26)]
- Utility(UtilityCall),
- /// Kusama bridge pallet.
- #[codec(index = 110)]
- BridgeKusamaGrandpa(BridgeKusamaGrandpaCall),
- /// Kusama messages pallet.
- #[codec(index = 111)]
- BridgeKusamaMessages(BridgeKusamaMessagesCall),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum SystemCall {
- #[codec(index = 1)]
- remark(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BalancesCall {
- #[codec(index = 0)]
- transfer(AccountAddress, Compact),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeKusamaGrandpaCall {
- #[codec(index = 0)]
- submit_finality_proof(
- Box<::Header>,
- bp_header_chain::justification::GrandpaJustification<::Header>,
- ),
- #[codec(index = 1)]
- initialize(bp_header_chain::InitializationData<::Header>),
- #[codec(index = 3)]
- set_operational(bool),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeKusamaMessagesCall {
- #[codec(index = 2)]
- update_pallet_parameter(BridgeKusamaMessagesParameter),
- #[codec(index = 3)]
- send_message(LaneId, Vec, bp_polkadot::Balance),
- #[codec(index = 5)]
- receive_messages_proof(
- bp_kusama::AccountId,
- bridge_runtime_common::messages::target::FromBridgedChainMessagesProof,
- u32,
- Weight,
- ),
- #[codec(index = 6)]
- receive_messages_delivery_proof(
- bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof<
- bp_kusama::Hash,
- >,
- UnrewardedRelayersState,
- ),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum UtilityCall {
- #[codec(index = 2)]
- batch_all(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum BridgeKusamaMessagesParameter {
- #[codec(index = 0)]
- KusamaToPolkadotConversionRate(FixedU128),
-}
-
-impl sp_runtime::traits::Dispatchable for Call {
- type Origin = ();
- type Config = ();
- type Info = ();
- type PostInfo = ();
-
- fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo {
- unimplemented!("The Call is not expected to be dispatched.")
- }
-}
diff --git a/bridges/relays/client-rococo/Cargo.toml b/bridges/relays/client-rococo/Cargo.toml
index e806ad594c..14d3c8ca23 100644
--- a/bridges/relays/client-rococo/Cargo.toml
+++ b/bridges/relays/client-rococo/Cargo.toml
@@ -6,24 +6,14 @@ edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
-codec = { package = "parity-scale-codec", version = "3.0.0" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
-scale-info = { version = "2.1.1", features = ["derive"] }
# Bridge dependencies
-bridge-runtime-common = { path = "../../bin/runtime-common" }
-bp-header-chain = { path = "../../primitives/header-chain" }
-bp-messages = { path = "../../primitives/messages" }
-bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-rococo = { path = "../../primitives/chain-rococo" }
-bp-runtime = { path = "../../primitives/runtime" }
-bp-wococo = { path = "../../primitives/chain-wococo" }
-pallet-bridge-messages = { path = "../../modules/messages" }
# Substrate Dependencies
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
diff --git a/bridges/relays/client-rococo/src/lib.rs b/bridges/relays/client-rococo/src/lib.rs
index 42a22a8f26..c33af96aed 100644
--- a/bridges/relays/client-rococo/src/lib.rs
+++ b/bridges/relays/client-rococo/src/lib.rs
@@ -16,19 +16,11 @@
//! Types used to connect to the Rococo-Substrate chain.
-use bp_messages::MessageNonce;
-use codec::Encode;
use frame_support::weights::Weight;
-use relay_substrate_client::{
- Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
- Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction,
-};
-use sp_core::{storage::StorageKey, Pair};
-use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
+use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
+use sp_core::storage::StorageKey;
use std::time::Duration;
-pub mod runtime;
-
/// Rococo header id.
pub type HeaderId = relay_utils::HeaderId;
@@ -68,7 +60,7 @@ impl Chain for Rococo {
const STORAGE_PROOF_OVERHEAD: u32 = bp_rococo::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = bp_rococo::SignedBlock;
- type Call = crate::runtime::Call;
+ type Call = ();
type WeightToFee = bp_rococo::WeightToFee;
}
@@ -76,77 +68,8 @@ impl ChainWithGrandpa for Rococo {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = bp_rococo::WITH_ROCOCO_GRANDPA_PALLET_NAME;
}
-impl ChainWithMessages for Rococo {
- const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
- bp_rococo::WITH_ROCOCO_MESSAGES_PALLET_NAME;
- const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_rococo::TO_ROCOCO_MESSAGE_DETAILS_METHOD;
- const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_rococo::FROM_ROCOCO_MESSAGE_DETAILS_METHOD;
- const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight =
- bp_rococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT;
- const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
- bp_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
- const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
- bp_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
- type WeightInfo = ();
-}
-
impl ChainWithBalances for Rococo {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
StorageKey(bp_rococo::account_info_storage_key(account_id))
}
}
-
-impl TransactionSignScheme for Rococo {
- type Chain = Rococo;
- type AccountKeyPair = sp_core::sr25519::Pair;
- type SignedTransaction = crate::runtime::UncheckedExtrinsic;
-
- fn sign_transaction(param: SignParam) -> Result {
- let raw_payload = SignedPayload::new(
- param.unsigned.call.clone(),
- bp_rococo::SignedExtensions::new(
- param.spec_version,
- param.transaction_version,
- param.era,
- param.genesis_hash,
- param.unsigned.nonce,
- param.unsigned.tip,
- ),
- )
- .expect("SignedExtension never fails.");
-
- let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
- let signer: sp_runtime::MultiSigner = param.signer.public().into();
- let (call, extra, _) = raw_payload.deconstruct();
-
- Ok(bp_rococo::UncheckedExtrinsic::new_signed(
- call,
- sp_runtime::MultiAddress::Id(signer.into_account()),
- signature.into(),
- extra,
- ))
- }
-
- fn is_signed(tx: &Self::SignedTransaction) -> bool {
- tx.signature.is_some()
- }
-
- fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
- tx.signature
- .as_ref()
- .map(|(address, _, _)| {
- *address == bp_rococo::AccountId::from(*signer.public().as_array_ref()).into()
- })
- .unwrap_or(false)
- }
-
- fn parse_transaction(tx: Self::SignedTransaction) -> Option> {
- let extra = &tx.signature.as_ref()?.2;
- Some(UnsignedTransaction { call: tx.function, nonce: extra.nonce(), tip: extra.tip() })
- }
-}
-
-/// Rococo signing params.
-pub type SigningParams = sp_core::sr25519::Pair;
diff --git a/bridges/relays/client-rococo/src/runtime.rs b/bridges/relays/client-rococo/src/runtime.rs
deleted file mode 100644
index 249e75a709..0000000000
--- a/bridges/relays/client-rococo/src/runtime.rs
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2019-2021 Parity Technologies (UK) Ltd.
-// This file is part of Parity Bridges Common.
-
-// Parity Bridges Common is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity Bridges Common is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity Bridges Common. If not, see .
-
-//! Types that are specific to the Rococo runtime.
-
-use bp_messages::{LaneId, UnrewardedRelayersState};
-use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike};
-use bp_runtime::Chain;
-use codec::{Compact, Decode, Encode};
-use frame_support::weights::Weight;
-use scale_info::TypeInfo;
-
-/// Unchecked Rococo extrinsic.
-pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic;
-
-/// Rococo Runtime `Call` enum.
-///
-/// The enum represents a subset of possible `Call`s we can send to Rococo chain.
-/// Ideally this code would be auto-generated from metadata, because we want to
-/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
-///
-/// All entries here (like pretty much in the entire file) must be kept in sync with Rococo
-/// `construct_runtime`, so that we maintain SCALE-compatibility.
-///
-/// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs)
-#[allow(clippy::large_enum_variant)]
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum Call {
- /// System pallet.
- #[codec(index = 0)]
- System(SystemCall),
- /// Balances pallet.
- #[codec(index = 4)]
- Balances(BalancesCall),
- /// Wococo bridge pallet.
- #[codec(index = 41)]
- BridgeGrandpaWococo(BridgeGrandpaWococoCall),
- /// Wococo messages pallet.
- #[codec(index = 44)]
- BridgeWococoMessages(BridgeWococoMessagesCall),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum SystemCall {
- #[codec(index = 1)]
- remark(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BalancesCall {
- #[codec(index = 0)]
- transfer(AccountAddress, Compact),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeGrandpaWococoCall {
- #[codec(index = 0)]
- submit_finality_proof(
- Box<::Header>,
- bp_header_chain::justification::GrandpaJustification<::Header>,
- ),
- #[codec(index = 1)]
- initialize(bp_header_chain::InitializationData<::Header>),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeWococoMessagesCall {
- #[codec(index = 3)]
- send_message(LaneId, Vec, bp_rococo::Balance),
- #[codec(index = 5)]
- receive_messages_proof(
- bp_wococo::AccountId,
- bridge_runtime_common::messages::target::FromBridgedChainMessagesProof,
- u32,
- Weight,
- ),
- #[codec(index = 6)]
- receive_messages_delivery_proof(
- bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof<
- bp_wococo::Hash,
- >,
- UnrewardedRelayersState,
- ),
-}
-
-impl sp_runtime::traits::Dispatchable for Call {
- type Origin = ();
- type Config = ();
- type Info = ();
- type PostInfo = ();
-
- fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo {
- unimplemented!("The Call is not expected to be dispatched.")
- }
-}
diff --git a/bridges/relays/client-wococo/Cargo.toml b/bridges/relays/client-wococo/Cargo.toml
index b322849d94..5b97694af1 100644
--- a/bridges/relays/client-wococo/Cargo.toml
+++ b/bridges/relays/client-wococo/Cargo.toml
@@ -6,22 +6,13 @@ edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
-codec = { package = "parity-scale-codec", version = "3.0.0" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
-scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
# Bridge dependencies
-bridge-runtime-common = { path = "../../bin/runtime-common" }
-bp-header-chain = { path = "../../primitives/header-chain" }
-bp-messages = { path = "../../primitives/messages" }
-bp-polkadot-core = { path = "../../primitives/polkadot-core" }
-bp-rococo = { path = "../../primitives/chain-rococo" }
-bp-runtime = { path = "../../primitives/runtime" }
+
bp-wococo = { path = "../../primitives/chain-wococo" }
-pallet-bridge-messages = { path = "../../modules/messages" }
# Substrate Dependencies
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
diff --git a/bridges/relays/client-wococo/src/lib.rs b/bridges/relays/client-wococo/src/lib.rs
index 3c96a80b60..06a63e7d2b 100644
--- a/bridges/relays/client-wococo/src/lib.rs
+++ b/bridges/relays/client-wococo/src/lib.rs
@@ -16,19 +16,11 @@
//! Types used to connect to the Wococo-Substrate chain.
-use bp_messages::MessageNonce;
-use codec::Encode;
use frame_support::weights::Weight;
-use relay_substrate_client::{
- Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages,
- Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction,
-};
-use sp_core::{storage::StorageKey, Pair};
-use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
+use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, ChainWithGrandpa};
+use sp_core::storage::StorageKey;
use std::time::Duration;
-pub mod runtime;
-
/// Wococo header id.
pub type HeaderId = relay_utils::HeaderId;
@@ -68,7 +60,7 @@ impl Chain for Wococo {
const STORAGE_PROOF_OVERHEAD: u32 = bp_wococo::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = bp_wococo::SignedBlock;
- type Call = crate::runtime::Call;
+ type Call = ();
type WeightToFee = bp_wococo::WeightToFee;
}
@@ -76,77 +68,8 @@ impl ChainWithGrandpa for Wococo {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = bp_wococo::WITH_WOCOCO_GRANDPA_PALLET_NAME;
}
-impl ChainWithMessages for Wococo {
- const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
- bp_wococo::WITH_WOCOCO_MESSAGES_PALLET_NAME;
- const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_wococo::TO_WOCOCO_MESSAGE_DETAILS_METHOD;
- const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
- bp_wococo::FROM_WOCOCO_MESSAGE_DETAILS_METHOD;
- const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight =
- bp_wococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT;
- const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
- bp_wococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
- const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
- bp_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
- type WeightInfo = ();
-}
-
impl ChainWithBalances for Wococo {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
StorageKey(bp_wococo::account_info_storage_key(account_id))
}
}
-
-impl TransactionSignScheme for Wococo {
- type Chain = Wococo;
- type AccountKeyPair = sp_core::sr25519::Pair;
- type SignedTransaction = crate::runtime::UncheckedExtrinsic;
-
- fn sign_transaction(param: SignParam) -> Result {
- let raw_payload = SignedPayload::new(
- param.unsigned.call.clone(),
- bp_wococo::SignedExtensions::new(
- param.spec_version,
- param.transaction_version,
- param.era,
- param.genesis_hash,
- param.unsigned.nonce,
- param.unsigned.tip,
- ),
- )
- .expect("SignedExtension never fails.");
-
- let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
- let signer: sp_runtime::MultiSigner = param.signer.public().into();
- let (call, extra, _) = raw_payload.deconstruct();
-
- Ok(bp_wococo::UncheckedExtrinsic::new_signed(
- call,
- sp_runtime::MultiAddress::Id(signer.into_account()),
- signature.into(),
- extra,
- ))
- }
-
- fn is_signed(tx: &Self::SignedTransaction) -> bool {
- tx.signature.is_some()
- }
-
- fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
- tx.signature
- .as_ref()
- .map(|(address, _, _)| {
- *address == bp_wococo::AccountId::from(*signer.public().as_array_ref()).into()
- })
- .unwrap_or(false)
- }
-
- fn parse_transaction(tx: Self::SignedTransaction) -> Option> {
- let extra = &tx.signature.as_ref()?.2;
- Some(UnsignedTransaction { call: tx.function, nonce: extra.nonce(), tip: extra.tip() })
- }
-}
-
-/// Wococo signing params.
-pub type SigningParams = sp_core::sr25519::Pair;
diff --git a/bridges/relays/client-wococo/src/runtime.rs b/bridges/relays/client-wococo/src/runtime.rs
deleted file mode 100644
index f7b9c03bf9..0000000000
--- a/bridges/relays/client-wococo/src/runtime.rs
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2019-2021 Parity Technologies (UK) Ltd.
-// This file is part of Parity Bridges Common.
-
-// Parity Bridges Common is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity Bridges Common is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity Bridges Common. If not, see .
-
-//! Types that are specific to the Wococo runtime.
-
-use bp_messages::{LaneId, UnrewardedRelayersState};
-use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike};
-use bp_runtime::Chain;
-use codec::{Compact, Decode, Encode};
-use frame_support::weights::Weight;
-use scale_info::TypeInfo;
-
-/// Unchecked Wococo extrinsic.
-pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic;
-
-/// Wococo Runtime `Call` enum.
-///
-/// The enum represents a subset of possible `Call`s we can send to Rococo chain.
-/// Ideally this code would be auto-generated from metadata, because we want to
-/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
-///
-/// All entries here (like pretty much in the entire file) must be kept in sync with Rococo
-/// `construct_runtime`, so that we maintain SCALE-compatibility.
-///
-/// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs)
-#[allow(clippy::large_enum_variant)]
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-pub enum Call {
- /// System pallet.
- #[codec(index = 0)]
- System(SystemCall),
- /// Balances pallet.
- #[codec(index = 4)]
- Balances(BalancesCall),
- /// Rococo bridge pallet.
- #[codec(index = 40)]
- BridgeGrandpaRococo(BridgeGrandpaRococoCall),
- /// Rococo messages pallet.
- #[codec(index = 43)]
- BridgeRococoMessages(BridgeRococoMessagesCall),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum SystemCall {
- #[codec(index = 1)]
- remark(Vec),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BalancesCall {
- #[codec(index = 0)]
- transfer(AccountAddress, Compact),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeGrandpaRococoCall {
- #[codec(index = 0)]
- submit_finality_proof(
- Box<::Header>,
- bp_header_chain::justification::GrandpaJustification<::Header>,
- ),
- #[codec(index = 1)]
- initialize(bp_header_chain::InitializationData<::Header>),
-}
-
-#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
-#[allow(non_camel_case_types)]
-pub enum BridgeRococoMessagesCall {
- #[codec(index = 3)]
- send_message(LaneId, Vec, bp_rococo::Balance),
- #[codec(index = 5)]
- receive_messages_proof(
- bp_rococo::AccountId,
- bridge_runtime_common::messages::target::FromBridgedChainMessagesProof,
- u32,
- Weight,
- ),
- #[codec(index = 6)]
- receive_messages_delivery_proof(
- bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof<
- bp_rococo::Hash,
- >,
- UnrewardedRelayersState,
- ),
-}
-
-impl sp_runtime::traits::Dispatchable for Call {
- type Origin = ();
- type Config = ();
- type Info = ();
- type PostInfo = ();
-
- fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo {
- unimplemented!("The Call is not expected to be dispatched.")
- }
-}
diff --git a/bridges/relays/lib-substrate-relay/Cargo.toml b/bridges/relays/lib-substrate-relay/Cargo.toml
index a1370744b1..a74ebf3e18 100644
--- a/bridges/relays/lib-substrate-relay/Cargo.toml
+++ b/bridges/relays/lib-substrate-relay/Cargo.toml
@@ -51,6 +51,7 @@ bp-rialto = { path = "../../primitives/chain-rialto" }
bp-rococo = { path = "../../primitives/chain-rococo" }
bp-wococo = { path = "../../primitives/chain-wococo" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
+relay-rialto-client = { path = "../client-rialto" }
relay-rococo-client = { path = "../client-rococo" }
relay-wococo-client = { path = "../client-wococo" }
rialto-runtime = { path = "../../bin/rialto/runtime" }
diff --git a/bridges/relays/lib-substrate-relay/src/messages_target.rs b/bridges/relays/lib-substrate-relay/src/messages_target.rs
index d860fa68a9..b315dfed4b 100644
--- a/bridges/relays/lib-substrate-relay/src/messages_target.rs
+++ b/bridges/relays/lib-substrate-relay/src/messages_target.rs
@@ -522,6 +522,7 @@ fn compute_prepaid_messages_refund(
#[cfg(test)]
mod tests {
use super::*;
+ use relay_rialto_client::Rialto;
use relay_rococo_client::Rococo;
use relay_wococo_client::Wococo;
@@ -581,10 +582,10 @@ mod tests {
#[test]
fn compute_prepaid_messages_refund_returns_sane_results() {
assert!(
- compute_prepaid_messages_refund::(
+ compute_prepaid_messages_refund::(
10,
FixedU128::saturating_from_rational(110, 100),
- ) > (10 * Wococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN).into()
+ ) > (10 * Rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN).into()
);
}
}