From 43a06350cf9a14d6a86bd08898bad15c19a0272d Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 20 Sep 2018 12:21:25 +0000 Subject: [PATCH 01/17] ringdb: use cursors to be a bit faster --- src/wallet/ringdb.cpp | 15 ++++++++------- tests/unit_tests/ringdb.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/wallet/ringdb.cpp b/src/wallet/ringdb.cpp index e9fc6866d..e5995e7fb 100644 --- a/src/wallet/ringdb.cpp +++ b/src/wallet/ringdb.cpp @@ -398,6 +398,8 @@ bool ringdb::blackball_worker(const std::vector> & epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);}); tx_active = true; + dbr = mdb_cursor_open(txn, dbi_blackballs, &cursor); + THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create cursor for blackballs table: " + std::string(mdb_strerror(dbr))); MDB_val key, data; for (const std::pair &output: outputs) @@ -411,25 +413,22 @@ bool ringdb::blackball_worker(const std::vector> & { case BLACKBALL_BLACKBALL: MDEBUG("Blackballing output " << output.first << "/" << output.second); - dbr = mdb_put(txn, dbi_blackballs, &key, &data, MDB_APPENDDUP); + dbr = mdb_cursor_put(cursor, &key, &data, MDB_APPENDDUP); if (dbr == MDB_KEYEXIST) dbr = 0; break; case BLACKBALL_UNBLACKBALL: MDEBUG("Unblackballing output " << output.first << "/" << output.second); - dbr = mdb_del(txn, dbi_blackballs, &key, &data); - if (dbr == MDB_NOTFOUND) - dbr = 0; + dbr = mdb_cursor_get(cursor, &key, &data, MDB_GET_BOTH); + if (dbr == 0) + dbr = mdb_cursor_del(cursor, 0); break; case BLACKBALL_QUERY: - dbr = mdb_cursor_open(txn, dbi_blackballs, &cursor); - THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create cursor for blackballs table: " + std::string(mdb_strerror(dbr))); dbr = mdb_cursor_get(cursor, &key, &data, MDB_GET_BOTH); THROW_WALLET_EXCEPTION_IF(dbr && dbr != MDB_NOTFOUND, tools::error::wallet_internal_error, "Failed to lookup in blackballs table: " + std::string(mdb_strerror(dbr))); ret = dbr != MDB_NOTFOUND; if (dbr == MDB_NOTFOUND) dbr = 0; - mdb_cursor_close(cursor); break; case BLACKBALL_CLEAR: break; @@ -439,6 +438,8 @@ bool ringdb::blackball_worker(const std::vector> & THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to query blackballs table: " + std::string(mdb_strerror(dbr))); } + mdb_cursor_close(cursor); + if (op == BLACKBALL_CLEAR) { dbr = mdb_drop(txn, dbi_blackballs, 0); diff --git a/tests/unit_tests/ringdb.cpp b/tests/unit_tests/ringdb.cpp index 416ae0890..0d92049ac 100644 --- a/tests/unit_tests/ringdb.cpp +++ b/tests/unit_tests/ringdb.cpp @@ -150,6 +150,30 @@ TEST(blackball, found) ASSERT_TRUE(ringdb.blackballed(OUTPUT_1)); } +TEST(blackball, vector) +{ + RingDB ringdb; + std::vector> outputs; + outputs.push_back(std::make_pair(0, 1)); + outputs.push_back(std::make_pair(10, 3)); + outputs.push_back(std::make_pair(10, 4)); + outputs.push_back(std::make_pair(10, 8)); + outputs.push_back(std::make_pair(20, 0)); + outputs.push_back(std::make_pair(20, 1)); + outputs.push_back(std::make_pair(30, 5)); + ASSERT_TRUE(ringdb.blackball(outputs)); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(0, 1))); + ASSERT_FALSE(ringdb.blackballed(std::make_pair(10, 2))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 3))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 4))); + ASSERT_FALSE(ringdb.blackballed(std::make_pair(10, 5))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 8))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(20, 0))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(20, 1))); + ASSERT_FALSE(ringdb.blackballed(std::make_pair(20, 2))); + ASSERT_TRUE(ringdb.blackballed(std::make_pair(30, 5))); +} + TEST(blackball, unblackball) { RingDB ringdb; From 7a056f4425aa4fbe87494f77a4dc64e26f6000bf Mon Sep 17 00:00:00 2001 From: naughtyfox Date: Thu, 20 Sep 2018 17:12:35 +0300 Subject: [PATCH 02/17] WalletAPI: multisigSignData bug fixed --- src/wallet/api/pending_transaction.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp index 8d200220d..913e3156f 100644 --- a/src/wallet/api/pending_transaction.cpp +++ b/src/wallet/api/pending_transaction.cpp @@ -200,7 +200,11 @@ std::string PendingTransactionImpl::multisigSignData() { throw std::runtime_error("wallet is not multisig"); } - auto cipher = m_wallet.m_wallet->save_multisig_tx(m_pending_tx); + tools::wallet2::multisig_tx_set txSet; + txSet.m_ptx = m_pending_tx; + txSet.m_signers = m_signers; + auto cipher = m_wallet.m_wallet->save_multisig_tx(txSet); + return epee::string_tools::buff_to_hex_nodelimer(cipher); } catch (const std::exception& e) { m_status = Status_Error; From 7964d4f8ea9ef05a4d2dea54e1b5a55a4b2487e5 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 19 Sep 2018 20:20:58 +0000 Subject: [PATCH 03/17] wallet2: handle corner case in picking fake outputs If we originally think we have enough outputs on the blockchain to pick random fake outputs, we might end up with not enough of them if enough are actually blackballed. --- src/wallet/wallet2.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 6502463e2..6ca393cd4 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -6642,11 +6642,23 @@ void wallet2::get_outs(std::vector> } // while we still need more mixins + uint64_t num_usable_outs = num_outs; + bool allow_blackballed = false; while (num_found < requested_outputs_count) { // if we've gone through every possible output, we've gotten all we can - if (seen_indices.size() == num_outs) - break; + if (seen_indices.size() == num_usable_outs) + { + // there is a first pass which rejects blackballed outputs, then a second pass + // which allows them if we don't have enough non blackballed outputs to reach + // the required amount of outputs (since consensus does not care about blackballed + // outputs, we still need to reach the minimum ring size) + if (allow_blackballed) + break; + MINFO("Not enough non blackballed outputs, we'll allow blackballed ones"); + allow_blackballed = true; + num_usable_outs = num_outs; + } // get a random output index from the DB. If we've already seen it, // return to the top of the loop and try again, otherwise add it to the @@ -6720,14 +6732,26 @@ void wallet2::get_outs(std::vector> if (seen_indices.count(i)) continue; - if (is_output_blackballed(std::make_pair(amount, i))) // don't add blackballed outputs + if (!allow_blackballed && is_output_blackballed(std::make_pair(amount, i))) // don't add blackballed outputs + { + --num_usable_outs; continue; + } seen_indices.emplace(i); LOG_PRINT_L2("picking " << i << " as " << type); req.outputs.push_back({amount, i}); ++num_found; } + + // if we had enough unusable outputs, we might fall off here and still + // have too few outputs, so we stuff with one to keep counts good, and + // we'll error out later + while (num_found < requested_outputs_count) + { + req.outputs.push_back({amount, 0}); + ++num_found; + } } // sort the subsection, to ensure the daemon doesn't know which output is ours From a21da9058bf33939ce07c2eef8ba9b2da508192b Mon Sep 17 00:00:00 2001 From: oneiric Date: Sat, 22 Sep 2018 22:03:36 +0000 Subject: [PATCH 04/17] Wallet: use unique_ptr for WalletImpl members Use unique_ptr to manage WalletImpl internals, rather than raw pointers. --- src/wallet/api/wallet.cpp | 26 ++++++++++---------------- src/wallet/api/wallet.h | 12 ++++++------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 8b25096a2..b0e5fa37f 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -376,15 +376,15 @@ WalletImpl::WalletImpl(NetworkType nettype, uint64_t kdf_rounds) , m_rebuildWalletCache(false) , m_is_connected(false) { - m_wallet = new tools::wallet2(static_cast(nettype), kdf_rounds, true); - m_history = new TransactionHistoryImpl(this); - m_wallet2Callback = new Wallet2CallbackImpl(this); + m_wallet = std::make_unique(static_cast(nettype), kdf_rounds, true); + m_history = std::make_unique(this); + m_wallet2Callback = std::make_unique(this); m_wallet->callback(m_wallet2Callback); m_refreshThreadDone = false; m_refreshEnabled = false; - m_addressBook = new AddressBookImpl(this); - m_subaddress = new SubaddressImpl(this); - m_subaddressAccount = new SubaddressAccountImpl(this); + m_addressBook = std::make_unique(this); + m_subaddress = std::make_unique(this); + m_subaddressAccount = std::make_unique(this); m_refreshIntervalMillis = DEFAULT_REFRESH_INTERVAL_MILLIS; @@ -405,12 +405,6 @@ WalletImpl::~WalletImpl() close(false); // do not store wallet as part of the closing activities // Stop refresh thread stopRefresh(); - delete m_wallet2Callback; - delete m_history; - delete m_addressBook; - delete m_subaddress; - delete m_subaddressAccount; - delete m_wallet; LOG_PRINT_L1(__FUNCTION__ << " finished"); } @@ -1551,22 +1545,22 @@ void WalletImpl::disposeTransaction(PendingTransaction *t) TransactionHistory *WalletImpl::history() { - return m_history; + return m_history.get(); } AddressBook *WalletImpl::addressBook() { - return m_addressBook; + return m_addressBook.get(); } Subaddress *WalletImpl::subaddress() { - return m_subaddress; + return m_subaddress.get(); } SubaddressAccount *WalletImpl::subaddressAccount() { - return m_subaddressAccount; + return m_subaddressAccount.get(); } void WalletImpl::setListener(WalletListener *l) diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index e3a300317..b2317b9ba 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -215,16 +215,16 @@ private: friend class SubaddressImpl; friend class SubaddressAccountImpl; - tools::wallet2 * m_wallet; + std::unique_ptr m_wallet; mutable boost::mutex m_statusMutex; mutable int m_status; mutable std::string m_errorString; std::string m_password; - TransactionHistoryImpl * m_history; - Wallet2CallbackImpl * m_wallet2Callback; - AddressBookImpl * m_addressBook; - SubaddressImpl * m_subaddress; - SubaddressAccountImpl * m_subaddressAccount; + std::unique_ptr m_history; + std::unique_ptr m_wallet2Callback; + std::unique_ptr m_addressBook; + std::unique_ptr m_subaddress; + std::unique_ptr m_subaddressAccount; // multi-threaded refresh stuff std::atomic m_refreshEnabled; From 92d1da28efcd750c5dc07e20de046375bfbe595e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 23 Sep 2018 13:47:30 +0000 Subject: [PATCH 05/17] unit_tests: fix build with GCC 5.4.0 on ubuntu --- tests/unit_tests/is_hdd.cpp | 4 ++-- tests/unit_tests/wipeable_string.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit_tests/is_hdd.cpp b/tests/unit_tests/is_hdd.cpp index 1be670e5e..040af4f47 100644 --- a/tests/unit_tests/is_hdd.cpp +++ b/tests/unit_tests/is_hdd.cpp @@ -6,12 +6,12 @@ TEST(is_hdd, linux_os_root) { std::string path = "/"; - EXPECT_TRUE(tools::is_hdd(path.c_str())); + EXPECT_TRUE(tools::is_hdd(path.c_str()) != boost::none); } #else TEST(is_hdd, unknown_os) { std::string path = ""; - EXPECT_FALSE(tools::is_hdd(path.c_str())); + EXPECT_FALSE(tools::is_hdd(path.c_str()) != boost::none); } #endif diff --git a/tests/unit_tests/wipeable_string.cpp b/tests/unit_tests/wipeable_string.cpp index 65718fd45..44e050c5c 100644 --- a/tests/unit_tests/wipeable_string.cpp +++ b/tests/unit_tests/wipeable_string.cpp @@ -194,13 +194,13 @@ TEST(wipeable_string, parse_hexstr) ASSERT_EQ(boost::none, epee::wipeable_string("0").parse_hexstr()); ASSERT_EQ(boost::none, epee::wipeable_string("000").parse_hexstr()); - ASSERT_TRUE((s = epee::wipeable_string("").parse_hexstr())); + ASSERT_TRUE((s = epee::wipeable_string("").parse_hexstr()) != boost::none); ASSERT_EQ(*s, ""); - ASSERT_TRUE((s = epee::wipeable_string("00").parse_hexstr())); + ASSERT_TRUE((s = epee::wipeable_string("00").parse_hexstr()) != boost::none); ASSERT_EQ(*s, epee::wipeable_string("", 1)); - ASSERT_TRUE((s = epee::wipeable_string("41").parse_hexstr())); + ASSERT_TRUE((s = epee::wipeable_string("41").parse_hexstr()) != boost::none); ASSERT_EQ(*s, epee::wipeable_string("A")); - ASSERT_TRUE((s = epee::wipeable_string("414243").parse_hexstr())); + ASSERT_TRUE((s = epee::wipeable_string("414243").parse_hexstr()) != boost::none); ASSERT_EQ(*s, epee::wipeable_string("ABC")); } From a69271faf78ce6071fd58e21c08f69ddc8c7814d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20K=C4=85kol?= Date: Sun, 23 Sep 2018 18:31:30 +0200 Subject: [PATCH 06/17] Fixed a typo --- cmake/CheckLinkerFlag.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CheckLinkerFlag.cmake b/cmake/CheckLinkerFlag.cmake index a3879d0be..2b507ab71 100644 --- a/cmake/CheckLinkerFlag.cmake +++ b/cmake/CheckLinkerFlag.cmake @@ -39,7 +39,7 @@ macro(CHECK_LINKER_FLAG flag VARIABLE) endif() set(${VARIABLE} "" CACHE INTERNAL "Have linker flag ${flag}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the ${flag} linker flag is suppored " + "Determining if the ${flag} linker flag is supported " "failed with the following output:\n" "${OUTPUT}\n\n") endif() From 89288863a4d3f0c87845a8651ab590e348fe5fe6 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 25 Sep 2018 09:41:41 +0000 Subject: [PATCH 07/17] README: mention ASAN usage alongside valgrind --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ded4eb51..c1abe625d 100644 --- a/README.md +++ b/README.md @@ -666,9 +666,19 @@ Type `run` to run monerod ### Analysing memory corruption -We use the tool `valgrind` for this. +There are two tools available: -Run with `valgrind /path/to/monerod`. It will be slow. +* ASAN + +Configure Monero with the -D SANITIZE=ON cmake flag, eg: + + cd build/debug && cmake -D SANITIZE=ON -D CMAKE_BUILD_TYPE=Debug ../.. + +You can then run the monero tools normally. Performance will typically halve. + +* valgrind + +Install valgrind and run as `valgrind /path/to/monerod`. It will be very slow. ### LMDB From 174f31bf7d53b032523f89cfe3ac78e9df2f784e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 25 Sep 2018 12:33:39 +0000 Subject: [PATCH 08/17] simplewallet: don't complain about payment id on pool mined blocks Those use the extra nonce without a payment id --- src/simplewallet/simplewallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 302d2a999..06655ed69 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -4157,10 +4157,11 @@ void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) { crypto::hash8 payment_id8 = crypto::null_hash8; + crypto::hash payment_id = crypto::null_hash; if (get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8)) message_writer() << tr("NOTE: this transaction uses an encrypted payment ID: consider using subaddresses instead"); - else + else if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id)) message_writer(console_color_red, false) << tr("WARNING: this transaction uses an unencrypted payment ID: consider using subaddresses instead"); } From cf470bf3d6d94d925a95e6bca66d84169e3ebaca Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Tue, 25 Sep 2018 15:07:28 +0200 Subject: [PATCH 09/17] switch from master to rc --- src/version.cpp.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.cpp.in b/src/version.cpp.in index ff2405811..257e7b5d1 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_MONERO_VERSION_TAG "@VERSIONTAG@" -#define DEF_MONERO_VERSION "0.13.0.0-master" +#define DEF_MONERO_VERSION "0.13.0.0-rc" #define DEF_MONERO_RELEASE_NAME "Beryllium Bullet" #define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG From 6f5360b3c6497da785da367a2b54f6760e3cd8bd Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Tue, 25 Sep 2018 15:48:56 +0200 Subject: [PATCH 10/17] bump version to 0.13.0.1 --- src/version.cpp.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.cpp.in b/src/version.cpp.in index 257e7b5d1..55075a064 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_MONERO_VERSION_TAG "@VERSIONTAG@" -#define DEF_MONERO_VERSION "0.13.0.0-rc" +#define DEF_MONERO_VERSION "0.13.0.1-rc" #define DEF_MONERO_RELEASE_NAME "Beryllium Bullet" #define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG From fe1256471a2de22e0ccaf27e7c62d6861bec197f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 25 Sep 2018 20:59:37 +0100 Subject: [PATCH 11/17] Fixup RENAME_DB() macro Make sure target DB's record is on a writable page --- src/blockchain_db/lmdb/db_lmdb.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index b0f3ca5f0..d8f7df5f7 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -3490,7 +3490,17 @@ void BlockchainLMDB::fixup() BlockchainDB::fixup(); } -#define RENAME_DB(name) \ +#define RENAME_DB(name) do { \ + char n2[] = name; \ + MDB_dbi tdbi; \ + n2[sizeof(n2)-2]--; \ + /* play some games to put (name) on a writable page */ \ + result = mdb_dbi_open(txn, n2, MDB_CREATE, &tdbi); \ + if (result) \ + throw0(DB_ERROR(lmdb_error("Failed to create " + std::string(n2) + ": ", result).c_str())); \ + result = mdb_drop(txn, tdbi, 1); \ + if (result) \ + throw0(DB_ERROR(lmdb_error("Failed to delete " + std::string(n2) + ": ", result).c_str())); \ k.mv_data = (void *)name; \ k.mv_size = sizeof(name)-1; \ result = mdb_cursor_open(txn, 1, &c_cur); \ @@ -3500,7 +3510,7 @@ void BlockchainLMDB::fixup() if (result) \ throw0(DB_ERROR(lmdb_error("Failed to get DB record for " name ": ", result).c_str())); \ ptr = (char *)k.mv_data; \ - ptr[sizeof(name)-2]++ + ptr[sizeof(name)-2]++; } while(0) #define LOGIF(y) if (ELPP->vRegistry()->allowed(y, "global")) From 69da14e105c96140a0fbf4c40f2bf1672965910f Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Tue, 25 Sep 2018 22:44:00 +0200 Subject: [PATCH 12/17] fixes make debug compilation on OSX --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 994d47691..a7746371e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -769,7 +769,7 @@ else() endif() if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -DGTEST_HAS_TR1_TUPLE=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0") endif() set(DEBUG_FLAGS "-g3") From 6a78140863cbfc11dd4388901c913717f8ca4d17 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Tue, 25 Sep 2018 19:54:41 +0000 Subject: [PATCH 13/17] Make depends use self built clang for darwin The configure script in hidapi and libsodium tried to find clang in /usr/bin, even though the correct prefix was passed in. This sets the correct CC flag. This was previously undetected, because clang and the sdk where installed in the global environment. This also fixes a subsequent error, where IOKIT and CoreFoundation are not found, again for the reason stated above. --- CMakeLists.txt | 12 ++++++++---- contrib/depends/packages/hidapi-darwin.mk | 2 +- contrib/depends/packages/packages.mk | 2 +- contrib/depends/packages/sodium-darwin.mk | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 994d47691..75d8ba9c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -883,10 +883,14 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) if (HIDAPI_FOUND) if (APPLE) - find_library(COREFOUNDATION CoreFoundation) - find_library(IOKIT IOKit) - list(APPEND EXTRA_LIBRARIES ${IOKIT}) - list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION}) + if(DEPENDS) + list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit") + else() + find_library(COREFOUNDATION CoreFoundation) + find_library(IOKIT IOKit) + list(APPEND EXTRA_LIBRARIES ${IOKIT}) + list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION}) + endif() endif() if (WIN32) list(APPEND EXTRA_LIBRARIES setupapi) diff --git a/contrib/depends/packages/hidapi-darwin.mk b/contrib/depends/packages/hidapi-darwin.mk index 1fbbb59e0..014aba578 100644 --- a/contrib/depends/packages/hidapi-darwin.mk +++ b/contrib/depends/packages/hidapi-darwin.mk @@ -11,7 +11,7 @@ endef define $(package)_config_cmds ./bootstrap &&\ - $($(package)_autoconf) $($(package)_config_opts) RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" + $($(package)_autoconf) $($(package)_config_opts) RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)" endef define $(package)_build_cmds diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk index 13ba37628..9bfbff7d9 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -4,7 +4,7 @@ native_packages := native_ccache wallet_packages=bdb darwin_native_packages = native_biplist native_ds_store native_mac_alias -darwin_packages += sodium-darwin hidapi-darwin +darwin_packages = sodium-darwin hidapi-darwin linux_packages = eudev libusb hidapi-linux diff --git a/contrib/depends/packages/sodium-darwin.mk b/contrib/depends/packages/sodium-darwin.mk index 796bead16..59c6d1ec6 100644 --- a/contrib/depends/packages/sodium-darwin.mk +++ b/contrib/depends/packages/sodium-darwin.mk @@ -5,13 +5,14 @@ $(package)_file_name=libsodium-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 define $(package)_set_vars +$(package)_build_opts_darwin=OS=Darwin LIBTOOL="$($(package)_libtool)" $(package)_config_opts=--enable-static $(package)_config_opts+=--prefix=$(host_prefix) endef define $(package)_config_cmds ./autogen.sh &&\ - $($(package)_autoconf) $($(package)_config_opts) RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" + $($(package)_autoconf) $($(package)_config_opts) RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin11-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin11-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)" endef define $(package)_build_cmds From 17142ec9bbb99c8e6ddea51965f2edeeaea8e769 Mon Sep 17 00:00:00 2001 From: m2049r Date: Fri, 30 Mar 2018 13:01:41 +0200 Subject: [PATCH 14/17] malloc scratchpad for all supported android archs --- src/crypto/slow-hash.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 80bf4e06f..40cfb0461 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -1040,10 +1040,37 @@ STATIC INLINE void aes_pseudo_round_xor(const uint8_t *in, uint8_t *out, const u } } +#ifdef FORCE_USE_HEAP +STATIC INLINE void* aligned_malloc(size_t size, size_t align) +{ + void *result; +#ifdef _MSC_VER + result = _aligned_malloc(size, align); +#else + if (posix_memalign(&result, align, size)) result = NULL; +#endif + return result; +} + +STATIC INLINE void aligned_free(void *ptr) +{ +#ifdef _MSC_VER + _aligned_free(ptr); +#else + free(ptr); +#endif +} +#endif /* FORCE_USE_HEAP */ + void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { RDATA_ALIGN16 uint8_t expandedKey[240]; + +#ifndef FORCE_USE_HEAP RDATA_ALIGN16 uint8_t hp_state[MEMORY]; +#else + uint8_t *hp_state = (uint8_t *)aligned_malloc(MEMORY,16); +#endif uint8_t text[INIT_SIZE_BYTE]; RDATA_ALIGN16 uint64_t a[2]; @@ -1129,6 +1156,10 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int memcpy(state.init, text, INIT_SIZE_BYTE); hash_permutation(&state.hs); extra_hashes[state.hs.b[0] & 3](&state, 200, hash); + +#ifdef FORCE_USE_HEAP + aligned_free(hp_state); +#endif } #else /* aarch64 && crypto */ @@ -1270,8 +1301,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int #ifndef FORCE_USE_HEAP uint8_t long_state[MEMORY]; #else - uint8_t *long_state = NULL; - long_state = (uint8_t *)malloc(MEMORY); + uint8_t *long_state = (uint8_t *)malloc(MEMORY); #endif if (prehashed) { @@ -1449,7 +1479,12 @@ union cn_slow_hash_state { #pragma pack(pop) void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { +#ifndef FORCE_USE_HEAP uint8_t long_state[MEMORY]; +#else + uint8_t *long_state = (uint8_t *)malloc(MEMORY); +#endif + union cn_slow_hash_state state; uint8_t text[INIT_SIZE_BYTE]; uint8_t a[AES_BLOCK_SIZE]; @@ -1534,6 +1569,10 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int /*memcpy(hash, &state, 32);*/ extra_hashes[state.hs.b[0] & 3](&state, 200, hash); oaes_free((OAES_CTX **) &aes_ctx); + +#ifdef FORCE_USE_HEAP + free(long_state); +#endif } #endif From b2972927ea0bff9d72594ed23f97e302a0022440 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Tue, 25 Sep 2018 19:30:22 +0200 Subject: [PATCH 15/17] osx compilation fix: missing boost libs added --- contrib/epee/src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index 0b5e7ae6c..bc437deb9 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -54,7 +54,9 @@ endif() target_link_libraries(epee PUBLIC easylogging + ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} PRIVATE ${OPENSSL_LIBRARIES} ${EXTRA_LIBRARIES}) From 83debef99e207fd5761141d2d2630f77dc1b00ed Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 24 Sep 2018 09:57:28 +0000 Subject: [PATCH 16/17] wallet_rpc_server: remove verbose field in incoming_transfers query The key image (which was only supplied if verbose was true) is readily available, not a secret key, and it was only modelled after the CLI command because it's a bit spammy for the CLI. --- src/wallet/wallet_rpc_server.cpp | 2 +- src/wallet/wallet_rpc_server_commands_defs.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index e6eb64d12..27631187c 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1554,7 +1554,7 @@ namespace tools rpc_transfers.global_index = td.m_global_output_index; rpc_transfers.tx_hash = epee::string_tools::pod_to_hex(td.m_txid); rpc_transfers.subaddr_index = {td.m_subaddr_index.major, td.m_subaddr_index.minor}; - rpc_transfers.key_image = req.verbose && td.m_key_image_known ? epee::string_tools::pod_to_hex(td.m_key_image) : ""; + rpc_transfers.key_image = td.m_key_image_known ? epee::string_tools::pod_to_hex(td.m_key_image) : ""; res.transfers.push_back(rpc_transfers); } } diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 2168e0f71..81ea22928 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -883,13 +883,11 @@ namespace wallet_rpc std::string transfer_type; uint32_t account_index; std::set subaddr_indices; - bool verbose; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(transfer_type) KV_SERIALIZE(account_index) KV_SERIALIZE(subaddr_indices) - KV_SERIALIZE(verbose) END_KV_SERIALIZE_MAP() }; From 2fbf38ee918894a92f2f058c5551d81d34e215c9 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Wed, 26 Sep 2018 00:36:34 +0200 Subject: [PATCH 17/17] Fix 32bit depends builds Add architecture flags when cmake invokes gcc manually. Add 32bit to Travis. --- .travis.yml | 2 ++ contrib/depends/toolchain.cmake.in | 4 ++++ src/blockchain_utilities/CMakeLists.txt | 2 ++ src/blocks/CMakeLists.txt | 12 +++++++++--- src/daemon/CMakeLists.txt | 2 ++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9368c3ff2..ca3a24ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ env: - HOST=arm-linux-gnueabihf PACKAGES="gperf g++-arm-linux-gnueabihf" # ARM v8 - HOST=aarch64-linux-gnu PACKAGES="gperf g++-aarch64-linux-gnu" +# i686 Win + - HOST=i686-w64-mingw32 PACKAGES="python3 nsis g++-mingw-w64-i686" # i686 Linux - HOST=i686-pc-linux-gnu PACKAGES="gperf cmake g++-multilib bc python3-zmq" RUN_TESTS=true # Win64 diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index 375533557..bde7497b3 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -78,5 +78,9 @@ elseif(ARCHITECTURE STREQUAL "aarch64") set(BUILD_64 ON) endif() +if(ARCHITECTURE STREQUAL "i686" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX_32 ON) +endif() + #Create a new global cmake flag that indicates building with depends set (DEPENDS true) diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index 37bca671f..ecd7b754c 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -32,6 +32,8 @@ if(PER_BLOCK_CHECKPOINT) add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} --target=x86_64-apple-darwin11 -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*) elseif(APPLE AND NOT DEPENDS) add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*) + elseif(LINUX_32) + add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat) else() add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat) endif() diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt index cf3f0b354..ebb5408cc 100644 --- a/src/blocks/CMakeLists.txt +++ b/src/blocks/CMakeLists.txt @@ -30,9 +30,15 @@ if(APPLE) add_library(blocks STATIC blockexports.c) set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C) else() - add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat) - add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat) - add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat) + if(LINUX_32) + add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat) + add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat) + add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat) + else() + add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat) + add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat) + add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat) + endif() add_library(blocks STATIC blocks.o testnet_blocks.o stagenet_blocks.o blockexports.c) set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C) endif() diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index b1c4b711d..f645836a4 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -32,6 +32,8 @@ if(PER_BLOCK_CHECKPOINT) add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} --target=x86_64-apple-darwin11 -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*) elseif(APPLE AND NOT DEPENDS) add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*) + elseif(LINUX_32) + add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat) else() add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat) endif()