Skip to content
Open
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
7 changes: 7 additions & 0 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,18 @@ class BCN_API chaser_validate
network::threadpool validation_threadpool_;

// These are thread safe.
std::atomic<size_t> batched_ecdsa_{};
std::atomic<size_t> unbatched_ecdsa_{};
std::atomic<size_t> batched_schnorr_{};
std::atomic<size_t> unbatched_schnorr_{};
std::atomic<size_t> batched_multisig_{};
std::atomic<size_t> unbatched_multisig_{};
std::atomic<size_t> backlog_{};
network::asio::strand validation_strand_;
const uint32_t subsidy_interval_;
const uint64_t initial_subsidy_;
const size_t maximum_backlog_;
const bool batch_signatures_;
const bool node_witness_;
const bool defer_;
const bool filter_;
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/estimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BCN_API estimator
public:
typedef std::unique_ptr<estimator> ptr;
static constexpr size_t maximum_horizon = 1008;
static constexpr size_t estimate_failed = max_uint64;

DELETE_COPY_MOVE_DESTRUCT(estimator);

Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BCN_API settings
bool thread_priority;
bool memory_priority;
bool allow_overlapped;
bool batch_signatures;
bool defer_validation;
bool defer_confirmation;
float allowed_deviation;
Expand Down
48 changes: 46 additions & 2 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT
subsidy_interval_(node.system_settings().subsidy_interval_blocks),
initial_subsidy_(node.system_settings().initial_subsidy()),
maximum_backlog_(node.node_settings().maximum_concurrency_()),
batch_signatures_(node.node_settings().batch_signatures),
node_witness_(node.network_settings().witness_node()),
defer_(node.node_settings().defer_validation),
filter_(!defer_ && node.archive().filter_enabled())
Expand Down Expand Up @@ -295,8 +296,51 @@ code chaser_validate::validate(bool bypass, const chain::block& block,
if ((ec = block.accept(ctx, subsidy_interval_, initial_subsidy_)))
return ec;

if ((ec = block.connect(ctx)))
return ec;
if (batch_signatures_)
{
const chain::signatures capture
{
.ecdsa = [&](const hash_digest& ,
const ec_compressed& , const ec_signature& ) NOEXCEPT
{
////query.set_signature(digest, point, sign, link);
},

.schnorr = [&](const hash_digest& ,
const ec_xonly& , const ec_signature& ) NOEXCEPT
{
////query.set_signature(digest, point, sign, link);
},

.enabled = batch_signatures_
};

if ((ec = block.connect(ctx, capture)))
return ec;

batched_ecdsa_ += capture.batched_ecdsa;
unbatched_ecdsa_ += capture.unbatched_ecdsa;
batched_schnorr_ += capture.batched_schnorr;
unbatched_schnorr_ += capture.unbatched_schnorr;
batched_multisig_ += capture.batched_multisig;
unbatched_multisig_ += capture.unbatched_multisig;
{
LOGV("Bypass ecdsa " << batched_ecdsa_ << " / (" << batched_ecdsa_ << " + " << unbatched_ecdsa_ << ")");
}
if (to_bool(batched_schnorr_.load()) || to_bool(unbatched_schnorr_.load()))
{
LOGV("Bypass schnorr " << batched_schnorr_ << " / (" << batched_schnorr_ << " + " << unbatched_schnorr_ << ")");
}
if (to_bool(batched_multisig_.load()) || to_bool(unbatched_multisig_.load()))
{
LOGV("Bypass multisig " << batched_multisig_ << " / (" << batched_multisig_ << " + " << unbatched_multisig_ << ")");
}
}
else
{
if ((ec = block.connect(ctx)))
return ec;
}

// Prevouts optimize confirmation.
if (!query.set_prevouts(link, block))
Expand Down
21 changes: 7 additions & 14 deletions src/estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,21 @@ using namespace system;

uint64_t estimator::estimate(size_t target, mode mode) const NOEXCEPT
{
// max_uint64 is failure sentinel (and unachievable/invalid as a fee).
auto estimate = max_uint64;
constexpr size_t large = horizon::large;
if (target >= large)
return estimate;
return estimate_failed;

// Valid results are effectively limited to at least 1 sat/vb.
// threshold_fee is thread safe but values are affected during update.
switch (mode)
{
case mode::basic:
{
estimate = compute(target, confidence::high);
break;
return compute(target, confidence::high);
}
case mode::geometric:
{
estimate = compute(target, confidence::high, true);
break;
return compute(target, confidence::high, true);
}
case mode::economical:
{
Expand All @@ -62,8 +58,7 @@ uint64_t estimator::estimate(size_t target, mode mode) const NOEXCEPT
const auto fee1 = compute(target1, confidence::low);
const auto fee2 = compute(target2, confidence::mid);
const auto fee3 = compute(target3, confidence::high);
estimate = std::max({ fee1, fee2, fee3 });
break;
return std::max({ fee1, fee2, fee3 });
}
case mode::conservative:
{
Expand All @@ -73,16 +68,14 @@ uint64_t estimator::estimate(size_t target, mode mode) const NOEXCEPT
const auto fee1 = compute(target1, confidence::low);
const auto fee2 = compute(target2, confidence::mid);
const auto fee3 = compute(target3, confidence::high);
estimate = std::max({ fee1, fee2, fee3 });
break;
return std::max({ fee1, fee2, fee3 });
}
default:
case mode::unknown:
{
break;
return estimate_failed;
}
}

return estimate;
}

bool estimator::initialize(const std::atomic_bool& cancel, const query& query,
Expand Down
1 change: 1 addition & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ settings::settings() NOEXCEPT
memory_priority{ true },
thread_priority{ true },
allow_overlapped{ true },
batch_signatures{ true },
defer_validation{ false },
defer_confirmation{ false },
minimum_fee_rate{ 0.0 },
Expand Down
1 change: 1 addition & 0 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
BOOST_REQUIRE_EQUAL(node.memory_priority, true);
BOOST_REQUIRE_EQUAL(node.thread_priority, true);
BOOST_REQUIRE_EQUAL(node.allow_overlapped, true);
BOOST_REQUIRE_EQUAL(node.batch_signatures, true);
BOOST_REQUIRE_EQUAL(node.defer_validation, false);
BOOST_REQUIRE_EQUAL(node.defer_confirmation, false);
BOOST_REQUIRE_EQUAL(node.minimum_fee_rate, 0.0);
Expand Down
Loading