Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Aug 30, 2024
1 parent fa4e771 commit e60932b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
14 changes: 4 additions & 10 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use sc_client_api::{
StorageProof,
};
use sc_telemetry::TelemetryWorkerHandle;
use sp_api::ProvideRuntimeApi;
use sp_api::{CallApiAt, CallApiAtParams, CallContext, ProvideRuntimeApi};
use sp_consensus::SyncOracle;
use sp_core::Pair;
use sp_state_machine::{Backend as StateBackend, StorageValue};
Expand Down Expand Up @@ -176,26 +176,20 @@ impl RelayChainInterface for RelayChainInProcessInterface {
Ok(self.backend.blockchain().info().finalized_hash)
}

async fn call_remote_runtime_function_encoded(
async fn call_runtime_api(
&self,
method_name: &'static str,
hash: PHash,
payload: &[u8],
) -> RelayChainResult<Vec<u8>> {
use sp_api::{CallApiAt, CallApiAtParams, CallContext, __private::Extensions};
use sp_state_machine::OverlayedChanges;
use std::cell::RefCell;

let overlayed_changes = OverlayedChanges::default();

Ok(self.full_client.call_api_at(CallApiAtParams {
at: hash,
function: method_name,
arguments: payload.to_vec(),
overlayed_changes: &RefCell::new(overlayed_changes),
overlayed_changes: &Default::default(),
call_context: CallContext::Offchain,
recorder: &None,
extensions: &RefCell::new(Extensions::new()),
extensions: &Default::default(),
})?)
}

Expand Down
11 changes: 6 additions & 5 deletions cumulus/client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ pub trait RelayChainInterface: Send + Sync {
/// Get the hash of the finalized block.
async fn finalized_block_hash(&self) -> RelayChainResult<PHash>;

async fn call_remote_runtime_function_encoded(
/// Call an arbitrary runtime api. The input and output are SCALE-encoded.
async fn call_runtime_api(
&self,
method_name: &'static str,
hash: RelayHash,
Expand Down Expand Up @@ -303,13 +304,13 @@ where
(**self).finalized_block_hash().await
}

async fn call_remote_runtime_function_encoded(
async fn call_runtime_api(
&self,
method_name: &'static str,
hash: RelayHash,
payload: &[u8],
) -> RelayChainResult<Vec<u8>> {
(**self).call_remote_runtime_function_encoded(method_name, hash, payload).await
(**self).call_runtime_api(method_name, hash, payload).await
}

async fn is_major_syncing(&self) -> RelayChainResult<bool> {
Expand Down Expand Up @@ -381,7 +382,7 @@ where
}
}

pub async fn call_remote_runtime_function<R>(
pub async fn call_runtime_api<R>(
client: &(impl RelayChainInterface + ?Sized),
method_name: &'static str,
hash: RelayHash,
Expand All @@ -391,7 +392,7 @@ where
R: Decode,
{
let res = client
.call_remote_runtime_function_encoded(method_name, hash, &payload.encode())
.call_runtime_api(method_name, hash, &payload.encode())
.await?;
Decode::decode(&mut &*res).map_err(Into::into)
}
2 changes: 1 addition & 1 deletion cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl RelayChainInterface for RelayChainRpcInterface {
self.rpc_client.chain_get_finalized_head().await
}

async fn call_remote_runtime_function_encoded(
async fn call_runtime_api(
&self,
method_name: &'static str,
hash: RelayHash,
Expand Down

0 comments on commit e60932b

Please sign in to comment.