diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 8234b30ca1..81477245b5 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -764,10 +764,6 @@ impl_runtime_apis! { WithRialtoMessageBridge, >(lane, begin, end) } - - fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { - BridgeRialtoMessages::outbound_latest_received_nonce(lane) - } } impl bp_rialto::FromRialtoInboundLaneApi for Runtime { diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index e1e2b785b7..1574535b89 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -912,10 +912,6 @@ impl_runtime_apis! { WithMillauMessageBridge, >(lane, begin, end) } - - fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { - BridgeMillauMessages::outbound_latest_received_nonce(lane) - } } impl bp_millau::FromMillauInboundLaneApi for Runtime { diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 20b5570794..6f1a432e09 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -769,11 +769,6 @@ pub mod pallet { OutboundLanes::::get(&lane).latest_generated_nonce } - /// Get nonce of the latest confirmed message at given outbound lane. - pub fn outbound_latest_received_nonce(lane: LaneId) -> MessageNonce { - OutboundLanes::::get(&lane).latest_received_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() diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index fc09bfcb8e..63c76282db 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -98,9 +98,6 @@ pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method. pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details"; -/// Name of the `ToKusamaOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_KUSAMA_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToKusamaOutboundLaneApi_latest_received_nonce"; /// Name of the `FromKusamaInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_KUSAMA_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -151,8 +148,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Kusama chain. diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index df212509ad..9b1e2a9e69 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -275,9 +275,6 @@ pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToMillauOutboundLaneApi::message_details` runtime method. pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details"; -/// Name of the `ToMillauOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToMillauOutboundLaneApi_latest_received_nonce"; /// Name of the `FromMillauInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -328,8 +325,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Millau chain. diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 51a4966534..4ba961e6dd 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -98,9 +98,6 @@ pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method. pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details"; -/// Name of the `ToPolkadotOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_POLKADOT_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToPolkadotOutboundLaneApi_latest_received_nonce"; /// Name of the `FromPolkadotInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_POLKADOT_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -151,8 +148,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Polkadot chain. diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 39310a48ef..2061ae0461 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -247,9 +247,6 @@ pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method. pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details"; -/// Name of the `ToRialtoOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_RIALTO_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToRialtoOutboundLaneApi_latest_received_nonce"; /// Name of the `FromRialtoInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_RIALTO_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -300,8 +297,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Rialto chain. diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 5d95e7f1d1..0593b0d8a1 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -87,9 +87,6 @@ pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToRococoOutboundLaneApi::message_details` runtime method. pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details"; -/// Name of the `ToRococoOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_ROCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToRococoOutboundLaneApi_latest_received_nonce"; /// Name of the `FromRococoInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_ROCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -152,8 +149,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Rococo chain. diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 617688e8e4..ae4dd38643 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -52,9 +52,6 @@ pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = "ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; /// Name of the `ToWococoOutboundLaneApi::message_details` runtime method. pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details"; -/// Name of the `ToWococoOutboundLaneApi::latest_received_nonce` runtime method. -pub const TO_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = - "ToWococoOutboundLaneApi_latest_received_nonce"; /// Name of the `FromWococoInboundLaneApi::latest_received_nonce` runtime method. pub const FROM_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = @@ -105,8 +102,6 @@ sp_api::decl_runtime_apis! { begin: MessageNonce, end: MessageNonce, ) -> Vec>; - /// Returns nonce of the latest message, received by bridged chain. - fn latest_received_nonce(lane: LaneId) -> MessageNonce; } /// Inbound message lane API for messages sent by Wococo chain. diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs index bdd7b74ffb..b6a1e1acf2 100644 --- a/bridges/relays/client-kusama/src/lib.rs +++ b/bridges/relays/client-kusama/src/lib.rs @@ -75,8 +75,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_kusama::TO_KUSAMA_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/client-millau/src/lib.rs b/bridges/relays/client-millau/src/lib.rs index 3b441e9a0e..609e8d76d7 100644 --- a/bridges/relays/client-millau/src/lib.rs +++ b/bridges/relays/client-millau/src/lib.rs @@ -59,8 +59,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_millau::TO_MILLAU_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs index ca23fe3199..1ec34988b9 100644 --- a/bridges/relays/client-polkadot/src/lib.rs +++ b/bridges/relays/client-polkadot/src/lib.rs @@ -75,8 +75,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_polkadot::TO_POLKADOT_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/client-rialto/src/lib.rs b/bridges/relays/client-rialto/src/lib.rs index b3a3bd1eaf..5a917a9660 100644 --- a/bridges/relays/client-rialto/src/lib.rs +++ b/bridges/relays/client-rialto/src/lib.rs @@ -74,8 +74,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_rialto::TO_RIALTO_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/client-rococo/src/lib.rs b/bridges/relays/client-rococo/src/lib.rs index 794e82efb0..aa52fbc6b7 100644 --- a/bridges/relays/client-rococo/src/lib.rs +++ b/bridges/relays/client-rococo/src/lib.rs @@ -78,8 +78,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_rococo::TO_ROCOCO_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index 48dcc48132..aa3be46424 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -76,9 +76,6 @@ pub trait ChainWithMessages: Chain { /// Name of the `ToOutboundLaneApi::message_details` runtime API method. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`. const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; - /// Name of the `ToOutboundLaneApi::latest_received_nonce` runtime API - /// method. The method is provided by the runtime that is bridged with this `ChainWithMessages`. - const TO_CHAIN_LATEST_RECEIVED_NONCE_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`. diff --git a/bridges/relays/client-wococo/src/lib.rs b/bridges/relays/client-wococo/src/lib.rs index 1b634930db..1f7c27c9bd 100644 --- a/bridges/relays/client-wococo/src/lib.rs +++ b/bridges/relays/client-wococo/src/lib.rs @@ -78,8 +78,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 TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD: &'static str = - bp_wococo::TO_WOCOCO_LATEST_RECEIVED_NONCE_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 = diff --git a/bridges/relays/lib-substrate-relay/src/messages_source.rs b/bridges/relays/lib-substrate-relay/src/messages_source.rs index 4918635550..87296457f8 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_source.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_source.rs @@ -149,16 +149,19 @@ where &self, id: SourceHeaderIdOf>, ) -> Result<(SourceHeaderIdOf>, MessageNonce), SubstrateError> { - let encoded_response = self + let outbound_lane_data: Option = self .client - .state_call( - P::TargetChain::TO_CHAIN_LATEST_RECEIVED_NONCE_METHOD.into(), - Bytes(self.lane_id.encode()), + .storage_value( + outbound_lane_data_key( + P::TargetChain::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 sent + let latest_received_nonce = + outbound_lane_data.map(|data| data.latest_received_nonce).unwrap_or(0); Ok((id, latest_received_nonce)) }