Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3h incompatible with the latest_confirmed_domain_block runtime api #2632

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading