Skip to content
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
6 changes: 4 additions & 2 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ class BCN_API chaser_validate
const uint64_t initial_subsidy_;
const size_t maximum_backlog_;
const size_t maximum_height_;
const uint64_t batch_target_;
const bool batch_enabled_;
const uint64_t verify_target_;
const uint64_t silent_target_;
const bool verify_enabled_;
const bool silent_enabled_;
const bool node_witness_;
const bool filter_;
};
Expand Down
6 changes: 4 additions & 2 deletions include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class BCN_API settings
float allowed_deviation;
double minimum_fee_rate;
double minimum_bump_rate;
uint64_t batch_signatures;
uint64_t batch_verify;
uint64_t batch_silent;
uint16_t current_connections;
uint16_t announcement_cache;
uint16_t fee_estimate_horizon;
Expand All @@ -72,7 +73,8 @@ class BCN_API settings
virtual uint64_t services_provided() const NOEXCEPT;
virtual uint64_t services_required() const NOEXCEPT;
virtual bool fee_estimate_enabled() const NOEXCEPT;
virtual bool batch_signatures_enabled() const NOEXCEPT;
virtual bool batch_verify_enabled() const NOEXCEPT;
virtual bool batch_silent_enabled() const NOEXCEPT;
virtual network::steady_clock::duration sample_period() const NOEXCEPT;
virtual network::steady_clock::duration compact_timeout() const NOEXCEPT;
virtual network::wall_clock::duration currency_window() const NOEXCEPT;
Expand Down
34 changes: 24 additions & 10 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT
initial_subsidy_(node.system_settings().initial_subsidy()),
maximum_backlog_(node.node_settings().maximum_concurrency_()),
maximum_height_(node.node_settings().maximum_height_()),
batch_target_(node.node_settings().batch_signatures),
batch_enabled_(node.node_settings().batch_signatures_enabled() &&
verify_target_(node.node_settings().batch_verify),
silent_target_(node.node_settings().batch_silent),
verify_enabled_(node.node_settings().batch_verify_enabled() &&
system::batched::accelerated()),
silent_enabled_(node.node_settings().batch_silent_enabled() &&
system::batched::accelerated()),
node_witness_(node.node_settings().require_witness),
filter_(node.archive().filter_enabled())
Expand All @@ -53,10 +56,14 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT

code chaser_validate::start() NOEXCEPT
{
if (node_settings().batch_signatures_enabled() && !batch_enabled_)
LOGN("Signature batching disabled ("
<< (system::batched::compiled() ? "no device" : "not compiled")
<< ").");
const auto reason = system::batched::compiled() ? "no device" :
"not compiled";

if (node_settings().batch_verify_enabled() && !verify_enabled_)
LOGN("Signature batching disabled (" << reason << ").");

if (node_settings().batch_silent_enabled() && !silent_enabled_)
LOGN("Silent batching disabled (" << reason << ").");

set_position(archive().get_fork());
if (const auto ec = start_batch())
Expand Down Expand Up @@ -298,15 +305,22 @@ void chaser_validate::complete_block(const code& ec, const header_link& link,
// Batch jobs (self-serviced from any thread).
// ------------------------------------------------------------------------

if (closed() || !batch_enabled_)
if (closed())
return;

// Silent batch drains when mature or recent, independent of signatures.
if (silent_enabled_)
{
const auto recent = !bypass && is_current_header(link);
process_silent_batch(recent || is_residual());
}

if (!verify_enabled_)
return;

// Capturing disabled when confirmed chain current (and not under bypass).
const auto current = !capturing && !bypass;

// Silent batch drains when mature or recent, independent of signatures.
process_silent_batch(current || is_residual());

if (batched)
{
process_batch(is_residual());
Expand Down
10 changes: 5 additions & 5 deletions src/chasers/chaser_validate_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ code chaser_validate::start_batch() NOEXCEPT

// Prevalid is not a validation state, so dropped blocks validate in
// place.
if (!batch_enabled_)
if (!verify_enabled_)
{
LOGN("Dropping staged batch rows ("
<< query.prevalid_records(bank) << ").");
Expand Down Expand Up @@ -280,20 +280,20 @@ bool chaser_validate::is_mature(bool residual) NOEXCEPT

// Verify residuals whenever, and non-residuals when mature.
return residual ||
(ecdsa >= batch_target_) ||
(schnorr >= batch_target_);
(ecdsa >= verify_target_) ||
(schnorr >= verify_target_);
}

// Silent batch is committed while the candidate is not current.
bool chaser_validate::is_silent_capturing(const header_link& link) NOEXCEPT
{
return batch_enabled_ && !is_current_header(link);
return silent_enabled_ && !is_current_header(link);
}

bool chaser_validate::is_silent_mature(bool residual) NOEXCEPT
{
const auto rows = archive().silent_records(silent_bank_.load());
return is_nonzero(rows) && (residual || rows >= batch_target_);
return is_nonzero(rows) && (residual || rows >= silent_target_);
}

std::string chaser_validate::log_rate(const std::string& name,
Expand Down
2 changes: 1 addition & 1 deletion src/chasers/chaser_validate_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void chaser_validate::do_fire(missed miss, size_t count) NOEXCEPT

signatures chaser_validate::get_capture(const header_link& link) NOEXCEPT
{
if (!batch_enabled_ || link.is_terminal() || is_current_header(link))
if (!verify_enabled_ || link.is_terminal() || is_current_header(link))
return { false };

// The capture populates this thread's accumulators (commit_capture consumes).
Expand Down
12 changes: 9 additions & 3 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ settings::settings() NOEXCEPT
provide_filters{ false },
provide_privacy{ false },
limited_blocks{ false },
batch_signatures{ 0 },
batch_verify{ 0 },
batch_silent{ 0 },
minimum_fee_rate{ 0.0 },
minimum_bump_rate{ 0.0 },
allowed_deviation{ 1.5 },
Expand Down Expand Up @@ -135,9 +136,14 @@ bool settings::fee_estimate_enabled() const NOEXCEPT
return to_bool(fee_estimate_horizon_());
}

bool settings::batch_signatures_enabled() const NOEXCEPT
bool settings::batch_verify_enabled() const NOEXCEPT
{
return to_bool(batch_signatures);
return to_bool(batch_verify);
}

bool settings::batch_silent_enabled() const NOEXCEPT
{
return to_bool(batch_silent);
}

network::steady_clock::duration settings::sample_period() const NOEXCEPT
Expand Down
4 changes: 2 additions & 2 deletions test/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ struct validate_staged_fixture
validate_staged_fixture()
: validate_setup_fixture(validate_staged, [](configuration& config)
{
config.node.batch_signatures = 1;
config.node.batch_verify = 1;
})
{
}
Expand All @@ -424,7 +424,7 @@ struct validate_staged_second_fixture
validate_staged_second_fixture()
: validate_setup_fixture(validate_staged_second, [](configuration& config)
{
config.node.batch_signatures = 1;
config.node.batch_verify = 1;
})
{
}
Expand Down
6 changes: 4 additions & 2 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
BOOST_REQUIRE_EQUAL(node.minimum_fee_rate_(), 0_u64);
BOOST_REQUIRE_EQUAL(node.minimum_bump_rate, 0.0);
BOOST_REQUIRE_EQUAL(node.allowed_deviation, 1.5);
BOOST_REQUIRE_EQUAL(node.batch_signatures, 0_u64);
BOOST_REQUIRE_EQUAL(node.batch_verify, 0_u64);
BOOST_REQUIRE_EQUAL(node.batch_silent, 0_u64);
BOOST_REQUIRE_EQUAL(node.current_connections, 10_u16);
BOOST_REQUIRE_EQUAL(node.announcement_cache, 42_u16);
BOOST_REQUIRE_EQUAL(node.fee_estimate_horizon, 0u);
Expand All @@ -67,7 +68,8 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50'000_size);
BOOST_REQUIRE_EQUAL(node.fee_estimate_horizon_(), 0_size);
BOOST_REQUIRE(!node.fee_estimate_enabled());
BOOST_REQUIRE(!node.batch_signatures_enabled());
BOOST_REQUIRE(!node.batch_verify_enabled());
BOOST_REQUIRE(!node.batch_silent_enabled());
BOOST_REQUIRE(node.sample_period() == steady_clock::duration(seconds(10)));
BOOST_REQUIRE(node.currency_window() == steady_clock::duration(minutes(1440)));
BOOST_REQUIRE(node.thread_priority_() == network::processing_priority::high);
Expand Down
Loading