mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +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:
@@ -96,8 +96,8 @@ use polkadot_node_subsystem::{
|
||||
use polkadot_node_subsystem_util::{
|
||||
self as util,
|
||||
backing_implicit_view::{FetchError as ImplicitViewFetchError, View as ImplicitView},
|
||||
request_from_runtime, request_session_index_for_child, request_validator_groups,
|
||||
request_validators,
|
||||
executor_params_at_relay_parent, request_from_runtime, request_session_index_for_child,
|
||||
request_validator_groups, request_validators,
|
||||
runtime::{
|
||||
self, prospective_parachains_mode, request_min_backing_votes, ProspectiveParachainsMode,
|
||||
},
|
||||
@@ -105,9 +105,9 @@ use polkadot_node_subsystem_util::{
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
BackedCandidate, CandidateCommitments, CandidateHash, CandidateReceipt,
|
||||
CommittedCandidateReceipt, CoreIndex, CoreState, Hash, Id as ParaId, PersistedValidationData,
|
||||
PvfExecTimeoutKind, SigningContext, ValidationCode, ValidatorId, ValidatorIndex,
|
||||
ValidatorSignature, ValidityAttestation,
|
||||
CommittedCandidateReceipt, CoreIndex, CoreState, ExecutorParams, Hash, Id as ParaId,
|
||||
PersistedValidationData, PvfExecTimeoutKind, SigningContext, ValidationCode, ValidatorId,
|
||||
ValidatorIndex, ValidatorSignature, ValidityAttestation,
|
||||
};
|
||||
use sp_keystore::KeystorePtr;
|
||||
use statement_table::{
|
||||
@@ -555,6 +555,7 @@ async fn request_candidate_validation(
|
||||
code: ValidationCode,
|
||||
candidate_receipt: CandidateReceipt,
|
||||
pov: Arc<PoV>,
|
||||
executor_params: ExecutorParams,
|
||||
) -> Result<ValidationResult, Error> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
@@ -564,6 +565,7 @@ async fn request_candidate_validation(
|
||||
code,
|
||||
candidate_receipt,
|
||||
pov,
|
||||
executor_params,
|
||||
PvfExecTimeoutKind::Backing,
|
||||
tx,
|
||||
))
|
||||
@@ -630,6 +632,11 @@ async fn validate_and_make_available(
|
||||
}
|
||||
};
|
||||
|
||||
let executor_params = match executor_params_at_relay_parent(relay_parent, &mut sender).await {
|
||||
Ok(ep) => ep,
|
||||
Err(e) => return Err(Error::UtilError(e)),
|
||||
};
|
||||
|
||||
let pov = match pov {
|
||||
PoVData::Ready(pov) => pov,
|
||||
PoVData::FetchFromValidator { from_validator, candidate_hash, pov_hash } =>
|
||||
@@ -665,6 +672,7 @@ async fn validate_and_make_available(
|
||||
validation_code,
|
||||
candidate.clone(),
|
||||
pov.clone(),
|
||||
executor_params,
|
||||
)
|
||||
.await?
|
||||
};
|
||||
|
||||
@@ -348,6 +348,24 @@ fn backing_second_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
@@ -356,6 +374,7 @@ fn backing_second_works() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -494,6 +513,24 @@ fn backing_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
// Sending a `Statement::Seconded` for our assignment will start
|
||||
// validation process. The first thing requested is the PoV.
|
||||
assert_matches!(
|
||||
@@ -519,6 +556,7 @@ fn backing_works() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -678,6 +716,24 @@ fn backing_works_while_validation_ongoing() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
// Sending a `Statement::Seconded` for our assignment will start
|
||||
// validation process. The first thing requested is PoV from the
|
||||
// `PoVDistribution`.
|
||||
@@ -704,6 +760,7 @@ fn backing_works_while_validation_ongoing() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -850,6 +907,24 @@ fn backing_misbehavior_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::AvailabilityDistribution(
|
||||
@@ -871,6 +946,7 @@ fn backing_misbehavior_works() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1036,6 +1112,24 @@ fn backing_dont_second_invalid() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
@@ -1044,6 +1138,7 @@ fn backing_dont_second_invalid() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1082,6 +1177,24 @@ fn backing_dont_second_invalid() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
@@ -1090,6 +1203,7 @@ fn backing_dont_second_invalid() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1200,6 +1314,24 @@ fn backing_second_after_first_fails_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1223,6 +1355,7 @@ fn backing_second_after_first_fails_works() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1289,6 +1422,24 @@ fn backing_second_after_first_fails_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
@@ -1357,6 +1508,24 @@ fn backing_works_after_failed_validation() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1380,6 +1549,7 @@ fn backing_works_after_failed_validation() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1566,6 +1736,24 @@ fn retry_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
// We cancel - should mean retry on next backing statement.
|
||||
assert_matches!(
|
||||
@@ -1586,7 +1774,7 @@ fn retry_works() {
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
// Not deterministic which message comes first:
|
||||
for _ in 0u32..3 {
|
||||
for _ in 0u32..5 {
|
||||
match virtual_overseer.recv().await {
|
||||
AllMessages::Provisioner(ProvisionerMessage::ProvisionableData(
|
||||
_,
|
||||
@@ -1605,6 +1793,18 @@ fn retry_works() {
|
||||
)) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
},
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
_,
|
||||
RuntimeApiRequest::SessionIndexForChild(tx),
|
||||
)) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
},
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
_,
|
||||
RuntimeApiRequest::SessionExecutorParams(sess_idx, tx),
|
||||
)) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
},
|
||||
msg => {
|
||||
assert!(false, "Unexpected message: {:?}", msg);
|
||||
},
|
||||
@@ -1624,6 +1824,24 @@ fn retry_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::AvailabilityDistribution(
|
||||
@@ -1647,6 +1865,7 @@ fn retry_works() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
..
|
||||
),
|
||||
@@ -1821,6 +2040,24 @@ fn cannot_second_multiple_candidates_per_parent() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
@@ -1829,6 +2066,7 @@ fn cannot_second_multiple_candidates_per_parent() {
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
@@ -1907,6 +2145,24 @@ fn cannot_second_multiple_candidates_per_parent() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
|
||||
@@ -217,6 +217,24 @@ async fn assert_validate_seconded_candidate(
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
if fetch_pov {
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -239,6 +257,7 @@ async fn assert_validate_seconded_candidate(
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
)) if &_pvd == pvd &&
|
||||
@@ -1339,7 +1358,7 @@ fn concurrent_dependent_candidates() {
|
||||
tx.send(pov.clone()).unwrap();
|
||||
},
|
||||
AllMessages::CandidateValidation(
|
||||
CandidateValidationMessage::ValidateFromExhaustive(.., candidate, _, _, tx),
|
||||
CandidateValidationMessage::ValidateFromExhaustive(.., candidate, _, _, _, tx),
|
||||
) => {
|
||||
let candidate_hash = candidate.hash();
|
||||
let (head_data, pvd) = if candidate_hash == candidate_a_hash {
|
||||
@@ -1396,6 +1415,20 @@ fn concurrent_dependent_candidates() {
|
||||
break
|
||||
}
|
||||
},
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
_,
|
||||
RuntimeApiRequest::SessionIndexForChild(tx),
|
||||
)) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
},
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
_,
|
||||
RuntimeApiRequest::SessionExecutorParams(sess_idx, tx),
|
||||
)) => {
|
||||
assert_eq!(sess_idx, 1);
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
},
|
||||
|
||||
_ => panic!("unexpected message received from overseer: {:?}", msg),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user