Use TypedLaneId instead of LaneId (#1738)

* TypedLaneId -> LaneId

* fix benchmarks compilation
This commit is contained in:
Svyatoslav Nikolsky
2022-12-30 12:09:19 +03:00
committed by Bastian Köcher
parent 41daa32acb
commit 03425b33ae
20 changed files with 65 additions and 50 deletions
@@ -28,7 +28,7 @@ use bridge_runtime_common::messages::{self, MessageBridge};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Default lane that is used to send messages to Rialto.
pub const XCM_LANE: LaneId = [0, 0, 0, 0];
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.
@@ -28,7 +28,7 @@ use bridge_runtime_common::messages::{self, MessageBridge};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Default lane that is used to send messages to Rialto parachain.
pub const XCM_LANE: LaneId = [0, 0, 0, 0];
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.
+1 -1
View File
@@ -298,7 +298,7 @@ mod tests {
let xcm: Xcm<RuntimeCall> = vec![Instruction::Trap(42)].into();
let mut incoming_message = DispatchMessage {
key: MessageKey { lane_id: [0, 0, 0, 0], nonce: 1 },
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 },
data: DispatchMessageData { payload: Ok((location, xcm).into()) },
};
@@ -832,7 +832,7 @@ mod tests {
use crate::millau_messages::WeightCredit;
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
MessageKey,
LaneId, MessageKey,
};
use bp_runtime::messages::MessageDispatchResult;
use bridge_runtime_common::messages::target::FromBridgedChainMessageDispatch;
@@ -875,7 +875,7 @@ mod tests {
let xcm: Xcm<RuntimeCall> = vec![Instruction::Trap(42)].into();
let mut incoming_message = DispatchMessage {
key: MessageKey { lane_id: [0, 0, 0, 0], nonce: 1 },
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 },
data: DispatchMessageData { payload: Ok((location, xcm).into()) },
};
@@ -31,7 +31,7 @@ use bridge_runtime_common::messages::{self, MessageBridge};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Default lane that is used to send messages to Millau.
pub const XCM_LANE: LaneId = [0, 0, 0, 0];
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.
@@ -28,7 +28,7 @@ use bridge_runtime_common::messages::{self, MessageBridge};
use frame_support::{parameter_types, weights::Weight, RuntimeDebug};
/// Lane that is used for XCM messages exchange.
pub const XCM_LANE: LaneId = [0, 0, 0, 0];
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.
+3 -3
View File
@@ -204,7 +204,7 @@ impl XcmBridge for ToMillauBridge {
}
fn xcm_lane() -> bp_messages::LaneId {
[0, 0, 0, 0]
bp_messages::LaneId([0, 0, 0, 0])
}
}
@@ -214,7 +214,7 @@ mod tests {
use crate::millau_messages::WeightCredit;
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
MessageKey,
LaneId, MessageKey,
};
use bp_runtime::messages::MessageDispatchResult;
use bridge_runtime_common::messages::target::FromBridgedChainMessageDispatch;
@@ -257,7 +257,7 @@ mod tests {
let xcm: Xcm<RuntimeCall> = vec![Instruction::Trap(42)].into();
let mut incoming_message = DispatchMessage {
key: MessageKey { lane_id: [0, 0, 0, 0], nonce: 1 },
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 },
data: DispatchMessageData { payload: Ok((location, xcm).into()) },
};
+2 -2
View File
@@ -892,7 +892,7 @@ mod tests {
OutboundLaneData::default()
}
const TEST_LANE_ID: &LaneId = b"test";
const TEST_LANE_ID: &LaneId = &LaneId(*b"test");
const MAXIMAL_PENDING_MESSAGES_AT_TEST_LANE: MessageNonce = 32;
fn regular_outbound_message_payload() -> source::FromThisChainMessagePayload {
@@ -904,7 +904,7 @@ mod tests {
assert_eq!(
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
b"dsbl",
&LaneId(*b"dsbl"),
&test_lane_outbound_data(),
&regular_outbound_message_payload(),
),
@@ -110,7 +110,7 @@ mod tests {
fn deliver_message_10() {
pallet_bridge_messages::InboundLanes::<Runtime, WithRialtoMessagesInstance>::insert(
[0, 0, 0, 0],
bp_messages::LaneId([0, 0, 0, 0]),
bp_messages::InboundLaneData { relayers: Default::default(), last_confirmed_nonce: 10 },
);
}
@@ -128,7 +128,7 @@ mod tests {
proof: FromBridgedChainMessagesProof {
bridged_header_hash: Default::default(),
storage_proof: vec![],
lane: [0, 0, 0, 0],
lane: bp_messages::LaneId([0, 0, 0, 0]),
nonces_start,
nonces_end,
},
@@ -170,7 +170,7 @@ mod tests {
fn confirm_message_10() {
pallet_bridge_messages::OutboundLanes::<Runtime, WithRialtoMessagesInstance>::insert(
[0, 0, 0, 0],
bp_messages::LaneId([0, 0, 0, 0]),
bp_messages::OutboundLaneData {
oldest_unpruned_nonce: 0,
latest_received_nonce: 10,
@@ -188,7 +188,7 @@ mod tests {
proof: FromBridgedChainMessagesDeliveryProof {
bridged_header_hash: Default::default(),
storage_proof: Vec::new(),
lane: [0, 0, 0, 0],
lane: bp_messages::LaneId([0, 0, 0, 0]),
},
relayers_state: UnrewardedRelayersState {
last_delivered_nonce,
@@ -489,7 +489,7 @@ mod tests {
parameter_types! {
pub TestParachain: u32 = 1000;
pub TestLaneId: LaneId = [0, 0, 0, 0];
pub TestLaneId: LaneId = LaneId([0, 0, 0, 0]);
}
type TestExtension = RefundRelayerForMessagesFromParachain<