From 5f098e5be3ada88a7caeadab3673634bcc131cfc Mon Sep 17 00:00:00 2001 From: XfedeX Date: Thu, 19 Jan 2023 22:47:53 +0100 Subject: [PATCH] 6-month unlock window for pool miners --- src/cryptonote_config.h | 2 ++ src/cryptonote_core/blockchain.cpp | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 552801fdf..52a80897b 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -41,12 +41,14 @@ #define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000 #define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0 #define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3 52560 // 6 months +#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3_SOLO 288 #define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2 288 #define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60 #define CURRENT_TRANSACTION_VERSION 2 #define CURRENT_BLOCK_MAJOR_VERSION 7 #define CURRENT_BLOCK_MINOR_VERSION 7 #define BLOCK_HEADER_MINER_SIG 18 +#define OPTIONAL_BLOCK_HEADER_MINER_SIG 20 #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 300*2 #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2 #define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 4 diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index b9d01f3ed..327ba89a5 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1391,6 +1391,8 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std: // valid output types bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height, uint8_t hf_version) { + bool isSignatureValid = true; + // Miner Block Header Signing if (hf_version >= BLOCK_HEADER_MINER_SIG) { @@ -1417,8 +1419,12 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height, crypto::public_key eph_pub_key = boost::get(b.miner_tx.vout[0].target).key; if (!crypto::check_signature(sig_data, eph_pub_key, signature)) { - MWARNING("Miner signature is invalid"); - return false; + if (hf_version < OPTIONAL_BLOCK_HEADER_MINER_SIG) + { + MWARNING("Miner signature is invalid"); + return false; + } + isSignatureValid = false; } else { LOG_PRINT_L1("Miner signature is good"); LOG_PRINT_L1("Vote: " << b.vote); @@ -1445,8 +1451,13 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height, if (hf_version >= HF_VERSION_LONG_UNLOCK) { - CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3, false, "coinbase transaction transaction has the wrong unlock time=" - << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3); + if (isSignatureValid) { + CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3_SOLO, false, "coinbase transaction transaction has the wrong unlock time=" + << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3_SOLO); + } else { + CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3, false, "coinbase transaction transaction has the wrong unlock time=" + << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V3); + } } else if (hf_version >= HF_VERSION_FIXED_UNLOCK) { CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2, false, "coinbase transaction transaction has the wrong unlock time="