diff options
-rw-r--r-- | .dockerignore | 1 | ||||
-rw-r--r-- | Dockerfile | 59 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | contrib/snap/daemon.bash | 12 | ||||
-rwxr-xr-x | contrib/snap/log.bash | 3 | ||||
-rwxr-xr-x | contrib/snap/monerod-wrapper | 8 | ||||
-rw-r--r-- | contrib/snap/monerod.conf | 9 | ||||
-rw-r--r-- | contrib/snap/setup/gui/icon.png | bin | 0 -> 19132 bytes | |||
-rw-r--r-- | contrib/snap/snapcraft.yaml (renamed from snapcraft.yaml) | 18 | ||||
-rwxr-xr-x | contrib/snap/wallet.bash | 7 | ||||
l--------- | snap | 1 | ||||
-rw-r--r-- | src/common/util.cpp | 12 | ||||
-rw-r--r-- | src/common/util.h | 1 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 29 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 20 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 5 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 4 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 7 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.h | 2 | ||||
-rw-r--r-- | src/daemon/command_server.cpp | 5 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 28 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.h | 2 | ||||
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 2 | ||||
-rw-r--r-- | src/rpc/rpc_args.cpp | 2 |
25 files changed, 167 insertions, 73 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +* diff --git a/Dockerfile b/Dockerfile index 8a40e9533..38d7b96d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,35 @@ -FROM debian:testing -MAINTAINER eiabea <developer@eiabea.com> - -# Install clone dependencies -RUN set -e && \ - apt-get update -q && \ - apt-get install -q -y --no-install-recommends ca-certificates git && \ - git clone https://github.com/monero-project/monero.git src && \ - apt-get purge -y git && \ - apt-get clean -q -y && \ - apt-get autoclean -q -y && \ - apt-get autoremove -q -y - -WORKDIR /src - -# Install make dependencies -RUN set -e && \ - apt-get update -q && \ - apt-get install -q -y --no-install-recommends build-essential ca-certificates g++ gcc cmake \ - pkg-config libunbound2 libevent-2.0-5 libgtest-dev libboost-all-dev libdb5.3++-dev libdb5.3-dev libssl1.0-dev && \ - make -j 4 && \ - apt-get purge -y g++ gcc cmake pkg-config && \ - apt-get clean -q -y && \ - apt-get autoclean -q -y && \ - apt-get autoremove -q -y && \ - mkdir /monero && \ - mv /src/build/release/bin/* /monero && \ - rm -rf /src - -WORKDIR /monero +FROM ubuntu:16.04 + +ENV SRC_DIR /usr/local/src/monero + +RUN set -x \ + && buildDeps=' \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost1.58-all-dev \ + libssl-dev \ + make \ + pkg-config \ + ' \ + && apt-get -qq update \ + && apt-get -qq --no-install-recommends install $buildDeps \ + \ + && git clone https://github.com/monero-project/monero.git $SRC_DIR \ + && cd $SRC_DIR \ + && make -j$(nproc) release-static \ + && cp build/release/bin/* /usr/local/bin/ \ + \ + && rm -r $SRC_DIR \ + && apt-get -qq --auto-remove purge $buildDeps # Contains the blockchain VOLUME /root/.bitmonero # Generate your wallet via accessing the container and run: # cd /wallet -# /./bitmonero/monero-wallet-cli +# monero-wallet-cli VOLUME /wallet ENV LOG_LEVEL 0 @@ -46,4 +41,4 @@ ENV RPC_BIND_PORT 18081 EXPOSE 18080 EXPOSE 18081 -CMD ./monerod --log-level=$LOG_LEVEL --p2p-bind-ip=$P2P_BIND_IP --p2p-bind-port=$P2P_BIND_PORT --rpc-bind-ip=$RPC_BIND_IP --rpc-bind-port=$RPC_BIND_PORT +CMD monerod --log-level=$LOG_LEVEL --p2p-bind-ip=$P2P_BIND_IP --p2p-bind-port=$P2P_BIND_PORT --rpc-bind-ip=$RPC_BIND_IP --rpc-bind-port=$RPC_BIND_PORT @@ -78,7 +78,7 @@ release-static-linux-armv7: release-static-android: mkdir -p build/release - cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG="android"../.. && $(MAKE) + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG="android" ../.. && $(MAKE) release-static-linux-armv8: mkdir -p build/release @@ -138,7 +138,6 @@ library archives (`.a`). | CMake | 3.0.0 | NO | `cmake` | `cmake` | NO | | | pkg-config | any | NO | `pkg-config` | `base-devel` | NO | | | Boost | 1.58 | NO | `libboost-all-dev` | `boost` | NO | C++ libraries | -| libevent | 2.0 | NO | `libevent-dev` | `libevent` | NO | Network IO | | OpenSSL | basically any | NO | `libssl-dev` | `openssl` | NO | sha256 sum | | libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | NO | DNS resolver | | libminiupnpc | 2.0 | YES | `libminiupnpc-dev` | `miniupnpc` | YES | NAT punching | diff --git a/contrib/snap/daemon.bash b/contrib/snap/daemon.bash deleted file mode 100755 index 41d1275de..000000000 --- a/contrib/snap/daemon.bash +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -e - -export LD_LIBRARY_PATH=${SNAP_LIBRARY_PATH}:${SNAP}/usr/lib/x86_64-linux-gnu -export HOME=${SNAP_DATA} -cd ${SNAP_DATA} - -ARGS= -if [ -e "${SNAP_DATA}/etc/monerod.conf" ]; then - ARGS="--config-file ${SNAP_DATA}/etc/monerod.conf" -fi - -exec ${SNAP}/bin/monerod --detach $ARGS diff --git a/contrib/snap/log.bash b/contrib/snap/log.bash deleted file mode 100755 index c81efeb2c..000000000 --- a/contrib/snap/log.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -e - -exec tail -c +0 -F ${SNAP_DATA}/.bitmonero/bitmonero.log diff --git a/contrib/snap/monerod-wrapper b/contrib/snap/monerod-wrapper new file mode 100755 index 000000000..f7266e11c --- /dev/null +++ b/contrib/snap/monerod-wrapper @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ ! -d "$SNAP_USER_DATA/etc" ]; then + mkdir $SNAP_USER_DATA/etc/ + cp -R $SNAP/etc/monerod.conf $SNAP_USER_DATA/etc/monerod.conf +fi + +exec "$SNAP/bin/monerod" "$@" diff --git a/contrib/snap/monerod.conf b/contrib/snap/monerod.conf new file mode 100644 index 000000000..9b3d308ed --- /dev/null +++ b/contrib/snap/monerod.conf @@ -0,0 +1,9 @@ +# Configuration for monerod +# Syntax: any command line option may be specified as 'clioptionname=value'. +# See 'monerod --help' for all available options. + +# Overrided by snap: +# data-dir=/var/lib/monero +# log-file=/var/log/monero/monero.log + +log-level=0 diff --git a/contrib/snap/setup/gui/icon.png b/contrib/snap/setup/gui/icon.png Binary files differnew file mode 100644 index 000000000..17b8bd47b --- /dev/null +++ b/contrib/snap/setup/gui/icon.png diff --git a/snapcraft.yaml b/contrib/snap/snapcraft.yaml index 17910392b..11d480d10 100644 --- a/snapcraft.yaml +++ b/contrib/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: monero -version: 0.10.1 # Current stable version +version: 0.10.2-1 summary: "Monero: the secure, private, untraceable cryptocurrency https://getmonero.org" description: | Monero is a private, secure, untraceable, decentralised digital currency. @@ -12,20 +12,20 @@ apps: monerod: daemon: forking command: | - monerod --detach --data-dir ${SNAP_DATA} + monerod-wrapper --detach --data-dir ${SNAP_COMMON} --config-file ${SNAP_USER_DATA}/etc/monerod.conf plugs: - network - network-bind monero-wallet-rpc: command: | - monero-wallet-rpc --log-file ${SNAP_USER_DATA} + monero-wallet-rpc --log-file ${SNAP_USER_DATA} plugs: - home - network - network-bind monero-wallet-cli: command: | - monero-wallet-cli --log-file ${SNAP_USER_DATA} + monero-wallet-cli --log-file ${SNAP_USER_DATA} plugs: - home - network @@ -63,3 +63,13 @@ parts: - usr/lib/ - -usr/lib/gcc - -usr/share + + dist-files: + plugin: dump + source: . + organize: + contrib/snap/monerod.conf: etc/monerod.conf + contrib/snap/monerod-wrapper: bin/monerod-wrapper + prime: + - etc + - bin diff --git a/contrib/snap/wallet.bash b/contrib/snap/wallet.bash deleted file mode 100755 index 004f1371e..000000000 --- a/contrib/snap/wallet.bash +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -export LD_LIBRARY_PATH=${SNAP_LIBRARY_PATH}:${SNAP}/usr/lib/x86_64-linux-gnu -export HOME=${SNAP_USER_DATA} -cd ${SNAP_USER_DATA} - -exec ${SNAP}/usr/bin/rlwrap ${SNAP}/bin/monero-wallet-cli "$@" @@ -0,0 +1 @@ +contrib/snap
\ No newline at end of file diff --git a/src/common/util.cpp b/src/common/util.cpp index cc2b5b8ff..046961b06 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -587,6 +587,18 @@ std::string get_nix_version_display_string() return 0; } + bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash) + { + SHA256_CTX ctx; + if (!SHA256_Init(&ctx)) + return false; + if (!SHA256_Update(&ctx, data, len)) + return false; + if (!SHA256_Final((unsigned char*)hash.data, &ctx)) + return false; + return true; + } + bool sha256sum(const std::string &filename, crypto::hash &hash) { if (!epee::file_io_utils::is_file_exist(filename)) diff --git a/src/common/util.h b/src/common/util.h index 1d4b3a153..4291d7e18 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -185,5 +185,6 @@ namespace tools bool is_local_address(const std::string &address); int vercmp(const char *v0, const char *v1); // returns < 0, 0, > 0, similar to strcmp, but more human friendly than lexical - does not attempt to validate + bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash); bool sha256sum(const std::string &filename, crypto::hash &hash); } diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 6ccd61f94..a65af3317 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3995,10 +3995,37 @@ void Blockchain::cancel() } #if defined(PER_BLOCK_CHECKPOINT) +static const char expected_block_hashes_hash[] = "23d8a8c73de7b2383c72a016d9a6034e69d62dd48077d1c414e064ceab6daa94"; void Blockchain::load_compiled_in_block_hashes() { if (m_fast_sync && get_blocks_dat_start(m_testnet) != nullptr) { + MINFO("Loading precomputed blocks (" << get_blocks_dat_size(m_testnet) << " bytes)"); + + if (!m_testnet) + { + // first check hash + crypto::hash hash; + if (!tools::sha256sum(get_blocks_dat_start(m_testnet), get_blocks_dat_size(m_testnet), hash)) + { + MERROR("Failed to hash precomputed blocks data"); + return; + } + MINFO("precomputed blocks hash: " << hash << ", expected " << expected_block_hashes_hash); + cryptonote::blobdata expected_hash_data; + if (!epee::string_tools::parse_hexstr_to_binbuff(std::string(expected_block_hashes_hash), expected_hash_data) || expected_hash_data.size() != sizeof(crypto::hash)) + { + MERROR("Failed to parse expected block hashes hash"); + return; + } + const crypto::hash expected_hash = *reinterpret_cast<const crypto::hash*>(expected_hash_data.data()); + if (hash != expected_hash) + { + MERROR("Block hash data does not match expected hash"); + return; + } + } + if (get_blocks_dat_size(m_testnet) > 4) { const unsigned char *p = get_blocks_dat_start(m_testnet); @@ -4006,7 +4033,6 @@ void Blockchain::load_compiled_in_block_hashes() const size_t size_needed = 4 + nblocks * sizeof(crypto::hash); if(nblocks > 0 && nblocks > m_db->height() && get_blocks_dat_size(m_testnet) >= size_needed) { - MINFO("Loading precomputed blocks: " << nblocks); p += sizeof(uint32_t); for (uint32_t i = 0; i < nblocks; i++) { @@ -4015,6 +4041,7 @@ void Blockchain::load_compiled_in_block_hashes() p += sizeof(hash.data); m_blocks_hash_check.push_back(hash); } + MINFO(nblocks << " block hashes loaded"); // FIXME: clear tx_pool because the process might have been // terminated and caused it to store txs kept by blocks. diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 98c53890e..cfe3b5441 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -60,6 +60,8 @@ DISABLE_VS_WARNINGS(4355) #define MERROR_VER(x) MCERROR("verify", x) +#define BAD_SEMANTICS_TXES_MAX_SIZE 100 + namespace cryptonote { @@ -496,11 +498,14 @@ namespace cryptonote } //std::cout << "!"<< tx.vin.size() << std::endl; - if (bad_semantics_txes.find(tx_hash) != bad_semantics_txes.end()) + for (int idx = 0; idx < 2; ++idx) { - LOG_PRINT_L1("Transaction already seen with bad semantics, rejected"); - tvc.m_verifivation_failed = true; - return false; + if (bad_semantics_txes[idx].find(tx_hash) != bad_semantics_txes[idx].end()) + { + LOG_PRINT_L1("Transaction already seen with bad semantics, rejected"); + tvc.m_verifivation_failed = true; + return false; + } } uint8_t version = m_blockchain_storage.get_current_hard_fork_version(); @@ -551,8 +556,13 @@ namespace cryptonote if(!check_tx_semantic(tx, keeped_by_block)) { LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected"); - bad_semantics_txes.insert(tx_hash); tvc.m_verifivation_failed = true; + bad_semantics_txes[0].insert(tx_hash); + if (bad_semantics_txes[0].size() >= BAD_SEMANTICS_TXES_MAX_SIZE) + { + std::swap(bad_semantics_txes[0], bad_semantics_txes[1]); + bad_semantics_txes[0].clear(); + } return false; } diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 114e8393e..7323bef29 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -818,7 +818,6 @@ namespace cryptonote epee::math_helper::once_a_time_seconds<60*2, false> m_txpool_auto_relayer; //!< interval for checking re-relaying txpool transactions epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions - friend class tx_validate_inputs; std::atomic<bool> m_starter_message_showed; //!< has the "daemon will sync now" message been shown? uint64_t m_target_blockchain_height; //!< blockchain height target @@ -833,13 +832,11 @@ namespace cryptonote std::atomic_flag m_checkpoints_updating; //!< set if checkpoints are currently updating to avoid multiple threads attempting to update at once - boost::interprocess::file_lock db_lock; //!< a lock object for a file lock in the db directory - size_t block_sync_size; time_t start_time; - std::unordered_set<crypto::hash> bad_semantics_txes; + std::unordered_set<crypto::hash> bad_semantics_txes[2]; enum { UPDATES_DISABLED, diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 0ce52a3f0..f007a83a8 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -266,6 +266,9 @@ namespace cryptonote return true; uint64_t target = m_core.get_target_blockchain_height(); + if (target == 0) + target = m_core.get_current_blockchain_height(); + if(m_core.have_block(hshd.top_id)) { context.m_state = cryptonote_connection_context::state_normal; @@ -280,7 +283,6 @@ namespace cryptonote I prefer pushing target height to the core at the same time it is pushed to the user. Nz. */ m_core.set_target_blockchain_height(static_cast<int64_t>(hshd.current_height)); - int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_height()); int64_t max_block_height = max(static_cast<int64_t>(hshd.current_height),static_cast<int64_t>(m_core.get_current_blockchain_height())); int64_t last_block_v1 = 1009826; diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 2bb4196af..8daaac611 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -51,6 +51,13 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>& return m_executor.print_peer_list(); } +bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args) +{ + if (!args.empty()) return false; + + return m_executor.print_peer_list_stats(); +} + bool t_command_parser_executor::save_blockchain(const std::vector<std::string>& args) { if (!args.empty()) return false; diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 3ea2b923a..37f431974 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -59,6 +59,8 @@ public: bool print_peer_list(const std::vector<std::string>& args); + bool print_peer_list_stats(const std::vector<std::string>& args); + bool save_blockchain(const std::vector<std::string>& args); bool show_hash_rate(const std::vector<std::string>& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 90142f2fb..4a063268f 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -69,6 +69,11 @@ t_command_server::t_command_server( , "Print peer list" ); m_command_lookup.set_handler( + "print_pl_stats" + , std::bind(&t_command_parser_executor::print_peer_list_stats, &m_parser, p::_1) + , "Print peer list stats" + ); + m_command_lookup.set_handler( "print_cn" , std::bind(&t_command_parser_executor::print_connections, &m_parser, p::_1) , "Print connections" diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index a3d9eb52a..b33736839 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -162,6 +162,34 @@ bool t_rpc_command_executor::print_peer_list() { return true; } +bool t_rpc_command_executor::print_peer_list_stats() { + cryptonote::COMMAND_RPC_GET_PEER_LIST::request req; + cryptonote::COMMAND_RPC_GET_PEER_LIST::response res; + + std::string failure_message = "Couldn't retrieve peer list"; + if (m_is_rpc) + { + if (!m_rpc_client->rpc_request(req, res, "/get_peer_list", failure_message.c_str())) + { + return false; + } + } + else + { + if (!m_rpc_server->on_get_peer_list(req, res) || res.status != CORE_RPC_STATUS_OK) + { + tools::fail_msg_writer() << failure_message; + return false; + } + } + + tools::msg_writer() + << "White list size: " << res.white_list.size() << "/" << P2P_LOCAL_WHITE_PEERLIST_LIMIT << " (" << res.white_list.size() * 100.0 / P2P_LOCAL_WHITE_PEERLIST_LIMIT << "%)" << std::endl + << "Gray list size: " << res.gray_list.size() << "/" << P2P_LOCAL_GRAY_PEERLIST_LIMIT << " (" << res.gray_list.size() * 100.0 / P2P_LOCAL_GRAY_PEERLIST_LIMIT << "%)"; + + return true; +} + bool t_rpc_command_executor::save_blockchain() { cryptonote::COMMAND_RPC_SAVE_BC::request req; cryptonote::COMMAND_RPC_SAVE_BC::response res; diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index 39db75a80..eb95101ce 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -72,6 +72,8 @@ public: bool print_peer_list(); + bool print_peer_list_stats(); + bool save_blockchain(); bool show_hash_rate(); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index ab17dfaf3..d79621de4 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -665,7 +665,7 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res) { - CHECK_CORE_READY(); + CHECK_CORE_BUSY(); const miner& lMiner = m_core.get_miner(); res.active = lMiner.is_mining(); diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp index 79f3f7e12..4435f74d1 100644 --- a/src/rpc/rpc_args.cpp +++ b/src/rpc/rpc_args.cpp @@ -37,7 +37,7 @@ namespace cryptonote rpc_args::descriptors::descriptors() : rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("Specify ip to bind rpc server"), "127.0.0.1"}) , rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true}) - , confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rcp-bind-ip value is NOT a loopback (local) IP")}) + , confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rpc-bind-ip value is NOT a loopback (local) IP")}) {} const char* rpc_args::tr(const char* str) { return i18n_translate(str, "cryptonote::rpc_args"); } |