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:
s0me0ne-unkn0wn
2023-09-01 20:07:32 +02:00
committed by GitHub
parent ccdf636c49
commit a2b6470607
29 changed files with 819 additions and 331 deletions
@@ -146,7 +146,7 @@ mod tests {
AllMessages, AvailabilityDistributionMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{CandidateHash, Hash, ValidatorIndex};
use polkadot_primitives::{CandidateHash, ExecutorParams, Hash, ValidatorIndex};
use test_helpers::mock::make_ferdie_keystore;
use super::*;
@@ -208,6 +208,12 @@ mod tests {
)) => {
tx.send(Ok(Some(make_session_info()))).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_,
RuntimeApiRequest::SessionExecutorParams(_, tx),
)) => {
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
},
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendRequests(
mut reqs,
_,
@@ -24,8 +24,8 @@ use polkadot_node_network_protocol::jaeger;
use polkadot_node_primitives::{BlockData, ErasureChunk, PoV};
use polkadot_node_subsystem_util::runtime::RuntimeInfo;
use polkadot_primitives::{
BlockNumber, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, SessionIndex,
SessionInfo,
BlockNumber, CoreState, ExecutorParams, GroupIndex, Hash, Id as ParaId, ScheduledCore,
SessionIndex, SessionInfo,
};
use sp_core::traits::SpawnNamed;
@@ -120,6 +120,10 @@ fn spawn_virtual_overseer(
tx.send(Ok(Some(test_state.session_info.clone())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::SessionExecutorParams(_, tx) => {
tx.send(Ok(Some(ExecutorParams::default())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::AvailabilityCores(tx) => {
let para_id = ParaId::from(1_u32);
let maybe_block_position =
@@ -48,8 +48,8 @@ use polkadot_node_subsystem::{
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{
CandidateHash, CoreState, GroupIndex, Hash, Id as ParaId, ScheduledCore, SessionInfo,
ValidatorIndex,
CandidateHash, CoreState, ExecutorParams, GroupIndex, Hash, Id as ParaId, ScheduledCore,
SessionInfo, ValidatorIndex,
};
use test_helpers::mock::make_ferdie_keystore;
@@ -267,6 +267,10 @@ impl TestState {
tx.send(Ok(Some(self.session_info.clone())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::SessionExecutorParams(_, tx) => {
tx.send(Ok(Some(ExecutorParams::default())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::AvailabilityCores(tx) => {
gum::trace!(target: LOG_TARGET, cores= ?self.cores[&hash], hash = ?hash, "Sending out cores for hash");
tx.send(Ok(self.cores[&hash].clone()))
@@ -45,8 +45,8 @@ use polkadot_node_subsystem::{
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_util::{reputation::add_reputation, TimeoutExt};
use polkadot_primitives::{
AuthorityDiscoveryId, CollatorPair, GroupIndex, GroupRotationInfo, IndexedVec, ScheduledCore,
SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
AuthorityDiscoveryId, CollatorPair, ExecutorParams, GroupIndex, GroupRotationInfo, IndexedVec,
ScheduledCore, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
};
use polkadot_primitives_test_helpers::TestCandidateBuilder;
@@ -398,6 +398,16 @@ async fn distribute_collation_with_receipt(
tx.send(Ok(Some(test_state.session_info.clone()))).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
relay_parent,
RuntimeApiRequest::SessionExecutorParams(session_index, tx),
)) => {
assert_eq!(relay_parent, relay_parent);
assert_eq!(session_index, test_state.current_session_index());
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_relay_parent,
RuntimeApiRequest::ValidatorGroups(tx),
@@ -57,7 +57,8 @@ use polkadot_node_subsystem_test_helpers::{
mock::make_ferdie_keystore, subsystem_test_harness, TestSubsystemContextHandle,
};
use polkadot_primitives::{
AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, SessionInfo,
AuthorityDiscoveryId, CandidateHash, CandidateReceipt, ExecutorParams, Hash, SessionIndex,
SessionInfo,
};
use self::mock::{
@@ -635,6 +636,16 @@ async fn nested_network_dispute_request<'a, F, O>(
},
unexpected => panic!("Unexpected message {:?}", unexpected),
}
match handle.recv().await {
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_,
RuntimeApiRequest::SessionExecutorParams(_, tx),
)) => {
tx.send(Ok(Some(ExecutorParams::default())))
.expect("Receiver should stay alive.");
},
unexpected => panic!("Unexpected message {:?}", unexpected),
}
}
// Import should get initiated:
@@ -746,15 +757,27 @@ async fn activate_leaf(
if let Some(session_info) = new_session {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionInfo(session_idx, tx)
)) => {
assert_eq!(h, activate);
assert_eq!(session_index, session_idx);
tx.send(Ok(Some(session_info))).expect("Receiver should stay alive.");
});
handle.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionInfo(session_idx, tx)
)) => {
assert_eq!(h, activate);
assert_eq!(session_index, session_idx);
tx.send(Ok(Some(session_info))).expect("Receiver should stay alive.");
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionExecutorParams(session_idx, tx)
)) => {
assert_eq!(h, activate);
assert_eq!(session_index, session_idx);
tx.send(Ok(Some(ExecutorParams::default()))).expect("Receiver should stay alive.");
}
);
}
assert_matches!(
@@ -44,7 +44,8 @@ use polkadot_node_subsystem::{
};
use polkadot_node_subsystem_test_helpers::mock::make_ferdie_keystore;
use polkadot_primitives::{
GroupIndex, Hash, HeadData, Id as ParaId, IndexedVec, SessionInfo, ValidationCode,
ExecutorParams, GroupIndex, Hash, HeadData, Id as ParaId, IndexedVec, SessionInfo,
ValidationCode,
};
use polkadot_primitives_test_helpers::{
dummy_committed_candidate_receipt, dummy_hash, AlwaysZeroRng,
@@ -828,6 +829,17 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == hash_a && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -1062,6 +1074,17 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == hash_a && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -1586,6 +1609,17 @@ fn delay_reputation_changes() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == hash_a && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -2060,6 +2094,17 @@ fn share_prioritizes_backing_group() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == hash_a && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of dummy peers and view
for (peer, pair) in dummy_peers.clone().into_iter().zip(dummy_pairs) {
handle
@@ -2376,6 +2421,17 @@ fn peer_cant_flood_with_large_statements() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == hash_a && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -2595,6 +2651,17 @@ fn handle_multiple_seconded_statements() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::SessionExecutorParams(sess_index, tx))
)
if r == relay_parent_hash && sess_index == session_index
=> {
let _ = tx.send(Ok(Some(ExecutorParams::default())));
}
);
// notify of peers and view
for peer in all_peers.iter() {
handle