From 37bdf6ebe3e0339fb195efb4083022dba8813e85 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 24 Jul 2016 18:30:27 +0100 Subject: [PATCH] change fork settings to allow pre-rct txes for one more fork cycle --- src/cryptonote_core/blockchain.cpp | 2 +- src/cryptonote_core/tx_pool.cpp | 9 +++++++-- src/wallet/wallet2.cpp | 4 ++-- tests/core_tests/rct.cpp | 16 ++++++++-------- tests/core_tests/rct.h | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 9972b25e..547f2d4c 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2285,7 +2285,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context } // for v3, we force txes with all mixable inputs to be rct - if (m_hardfork->get_current_version() >= 3) + if (m_hardfork->get_current_version() >= 4) { if (n_unmixable == 0 && tx.version == 1) { diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index c2414f58..3666088f 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -85,10 +85,15 @@ namespace cryptonote return false; } - const size_t max_tx_version = version == 1 ? 1 : 2; + const size_t max_tx_version = (version <= 3) ? 1 : 2; if (tx.version > max_tx_version) { - // v2 is the latest one we know + tvc.m_verifivation_failed = true; + return false; + } + const size_t min_tx_version = (version >= 5) ? 2 : 1; + if (tx.version < min_tx_version) + { tvc.m_verifivation_failed = true; return false; } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 69063e78..966c9420 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3254,7 +3254,7 @@ std::vector wallet2::create_transactions_2(std::vector wallet2::create_transactions_all(const cryptono std::vector txes; uint64_t needed_fee, available_for_fee = 0; uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit(); - const bool use_rct = use_fork_rules(3); + const bool use_rct = use_fork_rules(4); // gather all our dust and non dust outputs for (size_t i = 0; i < m_transfers.size(); ++i) diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp index 8dbf8b27..d1ca40d9 100644 --- a/tests/core_tests/rct.cpp +++ b/tests/core_tests/rct.cpp @@ -57,8 +57,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev miner_accounts[n].generate(); CHECK_AND_ASSERT_MES(generator.construct_block_manually(blocks[n], *prev_block, miner_accounts[n], test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 3, 3, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 3), + 4, 4, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), false, "Failed to generate block"); events.push_back(blocks[n]); prev_block = blocks + n; @@ -74,8 +74,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 3, 3, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 3), + 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; @@ -134,8 +134,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes[n], blk_last, miner_account, test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version, - 3, 3, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 0, 3), + 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 0, 4), false, "Failed to generate block"); events.push_back(blk_txes[n]); blk_last = blk_txes[n]; @@ -148,8 +148,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 3, 3, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 3), + 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; diff --git a/tests/core_tests/rct.h b/tests/core_tests/rct.h index a9399656..bf0dc61f 100644 --- a/tests/core_tests/rct.h +++ b/tests/core_tests/rct.h @@ -81,7 +81,7 @@ private: template<> struct get_test_options { - const std::pair hard_forks[2] = {std::make_pair(1, 0), std::make_pair(3, 1)}; + const std::pair hard_forks[2] = {std::make_pair(1, 0), std::make_pair(4, 1)}; const cryptonote::test_options test_options = { hard_forks };