Skip to content

Commit

Permalink
Fix for Issue paritytech#4788
Browse files Browse the repository at this point in the history
  • Loading branch information
tifecool committed Mar 18, 2022
1 parent 043329b commit dc27074
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
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.

3 changes: 1 addition & 2 deletions node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ pub(crate) async fn handle_new_head(
head: Hash,
finalized_number: &Option<BlockNumber>,
) -> SubsystemResult<Vec<BlockImportedCandidates>> {
const MAX_HEADS_LOOK_BACK: BlockNumber = 500;

let mut span = jaeger::Span::new(head, "approval-checking-import");

Expand Down Expand Up @@ -349,7 +348,7 @@ pub(crate) async fn handle_new_head(

// If we've just started the node and are far behind,
// import at most `MAX_HEADS_LOOK_BACK` blocks.
let lower_bound_number = header.number.saturating_sub(MAX_HEADS_LOOK_BACK);
let lower_bound_number = header.number.saturating_sub(crate::MAX_HEADS_LOOK_BACK);
let lower_bound_number = finalized_number.unwrap_or(lower_bound_number).max(lower_bound_number);

let new_blocks = determine_new_blocks(
Expand Down
1 change: 1 addition & 0 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mod tests;

pub const APPROVAL_SESSIONS: SessionWindowSize = new_session_window_size!(6);

pub const MAX_HEADS_LOOK_BACK: BlockNumber = 500;
const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120);
const APPROVAL_CACHE_SIZE: usize = 1024;
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
Expand Down
1 change: 1 addition & 0 deletions node/core/dispute-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
polkadot-node-core-approval-voting = { path = "../approval-voting" }

sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }

Expand Down
3 changes: 2 additions & 1 deletion node/core/dispute-coordinator/src/real/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use polkadot_primitives::v2::{
DisputeStatement, DisputeStatementSet, Hash, ScrapedOnChainVotes, SessionIndex, SessionInfo,
ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature,
};
use polkadot_node_core_approval_voting::MAX_HEADS_LOOK_BACK;

use crate::{
error::{log_error, Error, FatalError, FatalResult, JfyiError, JfyiResult, Result},
Expand All @@ -71,7 +72,7 @@ use super::{
// The capacity and scrape depth are equal to the maximum allowed unfinalized depth.
const LRU_SCRAPED_BLOCKS_CAPACITY: usize = 500;
// This is in sync with `MAX_FINALITY_LAG` in relay chain selection.
const MAX_BATCH_SCRAPE_ANCESTORS: u32 = 500;
const MAX_BATCH_SCRAPE_ANCESTORS: u32 = MAX_HEADS_LOOK_BACK;

/// After the first active leaves update we transition to `Initialized` state.
///
Expand Down
7 changes: 4 additions & 3 deletions node/service/src/relay_chain_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ use polkadot_subsystem::messages::{
ApprovalVotingMessage, ChainSelectionMessage, DisputeCoordinatorMessage,
HighestApprovedAncestorBlock,
};
use polkadot_node_core_approval_voting::MAX_HEADS_LOOK_BACK;
use std::sync::Arc;

/// The maximum amount of unfinalized blocks we are willing to allow due to approval checking
/// or disputes.
///
/// This is a safety net that should be removed at some point in the future.
// Until it's not, make sure to also update `MAX_HEADS_LOOK_BACK` in `approval-voting`
// and `MAX_BATCH_SCRAPE_ANCESTORS` in `dispute-coordinator` when changing its value.
const MAX_FINALITY_LAG: polkadot_primitives::v2::BlockNumber = 500;
// In sync with `MAX_HEADS_LOOK_BACK` in `approval-voting`
// and `MAX_BATCH_SCRAPE_ANCESTORS` in `dispute-coordinator`.
const MAX_FINALITY_LAG: polkadot_primitives::v2::BlockNumber = MAX_HEADS_LOOK_BACK;

const LOG_TARGET: &str = "parachain::chain-selection";

Expand Down

0 comments on commit dc27074

Please sign in to comment.