Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

change ActiveLeaves to contain at most one activated #3525

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 18 additions & 27 deletions node/core/av-store/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,12 @@ fn runtime_api_error_does_not_stop_the_subsystem() {

overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: vec![ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}].into(),
deactivated: vec![].into(),
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let header = Header {
Expand Down Expand Up @@ -806,15 +803,12 @@ fn we_dont_miss_anything_if_import_notifications_are_missed() {

overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: vec![ActivatedLeaf {
hash: new_leaf,
number: 4,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}].into(),
deactivated: vec![].into(),
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 4,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

assert_matches!(
Expand Down Expand Up @@ -1139,15 +1133,12 @@ async fn import_leaf(

overseer_signal(
virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: vec![ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}].into(),
deactivated: vec![].into(),
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: new_leaf,
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

assert_matches!(
Expand Down
1 change: 0 additions & 1 deletion node/network/availability-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "master
futures-timer = "3.0.2"
assert_matches = "1.4.0"
maplit = "1.0"
smallvec = "1.6.1"
7 changes: 3 additions & 4 deletions node/network/availability-distribution/src/tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::{collections::{HashMap, HashSet}, sync::Arc, time::Duration};

use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_subsystem_testhelpers::TestSubsystemContextHandle;
use smallvec::smallvec;

use futures::{FutureExt, channel::oneshot, SinkExt, channel::mpsc, StreamExt};
use futures_timer::Delay;
Expand Down Expand Up @@ -171,13 +170,13 @@ impl TestState {
self
.relay_chain.iter().zip(advanced)
.map(|(old, new)| ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
activated: Some(ActivatedLeaf {
hash: new.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![old.clone()],
}),
deactivated: vec![old.clone()].into(),
}).collect::<Vec<_>>()
};

Expand Down
1 change: 0 additions & 1 deletion node/network/availability-recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ assert_matches = "1.4.0"
env_logger = "0.8.4"
futures-timer = "3.0.2"
log = "0.4.11"
smallvec = "1.5.1"

sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
166 changes: 66 additions & 100 deletions node/network/availability-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::sync::Arc;
use futures::{executor, future};
use futures_timer::Delay;
use assert_matches::assert_matches;
use smallvec::smallvec;

use parity_scale_codec::Encode;

Expand Down Expand Up @@ -446,15 +445,12 @@ fn availability_is_recovered_from_chunks_if_no_group_provided() {
test_harness_fast_path(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -528,15 +524,12 @@ fn availability_is_recovered_from_chunks_even_if_backing_group_supplied_if_chunk
test_harness_chunks_only(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -610,15 +603,12 @@ fn bad_merkle_path_leads_to_recovery_error() {
test_harness_fast_path(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -667,15 +657,12 @@ fn wrong_chunk_index_leads_to_recovery_error() {
test_harness_fast_path(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -741,15 +728,12 @@ fn invalid_erasure_coding_leads_to_invalid_error() {

overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -789,15 +773,12 @@ fn fast_path_backing_group_recovers() {
test_harness_fast_path(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -842,15 +823,12 @@ fn no_answers_in_fast_path_causes_chunk_requests() {
test_harness_fast_path(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -905,15 +883,12 @@ fn task_canceled_when_receivers_dropped() {
test_harness_chunks_only(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, _) = oneshot::channel();
Expand Down Expand Up @@ -948,15 +923,12 @@ fn chunks_retry_until_all_nodes_respond() {
test_harness_chunks_only(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -1007,15 +979,12 @@ fn returns_early_if_we_have_the_data() {
test_harness_chunks_only(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down Expand Up @@ -1045,15 +1014,12 @@ fn does_not_query_local_validator() {
test_harness_chunks_only(|mut virtual_overseer| async move {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: smallvec![ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
}],
deactivated: smallvec![],
}),
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.current.clone(),
number: 1,
status: LeafStatus::Fresh,
span: Arc::new(jaeger::Span::Disabled),
})),
).await;

let (tx, rx) = oneshot::channel();
Expand Down
2 changes: 1 addition & 1 deletion node/network/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ where
tracing::trace!(
target: LOG_TARGET,
action = "ActiveLeaves",
num_activated = %activated.len(),
has_activated = activated.is_some(),
num_deactivated = %deactivated.len(),
);

Expand Down
Loading