Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions node/core/av-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ polkadot-node-subsystem-util = { path = "../../subsystem-util" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

[dev-dependencies]
log = "0.4.17"
Expand Down
19 changes: 17 additions & 2 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use futures::{channel::oneshot, future, select, FutureExt};
use futures_timer::Delay;
use parity_scale_codec::{Decode, Encode, Error as CodecError, Input};
use polkadot_node_subsystem_util::database::{DBTransaction, Database};
use sp_consensus::SyncOracle;

use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use polkadot_node_primitives::{AvailableData, ErasureChunk};
Expand Down Expand Up @@ -451,16 +452,23 @@ pub struct AvailabilityStoreSubsystem {
finalized_number: Option<BlockNumber>,
metrics: Metrics,
clock: Box<dyn Clock>,
sync_oracle: Box<dyn SyncOracle + Send + Sync>,
}

impl AvailabilityStoreSubsystem {
/// Create a new `AvailabilityStoreSubsystem` with a given config on disk.
pub fn new(db: Arc<dyn Database>, config: Config, metrics: Metrics) -> Self {
pub fn new(
db: Arc<dyn Database>,
config: Config,
sync_oracle: Box<dyn SyncOracle + Send + Sync>,
metrics: Metrics,
) -> Self {
Self::with_pruning_config_and_clock(
db,
config,
PruningConfig::default(),
Box::new(SystemClock),
sync_oracle,
metrics,
)
}
Expand All @@ -471,6 +479,7 @@ impl AvailabilityStoreSubsystem {
config: Config,
pruning_config: PruningConfig,
clock: Box<dyn Clock>,
sync_oracle: Box<dyn SyncOracle + Send + Sync>,
metrics: Metrics,
) -> Self {
Self {
Expand All @@ -480,6 +489,7 @@ impl AvailabilityStoreSubsystem {
metrics,
clock,
known_blocks: KnownUnfinalizedBlocks::default(),
sync_oracle,
finalized_number: None,
}
}
Expand Down Expand Up @@ -576,7 +586,12 @@ async fn run_iteration<Context>(
// candidates backed in this finalized block.
// Otherwise, we won't be able to store our chunk
// for these candidates.
process_block_activated(ctx, subsystem, hash).await?;
if !subsystem.sync_oracle.is_major_syncing() {
// If we're major syncing, processing finalized
// blocks might take quite a very long time
// and make the subsystem unresponsive.
process_block_activated(ctx, subsystem, hash).await?;
}
}
subsystem.finalized_number = Some(number);
subsystem.known_blocks.prune_finalized(number);
Expand Down
13 changes: 13 additions & 0 deletions node/core/av-store/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ impl Default for TestState {
}
}

struct NoSyncOracle;

impl sp_consensus::SyncOracle for NoSyncOracle {
fn is_major_syncing(&self) -> bool {
false
}

fn is_offline(&self) -> bool {
unimplemented!("not used")
}
}

fn test_harness<T: Future<Output = VirtualOverseer>>(
state: TestState,
store: Arc<dyn Database>,
Expand All @@ -122,6 +134,7 @@ fn test_harness<T: Future<Output = VirtualOverseer>>(
TEST_CONFIG,
state.pruning_config.clone(),
Box::new(state.clock),
Box::new(NoSyncOracle),
Metrics::default(),
);

Expand Down
1 change: 1 addition & 0 deletions node/service/src/overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ where
.availability_store(AvailabilityStoreSubsystem::new(
parachains_db.clone(),
availability_config,
Box::new(network_service.clone()),
Metrics::register(registry)?,
))
.bitfield_distribution(BitfieldDistributionSubsystem::new(Metrics::register(registry)?))
Expand Down