From b48c86afe088dae24b934b400d650f8c16994722 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Tue, 7 Jan 2025 22:53:58 +0000 Subject: [PATCH] added user tx verification --- src/cryptonote_config.h | 2 +- src/cryptonote_core/blockchain.cpp | 10 +--------- src/cryptonote_core/cryptonote_tx_utils.cpp | 1 + src/cryptonote_core/tx_pool.cpp | 9 +++++++++ src/hardforks/hardforks.cpp | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index d18fd54e6..c87cebec2 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -222,7 +222,7 @@ #define HF_VERSION_ENFORCE_FULL_PROOFS 4 -#define HF_VERSION_SHUTDOWN_USER_TXS 6 +#define HF_VERSION_SHUTDOWN_USER_TXS 5 #define HF_VERSION_REQUIRE_VIEW_TAGS 255 #define HF_VERSION_ENABLE_CONVERT 255 diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 964644d4e..ce5c0016c 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1499,6 +1499,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl case HF_VERSION_ENABLE_N_OUTS: case HF_VERSION_FULL_PROOFS: case HF_VERSION_ENFORCE_FULL_PROOFS: + case HF_VERSION_SHUTDOWN_USER_TXS: if (b.miner_tx.amount_burnt > 0) { CHECK_AND_ASSERT_MES(money_in_use + b.miner_tx.amount_burnt > money_in_use, false, "miner transaction is overflowed by amount_burnt"); money_in_use += b.miner_tx.amount_burnt; @@ -3656,15 +3657,6 @@ bool Blockchain::check_tx_type_and_version(const transaction& tx, tx_verificatio const uint8_t hf_version = m_hardfork->get_current_version(); - // Reject ALL TXs except miner + protocol for v5 - if (hf_version == HF_VERSION_SHUTDOWN_USER_TXS) { - if (tx.type != cryptonote::transaction_type::MINER && tx.type != cryptonote::transaction_type::PROTOCOL) { - MERROR_VER("User TXs are not permitted for v" + std::to_string(HF_VERSION_SHUTDOWN_USER_TXS)); - tvc.m_version_mismatch = true; - return false; - } - } - // Prior to v2, only allow TX v2 if (hf_version < HF_VERSION_ENABLE_N_OUTS) { diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 383dfd199..e9de4e231 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -591,6 +591,7 @@ namespace cryptonote case HF_VERSION_ENABLE_N_OUTS: case HF_VERSION_FULL_PROOFS: case HF_VERSION_ENFORCE_FULL_PROOFS: + case HF_VERSION_SHUTDOWN_USER_TXS: // SRCG: subtract 20% that will be rewarded to staking users CHECK_AND_ASSERT_MES(tx.amount_burnt == 0, false, "while creating outs: amount_burnt is nonzero"); tx.amount_burnt = amount / 5; diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index aaed85ad1..5f86824fb 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -167,6 +167,15 @@ namespace cryptonote return false; } + // Reject ALL TXs except miner + protocol for v5 + if (version == HF_VERSION_SHUTDOWN_USER_TXS) { + if (tx.type != cryptonote::transaction_type::MINER && tx.type != cryptonote::transaction_type::PROTOCOL) { + LOG_PRINT_L1("User TXs are not permitted for v" + std::to_string(HF_VERSION_SHUTDOWN_USER_TXS)); + tvc.m_verifivation_failed = true; + return false; + } + } + if(!check_inputs_types_supported(tx)) { tvc.m_verifivation_failed = true; diff --git a/src/hardforks/hardforks.cpp b/src/hardforks/hardforks.cpp index 041e9dd41..1f643e46a 100644 --- a/src/hardforks/hardforks.cpp +++ b/src/hardforks/hardforks.cpp @@ -61,7 +61,7 @@ const hardfork_t testnet_hard_forks[] = { { 3, 500, 0, 1729518000 }, // version 4 starts from block 600 - { 4, 600, 0, 173626500 }, + { 4, 600, 0, 1736265000 }, // version 5 starts from block 700 { 5, 700, 0, 1736265945 },