Skip to content

Commit

Permalink
Merge pull request #2150 from subspace/fix-xdm-check
Browse files Browse the repository at this point in the history
Switch the checking order of the empty message and state root for XDM
  • Loading branch information
NingLin-P authored Oct 23, 2023
2 parents 58a22c3 + 164035f commit c14b3ff
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions domains/client/relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@ where
return Err(Error::DomainNonConfirmedOnConsensusChain);
}

// fetch messages to be relayed
let domain_api = domain_client.runtime_api();
let block_messages: BlockMessagesWithStorageKey = domain_api
.block_messages(confirmed_block_hash)
.map_err(|_| Error::FetchAssignedMessages)?;

let filtered_messages = Self::filter_messages(domain_client, block_messages)?;

// short circuit if the there are no messages to relay
if filtered_messages.outbox.is_empty() && filtered_messages.inbox_responses.is_empty() {
return Ok(());
}

// verify if the state root is matching.
let domain_number = *domain_block_header.number();
if !consensus_chain_api
Expand All @@ -326,19 +339,6 @@ where
return Err(Error::DomainStateRootInvalid);
}

// fetch messages to be relayed
let domain_api = domain_client.runtime_api();
let block_messages: BlockMessagesWithStorageKey = domain_api
.block_messages(confirmed_block_hash)
.map_err(|_| Error::FetchAssignedMessages)?;

let filtered_messages = Self::filter_messages(domain_client, block_messages)?;

// short circuit if the there are no messages to relay
if filtered_messages.outbox.is_empty() && filtered_messages.inbox_responses.is_empty() {
return Ok(());
}

// generate domain proof that points to the state root of the domain block on Consensus chain.
let storage_key =
DomainStateRootStorage::<NumberFor<Block>, Block::Hash, Block::Hash>::storage_key(
Expand Down

0 comments on commit c14b3ff

Please sign in to comment.