Add feature flag to enable v2 assignments (#2444)

Scaffold everything, so that we can enable v2 assignments via a node
feature bit, once all nodes have upgraded to the new protocol.

Implements: https://github.com/paritytech/polkadot-sdk/issues/628

---------

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
This commit is contained in:
Alexandru Gheorghe
2023-12-11 12:49:11 +02:00
committed by GitHub
parent 6cedb0c78d
commit 84c932cd8a
12 changed files with 397 additions and 170 deletions
@@ -146,7 +146,9 @@ mod tests {
AllMessages, AvailabilityDistributionMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{CandidateHash, ExecutorParams, Hash, ValidatorIndex};
use polkadot_primitives::{
vstaging::NodeFeatures, CandidateHash, ExecutorParams, Hash, ValidatorIndex,
};
use test_helpers::mock::make_ferdie_keystore;
use super::*;
@@ -214,6 +216,12 @@ mod tests {
)) => {
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_,
RuntimeApiRequest::NodeFeatures(_, si_tx),
)) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
},
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendRequests(
mut reqs,
_,
@@ -25,8 +25,8 @@ use polkadot_node_primitives::{BlockData, ErasureChunk, PoV};
use polkadot_node_subsystem_test_helpers::mock::new_leaf;
use polkadot_node_subsystem_util::runtime::RuntimeInfo;
use polkadot_primitives::{
BlockNumber, CoreState, ExecutorParams, GroupIndex, Hash, Id as ParaId, ScheduledCore,
SessionIndex, SessionInfo,
vstaging::NodeFeatures, BlockNumber, CoreState, ExecutorParams, GroupIndex, Hash, Id as ParaId,
ScheduledCore, SessionIndex, SessionInfo,
};
use sp_core::traits::SpawnNamed;
@@ -125,6 +125,10 @@ fn spawn_virtual_overseer(
tx.send(Ok(Some(ExecutorParams::default())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::NodeFeatures(_, tx) => {
tx.send(Ok(NodeFeatures::EMPTY))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::AvailabilityCores(tx) => {
let para_id = ParaId::from(1_u32);
let maybe_block_position =
@@ -46,8 +46,8 @@ use polkadot_node_subsystem::{
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{
CandidateHash, CoreState, ExecutorParams, GroupIndex, Hash, Id as ParaId, ScheduledCore,
SessionInfo, ValidatorIndex,
vstaging::NodeFeatures, CandidateHash, CoreState, ExecutorParams, GroupIndex, Hash,
Id as ParaId, ScheduledCore, SessionInfo, ValidatorIndex,
};
use test_helpers::mock::{make_ferdie_keystore, new_leaf};
@@ -264,6 +264,9 @@ impl TestState {
tx.send(Ok(Some(ExecutorParams::default())))
.expect("Receiver should be alive.");
},
RuntimeApiRequest::NodeFeatures(_, si_tx) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).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,9 @@ 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, ExecutorParams, GroupIndex, GroupRotationInfo, IndexedVec,
ScheduledCore, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
vstaging::NodeFeatures, AuthorityDiscoveryId, CollatorPair, ExecutorParams, GroupIndex,
GroupRotationInfo, IndexedVec, ScheduledCore, SessionIndex, SessionInfo, ValidatorId,
ValidatorIndex,
};
use polkadot_primitives_test_helpers::TestCandidateBuilder;
use test_helpers::mock::new_leaf;
@@ -406,7 +407,12 @@ async fn distribute_collation_with_receipt(
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_,
RuntimeApiRequest::NodeFeatures(_, si_tx),
)) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
},
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_relay_parent,
RuntimeApiRequest::ValidatorGroups(tx),
@@ -57,8 +57,8 @@ use polkadot_node_subsystem_test_helpers::{
subsystem_test_harness, TestSubsystemContextHandle,
};
use polkadot_primitives::{
AuthorityDiscoveryId, CandidateHash, CandidateReceipt, ExecutorParams, Hash, SessionIndex,
SessionInfo,
vstaging::NodeFeatures, AuthorityDiscoveryId, CandidateHash, CandidateReceipt, ExecutorParams,
Hash, SessionIndex, SessionInfo,
};
use self::mock::{
@@ -646,6 +646,16 @@ async fn nested_network_dispute_request<'a, F, O>(
},
unexpected => panic!("Unexpected message {:?}", unexpected),
}
match handle.recv().await {
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
_,
RuntimeApiRequest::NodeFeatures(_, si_tx),
)) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
},
unexpected => panic!("Unexpected message {:?}", unexpected),
}
}
// Import should get initiated:
@@ -773,6 +783,14 @@ async fn activate_leaf(
tx.send(Ok(Some(ExecutorParams::default()))).expect("Receiver should stay alive.");
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
}
assert_matches!(
@@ -43,8 +43,8 @@ use polkadot_node_subsystem::{
};
use polkadot_node_subsystem_test_helpers::mock::{make_ferdie_keystore, new_leaf};
use polkadot_primitives::{
ExecutorParams, GroupIndex, Hash, HeadData, Id as ParaId, IndexedVec, SessionInfo,
ValidationCode,
vstaging::NodeFeatures, ExecutorParams, GroupIndex, Hash, HeadData, Id as ParaId, IndexedVec,
SessionInfo, ValidationCode,
};
use polkadot_primitives_test_helpers::{
dummy_committed_candidate_receipt, dummy_hash, AlwaysZeroRng,
@@ -834,6 +834,15 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -1074,6 +1083,15 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -1604,6 +1622,15 @@ fn delay_reputation_changes() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -2084,6 +2111,15 @@ fn share_prioritizes_backing_group() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of dummy peers and view
for (peer, pair) in dummy_peers.clone().into_iter().zip(dummy_pairs) {
handle
@@ -2406,6 +2442,15 @@ fn peer_cant_flood_with_large_statements() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of peers and view
handle
.send(FromOrchestra::Communication {
@@ -2631,6 +2676,14 @@ fn handle_multiple_seconded_statements() {
}
);
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::NodeFeatures(_, si_tx), )
) => {
si_tx.send(Ok(NodeFeatures::EMPTY)).unwrap();
}
);
// notify of peers and view
for peer in all_peers.iter() {
handle