polkadot: pin one block per session (#1220)

* polkadot: propagate UnpinHandle to ActiveLeafUpdate

Also extract the leaf creation for tests
into a common function.

* dispute-coordinator: try pinned blocks for slashin

* apparently 1.72 is smarter than 1.70

* address nits

* rename fresh_leaf to new_leaf
This commit is contained in:
ordian
2023-09-07 12:24:40 +02:00
committed by GitHub
parent 1346143194
commit 15503883e2
33 changed files with 387 additions and 620 deletions
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use self::test_helpers::mock::new_leaf;
use super::*;
use polkadot_node_primitives::{
approval::{
@@ -26,7 +27,7 @@ use polkadot_node_subsystem::{
messages::{
AllMessages, ApprovalVotingMessage, AssignmentCheckResult, AvailabilityRecoveryMessage,
},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
ActiveLeavesUpdate,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_util::TimeoutExt;
@@ -777,12 +778,7 @@ async fn import_block(
overseer_send(
overseer,
FromOrchestra::Signal(OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
ActivatedLeaf {
hash: *new_head,
number,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
},
new_leaf(*new_head, number),
))),
)
.await;
+17 -32
View File
@@ -19,14 +19,14 @@ use super::*;
use assert_matches::assert_matches;
use futures::{channel::oneshot, executor, future, Future};
use self::test_helpers::mock::new_leaf;
use ::test_helpers::TestCandidateBuilder;
use parking_lot::Mutex;
use polkadot_node_primitives::{AvailableData, BlockData, PoV, Proof};
use polkadot_node_subsystem::{
errors::RuntimeApiError,
jaeger,
messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
ActiveLeavesUpdate,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_util::{database::Database, TimeoutExt};
@@ -219,16 +219,11 @@ fn runtime_api_error_does_not_stop_the_subsystem() {
let store = test_store();
test_harness(TestState::default(), store, |mut virtual_overseer| async move {
let new_leaf = Hash::repeat_byte(0x01);
let a_leaf = Hash::repeat_byte(0x01);
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(new_leaf(a_leaf, 1))),
)
.await;
@@ -246,7 +241,7 @@ fn runtime_api_error_does_not_stop_the_subsystem() {
relay_parent,
tx,
)) => {
assert_eq!(relay_parent, new_leaf);
assert_eq!(relay_parent, a_leaf);
tx.send(Ok(Some(header))).unwrap();
}
);
@@ -258,7 +253,7 @@ fn runtime_api_error_does_not_stop_the_subsystem() {
relay_parent,
RuntimeApiRequest::CandidateEvents(tx),
)) => {
assert_eq!(relay_parent, new_leaf);
assert_eq!(relay_parent, a_leaf);
#[derive(Debug)]
struct FauxError;
impl std::error::Error for FauxError {}
@@ -741,7 +736,7 @@ fn stored_data_kept_until_finalized() {
available_data,
);
let new_leaf = import_leaf(
let a_leaf = import_leaf(
&mut virtual_overseer,
parent,
block_number,
@@ -764,7 +759,7 @@ fn stored_data_kept_until_finalized() {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::BlockFinalized(new_leaf, block_number),
OverseerSignal::BlockFinalized(a_leaf, block_number),
)
.await;
@@ -849,16 +844,11 @@ fn we_dont_miss_anything_if_import_notifications_are_missed() {
extrinsics_root: Hash::zero(),
digest: Default::default(),
};
let new_leaf = Hash::repeat_byte(4);
let a_leaf = Hash::repeat_byte(4);
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 4,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(new_leaf(a_leaf, 4))),
)
.await;
@@ -868,7 +858,7 @@ fn we_dont_miss_anything_if_import_notifications_are_missed() {
relay_parent,
tx,
)) => {
assert_eq!(relay_parent, new_leaf);
assert_eq!(relay_parent, a_leaf);
tx.send(Ok(Some(header))).unwrap();
}
);
@@ -886,7 +876,7 @@ fn we_dont_miss_anything_if_import_notifications_are_missed() {
k,
response_channel: tx,
}) => {
assert_eq!(hash, new_leaf);
assert_eq!(hash, a_leaf);
assert_eq!(k, 2);
let _ = tx.send(Ok(vec![
Hash::repeat_byte(3),
@@ -1166,16 +1156,11 @@ async fn import_leaf(
extrinsics_root: Hash::zero(),
digest: Default::default(),
};
let new_leaf = header.hash();
let a_leaf = header.hash();
overseer_signal(
virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(new_leaf(a_leaf, 1))),
)
.await;
@@ -1185,7 +1170,7 @@ async fn import_leaf(
relay_parent,
tx,
)) => {
assert_eq!(relay_parent, new_leaf);
assert_eq!(relay_parent, a_leaf);
tx.send(Ok(Some(header))).unwrap();
}
);
@@ -1196,7 +1181,7 @@ async fn import_leaf(
relay_parent,
RuntimeApiRequest::CandidateEvents(tx),
)) => {
assert_eq!(relay_parent, new_leaf);
assert_eq!(relay_parent, a_leaf);
tx.send(Ok(events)).unwrap();
}
);
@@ -1212,7 +1197,7 @@ async fn import_leaf(
}
);
new_leaf
a_leaf
}
#[test]
+3 -8
View File
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use self::test_helpers::mock::new_leaf;
use super::*;
use ::test_helpers::{
dummy_candidate_receipt_bad_sig, dummy_collator, dummy_collator_signature,
@@ -24,12 +25,11 @@ use futures::{future, Future};
use polkadot_node_primitives::{BlockData, InvalidCandidate, SignedFullStatement, Statement};
use polkadot_node_subsystem::{
errors::RuntimeApiError,
jaeger,
messages::{
AllMessages, CollatorProtocolMessage, RuntimeApiMessage, RuntimeApiRequest,
ValidationFailed,
},
ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, TimeoutExt,
ActiveLeavesUpdate, FromOrchestra, OverseerSignal, TimeoutExt,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{
@@ -234,12 +234,7 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
// Start work on some new parent.
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
ActivatedLeaf {
hash: test_state.relay_parent,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
},
new_leaf(test_state.relay_parent, 1),
))))
.await;
@@ -18,7 +18,7 @@
use polkadot_node_subsystem::{
messages::{ChainApiMessage, FragmentTreeMembership},
TimeoutExt,
ActivatedLeaf, TimeoutExt,
};
use polkadot_primitives::{vstaging as vstaging_primitives, BlockNumber, Header, OccupiedCore};
@@ -346,12 +346,7 @@ fn seconding_sanity_check_allowed() {
// `a` is grandparent of `b`.
let leaf_a_hash = Hash::from_low_u64_be(130);
let leaf_a_parent = get_parent_hash(leaf_a_hash);
let activated = ActivatedLeaf {
hash: leaf_a_hash,
number: LEAF_A_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -359,12 +354,7 @@ fn seconding_sanity_check_allowed() {
const LEAF_B_ANCESTRY_LEN: BlockNumber = 4;
let leaf_b_hash = Hash::from_low_u64_be(128);
let activated = ActivatedLeaf {
hash: leaf_b_hash,
number: LEAF_B_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_b_hash, LEAF_B_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_B_BLOCK_NUMBER - LEAF_B_ANCESTRY_LEN)];
let test_leaf_b = TestLeaf { activated, min_relay_parents };
@@ -503,24 +493,14 @@ fn seconding_sanity_check_disallowed() {
// `a` is grandparent of `b`.
let leaf_a_hash = Hash::from_low_u64_be(130);
let leaf_a_parent = get_parent_hash(leaf_a_hash);
let activated = ActivatedLeaf {
hash: leaf_a_hash,
number: LEAF_A_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
const LEAF_B_BLOCK_NUMBER: BlockNumber = LEAF_A_BLOCK_NUMBER + 2;
const LEAF_B_ANCESTRY_LEN: BlockNumber = 4;
let activated = ActivatedLeaf {
hash: leaf_b_hash,
number: LEAF_B_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_b_hash, LEAF_B_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_B_BLOCK_NUMBER - LEAF_B_ANCESTRY_LEN)];
let test_leaf_b = TestLeaf { activated, min_relay_parents };
@@ -722,12 +702,7 @@ fn prospective_parachains_reject_candidate() {
let leaf_a_hash = Hash::from_low_u64_be(130);
let leaf_a_parent = get_parent_hash(leaf_a_hash);
let activated = ActivatedLeaf {
hash: leaf_a_hash,
number: LEAF_A_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -905,12 +880,7 @@ fn second_multiple_candidates_per_relay_parent() {
let leaf_hash = Hash::from_low_u64_be(130);
let leaf_parent = get_parent_hash(leaf_hash);
let leaf_grandparent = get_parent_hash(leaf_parent);
let activated = ActivatedLeaf {
hash: leaf_hash,
number: LEAF_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -1046,12 +1016,7 @@ fn backing_works() {
let leaf_hash = Hash::from_low_u64_be(130);
let leaf_parent = get_parent_hash(leaf_hash);
let activated = ActivatedLeaf {
hash: leaf_hash,
number: LEAF_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -1212,12 +1177,7 @@ fn concurrent_dependent_candidates() {
let leaf_hash = Hash::from_low_u64_be(130);
let leaf_parent = get_parent_hash(leaf_hash);
let leaf_grandparent = get_parent_hash(leaf_parent);
let activated = ActivatedLeaf {
hash: leaf_hash,
number: LEAF_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -1458,12 +1418,7 @@ fn seconding_sanity_check_occupy_same_depth() {
let leaf_hash = Hash::from_low_u64_be(130);
let leaf_parent = get_parent_hash(leaf_hash);
let activated = ActivatedLeaf {
hash: leaf_hash,
number: LEAF_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_hash, LEAF_BLOCK_NUMBER);
let min_block_number = LEAF_BLOCK_NUMBER - LEAF_ANCESTRY_LEN;
let min_relay_parents = vec![(para_id_a, min_block_number), (para_id_b, min_block_number)];
@@ -1617,12 +1572,7 @@ fn occupied_core_assignment() {
let leaf_a_hash = Hash::from_low_u64_be(130);
let leaf_a_parent = get_parent_hash(leaf_a_hash);
let activated = ActivatedLeaf {
hash: leaf_a_hash,
number: LEAF_A_BLOCK_NUMBER,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(leaf_a_hash, LEAF_A_BLOCK_NUMBER);
let min_relay_parents = vec![(para_id, LEAF_A_BLOCK_NUMBER - LEAF_A_ANCESTRY_LEN)];
let test_leaf_a = TestLeaf { activated, min_relay_parents };
@@ -35,11 +35,10 @@ use parity_scale_codec::Encode;
use parking_lot::Mutex;
use sp_core::testing::TaskExecutor;
use polkadot_node_subsystem::{
jaeger, messages::AllMessages, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
};
use polkadot_node_subsystem::{messages::AllMessages, ActiveLeavesUpdate};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_primitives::{BlakeTwo256, ConsensusLog, HashT};
use test_helpers::mock::new_leaf;
#[derive(Default)]
struct TestBackendInner {
@@ -367,12 +366,10 @@ async fn import_blocks_into(
let hash = header.hash();
virtual_overseer
.send(
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(new_leaf(
hash,
number: header.number,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}))
header.number,
)))
.into(),
)
.await;
@@ -425,12 +422,10 @@ async fn import_all_blocks_into(
let (_, write_rx) = backend.await_next_write();
virtual_overseer
.send(
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: head_hash,
number: head.number,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}))
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(new_leaf(
head_hash,
head.number,
)))
.into(),
)
.await;
@@ -308,6 +308,8 @@ impl Initialized {
Ok(session_idx)
if self.gaps_in_cache || session_idx > self.highest_session_seen =>
{
// Pin the block from the new session.
self.runtime_info.pin_block(session_idx, new_leaf.unpin_handle);
// Fetch the last `DISPUTE_WINDOW` number of sessions unless there are no gaps
// in cache and we are not missing too many `SessionInfo`s
let mut lower_bound = session_idx.saturating_sub(DISPUTE_WINDOW.get() - 1);
@@ -387,26 +389,28 @@ impl Initialized {
"Processing unapplied validator slashes",
);
let pinned_hash = self.runtime_info.get_block_in_session(session_index);
let inclusions = self.scraper.get_blocks_including_candidate(&candidate_hash);
if inclusions.is_empty() {
if pinned_hash.is_none() && inclusions.is_empty() {
gum::info!(
target: LOG_TARGET,
"Couldn't find inclusion parent for an unapplied slash",
?session_index,
"Couldn't find blocks in the session for an unapplied slash",
);
return
}
// Find the first inclusion parent that we can use
// Find a relay block that we can use
// to generate key ownership proof on.
// We use inclusion parents because of the proper session index.
// We use inclusion parents as a fallback.
let mut key_ownership_proofs = Vec::new();
let mut dispute_proofs = Vec::new();
for (_height, inclusion_parent) in inclusions {
let blocks_in_the_session =
pinned_hash.into_iter().chain(inclusions.into_iter().map(|(_n, h)| h));
for hash in blocks_in_the_session {
for (validator_index, validator_id) in pending.keys.iter() {
let res =
key_ownership_proof(ctx.sender(), inclusion_parent, validator_id.clone())
.await;
let res = key_ownership_proof(ctx.sender(), hash, validator_id.clone()).await;
match res {
Ok(Some(key_ownership_proof)) => {
@@ -28,15 +28,14 @@ use ::test_helpers::{
use parity_scale_codec::Encode;
use polkadot_node_primitives::{AvailableData, BlockData, InvalidCandidate, PoV};
use polkadot_node_subsystem::{
jaeger,
messages::{
AllMessages, ChainApiMessage, DisputeCoordinatorMessage, RuntimeApiMessage,
RuntimeApiRequest,
},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, SpawnGlue,
ActiveLeavesUpdate, SpawnGlue,
};
use polkadot_node_subsystem_test_helpers::{
make_subsystem_context, TestSubsystemContext, TestSubsystemContextHandle,
make_subsystem_context, mock::new_leaf, TestSubsystemContext, TestSubsystemContextHandle,
};
use polkadot_primitives::{
BlakeTwo256, CandidateCommitments, HashT, Header, PersistedValidationData, ValidationCode,
@@ -100,12 +99,7 @@ async fn activate_leaf<Context>(
participation
.process_active_leaves_update(
ctx,
&ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: block_hash,
span: Arc::new(jaeger::Span::Disabled),
number: block_number,
status: LeafStatus::Fresh,
}),
&ActiveLeavesUpdate::start_work(new_leaf(block_hash, block_number)),
)
.await
}
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use std::{sync::Arc, time::Duration};
use std::time::Duration;
use assert_matches::assert_matches;
@@ -25,15 +25,15 @@ use sp_core::testing::TaskExecutor;
use ::test_helpers::{dummy_collator, dummy_collator_signature, dummy_hash};
use polkadot_node_primitives::DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION;
use polkadot_node_subsystem::{
jaeger,
messages::{
AllMessages, ChainApiMessage, DisputeCoordinatorMessage, RuntimeApiMessage,
RuntimeApiRequest,
},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, SpawnGlue,
ActivatedLeaf, ActiveLeavesUpdate, SpawnGlue,
};
use polkadot_node_subsystem_test_helpers::{
make_subsystem_context, TestSubsystemContext, TestSubsystemContextHandle, TestSubsystemSender,
make_subsystem_context, mock::new_leaf, TestSubsystemContext, TestSubsystemContextHandle,
TestSubsystemSender,
};
use polkadot_node_subsystem_util::{reexports::SubsystemContext, TimeoutExt};
use polkadot_primitives::{
@@ -141,12 +141,7 @@ fn make_candidate_receipt(relay_parent: Hash) -> CandidateReceipt {
/// Get a dummy `ActivatedLeaf` for a given block number.
fn get_activated_leaf(n: BlockNumber) -> ActivatedLeaf {
ActivatedLeaf {
hash: get_block_number_hash(n),
number: n,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}
new_leaf(get_block_number_hash(n), n)
}
/// Get a dummy relay parent hash for dummy block number.
@@ -54,12 +54,11 @@ use sp_keystore::{Keystore, KeystorePtr};
use ::test_helpers::{dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash};
use polkadot_node_primitives::{Timestamp, ACTIVE_DURATION_SECS};
use polkadot_node_subsystem::{
jaeger,
messages::{AllMessages, BlockDescription, RuntimeApiMessage, RuntimeApiRequest},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
ActiveLeavesUpdate,
};
use polkadot_node_subsystem_test_helpers::{
make_buffered_subsystem_context, TestSubsystemContextHandle,
make_buffered_subsystem_context, mock::new_leaf, TestSubsystemContextHandle,
};
use polkadot_primitives::{
ApprovalVote, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash,
@@ -276,12 +275,7 @@ impl TestState {
gum::debug!(?block_number, "Activating block in activate_leaf_at_session.");
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(
ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: block_hash,
span: Arc::new(jaeger::Span::Disabled),
number: block_number,
status: LeafStatus::Fresh,
}),
ActiveLeavesUpdate::start_work(new_leaf(block_hash, block_number)),
)))
.await;
@@ -449,12 +443,7 @@ impl TestState {
);
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(
ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: *leaf,
number: n as u32,
span: Arc::new(jaeger::Span::Disabled),
status: LeafStatus::Fresh,
}),
ActiveLeavesUpdate::start_work(new_leaf(*leaf, n as u32)),
)))
.await;
@@ -24,7 +24,6 @@ use polkadot_node_subsystem::{
},
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_types::{jaeger, ActivatedLeaf, LeafStatus};
use polkadot_primitives::{
vstaging::{AsyncBackingParams, BackingState, Constraints, InboundHrmpLimitations},
CommittedCandidateReceipt, HeadData, Header, PersistedValidationData, ScheduledCore,
@@ -32,6 +31,7 @@ use polkadot_primitives::{
};
use polkadot_primitives_test_helpers::make_candidate;
use std::sync::Arc;
use test_helpers::mock::new_leaf;
const ALLOWED_ANCESTRY_LEN: u32 = 3;
const ASYNC_BACKING_PARAMETERS: AsyncBackingParams =
@@ -197,12 +197,7 @@ async fn activate_leaf_with_params(
) {
let TestLeaf { number, hash, .. } = leaf;
let activated = ActivatedLeaf {
hash: *hash,
number: *number,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(*hash, *number);
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
@@ -497,12 +492,7 @@ fn should_do_no_work_if_async_backing_disabled_for_leaf() {
// Start work on some new parent.
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(
ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}),
ActiveLeavesUpdate::start_work(new_leaf(hash, 1)),
)))
.await;
@@ -1318,12 +1308,7 @@ fn correctly_updates_leaves() {
.await;
// Activate a leaf and remove one at the same time.
let activated = ActivatedLeaf {
hash: leaf_c.hash,
number: leaf_c.number,
span: Arc::new(jaeger::Span::Disabled),
status: LeafStatus::Fresh,
};
let activated = new_leaf(leaf_c.hash, leaf_c.number);
let update = ActiveLeavesUpdate {
activated: Some(activated),
deactivated: [leaf_b.hash][..].into(),
@@ -1349,12 +1334,7 @@ fn correctly_updates_leaves() {
.await;
// Activate and deactivate the same leaf.
let activated = ActivatedLeaf {
hash: leaf_a.hash,
number: leaf_a.number,
span: Arc::new(jaeger::Span::Disabled),
status: LeafStatus::Fresh,
};
let activated = new_leaf(leaf_a.hash, leaf_a.number);
let update = ActiveLeavesUpdate {
activated: Some(activated),
deactivated: [leaf_a.hash][..].into(),
@@ -1578,12 +1558,7 @@ fn uses_ancestry_only_within_session() {
vec![Hash::repeat_byte(4), Hash::repeat_byte(3), Hash::repeat_byte(2)];
let session_change_hash = Hash::repeat_byte(3);
let activated = ActivatedLeaf {
hash,
number,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
};
let activated = new_leaf(hash, number);
virtual_overseer
.send(FromOrchestra::Signal(OverseerSignal::ActiveLeaves(
@@ -24,12 +24,11 @@ use polkadot_node_primitives::{CandidateVotes, DisputeStatus, ACTIVE_DURATION_SE
use polkadot_node_subsystem::messages::{
AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use polkadot_node_subsystem_test_helpers::TestSubsystemSender;
use polkadot_node_subsystem_test_helpers::{mock::new_leaf, TestSubsystemSender};
use polkadot_primitives::{
CandidateHash, DisputeState, InvalidDisputeStatementKind, SessionIndex,
ValidDisputeStatementKind, ValidatorSignature,
};
use std::sync::Arc;
use test_helpers;
//
@@ -353,12 +352,7 @@ async fn mock_overseer(
}
fn leaf() -> ActivatedLeaf {
ActivatedLeaf {
hash: Hash::repeat_byte(0xAA),
number: 0xAA,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}
new_leaf(Hash::repeat_byte(0xAA), 0xAA)
}
struct TestDisputes {
+5 -9
View File
@@ -17,14 +17,15 @@
use ::test_helpers::{dummy_digest, dummy_hash};
use futures::{channel::oneshot, future::BoxFuture, prelude::*};
use polkadot_node_subsystem::{
jaeger,
messages::{
AllMessages, CandidateValidationMessage, PreCheckOutcome, PvfCheckerMessage,
RuntimeApiMessage, RuntimeApiRequest,
},
ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, RuntimeApiError,
ActiveLeavesUpdate, FromOrchestra, OverseerSignal, RuntimeApiError,
};
use polkadot_node_subsystem_test_helpers::{
make_subsystem_context, mock::new_leaf, TestSubsystemContextHandle,
};
use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
use polkadot_primitives::{
BlockNumber, Hash, Header, PvfCheckStatement, SessionIndex, ValidationCode, ValidationCodeHash,
ValidatorId,
@@ -195,12 +196,7 @@ impl TestState {
},
);
Some(ActivatedLeaf {
hash: activated_leaf.block_hash,
span: Arc::new(jaeger::Span::Disabled),
number: activated_leaf.block_number,
status: LeafStatus::Fresh,
})
Some(new_leaf(activated_leaf.block_hash, activated_leaf.block_number))
} else {
None
};