mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
cargo +nightly fmt (#3540)
* cargo +nightly fmt * add cargo-fmt check to ci * update ci * fmt * fmt * skip macro * ignore bridges
This commit is contained in:
@@ -71,18 +71,32 @@ impl<T> ResidentSize for VecOfDoesNotAllocate<T> {
|
||||
pub(crate) struct RequestResultCache {
|
||||
authorities: MemoryLruCache<Hash, VecOfDoesNotAllocate<AuthorityDiscoveryId>>,
|
||||
validators: MemoryLruCache<Hash, ResidentSizeOf<Vec<ValidatorId>>>,
|
||||
validator_groups: MemoryLruCache<Hash, ResidentSizeOf<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo)>>,
|
||||
validator_groups:
|
||||
MemoryLruCache<Hash, ResidentSizeOf<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo)>>,
|
||||
availability_cores: MemoryLruCache<Hash, ResidentSizeOf<Vec<CoreState>>>,
|
||||
persisted_validation_data: MemoryLruCache<(Hash, ParaId, OccupiedCoreAssumption), ResidentSizeOf<Option<PersistedValidationData>>>,
|
||||
check_validation_outputs: MemoryLruCache<(Hash, ParaId, CandidateCommitments), ResidentSizeOf<bool>>,
|
||||
persisted_validation_data: MemoryLruCache<
|
||||
(Hash, ParaId, OccupiedCoreAssumption),
|
||||
ResidentSizeOf<Option<PersistedValidationData>>,
|
||||
>,
|
||||
check_validation_outputs:
|
||||
MemoryLruCache<(Hash, ParaId, CandidateCommitments), ResidentSizeOf<bool>>,
|
||||
session_index_for_child: MemoryLruCache<Hash, ResidentSizeOf<SessionIndex>>,
|
||||
validation_code: MemoryLruCache<(Hash, ParaId, OccupiedCoreAssumption), ResidentSizeOf<Option<ValidationCode>>>,
|
||||
validation_code_by_hash: MemoryLruCache<ValidationCodeHash, ResidentSizeOf<Option<ValidationCode>>>,
|
||||
candidate_pending_availability: MemoryLruCache<(Hash, ParaId), ResidentSizeOf<Option<CommittedCandidateReceipt>>>,
|
||||
validation_code: MemoryLruCache<
|
||||
(Hash, ParaId, OccupiedCoreAssumption),
|
||||
ResidentSizeOf<Option<ValidationCode>>,
|
||||
>,
|
||||
validation_code_by_hash:
|
||||
MemoryLruCache<ValidationCodeHash, ResidentSizeOf<Option<ValidationCode>>>,
|
||||
candidate_pending_availability:
|
||||
MemoryLruCache<(Hash, ParaId), ResidentSizeOf<Option<CommittedCandidateReceipt>>>,
|
||||
candidate_events: MemoryLruCache<Hash, ResidentSizeOf<Vec<CandidateEvent>>>,
|
||||
session_info: MemoryLruCache<SessionIndex, ResidentSizeOf<Option<SessionInfo>>>,
|
||||
dmq_contents: MemoryLruCache<(Hash, ParaId), ResidentSizeOf<Vec<InboundDownwardMessage<BlockNumber>>>>,
|
||||
inbound_hrmp_channels_contents: MemoryLruCache<(Hash, ParaId), ResidentSizeOf<BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>>>,
|
||||
dmq_contents:
|
||||
MemoryLruCache<(Hash, ParaId), ResidentSizeOf<Vec<InboundDownwardMessage<BlockNumber>>>>,
|
||||
inbound_hrmp_channels_contents: MemoryLruCache<
|
||||
(Hash, ParaId),
|
||||
ResidentSizeOf<BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>>,
|
||||
>,
|
||||
current_babe_epoch: MemoryLruCache<Hash, DoesNotAllocate<Epoch>>,
|
||||
}
|
||||
|
||||
@@ -98,7 +112,9 @@ impl Default for RequestResultCache {
|
||||
session_index_for_child: MemoryLruCache::new(SESSION_INDEX_FOR_CHILD_CACHE_SIZE),
|
||||
validation_code: MemoryLruCache::new(VALIDATION_CODE_CACHE_SIZE),
|
||||
validation_code_by_hash: MemoryLruCache::new(VALIDATION_CODE_CACHE_SIZE),
|
||||
candidate_pending_availability: MemoryLruCache::new(CANDIDATE_PENDING_AVAILABILITY_CACHE_SIZE),
|
||||
candidate_pending_availability: MemoryLruCache::new(
|
||||
CANDIDATE_PENDING_AVAILABILITY_CACHE_SIZE,
|
||||
),
|
||||
candidate_events: MemoryLruCache::new(CANDIDATE_EVENTS_CACHE_SIZE),
|
||||
session_info: MemoryLruCache::new(SESSION_INFO_CACHE_SIZE),
|
||||
dmq_contents: MemoryLruCache::new(DMQ_CONTENTS_CACHE_SIZE),
|
||||
@@ -109,11 +125,18 @@ impl Default for RequestResultCache {
|
||||
}
|
||||
|
||||
impl RequestResultCache {
|
||||
pub(crate) fn authorities(&mut self, relay_parent: &Hash) -> Option<&Vec<AuthorityDiscoveryId>> {
|
||||
pub(crate) fn authorities(
|
||||
&mut self,
|
||||
relay_parent: &Hash,
|
||||
) -> Option<&Vec<AuthorityDiscoveryId>> {
|
||||
self.authorities.get(relay_parent).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_authorities(&mut self, relay_parent: Hash, authorities: Vec<AuthorityDiscoveryId>) {
|
||||
pub(crate) fn cache_authorities(
|
||||
&mut self,
|
||||
relay_parent: Hash,
|
||||
authorities: Vec<AuthorityDiscoveryId>,
|
||||
) {
|
||||
self.authorities.insert(relay_parent, VecOfDoesNotAllocate(authorities));
|
||||
}
|
||||
|
||||
@@ -125,11 +148,18 @@ impl RequestResultCache {
|
||||
self.validators.insert(relay_parent, ResidentSizeOf(validators));
|
||||
}
|
||||
|
||||
pub(crate) fn validator_groups(&mut self, relay_parent: &Hash) -> Option<&(Vec<Vec<ValidatorIndex>>, GroupRotationInfo)> {
|
||||
pub(crate) fn validator_groups(
|
||||
&mut self,
|
||||
relay_parent: &Hash,
|
||||
) -> Option<&(Vec<Vec<ValidatorIndex>>, GroupRotationInfo)> {
|
||||
self.validator_groups.get(relay_parent).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_validator_groups(&mut self, relay_parent: Hash, groups: (Vec<Vec<ValidatorIndex>>, GroupRotationInfo)) {
|
||||
pub(crate) fn cache_validator_groups(
|
||||
&mut self,
|
||||
relay_parent: Hash,
|
||||
groups: (Vec<Vec<ValidatorIndex>>, GroupRotationInfo),
|
||||
) {
|
||||
self.validator_groups.insert(relay_parent, ResidentSizeOf(groups));
|
||||
}
|
||||
|
||||
@@ -141,19 +171,33 @@ impl RequestResultCache {
|
||||
self.availability_cores.insert(relay_parent, ResidentSizeOf(cores));
|
||||
}
|
||||
|
||||
pub(crate) fn persisted_validation_data(&mut self, key: (Hash, ParaId, OccupiedCoreAssumption)) -> Option<&Option<PersistedValidationData>> {
|
||||
pub(crate) fn persisted_validation_data(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, OccupiedCoreAssumption),
|
||||
) -> Option<&Option<PersistedValidationData>> {
|
||||
self.persisted_validation_data.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_persisted_validation_data(&mut self, key: (Hash, ParaId, OccupiedCoreAssumption), data: Option<PersistedValidationData>) {
|
||||
pub(crate) fn cache_persisted_validation_data(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, OccupiedCoreAssumption),
|
||||
data: Option<PersistedValidationData>,
|
||||
) {
|
||||
self.persisted_validation_data.insert(key, ResidentSizeOf(data));
|
||||
}
|
||||
|
||||
pub(crate) fn check_validation_outputs(&mut self, key: (Hash, ParaId, CandidateCommitments)) -> Option<&bool> {
|
||||
pub(crate) fn check_validation_outputs(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, CandidateCommitments),
|
||||
) -> Option<&bool> {
|
||||
self.check_validation_outputs.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_check_validation_outputs(&mut self, key: (Hash, ParaId, CandidateCommitments), value: bool) {
|
||||
pub(crate) fn cache_check_validation_outputs(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, CandidateCommitments),
|
||||
value: bool,
|
||||
) {
|
||||
self.check_validation_outputs.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
@@ -161,33 +205,58 @@ impl RequestResultCache {
|
||||
self.session_index_for_child.get(relay_parent).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_session_index_for_child(&mut self, relay_parent: Hash, index: SessionIndex) {
|
||||
pub(crate) fn cache_session_index_for_child(
|
||||
&mut self,
|
||||
relay_parent: Hash,
|
||||
index: SessionIndex,
|
||||
) {
|
||||
self.session_index_for_child.insert(relay_parent, ResidentSizeOf(index));
|
||||
}
|
||||
|
||||
pub(crate) fn validation_code(&mut self, key: (Hash, ParaId, OccupiedCoreAssumption)) -> Option<&Option<ValidationCode>> {
|
||||
pub(crate) fn validation_code(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, OccupiedCoreAssumption),
|
||||
) -> Option<&Option<ValidationCode>> {
|
||||
self.validation_code.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_validation_code(&mut self, key: (Hash, ParaId, OccupiedCoreAssumption), value: Option<ValidationCode>) {
|
||||
pub(crate) fn cache_validation_code(
|
||||
&mut self,
|
||||
key: (Hash, ParaId, OccupiedCoreAssumption),
|
||||
value: Option<ValidationCode>,
|
||||
) {
|
||||
self.validation_code.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
// the actual key is `ValidationCodeHash` (`Hash` is ignored),
|
||||
// but we keep the interface that way to keep the macro simple
|
||||
pub(crate) fn validation_code_by_hash(&mut self, key: (Hash, ValidationCodeHash)) -> Option<&Option<ValidationCode>> {
|
||||
pub(crate) fn validation_code_by_hash(
|
||||
&mut self,
|
||||
key: (Hash, ValidationCodeHash),
|
||||
) -> Option<&Option<ValidationCode>> {
|
||||
self.validation_code_by_hash.get(&key.1).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_validation_code_by_hash(&mut self, key: ValidationCodeHash, value: Option<ValidationCode>) {
|
||||
pub(crate) fn cache_validation_code_by_hash(
|
||||
&mut self,
|
||||
key: ValidationCodeHash,
|
||||
value: Option<ValidationCode>,
|
||||
) {
|
||||
self.validation_code_by_hash.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
pub(crate) fn candidate_pending_availability(&mut self, key: (Hash, ParaId)) -> Option<&Option<CommittedCandidateReceipt>> {
|
||||
pub(crate) fn candidate_pending_availability(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
) -> Option<&Option<CommittedCandidateReceipt>> {
|
||||
self.candidate_pending_availability.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_candidate_pending_availability(&mut self, key: (Hash, ParaId), value: Option<CommittedCandidateReceipt>) {
|
||||
pub(crate) fn cache_candidate_pending_availability(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
value: Option<CommittedCandidateReceipt>,
|
||||
) {
|
||||
self.candidate_pending_availability.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
@@ -195,11 +264,18 @@ impl RequestResultCache {
|
||||
self.candidate_events.get(relay_parent).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_candidate_events(&mut self, relay_parent: Hash, events: Vec<CandidateEvent>) {
|
||||
pub(crate) fn cache_candidate_events(
|
||||
&mut self,
|
||||
relay_parent: Hash,
|
||||
events: Vec<CandidateEvent>,
|
||||
) {
|
||||
self.candidate_events.insert(relay_parent, ResidentSizeOf(events));
|
||||
}
|
||||
|
||||
pub(crate) fn session_info(&mut self, key: (Hash, SessionIndex)) -> Option<&Option<SessionInfo>> {
|
||||
pub(crate) fn session_info(
|
||||
&mut self,
|
||||
key: (Hash, SessionIndex),
|
||||
) -> Option<&Option<SessionInfo>> {
|
||||
self.session_info.get(&key.1).map(|v| &v.0)
|
||||
}
|
||||
|
||||
@@ -207,19 +283,33 @@ impl RequestResultCache {
|
||||
self.session_info.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
pub(crate) fn dmq_contents(&mut self, key: (Hash, ParaId)) -> Option<&Vec<InboundDownwardMessage<BlockNumber>>> {
|
||||
pub(crate) fn dmq_contents(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
) -> Option<&Vec<InboundDownwardMessage<BlockNumber>>> {
|
||||
self.dmq_contents.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_dmq_contents(&mut self, key: (Hash, ParaId), value: Vec<InboundDownwardMessage<BlockNumber>>) {
|
||||
pub(crate) fn cache_dmq_contents(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
value: Vec<InboundDownwardMessage<BlockNumber>>,
|
||||
) {
|
||||
self.dmq_contents.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
pub(crate) fn inbound_hrmp_channels_contents(&mut self, key: (Hash, ParaId)) -> Option<&BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>> {
|
||||
pub(crate) fn inbound_hrmp_channels_contents(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
) -> Option<&BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>> {
|
||||
self.inbound_hrmp_channels_contents.get(&key).map(|v| &v.0)
|
||||
}
|
||||
|
||||
pub(crate) fn cache_inbound_hrmp_channel_contents(&mut self, key: (Hash, ParaId), value: BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>) {
|
||||
pub(crate) fn cache_inbound_hrmp_channel_contents(
|
||||
&mut self,
|
||||
key: (Hash, ParaId),
|
||||
value: BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>,
|
||||
) {
|
||||
self.inbound_hrmp_channels_contents.insert(key, ResidentSizeOf(value));
|
||||
}
|
||||
|
||||
@@ -246,6 +336,10 @@ pub(crate) enum RequestResult {
|
||||
CandidateEvents(Hash, Vec<CandidateEvent>),
|
||||
SessionInfo(Hash, SessionIndex, Option<SessionInfo>),
|
||||
DmqContents(Hash, ParaId, Vec<InboundDownwardMessage<BlockNumber>>),
|
||||
InboundHrmpChannelsContents(Hash, ParaId, BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>),
|
||||
InboundHrmpChannelsContents(
|
||||
Hash,
|
||||
ParaId,
|
||||
BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>>,
|
||||
),
|
||||
CurrentBabeEpoch(Hash, Epoch),
|
||||
}
|
||||
|
||||
@@ -22,27 +22,23 @@
|
||||
#![deny(unused_crate_dependencies)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use polkadot_subsystem::{
|
||||
SubsystemError, SubsystemResult,
|
||||
FromOverseer, OverseerSignal, SpawnedSubsystem,
|
||||
SubsystemContext,
|
||||
errors::RuntimeApiError,
|
||||
messages::{
|
||||
RuntimeApiMessage, RuntimeApiRequest as Request,
|
||||
},
|
||||
overseer,
|
||||
};
|
||||
use polkadot_node_subsystem_util::metrics::{self, prometheus};
|
||||
use polkadot_primitives::v1::{Block, BlockId, Hash, ParachainHost};
|
||||
use polkadot_subsystem::{
|
||||
errors::RuntimeApiError,
|
||||
messages::{RuntimeApiMessage, RuntimeApiRequest as Request},
|
||||
overseer, FromOverseer, OverseerSignal, SpawnedSubsystem, SubsystemContext, SubsystemError,
|
||||
SubsystemResult,
|
||||
};
|
||||
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_authority_discovery::AuthorityDiscoveryApi;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
use sp_consensus_babe::BabeApi;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
use futures::{prelude::*, stream::FuturesUnordered, channel::oneshot, select};
|
||||
use std::{sync::Arc, collections::VecDeque, pin::Pin};
|
||||
use cache::{RequestResult, RequestResultCache};
|
||||
use futures::{channel::oneshot, prelude::*, select, stream::FuturesUnordered};
|
||||
use std::{collections::VecDeque, pin::Pin, sync::Arc};
|
||||
|
||||
mod cache;
|
||||
|
||||
@@ -75,7 +71,11 @@ pub struct RuntimeApiSubsystem<Client> {
|
||||
|
||||
impl<Client> RuntimeApiSubsystem<Client> {
|
||||
/// Create a new Runtime API subsystem wrapping the given client and metrics.
|
||||
pub fn new(client: Arc<Client>, metrics: Metrics, spawn_handle: impl SpawnNamed + 'static) -> Self {
|
||||
pub fn new(
|
||||
client: Arc<Client>,
|
||||
metrics: Metrics,
|
||||
spawn_handle: impl SpawnNamed + 'static,
|
||||
) -> Self {
|
||||
RuntimeApiSubsystem {
|
||||
client,
|
||||
metrics,
|
||||
@@ -87,21 +87,20 @@ impl<Client> RuntimeApiSubsystem<Client> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Client, Context> overseer::Subsystem<Context, SubsystemError> for RuntimeApiSubsystem<Client> where
|
||||
impl<Client, Context> overseer::Subsystem<Context, SubsystemError> for RuntimeApiSubsystem<Client>
|
||||
where
|
||||
Client: ProvideRuntimeApi<Block> + Send + 'static + Sync,
|
||||
Client::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
Context: SubsystemContext<Message = RuntimeApiMessage>,
|
||||
Context: overseer::SubsystemContext<Message = RuntimeApiMessage>,
|
||||
{
|
||||
fn start(self, ctx: Context) -> SpawnedSubsystem {
|
||||
SpawnedSubsystem {
|
||||
future: run(ctx, self).boxed(),
|
||||
name: "runtime-api-subsystem",
|
||||
}
|
||||
SpawnedSubsystem { future: run(ctx, self).boxed(), name: "runtime-api-subsystem" }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Client> RuntimeApiSubsystem<Client> where
|
||||
impl<Client> RuntimeApiSubsystem<Client>
|
||||
where
|
||||
Client: ProvideRuntimeApi<Block> + Send + 'static + Sync,
|
||||
Client::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
{
|
||||
@@ -117,26 +116,31 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
self.requests_cache.cache_validator_groups(relay_parent, groups),
|
||||
AvailabilityCores(relay_parent, cores) =>
|
||||
self.requests_cache.cache_availability_cores(relay_parent, cores),
|
||||
PersistedValidationData(relay_parent, para_id, assumption, data) =>
|
||||
self.requests_cache.cache_persisted_validation_data((relay_parent, para_id, assumption), data),
|
||||
CheckValidationOutputs(relay_parent, para_id, commitments, b) =>
|
||||
self.requests_cache.cache_check_validation_outputs((relay_parent, para_id, commitments), b),
|
||||
PersistedValidationData(relay_parent, para_id, assumption, data) => self
|
||||
.requests_cache
|
||||
.cache_persisted_validation_data((relay_parent, para_id, assumption), data),
|
||||
CheckValidationOutputs(relay_parent, para_id, commitments, b) => self
|
||||
.requests_cache
|
||||
.cache_check_validation_outputs((relay_parent, para_id, commitments), b),
|
||||
SessionIndexForChild(relay_parent, session_index) =>
|
||||
self.requests_cache.cache_session_index_for_child(relay_parent, session_index),
|
||||
ValidationCode(relay_parent, para_id, assumption, code) =>
|
||||
self.requests_cache.cache_validation_code((relay_parent, para_id, assumption), code),
|
||||
ValidationCode(relay_parent, para_id, assumption, code) => self
|
||||
.requests_cache
|
||||
.cache_validation_code((relay_parent, para_id, assumption), code),
|
||||
ValidationCodeByHash(_relay_parent, validation_code_hash, code) =>
|
||||
self.requests_cache.cache_validation_code_by_hash(validation_code_hash, code),
|
||||
CandidatePendingAvailability(relay_parent, para_id, candidate) =>
|
||||
self.requests_cache.cache_candidate_pending_availability((relay_parent, para_id), candidate),
|
||||
CandidatePendingAvailability(relay_parent, para_id, candidate) => self
|
||||
.requests_cache
|
||||
.cache_candidate_pending_availability((relay_parent, para_id), candidate),
|
||||
CandidateEvents(relay_parent, events) =>
|
||||
self.requests_cache.cache_candidate_events(relay_parent, events),
|
||||
SessionInfo(_relay_parent, session_index, info) =>
|
||||
self.requests_cache.cache_session_info(session_index, info),
|
||||
DmqContents(relay_parent, para_id, messages) =>
|
||||
self.requests_cache.cache_dmq_contents((relay_parent, para_id), messages),
|
||||
InboundHrmpChannelsContents(relay_parent, para_id, contents) =>
|
||||
self.requests_cache.cache_inbound_hrmp_channel_contents((relay_parent, para_id), contents),
|
||||
InboundHrmpChannelsContents(relay_parent, para_id, contents) => self
|
||||
.requests_cache
|
||||
.cache_inbound_hrmp_channel_contents((relay_parent, para_id), contents),
|
||||
CurrentBabeEpoch(relay_parent, epoch) =>
|
||||
self.requests_cache.cache_current_babe_epoch(relay_parent, epoch),
|
||||
}
|
||||
@@ -169,12 +173,12 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
}
|
||||
|
||||
match request {
|
||||
Request::Authorities(sender) => query!(authorities(), sender)
|
||||
.map(|sender| Request::Authorities(sender)),
|
||||
Request::Validators(sender) => query!(validators(), sender)
|
||||
.map(|sender| Request::Validators(sender)),
|
||||
Request::ValidatorGroups(sender) => query!(validator_groups(), sender)
|
||||
.map(|sender| Request::ValidatorGroups(sender)),
|
||||
Request::Authorities(sender) =>
|
||||
query!(authorities(), sender).map(|sender| Request::Authorities(sender)),
|
||||
Request::Validators(sender) =>
|
||||
query!(validators(), sender).map(|sender| Request::Validators(sender)),
|
||||
Request::ValidatorGroups(sender) =>
|
||||
query!(validator_groups(), sender).map(|sender| Request::ValidatorGroups(sender)),
|
||||
Request::AvailabilityCores(sender) => query!(availability_cores(), sender)
|
||||
.map(|sender| Request::AvailabilityCores(sender)),
|
||||
Request::PersistedValidationData(para, assumption, sender) =>
|
||||
@@ -183,9 +187,8 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
Request::CheckValidationOutputs(para, commitments, sender) =>
|
||||
query!(check_validation_outputs(para, commitments), sender)
|
||||
.map(|sender| Request::CheckValidationOutputs(para, commitments, sender)),
|
||||
Request::SessionIndexForChild(sender) =>
|
||||
query!(session_index_for_child(), sender)
|
||||
.map(|sender| Request::SessionIndexForChild(sender)),
|
||||
Request::SessionIndexForChild(sender) => query!(session_index_for_child(), sender)
|
||||
.map(|sender| Request::SessionIndexForChild(sender)),
|
||||
Request::ValidationCode(para, assumption, sender) =>
|
||||
query!(validation_code(para, assumption), sender)
|
||||
.map(|sender| Request::ValidationCode(para, assumption, sender)),
|
||||
@@ -195,18 +198,17 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
Request::CandidatePendingAvailability(para, sender) =>
|
||||
query!(candidate_pending_availability(para), sender)
|
||||
.map(|sender| Request::CandidatePendingAvailability(para, sender)),
|
||||
Request::CandidateEvents(sender) => query!(candidate_events(), sender)
|
||||
.map(|sender| Request::CandidateEvents(sender)),
|
||||
Request::CandidateEvents(sender) =>
|
||||
query!(candidate_events(), sender).map(|sender| Request::CandidateEvents(sender)),
|
||||
Request::SessionInfo(index, sender) => query!(session_info(index), sender)
|
||||
.map(|sender| Request::SessionInfo(index, sender)),
|
||||
Request::DmqContents(id, sender) => query!(dmq_contents(id), sender)
|
||||
.map(|sender| Request::DmqContents(id, sender)),
|
||||
Request::DmqContents(id, sender) =>
|
||||
query!(dmq_contents(id), sender).map(|sender| Request::DmqContents(id, sender)),
|
||||
Request::InboundHrmpChannelsContents(id, sender) =>
|
||||
query!(inbound_hrmp_channels_contents(id), sender)
|
||||
.map(|sender| Request::InboundHrmpChannelsContents(id, sender)),
|
||||
Request::CurrentBabeEpoch(sender) =>
|
||||
query!(current_babe_epoch(), sender)
|
||||
.map(|sender| Request::CurrentBabeEpoch(sender)),
|
||||
query!(current_babe_epoch(), sender).map(|sender| Request::CurrentBabeEpoch(sender)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +226,10 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
};
|
||||
|
||||
let request = async move {
|
||||
let result = make_runtime_api_request(
|
||||
client,
|
||||
metrics,
|
||||
relay_parent,
|
||||
request,
|
||||
);
|
||||
let result = make_runtime_api_request(client, metrics, relay_parent, request);
|
||||
let _ = sender.send(result);
|
||||
}.boxed();
|
||||
}
|
||||
.boxed();
|
||||
|
||||
if self.active_requests.len() >= MAX_PARALLEL_REQUESTS {
|
||||
self.waiting_requests.push_back((request, receiver));
|
||||
@@ -271,7 +269,8 @@ impl<Client> RuntimeApiSubsystem<Client> where
|
||||
async fn run<Client, Context>(
|
||||
mut ctx: Context,
|
||||
mut subsystem: RuntimeApiSubsystem<Client>,
|
||||
) -> SubsystemResult<()> where
|
||||
) -> SubsystemResult<()>
|
||||
where
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static,
|
||||
Client::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
Context: SubsystemContext<Message = RuntimeApiMessage>,
|
||||
@@ -323,12 +322,14 @@ where
|
||||
Request::Authorities(sender) => query!(Authorities, authorities(), sender),
|
||||
Request::Validators(sender) => query!(Validators, validators(), sender),
|
||||
Request::ValidatorGroups(sender) => query!(ValidatorGroups, validator_groups(), sender),
|
||||
Request::AvailabilityCores(sender) => query!(AvailabilityCores, availability_cores(), sender),
|
||||
Request::AvailabilityCores(sender) =>
|
||||
query!(AvailabilityCores, availability_cores(), sender),
|
||||
Request::PersistedValidationData(para, assumption, sender) =>
|
||||
query!(PersistedValidationData, persisted_validation_data(para, assumption), sender),
|
||||
Request::CheckValidationOutputs(para, commitments, sender) =>
|
||||
query!(CheckValidationOutputs, check_validation_outputs(para, commitments), sender),
|
||||
Request::SessionIndexForChild(sender) => query!(SessionIndexForChild, session_index_for_child(), sender),
|
||||
Request::SessionIndexForChild(sender) =>
|
||||
query!(SessionIndexForChild, session_index_for_child(), sender),
|
||||
Request::ValidationCode(para, assumption, sender) =>
|
||||
query!(ValidationCode, validation_code(para, assumption), sender),
|
||||
Request::ValidationCodeByHash(validation_code_hash, sender) =>
|
||||
@@ -338,7 +339,8 @@ where
|
||||
Request::CandidateEvents(sender) => query!(CandidateEvents, candidate_events(), sender),
|
||||
Request::SessionInfo(index, sender) => query!(SessionInfo, session_info(index), sender),
|
||||
Request::DmqContents(id, sender) => query!(DmqContents, dmq_contents(id), sender),
|
||||
Request::InboundHrmpChannelsContents(id, sender) => query!(InboundHrmpChannelsContents, inbound_hrmp_channels_contents(id), sender),
|
||||
Request::InboundHrmpChannelsContents(id, sender) =>
|
||||
query!(InboundHrmpChannelsContents, inbound_hrmp_channels_contents(id), sender),
|
||||
Request::CurrentBabeEpoch(sender) => query!(CurrentBabeEpoch, current_epoch(), sender),
|
||||
}
|
||||
}
|
||||
@@ -365,12 +367,15 @@ impl Metrics {
|
||||
}
|
||||
|
||||
fn on_cached_request(&self) {
|
||||
self.0.as_ref()
|
||||
self.0
|
||||
.as_ref()
|
||||
.map(|metrics| metrics.chain_api_requests.with_label_values(&["cached"]).inc());
|
||||
}
|
||||
|
||||
/// Provide a timer for `make_runtime_api_request` which observes on drop.
|
||||
fn time_make_runtime_api_request(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
fn time_make_runtime_api_request(
|
||||
&self,
|
||||
) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.make_runtime_api_request.start_timer())
|
||||
}
|
||||
}
|
||||
@@ -389,12 +394,10 @@ impl metrics::Metrics for Metrics {
|
||||
registry,
|
||||
)?,
|
||||
make_runtime_api_request: prometheus::register(
|
||||
prometheus::Histogram::with_opts(
|
||||
prometheus::HistogramOpts::new(
|
||||
"parachain_runtime_api_make_runtime_api_request",
|
||||
"Time spent within `runtime_api::make_runtime_api_request`",
|
||||
)
|
||||
)?,
|
||||
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
|
||||
"parachain_runtime_api_make_runtime_api_request",
|
||||
"Time spent within `runtime_api::make_runtime_api_request`",
|
||||
))?,
|
||||
registry,
|
||||
)?,
|
||||
};
|
||||
|
||||
@@ -16,18 +16,19 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use polkadot_primitives::v1::{
|
||||
ValidatorId, ValidatorIndex, GroupRotationInfo, CoreState, PersistedValidationData,
|
||||
Id as ParaId, OccupiedCoreAssumption, SessionIndex, ValidationCode,
|
||||
CommittedCandidateReceipt, CandidateEvent, InboundDownwardMessage,
|
||||
InboundHrmpMessage, SessionInfo, AuthorityDiscoveryId, ValidationCodeHash,
|
||||
};
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use std::{collections::{HashMap, BTreeMap}, sync::{Arc, Mutex}};
|
||||
use futures::channel::oneshot;
|
||||
use polkadot_node_primitives::{
|
||||
BabeEpoch, BabeEpochConfiguration, BabeAllowedSlots,
|
||||
use polkadot_node_primitives::{BabeAllowedSlots, BabeEpoch, BabeEpochConfiguration};
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
use polkadot_primitives::v1::{
|
||||
AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo,
|
||||
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption,
|
||||
PersistedValidationData, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash,
|
||||
ValidatorId, ValidatorIndex,
|
||||
};
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
@@ -201,9 +202,11 @@ fn requests_authorities() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::Authorities(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::Authorities(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.authorities);
|
||||
|
||||
@@ -225,9 +228,11 @@ fn requests_validators() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::Validators(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::Validators(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validators);
|
||||
|
||||
@@ -249,9 +254,11 @@ fn requests_validator_groups() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::ValidatorGroups(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::ValidatorGroups(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap().0, runtime_api.validator_groups);
|
||||
|
||||
@@ -273,9 +280,11 @@ fn requests_availability_cores() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::AvailabilityCores(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::AvailabilityCores(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.availability_cores);
|
||||
|
||||
@@ -302,22 +311,26 @@ fn requests_persisted_validation_data() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::PersistedValidationData(para_a, OccupiedCoreAssumption::Included, tx)
|
||||
),
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::PersistedValidationData(para_a, OccupiedCoreAssumption::Included, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), Some(Default::default()));
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::PersistedValidationData(para_b, OccupiedCoreAssumption::Included, tx)
|
||||
),
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::PersistedValidationData(para_b, OccupiedCoreAssumption::Included, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), None);
|
||||
|
||||
@@ -347,36 +360,26 @@ fn requests_check_validation_outputs() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CheckValidationOutputs(
|
||||
para_a,
|
||||
commitments.clone(),
|
||||
tx,
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CheckValidationOutputs(para_a, commitments.clone(), tx),
|
||||
),
|
||||
)
|
||||
}).await;
|
||||
assert_eq!(
|
||||
rx.await.unwrap().unwrap(),
|
||||
runtime_api.validation_outputs_results[¶_a],
|
||||
);
|
||||
})
|
||||
.await;
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validation_outputs_results[¶_a],);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CheckValidationOutputs(
|
||||
para_b,
|
||||
commitments,
|
||||
tx,
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CheckValidationOutputs(para_b, commitments, tx),
|
||||
),
|
||||
)
|
||||
}).await;
|
||||
assert_eq!(
|
||||
rx.await.unwrap().unwrap(),
|
||||
runtime_api.validation_outputs_results[¶_b],
|
||||
);
|
||||
})
|
||||
.await;
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.validation_outputs_results[¶_b],);
|
||||
|
||||
ctx_handle.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
@@ -396,9 +399,11 @@ fn requests_session_index_for_child() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::SessionIndexForChild(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::SessionIndexForChild(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.session_index_for_child);
|
||||
|
||||
@@ -424,9 +429,14 @@ fn requests_session_info() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::SessionInfo(session_index, tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::SessionInfo(session_index, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), Some(Default::default()));
|
||||
|
||||
@@ -454,22 +464,26 @@ fn requests_validation_code() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCode(para_a, OccupiedCoreAssumption::Included, tx)
|
||||
),
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCode(para_a, OccupiedCoreAssumption::Included, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), Some(Default::default()));
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCode(para_b, OccupiedCoreAssumption::Included, tx)
|
||||
),
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCode(para_b, OccupiedCoreAssumption::Included, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), None);
|
||||
|
||||
@@ -496,23 +510,27 @@ fn requests_candidate_pending_availability() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CandidatePendingAvailability(para_a, tx),
|
||||
)
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CandidatePendingAvailability(para_a, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), Some(Default::default()));
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CandidatePendingAvailability(para_b, tx),
|
||||
)
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::CandidatePendingAvailability(para_b, tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), None);
|
||||
|
||||
@@ -534,9 +552,11 @@ fn requests_candidate_events() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::CandidateEvents(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::CandidateEvents(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), runtime_api.candidate_events);
|
||||
|
||||
@@ -561,10 +581,7 @@ fn requests_dmq_contents() {
|
||||
runtime_api.dmq_contents.insert(para_a, vec![]);
|
||||
runtime_api.dmq_contents.insert(
|
||||
para_b,
|
||||
vec![InboundDownwardMessage {
|
||||
sent_at: 228,
|
||||
msg: b"Novus Ordo Seclorum".to_vec(),
|
||||
}],
|
||||
vec![InboundDownwardMessage { sent_at: 228, msg: b"Novus Ordo Seclorum".to_vec() }],
|
||||
);
|
||||
|
||||
runtime_api
|
||||
@@ -589,15 +606,10 @@ fn requests_dmq_contents() {
|
||||
.await;
|
||||
assert_eq!(
|
||||
rx.await.unwrap().unwrap(),
|
||||
vec![InboundDownwardMessage {
|
||||
sent_at: 228,
|
||||
msg: b"Novus Ordo Seclorum".to_vec(),
|
||||
}]
|
||||
vec![InboundDownwardMessage { sent_at: 228, msg: b"Novus Ordo Seclorum".to_vec() }]
|
||||
);
|
||||
|
||||
ctx_handle
|
||||
.send(FromOverseer::Signal(OverseerSignal::Conclude))
|
||||
.await;
|
||||
ctx_handle.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
futures::executor::block_on(future::join(subsystem_task, test_task));
|
||||
}
|
||||
@@ -614,13 +626,7 @@ fn requests_inbound_hrmp_channels_contents() {
|
||||
|
||||
let para_b_inbound_channels = [
|
||||
(para_a, vec![]),
|
||||
(
|
||||
para_c,
|
||||
vec![InboundHrmpMessage {
|
||||
sent_at: 1,
|
||||
data: "𝙀=𝙈𝘾²".as_bytes().to_owned(),
|
||||
}],
|
||||
),
|
||||
(para_c, vec![InboundHrmpMessage { sent_at: 1, data: "𝙀=𝙈𝘾²".as_bytes().to_owned() }]),
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
@@ -630,9 +636,7 @@ fn requests_inbound_hrmp_channels_contents() {
|
||||
let mut runtime_api = MockRuntimeApi::default();
|
||||
|
||||
runtime_api.hrmp_channels.insert(para_a, BTreeMap::new());
|
||||
runtime_api
|
||||
.hrmp_channels
|
||||
.insert(para_b, para_b_inbound_channels.clone());
|
||||
runtime_api.hrmp_channels.insert(para_b, para_b_inbound_channels.clone());
|
||||
|
||||
runtime_api
|
||||
});
|
||||
@@ -662,9 +666,7 @@ fn requests_inbound_hrmp_channels_contents() {
|
||||
.await;
|
||||
assert_eq!(rx.await.unwrap().unwrap(), para_b_inbound_channels,);
|
||||
|
||||
ctx_handle
|
||||
.send(FromOverseer::Signal(OverseerSignal::Conclude))
|
||||
.await;
|
||||
ctx_handle.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
};
|
||||
futures::executor::block_on(future::join(subsystem_task, test_task));
|
||||
}
|
||||
@@ -680,10 +682,7 @@ fn requests_validation_code_by_hash() {
|
||||
|
||||
for n in 0..5 {
|
||||
let code = ValidationCode::from(vec![n; 32]);
|
||||
runtime_api.validation_code_by_hash.insert(
|
||||
code.hash(),
|
||||
code.clone(),
|
||||
);
|
||||
runtime_api.validation_code_by_hash.insert(code.hash(), code.clone());
|
||||
validation_code.push(code);
|
||||
}
|
||||
|
||||
@@ -697,12 +696,14 @@ fn requests_validation_code_by_hash() {
|
||||
let test_task = async move {
|
||||
for code in validation_code {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCodeByHash(code.hash(), tx),
|
||||
)
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
Request::ValidationCodeByHash(code.hash(), tx),
|
||||
),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), Some(code));
|
||||
}
|
||||
@@ -732,9 +733,11 @@ fn multiple_requests_in_parallel_are_working() {
|
||||
for _ in 0..MAX_PARALLEL_REQUESTS * 10 {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::AvailabilityCores(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::AvailabilityCores(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
receivers.push(rx);
|
||||
}
|
||||
@@ -763,10 +766,7 @@ fn request_babe_epoch() {
|
||||
duration: 10,
|
||||
authorities: Vec::new(),
|
||||
randomness: [1u8; 32],
|
||||
config: BabeEpochConfiguration {
|
||||
c: (1, 4),
|
||||
allowed_slots: BabeAllowedSlots::PrimarySlots,
|
||||
},
|
||||
config: BabeEpochConfiguration { c: (1, 4), allowed_slots: BabeAllowedSlots::PrimarySlots },
|
||||
};
|
||||
runtime_api.babe_epoch = Some(epoch.clone());
|
||||
let runtime_api = Arc::new(runtime_api);
|
||||
@@ -778,9 +778,11 @@ fn request_babe_epoch() {
|
||||
let test_task = async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
ctx_handle.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::CurrentBabeEpoch(tx))
|
||||
}).await;
|
||||
ctx_handle
|
||||
.send(FromOverseer::Communication {
|
||||
msg: RuntimeApiMessage::Request(relay_parent, Request::CurrentBabeEpoch(tx)),
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(rx.await.unwrap().unwrap(), epoch);
|
||||
ctx_handle.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
|
||||
Reference in New Issue
Block a user