Skip to content

Commit

Permalink
Enable block-fanout validation, disabled confirmability.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Oct 23, 2024
1 parent 5637b9e commit 3c81431
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 256 deletions.
2 changes: 2 additions & 0 deletions include/bitcoin/node/chasers/chaser_confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class BCN_API chaser_confirm
chaser_confirm(full_node& node) NOEXCEPT;

code start() NOEXCEPT override;
void stopping(const code& ec) NOEXCEPT override;
void stop() NOEXCEPT override;

protected:
using header_links = std_vector<database::header_link>;
Expand Down
26 changes: 7 additions & 19 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,22 @@ class BCN_API chaser_validate
chaser_validate(full_node& node) NOEXCEPT;

code start() NOEXCEPT override;

/// Validate a populated candidate block.
virtual void validate(const system::chain::block::cptr& block,
const database::header_link& link, size_t height) NOEXCEPT;
void stopping(const code& ec) NOEXCEPT override;
void stop() NOEXCEPT override;

protected:
typedef network::race_unity<const code&, const database::tx_link&> race;

virtual bool handle_event(const code& ec, chase event_,
event_value value) NOEXCEPT;

virtual void do_validate(const system::chain::block::cptr& block,
database::header_link::integer link, size_t height) NOEXCEPT;

virtual void do_regressed(height_t branch_point) NOEXCEPT;
virtual void do_checked(height_t height) NOEXCEPT;
virtual void do_bump(height_t height) NOEXCEPT;

virtual bool enqueue_block(const database::header_link& link) NOEXCEPT;
virtual void validate_tx(const database::context& ctx,
const database::tx_link& link, const race::ptr& racer) NOEXCEPT;
virtual void handle_tx(const code& ec, const database::tx_link& tx,
const race::ptr& racer) NOEXCEPT;
virtual void handle_txs(const code& ec, const database::tx_link& tx,
const database::header_link& link,
const database::context& ctx) NOEXCEPT;
virtual void validate_block(const code& ec,
const database::header_link& link,
const database::context& ctx) NOEXCEPT;
virtual void validate_block(const database::header_link& link) NOEXCEPT;
virtual void complete_block(const code& ec,
const database::header_link& link, size_t height) NOEXCEPT;

private:
// neutrino
Expand All @@ -79,11 +66,12 @@ class BCN_API chaser_validate

// These are thread safe.
const uint64_t initial_subsidy_;
const uint32_t subsidy_interval_blocks_;
const uint32_t subsidy_interval_;

// These are protected by strand.
network::threadpool threadpool_;
system::hash_digest neutrino_{};
size_t validation_backlog_{};
};

} // namespace node
Expand Down
28 changes: 22 additions & 6 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

chaser_confirm::chaser_confirm(full_node& node) NOEXCEPT
: chaser(node),
threadpool_(std::max(node.config().node.threads, 1_u32))
threadpool_(one)
{
}

Expand All @@ -48,11 +48,27 @@ code chaser_confirm::start() NOEXCEPT
return error::success;
}

void chaser_confirm::stopping(const code& ec) NOEXCEPT
{
// Stop threadpool keep-alive, all work must self-terminate to affect join.
threadpool_.stop();
chaser::stopping(ec);
}

void chaser_confirm::stop() NOEXCEPT
{
if (!threadpool_.join())
{
BC_ASSERT_MSG(false, "failed to join threadpool");
std::abort();
}
}

// Protected
// ----------------------------------------------------------------------------

bool chaser_confirm::handle_event(const code&, chase event_,
event_value value) NOEXCEPT
event_value) NOEXCEPT
{
if (closed())
return false;
Expand All @@ -67,15 +83,15 @@ bool chaser_confirm::handle_event(const code&, chase event_,
case chase::blocks:
{
// TODO: value is branch point.
BC_ASSERT(std::holds_alternative<height_t>(value));
POST(do_validated, std::get<height_t>(value));
////BC_ASSERT(std::holds_alternative<height_t>(value));
////POST(do_validated, std::get<height_t>(value));
break;
}
case chase::valid:
{
// value is individual height.
BC_ASSERT(std::holds_alternative<height_t>(value));
POST(do_validated, std::get<height_t>(value));
////BC_ASSERT(std::holds_alternative<height_t>(value));
////POST(do_validated, std::get<height_t>(value));
break;
}
case chase::stop:
Expand Down
Loading

0 comments on commit 3c81431

Please sign in to comment.