mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 07:58:00 +00:00
Use cached session index to obtain executor params (#1190)
* Import changes from archieved repo * Revert erroneous changes * Fix more tests * Resolve discussions * Fix MORE tests * approval-voting: launch_approval better interface (#1355) --------- Co-authored-by: Javier Viola <javier@parity.io> Co-authored-by: ordian <noreply@reusable.software> Co-authored-by: ordian <write@reusable.software>
This commit is contained in:
@@ -38,6 +38,10 @@ pub enum Error {
|
||||
/// We tried fetching a session info which was not available.
|
||||
#[error("There was no session with the given index {0}")]
|
||||
NoSuchSession(SessionIndex),
|
||||
|
||||
/// We tried fetching executor params for a session which were not available.
|
||||
#[error("There was no executor parameters for session with the given index {0}")]
|
||||
NoExecutorParams(SessionIndex),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
@@ -29,17 +29,18 @@ use polkadot_node_subsystem::{
|
||||
overseer, SubsystemSender,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
vstaging, CandidateEvent, CandidateHash, CoreState, EncodeAs, GroupIndex, GroupRotationInfo,
|
||||
Hash, IndexedVec, OccupiedCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed,
|
||||
SigningContext, UncheckedSigned, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
ValidatorIndex, LEGACY_MIN_BACKING_VOTES,
|
||||
vstaging, CandidateEvent, CandidateHash, CoreState, EncodeAs, ExecutorParams, GroupIndex,
|
||||
GroupRotationInfo, Hash, IndexedVec, OccupiedCore, ScrapedOnChainVotes, SessionIndex,
|
||||
SessionInfo, Signed, SigningContext, UncheckedSigned, ValidationCode, ValidationCodeHash,
|
||||
ValidatorId, ValidatorIndex, LEGACY_MIN_BACKING_VOTES,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
request_availability_cores, request_candidate_events, request_from_runtime,
|
||||
request_key_ownership_proof, request_on_chain_votes, request_session_index_for_child,
|
||||
request_session_info, request_staging_async_backing_params, request_submit_report_dispute_lost,
|
||||
request_unapplied_slashes, request_validation_code_by_hash, request_validator_groups,
|
||||
request_key_ownership_proof, request_on_chain_votes, request_session_executor_params,
|
||||
request_session_index_for_child, request_session_info, request_staging_async_backing_params,
|
||||
request_submit_report_dispute_lost, request_unapplied_slashes, request_validation_code_by_hash,
|
||||
request_validator_groups,
|
||||
};
|
||||
|
||||
/// Errors that can happen on runtime fetches.
|
||||
@@ -84,6 +85,8 @@ pub struct ExtendedSessionInfo {
|
||||
pub session_info: SessionInfo,
|
||||
/// Contains useful information about ourselves, in case this node is a validator.
|
||||
pub validator_info: ValidatorInfo,
|
||||
/// Session executor parameters
|
||||
pub executor_params: ExecutorParams,
|
||||
}
|
||||
|
||||
/// Information about ourselves, in case we are an `Authority`.
|
||||
@@ -174,9 +177,15 @@ impl RuntimeInfo {
|
||||
recv_runtime(request_session_info(parent, session_index, sender).await)
|
||||
.await?
|
||||
.ok_or(JfyiError::NoSuchSession(session_index))?;
|
||||
|
||||
let executor_params =
|
||||
recv_runtime(request_session_executor_params(parent, session_index, sender).await)
|
||||
.await?
|
||||
.ok_or(JfyiError::NoExecutorParams(session_index))?;
|
||||
|
||||
let validator_info = self.get_validator_info(&session_info)?;
|
||||
|
||||
let full_info = ExtendedSessionInfo { session_info, validator_info };
|
||||
let full_info = ExtendedSessionInfo { session_info, validator_info, executor_params };
|
||||
|
||||
self.session_info_cache.insert(session_index, full_info);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user