From d476c1833912197c05da3836b90abb6de87b7d89 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 27 Apr 2022 02:28:09 +1000 Subject: [PATCH] fix(sync): Add an extra block retry, to speed up the initial sync (#4185) * Increase the block download retry limit to 3 * Remove an obsolete timing check from the tests We cancel all block downloads for each sync restart, so we don't need to wait for the maximum hedged download time. --- zebrad/src/components/sync.rs | 2 +- zebrad/src/components/sync/tests/timing.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/zebrad/src/components/sync.rs b/zebrad/src/components/sync.rs index c0b4e201..48cbb990 100644 --- a/zebrad/src/components/sync.rs +++ b/zebrad/src/components/sync.rs @@ -53,7 +53,7 @@ const FANOUT: usize = 3; /// /// We also hedge requests, so we may retry up to twice this many times. Hedged /// retries may be concurrent, inner retries are sequential. -const BLOCK_DOWNLOAD_RETRY_LIMIT: usize = 2; +const BLOCK_DOWNLOAD_RETRY_LIMIT: usize = 3; /// A lower bound on the user-specified lookahead limit. /// diff --git a/zebrad/src/components/sync/tests/timing.rs b/zebrad/src/components/sync/tests/timing.rs index 3f3f4cd1..b2b45e6d 100644 --- a/zebrad/src/components/sync/tests/timing.rs +++ b/zebrad/src/components/sync/tests/timing.rs @@ -1,3 +1,5 @@ +//! Check the relationship between various sync timeouts and delays. + use std::{ convert::TryInto, sync::{ @@ -34,15 +36,10 @@ fn ensure_timeouts_consistent() { "Sync restart should allow for pending and buffered requests to complete" ); - // This constraint avoids spurious failures due to block retries timing out. // We multiply by 2, because the Hedge can wait up to BLOCK_DOWNLOAD_TIMEOUT // seconds before retrying. const BLOCK_DOWNLOAD_HEDGE_TIMEOUT: u64 = 2 * BLOCK_DOWNLOAD_RETRY_LIMIT as u64 * BLOCK_DOWNLOAD_TIMEOUT.as_secs(); - assert!( - SYNC_RESTART_DELAY.as_secs() > BLOCK_DOWNLOAD_HEDGE_TIMEOUT, - "Sync restart should allow for block downloads to time out on every retry" - ); // This constraint avoids spurious failures due to block download timeouts assert!(