mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +00:00
Remove obsolete bridges (#1491)
* remove Rococo<>Wococo bridge mentions * remove Kusama <> Polkadot bridge mentions * fmt * remove unneeded mocked runtimes && trait impls for obsolete bridges * remove unused deps
This commit is contained in:
committed by
Bastian Köcher
parent
46c0400f26
commit
88e95388bb
@@ -1,64 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_messages::LaneId;
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_kusama_client::Kusama;
|
||||
use relay_substrate_client::BalanceOf;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
use crate::cli::{
|
||||
bridge,
|
||||
encode_message::{CliEncodeMessage, RawMessage},
|
||||
CliChain,
|
||||
};
|
||||
|
||||
impl CliEncodeMessage for Kusama {
|
||||
fn encode_send_message_call(
|
||||
lane: LaneId,
|
||||
payload: RawMessage,
|
||||
fee: BalanceOf<Self>,
|
||||
bridge_instance_index: u8,
|
||||
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
|
||||
Ok(match bridge_instance_index {
|
||||
bridge::KUSAMA_TO_POLKADOT_INDEX =>
|
||||
relay_kusama_client::runtime::Call::BridgePolkadotMessages(
|
||||
relay_kusama_client::runtime::BridgePolkadotMessagesCall::send_message(
|
||||
lane, payload, fee,
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
_ => anyhow::bail!(
|
||||
"Unsupported target bridge pallet with instance index: {}",
|
||||
bridge_instance_index
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for Kusama {
|
||||
const RUNTIME_VERSION: RuntimeVersion = bp_kusama::VERSION;
|
||||
|
||||
type KeyPair = sp_core::sr25519::Pair;
|
||||
type MessagePayload = Vec<u8>;
|
||||
|
||||
fn ss58_format() -> u16 {
|
||||
sp_core::crypto::Ss58AddressFormat::from(
|
||||
sp_core::crypto::Ss58AddressFormatRegistry::KusamaAccount,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
@@ -1,129 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Kusama-to-Polkadot headers sync entrypoint.
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_polkadot_client::Polkadot;
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Maximal saturating difference between `balance(now)` and `balance(now-24h)` to treat
|
||||
/// relay as gone wild.
|
||||
///
|
||||
/// Actual value, returned by `maximal_balance_decrease_per_day_is_sane` test is approximately 21
|
||||
/// DOT, and initial value of this constant was rounded up to 30 DOT. But for actual Kusama <>
|
||||
/// Polkadot deployment we'll be using the same account for delivering finality (free for mandatory
|
||||
/// headers) and messages. It means that we can't predict maximal loss. But to protect funds against
|
||||
/// relay/deployment issues, let's limit it so something that is much larger than this estimation -
|
||||
/// e.g. to 100 DOT.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1307
|
||||
pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_polkadot::Balance = 100 * 10_000_000_000;
|
||||
|
||||
/// Description of Kusama -> Polkadot finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct KusamaFinalityToPolkadot;
|
||||
substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!(
|
||||
KusamaFinalityToPolkadot,
|
||||
KusamaFinalityToPolkadotCallBuilder,
|
||||
relay_polkadot_client::runtime::Call::BridgeKusamaGrandpa,
|
||||
relay_polkadot_client::runtime::BridgeKusamaGrandpaCall::submit_finality_proof
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for KusamaFinalityToPolkadot {
|
||||
type SourceChain = relay_kusama_client::Kusama;
|
||||
type TargetChain = Polkadot;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
type SubmitFinalityProofCallBuilder = KusamaFinalityToPolkadotCallBuilder;
|
||||
type TransactionSignScheme = Polkadot;
|
||||
|
||||
async fn start_relay_guards(
|
||||
target_client: &relay_substrate_client::Client<Polkadot>,
|
||||
transaction_params: &TransactionParams<sp_core::sr25519::Pair>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
substrate_relay_helper::finality::guards::start::<Polkadot, Polkadot>(
|
||||
target_client,
|
||||
transaction_params,
|
||||
enable_version_guard,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use pallet_bridge_grandpa::weights::WeightInfo;
|
||||
|
||||
pub fn compute_maximal_balance_decrease_per_day<B, W>(expected_source_headers_per_day: u32) -> B
|
||||
where
|
||||
B: From<u32> + std::ops::Mul<Output = B>,
|
||||
W: WeightToFeePolynomial<Balance = B>,
|
||||
{
|
||||
// we assume that the GRANDPA is not lagging here => ancestry length will be near to 0
|
||||
// (let's round up to 2)
|
||||
const AVG_VOTES_ANCESTRIES_LEN: u32 = 2;
|
||||
// let's assume number of validators is 1024 (more than on any existing well-known chain
|
||||
// atm) => number of precommits is *2/3 + 1
|
||||
const AVG_PRECOMMITS_LEN: u32 = 1024 * 2 / 3 + 1;
|
||||
|
||||
// GRANDPA pallet weights. We're now using Rialto weights everywhere.
|
||||
//
|
||||
// Using Rialto runtime is slightly incorrect, because `DbWeight` of other runtimes may
|
||||
// differ from the `DbWeight` of Rialto runtime. But now (and most probably forever) it is
|
||||
// the same.
|
||||
type GrandpaPalletWeights =
|
||||
pallet_bridge_grandpa::weights::MillauWeight<rialto_runtime::Runtime>;
|
||||
|
||||
// The following formula shall not be treated as super-accurate - guard is to protect from
|
||||
// mad relays, not to protect from over-average loses.
|
||||
|
||||
// increase number of headers a bit
|
||||
let expected_source_headers_per_day = expected_source_headers_per_day * 110 / 100;
|
||||
let single_source_header_submit_call_weight = GrandpaPalletWeights::submit_finality_proof(
|
||||
AVG_VOTES_ANCESTRIES_LEN,
|
||||
AVG_PRECOMMITS_LEN,
|
||||
);
|
||||
// for simplicity - add extra weight for base tx fee + fee that is paid for the tx size +
|
||||
// adjusted fee
|
||||
let single_source_header_submit_tx_weight = single_source_header_submit_call_weight * 3 / 2;
|
||||
let single_source_header_tx_cost = W::calc(&single_source_header_submit_tx_weight);
|
||||
single_source_header_tx_cost * B::from(expected_source_headers_per_day)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maximal_balance_decrease_per_day_is_sane() {
|
||||
// we expect Kusama -> Polkadot relay to be running in mandatory-headers-only mode
|
||||
// => we expect single header for every Kusama session
|
||||
let maximal_balance_decrease = compute_maximal_balance_decrease_per_day::<
|
||||
bp_polkadot::Balance,
|
||||
bp_polkadot::WeightToFee,
|
||||
>(bp_kusama::DAYS / bp_kusama::SESSION_LENGTH + 1);
|
||||
assert!(
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY >= maximal_balance_decrease,
|
||||
"Maximal expected loss per day {} is larger than hardcoded {}",
|
||||
maximal_balance_decrease,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Kusama-to-Polkadot messages sync entrypoint.
|
||||
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
use messages_relay::relay_strategy::MixStrategy;
|
||||
use relay_kusama_client::Kusama;
|
||||
use relay_polkadot_client::Polkadot;
|
||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
||||
|
||||
/// Description of Kusama -> Polkadot messages bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct KusamaMessagesToPolkadot;
|
||||
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!(
|
||||
KusamaMessagesToPolkadot,
|
||||
KusamaMessagesToPolkadotReceiveMessagesProofCallBuilder,
|
||||
relay_polkadot_client::runtime::Call::BridgeKusamaMessages,
|
||||
relay_polkadot_client::runtime::BridgeKusamaMessagesCall::receive_messages_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!(
|
||||
KusamaMessagesToPolkadot,
|
||||
KusamaMessagesToPolkadotReceiveMessagesDeliveryProofCallBuilder,
|
||||
relay_kusama_client::runtime::Call::BridgePolkadotMessages,
|
||||
relay_kusama_client::runtime::BridgePolkadotMessagesCall::receive_messages_delivery_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_update_conversion_rate_call_builder!(
|
||||
Kusama,
|
||||
KusamaMessagesToPolkadotUpdateConversionRateCallBuilder,
|
||||
relay_kusama_client::runtime::Call::BridgePolkadotMessages,
|
||||
relay_kusama_client::runtime::BridgePolkadotMessagesCall::update_pallet_parameter,
|
||||
relay_kusama_client::runtime::BridgePolkadotMessagesParameter::PolkadotToKusamaConversionRate
|
||||
);
|
||||
|
||||
impl SubstrateMessageLane for KusamaMessagesToPolkadot {
|
||||
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME);
|
||||
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME);
|
||||
|
||||
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME);
|
||||
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME);
|
||||
|
||||
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::TRANSACTION_PAYMENT_PALLET_NAME);
|
||||
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::TRANSACTION_PAYMENT_PALLET_NAME);
|
||||
|
||||
type SourceChain = Kusama;
|
||||
type TargetChain = Polkadot;
|
||||
|
||||
type SourceTransactionSignScheme = Kusama;
|
||||
type TargetTransactionSignScheme = Polkadot;
|
||||
|
||||
type ReceiveMessagesProofCallBuilder = KusamaMessagesToPolkadotReceiveMessagesProofCallBuilder;
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
KusamaMessagesToPolkadotReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type TargetToSourceChainConversionRateUpdateBuilder =
|
||||
KusamaMessagesToPolkadotUpdateConversionRateCallBuilder;
|
||||
|
||||
type RelayStrategy = MixStrategy;
|
||||
}
|
||||
@@ -16,33 +16,21 @@
|
||||
|
||||
//! Chain-specific relayer configuration.
|
||||
|
||||
pub mod kusama_headers_to_polkadot;
|
||||
pub mod kusama_messages_to_polkadot;
|
||||
pub mod millau_headers_to_rialto;
|
||||
pub mod millau_headers_to_rialto_parachain;
|
||||
pub mod millau_messages_to_rialto;
|
||||
pub mod millau_messages_to_rialto_parachain;
|
||||
pub mod polkadot_headers_to_kusama;
|
||||
pub mod polkadot_messages_to_kusama;
|
||||
pub mod rialto_headers_to_millau;
|
||||
pub mod rialto_messages_to_millau;
|
||||
pub mod rialto_parachain_messages_to_millau;
|
||||
pub mod rialto_parachains_to_millau;
|
||||
pub mod rococo_headers_to_wococo;
|
||||
pub mod rococo_messages_to_wococo;
|
||||
pub mod westend_headers_to_millau;
|
||||
pub mod westend_parachains_to_millau;
|
||||
pub mod wococo_headers_to_rococo;
|
||||
pub mod wococo_messages_to_rococo;
|
||||
|
||||
mod kusama;
|
||||
mod millau;
|
||||
mod polkadot;
|
||||
mod rialto;
|
||||
mod rialto_parachain;
|
||||
mod rococo;
|
||||
mod westend;
|
||||
mod wococo;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -123,101 +111,3 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod rococo_tests {
|
||||
use bp_header_chain::justification::GrandpaJustification;
|
||||
use codec::Encode;
|
||||
|
||||
#[test]
|
||||
fn scale_compatibility_of_bridges_call() {
|
||||
// given
|
||||
let header = sp_runtime::generic::Header {
|
||||
parent_hash: Default::default(),
|
||||
number: Default::default(),
|
||||
state_root: Default::default(),
|
||||
extrinsics_root: Default::default(),
|
||||
digest: sp_runtime::generic::Digest { logs: vec![] },
|
||||
};
|
||||
|
||||
let justification = GrandpaJustification {
|
||||
round: 0,
|
||||
commit: finality_grandpa::Commit {
|
||||
target_hash: Default::default(),
|
||||
target_number: Default::default(),
|
||||
precommits: vec![],
|
||||
},
|
||||
votes_ancestries: vec![],
|
||||
};
|
||||
|
||||
let actual = relay_rococo_client::runtime::BridgeGrandpaWococoCall::submit_finality_proof(
|
||||
Box::new(header.clone()),
|
||||
justification.clone(),
|
||||
);
|
||||
let expected =
|
||||
millau_runtime::BridgeGrandpaCall::<millau_runtime::Runtime>::submit_finality_proof {
|
||||
finality_target: Box::new(header),
|
||||
justification,
|
||||
};
|
||||
|
||||
// when
|
||||
let actual_encoded = actual.encode();
|
||||
let expected_encoded = expected.encode();
|
||||
|
||||
// then
|
||||
assert_eq!(
|
||||
actual_encoded, expected_encoded,
|
||||
"\n\nEncoding difference.\nGot {:#?} \nExpected: {:#?}",
|
||||
actual, expected
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod westend_tests {
|
||||
use bp_header_chain::justification::GrandpaJustification;
|
||||
use codec::Encode;
|
||||
|
||||
#[test]
|
||||
fn scale_compatibility_of_bridges_call() {
|
||||
// given
|
||||
let header = sp_runtime::generic::Header {
|
||||
parent_hash: Default::default(),
|
||||
number: Default::default(),
|
||||
state_root: Default::default(),
|
||||
extrinsics_root: Default::default(),
|
||||
digest: sp_runtime::generic::Digest { logs: vec![] },
|
||||
};
|
||||
|
||||
let justification = GrandpaJustification {
|
||||
round: 0,
|
||||
commit: finality_grandpa::Commit {
|
||||
target_hash: Default::default(),
|
||||
target_number: Default::default(),
|
||||
precommits: vec![],
|
||||
},
|
||||
votes_ancestries: vec![],
|
||||
};
|
||||
|
||||
let actual = relay_kusama_client::runtime::BridgePolkadotGrandpaCall::submit_finality_proof(
|
||||
Box::new(header.clone()),
|
||||
justification.clone(),
|
||||
);
|
||||
let expected =
|
||||
millau_runtime::BridgeGrandpaCall::<millau_runtime::Runtime>::submit_finality_proof {
|
||||
finality_target: Box::new(header),
|
||||
justification,
|
||||
};
|
||||
|
||||
// when
|
||||
let actual_encoded = actual.encode();
|
||||
let expected_encoded = expected.encode();
|
||||
|
||||
// then
|
||||
assert_eq!(
|
||||
actual_encoded, expected_encoded,
|
||||
"\n\nEncoding difference.\nGot {:#?} \nExpected: {:#?}",
|
||||
actual, expected
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_messages::LaneId;
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_polkadot_client::Polkadot;
|
||||
use relay_substrate_client::BalanceOf;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
use crate::cli::{
|
||||
bridge,
|
||||
encode_message::{CliEncodeMessage, RawMessage},
|
||||
CliChain,
|
||||
};
|
||||
|
||||
impl CliEncodeMessage for Polkadot {
|
||||
fn encode_send_message_call(
|
||||
lane: LaneId,
|
||||
payload: RawMessage,
|
||||
fee: BalanceOf<Self>,
|
||||
bridge_instance_index: u8,
|
||||
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
|
||||
Ok(match bridge_instance_index {
|
||||
bridge::POLKADOT_TO_KUSAMA_INDEX =>
|
||||
relay_polkadot_client::runtime::Call::BridgeKusamaMessages(
|
||||
relay_polkadot_client::runtime::BridgeKusamaMessagesCall::send_message(
|
||||
lane, payload, fee,
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
_ => anyhow::bail!(
|
||||
"Unsupported target bridge pallet with instance index: {}",
|
||||
bridge_instance_index
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for Polkadot {
|
||||
const RUNTIME_VERSION: RuntimeVersion = bp_polkadot::VERSION;
|
||||
|
||||
type KeyPair = sp_core::sr25519::Pair;
|
||||
type MessagePayload = Vec<u8>;
|
||||
|
||||
fn ss58_format() -> u16 {
|
||||
sp_core::crypto::Ss58AddressFormat::from(
|
||||
sp_core::crypto::Ss58AddressFormatRegistry::PolkadotAccount,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
@@ -1,92 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Polkadot-to-Kusama headers sync entrypoint.
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_kusama_client::Kusama;
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Maximal saturating difference between `balance(now)` and `balance(now-24h)` to treat
|
||||
/// relay as gone wild.
|
||||
///
|
||||
/// Actual value, returned by `maximal_balance_decrease_per_day_is_sane` test is approximately 0.001
|
||||
/// KSM, and initial value of this constant was rounded up to 0.1 KSM. But for actual Kusama <>
|
||||
/// Polkadot deployment we'll be using the same account for delivering finality (free for mandatory
|
||||
/// headers) and messages. It means that we can't predict maximal loss. But to protect funds against
|
||||
/// relay/deployment issues, let's limit it so something that is much larger than this estimation -
|
||||
/// e.g. to 2 KSM.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1307
|
||||
pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_kusama::Balance = 2 * 1_000_000_000_000;
|
||||
|
||||
/// Description of Polkadot -> Kusama finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PolkadotFinalityToKusama;
|
||||
substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!(
|
||||
PolkadotFinalityToKusama,
|
||||
PolkadotFinalityToKusamaCallBuilder,
|
||||
relay_kusama_client::runtime::Call::BridgePolkadotGrandpa,
|
||||
relay_kusama_client::runtime::BridgePolkadotGrandpaCall::submit_finality_proof
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for PolkadotFinalityToKusama {
|
||||
type SourceChain = relay_polkadot_client::Polkadot;
|
||||
type TargetChain = Kusama;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
type SubmitFinalityProofCallBuilder = PolkadotFinalityToKusamaCallBuilder;
|
||||
type TransactionSignScheme = Kusama;
|
||||
|
||||
async fn start_relay_guards(
|
||||
target_client: &relay_substrate_client::Client<Kusama>,
|
||||
transaction_params: &TransactionParams<sp_core::sr25519::Pair>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
substrate_relay_helper::finality::guards::start::<Kusama, Kusama>(
|
||||
target_client,
|
||||
transaction_params,
|
||||
enable_version_guard,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::chains::kusama_headers_to_polkadot::tests::compute_maximal_balance_decrease_per_day;
|
||||
|
||||
#[test]
|
||||
fn maximal_balance_decrease_per_day_is_sane() {
|
||||
// we expect Polkadot -> Kusama relay to be running in mandatory-headers-only mode
|
||||
// => we expect single header for every Polkadot session
|
||||
let maximal_balance_decrease = compute_maximal_balance_decrease_per_day::<
|
||||
bp_kusama::Balance,
|
||||
bp_kusama::WeightToFee,
|
||||
>(bp_polkadot::DAYS / bp_polkadot::SESSION_LENGTH + 1);
|
||||
assert!(
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY >= maximal_balance_decrease,
|
||||
"Maximal expected loss per day {} is larger than hardcoded {}",
|
||||
maximal_balance_decrease,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Polkadot-to-Kusama messages sync entrypoint.
|
||||
|
||||
use frame_support::weights::Weight;
|
||||
use messages_relay::relay_strategy::MixStrategy;
|
||||
use relay_kusama_client::Kusama;
|
||||
use relay_polkadot_client::Polkadot;
|
||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
||||
|
||||
/// Description of Polkadot -> Kusama messages bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PolkadotMessagesToKusama;
|
||||
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!(
|
||||
PolkadotMessagesToKusama,
|
||||
PolkadotMessagesToKusamaReceiveMessagesProofCallBuilder,
|
||||
relay_kusama_client::runtime::Call::BridgePolkadotMessages,
|
||||
relay_kusama_client::runtime::BridgePolkadotMessagesCall::receive_messages_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!(
|
||||
PolkadotMessagesToKusama,
|
||||
PolkadotMessagesToKusamaReceiveMessagesDeliveryProofCallBuilder,
|
||||
relay_polkadot_client::runtime::Call::BridgeKusamaMessages,
|
||||
relay_polkadot_client::runtime::BridgeKusamaMessagesCall::receive_messages_delivery_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_update_conversion_rate_call_builder!(
|
||||
Polkadot,
|
||||
PolkadotMessagesToKusamaUpdateConversionRateCallBuilder,
|
||||
relay_polkadot_client::runtime::Call::BridgeKusamaMessages,
|
||||
relay_polkadot_client::runtime::BridgeKusamaMessagesCall::update_pallet_parameter,
|
||||
relay_polkadot_client::runtime::BridgeKusamaMessagesParameter::KusamaToPolkadotConversionRate
|
||||
);
|
||||
|
||||
impl SubstrateMessageLane for PolkadotMessagesToKusama {
|
||||
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME);
|
||||
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME);
|
||||
|
||||
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME);
|
||||
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME);
|
||||
|
||||
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
|
||||
Some(bp_polkadot::TRANSACTION_PAYMENT_PALLET_NAME);
|
||||
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> =
|
||||
Some(bp_kusama::TRANSACTION_PAYMENT_PALLET_NAME);
|
||||
|
||||
type SourceChain = Polkadot;
|
||||
type TargetChain = Kusama;
|
||||
|
||||
type SourceTransactionSignScheme = Polkadot;
|
||||
type TargetTransactionSignScheme = Kusama;
|
||||
|
||||
type ReceiveMessagesProofCallBuilder = PolkadotMessagesToKusamaReceiveMessagesProofCallBuilder;
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
PolkadotMessagesToKusamaReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type TargetToSourceChainConversionRateUpdateBuilder =
|
||||
PolkadotMessagesToKusamaUpdateConversionRateCallBuilder;
|
||||
|
||||
type RelayStrategy = MixStrategy;
|
||||
}
|
||||
@@ -1,60 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_messages::LaneId;
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_rococo_client::Rococo;
|
||||
use relay_substrate_client::BalanceOf;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
use crate::cli::{
|
||||
bridge,
|
||||
encode_message::{CliEncodeMessage, RawMessage},
|
||||
CliChain,
|
||||
};
|
||||
|
||||
impl CliEncodeMessage for Rococo {
|
||||
fn encode_send_message_call(
|
||||
lane: LaneId,
|
||||
payload: RawMessage,
|
||||
fee: BalanceOf<Self>,
|
||||
bridge_instance_index: u8,
|
||||
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
|
||||
Ok(match bridge_instance_index {
|
||||
bridge::ROCOCO_TO_WOCOCO_INDEX =>
|
||||
relay_rococo_client::runtime::Call::BridgeWococoMessages(
|
||||
relay_rococo_client::runtime::BridgeWococoMessagesCall::send_message(
|
||||
lane, payload, fee,
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
_ => anyhow::bail!(
|
||||
"Unsupported target bridge pallet with instance index: {}",
|
||||
bridge_instance_index
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
impl CliChain for Rococo {
|
||||
const RUNTIME_VERSION: RuntimeVersion = bp_rococo::VERSION;
|
||||
|
||||
type KeyPair = sp_core::sr25519::Pair;
|
||||
type MessagePayload = Vec<u8>;
|
||||
|
||||
fn ss58_format() -> u16 {
|
||||
42
|
||||
}
|
||||
}
|
||||
@@ -1,60 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rococo-to-Wococo headers sync entrypoint.
|
||||
|
||||
use crate::chains::wococo_headers_to_rococo::MAXIMAL_BALANCE_DECREASE_PER_DAY;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_wococo_client::Wococo;
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Description of Rococo -> Wococo finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RococoFinalityToWococo;
|
||||
substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!(
|
||||
RococoFinalityToWococo,
|
||||
RococoFinalityToWococoCallBuilder,
|
||||
relay_wococo_client::runtime::Call::BridgeGrandpaRococo,
|
||||
relay_wococo_client::runtime::BridgeGrandpaRococoCall::submit_finality_proof
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for RococoFinalityToWococo {
|
||||
type SourceChain = relay_rococo_client::Rococo;
|
||||
type TargetChain = Wococo;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
type SubmitFinalityProofCallBuilder = RococoFinalityToWococoCallBuilder;
|
||||
type TransactionSignScheme = Wococo;
|
||||
|
||||
async fn start_relay_guards(
|
||||
target_client: &relay_substrate_client::Client<Wococo>,
|
||||
transaction_params: &TransactionParams<sp_core::sr25519::Pair>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
substrate_relay_helper::finality::guards::start::<Wococo, Wococo>(
|
||||
target_client,
|
||||
transaction_params,
|
||||
enable_version_guard,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
@@ -1,63 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rococo-to-Wococo messages sync entrypoint.
|
||||
|
||||
use frame_support::weights::Weight;
|
||||
use messages_relay::relay_strategy::MixStrategy;
|
||||
use relay_rococo_client::Rococo;
|
||||
use relay_wococo_client::Wococo;
|
||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
||||
|
||||
/// Description of Rococo -> Wococo messages bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RococoMessagesToWococo;
|
||||
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!(
|
||||
RococoMessagesToWococo,
|
||||
RococoMessagesToWococoReceiveMessagesProofCallBuilder,
|
||||
relay_wococo_client::runtime::Call::BridgeRococoMessages,
|
||||
relay_wococo_client::runtime::BridgeRococoMessagesCall::receive_messages_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!(
|
||||
RococoMessagesToWococo,
|
||||
RococoMessagesToWococoReceiveMessagesDeliveryProofCallBuilder,
|
||||
relay_rococo_client::runtime::Call::BridgeWococoMessages,
|
||||
relay_rococo_client::runtime::BridgeWococoMessagesCall::receive_messages_delivery_proof
|
||||
);
|
||||
|
||||
impl SubstrateMessageLane for RococoMessagesToWococo {
|
||||
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None;
|
||||
|
||||
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
|
||||
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
|
||||
|
||||
type SourceChain = Rococo;
|
||||
type TargetChain = Wococo;
|
||||
|
||||
type SourceTransactionSignScheme = Rococo;
|
||||
type TargetTransactionSignScheme = Wococo;
|
||||
|
||||
type ReceiveMessagesProofCallBuilder = RococoMessagesToWococoReceiveMessagesProofCallBuilder;
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
RococoMessagesToWococoReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type TargetToSourceChainConversionRateUpdateBuilder = ();
|
||||
|
||||
type RelayStrategy = MixStrategy;
|
||||
}
|
||||
@@ -1,61 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bp_messages::LaneId;
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
use relay_substrate_client::BalanceOf;
|
||||
use relay_wococo_client::Wococo;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
use crate::cli::{
|
||||
bridge,
|
||||
encode_message::{CliEncodeMessage, RawMessage},
|
||||
CliChain,
|
||||
};
|
||||
|
||||
impl CliEncodeMessage for Wococo {
|
||||
fn encode_send_message_call(
|
||||
lane: LaneId,
|
||||
payload: RawMessage,
|
||||
fee: BalanceOf<Self>,
|
||||
bridge_instance_index: u8,
|
||||
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
|
||||
Ok(match bridge_instance_index {
|
||||
bridge::WOCOCO_TO_ROCOCO_INDEX =>
|
||||
relay_wococo_client::runtime::Call::BridgeRococoMessages(
|
||||
relay_wococo_client::runtime::BridgeRococoMessagesCall::send_message(
|
||||
lane, payload, fee,
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
_ => anyhow::bail!(
|
||||
"Unsupported target bridge pallet with instance index: {}",
|
||||
bridge_instance_index
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for Wococo {
|
||||
const RUNTIME_VERSION: RuntimeVersion = bp_wococo::VERSION;
|
||||
|
||||
type KeyPair = sp_core::sr25519::Pair;
|
||||
type MessagePayload = Vec<u8>;
|
||||
|
||||
fn ss58_format() -> u16 {
|
||||
42
|
||||
}
|
||||
}
|
||||
@@ -1,86 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Wococo-to-Rococo headers sync entrypoint.
|
||||
|
||||
use async_trait::async_trait;
|
||||
use relay_rococo_client::Rococo;
|
||||
use substrate_relay_helper::{
|
||||
finality::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline},
|
||||
TransactionParams,
|
||||
};
|
||||
|
||||
/// Maximal saturating difference between `balance(now)` and `balance(now-24h)` to treat
|
||||
/// relay as gone wild.
|
||||
///
|
||||
/// See `maximal_balance_decrease_per_day_is_sane` test for details.
|
||||
/// Note that this is in plancks, so this corresponds to `1500 UNITS`.
|
||||
pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_rococo::Balance = 1_500_000_000_000_000;
|
||||
|
||||
/// Description of Wococo -> Rococo finalized headers bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WococoFinalityToRococo;
|
||||
substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!(
|
||||
WococoFinalityToRococo,
|
||||
WococoFinalityToRococoCallBuilder,
|
||||
relay_rococo_client::runtime::Call::BridgeGrandpaWococo,
|
||||
relay_rococo_client::runtime::BridgeGrandpaWococoCall::submit_finality_proof
|
||||
);
|
||||
|
||||
#[async_trait]
|
||||
impl SubstrateFinalitySyncPipeline for WococoFinalityToRococo {
|
||||
type SourceChain = relay_wococo_client::Wococo;
|
||||
type TargetChain = Rococo;
|
||||
|
||||
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
|
||||
type SubmitFinalityProofCallBuilder = WococoFinalityToRococoCallBuilder;
|
||||
type TransactionSignScheme = Rococo;
|
||||
|
||||
async fn start_relay_guards(
|
||||
target_client: &relay_substrate_client::Client<Rococo>,
|
||||
transaction_params: &TransactionParams<sp_core::sr25519::Pair>,
|
||||
enable_version_guard: bool,
|
||||
) -> relay_substrate_client::Result<()> {
|
||||
substrate_relay_helper::finality::guards::start::<Rococo, Rococo>(
|
||||
target_client,
|
||||
transaction_params,
|
||||
enable_version_guard,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::chains::kusama_headers_to_polkadot::tests::compute_maximal_balance_decrease_per_day;
|
||||
|
||||
#[test]
|
||||
fn maximal_balance_decrease_per_day_is_sane() {
|
||||
// we expect Wococo -> Rococo relay to be running in all-headers mode
|
||||
let maximal_balance_decrease = compute_maximal_balance_decrease_per_day::<
|
||||
bp_kusama::Balance,
|
||||
bp_kusama::WeightToFee,
|
||||
>(bp_wococo::DAYS);
|
||||
assert!(
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY >= maximal_balance_decrease,
|
||||
"Maximal expected loss per day {} is larger than hardcoded {}",
|
||||
maximal_balance_decrease,
|
||||
MAXIMAL_BALANCE_DECREASE_PER_DAY,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Wococo-to-Rococo messages sync entrypoint.
|
||||
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
use messages_relay::relay_strategy::MixStrategy;
|
||||
use relay_rococo_client::Rococo;
|
||||
use relay_wococo_client::Wococo;
|
||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
||||
|
||||
/// Description of Wococo -> Rococo messages bridge.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WococoMessagesToRococo;
|
||||
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!(
|
||||
WococoMessagesToRococo,
|
||||
WococoMessagesToRococoReceiveMessagesProofCallBuilder,
|
||||
relay_rococo_client::runtime::Call::BridgeWococoMessages,
|
||||
relay_rococo_client::runtime::BridgeWococoMessagesCall::receive_messages_proof
|
||||
);
|
||||
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!(
|
||||
WococoMessagesToRococo,
|
||||
WococoMessagesToRococoReceiveMessagesDeliveryProofCallBuilder,
|
||||
relay_wococo_client::runtime::Call::BridgeRococoMessages,
|
||||
relay_wococo_client::runtime::BridgeRococoMessagesCall::receive_messages_delivery_proof
|
||||
);
|
||||
|
||||
impl SubstrateMessageLane for WococoMessagesToRococo {
|
||||
const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None;
|
||||
|
||||
const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None;
|
||||
const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
|
||||
const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None;
|
||||
|
||||
type SourceChain = Wococo;
|
||||
type TargetChain = Rococo;
|
||||
|
||||
type SourceTransactionSignScheme = Wococo;
|
||||
type TargetTransactionSignScheme = Rococo;
|
||||
|
||||
type ReceiveMessagesProofCallBuilder = WococoMessagesToRococoReceiveMessagesProofCallBuilder;
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
WococoMessagesToRococoReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type TargetToSourceChainConversionRateUpdateBuilder = ();
|
||||
|
||||
type RelayStrategy = MixStrategy;
|
||||
}
|
||||
Reference in New Issue
Block a user