Skip to content

Commit

Permalink
Merge pull request #635 from evoskuil/master
Browse files Browse the repository at this point in the history
Disable address/neutrino tables by default, fix dangling pointer.
  • Loading branch information
evoskuil committed May 31, 2024
2 parents 368702e + 44f2518 commit 5865b75
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 69 deletions.
76 changes: 39 additions & 37 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,39 +740,6 @@ void executor::scan_collisions() const
//// logger("No read test implemented.");
////}

#if defined(UNDEFINED)

void executor::read_test() const
{
logger("Wire size computation.");
const auto start = fine_clock::now();
constexpr auto last = 500'000_size;

size_t size{};
for (auto height = zero; !cancel_ && height <= last; ++height)
{
const auto link = query_.to_candidate(height);
if (link.is_terminal())
{
logger(format("Max candidate height is (%1%).") % sub1(height));
return;
}

const auto bytes = query_.get_block_size(link);
if (is_zero(bytes))
{
logger(format("Block (%1%) is not associated.") % height);
return;
}

size += bytes;
}

const auto span = duration_cast<milliseconds>(fine_clock::now() - start);
logger(format("Wire size (%1%) at (%2%) in (%3%) ms.") %
size % last % span.count());
}

void executor::read_test() const
{
constexpr auto start_tx = 15'000_u32;
Expand Down Expand Up @@ -906,7 +873,7 @@ void executor::read_test() const
null_hash,
max_uint32, // height

nullptr,
nullptr, //query_.get_output(out_fk),
nullptr
});
continue;
Expand Down Expand Up @@ -1005,6 +972,7 @@ void executor::read_test() const
logger(format("Got all [%1%] payments to [%2%] addresses in [%3%] ms.") %
outs.size() % keys.size() % span.count());

// Write it all...
////logger(
//// "output_script_hash, "
//// "output_fk, "
Expand Down Expand Up @@ -1068,6 +1036,39 @@ void executor::read_test() const
////}
}

#if defined(UNDEFINED)

void executor::read_test() const
{
logger("Wire size computation.");
const auto start = fine_clock::now();
constexpr auto last = 500'000_size;

size_t size{};
for (auto height = zero; !cancel_ && height <= last; ++height)
{
const auto link = query_.to_candidate(height);
if (link.is_terminal())
{
logger(format("Max candidate height is (%1%).") % sub1(height));
return;
}

const auto bytes = query_.get_block_size(link);
if (is_zero(bytes))
{
logger(format("Block (%1%) is not associated.") % height);
return;
}

size += bytes;
}

const auto span = duration_cast<milliseconds>(fine_clock::now() - start);
logger(format("Wire size (%1%) at (%2%) in (%3%) ms.") %
size % last % span.count());
}

void executor::read_test() const
{
// Binance wallet address with 1,380,169 transaction count.
Expand Down Expand Up @@ -1508,8 +1509,6 @@ void executor::read_test() const
logger(format("STOP (%1% secs)") % span.count());
}

#endif // UNDEFINED

// TODO: create a block/tx dumper.
void executor::read_test() const
{
Expand All @@ -1530,6 +1529,7 @@ void executor::read_test() const
logger("!block");
return;
}

if (!block->is_valid())
{
logger("!block->is_valid()");
Expand Down Expand Up @@ -1586,6 +1586,8 @@ void executor::read_test() const
logger(format("Validated block 523354 in %1% msec.") % span.count());
}

#endif // UNDEFINED

// arbitrary testing (non-const).
void executor::write_test()
{
Expand Down Expand Up @@ -2379,7 +2381,7 @@ bool executor::dispatch()
// Run.
// ----------------------------------------------------------------------------

// TODO: verify error handled.
// TODO: verify construction failure handled.
executor::rotator_t executor::create_log_sink() const
{
return
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class BCN_API chaser_validate
virtual void do_checked(height_t height) NOEXCEPT;
virtual void do_bump(height_t height) NOEXCEPT;

////#if defined(UNDEFINED)
virtual bool enqueue_block(const database::header_link& link) NOEXCEPT;
virtual void validate_tx(const database::context& context,
const database::tx_link& link, const race::ptr& racer) NOEXCEPT;
Expand All @@ -62,10 +61,11 @@ class BCN_API chaser_validate
virtual void validate_block(const code& ec,
const database::header_link& link,
const database::context& ctx) NOEXCEPT;
////#endif // UNDEFINED

private:
#if defined (UNDEFINED)
code validate(const database::header_link& link, size_t height) NOEXCEPT;
#endif // UNDEFINED

// neutrino
system::hash_digest get_neutrino(size_t height) const NOEXCEPT;
Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/node/impl/chasers/chaser_organize.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
return;
}

fire(events::header_organized, index++);
////fire(events::header_organized, index++);
}

// Store strong tree headers and push to candidate chain.
Expand All @@ -314,8 +314,8 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
return;
}

fire(events::header_archived, index);
fire(events::header_organized, index++);
////fire(events::header_archived, index);
////fire(events::header_organized, index++);
}

// Push new header as top of candidate chain.
Expand All @@ -326,8 +326,8 @@ void CLASS::do_organize(typename Block::cptr& block_ptr,
return;
}

fire(events::header_archived, index);
fire(events::header_organized, index++);
////fire(events::header_archived, index);
////fire(events::header_organized, index++);
}

// Reset top chain state cache and notify.
Expand Down
13 changes: 1 addition & 12 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT
: chaser(node),
initial_subsidy_(node.config().bitcoin.initial_subsidy()),
subsidy_interval_blocks_(node.config().bitcoin.subsidy_interval_blocks),
threadpool_(std::min(node.config().node.threads, 1_u32))
threadpool_(std::max(node.config().node.threads, 1_u32))
{
}

Expand Down Expand Up @@ -263,8 +263,6 @@ void chaser_validate::do_bump(height_t) NOEXCEPT
}
}

////#if defined(UNDEFINED)

// DISTRUBUTE WORK
bool chaser_validate::enqueue_block(const header_link& link) NOEXCEPT
{
Expand Down Expand Up @@ -405,12 +403,6 @@ void chaser_validate::handle_txs(const code& ec, const tx_link& tx,
LOG_ONLY(const auto hash = encode_hash(archive().get_tx_key(tx));)
LOGR("Error validating tx [" << hash << "] " << ec.message());
}
else
{
// Don't log tx here as it's just the last successful one.
LOG_ONLY(const auto hash = encode_hash(archive().get_header_key(link));)
////LOGV("Validated transactions from block [" << hash << "].");
}

validate_block(ec, link, ctx);
}
Expand All @@ -437,8 +429,6 @@ void chaser_validate::validate_block(const code& ec,
notify(ec, chase::valid, ctx.height);
}

////#endif // UNDEFINED

#if defined (UNDEFINED)
code chaser_validate::validate(const header_link& link,
size_t height) NOEXCEPT
Expand Down Expand Up @@ -483,7 +473,6 @@ code chaser_validate::validate(const header_link& link,
// This can only fail if block missing or prevouts are not fully populated.
return update_neutrino(link, block) ? ec : error::store_integrity;
}

#endif // UNDEFINED

// neutrino
Expand Down
20 changes: 10 additions & 10 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ parser::parser(system::chain::selection context) NOEXCEPT

// optional

configured.database.address_buckets = 1'459'791'875;
configured.database.address_size = 29'390'853'398;
configured.database.address_buckets = 0;
configured.database.address_size = 1;
configured.database.address_rate = 5;

configured.database.neutrino_buckets = 524'493;
configured.database.neutrino_size = 2'656'071'402;
configured.database.neutrino_buckets = 0;
configured.database.neutrino_size = 1;
configured.database.neutrino_rate = 5;

////configured.database.buffer_buckets = 100;
Expand Down Expand Up @@ -851,34 +851,34 @@ options_metadata parser::load_settings() THROWS
(
"database.address_buckets",
value<uint32_t>(&configured.database.address_buckets),
"The number of buckets in the address table head, defaults to '1459791875' (0 disables)."
"The number of buckets in the address table head, defaults to '0' (0 disables)."
)
(
"database.address_size",
value<uint64_t>(&configured.database.address_size),
"The minimum allocation of the address table body, defaults to '29390853398'."
"The minimum allocation of the address table body, defaults to '1'."
)
(
"database.address_rate",
value<uint16_t>(&configured.database.address_rate),
"The percentage expansion of the address table body, defaults to '5'."
"The percentage expansion of the address table body, defaults to '0'."
)

/* neutrino */
(
"database.neutrino_buckets",
value<uint32_t>(&configured.database.neutrino_buckets),
"The number of buckets in the neutrino table head, defaults to '524493' (0 disables)."
"The number of buckets in the neutrino table head, defaults to '0' (0 disables)."
)
(
"database.neutrino_size",
value<uint64_t>(&configured.database.neutrino_size),
"The minimum allocation of the neutrino table body, defaults to '2656071402'."
"The minimum allocation of the neutrino table body, defaults to '1'."
)
(
"database.neutrino_rate",
value<uint16_t>(&configured.database.neutrino_rate),
"The percentage expansion of the neutrino table body, defaults to '5'."
"The percentage expansion of the neutrino table body, defaults to '0'."
)

/* [node] */
Expand Down
8 changes: 5 additions & 3 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,12 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
// Commit block.txs.
// ........................................................................

const auto size = block_ptr->serialized_size(true);
const auto& txs_ptr = block_ptr->transactions_ptr();
const auto txs_ptr = block_ptr->transactions_ptr();
const auto block_size = block_ptr->serialized_size(true);

if (const auto code = query.set_code(*txs_ptr, link, size))
// block_ptr goes out of scope here, even if a reference is held to its
// transactions_ptr, so txs_ptr must be a pointer copy.
if (const auto code = query.set_code(*txs_ptr, link, block_size))
{
LOGF("Failure storing block [" << encode_hash(hash) << ":"
<< ctx.height << "] from [" << authority() << "] "
Expand Down

0 comments on commit 5865b75

Please sign in to comment.