diff --git a/.github/actions/clear-files/action.yml b/.github/actions/clear-files/action.yml new file mode 100644 index 000000000000..0008f825ff0d --- /dev/null +++ b/.github/actions/clear-files/action.yml @@ -0,0 +1,12 @@ +name: 'Clear unnecessary files' +description: 'Clear out unnecessary files to make space on the VM' +runs: + using: 'composite' + steps: + - name: Clear unnecessary files + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + run: | + set +o errexit + sudo bash -c '(ionice -c 3 nice -n 19 rm -rf /usr/share/dotnet/ /usr/local/graalvm/ /usr/local/.ghcup/ /usr/local/share/powershell /usr/local/share/chromium /usr/local/lib/android /usr/local/lib/node_modules)&' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cac4eab0b31..573e18ef0949 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -291,6 +291,10 @@ jobs: key: ${{ github.job }}-ccache-${{ github.run_id }} restore-keys: ${{ github.job }}-ccache- + - name: Clear unnecessary files + if: ${{ needs.runners.outputs.provider == 'gha' && true || false }} # Only needed on GHA runners + uses: ./.github/actions/clear-files + - name: Enable bpfcc script # In the image build step, no external environment variables are available, # so any settings will need to be written to the settings env file: diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp index ae76050c300c..8a0c4531a9b9 100644 --- a/src/bitcoin-util.cpp +++ b/src/bitcoin-util.cpp @@ -257,7 +257,7 @@ static int EvalScript(const ArgsManager& argsman, const std::vector for (size_t i = 1; i < args.size(); ++i) { if (args[i].size() == 0) { - stack.push_back({}); + stack.emplace_back(); } else if (IsHex(args[i])) { stack.push_back(ParseHex(args[i])); } else { diff --git a/src/init.cpp b/src/init.cpp index 780c4839d7f8..81112f49165f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1554,7 +1554,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // sanitize comments per BIP-0014, format user agent and check total size std::vector uacomments; if (!args.IsArgSet("-uacomment") && !args.IsArgNegated("-uacomment")) { - uacomments.push_back("inquisition"); + uacomments.emplace_back("inquisition"); } for (const std::string& cmt : args.GetArgs("-uacomment")) { if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) diff --git a/src/test/bip54_tests.cpp b/src/test/bip54_tests.cpp index 874c146888e4..2cc103444ca0 100644 --- a/src/test/bip54_tests.cpp +++ b/src/test/bip54_tests.cpp @@ -110,11 +110,11 @@ static std::vector SignInput(const CKey& key, const CScript& spent_scri } /** Verify a transaction input's script against consensus rules. */ -static bool VerifyTxin(const CScript& spent_script, const CMutableTransaction& tx, unsigned idx, std::vector&& spent_outputs, const CAmount& amount) +static bool VerifyTxin(const CScript& spent_script, const CMutableTransaction& tx, unsigned idx, std::vector spent_outputs, const CAmount& amount) { Assert(idx < tx.vin.size()); PrecomputedTransactionData txdata; - txdata.Init(tx, std::forward>(spent_outputs), /*force=*/true); + txdata.Init(tx, std::move(spent_outputs), /*force=*/true); const MutableTransactionSignatureChecker checker{&tx, idx, amount, txdata, MissingDataBehavior::ASSERT_FAIL}; return VerifyScript(tx.vin[idx].scriptSig, spent_script, &tx.vin[idx].scriptWitness, MANDATORY_SCRIPT_VERIFY_FLAGS, checker); } @@ -1019,7 +1019,7 @@ BOOST_AUTO_TEST_CASE(bip54_legacy_sigops) sigdata.tr_spenddata = builder.GetSpendData(); auto spent_outputs{RecordSpent(coins, tx_copy2)}; Assert(SignSignature(keystore, spk, tx_copy2, idx, value, std::vector(spent_outputs), SIGHASH_ALL, sigdata)); - BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, std::move(spent_outputs), value)); + BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, spent_outputs, value)); CheckWithinBIP54Limits(CTransaction(tx_copy2), coins, test_vectors, "Mixed input types reaching exactly 2500 BIP54-sigops + a Taproot key path spend input"); } @@ -1055,7 +1055,7 @@ BOOST_AUTO_TEST_CASE(bip54_legacy_sigops) keystore.keys[pubkey.GetID()] = privkey; sigdata.tr_spenddata = builder.GetSpendData(); Assert(SignSignature(keystore, spk, tx_copy2, idx, value, std::vector(spent_outputs), SIGHASH_ALL, sigdata)); - BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, std::vector(spent_outputs), value)); + BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, spent_outputs, value)); CheckWithinBIP54Limits(CTransaction(tx_copy2), coins, test_vectors, "Mixed input types reaching exactly 2500 BIP54-sigops + a Taproot script path spend input"); // Spend through the future-version leaf. @@ -1063,7 +1063,7 @@ BOOST_AUTO_TEST_CASE(bip54_legacy_sigops) keystore.keys[pubkey_future.GetID()] = privkey_future; sigdata.tr_spenddata = builder.GetSpendData(); Assert(SignSignature(keystore, spk, tx_copy2, idx, value, std::vector(spent_outputs), SIGHASH_ALL, sigdata)); - BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, std::move(spent_outputs), value)); + BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx, spent_outputs, value)); CheckWithinBIP54Limits(CTransaction(tx_copy2), coins, test_vectors, "Mixed input types reaching exactly 2500 BIP54-sigops + a Taproot script path spend input of a future leaf version"); } @@ -1343,6 +1343,7 @@ struct TimestampTestCase { * The BIP 54 timestamp test vectors are arranged as a tree. This recursively build a list of * header-chain test cases from the root of the JSON test vectors. */ +// NOLINTNEXTLINE(misc-no-recursion) static std::vector VisitNode(std::vector header_chain, const UniValue& test_node) { std::vector test_cases; @@ -1441,7 +1442,7 @@ BOOST_AUTO_TEST_CASE(bip54_coinbase) { auto test_setup{TestingSetup{ChainType::MAIN, {.extra_args = {"-vbparams=consensuscleanup:-1:-1"}}}}; BlockValidationState state; - BOOST_CHECK_MESSAGE(AcceptBlocks(*test_setup.m_node.chainman, std::move(blocks), state) == is_valid, comment); + BOOST_CHECK_MESSAGE(AcceptBlocks(*test_setup.m_node.chainman, blocks, state) == is_valid, comment); if (!is_valid) { const auto reason{state.GetRejectReason()}; BOOST_CHECK_MESSAGE(reason == "bad-cb-locktime" || reason == "bad-cb-sequence" || reason == "bad-txns-nonfinal", comment); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 0846122e6cc4..feaf56bacb4f 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -939,7 +939,7 @@ BOOST_AUTO_TEST_CASE(script_json_test) // We use #SCRIPT# to flag a non-hex script that we can read using ParseScript // Taproot script must be third from the last element in witness stack std::string scriptFlag = std::string("#SCRIPT#"); - if (element.find(scriptFlag) == 0) { + if (element.starts_with(scriptFlag)) { CScript script = ParseScript(element.substr(scriptFlag.size())); witness.stack.push_back(ToByteVector(script)); } else if (strcmp(element.c_str(), "#CONTROLBLOCK#") == 0) { @@ -1801,8 +1801,8 @@ BOOST_AUTO_TEST_CASE(cat_empty_stack) { // Ensures that OP_CAT successfully handles concatenating two empty stack elements std::vector> witData; - witData.push_back({}); - witData.push_back({}); + witData.emplace_back(); + witData.emplace_back(); std::vector witVerifyScript = {OP_CAT, OP_PUSHDATA1, 0x00,OP_EQUAL}; DoTapscriptTest(*this, witVerifyScript, witData, "CAT empty stack", SCRIPT_ERR_OK); } @@ -1816,7 +1816,7 @@ BOOST_AUTO_TEST_CASE(cat_dup_test) unsigned int maxDupsToCheck = 10; std::vector> witData; - witData.push_back({}); + witData.emplace_back(); for (unsigned int elementSize = 1; elementSize <= maxElementSize; elementSize++) { std::vector witVerifyScript; // increase the size of stack element by one byte