Skip to content

Commit

Permalink
Merge pull request #1237 from subspace/messenger/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas authored Mar 8, 2023
2 parents 55e49a9 + e414f2b commit c912524
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions crates/subspace-node/res/chain-spec-raw-devnet.json

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions domains/client/relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ where
system_domain_client: &Arc<SDC>,
confirmed_block_hash: Block::Hash,
gossip_message_sink: &GossipMessageSink,
relay_confirmation_depth: NumberFor<SBlock>,
) -> Result<(), Error>
where
SBlock: BlockT,
Expand All @@ -316,17 +317,18 @@ where
let best_system_domain_block_hash = system_domain_client.info().best_hash;
let best_system_domain_block_header =
system_domain_client.expect_header(best_system_domain_block_hash)?;
let k_depth = system_domain_api.relay_confirmation_depth(best_system_domain_block_hash)?;

// verify if the core domain number is K-deep on System domain client
if !system_domain_api
.domain_best_number(best_system_domain_block_hash, core_domain_id)?
.map(|best_number| match best_number.checked_sub(&k_depth) {
None => false,
Some(best_confirmed) => {
best_confirmed >= (*core_domain_block_header.number()).into()
}
})
.map(
|best_number| match best_number.checked_sub(&relay_confirmation_depth) {
None => false,
Some(best_confirmed) => {
best_confirmed >= (*core_domain_block_header.number()).into()
}
},
)
.unwrap_or(false)
{
return Err(Error::CoreDomainNonConfirmedOnSystemDomain);
Expand All @@ -342,11 +344,14 @@ where
confirmed_block_hash.into(),
)?
.map(|state_root| state_root == (*core_domain_block_header.state_root()).into())
.unwrap_or(false)
.unwrap_or_else(|| {
// if this is genesis block, ignore as state root of genesis for core domain is not tracked on runtime
core_domain_number.is_zero()
})
{
tracing::error!(
target: LOG_TARGET,
"Core domain state root mismatch at: Number{:?}, Hash{:?}",
"Core domain state root mismatch at: Number: {:?}, Hash: {:?}",
core_domain_number,
confirmed_block_hash
);
Expand Down
1 change: 1 addition & 0 deletions domains/client/relayer/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub async fn relay_core_domain_messages<CDC, SDC, SBlock, Block, SDSO, CDSO>(
&system_domain_client,
block_hash,
&gossip_message_sink,
relay_confirmation_depth.into(),
)
},
combined_sync_oracle,
Expand Down
5 changes: 3 additions & 2 deletions domains/runtime/core-payments/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ construct_runtime!(
TransactionPayment: pallet_transaction_payment = 3,

// messenger stuff
Messenger: pallet_messenger = 7,
Transporter: pallet_transporter = 8,
// Note: Indexes should match the indexes of the System domain runtime
Messenger: pallet_messenger = 6,
Transporter: pallet_transporter = 7,

// Sudo account
Sudo: pallet_sudo = 100,
Expand Down
15 changes: 5 additions & 10 deletions domains/runtime/system/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ construct_runtime!(
ExecutorRegistry: pallet_executor_registry = 4,
Receipts: pallet_receipts = 9,
DomainRegistry: pallet_domain_registry = 5,
// Note: Indexes should be used by all other core domain for proper xdm decode.
Messenger: pallet_messenger = 6,
Transporter: pallet_transporter = 7,

Expand Down Expand Up @@ -647,7 +648,10 @@ impl_runtime_apis! {
fn extract_xdm_proof_state_roots(
extrinsic: &<Block as BlockT>::Extrinsic,
) -> Option<ExtractedStateRootsFromProof<BlockNumber, <Block as BlockT>::Hash, <Block as BlockT>::Hash>> {
extract_xdm_proof_state_roots(extrinsic)
match &extrinsic.function {
RuntimeCall::Messenger(call) => call.extract_xdm_proof_state_roots(),
_ => None,
}
}

fn confirmation_depth() -> BlockNumber {
Expand Down Expand Up @@ -710,12 +714,3 @@ impl_runtime_apis! {
}
}
}

fn extract_xdm_proof_state_roots(
ext: &UncheckedExtrinsic,
) -> Option<ExtractedStateRootsFromProof<BlockNumber, Hash, Hash>> {
match &ext.function {
RuntimeCall::Messenger(call) => call.extract_xdm_proof_state_roots(),
_ => None,
}
}

0 comments on commit c912524

Please sign in to comment.