From 942c030682ca282e1d1052d404cebcb566369856 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Fri, 10 May 2024 15:44:18 -0400 Subject: [PATCH] Add snapshot_interval and remove maximum_inventory setting. --- include/bitcoin/node/chasers/chaser_check.hpp | 2 +- include/bitcoin/node/settings.hpp | 9 +++--- src/chasers/chaser_check.cpp | 9 +++--- src/parser.cpp | 30 +++++++++---------- src/settings.cpp | 22 +++++++++----- test/settings.cpp | 16 ++++++---- 6 files changed, 50 insertions(+), 38 deletions(-) diff --git a/include/bitcoin/node/chasers/chaser_check.hpp b/include/bitcoin/node/chasers/chaser_check.hpp index 47141c67..9c875584 100644 --- a/include/bitcoin/node/chasers/chaser_check.hpp +++ b/include/bitcoin/node/chasers/chaser_check.hpp @@ -74,7 +74,7 @@ class BCN_API chaser_check size_t get_unassociated() NOEXCEPT; // These are thread safe. - const size_t maximum_advance_; + const size_t maximum_concurrency_; const size_t maximum_height_; const size_t connections_; const size_t inventory_; diff --git a/include/bitcoin/node/settings.hpp b/include/bitcoin/node/settings.hpp index 40df8dd5..b958a037 100644 --- a/include/bitcoin/node/settings.hpp +++ b/include/bitcoin/node/settings.hpp @@ -63,15 +63,16 @@ class BCN_API settings /// Properties. bool headers_first; float allowed_deviation; - uint16_t maximum_inventory; + uint32_t maximum_height; + uint32_t maximum_concurrency; + uint32_t snapshot_interval; uint16_t sample_period_seconds; uint32_t currency_window_minutes; - uint32_t maximum_advance; - uint32_t maximum_height; /// Helpers. - virtual size_t maximum_advance_() const NOEXCEPT; virtual size_t maximum_height_() const NOEXCEPT; + virtual size_t maximum_concurrency_() const NOEXCEPT; + virtual size_t snapshot_interval_() const NOEXCEPT; virtual network::steady_clock::duration sample_period() const NOEXCEPT; virtual network::wall_clock::duration currency_window() const NOEXCEPT; }; diff --git a/src/chasers/chaser_check.cpp b/src/chasers/chaser_check.cpp index 1f5cc9cc..7d5b55b0 100644 --- a/src/chasers/chaser_check.cpp +++ b/src/chasers/chaser_check.cpp @@ -43,11 +43,10 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) chaser_check::chaser_check(full_node& node) NOEXCEPT : chaser(node), - maximum_advance_(node.config().node.maximum_advance_()), + maximum_concurrency_(node.config().node.maximum_concurrency_()), maximum_height_(node.config().node.maximum_height_()), connections_(node.config().network.outbound_connections), - inventory_(system::lesser(node.config().node.maximum_inventory, - messages::max_inventory)) + inventory_(node.maximum_inventory()) { } @@ -288,7 +287,7 @@ size_t chaser_check::get_unassociated() NOEXCEPT // not last requested, since all between are already downloaded. const auto& query = archive(); const auto requested = requested_; - const auto stop = std::min(ceilinged_add(validated_, maximum_advance_), + const auto stop = std::min(ceilinged_add(validated_, maximum_concurrency_), maximum_height_); while (true) @@ -306,7 +305,7 @@ size_t chaser_check::get_unassociated() NOEXCEPT } LOGN("Advance by (" - << maximum_advance_ << ") above (" + << maximum_concurrency_ << ") above (" << requested << ") from (" << validated_ << ") stop (" << stop << ") found (" diff --git a/src/parser.cpp b/src/parser.cpp index 42a295d8..4ececa3d 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -884,29 +884,29 @@ options_metadata parser::load_settings() THROWS "Allowable underperformance standard deviation, defaults to 1.5 (0 disables)." ) ( - "node.sample_period_seconds", - value(&configured.node.sample_period_seconds), - "Sampling period for drop of stalled channels, defaults to 10 (0 disables)." + "node.maximum_height", + value(&configured.node.maximum_height), + "Maximum block height to populate, defaults to 0 (unlimited)." ) ( - "node.currency_window_minutes", - value(&configured.node.currency_window_minutes), - "Time from present that blocks are considered current, defaults to 60 (0 disables)." + "node.maximum_concurrency", + value(&configured.node.maximum_concurrency), + "Maximum number of blocks to download concurrently, defaults to '50000' (0 disables)." ) ( - "node.maximum_inventory", - value(&configured.node.maximum_inventory), - "Maximum size of block inventory requests, defaults to 8000." + "node.snapshot_interval", + value(&configured.node.snapshot_interval), + "Block interval for automatic store snapshots, defaults to '100000' (0 disables)." ) ( - "node.maximum_advance", - value(&configured.node.maximum_advance), - "Maximum number of blocks to download prior to validation, defaults to 0 (unlimited)." + "node.sample_period_seconds", + value(&configured.node.sample_period_seconds), + "Sampling period for drop of stalled channels, defaults to 10 (0 disables)." ) ( - "node.maximum_height", - value(&configured.node.maximum_height), - "The maximum block height to populate, defaults to 0 (unlimited)." + "node.currency_window_minutes", + value(&configured.node.currency_window_minutes), + "Time from present that blocks are considered current, defaults to 60 (0 disables)." ) // ####################### ////( diff --git a/src/settings.cpp b/src/settings.cpp index def129f2..d23aac3c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -66,27 +66,33 @@ namespace node { settings::settings() NOEXCEPT : headers_first{ true }, allowed_deviation{ 1.5 }, - maximum_inventory{ 8000 }, + maximum_height{ 0 }, + maximum_concurrency{ 50'000 }, + snapshot_interval{ 100'000 }, sample_period_seconds{ 10 }, - currency_window_minutes{ 60 }, - maximum_advance{ 0 }, - maximum_height{ 0 } + currency_window_minutes{ 60 } { } settings::settings(chain::selection) NOEXCEPT : settings() { + // TODO: testnet, etc. maximum_concurrency, snapshot_interval. } -size_t settings::maximum_advance_() const NOEXCEPT +size_t settings::maximum_height_() const NOEXCEPT { - return is_zero(maximum_advance) ? max_size_t : maximum_advance; + return is_zero(maximum_height) ? max_size_t : maximum_height; } -size_t settings::maximum_height_() const NOEXCEPT +size_t settings::maximum_concurrency_() const NOEXCEPT { - return is_zero(maximum_height) ? max_size_t : maximum_height; + return is_zero(maximum_concurrency) ? max_size_t : maximum_concurrency; +} + +size_t settings::snapshot_interval_() const NOEXCEPT +{ + return is_zero(snapshot_interval) ? max_size_t : snapshot_interval; } network::steady_clock::duration settings::sample_period() const NOEXCEPT diff --git a/test/settings.cpp b/test/settings.cpp index 22ca27d2..12e5316b 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -40,14 +40,20 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected) const node::settings node{}; BOOST_REQUIRE_EQUAL(node.headers_first, true); BOOST_REQUIRE_EQUAL(node.allowed_deviation, 1.5); - BOOST_REQUIRE_EQUAL(node.maximum_inventory, 8000); - BOOST_REQUIRE_EQUAL(node.sample_period_seconds, 10_u16); - BOOST_REQUIRE_EQUAL(node.currency_window_minutes, 60_u32); - BOOST_REQUIRE_EQUAL(node.maximum_advance, 0_u32); - BOOST_REQUIRE_EQUAL(node.maximum_advance_(), max_size_t); + BOOST_REQUIRE_EQUAL(node.maximum_height, 0_u32); BOOST_REQUIRE_EQUAL(node.maximum_height_(), max_size_t); + + BOOST_REQUIRE_EQUAL(node.maximum_concurrency, 50000_u32); + BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50000_size); + + BOOST_REQUIRE_EQUAL(node.snapshot_interval, 100'000_u32); + BOOST_REQUIRE_EQUAL(node.snapshot_interval_(), 100'000_size); + + BOOST_REQUIRE_EQUAL(node.sample_period_seconds, 10_u16); BOOST_REQUIRE(node.sample_period() == network::steady_clock::duration(network::seconds(10))); + + BOOST_REQUIRE_EQUAL(node.currency_window_minutes, 60_u32); BOOST_REQUIRE(node.currency_window() == network::steady_clock::duration(network::minutes(60))); }