From d3ae1fcce6563d119ad2ad8c25dc0066383f7335 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 19 Jan 2018 16:58:07 +0300 Subject: [PATCH 1/3] Split tx issue fix --- src/supernode/graft_wallet.cpp | 6 +++-- src/wallet/wallet2.cpp | 4 ++- tests/supernode_tests/graft_wallet_tests.cpp | 27 +++++++++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/supernode/graft_wallet.cpp b/src/supernode/graft_wallet.cpp index 963fcb761..079974435 100644 --- a/src/supernode/graft_wallet.cpp +++ b/src/supernode/graft_wallet.cpp @@ -5451,8 +5451,10 @@ bool GraftWallet::use_fork_rules(uint8_t version, int64_t early_blocks) throw_on_rpc_response_error(result, "get_info"); result = m_node_rpc_proxy.get_earliest_height(version, earliest_height); throw_on_rpc_response_error(result, "get_hard_fork_info"); - - bool close_enough = height >= earliest_height - early_blocks; // start using the rules that many blocks beforehand + // graft: check if we have integer overflow in 'earliest_height - early_blocks' because we started from v7 + bool close_enough = earliest_height >= std::abs(early_blocks) ? + (height >= earliest_height - early_blocks) : true; // start using the rules that many blocks beforehand + LOG_PRINT_L2("height: " << height << ", earliest_height: " << earliest_height); if (close_enough) LOG_PRINT_L2("Using v" << (unsigned)version << " rules"); else diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index eab10aaac..12138e67f 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4900,7 +4900,9 @@ bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) throw_on_rpc_response_error(result, "get_info"); result = m_node_rpc_proxy.get_earliest_height(version, earliest_height); throw_on_rpc_response_error(result, "get_hard_fork_info"); - bool close_enough = height >= earliest_height - early_blocks; // start using the rules that many blocks beforehand + // graft: check if we have integer overflow in 'earliest_height - early_blocks' because we started from v7 + bool close_enough = earliest_height >= static_cast(std::abs(early_blocks)) ? + (height >= earliest_height - early_blocks) : true; // start using the rules that many blocks beforehand LOG_PRINT_L2("height: " << height << ", earliest_height: " << earliest_height); if (close_enough) LOG_PRINT_L2("Using v" << (unsigned)version << " rules"); diff --git a/tests/supernode_tests/graft_wallet_tests.cpp b/tests/supernode_tests/graft_wallet_tests.cpp index 712c4ccba..fa9617903 100644 --- a/tests/supernode_tests/graft_wallet_tests.cpp +++ b/tests/supernode_tests/graft_wallet_tests.cpp @@ -68,10 +68,9 @@ struct GraftWalletTest : public testing::Test const std::string DAEMON_ADDR = "localhost:28281"; - GraftWalletTest() { - GraftWallet *wallet1 = new GraftWallet(true, false); + GraftWallet * wallet1 = new GraftWallet(true, false); GraftWallet *wallet2 = new GraftWallet(true, false); wallet_root_path = epee::string_tools::get_current_module_folder() + "/../data/supernode/test_wallets"; string wallet_path1 = wallet_root_path + "/miner_wallet"; @@ -87,7 +86,6 @@ struct GraftWalletTest : public testing::Test ~GraftWalletTest() { - } }; @@ -142,7 +140,28 @@ TEST_F(GraftWalletTest, LoadWrongCache) ASSERT_ANY_THROW(wallet->load_graft(wallet_account2, "", cache_filename)); boost::filesystem::remove(temp); delete wallet; +} - +// implemented here; normally we need the same for wallet/wallet2.cpp +TEST_F(GraftWalletTest, UseForkRule) +{ + GraftWallet *wallet = new GraftWallet(true, false); + ASSERT_NO_THROW(wallet->load_graft(wallet_account1, "", "")); + // connect to daemon and get the blocks + wallet->init(DAEMON_ADDR); + ASSERT_TRUE(wallet->use_fork_rules(2, 0)); + ASSERT_TRUE(wallet->use_fork_rules(4, 0)); + ASSERT_TRUE(wallet->use_fork_rules(5, 0)); + ASSERT_TRUE(wallet->use_fork_rules(6, 0)); + // this will fail on rta testnet as we need to update block version there + ASSERT_TRUE(wallet->use_fork_rules(7, 0)); + ASSERT_FALSE(wallet->use_fork_rules(8, 0)); + ASSERT_TRUE(wallet->use_fork_rules(2, 10)); + ASSERT_TRUE(wallet->use_fork_rules(4, 10)); + ASSERT_TRUE(wallet->use_fork_rules(5, 10)); + ASSERT_TRUE(wallet->use_fork_rules(6, 10)); + // this will fail on rta testnet as we need to update block version there + ASSERT_TRUE(wallet->use_fork_rules(7, 10)); + ASSERT_FALSE(wallet->use_fork_rules(8, 10)); } From 5b4660c8ec00d6152e098f87ea1154aeeca8637a Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 19 Jan 2018 17:02:56 +0300 Subject: [PATCH 2/3] Revert "Improved error message: sending to more dests than available outputs" This reverts commit b102cbc49b7d04e5ee35e2111d965f901e265982. --- src/wallet/wallet2.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 12138e67f..9e7f574fc 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4507,11 +4507,6 @@ std::vector wallet2::create_transactions_2(std::vector Date: Fri, 19 Jan 2018 18:17:27 +0300 Subject: [PATCH 3/3] version increment --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index a30364ebe..ecab4b6ef 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1,4 +1,4 @@ #define GRAFT_VERSION_TAG "@VERSIONTAG@" -#define GRAFT_VERSION "1.0.0" +#define GRAFT_VERSION "1.0.1" #define GRAFT_RELEASE_NAME "Vega" #define GRAFT_VERSION_FULL GRAFT_VERSION "-" GRAFT_VERSION_TAG