Skip to content

Commit

Permalink
Merge fd964c9 into fea7066
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed May 4, 2024
2 parents fea7066 + fd964c9 commit 2576c98
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 33 deletions.
20 changes: 12 additions & 8 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ void executor::measure_size() const
((1.0 * query_.header_records()) / query_.validated_bk_buckets()) %
((1.0 * query_.address_records()) / query_.address_buckets()) %
((1.0 * query_.header_records()) / query_.neutrino_buckets()));
console(BN_MEASURE_PROGRESS_START);
console(format(BN_MEASURE_PROGRESS) %
query_.get_fork() %
query_.get_top_confirmed() %
Expand Down Expand Up @@ -695,11 +696,13 @@ void executor::scan_collisions() const
spend.shrink_to_fit();
}

////// arbitrary testing (const).
////void executor::read_test() const
////{
//// console("No read test implemented.");
////}
// arbitrary testing (const).
void executor::read_test() const
{
console("No read test implemented.");
}

#if defined(UNDEFINED)

void executor::read_test() const
{
Expand Down Expand Up @@ -997,8 +1000,6 @@ void executor::read_test() const
////}
}

#if defined(UNDEFINED)

void executor::read_test() const
{
// Binance wallet address with 1,380,169 transaction count.
Expand Down Expand Up @@ -1879,7 +1880,8 @@ bool executor::do_initchain()
query_.validated_bk_buckets() %
query_.address_buckets() %
query_.neutrino_buckets());
console(format(BN_MEASURE_PROGRESS) %
logger(BN_MEASURE_PROGRESS_START);
logger(format(BN_MEASURE_PROGRESS) %
query_.get_fork() %
query_.get_top_confirmed() %
encode_hash(query_.get_header_key(query_.to_confirmed(query_.get_top_confirmed()))) %
Expand Down Expand Up @@ -2514,6 +2516,7 @@ bool executor::do_run()
query_.validated_bk_buckets() %
query_.address_buckets() %
query_.neutrino_buckets());
logger(BN_MEASURE_PROGRESS_START);
logger(format(BN_MEASURE_PROGRESS) %
query_.get_fork() %
query_.get_top_confirmed() %
Expand Down Expand Up @@ -2574,6 +2577,7 @@ bool executor::do_run()
query_.spend_records() %
query_.strong_tx_records() %
query_.address_records());
logger(BN_MEASURE_PROGRESS_START);
logger(format(BN_MEASURE_PROGRESS) %
query_.get_fork() %
query_.get_top_confirmed() %
Expand Down
3 changes: 2 additions & 1 deletion console/localize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ namespace node {
" valid_bk :%8%\n" \
" address :%9%\n" \
" neutrino :%10%"
#define BN_MEASURE_PROGRESS_START \
"Progress..."
#define BN_MEASURE_PROGRESS \
"Progress...\n" \
" fork pt :%1%\n" \
" top conf :%2%:%3%\n" \
" top cand :%4%:%5%\n" \
Expand Down
40 changes: 40 additions & 0 deletions include/bitcoin/node/impl/chasers/chaser_organize.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
{
if (!query.pop_candidate())
{
if (query.is_full())
{
handler(database::error::disk_full, height);
fault(database::error::disk_full);
return;
}

handler(error::store_integrity, height);
fault(error::store_integrity);
return;
Expand All @@ -290,6 +297,13 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
{
if (!query.push_candidate(link))
{
if (query.is_full())
{
handler(database::error::disk_full, height);
fault(database::error::disk_full);
return;
}

handler(error::store_integrity, height);
fault(error::store_integrity);
return;
Expand All @@ -303,6 +317,13 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
{
if (!push(key))
{
if (query.is_full())
{
handler(database::error::disk_full, height);
fault(database::error::disk_full);
return;
}

handler(error::store_integrity, height);
fault(error::store_integrity);
return;
Expand All @@ -316,6 +337,13 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
{
if (push(block, state->context()).is_terminal())
{
if (query.is_full())
{
handler(database::error::disk_full, height);
fault(database::error::disk_full);
return;
}

handler(error::store_integrity, height);
fault(error::store_integrity);
return;
Expand Down Expand Up @@ -422,6 +450,12 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
{
if (!query.pop_candidate())
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -437,6 +471,12 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
{
if (!query.push_candidate(query.to_confirmed(index)))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/chasers/chaser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ chaser::chaser(full_node& node) NOEXCEPT

void chaser::fault(const code& ec) const NOEXCEPT
{
LOGF("Detected fault: " << ec.message());
notify(ec, chase::stop, {});
LOGF("Fault: " << ec.message());
notify(error::success, chase::stop, ec.value());
}

bool chaser::closed() const NOEXCEPT
Expand Down
11 changes: 7 additions & 4 deletions src/chasers/chaser_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

namespace libbitcoin {
namespace node {


using namespace system;
using namespace system::chain;

chaser_block::chaser_block(full_node& node) NOEXCEPT
Expand Down Expand Up @@ -105,10 +106,12 @@ bool chaser_block::is_storable(const block&, const chain_state&) const NOEXCEPT
database::header_link chaser_block::push(const block& block,
const context& context) const NOEXCEPT
{
using namespace system;
auto& query = archive();
const auto link = chaser_organize<chain::block>::push(block, context);
return archive().set_block_confirmable(link, block.fees()) ? link :
database::header_link{};
if (!query.set_block_confirmable(link, block.fees()))
return {};

return link;
}

void chaser_block::set_prevout(const input& input) const NOEXCEPT
Expand Down
15 changes: 13 additions & 2 deletions src/chasers/chaser_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,19 @@ void chaser_check::do_malleated(header_t link) NOEXCEPT
auto& query = archive();

association out{};
if (!query.dissasociate(link) ||
!query.get_unassociated(out, link))
if (!query.set_dissasociated(link))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}

if (!query.get_unassociated(out, link))
{
fault(error::store_integrity);
return;
Expand Down
52 changes: 50 additions & 2 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,24 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
while (index > fork_point)
{
popped.push_back(query.to_confirmed(index));
if (popped.back().is_terminal() || !query.pop_confirmed())
if (popped.back().is_terminal())
{
fault(error::store_integrity);
return;
}

if (!query.pop_confirmed())
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}

notify(error::success, chase::reorganized, popped.back());
fire(events::block_reorganized, index--);
}
Expand Down Expand Up @@ -166,15 +178,27 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
// chase::organized & events::block_organized
if (!set_confirmed(link, index++))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}

continue;
}

if (code == error::store_integrity)
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -190,6 +214,12 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
if (code != database::error::block_unconfirmable &&
!query.set_block_unconfirmable(link))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -203,6 +233,12 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
// chase::organized & events::block_organized
if (!roll_back(popped, fork_point, sub1(index)))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -217,6 +253,12 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
// TODO: compute fees from validation records (optional metadata).
if (!query.set_block_confirmable(link, uint64_t{}))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -230,6 +272,12 @@ void chaser_confirm::do_preconfirmed(height_t height) NOEXCEPT
// chase::organized & events::block_organized
if (!set_confirmed(link, index++))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand Down
21 changes: 21 additions & 0 deletions src/chasers/chaser_preconfirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ void chaser_preconfirm::do_bump(height_t) NOEXCEPT

if (code == error::store_integrity)
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -169,6 +175,12 @@ void chaser_preconfirm::do_bump(height_t) NOEXCEPT
if (code != database::error::block_unconfirmable &&
!query.set_block_unconfirmable(link))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand All @@ -191,6 +203,12 @@ void chaser_preconfirm::do_bump(height_t) NOEXCEPT
if (!query.set_txs_connected(link) ||
!query.set_block_preconfirmable(link))
{
if (query.is_full())
{
fault(database::error::disk_full);
return;
}

fault(error::store_integrity);
return;
}
Expand Down Expand Up @@ -244,6 +262,7 @@ code chaser_preconfirm::validate(const header_link& link,
if ((ec = block.connect(ctx)))
return ec;

// This can only fail if block missing or prevouts are not fully populated.
return update_neutrino(link, block) ? ec : error::store_integrity;
}

Expand All @@ -267,6 +286,7 @@ hash_digest chaser_preconfirm::get_neutrino(size_t height) const NOEXCEPT
return neutrino;
}

// This can only fail if block missing or prevouts are not fully populated.
bool chaser_preconfirm::update_neutrino(const header_link& link) NOEXCEPT
{
const auto& query = archive();
Expand All @@ -281,6 +301,7 @@ bool chaser_preconfirm::update_neutrino(const header_link& link) NOEXCEPT
return query.populate(block) && update_neutrino(link, block);
}

// This can only fail if prevouts are not fully populated.
bool chaser_preconfirm::update_neutrino(const header_link& link,
const chain::block& block) NOEXCEPT
{
Expand Down
3 changes: 2 additions & 1 deletion src/full_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ void full_node::close() NOEXCEPT
void full_node::do_close() NOEXCEPT
{
BC_ASSERT(stranded());
event_subscriber_.stop(network::error::service_stopped, chase::stop, zero);
event_subscriber_.stop(network::error::service_stopped, chase::stop,
error::success);
p2p::do_close();
}

Expand Down
Loading

0 comments on commit 2576c98

Please sign in to comment.