Skip to content

Commit 617c426

Browse files
authored
Merge pull request #3544 from autonomys/relay_messages
XDM Relayer: Optimized XDM processing
2 parents 7b76499 + afc8da0 commit 617c426

File tree

23 files changed

+1039
-378
lines changed

23 files changed

+1039
-378
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/subspace-fake-runtime-api/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use sp_domains::{
1616
use sp_domains_fraud_proof::fraud_proof::FraudProof;
1717
use sp_domains_fraud_proof::storage_proof::FraudProofStorageKeyRequest;
1818
use sp_messenger::messages::{
19-
BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, MessageId, MessageKey,
19+
BlockMessagesQuery, BlockMessagesWithStorageKey, ChainId, ChannelId, ChannelStateWithNonce,
20+
CrossDomainMessage, MessageId, MessageKey, MessagesWithStorageKey, Nonce as XdmNonce,
2021
};
2122
use sp_messenger::{ChannelNonce, XdmId};
2223
use sp_runtime::traits::NumberFor;
@@ -412,6 +413,22 @@ sp_api::impl_runtime_apis! {
412413
fn open_channels() -> BTreeSet<(ChainId, ChannelId)> {
413414
unreachable!()
414415
}
416+
417+
fn block_messages_with_query(_: BlockMessagesQuery) -> MessagesWithStorageKey {
418+
unreachable!()
419+
}
420+
421+
fn channels_and_state() -> Vec<(ChainId, ChannelId, ChannelStateWithNonce)> {
422+
unreachable!()
423+
}
424+
425+
fn first_outbox_message_nonce_to_relay(_: ChainId, _: ChannelId, _: XdmNonce) -> Option<XdmNonce> {
426+
unreachable!()
427+
}
428+
429+
fn first_inbox_message_response_nonce_to_relay(_: ChainId, _: ChannelId, _: XdmNonce) -> Option<XdmNonce> {
430+
unreachable!()
431+
}
415432
}
416433

417434
impl sp_domains_fraud_proof::FraudProofApi<Block, DomainHeader> for Runtime {

crates/subspace-runtime/src/lib.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ use sp_domains_fraud_proof::storage_proof::{
7171
};
7272
use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId};
7373
use sp_messenger::messages::{
74-
BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, MessageId, MessageKey,
74+
BlockMessagesQuery, BlockMessagesWithStorageKey, ChainId, ChannelStateWithNonce,
75+
CrossDomainMessage, MessageId, MessageKey, MessagesWithStorageKey, Nonce as XdmNonce,
7576
};
7677
use sp_messenger::{ChannelNonce, XdmId};
7778
use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest};
@@ -1672,7 +1673,7 @@ impl_runtime_apis! {
16721673

16731674
impl sp_messenger::RelayerApi<Block, BlockNumber, BlockNumber, BlockHashFor<Block>> for Runtime {
16741675
fn block_messages() -> BlockMessagesWithStorageKey {
1675-
Messenger::get_block_messages()
1676+
BlockMessagesWithStorageKey::default()
16761677
}
16771678

16781679
fn outbox_message_unsigned(msg: CrossDomainMessage<NumberFor<Block>, BlockHashFor<Block>, BlockHashFor<Block>>) -> Option<ExtrinsicFor<Block>> {
@@ -1683,12 +1684,12 @@ impl_runtime_apis! {
16831684
Messenger::inbox_response_message_unsigned(msg)
16841685
}
16851686

1686-
fn should_relay_outbox_message(dst_chain_id: ChainId, msg_id: MessageId) -> bool {
1687-
Messenger::should_relay_outbox_message(dst_chain_id, msg_id)
1687+
fn should_relay_outbox_message(_: ChainId, _: MessageId) -> bool {
1688+
false
16881689
}
16891690

1690-
fn should_relay_inbox_message_response(dst_chain_id: ChainId, msg_id: MessageId) -> bool {
1691-
Messenger::should_relay_inbox_message_response(dst_chain_id, msg_id)
1691+
fn should_relay_inbox_message_response(_: ChainId, _: MessageId) -> bool {
1692+
false
16921693
}
16931694

16941695
fn updated_channels() -> BTreeSet<(ChainId, ChannelId)> {
@@ -1702,6 +1703,22 @@ impl_runtime_apis! {
17021703
fn open_channels() -> BTreeSet<(ChainId, ChannelId)> {
17031704
Messenger::open_channels()
17041705
}
1706+
1707+
fn block_messages_with_query(query: BlockMessagesQuery) -> MessagesWithStorageKey {
1708+
Messenger::get_block_messages(query)
1709+
}
1710+
1711+
fn channels_and_state() -> Vec<(ChainId, ChannelId, ChannelStateWithNonce)> {
1712+
Messenger::channels_and_states()
1713+
}
1714+
1715+
fn first_outbox_message_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1716+
Messenger::first_outbox_message_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1717+
}
1718+
1719+
fn first_inbox_message_response_nonce_to_relay(dst_chain_id: ChainId, channel_id: ChannelId, from_nonce: XdmNonce) -> Option<XdmNonce> {
1720+
Messenger::first_inbox_message_response_nonce_to_relay(dst_chain_id, channel_id, from_nonce)
1721+
}
17051722
}
17061723

17071724
impl sp_domains_fraud_proof::FraudProofApi<Block, DomainHeader> for Runtime {

domains/client/cross-domain-message-gossip/src/aux_schema.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Schema for channel update storage.
22
3-
use crate::RELAYER_PREFIX;
43
use parity_scale_codec::{Decode, Encode};
54
use sc_client_api::backend::AuxStore;
65
use sp_blockchain::{Error as ClientError, Info, Result as ClientResult};
@@ -89,19 +88,6 @@ where
8988
channel_detail.encode().as_slice(),
9089
)],
9190
vec![],
92-
)?;
93-
94-
let channel_nonce = ChannelNonce {
95-
relay_msg_nonce: Some(channel_detail.next_inbox_nonce),
96-
relay_response_msg_nonce: channel_detail.latest_response_received_message_nonce,
97-
};
98-
let prefix = (RELAYER_PREFIX, src_chain_id, self_chain_id).encode();
99-
cleanup_chain_channel_storages(
100-
backend,
101-
&prefix,
102-
src_chain_id,
103-
channel_detail.channel_id,
104-
channel_nonce,
10591
)
10692
}
10793

domains/client/cross-domain-message-gossip/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ pub use gossip_worker::{
1313
xdm_gossip_peers_set_config, ChainMsg, ChainSink, ChannelUpdate, GossipWorker,
1414
GossipWorkerBuilder, Message, MessageData,
1515
};
16-
pub use message_listener::{
17-
can_allow_xdm_submission, start_cross_chain_message_listener, RELAYER_PREFIX,
18-
};
16+
pub use message_listener::{can_allow_xdm_submission, start_cross_chain_message_listener};

domains/client/cross-domain-message-gossip/src/message_listener.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use thiserror::Error;
3333

3434
pub(crate) const LOG_TARGET: &str = "domain_message_listener";
3535
const TX_POOL_PREFIX: &[u8] = b"xdm_tx_pool_listener";
36-
pub const RELAYER_PREFIX: &[u8] = b"xdm_relayer";
3736

3837
/// Number of blocks an already submitted XDM is not accepted since last submission.
3938
const XDM_ACCEPT_BLOCK_LIMIT: u32 = 15;

domains/client/domain-operator/src/tests.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,7 +5346,6 @@ async fn existing_bundle_can_be_resubmitted_to_new_fork() {
53465346
}
53475347

53485348
#[tokio::test(flavor = "multi_thread")]
5349-
#[ignore]
53505349
async fn test_domain_sudo_calls() {
53515350
let (_directory, mut ferdie, mut alice, account_infos) =
53525351
setup_evm_test_accounts(Sr25519Alice, true, Sr25519Alice).await;
@@ -5764,7 +5763,6 @@ async fn test_public_evm_rejects_allow_list_domain_owner_calls() {
57645763
}
57655764

57665765
#[tokio::test(flavor = "multi_thread")]
5767-
#[ignore]
57685766
async fn test_xdm_between_consensus_and_domain_should_work() {
57695767
let directory = TempDir::new().expect("Must be able to create temporary directory");
57705768

@@ -5923,7 +5921,6 @@ async fn test_xdm_between_consensus_and_domain_should_work() {
59235921
}
59245922

59255923
#[tokio::test(flavor = "multi_thread")]
5926-
#[ignore]
59275924
async fn test_xdm_between_domains_should_work() {
59285925
let directory = TempDir::new().expect("Must be able to create temporary directory");
59295926

@@ -6047,7 +6044,6 @@ async fn test_xdm_between_domains_should_work() {
60476044
}
60486045

60496046
#[tokio::test(flavor = "multi_thread")]
6050-
#[ignore]
60516047
async fn test_unordered_cross_domains_message_should_work() {
60526048
let directory = TempDir::new().expect("Must be able to create temporary directory");
60536049

@@ -7143,7 +7139,6 @@ async fn test_equivocated_bundle_check() {
71437139
}
71447140

71457141
#[tokio::test(flavor = "multi_thread")]
7146-
#[ignore]
71477142
async fn test_xdm_false_invalid_fraud_proof() {
71487143
let directory = TempDir::new().expect("Must be able to create temporary directory");
71497144

@@ -7617,7 +7612,6 @@ async fn test_custom_api_storage_root_match_upstream_root() {
76177612
}
76187613

76197614
#[tokio::test(flavor = "multi_thread")]
7620-
#[ignore]
76217615
async fn test_xdm_channel_allowlist_removed_after_xdm_initiated() {
76227616
let directory = TempDir::new().expect("Must be able to create temporary directory");
76237617

@@ -7695,7 +7689,6 @@ async fn test_xdm_channel_allowlist_removed_after_xdm_initiated() {
76957689
}
76967690

76977691
#[tokio::test(flavor = "multi_thread")]
7698-
#[ignore]
76997692
async fn test_xdm_channel_allowlist_removed_after_xdm_req_relaying() {
77007693
let directory = TempDir::new().expect("Must be able to create temporary directory");
77017694

@@ -7802,7 +7795,6 @@ async fn test_xdm_channel_allowlist_removed_after_xdm_req_relaying() {
78027795
}
78037796

78047797
#[tokio::test(flavor = "multi_thread")]
7805-
#[ignore]
78067798
async fn test_xdm_channel_allowlist_removed_after_xdm_resp_relaying() {
78077799
let directory = TempDir::new().expect("Must be able to create temporary directory");
78087800

@@ -7907,7 +7899,6 @@ async fn test_xdm_channel_allowlist_removed_after_xdm_resp_relaying() {
79077899
}
79087900

79097901
#[tokio::test(flavor = "multi_thread")]
7910-
#[ignore]
79117902
async fn test_xdm_transfer_below_existential_deposit() {
79127903
let directory = TempDir::new().expect("Must be able to create temporary directory");
79137904

@@ -7983,7 +7974,6 @@ async fn test_xdm_transfer_below_existential_deposit() {
79837974
}
79847975

79857976
#[tokio::test(flavor = "multi_thread")]
7986-
#[ignore]
79877977
async fn test_xdm_transfer_to_wrong_format_address() {
79887978
let directory = TempDir::new().expect("Must be able to create temporary directory");
79897979

@@ -8432,7 +8422,6 @@ async fn test_invalid_chain_reward_receipt() {
84328422
}
84338423

84348424
#[tokio::test(flavor = "multi_thread")]
8435-
#[ignore]
84368425
async fn test_domain_total_issuance_match_consensus_chain_bookkeeping_with_xdm() {
84378426
let directory = TempDir::new().expect("Must be able to create temporary directory");
84388427

domains/client/relayer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async-channel.workspace = true
1616
cross-domain-message-gossip.workspace = true
1717
futures.workspace = true
1818
parity-scale-codec = { workspace = true, features = ["derive"] }
19+
rand.workspace = true
1920
sc-client-api.workspace = true
2021
sc-state-db.workspace = true
2122
sc-utils.workspace = true

0 commit comments

Comments
 (0)