Skip to content

Commit

Permalink
Merge pull request #2632 from subspace/fix-3h-compatibility
Browse files Browse the repository at this point in the history
Fix 3h incompatible with the `latest_confirmed_domain_block` runtime api
  • Loading branch information
NingLin-P authored Mar 20, 2024
2 parents 6db1fb9 + e4d39db commit b970b6a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion domains/client/relayer/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{BlockT, Error, GossipMessageSink, HeaderBackend, HeaderT, Relayer, L
use futures::StreamExt;
use sc_client_api::{AuxStore, BlockchainEvents, ProofProvider};
use sc_state_db::PruningMode;
use sp_api::{ApiError, ProvideRuntimeApi};
use sp_api::{ApiError, ApiExt, ProvideRuntimeApi};
use sp_consensus::SyncOracle;
use sp_domains::{DomainId, DomainsApi};
use sp_messenger::messages::ChainId;
Expand Down Expand Up @@ -137,6 +137,20 @@ pub async fn relay_domain_messages<CClient, Client, CBlock, Block, SO>(
.hash(consensus_block_number)?
.ok_or(ApiError::UnknownBlock(format!("Missing Hash for block number: {consensus_block_number:?}")))?;
let api = consensus_chain_client.runtime_api();

// TODO: This is used to keep compatible with gemini-3h, remove before next network
let api_version = api
.api_version::<dyn DomainsApi<CBlock, Block::Header>>(consensus_hash_to_process)
.map_err(sp_blockchain::Error::RuntimeApiError)?
.ok_or_else(|| {
sp_blockchain::Error::RuntimeApiError(ApiError::Application(
format!("DomainsApi not found at: {:?}", consensus_hash_to_process).into(),
))
})?;
if api_version < 2 {
return Ok(None)
}

let confirmed_domain_block =
api.latest_confirmed_domain_block(consensus_hash_to_process, domain_id)?;

Expand Down

0 comments on commit b970b6a

Please sign in to comment.