File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ namespace node {
1414
1515// ! Default reserved weight for block assembly scaffolding (header, coinbase, etc).
1616static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000 };
17+ // ! Minimum reserved weight enforced by block assembly.
18+ static constexpr size_t MIN_BLOCK_RESERVED_WEIGHT{2000 };
1719
1820struct BlockCreateOptions {
1921 /* * Set false to omit mempool transactions from templates. */
Original file line number Diff line number Diff line change @@ -266,14 +266,13 @@ void Sv2TemplateProvider::ThreadSv2ClientHandler(size_t client_id)
266266 const size_t block_reserved_floor{1168 };
267267 // Reserve a little more so that if the above calculation is
268268 // wrong or there's an implementation error, we don't produce
269- // an invalid bock when the template is completely full.
269+ // an invalid block when the template is completely full.
270270 const size_t block_reserved_padding{400 };
271271
272- // Bitcoin Core enforces a mimimum block reserved weight of 2000.
273- options.block_reserved_weight = std::min (size_t (2000 ),
274- block_reserved_floor +
275- block_reserved_padding +
276- client->m_coinbase_tx_outputs_size * 4 );
272+ // Bitcoin Core enforces a minimum block reserved weight of 2000.
273+ options.block_reserved_weight = std::max (
274+ node::MIN_BLOCK_RESERVED_WEIGHT,
275+ block_reserved_floor + block_reserved_padding + client->m_coinbase_tx_outputs_size * 4 );
277276 }
278277 return true ;
279278 };
Original file line number Diff line number Diff line change 11#include < boost/test/unit_test.hpp>
22#include < interfaces/mining.h>
3+ #include < sv2/block_options.h>
34#include < interfaces/init.h>
45#include < sv2/messages.h>
56#include < test/sv2_test_setup.h>
1617#include < test/sv2_mock_mining.h>
1718
1819#include < future>
20+ #include < algorithm>
1921#include < memory>
2022#include < string>
2123#include < thread>
2729
2830BOOST_FIXTURE_TEST_SUITE (sv2_template_provider_tests, Sv2BasicTestingSetup)
2931
32+ BOOST_AUTO_TEST_CASE(block_reserved_weight_floor)
33+ {
34+ node::BlockCreateOptions options{};
35+ // Guard against regressions where the reserved weight floor is treated as a cap.
36+ options.block_reserved_weight = 1800 ;
37+ options.block_reserved_weight = std::max (node::MIN_BLOCK_RESERVED_WEIGHT, options.block_reserved_weight );
38+ BOOST_REQUIRE_EQUAL (options.block_reserved_weight , node::MIN_BLOCK_RESERVED_WEIGHT);
39+ }
40+
3041BOOST_AUTO_TEST_CASE (client_tests)
3142{
3243 TPTester tester{};
You can’t perform that action at this time.
0 commit comments