Skip to content

Commit

Permalink
Merge branch 'main' into fix-lwd-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jun 21, 2022
2 parents 8011615 + 1f7e621 commit a8a6c7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion zebra-utils/zcash-rpc-diff
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ fi
ZEBRAD_RPC_PORT=$1
shift

ZCASH_RPC_TMP_DIR=$(mktemp -d)
# Use an easily identified temp directory name,
# but fall back to the default temp name if `mktemp` does not understand `--suffix`.
ZCASH_RPC_TMP_DIR=$(mktemp --suffix=.rpc-diff -d 2>/dev/null || mktemp -d)

ZEBRAD_RELEASE_INFO="$ZCASH_RPC_TMP_DIR/first-check-getinfo.json"
ZCASHD_RELEASE_INFO="$ZCASH_RPC_TMP_DIR/second-check-getinfo.json"
Expand Down
25 changes: 14 additions & 11 deletions zebrad/src/components/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const BLOCK_DOWNLOAD_RETRY_LIMIT: usize = 3;

/// A lower bound on the user-specified lookahead limit.
///
/// Set to two checkpoint intervals, so that we're sure that the lookahead
/// limit always contains at least one complete checkpoint.
/// Set to the maximum checkpoint interval, so the pipeline holds at least one checkpoint's
/// worth of blocks.
///
/// ## Security
///
Expand All @@ -74,7 +74,7 @@ const BLOCK_DOWNLOAD_RETRY_LIMIT: usize = 3;
/// Once these malicious blocks start failing validation, the syncer will cancel all
/// the pending download and verify tasks, drop all the blocks, and start a new
/// ObtainTips with a new set of peers.
pub const MIN_LOOKAHEAD_LIMIT: usize = zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP * 2;
pub const MIN_LOOKAHEAD_LIMIT: usize = zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP;

/// The default for the user-specified lookahead limit.
///
Expand Down Expand Up @@ -318,24 +318,27 @@ where
// We apply a timeout to the verifier to avoid hangs due to missing earlier blocks.
let verifier = Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT);

assert!(
config.sync.lookahead_limit >= MIN_LOOKAHEAD_LIMIT,
"configured lookahead limit {} too low, must be at least {}",
config.sync.lookahead_limit,
MIN_LOOKAHEAD_LIMIT
);
let mut lookahead_limit = config.sync.lookahead_limit;
if lookahead_limit < MIN_LOOKAHEAD_LIMIT {
warn!(
"configured lookahead limit {} too low, increasing to {}",
config.sync.lookahead_limit, MIN_LOOKAHEAD_LIMIT,
);

lookahead_limit = MIN_LOOKAHEAD_LIMIT;
}

let (sync_status, recent_syncs) = SyncStatus::new();

let new_syncer = Self {
genesis_hash: genesis_hash(config.network.network),
lookahead_limit: config.sync.lookahead_limit,
lookahead_limit,
tip_network,
downloads: Box::pin(Downloads::new(
block_network,
verifier,
latest_chain_tip.clone(),
config.sync.lookahead_limit,
lookahead_limit,
)),
state,
latest_chain_tip,
Expand Down

0 comments on commit a8a6c7e

Please sign in to comment.