diff --git a/crates/subspace-fake-runtime-api/src/lib.rs b/crates/subspace-fake-runtime-api/src/lib.rs index 9ca477d0ed..05539ce2fb 100644 --- a/crates/subspace-fake-runtime-api/src/lib.rs +++ b/crates/subspace-fake-runtime-api/src/lib.rs @@ -32,6 +32,7 @@ use sp_domains_fraud_proof::storage_proof::FraudProofStorageKeyRequest; use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_runtime::traits::{Block as BlockT, NumberFor}; use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity}; use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode}; @@ -361,6 +362,10 @@ sp_api::impl_runtime_apis! { fn domain_chains_allowlist_update(_domain_id: DomainId) -> Option{ unreachable!() } + + fn xdm_id(_ext: &::Extrinsic) -> Option { + unreachable!() + } } impl sp_messenger::RelayerApi::Hash> for Runtime { diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index d145592342..3654183d44 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -83,6 +83,7 @@ use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, Endp use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::traits::{ @@ -1442,6 +1443,18 @@ impl_runtime_apis! { fn domain_chains_allowlist_update(domain_id: DomainId) -> Option{ Messenger::domain_chains_allowlist_update(domain_id) } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi::Hash> for Runtime { diff --git a/domains/client/cross-domain-message-gossip/src/message_listener.rs b/domains/client/cross-domain-message-gossip/src/message_listener.rs index e0648fc65f..07f52ecb4b 100644 --- a/domains/client/cross-domain-message-gossip/src/message_listener.rs +++ b/domains/client/cross-domain-message-gossip/src/message_listener.rs @@ -470,9 +470,12 @@ async fn handle_xdm_message( Client: HeaderBackend>, { let at = client.info().best_hash; + let tx_hash = tx_pool.hash_of(&ext); tracing::debug!( target: LOG_TARGET, - "Submitting extrinsic to tx pool at block: {:?}", + "Submitting extrinsic {:?} to tx pool for chain {:?} at block: {:?}", + tx_hash, + chain_id, at ); @@ -487,5 +490,13 @@ async fn handle_xdm_message( chain_id, err ); + } else { + tracing::debug!( + target: LOG_TARGET, + "Submitted extrinsic {:?} to tx pool for chain {:?} at {:?}", + tx_hash, + chain_id, + at + ) } } diff --git a/domains/primitives/messenger/src/lib.rs b/domains/primitives/messenger/src/lib.rs index 8f26eab00b..67a2cf4282 100644 --- a/domains/primitives/messenger/src/lib.rs +++ b/domains/primitives/messenger/src/lib.rs @@ -33,6 +33,7 @@ use codec::{Decode, Encode}; use frame_support::inherent::InherentData; use frame_support::inherent::{InherentIdentifier, IsFatalError}; use messages::{BlockMessagesWithStorageKey, ChannelId, CrossDomainMessage, MessageId}; +use scale_info::TypeInfo; use sp_domains::{ChainId, DomainAllowlistUpdates, DomainId}; use sp_subspace_mmr::ConsensusChainMmrLeafProof; #[cfg(feature = "std")] @@ -159,6 +160,13 @@ impl sp_inherents::InherentDataProvider for InherentDataProvider { } } +/// Represent a union of XDM types with their message ID +#[derive(Debug, Encode, Decode, TypeInfo)] +pub enum XdmId { + RelayMessage(MessageKey), + RelayResponseMessage(MessageKey), +} + sp_api::decl_runtime_apis! { /// Api useful for relayers to fetch messages and submit transactions. pub trait RelayerApi @@ -220,5 +228,8 @@ sp_api::decl_runtime_apis! { /// Returns any domain's chains allowlist updates on consensus chain. fn domain_chains_allowlist_update(domain_id: DomainId) -> Option; + + /// Returns XDM message ID + fn xdm_id(ext: &Block::Extrinsic) -> Option; } } diff --git a/domains/runtime/auto-id/src/lib.rs b/domains/runtime/auto-id/src/lib.rs index 61ddda8c3a..b1c3abe560 100644 --- a/domains/runtime/auto-id/src/lib.rs +++ b/domains/runtime/auto-id/src/lib.rs @@ -45,6 +45,7 @@ use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, Endp use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::generic::Era; @@ -909,6 +910,18 @@ impl_runtime_apis! { // not valid call on domains None } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi for Runtime { diff --git a/domains/runtime/evm/src/lib.rs b/domains/runtime/evm/src/lib.rs index 172e0c3b01..91a4f9ec00 100644 --- a/domains/runtime/evm/src/lib.rs +++ b/domains/runtime/evm/src/lib.rs @@ -58,6 +58,7 @@ use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, Endp use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::generic::Era; @@ -1320,6 +1321,18 @@ impl_runtime_apis! { // not valid call on domains None } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.0.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi for Runtime { diff --git a/domains/test/runtime/auto-id/src/lib.rs b/domains/test/runtime/auto-id/src/lib.rs index 1bfab38c27..59cb9c05d0 100644 --- a/domains/test/runtime/auto-id/src/lib.rs +++ b/domains/test/runtime/auto-id/src/lib.rs @@ -45,6 +45,7 @@ use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, Endp use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::generic::Era; @@ -900,6 +901,18 @@ impl_runtime_apis! { // not valid call on domains None } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi for Runtime { diff --git a/domains/test/runtime/evm/src/lib.rs b/domains/test/runtime/evm/src/lib.rs index b530910fdb..9bd7d22fee 100644 --- a/domains/test/runtime/evm/src/lib.rs +++ b/domains/test/runtime/evm/src/lib.rs @@ -58,6 +58,7 @@ use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::generic::Era; @@ -1276,6 +1277,18 @@ impl_runtime_apis! { // not valid call on domains None } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.0.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi for Runtime { diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index cd89a54111..271590afae 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -73,6 +73,7 @@ use sp_messenger::messages::{ BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; +use sp_messenger::XdmId; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; use sp_runtime::traits::{ @@ -1503,6 +1504,18 @@ impl_runtime_apis! { fn domain_chains_allowlist_update(domain_id: DomainId) -> Option{ Messenger::domain_chains_allowlist_update(domain_id) } + + fn xdm_id(ext: &::Extrinsic) -> Option { + match &ext.function { + RuntimeCall::Messenger(pallet_messenger::Call::relay_message { msg })=> { + Some(XdmId::RelayMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + RuntimeCall::Messenger(pallet_messenger::Call::relay_message_response { msg }) => { + Some(XdmId::RelayResponseMessage((msg.src_chain_id, msg.channel_id, msg.nonce))) + } + _ => None, + } + } } impl sp_messenger::RelayerApi::Hash> for Runtime {