Skip to content

Commit

Permalink
Merge pull request #636 from evoskuil/master
Browse files Browse the repository at this point in the history
Hardwired block.check(bypass) and set(txs, bypass).
  • Loading branch information
evoskuil committed Jun 2, 2024
2 parents 5865b75 + 6191938 commit 4e4da01
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
20 changes: 6 additions & 14 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,18 +1602,10 @@ void executor::write_test()
size_t count{};
const auto start = fine_clock::now();

////// This tx in block 840161 is not strong by block 840112 (weak prevout).
////const auto tx = "865d721037b0c995822367c41875593d7093d1bae412f3861ce471de3c07e180";
////const auto block = "00000000000000000002504eefed4dc72956aa941aa7b6defe893e261de6a636";
////const auto hash = system::base16_hash(block);
////if (!query_.push_candidate(query_.to_header(hash)))
////{
//// logger(format("!query_.push_candidate(query_.to_header(hash))"));
//// return;
////}
const auto fork = query_.get_fork();
const auto top_associated = query_.get_top_associated_from(fork);

for (size_t height = query_.get_fork();
!cancel_ && !ec && height <= query_.get_top_associated_from(height);
for (auto height = fork; !cancel_ && !ec && height <= top_associated;
++height, ++count)
{
const auto block = query_.to_candidate(height);
Expand All @@ -1623,7 +1615,6 @@ void executor::write_test()
return;
}

////if (height > 804'000_size)
////if (ec = query_.block_confirmable(block))
////{
//// logger(format("block_confirmable [%1%] fault (%2%).") % height % ec.message());
Expand All @@ -1642,12 +1633,13 @@ void executor::write_test()
return;
}

if (is_zero(height % 100_size))
if (is_zero(height % 1000_size))
logger(format("write_test [%1%].") % height);
}

const auto span = duration_cast<seconds>(fine_clock::now() - start);
logger(format("%1% blocks in %2% secs.") % count % span.count());
logger(format("Set confirmation of %1% blocks in %2% secs.") % count %
span.count());
}

void executor::write_test()
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/protocols/protocol_block_in_31800.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class BCN_API protocol_block_in_31800
using type_id = network::messages::inventory::type_id;

code check(const system::chain::block& block,
const system::chain::context& ctx) const NOEXCEPT;
const system::chain::context& ctx, bool bypass) const NOEXCEPT;

void send_get_data(const map_ptr& map) NOEXCEPT;
network::messages::get_data create_get_data(
Expand Down
2 changes: 1 addition & 1 deletion src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ code chaser_validate::start() NOEXCEPT
}

bool chaser_validate::handle_event(const code&, chase event_,
event_value value) NOEXCEPT
event_value) NOEXCEPT
{
if (closed())
return false;
Expand Down
14 changes: 8 additions & 6 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
// Check block.
// ........................................................................

if (const auto code = check(*block_ptr, ctx))
// Hack to measure performance with cached bypass point.
constexpr auto bypass = true;

if (const auto code = check(*block_ptr, ctx, bypass))
{
// Both forms of malleabilty are possible here.
// Malleable has not been associated, so just drop peer and continue.
Expand Down Expand Up @@ -339,7 +342,7 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,

// 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))
if (const auto code = query.set_code(*txs_ptr, link, block_size, bypass))
{
LOGF("Failure storing block [" << encode_hash(hash) << ":"
<< ctx.height << "] from [" << authority() << "] "
Expand All @@ -366,13 +369,12 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
return true;
}

// Transaction commitments are required under checkpoint/milestone, and other
// checks are comparable to the bypass condition cost, so just do them.
// Transaction/witness commitments are required under checkpoint/milestone.
code protocol_block_in_31800::check(const chain::block& block,
const chain::context& ctx) const NOEXCEPT
const chain::context& ctx, bool bypass) const NOEXCEPT
{
code ec{};
return ec = block.check() ? ec : block.check(ctx);
return ec = block.check(bypass) ? ec : block.check(ctx, bypass);
}

// get/put hashes
Expand Down

0 comments on commit 4e4da01

Please sign in to comment.