diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 4 | ||||
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 13 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 2 | ||||
-rw-r--r-- | src/cryptonote_protocol/levin_notify.cpp | 17 | ||||
-rw-r--r-- | src/cryptonote_protocol/levin_notify.h | 2 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 13 | ||||
-rw-r--r-- | src/rpc/bootstrap_daemon.cpp | 2 | ||||
-rw-r--r-- | src/rpc/bootstrap_daemon.h | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 1 | ||||
-rw-r--r-- | src/wallet/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/wallet/api/wallet.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 6 |
12 files changed, 50 insertions, 18 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index bcf99bbed..de0279b4b 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1315,7 +1315,9 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, if (!memcmp(&miner_address, &m_btc_address, sizeof(cryptonote::account_public_address)) && m_btc_nonce == ex_nonce && m_btc_pool_cookie == m_tx_pool.cookie() && m_btc.prev_id == get_tail_id()) { MDEBUG("Using cached template"); - m_btc.timestamp = time(NULL); // update timestamp unconditionally + const uint64_t now = time(NULL); + if (m_btc.timestamp < now) // ensures it can't get below the median of the last few blocks + m_btc.timestamp = now; b = m_btc; diffic = m_btc_difficulty; height = m_btc_height; diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 49d5a8ccc..5927e116a 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -733,7 +733,7 @@ namespace cryptonote if (meta.double_spend_seen) ++stats.num_double_spends; return true; - }, false, include_unrelayed_txes); + }, false, include_unrelayed_txes); stats.bytes_med = epee::misc_utils::median(weights); if (stats.txs_total > 1) { @@ -746,8 +746,15 @@ namespace cryptonote /* If enough txs, spread the first 98% of results across * the first 9 bins, drop final 2% in last bin. */ - it=agebytes.end(); - for (size_t n=0; n <= end; n++, it--); + it = agebytes.end(); + size_t cumulative_num = 0; + /* Since agebytes is not empty and end is nonzero, the + * below loop can always run at least once. + */ + do { + --it; + cumulative_num += it->second.txs; + } while (it != agebytes.begin() && cumulative_num < end); stats.histo_98pc = it->first; factor = 9; delta = it->first; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 82f9f96a0..4437c6a3a 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -2059,7 +2059,7 @@ skip: bool t_cryptonote_protocol_handler<t_core>::on_connection_synchronized() { bool val_expected = false; - if(m_synchronized.compare_exchange_strong(val_expected, true)) + if(!m_core.is_within_compiled_block_hash_area(m_core.get_current_blockchain_height()) && m_synchronized.compare_exchange_strong(val_expected, true)) { MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL << "You are now synchronized with the network. You may now start monero-wallet-cli." << ENDL diff --git a/src/cryptonote_protocol/levin_notify.cpp b/src/cryptonote_protocol/levin_notify.cpp index 26cd93b5a..4b41b5bfc 100644 --- a/src/cryptonote_protocol/levin_notify.cpp +++ b/src/cryptonote_protocol/levin_notify.cpp @@ -187,14 +187,15 @@ namespace levin { struct zone { - explicit zone(boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in) + explicit zone(boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in, bool is_public) : p2p(std::move(p2p)), noise(std::move(noise_in)), next_epoch(io_service), strand(io_service), map(), channels(), - connection_count(0) + connection_count(0), + is_public(is_public) { for (std::size_t count = 0; !noise.empty() && count < CRYPTONOTE_NOISE_CHANNELS; ++count) channels.emplace_back(io_service); @@ -207,6 +208,7 @@ namespace levin net::dandelionpp::connection_map map;//!< Tracks outgoing uuid's for noise channels or Dandelion++ stems std::deque<noise_channel> channels; //!< Never touch after init; only update elements on `noise_channel.strand` std::atomic<std::size_t> connection_count; //!< Only update in strand, can be read at any time + const bool is_public; //!< Zone is public ipv4/ipv6 connections }; } // detail @@ -276,7 +278,10 @@ namespace levin std::vector<boost::uuids::uuid> connections; connections.reserve(connection_id_reserve_size); zone_->p2p->foreach_connection([this, &connections] (detail::p2p_context& context) { - if (this->source_ != context.m_connection_id) + /* Only send to outgoing connections when "flooding" over i2p/tor. + Otherwise this makes the tx linkable to a hidden service address, + making things linkable across connections. */ + if (this->source_ != context.m_connection_id && (this->zone_->is_public || !context.m_is_income)) connections.emplace_back(context.m_connection_id); return true; }); @@ -476,8 +481,8 @@ namespace levin }; } // anonymous - notify::notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise) - : zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise))) + notify::notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, bool is_public) + : zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise), is_public)) { if (!zone_->p2p) throw std::logic_error{"cryptonote::levin::notify cannot have nullptr p2p argument"}; @@ -528,7 +533,7 @@ namespace levin channel.next_noise.cancel(); } - bool notify::send_txs(std::vector<cryptonote::blobdata> txs, const boost::uuids::uuid& source, const bool pad_txs) + bool notify::send_txs(std::vector<blobdata> txs, const boost::uuids::uuid& source, const bool pad_txs) { if (!zone_) return false; diff --git a/src/cryptonote_protocol/levin_notify.h b/src/cryptonote_protocol/levin_notify.h index 82d22680a..484243af5 100644 --- a/src/cryptonote_protocol/levin_notify.h +++ b/src/cryptonote_protocol/levin_notify.h @@ -86,7 +86,7 @@ namespace levin {} //! Construct an instance with available notification `zones`. - explicit notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise); + explicit notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, bool is_public); notify(const notify&) = delete; notify(notify&&) = default; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 24c87cef8..bb77ea658 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -384,7 +384,7 @@ namespace nodetool m_use_ipv6 = command_line::get_arg(vm, arg_p2p_use_ipv6); m_require_ipv4 = command_line::get_arg(vm, arg_p2p_require_ipv4); public_zone.m_notifier = cryptonote::levin::notify{ - public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr + public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, true }; if (command_line::has_arg(vm, arg_p2p_add_peer)) @@ -495,7 +495,7 @@ namespace nodetool } zone.m_notifier = cryptonote::levin::notify{ - zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise) + zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise), false }; } @@ -670,11 +670,18 @@ namespace nodetool std::vector<std::vector<std::string>> dns_results; dns_results.resize(m_seed_nodes_list.size()); + // some libc implementation provide only a very small stack + // for threads, e.g. musl only gives +- 80kb, which is not + // enough to do a resolve with unbound. we request a stack + // of 1 mb, which should be plenty + boost::thread::attributes thread_attributes; + thread_attributes.set_stack_size(1024*1024); + std::list<boost::thread> dns_threads; uint64_t result_index = 0; for (const std::string& addr_str : m_seed_nodes_list) { - boost::thread th = boost::thread([=, &dns_results, &addr_str] + boost::thread th = boost::thread(thread_attributes, [=, &dns_results, &addr_str] { MDEBUG("dns_threads[" << result_index << "] created for: " << addr_str); // TODO: care about dnssec avail/valid diff --git a/src/rpc/bootstrap_daemon.cpp b/src/rpc/bootstrap_daemon.cpp index 6f8426ee7..c97b2c95a 100644 --- a/src/rpc/bootstrap_daemon.cpp +++ b/src/rpc/bootstrap_daemon.cpp @@ -12,7 +12,7 @@ namespace cryptonote { - bootstrap_daemon::bootstrap_daemon(std::function<boost::optional<std::string>()> get_next_public_node) noexcept + bootstrap_daemon::bootstrap_daemon(std::function<boost::optional<std::string>()> get_next_public_node) : m_get_next_public_node(get_next_public_node) { } diff --git a/src/rpc/bootstrap_daemon.h b/src/rpc/bootstrap_daemon.h index 130a6458d..6276b1b21 100644 --- a/src/rpc/bootstrap_daemon.h +++ b/src/rpc/bootstrap_daemon.h @@ -15,7 +15,7 @@ namespace cryptonote class bootstrap_daemon { public: - bootstrap_daemon(std::function<boost::optional<std::string>()> get_next_public_node) noexcept; + bootstrap_daemon(std::function<boost::optional<std::string>()> get_next_public_node); bootstrap_daemon(const std::string &address, const boost::optional<epee::net_utils::http::login> &credentials); std::string address() const noexcept; diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index fe384e529..f07d142fb 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2987,7 +2987,6 @@ simple_wallet::simple_wallet() " Set this if you are not sure whether you will spend on a key reusing Monero fork later.\n " "subaddress-lookahead <major>:<minor>\n " " Set the lookahead sizes for the subaddress hash table.\n " - " Set this if you are not sure whether you will spend on a key reusing Monero fork later.\n " "segregation-height <n>\n " " Set to the height of a key reusing fork you want to use, 0 to use default.\n " "ignore-fractional-outputs <1|0>\n " diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index d0fc21f51..553445a39 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -117,12 +117,14 @@ if (BUILD_GUI_DEPS) wallet_api wallet multisig + blockchain_db cryptonote_core cryptonote_basic mnemonics common cncrypto device + hardforks ringct ringct_basic checkpoints diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 7120485d5..6200c7a1f 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -1123,6 +1123,10 @@ UnsignedTransaction *WalletImpl::loadUnsignedTx(const std::string &unsigned_file UnsignedTransactionImpl * transaction = new UnsignedTransactionImpl(*this); if (!m_wallet->load_unsigned_tx(unsigned_filename, transaction->m_unsigned_tx_set)){ setStatusError(tr("Failed to load unsigned transactions")); + transaction->m_status = UnsignedTransaction::Status::Status_Error; + transaction->m_errorString = errorString(); + + return transaction; } // Check tx data and construct confirmation message diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b85e805de..3e00369a8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -13195,6 +13195,12 @@ bool wallet2::save_to_file(const std::string& path_to_file, const std::string& r } FILE *fp = fopen(path_to_file.c_str(), "w+"); + if (!fp) + { + MERROR("Failed to open wallet file for writing: " << path_to_file << ": " << strerror(errno)); + return false; + } + // Save the result b/c we need to close the fp before returning success/failure. int write_result = PEM_write(fp, ASCII_OUTPUT_MAGIC.c_str(), "", (const unsigned char *) raw.c_str(), raw.length()); fclose(fp); |