mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 15:07:59 +00:00
refactor+feat: allow subsystems to send only declared messages, generate graphviz (#5314)
Closes #3774 Closes #3826
This commit is contained in:
committed by
GitHub
parent
26340b9054
commit
511891dcce
@@ -35,8 +35,8 @@ use polkadot_node_subsystem::{
|
||||
CandidateValidationMessage, PreCheckOutcome, RuntimeApiMessage, RuntimeApiRequest,
|
||||
ValidationFailed,
|
||||
},
|
||||
overseer, FromOverseer, OverseerSignal, SpawnedSubsystem, SubsystemContext, SubsystemError,
|
||||
SubsystemResult, SubsystemSender,
|
||||
overseer, FromOverseer, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult,
|
||||
SubsystemSender,
|
||||
};
|
||||
use polkadot_parachain::primitives::{ValidationParams, ValidationResult as WasmValidationResult};
|
||||
use polkadot_primitives::v2::{
|
||||
@@ -93,11 +93,8 @@ impl CandidateValidationSubsystem {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Context> overseer::Subsystem<Context, SubsystemError> for CandidateValidationSubsystem
|
||||
where
|
||||
Context: SubsystemContext<Message = CandidateValidationMessage>,
|
||||
Context: overseer::SubsystemContext<Message = CandidateValidationMessage>,
|
||||
{
|
||||
#[overseer::subsystem(CandidateValidation, error=SubsystemError, prefix=self::overseer)]
|
||||
impl<Context> CandidateValidationSubsystem {
|
||||
fn start(self, ctx: Context) -> SpawnedSubsystem {
|
||||
let future = run(
|
||||
ctx,
|
||||
@@ -112,17 +109,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[overseer::contextbounds(CandidateValidation, prefix = self::overseer)]
|
||||
async fn run<Context>(
|
||||
mut ctx: Context,
|
||||
metrics: Metrics,
|
||||
pvf_metrics: polkadot_node_core_pvf::Metrics,
|
||||
cache_path: PathBuf,
|
||||
program_path: PathBuf,
|
||||
) -> SubsystemResult<()>
|
||||
where
|
||||
Context: SubsystemContext<Message = CandidateValidationMessage>,
|
||||
Context: overseer::SubsystemContext<Message = CandidateValidationMessage>,
|
||||
{
|
||||
) -> SubsystemResult<()> {
|
||||
let (validation_host, task) = polkadot_node_core_pvf::start(
|
||||
polkadot_node_core_pvf::Config::new(cache_path, program_path),
|
||||
pvf_metrics,
|
||||
@@ -235,7 +229,7 @@ async fn runtime_api_request<T, Sender>(
|
||||
receiver: oneshot::Receiver<Result<T, RuntimeApiError>>,
|
||||
) -> Result<T, RuntimeRequestFailed>
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
sender
|
||||
.send_message(RuntimeApiMessage::Request(relay_parent, request).into())
|
||||
@@ -268,7 +262,7 @@ async fn request_validation_code_by_hash<Sender>(
|
||||
validation_code_hash: ValidationCodeHash,
|
||||
) -> Result<Option<ValidationCode>, RuntimeRequestFailed>
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
let (tx, rx) = oneshot::channel();
|
||||
runtime_api_request(
|
||||
@@ -287,7 +281,7 @@ async fn precheck_pvf<Sender>(
|
||||
validation_code_hash: ValidationCodeHash,
|
||||
) -> PreCheckOutcome
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
let validation_code =
|
||||
match request_validation_code_by_hash(sender, relay_parent, validation_code_hash).await {
|
||||
@@ -342,7 +336,7 @@ async fn check_assumption_validation_data<Sender>(
|
||||
assumption: OccupiedCoreAssumption,
|
||||
) -> AssumptionCheckOutcome
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
let validation_data = {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -386,7 +380,7 @@ async fn find_assumed_validation_data<Sender>(
|
||||
descriptor: &CandidateDescriptor,
|
||||
) -> AssumptionCheckOutcome
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
// The candidate descriptor has a `persisted_validation_data_hash` which corresponds to
|
||||
// one of up to two possible values that we can derive from the state of the
|
||||
@@ -421,7 +415,7 @@ pub async fn find_validation_data<Sender>(
|
||||
descriptor: &CandidateDescriptor,
|
||||
) -> Result<Option<(PersistedValidationData, ValidationCode)>, ValidationFailed>
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
match find_assumed_validation_data(sender, &descriptor).await {
|
||||
AssumptionCheckOutcome::Matches(validation_data, validation_code) =>
|
||||
@@ -446,7 +440,7 @@ async fn validate_from_chain_state<Sender>(
|
||||
metrics: &Metrics,
|
||||
) -> Result<ValidationResult, ValidationFailed>
|
||||
where
|
||||
Sender: SubsystemSender,
|
||||
Sender: SubsystemSender<RuntimeApiMessage>,
|
||||
{
|
||||
let mut new_sender = sender.clone();
|
||||
let (validation_data, validation_code) =
|
||||
|
||||
Reference in New Issue
Block a user