Remove chain-specific dependencies from crates that will be used in Cumulus (#1783)

* leave-modules.sh

* remove bp-rialto dependency from bp-relayers

* update leave-modules.sh

* fix Cargo.toml of pallet-bridge-relayers

* update leave-modules.sh

* remove bp-rialto and millau-runtime frombridge-runtime-common Cargo.toml

* update leave-modules.sh

* remove chain dependencies from bridge-runtime-common crate

* fix tests

* cleanup script

* rename script

* kind of success message

* remove leave-modules.sh

* use TargetHeaderChainAdapter and SourceHeaderChainAdapter in our testnets

* update script
This commit is contained in:
Svyatoslav Nikolsky
2023-01-20 11:39:36 +03:00
committed by Bastian Köcher
parent 9465ef6071
commit ec9cd8ddb0
20 changed files with 660 additions and 507 deletions
+4 -4
View File
@@ -473,7 +473,7 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
type InboundRelayer = bp_rialto::AccountId;
type DeliveryPayments = ();
type TargetHeaderChain = crate::rialto_messages::Rialto;
type TargetHeaderChain = crate::rialto_messages::RialtoAsTargetHeaderChain;
type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier;
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
Runtime,
@@ -481,7 +481,7 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
frame_support::traits::ConstU64<10_000>,
>;
type SourceHeaderChain = crate::rialto_messages::Rialto;
type SourceHeaderChain = crate::rialto_messages::RialtoAsSourceHeaderChain;
type MessageDispatch = crate::rialto_messages::FromRialtoMessageDispatch;
type BridgedChainId = RialtoChainId;
}
@@ -504,7 +504,7 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
type InboundRelayer = bp_rialto_parachain::AccountId;
type DeliveryPayments = ();
type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachain;
type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachainAsTargetHeaderChain;
type LaneMessageVerifier = crate::rialto_parachain_messages::ToRialtoParachainMessageVerifier;
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
Runtime,
@@ -512,7 +512,7 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
frame_support::traits::ConstU64<10_000>,
>;
type SourceHeaderChain = crate::rialto_parachain_messages::RialtoParachain;
type SourceHeaderChain = crate::rialto_parachain_messages::RialtoParachainAsSourceHeaderChain;
type MessageDispatch = crate::rialto_parachain_messages::FromRialtoParachainMessageDispatch;
type BridgedChainId = RialtoParachainChainId;
}
@@ -18,13 +18,11 @@
use crate::{RialtoGrandpaInstance, Runtime, RuntimeCall, RuntimeOrigin};
use bp_messages::{
source_chain::TargetHeaderChain,
target_chain::{ProvedMessages, SourceHeaderChain},
InboundLaneData, LaneId, Message, MessageNonce,
};
use bp_messages::{LaneId, MessageNonce};
use bp_runtime::{ChainId, MILLAU_CHAIN_ID, RIALTO_CHAIN_ID};
use bridge_runtime_common::messages::{self, MessageBridge};
use bridge_runtime_common::messages::{
self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge,
};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Default lane that is used to send messages to Rialto.
@@ -110,6 +108,10 @@ impl messages::ThisChainWithMessages for Millau {
/// Rialto chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Rialto;
/// Rialto as source header chain.
pub type RialtoAsSourceHeaderChain = SourceHeaderChainAdapter<WithRialtoMessageBridge>;
/// Rialto as target header chain.
pub type RialtoAsTargetHeaderChain = TargetHeaderChainAdapter<WithRialtoMessageBridge>;
impl messages::UnderlyingChainProvider for Rialto {
type Chain = bp_rialto::Rialto;
@@ -121,43 +123,6 @@ impl messages::BridgedChainWithMessages for Rialto {
}
}
impl TargetHeaderChain<ToRialtoMessagePayload, bp_millau::AccountId> for Rialto {
type Error = &'static str;
// The proof is:
// - hash of the header this proof has been created with;
// - the storage proof or one or several keys;
// - id of the lane we prove state of.
type MessagesDeliveryProof = ToRialtoMessagesDeliveryProof;
fn verify_message(payload: &ToRialtoMessagePayload) -> Result<(), Self::Error> {
messages::source::verify_chain_message::<WithRialtoMessageBridge>(payload)
}
fn verify_messages_delivery_proof(
proof: Self::MessagesDeliveryProof,
) -> Result<(LaneId, InboundLaneData<bp_millau::AccountId>), Self::Error> {
messages::source::verify_messages_delivery_proof::<WithRialtoMessageBridge>(proof)
}
}
impl SourceHeaderChain for Rialto {
type Error = &'static str;
// The proof is:
// - hash of the header this proof has been created with;
// - the storage proof or one or several keys;
// - id of the lane we prove messages for;
// - inclusive range of messages nonces that are proved.
type MessagesProof = FromRialtoMessagesProof;
fn verify_messages_proof(
proof: Self::MessagesProof,
messages_count: u32,
) -> Result<ProvedMessages<Message>, Self::Error> {
messages::target::verify_messages_proof::<WithRialtoMessageBridge>(proof, messages_count)
.map_err(Into::into)
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -18,13 +18,11 @@
use crate::{Runtime, RuntimeCall, RuntimeOrigin, WithRialtoParachainsInstance};
use bp_messages::{
source_chain::TargetHeaderChain,
target_chain::{ProvedMessages, SourceHeaderChain},
InboundLaneData, LaneId, Message, MessageNonce,
};
use bp_messages::{LaneId, MessageNonce};
use bp_runtime::{ChainId, MILLAU_CHAIN_ID, RIALTO_PARACHAIN_CHAIN_ID};
use bridge_runtime_common::messages::{self, MessageBridge};
use bridge_runtime_common::messages::{
self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge,
};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Default lane that is used to send messages to Rialto parachain.
@@ -53,14 +51,6 @@ pub type ToRialtoParachainMessageVerifier =
pub type FromRialtoParachainMessagePayload =
messages::target::FromBridgedChainMessagePayload<RuntimeCall>;
/// Messages proof for RialtoParachain -> Millau messages.
type FromRialtoParachainMessagesProof =
messages::target::FromBridgedChainMessagesProof<bp_rialto_parachain::Hash>;
/// Messages delivery proof for Millau -> RialtoParachain messages.
type ToRialtoParachainMessagesDeliveryProof =
messages::source::FromBridgedChainMessagesDeliveryProof<bp_rialto_parachain::Hash>;
/// Call-dispatch based message dispatch for RialtoParachain -> Millau messages.
pub type FromRialtoParachainMessageDispatch = messages::target::FromBridgedChainMessageDispatch<
WithRialtoParachainMessageBridge,
@@ -115,6 +105,12 @@ impl messages::ThisChainWithMessages for Millau {
/// RialtoParachain chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct RialtoParachain;
/// RialtoParachain as source header chain.
pub type RialtoParachainAsSourceHeaderChain =
SourceHeaderChainAdapter<WithRialtoParachainMessageBridge>;
/// RialtoParachain as target header chain.
pub type RialtoParachainAsTargetHeaderChain =
TargetHeaderChainAdapter<WithRialtoParachainMessageBridge>;
impl messages::UnderlyingChainProvider for RialtoParachain {
type Chain = bp_rialto_parachain::RialtoParachain;
@@ -125,43 +121,3 @@ impl messages::BridgedChainWithMessages for RialtoParachain {
true
}
}
impl TargetHeaderChain<ToRialtoParachainMessagePayload, bp_millau::AccountId> for RialtoParachain {
type Error = &'static str;
// The proof is:
// - hash of the header this proof has been created with;
// - the storage proof or one or several keys;
// - id of the lane we prove state of.
type MessagesDeliveryProof = ToRialtoParachainMessagesDeliveryProof;
fn verify_message(payload: &ToRialtoParachainMessagePayload) -> Result<(), Self::Error> {
messages::source::verify_chain_message::<WithRialtoParachainMessageBridge>(payload)
}
fn verify_messages_delivery_proof(
proof: Self::MessagesDeliveryProof,
) -> Result<(LaneId, InboundLaneData<bp_millau::AccountId>), Self::Error> {
messages::source::verify_messages_delivery_proof::<WithRialtoParachainMessageBridge>(proof)
}
}
impl SourceHeaderChain for RialtoParachain {
type Error = &'static str;
// The proof is:
// - hash of the header this proof has been created with;
// - the storage proof or one or several keys;
// - id of the lane we prove messages for;
// - inclusive range of messages nonces that are proved.
type MessagesProof = FromRialtoParachainMessagesProof;
fn verify_messages_proof(
proof: Self::MessagesProof,
messages_count: u32,
) -> Result<ProvedMessages<Message>, Self::Error> {
messages::target::verify_messages_proof::<WithRialtoParachainMessageBridge>(
proof,
messages_count,
)
.map_err(Into::into)
}
}