diff --git a/src/script/script.h b/src/script/script.h index cd19f09436f..b556aae6060 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -403,10 +403,8 @@ private: /** * We use a prevector for the script to reduce the considerable memory overhead * of vectors in cases where they normally contain a small number of small elements. - * Tests in October 2015 showed use of this reduced dbcache memory usage by 23% - * and made an initial sync 13% faster. */ -using CScriptBase = prevector<28, uint8_t>; +using CScriptBase = prevector<36, uint8_t>; bool GetScriptOp(CScriptBase::const_iterator& pc, CScriptBase::const_iterator end, opcodetype& opcodeRet, std::vector* pvchRet); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index d5b0dfab189..5d7593020b4 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -1175,10 +1175,10 @@ static TxoutType GetTxoutType(const CScript& output_script) BOOST_AUTO_TEST_CASE(script_size_and_capacity_test) { BOOST_CHECK_EQUAL(sizeof(CompressedScript), 40); - BOOST_CHECK_EQUAL(sizeof(CScriptBase), 32); + BOOST_CHECK_EQUAL(sizeof(CScriptBase), 40); BOOST_CHECK_NE(sizeof(CScriptBase), sizeof(prevector)); // CScriptBase size should be set to avoid wasting space in padding - BOOST_CHECK_EQUAL(sizeof(CScript), 32); - BOOST_CHECK_EQUAL(sizeof(CTxOut), 40); + BOOST_CHECK_EQUAL(sizeof(CScript), 40); + BOOST_CHECK_EQUAL(sizeof(CTxOut), 48); CKey dummy_key; dummy_key.MakeNewKey(/*fCompressed=*/true); @@ -1212,25 +1212,25 @@ BOOST_AUTO_TEST_CASE(script_size_and_capacity_test) CHECK_SCRIPT_STATIC_SIZE(script, 25); } - // P2WSH needs extra allocation + // P2WSH has direct allocation { const auto script{GetScriptForDestination(WitnessV0ScriptHash{CScript{} << OP_TRUE})}; BOOST_CHECK(script.IsPayToWitnessScriptHash()); - CHECK_SCRIPT_DYNAMIC_SIZE(script, 34, 34); + CHECK_SCRIPT_STATIC_SIZE(script, 34); } - // P2TR needs extra allocation + // P2TR has direct allocation { const auto script{GetScriptForDestination(WitnessV1Taproot{XOnlyPubKey{dummy_pubkey}})}; BOOST_CHECK_EQUAL(GetTxoutType(script), TxoutType::WITNESS_V1_TAPROOT); - CHECK_SCRIPT_DYNAMIC_SIZE(script, 34, 34); + CHECK_SCRIPT_STATIC_SIZE(script, 34); } - // Compressed P2PK needs extra allocation + // Compressed P2PK has direct allocation { const auto script{GetScriptForRawPubKey(dummy_pubkey)}; BOOST_CHECK_EQUAL(GetTxoutType(script), TxoutType::PUBKEY); - CHECK_SCRIPT_DYNAMIC_SIZE(script, 35, 35); + CHECK_SCRIPT_STATIC_SIZE(script, 35); } // Uncompressed P2PK needs extra allocation diff --git a/src/test/validation_flush_tests.cpp b/src/test/validation_flush_tests.cpp index c325f7deb2b..4d6017a0e30 100644 --- a/src/test/validation_flush_tests.cpp +++ b/src/test/validation_flush_tests.cpp @@ -26,9 +26,8 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate) LOCK(::cs_main); auto& view = chainstate.CoinsTip(); - // The number of bytes consumed by coin's heap data, i.e. CScript - // (prevector<28, unsigned char>) when assigned 56 bytes of data per above. - // + // The number of bytes consumed by coin's heap data, i.e. + // CScript (prevector<36, unsigned char>) when assigned 56 bytes of data per above. // See also: Coin::DynamicMemoryUsage(). constexpr unsigned int COIN_SIZE = is_64_bit ? 80 : 64;