mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
kernel: De-globalize signature cache
Move its ownership to the ChainstateManager class. Next to simplifying usage of the kernel library by no longer requiring manual setup of the cache prior to using validation code, it also slims down the amount of memory allocated by BasicTestingSetup. Use this opportunity to make SignatureCache RAII styled Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -1526,7 +1526,7 @@ static std::vector<unsigned int> AllConsensusFlags()
|
||||
/** Precomputed list of all valid combinations of consensus-relevant script validation flags. */
|
||||
static const std::vector<unsigned int> ALL_CONSENSUS_FLAGS = AllConsensusFlags();
|
||||
|
||||
static void AssetTest(const UniValue& test)
|
||||
static void AssetTest(const UniValue& test, SignatureCache& signature_cache)
|
||||
{
|
||||
BOOST_CHECK(test.isObject());
|
||||
|
||||
@@ -1543,7 +1543,7 @@ static void AssetTest(const UniValue& test)
|
||||
CTransaction tx(mtx);
|
||||
PrecomputedTransactionData txdata;
|
||||
txdata.Init(tx, std::vector<CTxOut>(prevouts));
|
||||
CachingTransactionSignatureChecker txcheck(&tx, idx, prevouts[idx].nValue, true, txdata);
|
||||
CachingTransactionSignatureChecker txcheck(&tx, idx, prevouts[idx].nValue, true, signature_cache, txdata);
|
||||
|
||||
for (const auto flags : ALL_CONSENSUS_FLAGS) {
|
||||
// "final": true tests are valid for all flags. Others are only valid with flags that are
|
||||
@@ -1561,7 +1561,7 @@ static void AssetTest(const UniValue& test)
|
||||
CTransaction tx(mtx);
|
||||
PrecomputedTransactionData txdata;
|
||||
txdata.Init(tx, std::vector<CTxOut>(prevouts));
|
||||
CachingTransactionSignatureChecker txcheck(&tx, idx, prevouts[idx].nValue, true, txdata);
|
||||
CachingTransactionSignatureChecker txcheck(&tx, idx, prevouts[idx].nValue, true, signature_cache, txdata);
|
||||
|
||||
for (const auto flags : ALL_CONSENSUS_FLAGS) {
|
||||
// If a test is supposed to fail with test_flags, it should also fail with any superset thereof.
|
||||
@@ -1577,6 +1577,7 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
|
||||
{
|
||||
// See src/test/fuzz/script_assets_test_minimizer.cpp for information on how to generate
|
||||
// the script_assets_test.json file used by this test.
|
||||
SignatureCache signature_cache{DEFAULT_SIGNATURE_CACHE_BYTES};
|
||||
|
||||
const char* dir = std::getenv("DIR_UNIT_TEST_DATA");
|
||||
BOOST_WARN_MESSAGE(dir != nullptr, "Variable DIR_UNIT_TEST_DATA unset, skipping script_assets_test");
|
||||
@@ -1597,7 +1598,7 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
|
||||
BOOST_CHECK(tests.size() > 0);
|
||||
|
||||
for (size_t i = 0; i < tests.size(); i++) {
|
||||
AssetTest(tests[i]);
|
||||
AssetTest(tests[i], signature_cache);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user