Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
BridgeHub fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Nov 16, 2022
1 parent bc1f1d4 commit c6756cd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 93 deletions.
34 changes: 12 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ members = [
"bridges/modules/relayers",
"bridges/modules/shift-session-manager",
"bridges/primitives/messages",
"bridges/primitives/polkadot-core",
"bridges/primitives/runtime",
"bridges/primitives/chain-bridge-hub-rococo",
"bridges/primitives/chain-bridge-hub-wococo",
Expand Down Expand Up @@ -248,6 +247,11 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech//substrat
substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
substrate-wasm-builder = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
try-runtime-cli = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
substrate-test-client = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
pallet-offences-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }
pallet-session-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" }

[patch."https://github.com/paritytech/polkadot"]
kusama-runtime = { git = "https://github.com/paritytech//polkadot", branch = "locked-for-gav-xcm-v3-and-bridges" }
Expand Down
2 changes: 0 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ parachains-common = { path = "../../../../parachains/common", default-features =
bp-bridge-hub-rococo = { path = "../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false }
bp-bridge-hub-wococo = { path = "../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false }
bp-messages = { path = "../../../../bridges/primitives/messages", default-features = false }
bp-polkadot-core = { path = "../../../../bridges/primitives/polkadot-core", default-features = false }
bp-runtime = { path = "../../../../bridges/primitives/runtime", default-features = false }
bp-rococo = { path = "../../../../bridges/primitives/chain-rococo", default-features = false }
bp-wococo = { path = "../../../../bridges/primitives/chain-wococo", default-features = false }
Expand All @@ -91,7 +90,6 @@ default = [
std = [
"bp-bridge-hub-rococo/std",
"bp-bridge-hub-wococo/std",
"bp-polkadot-core/std",
"bp-messages/std",
"bp-runtime/std",
"bp-rococo/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use crate::{
ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler,
XcmBlobHaulerAdapter, XcmRouter,
BridgeParachainWococoInstance, ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance,
XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter,
};
use bp_messages::{
source_chain::TargetHeaderChain,
target_chain::{ProvedMessages, SourceHeaderChain},
InboundLaneData, LaneId, Message, MessageNonce,
};
use bp_polkadot_core::parachains::ParaId;
use bp_runtime::{Chain, ChainId};
use bp_runtime::ChainId;
use bridge_runtime_common::{
messages,
messages::{
target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation,
BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain,
ThisChainWithMessages,
BridgedChain, MessageBridge, MessageTransaction, ThisChain, ThisChainWithMessages,
UnderlyingChainProvider,
},
};
use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug};
Expand Down Expand Up @@ -89,6 +88,11 @@ impl MessageBridge for WithBridgeHubWococoMessageBridge {
bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME;
type ThisChain = BridgeHubRococo;
type BridgedChain = BridgeHubWococo;
type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders<
Runtime,
BridgeParachainWococoInstance,
bp_bridge_hub_wococo::BridgeHubWococo,
>;

fn bridged_balance_to_this_balance(
bridged_balance: bridge_runtime_common::messages::BalanceOf<BridgedChain<Self>>,
Expand All @@ -112,12 +116,8 @@ pub type ToBridgeHubWococoMaximalOutboundPayloadSize =
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubWococo;

impl ChainWithMessages for BridgeHubWococo {
type Hash = bp_bridge_hub_wococo::Hash;
type AccountId = bp_bridge_hub_wococo::AccountId;
type Signer = bp_bridge_hub_wococo::AccountSigner;
type Signature = bp_bridge_hub_wococo::Signature;
type Balance = bp_bridge_hub_wococo::Balance;
impl UnderlyingChainProvider for BridgeHubWococo {
type Chain = bp_bridge_hub_wococo::BridgeHubWococo;
}

impl SourceHeaderChain<crate::Balance> for BridgeHubWococo {
Expand All @@ -128,12 +128,10 @@ impl SourceHeaderChain<crate::Balance> for BridgeHubWococo {
proof: Self::MessagesProof,
messages_count: u32,
) -> Result<ProvedMessages<Message<crate::Balance>>, Self::Error> {
bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::<
bridge_runtime_common::messages::target::verify_messages_proof::<
WithBridgeHubWococoMessageBridge,
bp_bridge_hub_wococo::Header,
crate::Runtime,
crate::BridgeParachainWococoInstance,
>(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof, messages_count)
>(proof, messages_count)
.map_err(Into::into)
}
}

Expand All @@ -149,20 +147,11 @@ impl TargetHeaderChain<XcmAsPlainPayload, crate::AccountId> for BridgeHubWococo
fn verify_messages_delivery_proof(
proof: Self::MessagesDeliveryProof,
) -> Result<(LaneId, InboundLaneData<bp_bridge_hub_rococo::AccountId>), Self::Error> {
messages::source::verify_messages_delivery_proof_from_parachain::<
WithBridgeHubWococoMessageBridge,
bp_bridge_hub_wococo::Header,
crate::Runtime,
crate::BridgeParachainWococoInstance,
>(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof)
messages::source::verify_messages_delivery_proof::<WithBridgeHubWococoMessageBridge>(proof)
}
}

impl messages::BridgedChainWithMessages for BridgeHubWococo {
fn maximal_extrinsic_size() -> u32 {
bp_bridge_hub_wococo::BridgeHubWococo::max_extrinsic_size()
}

fn verify_dispatch_weight(_message_payload: &[u8]) -> bool {
true
}
Expand Down Expand Up @@ -206,19 +195,15 @@ impl messages::BridgedChainWithMessages for BridgeHubWococo {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubRococo;

impl ChainWithMessages for BridgeHubRococo {
type Hash = bp_bridge_hub_rococo::Hash;
type AccountId = bp_bridge_hub_rococo::AccountId;
type Signer = bp_bridge_hub_rococo::AccountSigner;
type Signature = bp_bridge_hub_rococo::Signature;
type Balance = bp_bridge_hub_rococo::Balance;
impl UnderlyingChainProvider for BridgeHubRococo {
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
}

impl ThisChainWithMessages for BridgeHubRococo {
type RuntimeOrigin = crate::RuntimeOrigin;
type RuntimeCall = crate::RuntimeCall;
type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation<
Self::AccountId,
bp_bridge_hub_rococo::AccountId,
{ bp_bridge_hub_rococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() },
{ bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE },
{ bp_bridge_hub_rococo::TX_EXTRA_BYTES },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use crate::{
ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler,
XcmBlobHaulerAdapter, XcmRouter,
BridgeParachainRococoInstance, ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance,
XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter,
};
use bp_messages::{
source_chain::TargetHeaderChain,
target_chain::{ProvedMessages, SourceHeaderChain},
InboundLaneData, LaneId, Message, MessageNonce,
};
use bp_polkadot_core::parachains::ParaId;
use bp_runtime::{Chain, ChainId};
use bp_runtime::ChainId;
use bridge_runtime_common::{
messages,
messages::{
target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation,
BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain,
ThisChainWithMessages,
BridgedChain, MessageBridge, MessageTransaction, ThisChain, ThisChainWithMessages,
UnderlyingChainProvider,
},
};
use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug};
Expand Down Expand Up @@ -89,6 +88,11 @@ impl MessageBridge for WithBridgeHubRococoMessageBridge {
bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME;
type ThisChain = BridgeHubWococo;
type BridgedChain = BridgeHubRococo;
type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders<
Runtime,
BridgeParachainRococoInstance,
bp_bridge_hub_rococo::BridgeHubRococo,
>;

fn bridged_balance_to_this_balance(
bridged_balance: bridge_runtime_common::messages::BalanceOf<BridgedChain<Self>>,
Expand All @@ -112,12 +116,8 @@ pub type ToBridgeHubRococoMaximalOutboundPayloadSize =
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubRococo;

impl ChainWithMessages for BridgeHubRococo {
type Hash = bp_bridge_hub_rococo::Hash;
type AccountId = bp_bridge_hub_rococo::AccountId;
type Signer = bp_bridge_hub_rococo::AccountSigner;
type Signature = bp_bridge_hub_rococo::Signature;
type Balance = bp_bridge_hub_rococo::Balance;
impl UnderlyingChainProvider for BridgeHubRococo {
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
}

impl SourceHeaderChain<crate::Balance> for BridgeHubRococo {
Expand All @@ -128,12 +128,10 @@ impl SourceHeaderChain<crate::Balance> for BridgeHubRococo {
proof: Self::MessagesProof,
messages_count: u32,
) -> Result<ProvedMessages<Message<crate::Balance>>, Self::Error> {
bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::<
bridge_runtime_common::messages::target::verify_messages_proof::<
WithBridgeHubRococoMessageBridge,
bp_bridge_hub_rococo::Header,
crate::Runtime,
crate::BridgeParachainRococoInstance,
>(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof, messages_count)
>(proof, messages_count)
.map_err(Into::into)
}
}

Expand All @@ -149,20 +147,11 @@ impl TargetHeaderChain<XcmAsPlainPayload, crate::AccountId> for BridgeHubRococo
fn verify_messages_delivery_proof(
proof: Self::MessagesDeliveryProof,
) -> Result<(LaneId, InboundLaneData<bp_bridge_hub_wococo::AccountId>), Self::Error> {
messages::source::verify_messages_delivery_proof_from_parachain::<
WithBridgeHubRococoMessageBridge,
bp_bridge_hub_rococo::Header,
crate::Runtime,
crate::BridgeParachainRococoInstance,
>(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof)
messages::source::verify_messages_delivery_proof::<WithBridgeHubRococoMessageBridge>(proof)
}
}

impl messages::BridgedChainWithMessages for BridgeHubRococo {
fn maximal_extrinsic_size() -> u32 {
bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size()
}

fn verify_dispatch_weight(_message_payload: &[u8]) -> bool {
true
}
Expand Down Expand Up @@ -206,19 +195,15 @@ impl messages::BridgedChainWithMessages for BridgeHubRococo {
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubWococo;

impl ChainWithMessages for BridgeHubWococo {
type Hash = bp_bridge_hub_wococo::Hash;
type AccountId = bp_bridge_hub_wococo::AccountId;
type Signer = bp_bridge_hub_wococo::AccountSigner;
type Signature = bp_bridge_hub_wococo::Signature;
type Balance = bp_bridge_hub_wococo::Balance;
impl UnderlyingChainProvider for BridgeHubWococo {
type Chain = bp_bridge_hub_wococo::BridgeHubWococo;
}

impl ThisChainWithMessages for BridgeHubWococo {
type RuntimeOrigin = crate::RuntimeOrigin;
type RuntimeCall = crate::RuntimeCall;
type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation<
Self::AccountId,
bp_bridge_hub_wococo::AccountId,
{ bp_bridge_hub_wococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() },
{ bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE },
{ bp_bridge_hub_wococo::TX_EXTRA_BYTES },
Expand Down

0 comments on commit c6756cd

Please sign in to comment.