diff --git a/Cargo.lock b/Cargo.lock index 38c5d5c8a94..f6db689aec7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -944,6 +944,7 @@ dependencies = [ "scale-info", "serde", "sp-core", + "sp-io", "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=master)", ] @@ -5816,6 +5817,7 @@ name = "millau-bridge-node" version = "0.1.0" dependencies = [ "bp-messages", + "bridge-runtime-common", "clap 4.3.4", "frame-benchmarking", "frame-benchmarking-cli", @@ -10121,6 +10123,7 @@ name = "rialto-bridge-node" version = "0.1.0" dependencies = [ "bp-messages", + "bridge-runtime-common", "clap 4.3.4", "frame-benchmarking", "frame-benchmarking-cli", @@ -10149,6 +10152,7 @@ name = "rialto-parachain-collator" version = "0.1.0" dependencies = [ "bp-messages", + "bridge-runtime-common", "clap 4.3.4", "cumulus-client-cli", "cumulus-client-consensus-aura", @@ -10271,6 +10275,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", "pallet-authority-discovery", "pallet-babe", "pallet-balances", @@ -13468,6 +13473,7 @@ dependencies = [ "relay-wococo-client", "rialto-parachain-runtime", "rialto-runtime", + "rustc-hex", "signal-hook", "signal-hook-async-std", "sp-core", diff --git a/README.md b/README.md index 2f8c5ca9abb..e72d4b2cd44 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ You will also see the message lane relayers listening for new messages. ``` # Message Relayer Logs -[Millau_to_Rialto_MessageLane_00000000] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces +[Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces [...] [date] INFO bridge Synced Some(2) of Some(3) nonces in Millau::MessagesDelivery -> Rialto::MessagesDelivery race [...] [date] DEBUG bridge Asking Millau::MessagesDelivery about message nonces [...] [date] DEBUG bridge Received best nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { latest_nonce: 0, nonces_data: () } diff --git a/bin/millau/node/Cargo.toml b/bin/millau/node/Cargo.toml index db5f83ac7fa..78a44b18a9c 100644 --- a/bin/millau/node/Cargo.toml +++ b/bin/millau/node/Cargo.toml @@ -16,6 +16,7 @@ serde_json = "1.0.97" # Bridge dependencies bp-messages = { path = "../../../primitives/messages" } +bridge-runtime-common = { path = "../../runtime-common" } millau-runtime = { path = "../runtime" } # Substrate Dependencies diff --git a/bin/millau/node/src/chain_spec.rs b/bin/millau/node/src/chain_spec.rs index 708c377c080..0b3662b2b06 100644 --- a/bin/millau/node/src/chain_spec.rs +++ b/bin/millau/node/src/chain_spec.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler; use millau_runtime::{ AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig, BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GrandpaConfig, @@ -223,14 +224,17 @@ fn testnet_genesis( }, bridge_rialto_messages: BridgeRialtoMessagesConfig { owner: Some(get_account_id_from_seed::(RIALTO_MESSAGES_PALLET_OWNER)), - opened_lanes: vec![bp_messages::LaneId::default()], + opened_lanes: vec![millau_runtime::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane()], ..Default::default() }, bridge_rialto_parachain_messages: BridgeRialtoParachainMessagesConfig { owner: Some(get_account_id_from_seed::( RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER, )), - opened_lanes: vec![bp_messages::LaneId::default()], + opened_lanes: vec![ + millau_runtime::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane( + ), + ], ..Default::default() }, xcm_pallet: Default::default(), diff --git a/bin/millau/runtime/src/lib.rs b/bin/millau/runtime/src/lib.rs index 801842e1321..319721cc61d 100644 --- a/bin/millau/runtime/src/lib.rs +++ b/bin/millau/runtime/src/lib.rs @@ -484,7 +484,6 @@ impl pallet_bridge_messages::Config for Run } parameter_types! { - pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE; pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME; pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME; pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; @@ -586,7 +585,7 @@ pub type PriorityBoostPerMessage = ConstU64<327_319_648>; pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages< Runtime, RefundableParachain, - RefundableMessagesLane, + RefundableMessagesLane, ActualFeeRefund, PriorityBoostPerMessage, StrBridgeRefundRialtoPara2000Lane0Msgs, diff --git a/bin/millau/runtime/src/rialto_messages.rs b/bin/millau/runtime/src/rialto_messages.rs index 6cbb6215978..7e785703aee 100644 --- a/bin/millau/runtime/src/rialto_messages.rs +++ b/bin/millau/runtime/src/rialto_messages.rs @@ -19,13 +19,14 @@ use crate::{Runtime, WithRialtoMessagesInstance}; use bp_messages::LaneId; -use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; +use bridge_runtime_common::messages_xcm_extension::{ + LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter, +}; use frame_support::{parameter_types, weights::Weight}; use pallet_bridge_relayers::WeightInfoExt as _; +use sp_core::Get; use xcm_builder::HaulBlobExporter; -/// Default lane that is used to send messages to Rialto. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// tests, confirming that we don't break encoding somewhere between. @@ -60,7 +61,7 @@ impl XcmBlobHauler for ToRialtoXcmBlobHauler { type MessageSender = pallet_bridge_messages::Pallet; fn xcm_lane() -> LaneId { - XCM_LANE + LaneIdFromChainId::::get() } } @@ -80,6 +81,7 @@ impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWei #[cfg(test)] mod tests { + use super::*; use crate::{RialtoGrandpaInstance, Runtime, WithRialtoMessagesInstance}; use bridge_runtime_common::{ @@ -121,4 +123,15 @@ mod tests { }, }); } + + #[test] + fn rialto_millau_bridge_identifier_did_not_changed() { + // there's nothing criminal if it is changed, but then thou need to fix it across + // all deployments scripts, alerts and so on + assert_eq!( + *ToRialtoXcmBlobHauler::xcm_lane().as_ref(), + hex_literal::hex!("52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7") + .into(), + ); + } } diff --git a/bin/millau/runtime/src/rialto_parachain_messages.rs b/bin/millau/runtime/src/rialto_parachain_messages.rs index 728ff1bf5f8..e13c4c203c4 100644 --- a/bin/millau/runtime/src/rialto_parachain_messages.rs +++ b/bin/millau/runtime/src/rialto_parachain_messages.rs @@ -19,13 +19,14 @@ use crate::{Runtime, WithRialtoParachainMessagesInstance}; use bp_messages::LaneId; -use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; +use bridge_runtime_common::messages_xcm_extension::{ + LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter, +}; use frame_support::{parameter_types, weights::Weight}; use pallet_bridge_relayers::WeightInfoExt as _; +use sp_core::Get; use xcm_builder::HaulBlobExporter; -/// Default lane that is used to send messages to Rialto parachain. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// tests, confirming that we don't break encoding somewhere between. @@ -61,7 +62,7 @@ impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler { pallet_bridge_messages::Pallet; fn xcm_lane() -> LaneId { - XCM_LANE + LaneIdFromChainId::::get() } } @@ -83,6 +84,7 @@ impl pallet_bridge_messages::WeightInfoExt #[cfg(test)] mod tests { + use super::*; use crate::{ PriorityBoostPerMessage, RialtoGrandpaInstance, Runtime, WithRialtoParachainMessagesInstance, @@ -134,4 +136,15 @@ mod tests { PriorityBoostPerMessage, >(1_000_000); } + + #[test] + fn rialto_parachain_millau_bridge_identifier_did_not_changed() { + // there's nothing criminal if it is changed, but then thou need to fix it across + // all deployments scripts, alerts and so on + assert_eq!( + *ToRialtoParachainXcmBlobHauler::xcm_lane().as_ref(), + hex_literal::hex!("6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de") + .into(), + ); + } } diff --git a/bin/millau/runtime/src/xcm_config.rs b/bin/millau/runtime/src/xcm_config.rs index cae4b68d991..d1135b2942a 100644 --- a/bin/millau/runtime/src/xcm_config.rs +++ b/bin/millau/runtime/src/xcm_config.rs @@ -245,7 +245,9 @@ mod tests { target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, LaneId, MessageKey, OutboundLaneData, }; - use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; + use bridge_runtime_common::messages_xcm_extension::{ + XcmBlobHauler, XcmBlobMessageDispatchResult, + }; use codec::Encode; use pallet_bridge_messages::OutboundLanes; use xcm_executor::XcmExecutor; @@ -269,16 +271,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 + let lane_id = crate::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane(); OutboundLanes::::insert( - crate::rialto_messages::XCM_LANE, + lane_id, OutboundLaneData::opened(), ); assert_eq!( - OutboundLanes::::get( - crate::rialto_messages::XCM_LANE - ) - .unwrap() - .latest_generated_nonce, + OutboundLanes::::get(lane_id) + .unwrap() + .latest_generated_nonce, 0, ); @@ -295,11 +296,9 @@ mod tests { // ensure that the message has been queued assert_eq!( - OutboundLanes::::get( - crate::rialto_messages::XCM_LANE - ) - .unwrap() - .latest_generated_nonce, + OutboundLanes::::get(lane_id) + .unwrap() + .latest_generated_nonce, 1, ); }) @@ -309,16 +308,16 @@ 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 + let lane_id = + crate::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane(); OutboundLanes::::insert( - crate::rialto_parachain_messages::XCM_LANE, + lane_id, OutboundLaneData::opened(), ); assert_eq!( - OutboundLanes::::get( - crate::rialto_parachain_messages::XCM_LANE - ) - .unwrap() - .latest_generated_nonce, + OutboundLanes::::get(lane_id) + .unwrap() + .latest_generated_nonce, 0, ); @@ -335,17 +334,15 @@ mod tests { // ensure that the message has been queued assert_eq!( - OutboundLanes::::get( - crate::rialto_parachain_messages::XCM_LANE - ) - .unwrap() - .latest_generated_nonce, + OutboundLanes::::get(lane_id) + .unwrap() + .latest_generated_nonce, 1, ); }) } - fn prepare_inbound_bridge_message() -> DispatchMessage> { + fn prepare_inbound_bridge_message(lane_id: LaneId) -> DispatchMessage> { let xcm = xcm::VersionedXcm::::V3(vec![Instruction::Trap(42)].into()); let location = xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); @@ -353,14 +350,16 @@ mod tests { // or public fields, so just tuple let bridge_message = (location, xcm).encode(); DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, + key: MessageKey { lane_id, nonce: 1 }, data: DispatchMessageData { payload: Ok(bridge_message) }, } } #[test] fn xcm_messages_from_rialto_are_dispatched() { - let incoming_message = prepare_inbound_bridge_message(); + let incoming_message = prepare_inbound_bridge_message( + crate::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane(), + ); // we care only about handing message to the XCM dispatcher, so we don't care about its // actual dispatch @@ -373,7 +372,9 @@ mod tests { #[test] fn xcm_messages_from_rialto_parachain_are_dispatched() { - let incoming_message = prepare_inbound_bridge_message(); + let incoming_message = prepare_inbound_bridge_message( + crate::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane(), + ); // we care only about handing message to the XCM dispatcher, so we don't care about its // actual dispatch diff --git a/bin/rialto-parachain/node/Cargo.toml b/bin/rialto-parachain/node/Cargo.toml index 90331a22ea4..781355dc363 100644 --- a/bin/rialto-parachain/node/Cargo.toml +++ b/bin/rialto-parachain/node/Cargo.toml @@ -28,6 +28,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] } # Local Dependencies bp-messages = { path = "../../../primitives/messages" } +bridge-runtime-common = { path = "../../runtime-common" } rialto-parachain-runtime = { path = '../runtime' } # Substrate Dependencies diff --git a/bin/rialto-parachain/node/src/chain_spec.rs b/bin/rialto-parachain/node/src/chain_spec.rs index 30f5a624a5e..e3d9be39695 100644 --- a/bin/rialto-parachain/node/src/chain_spec.rs +++ b/bin/rialto-parachain/node/src/chain_spec.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler; use cumulus_primitives_core::ParaId; use rialto_parachain_runtime::{AccountId, AuraId, BridgeMillauMessagesConfig, Signature}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; @@ -192,7 +193,9 @@ fn testnet_genesis( aura_ext: Default::default(), bridge_millau_messages: BridgeMillauMessagesConfig { owner: Some(get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER)), - opened_lanes: vec![bp_messages::LaneId::default()], + opened_lanes: vec![ + rialto_parachain_runtime::millau_messages::ToMillauXcmBlobHauler::xcm_lane(), + ], ..Default::default() }, } diff --git a/bin/rialto-parachain/runtime/src/lib.rs b/bin/rialto-parachain/runtime/src/lib.rs index 78f7c794872..48b825b573d 100644 --- a/bin/rialto-parachain/runtime/src/lib.rs +++ b/bin/rialto-parachain/runtime/src/lib.rs @@ -841,14 +841,15 @@ cumulus_pallet_parachain_system::register_validate_block!( #[cfg(test)] mod tests { use super::*; - use crate::millau_messages::{FromMillauMessageDispatch, XCM_LANE}; + use crate::millau_messages::FromMillauMessageDispatch; use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, - LaneId, MessageKey, OutboundLaneData, + MessageKey, OutboundLaneData, }; use bp_runtime::Chain; use bridge_runtime_common::{ - integrity::check_additional_signed, messages_xcm_extension::XcmBlobMessageDispatchResult, + integrity::check_additional_signed, + messages_xcm_extension::{XcmBlobHauler, XcmBlobMessageDispatchResult}, }; use codec::Encode; use pallet_bridge_messages::OutboundLanes; @@ -882,12 +883,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 + let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane(); OutboundLanes::::insert( - XCM_LANE, + lane_id, OutboundLaneData::opened(), ); assert_eq!( - OutboundLanes::::get(XCM_LANE) + OutboundLanes::::get(lane_id) .unwrap() .latest_generated_nonce, 0, @@ -906,7 +908,7 @@ mod tests { // ensure that the message has been queued assert_eq!( - OutboundLanes::::get(XCM_LANE) + OutboundLanes::::get(lane_id) .unwrap() .latest_generated_nonce, 1, @@ -920,9 +922,10 @@ mod tests { xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor // or public fields, so just tuple + let xcm_lane = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane(); let bridge_message = (location, xcm).encode(); DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, + key: MessageKey { lane_id: xcm_lane, nonce: 1 }, data: DispatchMessageData { payload: Ok(bridge_message) }, } } diff --git a/bin/rialto-parachain/runtime/src/millau_messages.rs b/bin/rialto-parachain/runtime/src/millau_messages.rs index d9f51c1ed2b..2eb7c1b8525 100644 --- a/bin/rialto-parachain/runtime/src/millau_messages.rs +++ b/bin/rialto-parachain/runtime/src/millau_messages.rs @@ -22,12 +22,13 @@ use crate::{Runtime, WithMillauMessagesInstance}; use bp_messages::LaneId; -use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; +use bridge_runtime_common::messages_xcm_extension::{ + LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter, +}; use frame_support::{parameter_types, weights::Weight}; +use sp_core::Get; use xcm_builder::HaulBlobExporter; -/// Default lane that is used to send messages to Millau. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// tests, confirming that we don't break encoding somewhere between. @@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler { type MessageSender = pallet_bridge_messages::Pallet; fn xcm_lane() -> LaneId { - XCM_LANE + LaneIdFromChainId::::get() } } #[cfg(test)] mod tests { + use super::*; use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; use bridge_runtime_common::{ assert_complete_bridge_types, @@ -109,4 +111,15 @@ mod tests { }, }); } + + #[test] + fn rialto_parachain_millau_bridge_identifier_did_not_changed() { + // there's nothing criminal if it is changed, but then thou need to fix it across + // all deployments scripts, alerts and so on + assert_eq!( + *ToMillauXcmBlobHauler::xcm_lane().as_ref(), + hex_literal::hex!("6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de") + .into(), + ); + } } diff --git a/bin/rialto/node/Cargo.toml b/bin/rialto/node/Cargo.toml index bf0f145b6e4..bc89c207c78 100644 --- a/bin/rialto/node/Cargo.toml +++ b/bin/rialto/node/Cargo.toml @@ -15,6 +15,7 @@ serde_json = "1.0.97" # Bridge dependencies bp-messages = { path = "../../../primitives/messages" } +bridge-runtime-common = { path = "../../runtime-common" } rialto-runtime = { path = "../runtime" } # Substrate Dependencies diff --git a/bin/rialto/node/src/chain_spec.rs b/bin/rialto/node/src/chain_spec.rs index 4f0cb5aa650..72f62897b6e 100644 --- a/bin/rialto/node/src/chain_spec.rs +++ b/bin/rialto/node/src/chain_spec.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler; use polkadot_primitives::v5::{AssignmentId, ValidatorId}; use rialto_runtime::{ AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig, @@ -277,7 +278,7 @@ fn testnet_genesis( paras: Default::default(), bridge_millau_messages: BridgeMillauMessagesConfig { owner: Some(get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER)), - opened_lanes: vec![bp_messages::LaneId::default()], + opened_lanes: vec![rialto_runtime::millau_messages::ToMillauXcmBlobHauler::xcm_lane()], ..Default::default() }, xcm_pallet: Default::default(), diff --git a/bin/rialto/runtime/Cargo.toml b/bin/rialto/runtime/Cargo.toml index 12254010b35..38de00da62f 100644 --- a/bin/rialto/runtime/Cargo.toml +++ b/bin/rialto/runtime/Cargo.toml @@ -71,6 +71,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "maste [dev-dependencies] bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } env_logger = "0.10" +hex-literal = "0.4" static_assertions = "1.1" [build-dependencies] diff --git a/bin/rialto/runtime/src/millau_messages.rs b/bin/rialto/runtime/src/millau_messages.rs index 2ef82f22f16..b8f6fadcad5 100644 --- a/bin/rialto/runtime/src/millau_messages.rs +++ b/bin/rialto/runtime/src/millau_messages.rs @@ -19,12 +19,13 @@ use crate::{Runtime, WithMillauMessagesInstance}; use bp_messages::LaneId; -use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; +use bridge_runtime_common::messages_xcm_extension::{ + LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter, +}; use frame_support::{parameter_types, weights::Weight}; +use sp_core::Get; use xcm_builder::HaulBlobExporter; -/// Lane that is used for XCM messages exchange. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// tests, confirming that we don't break encoding somewhere between. @@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler { type MessageSender = pallet_bridge_messages::Pallet; fn xcm_lane() -> LaneId { - XCM_LANE + LaneIdFromChainId::::get() } } #[cfg(test)] mod tests { + use super::*; use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; use bridge_runtime_common::{ assert_complete_bridge_types, @@ -105,4 +107,15 @@ mod tests { }, }); } + + #[test] + fn rialto_millau_bridge_identifier_did_not_changed() { + // there's nothing criminal if it is changed, but then thou need to fix it across + // all deployments scripts, alerts and so on + assert_eq!( + *ToMillauXcmBlobHauler::xcm_lane().as_ref(), + hex_literal::hex!("52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7") + .into(), + ); + } } diff --git a/bin/rialto/runtime/src/xcm_config.rs b/bin/rialto/runtime/src/xcm_config.rs index bc3460d5a36..0018b7fc67b 100644 --- a/bin/rialto/runtime/src/xcm_config.rs +++ b/bin/rialto/runtime/src/xcm_config.rs @@ -192,15 +192,14 @@ impl pallet_xcm::Config for Runtime { #[cfg(test)] mod tests { use super::*; - use crate::{ - millau_messages::{FromMillauMessageDispatch, XCM_LANE}, - WithMillauMessagesInstance, - }; + use crate::{millau_messages::FromMillauMessageDispatch, WithMillauMessagesInstance}; use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, - LaneId, MessageKey, OutboundLaneData, + MessageKey, OutboundLaneData, + }; + use bridge_runtime_common::messages_xcm_extension::{ + XcmBlobHauler, XcmBlobMessageDispatchResult, }; - use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; use codec::Encode; use pallet_bridge_messages::OutboundLanes; use xcm_executor::XcmExecutor; @@ -224,12 +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 + let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane(); OutboundLanes::::insert( - XCM_LANE, + lane_id, OutboundLaneData::opened(), ); assert_eq!( - OutboundLanes::::get(XCM_LANE) + OutboundLanes::::get(lane_id) .unwrap() .latest_generated_nonce, 0, @@ -248,7 +248,7 @@ mod tests { // ensure that the message has been queued assert_eq!( - OutboundLanes::::get(XCM_LANE) + OutboundLanes::::get(lane_id) .unwrap() .latest_generated_nonce, 1, @@ -263,8 +263,9 @@ mod tests { // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor // or public fields, so just tuple let bridge_message = (location, xcm).encode(); + let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane(); DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, + key: MessageKey { lane_id, nonce: 1 }, data: DispatchMessageData { payload: Ok(bridge_message) }, } } diff --git a/bin/runtime-common/src/messages_call_ext.rs b/bin/runtime-common/src/messages_call_ext.rs index bad1b0255fe..4ec82b84656 100644 --- a/bin/runtime-common/src/messages_call_ext.rs +++ b/bin/runtime-common/src/messages_call_ext.rs @@ -324,11 +324,13 @@ mod tests { }; use sp_std::ops::RangeInclusive; - const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 0]); + fn test_lane_id() -> LaneId { + LaneId::new(1, 2) + } fn fill_unrewarded_relayers() { let mut inbound_lane_state = - pallet_bridge_messages::InboundLanes::::get(TEST_LANE_ID).unwrap(); + pallet_bridge_messages::InboundLanes::::get(test_lane_id()).unwrap(); for n in 0..BridgedUnderlyingChain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX { inbound_lane_state.relayers.push_back(UnrewardedRelayer { relayer: Default::default(), @@ -336,14 +338,14 @@ mod tests { }); } pallet_bridge_messages::InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), inbound_lane_state, ); } fn fill_unrewarded_messages() { let mut inbound_lane_state = - pallet_bridge_messages::InboundLanes::::get(TEST_LANE_ID).unwrap(); + pallet_bridge_messages::InboundLanes::::get(test_lane_id()).unwrap(); inbound_lane_state.relayers.push_back(UnrewardedRelayer { relayer: Default::default(), messages: DeliveredMessages { @@ -352,14 +354,14 @@ mod tests { }, }); pallet_bridge_messages::InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), inbound_lane_state, ); } fn deliver_message_10() { pallet_bridge_messages::InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), bp_messages::InboundLaneData { state: LaneState::Opened, relayers: Default::default(), @@ -381,7 +383,7 @@ mod tests { proof: Box::new(FromBridgedChainMessagesProof { bridged_header_hash: Default::default(), storage: Default::default(), - lane: TEST_LANE_ID, + lane: test_lane_id(), nonces_start, nonces_end, }), @@ -394,11 +396,11 @@ mod tests { fn run_test(test: impl Fn() -> T) -> T { sp_io::TestExternalities::new(Default::default()).execute_with(|| { pallet_bridge_messages::InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), InboundLaneData::opened(), ); pallet_bridge_messages::OutboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), OutboundLaneData::opened(), ); test() @@ -488,7 +490,7 @@ mod tests { fn confirm_message_10() { pallet_bridge_messages::OutboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), bp_messages::OutboundLaneData { state: LaneState::Opened, oldest_unpruned_nonce: 0, @@ -504,7 +506,7 @@ mod tests { proof: FromBridgedChainMessagesDeliveryProof { bridged_header_hash: Default::default(), storage_proof: Default::default(), - lane: TEST_LANE_ID, + lane: test_lane_id(), }, relayers_state: UnrewardedRelayersState { last_delivered_nonce, @@ -562,7 +564,7 @@ mod tests { CallHelper::::was_successful(&CallInfo::ReceiveMessagesProof( ReceiveMessagesProofInfo { base: BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range, best_stored_nonce: 0, // doesn't matter for `was_successful` }, @@ -622,7 +624,7 @@ mod tests { fn was_message_confirmation_successful(bundled_range: RangeInclusive) -> bool { CallHelper::::was_successful(&CallInfo::ReceiveMessagesDeliveryProof( ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range, best_stored_nonce: 0, // doesn't matter for `was_successful` }), diff --git a/bin/runtime-common/src/messages_xcm_extension.rs b/bin/runtime-common/src/messages_xcm_extension.rs index 0317d745c15..c6a7703a72e 100644 --- a/bin/runtime-common/src/messages_xcm_extension.rs +++ b/bin/runtime-common/src/messages_xcm_extension.rs @@ -26,17 +26,37 @@ use bp_messages::{ target_chain::{DispatchMessage, MessageDispatch}, LaneId, }; -use bp_runtime::messages::MessageDispatchResult; +use bp_runtime::{messages::MessageDispatchResult, Chain}; use codec::{Decode, Encode}; use frame_support::{dispatch::Weight, CloneNoBound, EqNoBound, PartialEqNoBound}; use pallet_bridge_messages::WeightInfoExt as MessagesPalletWeights; use scale_info::TypeInfo; +use sp_core::Get; use sp_runtime::SaturatedConversion; +use sp_std::marker::PhantomData; use xcm_builder::{DispatchBlob, DispatchBlobError, HaulBlob, HaulBlobError}; /// Plain "XCM" payload, which we transfer through bridge pub type XcmAsPlainPayload = sp_std::prelude::Vec; +/// Make LaneId from chain identifiers of two bridge endpoints. +// TODO: https://github.com/paritytech/parity-bridges-common/issues/1666: this function +// is a temporary solution, because `ChainId` and will be removed soon. +pub struct LaneIdFromChainId(PhantomData<(R, I)>); + +impl Get for LaneIdFromChainId +where + R: pallet_bridge_messages::Config, + I: 'static, +{ + fn get() -> LaneId { + LaneId::new( + pallet_bridge_messages::ThisChainOf::::ID, + pallet_bridge_messages::BridgedChainOf::::ID, + ) + } +} + /// Message dispatch result type for single message #[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)] pub enum XcmBlobMessageDispatchResult { diff --git a/bin/runtime-common/src/mock.rs b/bin/runtime-common/src/mock.rs index b67543ad145..7c7e40c92e9 100644 --- a/bin/runtime-common/src/mock.rs +++ b/bin/runtime-common/src/mock.rs @@ -36,6 +36,7 @@ use frame_support::{ StateVersion, }; use pallet_transaction_payment::Multiplier; +use sp_core::Get; use sp_runtime::{ testing::H256, traits::{BlakeTwo256, ConstU32, ConstU64, ConstU8, IdentityLookup}, @@ -90,7 +91,10 @@ pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< >; /// Message lane used in tests. -pub const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 0]); +pub fn test_lane_id() -> LaneId { + crate::messages_xcm_extension::LaneIdFromChainId::::get() +} + /// Bridged chain id used in tests. pub const TEST_BRIDGED_CHAIN_ID: ChainId = *b"brdg"; /// Maximal extrinsic size at the `BridgedChain`. diff --git a/bin/runtime-common/src/refund_relayer_extension.rs b/bin/runtime-common/src/refund_relayer_extension.rs index ce8c3c2346f..90f6d4bfce1 100644 --- a/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bin/runtime-common/src/refund_relayer_extension.rs @@ -19,8 +19,11 @@ //! with calls that are: delivering new messsage and all necessary underlying headers //! (parachain or relay chain). -use crate::messages_call_ext::{ - CallHelper as MessagesCallHelper, CallInfo as MessagesCallInfo, MessagesCallSubType, +use crate::{ + messages_call_ext::{ + CallHelper as MessagesCallHelper, CallInfo as MessagesCallInfo, MessagesCallSubType, + }, + messages_xcm_extension::LaneIdFromChainId, }; use bp_messages::{ChainWithMessages, LaneId, MessageNonce}; use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; @@ -102,14 +105,15 @@ pub trait RefundableMessagesLaneId { } /// Default implementation of `RefundableMessagesLaneId`. -pub struct RefundableMessagesLane(PhantomData<(Instance, Id)>); +pub struct RefundableMessagesLane(PhantomData<(Runtime, Instance)>); -impl RefundableMessagesLaneId for RefundableMessagesLane +impl RefundableMessagesLaneId for RefundableMessagesLane where - Id: Get, + Runtime: MessagesConfig, + Instance: 'static, { type Instance = Instance; - type Id = Id; + type Id = LaneIdFromChainId; } /// Refund calculator. @@ -680,14 +684,13 @@ mod tests { parameter_types! { TestParachain: u32 = 1000; - pub TestLaneId: LaneId = TEST_LANE_ID; pub MsgProofsRewardsAccount: RewardsAccountParams = RewardsAccountParams::new( - TEST_LANE_ID, + test_lane_id(), TEST_BRIDGED_CHAIN_ID, RewardsAccountOwner::ThisChain, ); pub MsgDeliveryProofsRewardsAccount: RewardsAccountParams = RewardsAccountParams::new( - TEST_LANE_ID, + test_lane_id(), TEST_BRIDGED_CHAIN_ID, RewardsAccountOwner::BridgedChain, ); @@ -697,7 +700,7 @@ mod tests { type TestExtension = RefundBridgedParachainMessages< TestRuntime, DefaultRefundableParachainId<(), TestParachain>, - RefundableMessagesLane<(), TestLaneId>, + RefundableMessagesLane, ActualFeeRefund, ConstU64<1>, StrTestExtension, @@ -749,7 +752,7 @@ mod tests { }; pallet_bridge_parachains::ParasInfo::::insert(para_id, para_info); - let lane_id = TestLaneId::get(); + let lane_id = test_lane_id(); let in_lane_data = InboundLaneData { last_confirmed_nonce: best_message, ..Default::default() }; pallet_bridge_messages::InboundLanes::::insert(lane_id, in_lane_data); @@ -802,9 +805,9 @@ mod tests { proof: Box::new(FromBridgedChainMessagesProof { bridged_header_hash: Default::default(), storage: Default::default(), - lane: TestLaneId::get(), + lane: test_lane_id(), nonces_start: pallet_bridge_messages::InboundLanes::::get( - TEST_LANE_ID, + test_lane_id(), ) .unwrap() .last_delivered_nonce() + @@ -821,7 +824,7 @@ mod tests { proof: FromBridgedChainMessagesDeliveryProof { bridged_header_hash: Default::default(), storage_proof: Default::default(), - lane: TestLaneId::get(), + lane: test_lane_id(), }, relayers_state: UnrewardedRelayersState { last_delivered_nonce: best_message, @@ -898,7 +901,7 @@ mod tests { }, MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo { base: BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }, @@ -929,7 +932,7 @@ mod tests { }, MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo( BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }, @@ -949,7 +952,7 @@ mod tests { }, MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo { base: BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }, @@ -975,7 +978,7 @@ mod tests { }, MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo( BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }, @@ -990,7 +993,7 @@ mod tests { call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesProof( ReceiveMessagesProofInfo { base: BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }, @@ -1010,7 +1013,7 @@ mod tests { relayer: relayer_account_at_this_chain(), call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesDeliveryProof( ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), bundled_range: 101..=200, best_stored_nonce: 100, }), diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json index af8749325de..d3c59e98868 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json @@ -63,14 +63,14 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_Rialto_MessageLane_00000000_best_target_block_number", + "expr": "Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_target_block_number", "instant": false, "interval": "", "legendFormat": "At Rialto", "refId": "A" }, { - "expr": "Millau_to_Rialto_MessageLane_00000000_best_target_at_source_block_number", + "expr": "Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_target_at_source_block_number", "instant": false, "interval": "", "legendFormat": "At Millau", @@ -164,13 +164,13 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_Rialto_MessageLane_00000000_best_source_block_number", + "expr": "Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_source_block_number", "interval": "", "legendFormat": "At Millau", "refId": "A" }, { - "expr": "Millau_to_Rialto_MessageLane_00000000_best_source_at_target_block_number", + "expr": "Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_source_at_target_block_number", "interval": "", "legendFormat": "At Rialto", "refId": "B" @@ -298,16 +298,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Rialto\", \"type\", \"source_latest_generated\"), \"type\", \"Latest Rialto message received by Millau\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Rialto\", \"type\", \"source_latest_generated\"), \"type\", \"Latest Rialto message received by Millau\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"source_latest_generated\"}[10m]) OR on() vector(0)", + "expr": "increase(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_generated\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", - "legendFormat": "Messages generated in last 5 minutes (Millau -> Rialto, 00000000)", + "legendFormat": "Messages generated in last 5 minutes (Millau -> Rialto)", "refId": "B" } ], @@ -324,7 +324,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race (00000000)", + "title": "Delivery race", "tooltip": { "shared": true, "sort": 0, @@ -407,7 +407,7 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Rialto to Millau\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest Rialto message received by Millau\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Rialto to Millau\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest Rialto message received by Millau\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" @@ -417,7 +417,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race (00000000)", + "title": "Confirmations race", "tooltip": { "shared": true, "sort": 0, @@ -535,7 +535,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]))", + "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]))", "format": "time_series", "instant": false, "interval": "", @@ -543,7 +543,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[5m]) OR on() vector(0)", + "expr": "increase(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[5m]) OR on() vector(0)", "interval": "", "legendFormat": "Millau Messages delivered to Rialto in last 5m", "refId": "B" @@ -562,7 +562,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race lags (00000000)", + "title": "Delivery race lags", "tooltip": { "shared": true, "sort": 0, @@ -680,7 +680,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", + "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", "interval": "", "legendFormat": "Unconfirmed messages at Millau", "refId": "A" @@ -699,7 +699,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race lags (00000000)", + "title": "Confirmations race lags", "tooltip": { "shared": true, "sort": 0, @@ -817,13 +817,13 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]))", + "expr": "scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Rialto", "refId": "A" }, { - "expr": "(scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]) > bool min_over_time(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]))", + "expr": "(scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]) > bool min_over_time(Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau->Rialto (zero if messages are not being delivered to Rialto)", "refId": "B" @@ -842,7 +842,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Reward lags (00000000)", + "title": "Reward lags", "tooltip": { "shared": true, "sort": 0, diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json index efee749c5c1..68932a05891 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json @@ -64,14 +64,14 @@ "steppedLine": false, "targets": [ { - "expr": "Rialto_to_Millau_MessageLane_00000000_best_target_block_number", + "expr": "Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_target_block_number", "instant": false, "interval": "", "legendFormat": "At Millau", "refId": "A" }, { - "expr": "Rialto_to_Millau_MessageLane_00000000_best_target_at_source_block_number", + "expr": "Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_target_at_source_block_number", "instant": false, "interval": "", "legendFormat": "At Rialto", @@ -165,13 +165,13 @@ "steppedLine": false, "targets": [ { - "expr": "Rialto_to_Millau_MessageLane_00000000_best_source_block_number", + "expr": "Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_source_block_number", "interval": "", "legendFormat": "At Rialto", "refId": "A" }, { - "expr": "Rialto_to_Millau_MessageLane_00000000_best_source_at_target_block_number", + "expr": "Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_best_source_at_target_block_number", "interval": "", "legendFormat": "At Millau", "refId": "B" @@ -299,16 +299,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Millau\", \"type\", \"source_latest_generated\"), \"type\", \"Latest message received by Rialto\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Millau\", \"type\", \"source_latest_generated\"), \"type\", \"Latest message received by Rialto\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" }, { - "expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"source_latest_generated\"}[10m]) OR on() vector(0)", + "expr": "increase(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_generated\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", - "legendFormat": "Messages generated in last 5 minutes (Rialto -> Millau, 00000000)", + "legendFormat": "Messages generated in last 5 minutes (Rialto -> Millau)", "refId": "B" } ], @@ -316,7 +316,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race (00000000)", + "title": "Delivery race", "tooltip": { "shared": true, "sort": 0, @@ -399,7 +399,7 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Millau to Rialto\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest message received by Rialto\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Millau to Rialto\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest message received by Rialto\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" @@ -409,7 +409,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race (00000000)", + "title": "Confirmations race", "tooltip": { "shared": true, "sort": 0, @@ -527,7 +527,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]))", + "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]))", "format": "time_series", "instant": false, "interval": "", @@ -535,7 +535,7 @@ "refId": "A" }, { - "expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[5m]) OR on() vector(0)", + "expr": "increase(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[5m]) OR on() vector(0)", "interval": "", "legendFormat": "Rialto Messages delivered to Millau in last 5m", "refId": "B" @@ -554,7 +554,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race lags (00000000)", + "title": "Delivery race lags", "tooltip": { "shared": true, "sort": 0, @@ -672,7 +672,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", + "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", "interval": "", "legendFormat": "Unconfirmed messages at Rialto", "refId": "A" @@ -691,7 +691,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race lags (00000000)", + "title": "Confirmations race lags", "tooltip": { "shared": true, "sort": 0, @@ -809,13 +809,13 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]))", + "expr": "scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau", "refId": "A" }, { - "expr": "(scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]) > bool min_over_time(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[2m]))", + "expr": "(scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]) > bool min_over_time(Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_lane_state_nonces{type=\"target_latest_received\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau (zero if messages are not being delivered to Millau)", "refId": "B" @@ -834,7 +834,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Reward lags (00000000)", + "title": "Reward lags", "tooltip": { "shared": true, "sort": 0, diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json index 4f134914f70..23a180b17ce 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json @@ -426,7 +426,7 @@ "steppedLine": false, "targets": [ { - "expr": "Rialto_to_Millau_MessageLane_00000000_is_source_and_source_at_target_using_different_forks OR on() vector(0)", + "expr": "Rialto_to_Millau_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_is_source_and_source_at_target_using_different_forks OR on() vector(0)", "interval": "", "legendFormat": "On different forks?", "refId": "A" @@ -559,7 +559,7 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_Rialto_MessageLane_00000000_is_source_and_source_at_target_using_different_forks OR on() vector(0)", + "expr": "Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7_is_source_and_source_at_target_using_different_forks OR on() vector(0)", "interval": "", "legendFormat": "On different forks?", "refId": "A" diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-messages-millau-to-rialto-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-messages-millau-to-rialto-entrypoint.sh deleted file mode 100755 index 3a55cc782ca..00000000000 --- a/deployments/bridges/rialto-millau/entrypoints/relay-messages-millau-to-rialto-entrypoint.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -xeu - -sleep 15 - -MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000} - -/home/user/substrate-relay relay-messages millau-to-rialto \ - --lane $MESSAGE_LANE \ - --source-host millau-node-bob \ - --source-port 9944 \ - --source-signer //Rialto.OutboundMessagesRelay.Lane00000001 \ - --target-host rialto-node-bob \ - --target-port 9944 \ - --target-signer //Millau.InboundMessagesRelay.Lane00000001 \ - --prometheus-host=0.0.0.0 diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-messages-rialto-to-millau-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-messages-rialto-to-millau-entrypoint.sh deleted file mode 100755 index 145cd20100d..00000000000 --- a/deployments/bridges/rialto-millau/entrypoints/relay-messages-rialto-to-millau-entrypoint.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -xeu - -sleep 15 - -MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000} - -/home/user/substrate-relay relay-messages rialto-to-millau \ - --lane $MESSAGE_LANE \ - --source-host rialto-node-bob \ - --source-port 9944 \ - --source-signer //Millau.OutboundMessagesRelay.Lane00000001 \ - --target-host millau-node-bob \ - --target-port 9944 \ - --target-signer //Rialto.InboundMessagesRelay.Lane00000001 \ - --prometheus-host=0.0.0.0 diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-millau-rialto-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-millau-rialto-entrypoint.sh index a1306984bca..1227c4a4452 100755 --- a/deployments/bridges/rialto-millau/entrypoints/relay-millau-rialto-entrypoint.sh +++ b/deployments/bridges/rialto-millau/entrypoints/relay-millau-rialto-entrypoint.sh @@ -3,6 +3,10 @@ set -xeu sleep 15 +# see `rialto_millau_bridge_identifier_did_not_changed` test in `millau-runtime` crate for +# details on how this lane is computed +MESSAGE_LANE="52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7" + /home/user/substrate-relay init-bridge millau-to-rialto \ --source-host millau-node-alice \ --source-port 9944 \ @@ -33,5 +37,5 @@ RIALTO_NODE_CONNECTION_PARAMS=$([ -z ${GLOBAL_DEPLOYMENTS} ] && \ $RIALTO_NODE_CONNECTION_PARAMS \ --rialto-signer //Millau.HeadersAndMessagesRelay \ --rialto-transactions-mortality=64 \ - --lane=00000000 \ + --lane=$MESSAGE_LANE \ --prometheus-host=0.0.0.0 diff --git a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-millau-to-rialto-parachain-messages-dashboard.json b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-millau-to-rialto-parachain-messages-dashboard.json index b20348cc513..d4feb6a4c7e 100644 --- a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-millau-to-rialto-parachain-messages-dashboard.json +++ b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-millau-to-rialto-parachain-messages-dashboard.json @@ -63,14 +63,14 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_RialtoParachain_MessageLane_00000000_best_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "instant": false, "interval": "", "legendFormat": "At RialtoParachain", "refId": "A" }, { - "expr": "Millau_to_RialtoParachain_MessageLane_00000000_best_target_at_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_target_at_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "instant": false, "interval": "", "legendFormat": "At Millau", @@ -164,13 +164,13 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_RialtoParachain_MessageLane_00000000_best_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "interval": "", "legendFormat": "At Millau", "refId": "A" }, { - "expr": "Millau_to_RialtoParachain_MessageLane_00000000_best_source_at_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_source_at_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "interval": "", "legendFormat": "At RialtoParachain", "refId": "B" @@ -298,16 +298,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from RialtoParachain\", \"type\", \"source_latest_generated\"), \"type\", \"Latest RialtoParachain message received by Millau\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from RialtoParachain\", \"type\", \"source_latest_generated\"), \"type\", \"Latest RialtoParachain message received by Millau\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" }, { - "expr": "increase(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[10m]) OR on() vector(0)", + "expr": "increase(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", - "legendFormat": "Messages generated in last 5 minutes (Millau -> RialtoParachain, 00000000)", + "legendFormat": "Messages generated in last 5 minutes (Millau -> RialtoParachain)", "refId": "B" } ], @@ -324,7 +324,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race (00000000)", + "title": "Delivery race", "tooltip": { "shared": true, "sort": 0, @@ -407,7 +407,7 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by RialtoParachain to Millau\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest RialtoParachain message received by Millau\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by RialtoParachain to Millau\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest RialtoParachain message received by Millau\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" @@ -417,7 +417,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race (00000000)", + "title": "Confirmations race", "tooltip": { "shared": true, "sort": 0, @@ -535,7 +535,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", + "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", "format": "time_series", "instant": false, "interval": "", @@ -543,7 +543,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[5m]) OR on() vector(0)", + "expr": "increase(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[5m]) OR on() vector(0)", "interval": "", "legendFormat": "Millau Messages delivered to RialtoParachain in last 5m", "refId": "B" @@ -561,7 +561,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race lags (00000000)", + "title": "Delivery race lags", "tooltip": { "shared": true, "sort": 0, @@ -679,7 +679,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", + "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", "interval": "", "legendFormat": "Unconfirmed messages at Millau", "refId": "A" @@ -697,7 +697,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race lags (00000000)", + "title": "Confirmations race lags", "tooltip": { "shared": true, "sort": 0, @@ -815,13 +815,13 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]))", + "expr": "scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at RialtoParachain", "refId": "A" }, { - "expr": "(scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) > bool min_over_time(Millau_to_RialtoParachain_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", + "expr": "(scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) > bool min_over_time(Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau->RaltoParachain (zero if messages are not being delivered to RialtoParachain)", "refId": "B" @@ -840,7 +840,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Reward lags (00000000)", + "title": "Reward lags", "tooltip": { "shared": true, "sort": 0, diff --git a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-rialto-parachain-to-millau-messages-dashboard.json b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-rialto-parachain-to-millau-messages-dashboard.json index 064436145de..10c8fcd3928 100644 --- a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-rialto-parachain-to-millau-messages-dashboard.json +++ b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/relay-rialto-parachain-to-millau-messages-dashboard.json @@ -63,14 +63,14 @@ "steppedLine": false, "targets": [ { - "expr": "RialtoParachain_to_Millau_MessageLane_00000000_best_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "instant": false, "interval": "", "legendFormat": "At Millau", "refId": "A" }, { - "expr": "RialtoParachain_to_Millau_MessageLane_00000000_best_target_at_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_target_at_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "instant": false, "interval": "", "legendFormat": "At RialtoParachain", @@ -164,13 +164,13 @@ "steppedLine": false, "targets": [ { - "expr": "RialtoParachain_to_Millau_MessageLane_00000000_best_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_source_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "interval": "", "legendFormat": "At RialtoParachain", "refId": "A" }, { - "expr": "RialtoParachain_to_Millau_MessageLane_00000000_best_source_at_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_best_source_at_target_block_number{instance=\"relay-millau-rialto-parachain-1:9616\"}", "interval": "", "legendFormat": "At Millau", "refId": "B" @@ -298,16 +298,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Millau\", \"type\", \"source_latest_generated\"), \"type\", \"Latest Millau message received by RialtoParachain\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_generated|target_latest_received\"}, \"type\", \"Latest message sent from Millau\", \"type\", \"source_latest_generated\"), \"type\", \"Latest Millau message received by RialtoParachain\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" }, { - "expr": "increase(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[10m]) OR on() vector(0)", + "expr": "increase(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", - "legendFormat": "Messages generated in last 5 minutes (RialtoParachain -> Millau, 00000000)", + "legendFormat": "Messages generated in last 5 minutes (RialtoParachain -> Millau)", "refId": "B" } ], @@ -323,7 +323,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race (00000000)", + "title": "Delivery race", "tooltip": { "shared": true, "sort": 0, @@ -406,7 +406,7 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Millau to RialtoParachain\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest Millau message received by RialtoParachain\", \"type\", \"target_latest_received\")", + "expr": "label_replace(label_replace(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=~\"source_latest_confirmed|target_latest_received\"}, \"type\", \"Latest message confirmed by Millau to RialtoParachain\", \"type\", \"source_latest_confirmed\"), \"type\", \"Latest Millau message received by RialtoParachain\", \"type\", \"target_latest_received\")", "interval": "", "legendFormat": "{{type}}", "refId": "A" @@ -416,7 +416,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race (00000000)", + "title": "Confirmations race", "tooltip": { "shared": true, "sort": 0, @@ -534,7 +534,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", + "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_generated\"}[2m])) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", "format": "time_series", "instant": false, "interval": "", @@ -542,7 +542,7 @@ "refId": "A" }, { - "expr": "increase(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[5m]) OR on() vector(0)", + "expr": "increase(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[5m]) OR on() vector(0)", "interval": "", "legendFormat": "RialtoParachain Messages delivered to Millau in last 5m", "refId": "B" @@ -560,7 +560,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Delivery race lags (00000000)", + "title": "Delivery race lags", "tooltip": { "shared": true, "sort": 0, @@ -678,7 +678,7 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", + "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) OR on() vector(0)) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0))", "interval": "", "legendFormat": "Unconfirmed messages at RialtoParachain", "refId": "A" @@ -696,7 +696,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Confirmations race lags (00000000)", + "title": "Confirmations race lags", "tooltip": { "shared": true, "sort": 0, @@ -814,13 +814,13 @@ "steppedLine": false, "targets": [ { - "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]))", + "expr": "scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m])) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau", "refId": "A" }, { - "expr": "(scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) > bool min_over_time(RialtoParachain_to_Millau_MessageLane_00000000_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", + "expr": "(scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"source_latest_confirmed\"}[2m]) OR on() vector(0)) - scalar(max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_confirmed\"}[2m]) OR on() vector(0))) * (max_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]) > bool min_over_time(RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_lane_state_nonces{instance=\"relay-millau-rialto-parachain-1:9616\",type=\"target_latest_received\"}[2m]))", "interval": "", "legendFormat": "Unconfirmed rewards at Millau (zero if messages are not being delivered to Millau)", "refId": "B" @@ -838,7 +838,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Reward lags (00000000)", + "title": "Reward lags", "tooltip": { "shared": true, "sort": 0, diff --git a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/rialto-parachain-millau-maintenance-dashboard.json b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/rialto-parachain-millau-maintenance-dashboard.json index ca22a6dadd0..d3cd10f5a80 100644 --- a/deployments/bridges/rialto-parachain-millau/dashboard/grafana/rialto-parachain-millau-maintenance-dashboard.json +++ b/deployments/bridges/rialto-parachain-millau/dashboard/grafana/rialto-parachain-millau-maintenance-dashboard.json @@ -111,7 +111,7 @@ }, { "exemplar": true, - "expr": "at_RialtoParachain_relay_MillauMessages_reward_for_msgs_from_Millau_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_to_Millau_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "at_RialtoParachain_relay_MillauMessages_reward_for_msgs_from_Millau_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_to_Millau_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"}", "hide": false, "instant": false, "interval": "", @@ -120,7 +120,7 @@ }, { "exemplar": true, - "expr": "at_RialtoParachain_relay_MillauMessages_balance{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_from_Millau_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_to_Millau_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "at_RialtoParachain_relay_MillauMessages_balance{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_from_Millau_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_RialtoParachain_relay_MillauMessages_reward_for_msgs_to_Millau_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"}", "hide": false, "interval": "", "legendFormat": "With-Millau relay account total balance (balance + reward)", @@ -262,7 +262,7 @@ }, { "exemplar": true, - "expr": "at_Millau_relay_RialtoParachainMessages_reward_for_msgs_from_RialtoParachain_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_to_RialtoParachain_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "at_Millau_relay_RialtoParachainMessages_reward_for_msgs_from_RialtoParachain_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_to_RialtoParachain_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"}", "hide": false, "interval": "", "legendFormat": "With-Rialto relay account reward", @@ -270,7 +270,7 @@ }, { "exemplar": true, - "expr": "at_Millau_relay_RialtoParachainMessages_balance{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_from_RialtoParachain_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_to_RialtoParachain_on_lane_00000000{instance=\"relay-millau-rialto-parachain-1:9616\"}", + "expr": "at_Millau_relay_RialtoParachainMessages_balance{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_from_RialtoParachain_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"} + at_Millau_relay_RialtoParachainMessages_reward_for_msgs_to_RialtoParachain_on_lane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de{instance=\"relay-millau-rialto-parachain-1:9616\"}", "hide": false, "interval": "", "legendFormat": "With-Rialto relay account total balance (balance + reward)", @@ -404,7 +404,7 @@ "steppedLine": false, "targets": [ { - "expr": "RialtoParachain_to_Millau_MessageLane_00000000_is_source_and_source_at_target_using_different_forks{instance=\"relay-millau-rialto-parachain-1:9616\"} OR on() vector(0)", + "expr": "RialtoParachain_to_Millau_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_is_source_and_source_at_target_using_different_forks{instance=\"relay-millau-rialto-parachain-1:9616\"} OR on() vector(0)", "instant": false, "interval": "", "legendFormat": "On different forks?", @@ -538,7 +538,7 @@ "steppedLine": false, "targets": [ { - "expr": "Millau_to_RialtoParachain_MessageLane_00000000_is_source_and_source_at_target_using_different_forks{instance=\"relay-millau-rialto-parachain-1:9616\"} OR on() vector(0)", + "expr": "Millau_to_RialtoParachain_MessageLane_0x6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de_is_source_and_source_at_target_using_different_forks{instance=\"relay-millau-rialto-parachain-1:9616\"} OR on() vector(0)", "interval": "", "legendFormat": "On different forks?", "refId": "A" diff --git a/deployments/bridges/rialto-parachain-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh b/deployments/bridges/rialto-parachain-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh index c09116a1614..80208dc752b 100755 --- a/deployments/bridges/rialto-parachain-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh +++ b/deployments/bridges/rialto-parachain-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh @@ -9,7 +9,6 @@ set -eu # Max delay before submitting transactions (s) MAX_SUBMIT_DELAY_S=${MSG_EXCHANGE_GEN_MAX_SUBMIT_DELAY_S:-30} -MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000} MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE=1024 SHARED_CMD="/home/user/substrate-relay send-message rialto-parachain-to-millau" diff --git a/deployments/bridges/rialto-parachain-millau/entrypoints/relay-millau-rialto-parachain-entrypoint.sh b/deployments/bridges/rialto-parachain-millau/entrypoints/relay-millau-rialto-parachain-entrypoint.sh index 7685f5f5ec2..caa3ebb7ceb 100755 --- a/deployments/bridges/rialto-parachain-millau/entrypoints/relay-millau-rialto-parachain-entrypoint.sh +++ b/deployments/bridges/rialto-parachain-millau/entrypoints/relay-millau-rialto-parachain-entrypoint.sh @@ -7,6 +7,10 @@ MILLAU_RELAY_ACCOUNT=${EXT_MILLAU_RELAY_ACCOUNT:-//RialtoParachain.HeadersAndMes MILLAU_RELAY_ACCOUNT_HEADERS_OVERRIDE=${EXT_MILLAU_RELAY_ACCOUNT_HEADERS_OVERRIDE:-//RialtoParachain.RialtoHeadersRelay1} RIALTO_PARACHAIN_RELAY_ACCOUNT=${EXT_RIALTO_PARACHAIN_RELAY_ACCOUNT:-//Millau.HeadersAndMessagesRelay1} +# see `rialto_parachain_millau_bridge_identifier_did_not_changed` test in `millau-runtime` crate for +# details on how this lane is computed +MESSAGE_LANE="6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de" + /home/user/substrate-relay init-bridge millau-to-rialto-parachain \ --source-host millau-node-alice \ --source-port 9944 \ @@ -35,5 +39,5 @@ exec /home/user/substrate-relay relay-headers-and-messages millau-rialto-paracha --rialto-parachain-transactions-mortality=64 \ --rialto-host rialto-node-alice \ --rialto-port 9944 \ - --lane=00000000 \ + --lane=$MESSAGE_LANE \ --prometheus-host=0.0.0.0 diff --git a/deployments/local-scripts/relay-messages-millau-to-rialto.sh b/deployments/local-scripts/relay-messages-millau-to-rialto.sh index d420dc56c26..90f9c8c9dd7 100755 --- a/deployments/local-scripts/relay-messages-millau-to-rialto.sh +++ b/deployments/local-scripts/relay-messages-millau-to-rialto.sh @@ -10,7 +10,7 @@ RIALTO_PORT="${RIALTO_PORT:-9944}" RUST_LOG=bridge=debug \ ./target/debug/substrate-relay relay-messages millau-to-rialto \ - --lane 00000000 \ + --lane "52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7" \ --source-host localhost \ --source-port $MILLAU_PORT \ --source-signer //Bob \ diff --git a/deployments/local-scripts/relay-messages-rialto-to-millau.sh b/deployments/local-scripts/relay-messages-rialto-to-millau.sh index 0cd73c00454..03791d41352 100755 --- a/deployments/local-scripts/relay-messages-rialto-to-millau.sh +++ b/deployments/local-scripts/relay-messages-rialto-to-millau.sh @@ -10,7 +10,7 @@ RIALTO_PORT="${RIALTO_PORT:-9944}" RUST_LOG=bridge=debug \ ./target/debug/substrate-relay relay-messages rialto-to-millau \ - --lane 00000000 \ + --lane "52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7" \ --source-host localhost \ --source-port $RIALTO_PORT \ --source-signer //Bob \ diff --git a/modules/messages/src/benchmarking.rs b/modules/messages/src/benchmarking.rs index e68911f8aa1..a12a84546f8 100644 --- a/modules/messages/src/benchmarking.rs +++ b/modules/messages/src/benchmarking.rs @@ -74,10 +74,8 @@ pub struct MessageDeliveryProofParams { /// Trait that must be implemented by runtime. pub trait Config: crate::Config { /// Lane id to use in benchmarks. - /// - /// By default, lane 00000000 is used. fn bench_lane_id() -> LaneId { - LaneId([0, 0, 0, 0]) + LaneId::new(1, 2) } /// Return id of relayer account at the bridged chain. diff --git a/modules/messages/src/inbound_lane.rs b/modules/messages/src/inbound_lane.rs index 5df48cad0ba..41d00b91627 100644 --- a/modules/messages/src/inbound_lane.rs +++ b/modules/messages/src/inbound_lane.rs @@ -216,15 +216,7 @@ impl InboundLane { #[cfg(test)] mod tests { use super::*; - use crate::{ - inbound_lane, - tests::mock::{ - dispatch_result, inbound_message_data, inbound_unrewarded_relayers_state, run_test, - unrewarded_relayer, BridgedChain, TestMessageDispatch, TestRuntime, REGULAR_PAYLOAD, - TEST_LANE_ID, TEST_RELAYER_A, TEST_RELAYER_B, TEST_RELAYER_C, - }, - RuntimeInboundLaneStorage, - }; + use crate::{inbound_lane, tests::mock::*, RuntimeInboundLaneStorage}; use bp_messages::UnrewardedRelayersState; fn receive_regular_message( @@ -244,7 +236,7 @@ mod tests { #[test] fn receive_status_update_ignores_status_from_the_future() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); receive_regular_message(&mut lane, 1); assert_eq!( lane.receive_state_update(OutboundLaneData { @@ -261,7 +253,7 @@ mod tests { #[test] fn receive_status_update_ignores_obsolete_status() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); receive_regular_message(&mut lane, 1); receive_regular_message(&mut lane, 2); receive_regular_message(&mut lane, 3); @@ -288,7 +280,7 @@ mod tests { #[test] fn receive_status_update_works() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); receive_regular_message(&mut lane, 1); receive_regular_message(&mut lane, 2); receive_regular_message(&mut lane, 3); @@ -326,7 +318,7 @@ mod tests { #[test] fn receive_status_update_works_with_batches_from_relayers() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); let mut seed_storage_data = lane.storage.data(); // Prepare data seed_storage_data.last_confirmed_nonce = 0; @@ -357,7 +349,7 @@ mod tests { #[test] fn fails_to_receive_message_with_incorrect_nonce() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); assert_eq!( lane.receive_message::( &TEST_RELAYER_A, @@ -373,7 +365,7 @@ mod tests { #[test] fn fails_to_receive_messages_above_unrewarded_relayer_entries_limit_per_lane() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); let max_nonce = BridgedChain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; for current_nonce in 1..max_nonce + 1 { assert_eq!( @@ -409,7 +401,7 @@ mod tests { #[test] fn fails_to_receive_messages_above_unconfirmed_messages_limit_per_lane() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); let max_nonce = BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; for current_nonce in 1..=max_nonce { assert_eq!( @@ -445,7 +437,7 @@ mod tests { #[test] fn correctly_receives_following_messages_from_two_relayers_alternately() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); assert_eq!( lane.receive_message::( &TEST_RELAYER_A, @@ -484,7 +476,7 @@ mod tests { #[test] fn rejects_same_message_from_two_different_relayers() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); assert_eq!( lane.receive_message::( &TEST_RELAYER_A, @@ -507,7 +499,7 @@ mod tests { #[test] fn correct_message_is_processed_instantly() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); receive_regular_message(&mut lane, 1); assert_eq!(lane.storage.data().last_delivered_nonce(), 1); }); @@ -516,7 +508,7 @@ mod tests { #[test] fn unspent_weight_is_returned_by_receive_message() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); let mut payload = REGULAR_PAYLOAD; *payload.dispatch_result.unspent_weight.ref_time_mut() = 1; assert_eq!( @@ -533,7 +525,7 @@ mod tests { #[test] fn first_message_is_confirmed_correctly() { run_test(|| { - let mut lane = inbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = inbound_lane::(test_lane_id()).unwrap(); receive_regular_message(&mut lane, 1); receive_regular_message(&mut lane, 2); assert_eq!( @@ -544,7 +536,7 @@ mod tests { Some(1), ); assert_eq!( - inbound_unrewarded_relayers_state(TEST_LANE_ID), + inbound_unrewarded_relayers_state(test_lane_id()), UnrewardedRelayersState { unrewarded_relayer_entries: 1, messages_in_oldest_entry: 1, diff --git a/modules/messages/src/outbound_lane.rs b/modules/messages/src/outbound_lane.rs index 92a356a0a66..559328163ba 100644 --- a/modules/messages/src/outbound_lane.rs +++ b/modules/messages/src/outbound_lane.rs @@ -192,13 +192,7 @@ fn ensure_unrewarded_relayers_are_correct( #[cfg(test)] mod tests { use super::*; - use crate::{ - outbound_lane, - tests::mock::{ - outbound_message_data, run_test, unrewarded_relayer, TestRelayer, TestRuntime, - REGULAR_PAYLOAD, TEST_LANE_ID, - }, - }; + use crate::{outbound_lane, tests::mock::*}; use frame_support::assert_ok; use sp_std::ops::RangeInclusive; @@ -219,7 +213,7 @@ mod tests { relayers: &VecDeque>, ) -> Result, ReceivalConfirmationError> { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); @@ -235,7 +229,7 @@ mod tests { #[test] fn send_message_works() { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_eq!(lane.storage.data().latest_generated_nonce, 0); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(1)); assert!(lane.storage.message(&1).is_some()); @@ -246,7 +240,7 @@ mod tests { #[test] fn confirm_delivery_works() { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(1)); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(2)); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(3)); @@ -266,7 +260,7 @@ mod tests { #[test] fn confirm_partial_delivery_works() { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(1)); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(2)); assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(3)); @@ -295,7 +289,7 @@ mod tests { #[test] fn confirm_delivery_rejects_nonce_lesser_than_latest_received() { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); @@ -375,7 +369,7 @@ mod tests { #[test] fn confirm_delivery_detects_when_more_than_expected_messages_are_confirmed() { run_test(|| { - let mut lane = outbound_lane::(TEST_LANE_ID).unwrap(); + let mut lane = outbound_lane::(test_lane_id()).unwrap(); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); diff --git a/modules/messages/src/proofs.rs b/modules/messages/src/proofs.rs index 0e5edac635e..db80952b634 100644 --- a/modules/messages/src/proofs.rs +++ b/modules/messages/src/proofs.rs @@ -184,7 +184,7 @@ mod tests { test: impl Fn(FromBridgedChainMessagesProof) -> R, ) -> R { let (state_root, storage) = prepare_messages_storage_proof::( - TEST_LANE_ID, + test_lane_id(), 1..=nonces_end, outbound_lane_data, bp_runtime::StorageProofSize::Minimal(0), @@ -216,7 +216,7 @@ mod tests { test(FromBridgedChainMessagesProof { bridged_header_hash, storage, - lane: TEST_LANE_ID, + lane: test_lane_id(), nonces_start: 1, nonces_end, }) @@ -442,7 +442,7 @@ mod tests { |proof| verify_messages_proof::(proof, 0), ), Ok(vec![( - TEST_LANE_ID, + test_lane_id(), ProvedLaneMessages { lane_state: Some(OutboundLaneData { state: LaneState::Opened, @@ -476,7 +476,7 @@ mod tests { |proof| verify_messages_proof::(proof, 1), ), Ok(vec![( - TEST_LANE_ID, + test_lane_id(), ProvedLaneMessages { lane_state: Some(OutboundLaneData { state: LaneState::Opened, @@ -485,7 +485,7 @@ mod tests { latest_generated_nonce: 1, }), messages: vec![Message { - key: MessageKey { lane_id: TEST_LANE_ID, nonce: 1 }, + key: MessageKey { lane_id: test_lane_id(), nonce: 1 }, payload: vec![42], }], }, diff --git a/modules/messages/src/tests/mock.rs b/modules/messages/src/tests/mock.rs index 2a73f2df966..2f5b11b4a8e 100644 --- a/modules/messages/src/tests/mock.rs +++ b/modules/messages/src/tests/mock.rs @@ -252,7 +252,7 @@ impl Config for TestRuntime { #[cfg(feature = "runtime-benchmarks")] impl crate::benchmarking::Config<()> for TestRuntime { fn bench_lane_id() -> LaneId { - TEST_LANE_ID + test_lane_id() } fn prepare_message_proof( @@ -303,13 +303,19 @@ pub const TEST_RELAYER_B: AccountId = 101; pub const TEST_RELAYER_C: AccountId = 102; /// Lane that we're using in tests. -pub const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 1]); +pub fn test_lane_id() -> LaneId { + LaneId::new(1, 2) +} /// Lane that is completely unknown to our runtime. -pub const UNKNOWN_LANE_ID: LaneId = LaneId([0, 0, 0, 2]); +pub fn unknown_lane_id() -> LaneId { + LaneId::new(1, 3) +} /// Lane that is registered, but it is closed. -pub const CLOSED_LANE_ID: LaneId = LaneId([0, 0, 0, 3]); +pub fn closed_lane_id() -> LaneId { + LaneId::new(1, 4) +} /// Regular message payload. pub const REGULAR_PAYLOAD: TestPayload = message_payload(0, 50); @@ -401,7 +407,7 @@ impl MessageDispatch for TestMessageDispatch { /// Return test lane message with given nonce and payload. pub fn message(nonce: MessageNonce, payload: TestPayload) -> Message { - Message { key: MessageKey { lane_id: TEST_LANE_ID, nonce }, payload: payload.encode() } + Message { key: MessageKey { lane_id: test_lane_id(), nonce }, payload: payload.encode() } } /// Return valid outbound message data, constructed from given payload. @@ -461,14 +467,14 @@ pub fn new_test_ext() -> sp_io::TestExternalities { /// Run pallet test. pub fn run_test(test: impl FnOnce() -> T) -> T { new_test_ext().execute_with(|| { - crate::InboundLanes::::insert(TEST_LANE_ID, InboundLaneData::opened()); - crate::OutboundLanes::::insert(TEST_LANE_ID, OutboundLaneData::opened()); + crate::InboundLanes::::insert(test_lane_id(), InboundLaneData::opened()); + crate::OutboundLanes::::insert(test_lane_id(), OutboundLaneData::opened()); crate::InboundLanes::::insert( - CLOSED_LANE_ID, + closed_lane_id(), InboundLaneData { state: LaneState::Closed, ..Default::default() }, ); crate::OutboundLanes::::insert( - CLOSED_LANE_ID, + closed_lane_id(), OutboundLaneData { state: LaneState::Closed, ..Default::default() }, ); test() diff --git a/modules/messages/src/tests/pallet_tests.rs b/modules/messages/src/tests/pallet_tests.rs index 5387cb9ee97..eddb81801cb 100644 --- a/modules/messages/src/tests/pallet_tests.rs +++ b/modules/messages/src/tests/pallet_tests.rs @@ -50,12 +50,12 @@ fn get_ready_for_events() { fn send_regular_message() { get_ready_for_events(); - let message_nonce = outbound_lane::(TEST_LANE_ID) + let message_nonce = outbound_lane::(test_lane_id()) .unwrap() .data() .latest_generated_nonce + 1; - send_message::(TEST_LANE_ID, REGULAR_PAYLOAD) + send_message::(test_lane_id(), REGULAR_PAYLOAD) .expect("send_message has failed"); // check event with assigned nonce @@ -64,7 +64,7 @@ fn send_regular_message() { vec![EventRecord { phase: Phase::Initialization, event: TestEvent::Messages(Event::MessageAccepted { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), nonce: message_nonce }), topics: vec![], @@ -79,7 +79,7 @@ fn receive_messages_delivery_proof() { assert_ok!(Pallet::::receive_messages_delivery_proof( RuntimeOrigin::signed(1), prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 1, @@ -103,7 +103,7 @@ fn receive_messages_delivery_proof() { vec![EventRecord { phase: Phase::Initialization, event: TestEvent::Messages(Event::MessagesDelivered { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), messages: DeliveredMessages::new(1), }), topics: vec![], @@ -122,7 +122,7 @@ fn pallet_rejects_transactions_if_halted() { )); assert_noop!( - send_message::(TEST_LANE_ID, REGULAR_PAYLOAD,), + send_message::(test_lane_id(), REGULAR_PAYLOAD,), Error::::NotOperatingNormally, ); @@ -139,7 +139,7 @@ fn pallet_rejects_transactions_if_halted() { ); let delivery_proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 1, @@ -173,7 +173,7 @@ fn pallet_rejects_new_messages_in_rejecting_outbound_messages_operating_mode() { ); assert_noop!( - send_message::(TEST_LANE_ID, REGULAR_PAYLOAD,), + send_message::(test_lane_id(), REGULAR_PAYLOAD,), Error::::NotOperatingNormally, ); @@ -188,7 +188,7 @@ fn pallet_rejects_new_messages_in_rejecting_outbound_messages_operating_mode() { assert_ok!(Pallet::::receive_messages_delivery_proof( RuntimeOrigin::signed(1), prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 1, @@ -223,7 +223,7 @@ fn send_message_rejects_too_large_message() { .extra .extend_from_slice(&vec![0u8; max_outbound_payload_size as usize]); assert_noop!( - send_message::(TEST_LANE_ID, message_payload.clone(),), + send_message::(test_lane_id(), message_payload.clone(),), Error::::MessageRejectedByPallet(VerificationError::MessageTooLarge), ); @@ -232,7 +232,7 @@ fn send_message_rejects_too_large_message() { message_payload.extra.pop(); } assert_eq!(message_payload.encoded_size() as u32, max_outbound_payload_size); - assert_ok!(send_message::(TEST_LANE_ID, message_payload,),); + assert_ok!(send_message::(test_lane_id(), message_payload,),); }) } @@ -248,7 +248,10 @@ fn receive_messages_proof_works() { )); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().0.last_delivered_nonce(), + InboundLanes::::get(test_lane_id()) + .unwrap() + .0 + .last_delivered_nonce(), 1 ); @@ -261,7 +264,7 @@ fn receive_messages_proof_updates_confirmed_message_nonce() { run_test(|| { // say we have received 10 messages && last confirmed message is 8 InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 8, @@ -273,7 +276,7 @@ fn receive_messages_proof_updates_confirmed_message_nonce() { }, ); assert_eq!( - inbound_unrewarded_relayers_state(TEST_LANE_ID), + inbound_unrewarded_relayers_state(test_lane_id()), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, @@ -295,7 +298,7 @@ fn receive_messages_proof_updates_confirmed_message_nonce() { )); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().0, + InboundLanes::::get(test_lane_id()).unwrap().0, InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 9, @@ -307,7 +310,7 @@ fn receive_messages_proof_updates_confirmed_message_nonce() { }, ); assert_eq!( - inbound_unrewarded_relayers_state(TEST_LANE_ID), + inbound_unrewarded_relayers_state(test_lane_id()), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, @@ -336,7 +339,7 @@ fn receive_messages_proof_does_not_accept_message_if_dispatch_weight_is_not_enou Error::::InsufficientDispatchWeight ); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().last_delivered_nonce(), + InboundLanes::::get(test_lane_id()).unwrap().last_delivered_nonce(), 0 ); }); @@ -385,7 +388,7 @@ fn receive_messages_delivery_proof_works() { receive_messages_delivery_proof(); assert_eq!( - OutboundLanes::::get(TEST_LANE_ID) + OutboundLanes::::get(test_lane_id()) .unwrap() .latest_received_nonce, 1, @@ -396,12 +399,12 @@ fn receive_messages_delivery_proof_works() { #[test] fn receive_messages_delivery_proof_rewards_relayers() { run_test(|| { - assert_ok!(send_message::(TEST_LANE_ID, REGULAR_PAYLOAD,)); - assert_ok!(send_message::(TEST_LANE_ID, REGULAR_PAYLOAD,)); + assert_ok!(send_message::(test_lane_id(), REGULAR_PAYLOAD,)); + assert_ok!(send_message::(test_lane_id(), REGULAR_PAYLOAD,)); // this reports delivery of message 1 => reward is paid to TEST_RELAYER_A let single_message_delivery_proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { relayers: vec![unrewarded_relayer(1, 1, TEST_RELAYER_A)].into(), ..Default::default() @@ -436,7 +439,7 @@ fn receive_messages_delivery_proof_rewards_relayers() { // this reports delivery of both message 1 and message 2 => reward is paid only to // TEST_RELAYER_B let two_messages_delivery_proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { relayers: vec![ unrewarded_relayer(1, 1, TEST_RELAYER_A), @@ -479,8 +482,8 @@ fn receive_messages_delivery_proof_rewards_relayers() { #[test] fn receive_messages_delivery_proof_rejects_invalid_proof() { run_test(|| { - let mut proof = prepare_messages_delivery_proof(TEST_LANE_ID, Default::default()); - proof.lane = bp_messages::LaneId([42, 42, 42, 42]); + let mut proof = prepare_messages_delivery_proof(test_lane_id(), Default::default()); + proof.lane = bp_messages::LaneId::new(42, 84); assert_noop!( Pallet::::receive_messages_delivery_proof( @@ -498,7 +501,7 @@ fn receive_messages_delivery_proof_rejects_proof_if_declared_relayers_state_is_i run_test(|| { // when number of relayers entries is invalid let proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { relayers: vec![ unrewarded_relayer(1, 1, TEST_RELAYER_A), @@ -524,7 +527,7 @@ fn receive_messages_delivery_proof_rejects_proof_if_declared_relayers_state_is_i // when number of messages is invalid let proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { relayers: vec![ unrewarded_relayer(1, 1, TEST_RELAYER_A), @@ -550,7 +553,7 @@ fn receive_messages_delivery_proof_rejects_proof_if_declared_relayers_state_is_i // when last delivered nonce is invalid let proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { relayers: vec![ unrewarded_relayer(1, 1, TEST_RELAYER_A), @@ -592,7 +595,7 @@ fn receive_messages_accepts_single_message_with_invalid_payload() { ),); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().last_delivered_nonce(), + InboundLanes::::get(test_lane_id()).unwrap().last_delivered_nonce(), 1, ); }); @@ -616,7 +619,7 @@ fn receive_messages_accepts_batch_with_message_with_invalid_payload() { ),); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().last_delivered_nonce(), + InboundLanes::::get(test_lane_id()).unwrap().last_delivered_nonce(), 3, ); }); @@ -642,7 +645,7 @@ fn actual_dispatch_weight_does_not_overlow() { Error::::InsufficientDispatchWeight ); assert_eq!( - InboundLanes::::get(TEST_LANE_ID).unwrap().last_delivered_nonce(), + InboundLanes::::get(test_lane_id()).unwrap().last_delivered_nonce(), 0 ); }); @@ -721,7 +724,7 @@ fn proof_size_refund_from_receive_messages_proof_works() { REGULAR_PAYLOAD.declared_weight, ); InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), StoredInboundLaneData(InboundLaneData { state: LaneState::Opened, relayers: vec![ @@ -750,7 +753,7 @@ fn proof_size_refund_from_receive_messages_proof_works() { // if count of unrewarded relayer entries is less than maximal, then some `proof_size` // must be refunded InboundLanes::::insert( - TEST_LANE_ID, + test_lane_id(), StoredInboundLaneData(InboundLaneData { state: LaneState::Opened, relayers: vec![ @@ -797,7 +800,7 @@ fn receive_messages_delivery_proof_rejects_proof_if_trying_to_confirm_more_messa // 4) so the number of declared messages (see `UnrewardedRelayersState`) is `0` and // numer of actually confirmed messages is `1`. let proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 1, @@ -826,20 +829,20 @@ fn storage_keys_computed_properly() { assert_eq!( OutboundMessages::::storage_map_final_key(MessageKey { - lane_id: TEST_LANE_ID, + lane_id: test_lane_id(), nonce: 42 }), - bp_messages::storage_keys::message_key("Messages", &TEST_LANE_ID, 42).0, + bp_messages::storage_keys::message_key("Messages", &test_lane_id(), 42).0, ); assert_eq!( - OutboundLanes::::storage_map_final_key(TEST_LANE_ID), - bp_messages::storage_keys::outbound_lane_data_key("Messages", &TEST_LANE_ID).0, + OutboundLanes::::storage_map_final_key(test_lane_id()), + bp_messages::storage_keys::outbound_lane_data_key("Messages", &test_lane_id()).0, ); assert_eq!( - InboundLanes::::storage_map_final_key(TEST_LANE_ID), - bp_messages::storage_keys::inbound_lane_data_key("Messages", &TEST_LANE_ID).0, + InboundLanes::::storage_map_final_key(test_lane_id()), + bp_messages::storage_keys::inbound_lane_data_key("Messages", &test_lane_id()).0, ); } @@ -848,7 +851,7 @@ fn inbound_message_details_works() { run_test(|| { assert_eq!( Pallet::::inbound_message_data( - TEST_LANE_ID, + test_lane_id(), REGULAR_PAYLOAD.encode(), OutboundMessageDetails { nonce: 0, dispatch_weight: Weight::zero(), size: 0 }, ), @@ -863,7 +866,7 @@ fn test_bridge_messages_call_is_correctly_defined() { let account_id = 1; let message_proof = prepare_messages_proof(vec![message(1, REGULAR_PAYLOAD)], None); let message_delivery_proof = prepare_messages_delivery_proof( - TEST_LANE_ID, + test_lane_id(), InboundLaneData { state: LaneState::Opened, last_confirmed_nonce: 1, @@ -935,7 +938,7 @@ fn inbound_storage_extra_proof_size_bytes_works() { fn storage(relayer_entries: usize) -> RuntimeInboundLaneStorage { RuntimeInboundLaneStorage { - lane_id: Default::default(), + lane_id: LaneId::new(1, 2), cached_data: InboundLaneData { state: LaneState::Opened, relayers: vec![relayer_entry(); relayer_entries].into(), @@ -969,12 +972,12 @@ fn inbound_storage_extra_proof_size_bytes_works() { fn send_messages_fails_if_outbound_lane_is_not_opened() { run_test(|| { assert_noop!( - send_message::(UNKNOWN_LANE_ID, REGULAR_PAYLOAD), + send_message::(unknown_lane_id(), REGULAR_PAYLOAD), Error::::UnknownOutboundLane, ); assert_noop!( - send_message::(CLOSED_LANE_ID, REGULAR_PAYLOAD), + send_message::(closed_lane_id(), REGULAR_PAYLOAD), Error::::ClosedOutboundLane, ); }); @@ -984,7 +987,7 @@ fn send_messages_fails_if_outbound_lane_is_not_opened() { fn receive_messages_proof_fails_if_inbound_lane_is_not_opened() { run_test(|| { let mut message = message(1, REGULAR_PAYLOAD); - message.key.lane_id = UNKNOWN_LANE_ID; + message.key.lane_id = unknown_lane_id(); let proof = prepare_messages_proof(vec![message.clone()], None); assert_noop!( @@ -998,7 +1001,7 @@ fn receive_messages_proof_fails_if_inbound_lane_is_not_opened() { Error::::UnknownInboundLane, ); - message.key.lane_id = CLOSED_LANE_ID; + message.key.lane_id = closed_lane_id(); let proof = prepare_messages_proof(vec![message], None); assert_noop!( @@ -1032,7 +1035,7 @@ fn receive_messages_delivery_proof_fails_if_outbound_lane_is_unknown() { ) }; - let proof = make_proof(UNKNOWN_LANE_ID); + let proof = make_proof(unknown_lane_id()); assert_noop!( Pallet::::receive_messages_delivery_proof( RuntimeOrigin::signed(1), @@ -1047,7 +1050,7 @@ fn receive_messages_delivery_proof_fails_if_outbound_lane_is_unknown() { Error::::UnknownOutboundLane, ); - let proof = make_proof(CLOSED_LANE_ID); + let proof = make_proof(closed_lane_id()); assert_noop!( Pallet::::receive_messages_delivery_proof( RuntimeOrigin::signed(1), diff --git a/modules/relayers/src/benchmarking.rs b/modules/relayers/src/benchmarking.rs index d66a11ff06d..69357aebbae 100644 --- a/modules/relayers/src/benchmarking.rs +++ b/modules/relayers/src/benchmarking.rs @@ -43,7 +43,7 @@ pub trait Config: crate::Config { benchmarks! { // Benchmark `claim_rewards` call. claim_rewards { - let lane = LaneId([0, 0, 0, 0]); + let lane = LaneId::new(1, 2); let account_params = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); let relayer: T::AccountId = whitelisted_caller(); @@ -102,7 +102,7 @@ benchmarks! { crate::Pallet::::register(RawOrigin::Signed(relayer.clone()).into(), valid_till).unwrap(); // create slash destination account - let lane = LaneId([0, 0, 0, 0]); + let lane = LaneId::new(1, 2); let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); T::prepare_rewards_account(slash_destination.clone(), Zero::zero()); }: { @@ -116,7 +116,7 @@ benchmarks! { // the weight of message delivery call if `RefundBridgedParachainMessages` signed extension // is deployed at runtime level. register_relayer_reward { - let lane = LaneId([0, 0, 0, 0]); + let lane = LaneId::new(1, 2); let relayer: T::AccountId = whitelisted_caller(); let account_params = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); diff --git a/modules/relayers/src/lib.rs b/modules/relayers/src/lib.rs index aac31e008fc..27803b73771 100644 --- a/modules/relayers/src/lib.rs +++ b/modules/relayers/src/lib.rs @@ -476,7 +476,7 @@ mod tests { assert_noop!( Pallet::::claim_rewards( RuntimeOrigin::root(), - TEST_REWARDS_ACCOUNT_PARAMS + test_reward_account_param() ), DispatchError::BadOrigin, ); @@ -489,7 +489,7 @@ mod tests { assert_noop!( Pallet::::claim_rewards( RuntimeOrigin::signed(REGULAR_RELAYER), - TEST_REWARDS_ACCOUNT_PARAMS + test_reward_account_param() ), Error::::NoRewardForRelayer, ); @@ -501,13 +501,13 @@ mod tests { run_test(|| { RelayerRewards::::insert( FAILING_RELAYER, - TEST_REWARDS_ACCOUNT_PARAMS, + test_reward_account_param(), 100, ); assert_noop!( Pallet::::claim_rewards( RuntimeOrigin::signed(FAILING_RELAYER), - TEST_REWARDS_ACCOUNT_PARAMS + test_reward_account_param() ), Error::::FailedToPayReward, ); @@ -521,15 +521,15 @@ mod tests { RelayerRewards::::insert( REGULAR_RELAYER, - TEST_REWARDS_ACCOUNT_PARAMS, + test_reward_account_param(), 100, ); assert_ok!(Pallet::::claim_rewards( RuntimeOrigin::signed(REGULAR_RELAYER), - TEST_REWARDS_ACCOUNT_PARAMS + test_reward_account_param() )); assert_eq!( - RelayerRewards::::get(REGULAR_RELAYER, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(REGULAR_RELAYER, test_reward_account_param()), None ); @@ -540,7 +540,7 @@ mod tests { phase: Phase::Initialization, event: TestEvent::Relayers(RewardPaid { relayer: REGULAR_RELAYER, - rewards_account_params: TEST_REWARDS_ACCOUNT_PARAMS, + rewards_account_params: test_reward_account_param(), reward: 100 }), topics: vec![], @@ -556,12 +556,12 @@ mod tests { run_test(|| { let in_lane_0 = RewardsAccountParams::new( - LaneId([0, 0, 0, 0]), + LaneId::new(1, 2), *b"test", RewardsAccountOwner::ThisChain, ); let out_lane_1 = RewardsAccountParams::new( - LaneId([0, 0, 0, 1]), + LaneId::new(1, 3), *b"test", RewardsAccountOwner::BridgedChain, ); diff --git a/modules/relayers/src/mock.rs b/modules/relayers/src/mock.rs index d8c5bd90967..9e0274cecfa 100644 --- a/modules/relayers/src/mock.rs +++ b/modules/relayers/src/mock.rs @@ -131,10 +131,6 @@ impl pallet_bridge_relayers::benchmarking::Config for TestRuntime { } } -/// Message lane that we're using in tests. -pub const TEST_REWARDS_ACCOUNT_PARAMS: RewardsAccountParams = - RewardsAccountParams::new(LaneId([0, 0, 0, 0]), *b"test", RewardsAccountOwner::ThisChain); - /// Regular relayer that may receive rewards. pub const REGULAR_RELAYER: AccountId = 1; @@ -168,6 +164,11 @@ impl PaymentProcedure for TestPaymentProcedure { } } +/// Reward account params that we are using in tests. +pub fn test_reward_account_param() -> RewardsAccountParams { + RewardsAccountParams::new(LaneId::new(1, 2), *b"test", RewardsAccountOwner::ThisChain) +} + /// Return test externalities to use in tests. pub fn new_test_ext() -> sp_io::TestExternalities { let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); diff --git a/modules/relayers/src/payment_adapter.rs b/modules/relayers/src/payment_adapter.rs index 7415cfa22af..f2b81bd1546 100644 --- a/modules/relayers/src/payment_adapter.rs +++ b/modules/relayers/src/payment_adapter.rs @@ -117,16 +117,16 @@ mod tests { register_relayers_rewards::( &RELAYER_2, relayers_rewards(), - TEST_REWARDS_ACCOUNT_PARAMS, + test_reward_account_param(), 50, ); assert_eq!( - RelayerRewards::::get(RELAYER_1, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(RELAYER_1, test_reward_account_param()), Some(100) ); assert_eq!( - RelayerRewards::::get(RELAYER_2, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(RELAYER_2, test_reward_account_param()), Some(150) ); }); @@ -138,20 +138,20 @@ mod tests { register_relayers_rewards::( &RELAYER_3, relayers_rewards(), - TEST_REWARDS_ACCOUNT_PARAMS, + test_reward_account_param(), 50, ); assert_eq!( - RelayerRewards::::get(RELAYER_1, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(RELAYER_1, test_reward_account_param()), Some(100) ); assert_eq!( - RelayerRewards::::get(RELAYER_2, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(RELAYER_2, test_reward_account_param()), Some(150) ); assert_eq!( - RelayerRewards::::get(RELAYER_3, TEST_REWARDS_ACCOUNT_PARAMS), + RelayerRewards::::get(RELAYER_3, test_reward_account_param()), None ); }); diff --git a/modules/relayers/src/stake_adapter.rs b/modules/relayers/src/stake_adapter.rs index 055b6a111ec..bdb66b007c5 100644 --- a/modules/relayers/src/stake_adapter.rs +++ b/modules/relayers/src/stake_adapter.rs @@ -127,7 +127,7 @@ mod tests { #[test] fn repatriate_reserved_works() { run_test(|| { - let beneficiary = TEST_REWARDS_ACCOUNT_PARAMS; + let beneficiary = test_reward_account_param(); let beneficiary_account = TestPaymentProcedure::rewards_account(beneficiary); let mut expected_balance = ExistentialDeposit::get(); @@ -171,7 +171,7 @@ mod tests { #[test] fn repatriate_reserved_doesnt_work_when_beneficiary_account_is_missing() { run_test(|| { - let beneficiary = TEST_REWARDS_ACCOUNT_PARAMS; + let beneficiary = test_reward_account_param(); let beneficiary_account = TestPaymentProcedure::rewards_account(beneficiary); Balances::mint_into(&3, test_stake() * 2).unwrap(); diff --git a/primitives/messages/Cargo.toml b/primitives/messages/Cargo.toml index f056c1f033c..d7525da8b54 100644 --- a/primitives/messages/Cargo.toml +++ b/primitives/messages/Cargo.toml @@ -20,6 +20,7 @@ bp-header-chain = { path = "../header-chain", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [dev-dependencies] @@ -36,5 +37,6 @@ std = [ "scale-info/std", "serde/std", "sp-core/std", + "sp-io/std", "sp-std/std" ] diff --git a/primitives/messages/src/lib.rs b/primitives/messages/src/lib.rs index 6d0bba21e64..a2022342b2a 100644 --- a/primitives/messages/src/lib.rs +++ b/primitives/messages/src/lib.rs @@ -32,7 +32,8 @@ pub use frame_support::weights::Weight; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use source_chain::RelayersRewards; -use sp_core::TypeId; +use sp_core::{TypeId, H256}; +use sp_io::hashing::blake2_256; use sp_std::{collections::vec_deque::VecDeque, ops::RangeInclusive, prelude::*}; pub mod source_chain; @@ -166,7 +167,24 @@ impl OperatingMode for MessagesOperatingMode { } } -/// Lane id which implements `TypeId`. +/// Bridge lane identifier. +/// +/// Lane connects two endpoints at both sides of the bridge. We assume that every endpoint +/// has its own unique identifier. We want lane identifiers to be the same on the both sides +/// of the bridge (and naturally unique across global consensus if endpoints have unique +/// identifiers). So lane id is the hash (`blake2_256`) of **ordered** encoded locations +/// concatenation (separated by some binary data). I.e.: +/// +/// ```nocompile +/// let endpoint1 = X2(GlobalConsensus(NetworkId::Rococo), Parachain(42)); +/// let endpoint2 = X2(GlobalConsensus(NetworkId::Wococo), Parachain(777)); +/// +/// let final_lane_key = if endpoint1 < endpoint2 { +/// (endpoint1, VALUES_SEPARATOR, endpoint2) +/// } else { +/// (endpoint2, VALUES_SEPARATOR, endpoint1) +/// }.using_encoded(blake2_256); +/// ``` #[derive( Clone, Copy, @@ -182,7 +200,39 @@ impl OperatingMode for MessagesOperatingMode { Serialize, Deserialize, )] -pub struct LaneId(pub [u8; 4]); +pub struct LaneId(H256); + +impl LaneId { + /// Create lane identifier from two locations. + pub fn new(endpoint1: T, endpoint2: T) -> Self { + const VALUES_SEPARATOR: [u8; 31] = *b"bridges-lane-id-value-separator"; + + LaneId( + if endpoint1 < endpoint2 { + (endpoint1, VALUES_SEPARATOR, endpoint2) + } else { + (endpoint2, VALUES_SEPARATOR, endpoint1) + } + .using_encoded(blake2_256) + .into(), + ) + } + + /// Create lane identifier from given hash. + /// + /// There's no `From` implementation for the `LaneId`, because using this conversion + /// in a wrong way (i.e. computing hash of endpoints manually) may lead to issues. So we + /// want the call to be explicit. + pub const fn from_inner(hash: H256) -> Self { + LaneId(hash) + } +} + +impl core::fmt::Display for LaneId { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + self.0.fmt(fmt) + } +} impl core::fmt::Debug for LaneId { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -190,8 +240,8 @@ impl core::fmt::Debug for LaneId { } } -impl AsRef<[u8]> for LaneId { - fn as_ref(&self) -> &[u8] { +impl AsRef for LaneId { + fn as_ref(&self) -> &H256 { &self.0 } } @@ -381,7 +431,7 @@ pub struct UnrewardedRelayer { } /// Received messages with their dispatch result. -#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] +#[derive(Clone, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct ReceivedMessages { /// Id of the lane which is receiving messages. pub lane: LaneId, @@ -669,7 +719,50 @@ mod tests { } #[test] - fn lane_id_debug_format_matches_inner_array_format() { - assert_eq!(format!("{:?}", LaneId([0, 0, 0, 0])), format!("{:?}", [0, 0, 0, 0]),); + fn lane_id_debug_format_matches_inner_hash_format() { + assert_eq!( + format!("{:?}", LaneId(H256::from([1u8; 32]))), + format!("{:?}", H256::from([1u8; 32])), + ); + } + + #[test] + fn lane_id_is_generated_using_ordered_endpoints() { + assert_eq!(LaneId::new(1, 2), LaneId::new(2, 1)); + } + + #[test] + fn lane_id_is_different_for_different_endpoints() { + assert_ne!(LaneId::new(1, 2), LaneId::new(1, 3)); + } + + #[test] + fn lane_id_is_different_even_if_arguments_has_partial_matching_encoding() { + /// Some artificial type that generates the same encoding for different values + /// concatenations. I.e. the encoding for `(Either::Two(1, 2), Either::Two(3, 4))` + /// is the same as encoding of `(Either::Three(1, 2, 3), Either::One(4))`. + /// In practice, this type is not useful, because you can't do a proper decoding. + /// But still there may be some collisions even in proper types. + #[derive(Eq, Ord, PartialEq, PartialOrd)] + enum Either { + Three(u64, u64, u64), + Two(u64, u64), + One(u64), + } + + impl codec::Encode for Either { + fn encode(&self) -> Vec { + match *self { + Self::One(a) => a.encode(), + Self::Two(a, b) => (a, b).encode(), + Self::Three(a, b, c) => (a, b, c).encode(), + } + } + } + + assert_ne!( + LaneId::new(Either::Two(1, 2), Either::Two(3, 4)), + LaneId::new(Either::Three(1, 2, 3), Either::One(4)), + ); } } diff --git a/primitives/messages/src/storage_keys.rs b/primitives/messages/src/storage_keys.rs index 4edf9828cfd..8908432653e 100644 --- a/primitives/messages/src/storage_keys.rs +++ b/primitives/messages/src/storage_keys.rs @@ -91,10 +91,10 @@ mod tests { fn storage_message_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking // all previously crafted messages proofs. - let storage_key = message_key("BridgeMessages", &LaneId(*b"test"), 42).0; + let storage_key = message_key("BridgeMessages", &LaneId::new(1, 2), 42).0; assert_eq!( storage_key, - hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(), + hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea70e9bdb8f50c68d12f06eabb57759ee5eb1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dcf87f9793be208e5ea02a00000000000000").to_vec(), "Unexpected storage key: {}", hex::encode(&storage_key), ); @@ -104,10 +104,10 @@ mod tests { fn outbound_lane_data_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking // all previously crafted outbound lane state proofs. - let storage_key = outbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0; + let storage_key = outbound_lane_data_key("BridgeMessages", &LaneId::new(1, 2)).0; assert_eq!( storage_key, - hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(), + hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1fd3bef8b00df8ca7b01813b5e2741950db1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dcf87f9793be208e5ea0").to_vec(), "Unexpected storage key: {}", hex::encode(&storage_key), ); @@ -117,10 +117,10 @@ mod tests { fn inbound_lane_data_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking // all previously crafted inbound lane state proofs. - let storage_key = inbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0; + let storage_key = inbound_lane_data_key("BridgeMessages", &LaneId::new(1, 2)).0; assert_eq!( storage_key, - hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(), + hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fabd3bef8b00df8ca7b01813b5e2741950db1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dcf87f9793be208e5ea0").to_vec(), "Unexpected storage key: {}", hex::encode(&storage_key), ); diff --git a/primitives/relayers/src/lib.rs b/primitives/relayers/src/lib.rs index dc63f94fbb8..d80e9e0350c 100644 --- a/primitives/relayers/src/lib.rs +++ b/primitives/relayers/src/lib.rs @@ -57,9 +57,12 @@ pub enum RewardsAccountOwner { /// parameters to identify the account that pays a reward to the relayer. #[derive(Copy, Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub struct RewardsAccountParams { - lane_id: LaneId, - bridged_chain_id: ChainId, + // **IMPORTANT NOTE**: the order of fields here matters - we are using + // `into_account_truncating` and lane id is already `32` byte, so if other fields are encoded + // after it, they're simply dropped. So lane id shall be the last field. owner: RewardsAccountOwner, + bridged_chain_id: ChainId, + lane_id: LaneId, } impl RewardsAccountParams { @@ -162,21 +165,21 @@ mod tests { fn different_lanes_are_using_different_accounts() { assert_eq!( PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( - LaneId([0, 0, 0, 0]), + LaneId::new(1, 2), *b"test", RewardsAccountOwner::ThisChain )), - hex_literal::hex!("62726170000000007465737400726577617264732d6163636f756e7400000000") + hex_literal::hex!("627261700074657374b1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dc") .into(), ); assert_eq!( PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( - LaneId([0, 0, 0, 1]), + LaneId::new(1, 3), *b"test", RewardsAccountOwner::ThisChain )), - hex_literal::hex!("62726170000000017465737400726577617264732d6163636f756e7400000000") + hex_literal::hex!("627261700074657374a43e8951aa302c133beb5f85821a21645f07b487270ef3") .into(), ); } @@ -185,21 +188,21 @@ mod tests { fn different_directions_are_using_different_accounts() { assert_eq!( PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( - LaneId([0, 0, 0, 0]), + LaneId::new(1, 2), *b"test", RewardsAccountOwner::ThisChain )), - hex_literal::hex!("62726170000000007465737400726577617264732d6163636f756e7400000000") + hex_literal::hex!("627261700074657374b1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dc") .into(), ); assert_eq!( PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( - LaneId([0, 0, 0, 0]), + LaneId::new(1, 2), *b"test", RewardsAccountOwner::BridgedChain )), - hex_literal::hex!("62726170000000007465737401726577617264732d6163636f756e7400000000") + hex_literal::hex!("627261700174657374b1d3dccd8b3c3a012afe265f3e3c4432129b8aee50c9dc") .into(), ); } diff --git a/relays/bin-substrate/Cargo.toml b/relays/bin-substrate/Cargo.toml index 7b382e7d673..6d309c17ad3 100644 --- a/relays/bin-substrate/Cargo.toml +++ b/relays/bin-substrate/Cargo.toml @@ -16,6 +16,7 @@ log = "0.4.19" num-format = "0.4" num-traits = "0.2" rbtag = "0.3" +rustc-hex = "2.1" structopt = "0.3" signal-hook = "0.3.15" signal-hook-async-std = "0.2.2" diff --git a/relays/bin-substrate/src/cli/mod.rs b/relays/bin-substrate/src/cli/mod.rs index 87198cb9037..85251d6fdf3 100644 --- a/relays/bin-substrate/src/cli/mod.rs +++ b/relays/bin-substrate/src/cli/mod.rs @@ -24,6 +24,7 @@ use futures::{select, FutureExt}; use rbtag::BuildInfo; use signal_hook::consts::*; use signal_hook_async_std::Signals; +use sp_core::H256; use structopt::{clap::arg_enum, StructOpt}; use strum::{EnumString, EnumVariantNames}; @@ -205,21 +206,19 @@ pub trait CliChain: relay_substrate_client::Chain { /// Lane id. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct HexLaneId(pub [u8; 4]); +pub struct HexLaneId(pub H256); impl From for LaneId { fn from(lane_id: HexLaneId) -> LaneId { - LaneId(lane_id.0) + LaneId::from_inner(lane_id.0) } } impl std::str::FromStr for HexLaneId { - type Err = hex::FromHexError; + type Err = rustc_hex::FromHexError; fn from_str(s: &str) -> Result { - let mut lane_id = [0u8; 4]; - hex::decode_to_slice(s, &mut lane_id)?; - Ok(HexLaneId(lane_id)) + Ok(HexLaneId(H256::from_str(s)?)) } } diff --git a/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs b/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs index bb1e9e5b7b9..6ef9cf2bf05 100644 --- a/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs +++ b/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs @@ -84,7 +84,7 @@ use substrate_relay_helper::{ #[derive(Debug, PartialEq, StructOpt)] pub struct HeadersAndMessagesSharedParams { /// Hex-encoded lane identifiers that should be served by the complex relay. - #[structopt(long, default_value = "00000000")] + #[structopt(long)] pub lane: Vec, /// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set) /// are relayed. @@ -550,6 +550,7 @@ impl RelayHeadersAndMessages { #[cfg(test)] mod tests { use super::*; + use sp_core::H256; #[test] fn should_parse_relay_to_relay_options() { @@ -574,9 +575,9 @@ mod tests { "--rialto-transactions-mortality", "64", "--lane", - "00000000", + "0000000000000000000000000000000000000000000000000000000000000000", "--lane", - "73776170", + "1111111111111111111111111111111111111111111111111111111111111111", "--prometheus-host", "0.0.0.0", ]); @@ -587,8 +588,8 @@ mod tests { RelayHeadersAndMessages::MillauRialto(MillauRialtoHeadersAndMessages { shared: HeadersAndMessagesSharedParams { lane: vec![ - HexLaneId([0x00, 0x00, 0x00, 0x00]), - HexLaneId([0x73, 0x77, 0x61, 0x70]) + HexLaneId(H256::from([0x00u8; 32])), + HexLaneId(H256::from([0x11u8; 32])) ], only_mandatory_headers: false, prometheus_params: PrometheusParams { @@ -678,7 +679,7 @@ mod tests { "--rialto-port", "9944", "--lane", - "00000000", + "0000000000000000000000000000000000000000000000000000000000000000", "--prometheus-host", "0.0.0.0", ]); @@ -689,7 +690,7 @@ mod tests { RelayHeadersAndMessages::MillauRialtoParachain( MillauRialtoParachainHeadersAndMessages { shared: HeadersAndMessagesSharedParams { - lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])], + lane: vec![HexLaneId(H256::from([0x00u8; 32]))], only_mandatory_headers: false, prometheus_params: PrometheusParams { no_prometheus: false, diff --git a/relays/bin-substrate/src/cli/relay_messages.rs b/relays/bin-substrate/src/cli/relay_messages.rs index c26e723af02..3183647e22e 100644 --- a/relays/bin-substrate/src/cli/relay_messages.rs +++ b/relays/bin-substrate/src/cli/relay_messages.rs @@ -48,8 +48,8 @@ pub struct RelayMessages { /// A bridge instance to relay messages for. #[structopt(possible_values = FullBridge::VARIANTS, case_insensitive = true)] bridge: FullBridge, - /// Hex-encoded lane id that should be served by the relay. Defaults to `00000000`. - #[structopt(long, default_value = "00000000")] + /// Hex-encoded lane id that should be served by the relay. + #[structopt(long)] lane: HexLaneId, #[structopt(flatten)] source: SourceConnectionParams, diff --git a/relays/lib-substrate-relay/src/messages/mod.rs b/relays/lib-substrate-relay/src/messages/mod.rs index ae143616432..05da4c6b5ff 100644 --- a/relays/lib-substrate-relay/src/messages/mod.rs +++ b/relays/lib-substrate-relay/src/messages/mod.rs @@ -548,7 +548,7 @@ where FromBridgedChainMessagesProof { bridged_header_hash: Default::default(), storage: Default::default(), - lane: Default::default(), + lane: LaneId::new(1, 2), nonces_start: 1, nonces_end: messages as u64, }, diff --git a/relays/lib-substrate-relay/src/messages/source.rs b/relays/lib-substrate-relay/src/messages/source.rs index 7adae6ac3ec..ca33f0880ef 100644 --- a/relays/lib-substrate-relay/src/messages/source.rs +++ b/relays/lib-substrate-relay/src/messages/source.rs @@ -667,7 +667,7 @@ mod tests { } let maybe_batches = - split_msgs_to_refine::(LaneId([0, 0, 0, 0]), msgs_to_refine); + split_msgs_to_refine::(LaneId::new(1, 2), msgs_to_refine); match expected_batches { Ok(expected_batches) => { let batches = maybe_batches.unwrap(); diff --git a/relays/messages/src/message_lane_loop.rs b/relays/messages/src/message_lane_loop.rs index b681d86d2ae..995499092c3 100644 --- a/relays/messages/src/message_lane_loop.rs +++ b/relays/messages/src/message_lane_loop.rs @@ -276,7 +276,7 @@ pub struct ClientsState { /// Return prefix that will be used by default to expose Prometheus metrics of the finality proofs /// sync loop. pub fn metrics_prefix(lane: &LaneId) -> String { - format!("{}_to_{}_MessageLane_{}", P::SOURCE_NAME, P::TARGET_NAME, hex::encode(lane)) + format!("{}_to_{}_MessageLane_{:?}", P::SOURCE_NAME, P::TARGET_NAME, lane) } /// Run message lane service loop. @@ -957,7 +957,7 @@ pub(crate) mod tests { }; let _ = run( Params { - lane: LaneId([0, 0, 0, 0]), + lane: LaneId::new(1, 2), source_tick: Duration::from_millis(100), target_tick: Duration::from_millis(100), reconnect_delay: Duration::from_millis(0), @@ -1274,4 +1274,12 @@ pub(crate) mod tests { assert!(!result.target_to_source_header_requirements.is_empty()); assert!(!result.source_to_target_header_requirements.is_empty()); } + + #[test] + fn metrics_prefix_is_valid() { + assert!(MessageLaneLoopMetrics::new(Some(&metrics_prefix::( + &LaneId::new(1, 2) + ))) + .is_ok()); + } }