Replace InboundLaneApi::latest_received_nonce with direct storage read (#1269)

* remove inbound_latest_received_nonce

* Update relays/lib-substrate-relay/src/messages_target.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Svyatoslav Nikolsky
2021-12-23 17:18:43 +03:00
committed by Bastian Köcher
parent bb249eff15
commit a88207876c
18 changed files with 27 additions and 84 deletions
-4
View File
@@ -767,10 +767,6 @@ impl_runtime_apis! {
} }
impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime { impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime {
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
BridgeRialtoMessages::inbound_latest_received_nonce(lane)
}
fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane) BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane)
} }
-4
View File
@@ -915,10 +915,6 @@ impl_runtime_apis! {
} }
impl bp_millau::FromMillauInboundLaneApi<Block> for Runtime { impl bp_millau::FromMillauInboundLaneApi<Block> for Runtime {
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
BridgeMillauMessages::inbound_latest_received_nonce(lane)
}
fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
BridgeMillauMessages::inbound_latest_confirmed_nonce(lane) BridgeMillauMessages::inbound_latest_confirmed_nonce(lane)
} }
+14 -14
View File
@@ -155,7 +155,7 @@ benchmarks_instance_pallet! {
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()), crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
T::MaxMessagesToPruneAtOnce::get() + 1, T::MaxMessagesToPruneAtOnce::get() + 1,
); );
} }
@@ -192,7 +192,7 @@ benchmarks_instance_pallet! {
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()), crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
T::MaxMessagesToPruneAtOnce::get() + 1, T::MaxMessagesToPruneAtOnce::get() + 1,
); );
} }
@@ -229,7 +229,7 @@ benchmarks_instance_pallet! {
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()), crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
T::MaxMessagesToPruneAtOnce::get() + 1, T::MaxMessagesToPruneAtOnce::get() + 1,
); );
} }
@@ -297,7 +297,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
assert!(T::is_message_dispatched(21)); assert!(T::is_message_dispatched(21));
@@ -331,7 +331,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
22, 22,
); );
assert!(T::is_message_dispatched(22)); assert!(T::is_message_dispatched(22));
@@ -369,7 +369,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
assert_eq!( assert_eq!(
@@ -405,7 +405,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
assert!(T::is_message_dispatched(21)); assert!(T::is_message_dispatched(21));
@@ -439,7 +439,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
assert!(T::is_message_dispatched(21)); assert!(T::is_message_dispatched(21));
@@ -472,7 +472,7 @@ benchmarks_instance_pallet! {
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
assert!(T::is_message_dispatched(21)); assert!(T::is_message_dispatched(21));
@@ -634,7 +634,7 @@ benchmarks_instance_pallet! {
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()), crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
T::MaxMessagesToPruneAtOnce::get() + 1, T::MaxMessagesToPruneAtOnce::get() + 1,
); );
} }
@@ -674,7 +674,7 @@ benchmarks_instance_pallet! {
) )
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
20 + i as MessageNonce, 20 + i as MessageNonce,
); );
} }
@@ -712,7 +712,7 @@ benchmarks_instance_pallet! {
) )
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
} }
@@ -750,7 +750,7 @@ benchmarks_instance_pallet! {
) )
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
21, 21,
); );
} }
@@ -794,7 +794,7 @@ benchmarks_instance_pallet! {
) )
verify { verify {
assert_eq!( assert_eq!(
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()), crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
20 + i as MessageNonce, 20 + i as MessageNonce,
); );
assert_eq!( assert_eq!(
-10
View File
@@ -764,16 +764,6 @@ pub mod pallet {
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce }) OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce })
} }
/// Get nonce of the latest generated message at given outbound lane.
pub fn outbound_latest_generated_nonce(lane: LaneId) -> MessageNonce {
OutboundLanes::<T, I>::get(&lane).latest_generated_nonce
}
/// Get nonce of the latest received message at given inbound lane.
pub fn inbound_latest_received_nonce(lane: LaneId) -> MessageNonce {
InboundLanes::<T, I>::get(&lane).last_delivered_nonce()
}
/// Get nonce of the latest confirmed message at given inbound lane. /// Get nonce of the latest confirmed message at given inbound lane.
pub fn inbound_latest_confirmed_nonce(lane: LaneId) -> MessageNonce { pub fn inbound_latest_confirmed_nonce(lane: LaneId) -> MessageNonce {
InboundLanes::<T, I>::get(&lane).last_confirmed_nonce InboundLanes::<T, I>::get(&lane).last_confirmed_nonce
@@ -101,9 +101,6 @@ pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method. /// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method.
pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details"; pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details";
/// Name of the `FromKusamaInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_KUSAMA_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromKusamaInboundLaneApi_latest_received_nonce";
/// Name of the `FromKusamaInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromKusamaInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromKusamaInboundLaneApi_latest_confirmed_nonce"; "FromKusamaInboundLaneApi_latest_confirmed_nonce";
@@ -157,8 +154,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Kusama chain, not the /// This API is implemented by runtimes that are receiving messages from Kusama chain, not the
/// Kusama runtime itself. /// Kusama runtime itself.
pub trait FromKusamaInboundLaneApi { pub trait FromKusamaInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
@@ -278,9 +278,6 @@ pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToMillauOutboundLaneApi::message_details` runtime method. /// Name of the `ToMillauOutboundLaneApi::message_details` runtime method.
pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details"; pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details";
/// Name of the `FromMillauInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromMillauInboundLaneApi_latest_received_nonce";
/// Name of the `FromMillauInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromMillauInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromMillauInboundLaneApi_latest_confirmed_nonce"; "FromMillauInboundLaneApi_latest_confirmed_nonce";
@@ -334,8 +331,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Millau chain, not the /// This API is implemented by runtimes that are receiving messages from Millau chain, not the
/// Millau runtime itself. /// Millau runtime itself.
pub trait FromMillauInboundLaneApi { pub trait FromMillauInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
@@ -101,9 +101,6 @@ pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method. /// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method.
pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details"; pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details";
/// Name of the `FromPolkadotInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_POLKADOT_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromPolkadotInboundLaneApi_latest_received_nonce";
/// Name of the `FromPolkadotInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromPolkadotInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromPolkadotInboundLaneApi_latest_confirmed_nonce"; "FromPolkadotInboundLaneApi_latest_confirmed_nonce";
@@ -157,8 +154,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the /// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the
/// Polkadot runtime itself. /// Polkadot runtime itself.
pub trait FromPolkadotInboundLaneApi { pub trait FromPolkadotInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
@@ -250,9 +250,6 @@ pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method. /// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method.
pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details"; pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details";
/// Name of the `FromRialtoInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_RIALTO_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromRialtoInboundLaneApi_latest_received_nonce";
/// Name of the `FromRialtoInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromRialtoInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromRialtoInboundLaneApi_latest_confirmed_nonce"; "FromRialtoInboundLaneApi_latest_confirmed_nonce";
@@ -306,8 +303,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Rialto chain, not the /// This API is implemented by runtimes that are receiving messages from Rialto chain, not the
/// Rialto runtime itself. /// Rialto runtime itself.
pub trait FromRialtoInboundLaneApi { pub trait FromRialtoInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
@@ -90,9 +90,6 @@ pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToRococoOutboundLaneApi::message_details` runtime method. /// Name of the `ToRococoOutboundLaneApi::message_details` runtime method.
pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details"; pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details";
/// Name of the `FromRococoInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_ROCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromRococoInboundLaneApi_latest_received_nonce";
/// Name of the `FromRococoInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromRococoInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromRococoInboundLaneApi_latest_confirmed_nonce"; "FromRococoInboundLaneApi_latest_confirmed_nonce";
@@ -158,8 +155,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Rococo chain, not the /// This API is implemented by runtimes that are receiving messages from Rococo chain, not the
/// Rococo runtime itself. /// Rococo runtime itself.
pub trait FromRococoInboundLaneApi { pub trait FromRococoInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
@@ -55,9 +55,6 @@ pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
/// Name of the `ToWococoOutboundLaneApi::message_details` runtime method. /// Name of the `ToWococoOutboundLaneApi::message_details` runtime method.
pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details"; pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details";
/// Name of the `FromWococoInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromWococoInboundLaneApi_latest_received_nonce";
/// Name of the `FromWococoInboundLaneApi::latest_onfirmed_nonce` runtime method. /// Name of the `FromWococoInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str = pub const FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromWococoInboundLaneApi_latest_confirmed_nonce"; "FromWococoInboundLaneApi_latest_confirmed_nonce";
@@ -111,8 +108,6 @@ sp_api::decl_runtime_apis! {
/// This API is implemented by runtimes that are receiving messages from Wococo chain, not the /// This API is implemented by runtimes that are receiving messages from Wococo chain, not the
/// Wococo runtime itself. /// Wococo runtime itself.
pub trait FromWococoInboundLaneApi { pub trait FromWococoInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of the latest message that has been confirmed to the bridged chain. /// Nonce of the latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane. /// State of the unrewarded relayers set at given lane.
-2
View File
@@ -79,8 +79,6 @@ impl ChainWithMessages for Kusama {
bp_kusama::WITH_KUSAMA_MESSAGES_PALLET_NAME; bp_kusama::WITH_KUSAMA_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_kusama::TO_KUSAMA_MESSAGE_DETAILS_METHOD; bp_kusama::TO_KUSAMA_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_kusama::FROM_KUSAMA_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_kusama::FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD; bp_kusama::FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
-2
View File
@@ -63,8 +63,6 @@ impl ChainWithMessages for Millau {
bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_millau::TO_MILLAU_MESSAGE_DETAILS_METHOD; bp_millau::TO_MILLAU_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_millau::FROM_MILLAU_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_millau::FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD; bp_millau::FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
@@ -80,8 +80,6 @@ impl ChainWithMessages for Polkadot {
bp_polkadot::WITH_POLKADOT_MESSAGES_PALLET_NAME; bp_polkadot::WITH_POLKADOT_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_polkadot::TO_POLKADOT_MESSAGE_DETAILS_METHOD; bp_polkadot::TO_POLKADOT_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_polkadot::FROM_POLKADOT_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_polkadot::FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD; bp_polkadot::FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
-2
View File
@@ -78,8 +78,6 @@ impl ChainWithMessages for Rialto {
bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME; bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_rialto::TO_RIALTO_MESSAGE_DETAILS_METHOD; bp_rialto::TO_RIALTO_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_rialto::FROM_RIALTO_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_rialto::FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD; bp_rialto::FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
-2
View File
@@ -82,8 +82,6 @@ impl ChainWithMessages for Rococo {
bp_rococo::WITH_ROCOCO_MESSAGES_PALLET_NAME; bp_rococo::WITH_ROCOCO_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_rococo::TO_ROCOCO_MESSAGE_DETAILS_METHOD; bp_rococo::TO_ROCOCO_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_rococo::FROM_ROCOCO_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_rococo::FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD; bp_rococo::FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
@@ -91,9 +91,6 @@ pub trait ChainWithMessages: Chain {
/// The method is provided by the runtime that is bridged with this `ChainWithMessages`. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`.
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str;
/// Name of the `From<ChainWithMessages>InboundLaneApi::latest_received_nonce` runtime method.
/// The method is provided by the runtime that is bridged with this `ChainWithMessages`.
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str;
/// Name of the `From<ChainWithMessages>InboundLaneApi::latest_confirmed_nonce` runtime method. /// Name of the `From<ChainWithMessages>InboundLaneApi::latest_confirmed_nonce` runtime method.
/// The method is provided by the runtime that is bridged with this `ChainWithMessages`. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`.
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str; const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str;
-2
View File
@@ -82,8 +82,6 @@ impl ChainWithMessages for Wococo {
bp_wococo::WITH_WOCOCO_MESSAGES_PALLET_NAME; bp_wococo::WITH_WOCOCO_MESSAGES_PALLET_NAME;
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_wococo::TO_WOCOCO_MESSAGE_DETAILS_METHOD; bp_wococo::TO_WOCOCO_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str =
bp_wococo::FROM_WOCOCO_LATEST_RECEIVED_NONCE_METHOD;
const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str = const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str =
bp_wococo::FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD; bp_wococo::FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD;
const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str =
@@ -27,7 +27,10 @@ use crate::{
}; };
use async_trait::async_trait; use async_trait::async_trait;
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState}; use bp_messages::{
storage_keys::inbound_lane_data_key, InboundLaneData, LaneId, MessageNonce,
UnrewardedRelayersState,
};
use bridge_runtime_common::messages::{ use bridge_runtime_common::messages::{
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
}; };
@@ -130,16 +133,19 @@ where
&self, &self,
id: TargetHeaderIdOf<MessageLaneAdapter<P>>, id: TargetHeaderIdOf<MessageLaneAdapter<P>>,
) -> Result<(TargetHeaderIdOf<MessageLaneAdapter<P>>, MessageNonce), SubstrateError> { ) -> Result<(TargetHeaderIdOf<MessageLaneAdapter<P>>, MessageNonce), SubstrateError> {
let encoded_response = self let inbound_lane_data: Option<InboundLaneData<AccountIdOf<P::SourceChain>>> = self
.client .client
.state_call( .storage_value(
P::SourceChain::FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD.into(), inbound_lane_data_key(
Bytes(self.lane_id.encode()), P::SourceChain::WITH_CHAIN_MESSAGES_PALLET_NAME,
&self.lane_id,
),
Some(id.1), Some(id.1),
) )
.await?; .await?;
let latest_received_nonce: MessageNonce = Decode::decode(&mut &encoded_response.0[..]) // lane data missing from the storage is fine until first message is received
.map_err(SubstrateError::ResponseParseFailed)?; let latest_received_nonce =
inbound_lane_data.map(|data| data.last_delivered_nonce()).unwrap_or(0);
Ok((id, latest_received_nonce)) Ok((id, latest_received_nonce))
} }