From 9440ae84cb34304a75a90ad9f241cff2bef43b6e Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 1 Jun 2024 11:08:45 -0400 Subject: [PATCH 1/3] Fix unused write_test() loop condition. --- console/executor.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/console/executor.cpp b/console/executor.cpp index e06acaf9..48991e64 100644 --- a/console/executor.cpp +++ b/console/executor.cpp @@ -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); @@ -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()); @@ -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(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() From 986fd43572a8e733fbdb6d77263a0f1cf0e8a0b3 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 1 Jun 2024 11:35:32 -0400 Subject: [PATCH 2/3] Hardwired block.check(bypass) and set(txs, bypass). --- .../node/protocols/protocol_block_in_31800.hpp | 2 +- src/protocols/protocol_block_in_31800.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp index 774ac7cb..4cd0f980 100644 --- a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp +++ b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp @@ -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( diff --git a/src/protocols/protocol_block_in_31800.cpp b/src/protocols/protocol_block_in_31800.cpp index a7f8d33c..48b22785 100644 --- a/src/protocols/protocol_block_in_31800.cpp +++ b/src/protocols/protocol_block_in_31800.cpp @@ -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. @@ -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() << "] " @@ -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 From 61919380ef6403d2e17f21432e311023d1faf553 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 1 Jun 2024 11:35:50 -0400 Subject: [PATCH 3/3] Temporary delint. --- src/chasers/chaser_validate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chasers/chaser_validate.cpp b/src/chasers/chaser_validate.cpp index 4c5eab9d..fbc1b592 100644 --- a/src/chasers/chaser_validate.cpp +++ b/src/chasers/chaser_validate.cpp @@ -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;