From 250376432997f73047ab7c7d351851175bbe9119 Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 21 Mar 2024 19:20:27 +0000 Subject: [PATCH] ci + upstream tx patch --- .github/workflows/cli-testnet.yml | 6 +++--- src/currency_core/currency_core.cpp | 2 ++ src/currency_core/tx_pool.cpp | 21 +++++++++++++++++++++ src/currency_core/tx_pool.h | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cli-testnet.yml b/.github/workflows/cli-testnet.yml index d48fe8f3..8925597d 100644 --- a/.github/workflows/cli-testnet.yml +++ b/.github/workflows/cli-testnet.yml @@ -75,19 +75,19 @@ jobs: - name: Call make release-testnet run: | conan config install contrib/cmake/settings_user.yml - make ci-${{ runner.target }}-testnet + make ci-${{ matrix.target }}-testnet - name: Release Tag uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - files: '*ethean-${{ runner.target }}-cli.*' + files: '*ethean-${{ matrix.target }}-cli.*' - name: Release Branch uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/heads/main') with: tag_name: canary prerelease: true - files: '*ethean-${{ runner.target }}-cli.*' + files: '*ethean-${{ matrix.target }}-cli.*' # linux-amd64: # runs-on: ubuntu-20.04 # env: diff --git a/src/currency_core/currency_core.cpp b/src/currency_core/currency_core.cpp index e1a302e6..5fc1b714 100644 --- a/src/currency_core/currency_core.cpp +++ b/src/currency_core/currency_core.cpp @@ -163,6 +163,8 @@ namespace currency r = m_blockchain_storage.init(m_config_folder, vm); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage"); + m_mempool.remove_incompatible_txs(); + r = m_miner.init(vm); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner"); diff --git a/src/currency_core/tx_pool.cpp b/src/currency_core/tx_pool.cpp index 3c4fe8d3..d7e9d760 100644 --- a/src/currency_core/tx_pool.cpp +++ b/src/currency_core/tx_pool.cpp @@ -1291,6 +1291,27 @@ namespace currency return true; } //--------------------------------------------------------------------------------- + void tx_memory_pool::remove_incompatible_txs() + { + std::vector invalid_tx_ids; + + m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry) + { + if (!m_blockchain.validate_tx_for_hardfork_specific_terms(tx_entry.tx, h)) + invalid_tx_ids.push_back(h); + return true; + }); + + for(const auto& id : invalid_tx_ids) + { + transaction tx{}; + size_t blob_size = 0; + uint64_t fee = 0; + take_tx(id, tx, blob_size, fee); + LOG_PRINT_L0("tx " << id << " was incompatible with the hardfork rules and removed"); + } + } + //--------------------------------------------------------------------------------- bool tx_memory_pool::load_keyimages_cache() { CRITICAL_REGION_LOCAL(m_key_images_lock); diff --git a/src/currency_core/tx_pool.h b/src/currency_core/tx_pool.h index 4ede52a2..92d60604 100644 --- a/src/currency_core/tx_pool.h +++ b/src/currency_core/tx_pool.h @@ -138,6 +138,8 @@ namespace currency bool remove_stuck_transactions(); // made public to be called from coretests + void remove_incompatible_txs(); // made public to be called after the BCS is loaded and hardfork info is ready + private: bool on_tx_add(crypto::hash tx_id, const transaction& tx, bool kept_by_block); bool on_tx_remove(const crypto::hash &tx_id, const transaction& tx, bool kept_by_block);