Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
BlockId removal: refactor of runtime API
Browse files Browse the repository at this point in the history
It changes the first argument of all generated runtime API calls from: `BlockId<Block>` to: `Block::Hash`
  • Loading branch information
michalkucharczyk committed Feb 15, 2023
1 parent 9a17c4e commit befb596
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions node/subsystem-types/src/runtime_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,21 @@ where
T::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
{
async fn validators(&self, at: Hash) -> Result<Vec<ValidatorId>, ApiError> {
self.runtime_api().validators(&BlockId::Hash(at))
self.runtime_api().validators(at)
}

async fn validator_groups(
&self,
at: Hash,
) -> Result<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>), ApiError> {
self.runtime_api().validator_groups(&BlockId::Hash(at))
self.runtime_api().validator_groups(at)
}

async fn availability_cores(
&self,
at: Hash,
) -> Result<Vec<CoreState<Hash, BlockNumber>>, ApiError> {
self.runtime_api().availability_cores(&BlockId::Hash(at))
self.runtime_api().availability_cores(at)
}

async fn persisted_validation_data(
Expand All @@ -243,7 +243,7 @@ where
assumption: OccupiedCoreAssumption,
) -> Result<Option<PersistedValidationData<Hash, BlockNumber>>, ApiError> {
self.runtime_api()
.persisted_validation_data(&BlockId::Hash(at), para_id, assumption)
.persisted_validation_data(at, para_id, assumption)
}

async fn assumed_validation_data(
Expand All @@ -254,7 +254,7 @@ where
) -> Result<Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)>, ApiError>
{
self.runtime_api().assumed_validation_data(
&BlockId::Hash(at),
at,
para_id,
expected_persisted_validation_data_hash,
)
Expand All @@ -267,11 +267,11 @@ where
outputs: CandidateCommitments,
) -> Result<bool, ApiError> {
self.runtime_api()
.check_validation_outputs(&BlockId::Hash(at), para_id, outputs)
.check_validation_outputs(at, para_id, outputs)
}

async fn session_index_for_child(&self, at: Hash) -> Result<SessionIndex, ApiError> {
self.runtime_api().session_index_for_child(&BlockId::Hash(at))
self.runtime_api().session_index_for_child(at)
}

async fn validation_code(
Expand All @@ -280,50 +280,50 @@ where
para_id: Id,
assumption: OccupiedCoreAssumption,
) -> Result<Option<ValidationCode>, ApiError> {
self.runtime_api().validation_code(&BlockId::Hash(at), para_id, assumption)
self.runtime_api().validation_code(at, para_id, assumption)
}

async fn candidate_pending_availability(
&self,
at: Hash,
para_id: Id,
) -> Result<Option<CommittedCandidateReceipt<Hash>>, ApiError> {
self.runtime_api().candidate_pending_availability(&BlockId::Hash(at), para_id)
self.runtime_api().candidate_pending_availability(at, para_id)
}

async fn candidate_events(&self, at: Hash) -> Result<Vec<CandidateEvent<Hash>>, ApiError> {
self.runtime_api().candidate_events(&BlockId::Hash(at))
self.runtime_api().candidate_events(at)
}

async fn dmq_contents(
&self,
at: Hash,
recipient: Id,
) -> Result<Vec<InboundDownwardMessage<BlockNumber>>, ApiError> {
self.runtime_api().dmq_contents(&BlockId::Hash(at), recipient)
self.runtime_api().dmq_contents(at, recipient)
}

async fn inbound_hrmp_channels_contents(
&self,
at: Hash,
recipient: Id,
) -> Result<BTreeMap<Id, Vec<InboundHrmpMessage<BlockNumber>>>, ApiError> {
self.runtime_api().inbound_hrmp_channels_contents(&BlockId::Hash(at), recipient)
self.runtime_api().inbound_hrmp_channels_contents(at, recipient)
}

async fn validation_code_by_hash(
&self,
at: Hash,
hash: ValidationCodeHash,
) -> Result<Option<ValidationCode>, ApiError> {
self.runtime_api().validation_code_by_hash(&BlockId::Hash(at), hash)
self.runtime_api().validation_code_by_hash(at, hash)
}

async fn on_chain_votes(
&self,
at: Hash,
) -> Result<Option<ScrapedOnChainVotes<Hash>>, ApiError> {
self.runtime_api().on_chain_votes(&BlockId::Hash(at))
self.runtime_api().on_chain_votes(at)
}

async fn session_executor_params(
Expand All @@ -339,7 +339,7 @@ where
at: Hash,
index: SessionIndex,
) -> Result<Option<SessionInfo>, ApiError> {
self.runtime_api().session_info(&BlockId::Hash(at), index)
self.runtime_api().session_info(at, index)
}

async fn submit_pvf_check_statement(
Expand All @@ -349,11 +349,11 @@ where
signature: ValidatorSignature,
) -> Result<(), ApiError> {
self.runtime_api()
.submit_pvf_check_statement(&BlockId::Hash(at), stmt, signature)
.submit_pvf_check_statement(at, stmt, signature)
}

async fn pvfs_require_precheck(&self, at: Hash) -> Result<Vec<ValidationCodeHash>, ApiError> {
self.runtime_api().pvfs_require_precheck(&BlockId::Hash(at))
self.runtime_api().pvfs_require_precheck(at)
}

async fn validation_code_hash(
Expand All @@ -362,22 +362,22 @@ where
para_id: Id,
assumption: OccupiedCoreAssumption,
) -> Result<Option<ValidationCodeHash>, ApiError> {
self.runtime_api().validation_code_hash(&BlockId::Hash(at), para_id, assumption)
self.runtime_api().validation_code_hash(at, para_id, assumption)
}

async fn current_epoch(&self, at: Hash) -> Result<Epoch, ApiError> {
self.runtime_api().current_epoch(&BlockId::Hash(at))
self.runtime_api().current_epoch(at)
}

async fn authorities(
&self,
at: Hash,
) -> std::result::Result<Vec<sp_authority_discovery::AuthorityId>, ApiError> {
self.runtime_api().authorities(&BlockId::Hash(at))
self.runtime_api().authorities(at)
}

async fn api_version_parachain_host(&self, at: Hash) -> Result<Option<u32>, ApiError> {
self.runtime_api().api_version::<dyn ParachainHost<Block>>(&BlockId::Hash(at))
self.runtime_api().api_version::<dyn ParachainHost<Block>>(at)
}

#[warn(deprecated)]
Expand All @@ -387,13 +387,13 @@ where
index: SessionIndex,
) -> Result<Option<OldV1SessionInfo>, ApiError> {
#[allow(deprecated)]
self.runtime_api().session_info_before_version_2(&BlockId::Hash(at), index)
self.runtime_api().session_info_before_version_2(at, index)
}

async fn disputes(
&self,
at: Hash,
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, ApiError> {
self.runtime_api().disputes(&BlockId::Hash(at))
self.runtime_api().disputes(at)
}
}

0 comments on commit befb596

Please sign in to comment.