Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state to message lanes #2214

Merged
merged 9 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde_json = "1.0.97"

# Bridge dependencies

bp-messages = { path = "../../../primitives/messages" }
millau-runtime = { path = "../runtime" }

# Substrate Dependencies
Expand Down
2 changes: 2 additions & 0 deletions bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ fn testnet_genesis(
},
bridge_rialto_messages: BridgeRialtoMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(RIALTO_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()],
..Default::default()
},
bridge_rialto_parachain_messages: BridgeRialtoParachainMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(
RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER,
)),
opened_lanes: vec![bp_messages::LaneId::default()],
..Default::default()
},
xcm_pallet: Default::default(),
Expand Down
6 changes: 0 additions & 6 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,6 @@ impl pallet_shift_session_manager::Config for Runtime {}
parameter_types! {
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
pub const RootAccountForPayments: Option<AccountId> = None;
pub RialtoActiveOutboundLanes: &'static [bp_messages::LaneId] = &[rialto_messages::XCM_LANE];
pub RialtoParachainActiveOutboundLanes: &'static [bp_messages::LaneId] = &[rialto_parachain_messages::XCM_LANE];
}

/// Instance of the messages pallet used to relay messages to/from Rialto chain.
Expand All @@ -443,8 +441,6 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
type BridgedChain = bp_rialto::Rialto;
type BridgedHeaderChain = BridgeRialtoGrandpa;

type ActiveOutboundLanes = RialtoActiveOutboundLanes;

type OutboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;
type InboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;

Expand Down Expand Up @@ -473,8 +469,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
bp_rialto_parachain::RialtoParachain,
>;

type ActiveOutboundLanes = RialtoParachainActiveOutboundLanes;

type OutboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;
type InboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;

Expand Down
14 changes: 13 additions & 1 deletion bin/millau/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ mod tests {
};
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey,
LaneId, MessageKey, OutboundLaneData,
};
use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult;
use codec::Encode;
Expand All @@ -268,10 +268,15 @@ mod tests {
fn xcm_messages_to_rialto_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| {
// ensure that the there are no messages queued
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::insert(
crate::rialto_messages::XCM_LANE,
OutboundLaneData::opened(),
);
assert_eq!(
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get(
crate::rialto_messages::XCM_LANE
)
.unwrap()
.latest_generated_nonce,
0,
);
Expand All @@ -292,6 +297,7 @@ mod tests {
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get(
crate::rialto_messages::XCM_LANE
)
.unwrap()
.latest_generated_nonce,
1,
);
Expand All @@ -302,10 +308,15 @@ mod tests {
fn xcm_messages_to_rialto_parachain_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| {
// ensure that the there are no messages queued
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::insert(
crate::rialto_parachain_messages::XCM_LANE,
OutboundLaneData::opened(),
);
assert_eq!(
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get(
crate::rialto_parachain_messages::XCM_LANE
)
.unwrap()
.latest_generated_nonce,
0,
);
Expand All @@ -326,6 +337,7 @@ mod tests {
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get(
crate::rialto_parachain_messages::XCM_LANE
)
.unwrap()
.latest_generated_nonce,
1,
);
Expand Down
2 changes: 2 additions & 0 deletions bin/rialto-parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ serde = { version = '1.0', features = ['derive'] }
jsonrpsee = { version = "0.16.2", features = ["server"] }

# Local Dependencies

bp-messages = { path = "../../../primitives/messages" }
rialto-parachain-runtime = { path = '../runtime' }

# Substrate Dependencies
Expand Down
1 change: 1 addition & 0 deletions bin/rialto-parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ fn testnet_genesis(
aura_ext: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()],
..Default::default()
},
}
Expand Down
11 changes: 7 additions & 4 deletions bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ impl pallet_bridge_grandpa::Config for Runtime {
parameter_types! {
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
pub const RootAccountForPayments: Option<AccountId> = None;
pub ActiveOutboundLanes: &'static [bp_messages::LaneId] = &[millau_messages::XCM_LANE];
}

/// Instance of the messages pallet used to relay messages to/from Millau chain.
Expand All @@ -566,8 +565,6 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
type BridgedChain = bp_millau::Millau;
type BridgedHeaderChain = BridgeMillauGrandpa;

type ActiveOutboundLanes = ActiveOutboundLanes;

type OutboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;
type InboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;

Expand Down Expand Up @@ -845,7 +842,7 @@ mod tests {
use crate::millau_messages::{FromMillauMessageDispatch, XCM_LANE};
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey,
LaneId, MessageKey, OutboundLaneData,
};
use bp_runtime::Chain;
use bridge_runtime_common::{
Expand Down Expand Up @@ -883,8 +880,13 @@ mod tests {
fn xcm_messages_to_millau_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| {
// ensure that the there are no messages queued
OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert(
XCM_LANE,
OutboundLaneData::opened(),
);
assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE)
.unwrap()
.latest_generated_nonce,
0,
);
Expand All @@ -903,6 +905,7 @@ mod tests {
// ensure that the message has been queued
assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE)
.unwrap()
.latest_generated_nonce,
1,
);
Expand Down
1 change: 1 addition & 0 deletions bin/rialto/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ serde_json = "1.0.97"

# Bridge dependencies

bp-messages = { path = "../../../primitives/messages" }
rialto-runtime = { path = "../runtime" }

# Substrate Dependencies
Expand Down
1 change: 1 addition & 0 deletions bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ fn testnet_genesis(
paras: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()],
..Default::default()
},
xcm_pallet: Default::default(),
Expand Down
3 changes: 0 additions & 3 deletions bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ impl pallet_shift_session_manager::Config for Runtime {}
parameter_types! {
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
pub const RootAccountForPayments: Option<AccountId> = None;
pub ActiveOutboundLanes: &'static [bp_messages::LaneId] = &[millau_messages::XCM_LANE];
}

/// Instance of the messages pallet used to relay messages to/from Millau chain.
Expand All @@ -422,8 +421,6 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
type BridgedChain = bp_millau::Millau;
type BridgedHeaderChain = BridgeMillauGrandpa;

type ActiveOutboundLanes = ActiveOutboundLanes;

type OutboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;
type InboundPayload = bridge_runtime_common::messages_xcm_extension::XcmAsPlainPayload;

Expand Down
8 changes: 7 additions & 1 deletion bin/rialto/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod tests {
};
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey,
LaneId, MessageKey, OutboundLaneData,
};
use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult;
use codec::Encode;
Expand All @@ -223,8 +223,13 @@ mod tests {
fn xcm_messages_to_millau_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| {
// ensure that the there are no messages queued
OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert(
XCM_LANE,
OutboundLaneData::opened(),
);
assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE)
.unwrap()
.latest_generated_nonce,
0,
);
Expand All @@ -243,6 +248,7 @@ mod tests {
// ensure that the message has been queued
assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE)
.unwrap()
.latest_generated_nonce,
1,
);
Expand Down
6 changes: 0 additions & 6 deletions bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ where
R: pallet_bridge_messages::Config<MI>,
MI: 'static,
{
assert!(
!R::ActiveOutboundLanes::get().is_empty(),
"ActiveOutboundLanes ({:?}) must not be empty",
R::ActiveOutboundLanes::get(),
);

assert!(
pallet_bridge_messages::BridgedChainOf::<R, MI>::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX
<= pallet_bridge_messages::BridgedChainOf::<R, MI>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Expand Down
Loading