Skip to content

Commit 0500416

Browse files
committed
Delint, handle batch sequence counter overflow.
1 parent 96469c4 commit 0500416

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

include/bitcoin/node/chasers/chaser_validate.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class BCN_API chaser_validate
9191
static constexpr auto relaxed = std::memory_order_relaxed;
9292
using atomic_counter = std::atomic<size_t>;
9393
using atomic_counter_ptr = std::shared_ptr<atomic_counter>;
94-
using threshold_group = signatures::threshold_group;
94+
using threshold = system::chain::threshold;
9595
using missed = signatures::miss;
9696

9797
/// Batching helpers.
@@ -112,7 +112,7 @@ class BCN_API chaser_validate
112112
const system::ec_compresseds& points,
113113
const system::ec_signatures& signs, const header_link& link,
114114
const atomic_counter_ptr& sequence) NOEXCEPT;
115-
bool do_threshold(const threshold_group& group, const header_link& link,
115+
bool do_threshold(const threshold& batch, const header_link& link,
116116
const atomic_counter_ptr& sequence) NOEXCEPT;
117117

118118
// Capture helpers.

src/chasers/chaser_validate_capture.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ using namespace system::chain;
3131
using namespace database;
3232
using namespace std::placeholders;
3333

34+
// Shared pointers required for lifetime in handler parameters.
35+
BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR)
36+
BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED)
3437
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
3538

3639
// Capture handlers.
@@ -67,7 +70,9 @@ bool chaser_validate::do_ecdsa(const hash_digest& digest,
6770
{
6871
++ecdsa_;
6972
const auto id = (*sequence)++;
70-
const auto set = archive().set_signature(digest, point, sign, id, link);
73+
if (is_limited<uint16_t>(id)) return false;
74+
const auto group = narrow_cast<uint16_t>(id);
75+
const auto set = archive().set_signature(digest, point, sign, group, link);
7176
if (!set) fault(error::batch5);
7277
return set;
7378
}
@@ -78,7 +83,9 @@ bool chaser_validate::do_schnorr(const hash_digest& digest,
7883
{
7984
++schnorr_;
8085
const auto id = (*sequence)++;
81-
const auto set = archive().set_signature(digest, point, sign, id, link);
86+
if (is_limited<uint16_t>(id)) return false;
87+
const auto group = narrow_cast<uint16_t>(id);
88+
const auto set = archive().set_signature(digest, point, sign, group, link);
8289
if (!set) fault(error::batch6);
8390
return set;
8491
}
@@ -91,17 +98,21 @@ bool chaser_validate::do_multisig(const hash_digest& digest,
9198

9299
multisig_ += points.size();
93100
const auto id = (*sequence)++;
94-
const auto set = archive().set_signatures(digest, points, signs, id, link);
101+
if (is_limited<uint16_t>(id)) return false;
102+
const auto group = narrow_cast<uint16_t>(id);
103+
const auto set = archive().set_signatures(digest, points, signs, group, link);
95104
if (!set) fault(error::batch7);
96105
return set;
97106
}
98107

99-
bool chaser_validate::do_threshold(const threshold_group& group,
108+
bool chaser_validate::do_threshold(const threshold& batch,
100109
const header_link& link, const atomic_counter_ptr& sequence) NOEXCEPT
101110
{
102-
threshold_ += group.entries.size();
111+
threshold_ += batch.tuples.size();
103112
const auto id = (*sequence)++;
104-
const auto set = archive().set_signatures(group, id, link);
113+
if (is_limited<uint16_t>(id)) return false;
114+
const auto group = narrow_cast<uint16_t>(id);
115+
const auto set = archive().set_signatures(batch, group, link);
105116
if (!set) fault(error::batch8);
106117
return set;
107118
}
@@ -155,6 +166,8 @@ void chaser_validate::log_captures() const NOEXCEPT
155166
LOGV(log_ratio("Capture rate threshold ", threshold_, threshold_ + zero));
156167
}
157168

169+
BC_POP_WARNING()
170+
BC_POP_WARNING()
158171
BC_POP_WARNING()
159172

160173
} // namespace node

0 commit comments

Comments
 (0)