diff options
-rw-r--r-- | CMakeLists.txt | 93 | ||||
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | cmake/MergeStaticLibs.cmake | 129 | ||||
-rw-r--r-- | src/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.cpp | 5 | ||||
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.h | 2 | ||||
-rw-r--r-- | src/blockchain_db/blockchain_db.h | 3 | ||||
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 9 | ||||
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 10 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 9 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 5 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 2 | ||||
-rw-r--r-- | src/daemon/command_server.cpp | 2 | ||||
-rw-r--r-- | src/wallet/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 6 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 34 | ||||
-rw-r--r-- | tests/daemon_tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/libwallet_api_tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/net_load_tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/unit_tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/unit_tests/hardfork.cpp | 2 |
23 files changed, 172 insertions, 190 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ff1590860..fb587f9a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,11 @@ if (ARM_TEST STREQUAL "arm") endif() endif() +if (ARCH_ID STREQUAL "aarch64") + set(ARM 1) + set(ARM8 1) +endif() + if(WIN32 OR ARM) set(OPT_FLAGS_RELEASE "-O2") else() @@ -367,23 +372,89 @@ else() message(STATUS "AES support enabled") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") - elseif(ARM) + elseif(ARM) #NB ARMv8 DOES support AES, but not yet coded message(STATUS "AES support disabled (not available on ARM)") else() message(STATUS "AES support disabled") endif() - if(ARM6) - message(STATUS "Setting ARM6 C and C++ flags") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp -mfloat-abi=hard") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp -mfloat-abi=hard") - endif() + if(ARM) + message(STATUS "Setting FPU Flags for ARM Processors") + include(TestCXXAcceptsFlag) + + #NB NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic + #Need custom assembly code to take full advantage of NEON SIMD + + #Cortex-A5/9 -mfpu=neon-fp16 + #Cortex-A7/15 -mfpu=neon-vfpv4 + #Cortex-A8 -mfpu=neon + #ARMv8 -FP and SIMD on by default for all ARM8v-a series, NO -mfpu setting needed + + #For custom -mtune, processor IDs for ARMv8-A series: + #0xd04 - Cortex-A35 + #0xd07 - Cortex-A57 + #0xd08 - Cortex-A72 + #0xd03 - Cortex-A73 + + if(NOT ARM8) + CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp3-d16 CXX_ACCEPTS_VFP3_D16) + CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp4 CXX_ACCEPTS_VFP4) + CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=hard CXX_ACCEPTS_MFLOAT_HARD) + CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=softfp CXX_ACCEPTS_MFLOAT_SOFTFP) + endif() - if(ARM7) - message(STATUS "Setting ARM7 C and C++ flags") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") - endif() + if(ARM8) + CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-835769 CXX_ACCEPTS_MFIX_CORTEX_A53_835769) + CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-843419 CXX_ACCEPTS_MFIX_CORTEX_A53_843419) + endif() + + if(ARM6) + message(STATUS "Selecting VFP for ARMv6") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp") + endif(ARM6) + + if(ARM7) + if(CXX_ACCEPTS_VFP3_D16 AND NOT CXX_ACCEPTS_VFP4) + message(STATUS "Selecting VFP3 for ARMv7") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp3-d16") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp3-d16") + endif() + + if(CXX_ACCEPTS_VFP4) + message(STATUS "Selecting VFP4 for ARMv7") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp4") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp4") + endif() + + if(CXX_ACCEPTS_MFLOAT_HARD) + message(STATUS "Setting Hardware ABI for Floating Point") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") + endif() + + if(CXX_ACCEPTS_MFLOAT_SOFTFP AND NOT CXX_ACCEPTS_MFLOAT_HARD) + message(STATUS "Setting Software ABI for Floating Point") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=softfp") + endif() + endif(ARM7) + + if(ARM8) + if(CXX_ACCEPTS_MFIX_CORTEX_A53_835769) + message(STATUS "Enabling Cortex-A53 workaround 835769") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-835769") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-835769") + endif() + + if(CXX_ACCEPTS_MFIX_CORTEX_A53_843419) + message(STATUS "Enabling Cortex-A53 workaround 843419") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-843419") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-843419") + endif() + endif(ARM8) + + endif(ARM) if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") @@ -1,21 +1,21 @@ # Copyright (c) 2014-2016, The Monero Project -# +# # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without modification, are # permitted provided that the following conditions are met: -# +# # 1. Redistributions of source code must retain the above copyright notice, this list of # conditions and the following disclaimer. -# +# # 2. Redistributions in binary form must reproduce the above copyright notice, this list # of conditions and the following disclaimer in the documentation and/or other # materials provided with the distribution. -# +# # 3. Neither the name of the copyright holder nor the names of its contributors may be # used to endorse or promote products derived from this software without specific # prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -65,7 +65,11 @@ release-static-arm6: release-static-arm7: 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 ../.. && $(MAKE) - + +release-static-armv8: + mkdir -p build/release + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + release-static: release-static-64 release-static-64: @@ -89,7 +89,6 @@ Packaging for your favorite distribution would be a welcome contribution! * pkg-config * libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is) * libevent `>=2.0` -* libgtest `>=1.5` * Boost `>=1.58` * BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev) * libunwind (optional, for stack trace on exception) @@ -97,6 +96,7 @@ Packaging for your favorite distribution would be a welcome contribution! * ldns `>=1.6.17` (optional, for statically-linked binaries) * expat `>=1.1` (optional, for statically-linked binaries) * bison or yacc (optional, for statically-linked binaries) +* GTest `>=1.5` (optional, for running test suite) (NOTE: `libgtest-dev` package in Ubuntu ships without binaries and requires a manual build; `gtest` on Arch includes binaries) * Doxygen (optional, for generating documentation) * graphviz (optional, for generating documentation) @@ -207,7 +207,8 @@ By default, in either dynamically or statically linked builds, binaries target t * ```make release-static-64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors * ```make release-static-32``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors -* ```make release-static-arm7``` builds binaries on Linux on armv7 portable across POSIX systesm on armv7 processors +* ```make release-static-arm8``` builds binaries on Linux on armv8 portable across POSIX systems on armv8 processors +* ```make release-static-arm7``` builds binaries on Linux on armv7 portable across POSIX systems on armv7 processors * ```make release-static-arm6``` builds binaries on Linux on armv7 or armv6 portable across POSIX systems on armv6 processors, such as the Raspberry Pi * ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems * ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems diff --git a/cmake/MergeStaticLibs.cmake b/cmake/MergeStaticLibs.cmake deleted file mode 100644 index 858a026a3..000000000 --- a/cmake/MergeStaticLibs.cmake +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (C) 2012 Modelon AB - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the BSD style license. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# FMILIB_License.txt file for more details. - -# You should have received a copy of the FMILIB_License.txt file -# along with this program. If not, contact Modelon AB <http://www.modelon.com>. - -# Merge_static_libs(outlib lib1 lib2 ... libn) merges a number of static -# libs into a single static library -function(merge_static_libs outlib ) - set(libs ${ARGV}) - list(REMOVE_AT libs 0) -# Create a dummy file that the target will depend on - set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c) - file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") - - add_library(${outlib} STATIC ${dummyfile}) - - if("${CMAKE_CFG_INTDIR}" STREQUAL ".") - set(multiconfig FALSE) - else() - set(multiconfig TRUE) - endif() - -# First get the file names of the libraries to be merged - foreach(lib ${libs}) - get_target_property(libtype ${lib} TYPE) - if(NOT libtype STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "Merge_static_libs can only process static libraries") - endif() - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}") - list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}}) - endforeach() - else() - get_target_property(libfile ${lib} LOCATION) - list(APPEND libfiles "${libfile}") - endif(multiconfig) - endforeach() - message(STATUS "will be merging ${libfiles}") -# Just to be sure: cleanup from duplicates - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE}) - set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}}) - endforeach() - endif() - list(REMOVE_DUPLICATES libfiles) - -# Now the easy part for MSVC and for MAC - if(MSVC) - # lib.exe does the merging of libraries just need to conver the list into string - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - set(flags "") - foreach(lib ${libfiles_${CONFIG_TYPE}}) - set(flags "${flags} ${lib}") - endforeach() - string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) - set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}") - endforeach() - - elseif(APPLE) - # Use OSX's libtool to merge archives - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND rm ${outfile} - COMMAND /usr/bin/libtool -static -o ${outfile} - ${libfiles} - ) - else() - # general UNIX - need to "ar -x" and then "ar -ru" - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - message(STATUS "outfile location is ${outfile}") - foreach(lib ${libfiles}) -# objlistfile will contain the list of object files for the library - set(objlistfile ${lib}.objlist) - set(objdir ${lib}.objdir) - set(objlistcmake ${objlistfile}.cmake) -# we only need to extract files once - if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake}) -#--------------------------------- - FILE(WRITE ${objlistcmake} -"# Extract object files from the library -message(STATUS \"Extracting object files from ${lib}\") -EXECUTE_PROCESS(COMMAND ${CMAKE_AR} -x ${lib} - WORKING_DIRECTORY ${objdir}) -# save the list of object files -EXECUTE_PROCESS(COMMAND ls . - OUTPUT_FILE ${objlistfile} - WORKING_DIRECTORY ${objdir})") -#--------------------------------- - file(MAKE_DIRECTORY ${objdir}) - add_custom_command( - OUTPUT ${objlistfile} - COMMAND ${CMAKE_COMMAND} -P ${objlistcmake} - DEPENDS ${lib}) - endif() - list(APPEND extrafiles "${objlistfile}") - # relative path is needed by ar under MSYS - file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile}) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}" - COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}" - WORKING_DIRECTORY ${objdir}) - endforeach() - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}" - COMMAND ${CMAKE_RANLIB} ${outfile}) - endif() - file(WRITE ${dummyfile}.base "const char* ${outlib}_sublibs=\"${libs}\";") - add_custom_command( - OUTPUT ${dummyfile} - COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile} - DEPENDS ${libs} ${extrafiles}) - - endfunction()
\ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70bb215d0..5a79325ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,8 +82,13 @@ function (bitmonero_add_library name) FILES ${ARGN}) - add_library("${name}" - ${ARGN}) + # Define a ("virtual") object library and an actual library that links those + # objects together. The virtual libraries can be arbitrarily combined to link + # any subset of objects into one library archive. This is used for releasing + # libwallet, which combines multiple components. + set(objlib obj_${name}) + add_library(${objlib} OBJECT ${ARGN}) + add_library("${name}" STATIC $<TARGET_OBJECTS:${objlib}>) set_property(TARGET "${name}" PROPERTY FOLDER "libs") diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index 4ec284e38..137ed9dc6 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -1235,7 +1235,7 @@ void BlockchainBDB::unlock() check_open(); } -bool BlockchainBDB::block_exists(const crypto::hash& h) const +bool BlockchainBDB::block_exists(const crypto::hash& h, uint64_t *height) const { LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); @@ -1251,6 +1251,9 @@ bool BlockchainBDB::block_exists(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR("DB error attempting to fetch block index from hash")); + if (height) + *height = get_result - 1; + return true; } diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index f8e9440bd..f320ab0e3 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -250,7 +250,7 @@ public: virtual void unlock(); - virtual bool block_exists(const crypto::hash& h) const; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const; virtual block get_block(const crypto::hash& h) const; diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index d26080a3b..5b6a793d8 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -736,10 +736,11 @@ public: * @brief checks if a block exists * * @param h the hash of the requested block + * @param height if non NULL, returns the block's height if found * * @return true of the block exists, otherwise false */ - virtual bool block_exists(const crypto::hash& h) const = 0; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const = 0; /** * @brief fetches the block with the given hash diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index c0cf28dda..8ad875fc8 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -1387,7 +1387,7 @@ void BlockchainLMDB::unlock() auto_txn.commit(); \ } while(0) -bool BlockchainLMDB::block_exists(const crypto::hash& h) const +bool BlockchainLMDB::block_exists(const crypto::hash& h, uint64_t *height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1405,7 +1405,14 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR(lmdb_error("DB error attempting to fetch block index from hash", get_result).c_str())); else + { + if (height) + { + const blk_height *bhp = (const blk_height *)key.mv_data; + *height = bhp->bh_height; + } ret = true; + } TXN_POSTFIX_RDONLY(); return ret; diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 050e9e0ae..9df4b86d1 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -168,7 +168,7 @@ public: virtual void unlock(); - virtual bool block_exists(const crypto::hash& h) const; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const; virtual block get_block(const crypto::hash& h) const; diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 07db59796..b15eb4b90 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1801,12 +1801,8 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc { try { - split_height = m_db->get_block_height(*bl_it); - break; - } - catch (const BLOCK_DNE& e) - { - continue; + if (m_db->block_exists(*bl_it, &split_height)) + break; } catch (const std::exception& e) { @@ -3378,7 +3374,7 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync) store_blockchain(); m_sync_counter = 0; } - else if (m_sync_counter >= m_db_blocks_per_sync) + else if (m_db_blocks_per_sync && m_sync_counter >= m_db_blocks_per_sync) { if(m_db_sync_mode == db_async) { diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 73edde1b7..f5445b48a 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -372,11 +372,10 @@ namespace cryptonote if(options.size() >= 3 && !safemode) { - blocks_per_sync = atoll(options[2].c_str()); - if(blocks_per_sync > 5000) - blocks_per_sync = 5000; - if(blocks_per_sync == 0) - blocks_per_sync = 1; + char *endptr; + uint64_t bps = strtoull(options[2].c_str(), &endptr, 0); + if (*endptr == '\0') + blocks_per_sync = bps; } bool auto_remove_logs = command_line::get_arg(vm, command_line::arg_db_auto_remove_logs) != 0; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 6f095a76f..81d96d5bf 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -277,8 +277,11 @@ namespace cryptonote 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; + int64_t diff_v2 = max_block_height > last_block_v1 ? min(abs(diff), max_block_height - last_block_v1) : 0; LOG_PRINT_CCONTEXT_YELLOW("Sync data returned unknown top block: " << m_core.get_current_blockchain_height() << " -> " << hshd.current_height - << " [" << std::abs(diff) << " blocks (" << diff / (24 * 60 * 60 / DIFFICULTY_TARGET_V1) << " days) " + << " [" << std::abs(diff) << " blocks (" << ((abs(diff) - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) " << (0 <= diff ? std::string("behind") : std::string("ahead")) << "] " << ENDL << "SYNCHRONIZATION started", (is_inital ? LOG_LEVEL_0:LOG_LEVEL_1)); LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id); diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 166fe04ca..00ea6ef6c 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -225,7 +225,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg { if(!args.size()) { - std::cout << "Please specify a wallet address to mine for: start_mining <addr> [threads=1]" << std::endl; + std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>]" << std::endl; return true; } diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index aabc2f09a..ce8ac44fc 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -92,7 +92,7 @@ t_command_server::t_command_server( m_command_lookup.set_handler( "start_mining" , std::bind(&t_command_parser_executor::start_mining, &m_parser, p::_1) - , "Start mining for specified address, start_mining <addr> [threads=1]" + , "Start mining for specified address, start_mining <addr> [<threads>], default 1 thread" ); m_command_lookup.set_handler( "stop_mining" diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index c4585f9ee..48e4b0a23 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -27,7 +27,6 @@ # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # include (${PROJECT_SOURCE_DIR}/cmake/libutils.cmake) -include (${PROJECT_SOURCE_DIR}/cmake/MergeStaticLibs.cmake) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -76,7 +75,11 @@ target_link_libraries(wallet ${EXTRA_LIBRARIES}) set(libs_to_merge wallet cryptonote_core mnemonics common crypto) -merge_static_libs(wallet_merged "${libs_to_merge}") + +foreach(lib ${libs_to_merge}) + list(APPEND objlibs $<TARGET_OBJECTS:obj_${lib}>) # matches naming convention in src/CMakeLists.txtA +endforeach() +add_library(wallet_merged STATIC ${objlibs}) install(TARGETS wallet_merged ARCHIVE DESTINATION lib) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d889720af..c6e2411b6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2709,6 +2709,8 @@ void wallet2::get_outs(std::vector<std::vector<entry>> &outs, const std::list<tr } } LOG_PRINT_L1("" << num_outs << " outputs of size " << print_money(amount)); + THROW_WALLET_EXCEPTION_IF(num_outs == 0, error::wallet_internal_error, + "histogram reports no outputs for " + boost::lexical_cast<std::string>(amount) + ", not even ours"); if (num_outs <= requested_outputs_count) { @@ -3468,7 +3470,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp return ptx_vector; } -std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon) +std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon) { std::vector<size_t> unused_transfers_indices; std::vector<size_t> unused_dust_indices; @@ -3485,6 +3487,8 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit(); const bool use_rct = use_fork_rules(4, 0); + fee_multiplier = sanitize_fee_multiplier(fee_multiplier); + // gather all our dust and non dust outputs for (size_t i = 0; i < m_transfers.size(); ++i) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 33f5226ef..33d6c233d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,9 @@ # # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +# The docs say this only affects grouping in IDEs +set(folder "tests") + if (WIN32 AND STATIC) add_definitions(-DSTATICLIB) # miniupnp changed their static define @@ -39,19 +42,24 @@ find_package(GTest) if (GTest_FOUND) include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) else () + message(STATUS "GTest not found on the system: will use GTest bundled with this source") add_subdirectory(gtest) include_directories(SYSTEM "${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}") # Emulate the FindGTest module's variable. - set(GTEST_MAIN_LIBRARIES gtest_main) + set(GTEST_LIBRARIES gtest) # Ignore some warnings when building gtest binaries. if(NOT MSVC) - set_property(TARGET gtest gtest_main + set_property(TARGET gtest APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") endif() + + set_property(TARGET gtest + PROPERTY + FOLDER "${folder}") endif () if (NOT DEFINED ENV{TRAVIS}) @@ -84,17 +92,23 @@ target_link_libraries(hash-target-tests cryptonote_core) set_property(TARGET hash-target-tests PROPERTY - FOLDER "tests") + FOLDER "${folder}") add_test( NAME hash-target COMMAND hash-target-tests) -# Skip the core_tests if we are running in Travis-CI because they will take too long -if (DEFINED ENV{TRAVIS}) - add_custom_target(tests DEPENDS difficulty hash performance_tests core_proxy unit_tests) -else () - add_custom_target(tests DEPENDS coretests difficulty hash performance_tests core_proxy unit_tests) -endif () +set(enabled_tests + difficulty + hash + performance_tests + core_proxy + unit_tests) + +# Skip the core_tests in Travis-CI because they will take too long +if (NOT DEFINED ENV{TRAVIS}) + list(APPEND enabled_tests coretests) +endif() -set_property(TARGET gtest gtest_main hash-target-tests tests PROPERTY FOLDER "tests") +add_custom_target(tests DEPENDS enabled_tests) +set_property(TARGET tests PROPERTY FOLDER "${folder}") diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt index 25ca09ce4..ae11ab5d5 100644 --- a/tests/daemon_tests/CMakeLists.txt +++ b/tests/daemon_tests/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries(transfers crypto common epee - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_LIBRARIES}) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_transfers") diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt index e60947084..416192cce 100644 --- a/tests/libwallet_api_tests/CMakeLists.txt +++ b/tests/libwallet_api_tests/CMakeLists.txt @@ -40,7 +40,7 @@ add_executable(libwallet_api_tests target_link_libraries(libwallet_api_tests LINK_PRIVATE wallet - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${EXTRA_LIBRARIES}) set_property(TARGET libwallet_api_tests diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt index c3a68d18d..2c97acf51 100644 --- a/tests/net_load_tests/CMakeLists.txt +++ b/tests/net_load_tests/CMakeLists.txt @@ -40,7 +40,7 @@ target_link_libraries(net_load_tests_clt otshell_utils p2p cryptonote_core - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} @@ -62,7 +62,7 @@ target_link_libraries(net_load_tests_srv otshell_utils p2p cryptonote_core - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 3d42809e3..d36c2748c 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -69,7 +69,7 @@ target_link_libraries(unit_tests rpc wallet p2p - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index a279b6c68..b3bd47687 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -58,7 +58,7 @@ public: virtual void block_txn_stop() {} virtual void block_txn_abort() {} virtual void drop_hard_fork_info() {} - virtual bool block_exists(const crypto::hash& h) const { return false; } + virtual bool block_exists(const crypto::hash& h, uint64_t *height) const { return false; } virtual block get_block(const crypto::hash& h) const { return block(); } virtual uint64_t get_block_height(const crypto::hash& h) const { return 0; } virtual block_header get_block_header(const crypto::hash& h) const { return block_header(); } |