diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 81477245b5..2e40b69497 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -767,10 +767,6 @@ impl_runtime_apis! { } impl bp_rialto::FromRialtoInboundLaneApi 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 { BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane) } diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 1574535b89..0bb9980462 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -915,10 +915,6 @@ impl_runtime_apis! { } impl bp_millau::FromMillauInboundLaneApi 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 { BridgeMillauMessages::inbound_latest_confirmed_nonce(lane) } diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs index 788ccc0703..2074c55980 100644 --- a/bridges/modules/messages/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -155,7 +155,7 @@ benchmarks_instance_pallet! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::OutboundLanes::::get(&T::bench_lane_id()).latest_generated_nonce, T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -192,7 +192,7 @@ benchmarks_instance_pallet! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::OutboundLanes::::get(&T::bench_lane_id()).latest_generated_nonce, T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -229,7 +229,7 @@ benchmarks_instance_pallet! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::OutboundLanes::::get(&T::bench_lane_id()).latest_generated_nonce, 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 21, ); 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 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) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 21, ); assert!(T::is_message_dispatched(21)); @@ -634,7 +634,7 @@ benchmarks_instance_pallet! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::OutboundLanes::::get(&T::bench_lane_id()).latest_generated_nonce, T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -674,7 +674,7 @@ benchmarks_instance_pallet! { ) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 20 + i as MessageNonce, ); } @@ -712,7 +712,7 @@ benchmarks_instance_pallet! { ) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 21, ); } @@ -750,7 +750,7 @@ benchmarks_instance_pallet! { ) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 21, ); } @@ -794,7 +794,7 @@ benchmarks_instance_pallet! { ) verify { assert_eq!( - crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), 20 + i as MessageNonce, ); assert_eq!( diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 6f1a432e09..09298013a5 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -764,16 +764,6 @@ pub mod pallet { OutboundMessages::::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::::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::::get(&lane).last_delivered_nonce() - } - /// Get nonce of the latest confirmed message at given inbound lane. pub fn inbound_latest_confirmed_nonce(lane: LaneId) -> MessageNonce { InboundLanes::::get(&lane).last_confirmed_nonce diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 44cb7f009b..f15486e0a7 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -101,9 +101,6 @@ pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method. 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. pub const FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Kusama runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 143772145b..0a9790a096 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -278,9 +278,6 @@ pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToMillauOutboundLaneApi::message_details` runtime method. 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. pub const FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Millau runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 9d5e18b4b8..635525fc7f 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -101,9 +101,6 @@ pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method. 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. pub const FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Polkadot runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 79b0bf05a1..6c0a678f50 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -250,9 +250,6 @@ pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method. 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. pub const FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Rialto runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 868982b8ef..2397ea17e9 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -90,9 +90,6 @@ pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToRococoOutboundLaneApi::message_details` runtime method. 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. pub const FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Rococo runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 5ebbde9d00..d0a1c71c0f 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -55,9 +55,6 @@ pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToWococoOutboundLaneApi::message_details` runtime method. 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. pub const FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str = "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 /// Wococo runtime itself. 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. fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; /// State of the unrewarded relayers set at given lane. diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs index 78dd70b297..55e8169941 100644 --- a/bridges/relays/client-kusama/src/lib.rs +++ b/bridges/relays/client-kusama/src/lib.rs @@ -79,8 +79,6 @@ impl ChainWithMessages for Kusama { bp_kusama::WITH_KUSAMA_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_kusama::FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/client-millau/src/lib.rs b/bridges/relays/client-millau/src/lib.rs index b1f14992d8..908ffc929c 100644 --- a/bridges/relays/client-millau/src/lib.rs +++ b/bridges/relays/client-millau/src/lib.rs @@ -63,8 +63,6 @@ impl ChainWithMessages for Millau { bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_millau::FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs index cc3077c582..fbe1ffae08 100644 --- a/bridges/relays/client-polkadot/src/lib.rs +++ b/bridges/relays/client-polkadot/src/lib.rs @@ -80,8 +80,6 @@ impl ChainWithMessages for Polkadot { bp_polkadot::WITH_POLKADOT_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_polkadot::FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/client-rialto/src/lib.rs b/bridges/relays/client-rialto/src/lib.rs index 8b1c1351d3..61065b352f 100644 --- a/bridges/relays/client-rialto/src/lib.rs +++ b/bridges/relays/client-rialto/src/lib.rs @@ -78,8 +78,6 @@ impl ChainWithMessages for Rialto { bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_rialto::FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/client-rococo/src/lib.rs b/bridges/relays/client-rococo/src/lib.rs index b125c63478..7319b3f2ee 100644 --- a/bridges/relays/client-rococo/src/lib.rs +++ b/bridges/relays/client-rococo/src/lib.rs @@ -82,8 +82,6 @@ impl ChainWithMessages for Rococo { bp_rococo::WITH_ROCOCO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_rococo::FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index b78a03dc73..d11e732d31 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -91,9 +91,6 @@ pub trait ChainWithMessages: Chain { /// The method is provided by the runtime that is bridged with this `ChainWithMessages`. const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; - /// Name of the `FromInboundLaneApi::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 `FromInboundLaneApi::latest_confirmed_nonce` runtime method. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`. const FROM_CHAIN_LATEST_CONFIRMED_NONCE_METHOD: &'static str; diff --git a/bridges/relays/client-wococo/src/lib.rs b/bridges/relays/client-wococo/src/lib.rs index 4825a06010..a6f6d734dd 100644 --- a/bridges/relays/client-wococo/src/lib.rs +++ b/bridges/relays/client-wococo/src/lib.rs @@ -82,8 +82,6 @@ impl ChainWithMessages for Wococo { bp_wococo::WITH_WOCOCO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = 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 = bp_wococo::FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD; const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = diff --git a/bridges/relays/lib-substrate-relay/src/messages_target.rs b/bridges/relays/lib-substrate-relay/src/messages_target.rs index 7e7722bb57..cdd25c64e5 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_target.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_target.rs @@ -27,7 +27,10 @@ use crate::{ }; 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::{ source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, }; @@ -130,16 +133,19 @@ where &self, id: TargetHeaderIdOf>, ) -> Result<(TargetHeaderIdOf>, MessageNonce), SubstrateError> { - let encoded_response = self + let inbound_lane_data: Option>> = self .client - .state_call( - P::SourceChain::FROM_CHAIN_LATEST_RECEIVED_NONCE_METHOD.into(), - Bytes(self.lane_id.encode()), + .storage_value( + inbound_lane_data_key( + P::SourceChain::WITH_CHAIN_MESSAGES_PALLET_NAME, + &self.lane_id, + ), Some(id.1), ) .await?; - let latest_received_nonce: MessageNonce = Decode::decode(&mut &encoded_response.0[..]) - .map_err(SubstrateError::ResponseParseFailed)?; + // lane data missing from the storage is fine until first message is received + let latest_received_nonce = + inbound_lane_data.map(|data| data.last_delivered_nonce()).unwrap_or(0); Ok((id, latest_received_nonce)) }