Compare commits

..

26 Commits

Author SHA1 Message Date
wowario
3e302be710 Merge pull request 'upstream' (#494) from wowario/wownero:upstream into master
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/494
2024-12-15 21:38:34 +00:00
nsec1
b4ea97713d fix zmq and sodium include dirs search 2024-12-15 23:51:09 +03:00
tobtoht
3e5fbb4fec wallet2: fix error throw if unable to load cache 2024-12-15 23:49:04 +03:00
Lee Clagett
178f454742 Relax static_asserts in src/lmdb 2024-12-15 23:47:57 +03:00
Lee *!* Clagett
345be3361e Add byte_stream value_type and data() 2024-12-15 23:46:16 +03:00
Lee *!* Clagett
5ad6661274 Fix memcpy in byte_slice constructor 2024-12-15 23:40:56 +03:00
0xFFFC0000
cd1de16fc2 Daemon-specific proxy for the wallet-rpc.
1. Daemon-specific proxy is exclusive with global proxy (--proxy).
2. If you set global proxy (--proxy) you cannot set daemon-specific proxy.
3. If you don't set global proxy, you can set proxy (or not set) proxy for
each daemon connection with the proxy field in jsonrpc to the wallet-rpc.
2024-12-15 23:39:48 +03:00
0xFFFC0000
c9d4dd1082 simplewallet: add header to show_transfers command 2024-12-15 23:37:37 +03:00
wowario
7d44e42dde Merge pull request 'Decoy selection fix' (#489) from wowario/wownero:decoy-fix into master
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/489
2024-12-15 20:30:27 +00:00
jeffro256
6481a9ba5e Blockchain: fix temp fails causing alt blocks to be permanently invalid 2024-12-15 19:55:18 +03:00
jeffro256
e5dc1f749f epee: partially revert c56ee140 to fix linking errors
On Linux Mint 21.3, g++ Ubuntu 11.4.0-1ubuntu1~22.04, I get linking error for an undefined reference to `epee::string_tools::trim_right`. This PR reverts the changes
to epee_readline.cpp in commit c56ee140, which turns a `boost::trim_right` callsite into an `epee::string_tools::trim_right` callsite.
2024-12-15 19:52:38 +03:00
0xFFFC0000
7d01e5fa30 wallet: report exact reason for open_wallet failure. 2024-12-15 19:51:50 +03:00
0xFFFC0000
f603c70a5f contrib: force (de)serialization to create params section incase there is none.
Co-authored-by: Boog900 <boog900@tutanota.com>
2024-12-15 19:51:27 +03:00
jeffro256
d807ab95f1 p2p: allow comments in banlist files
In-line comments explicitly explaining banned hosts/subnets might help assuage fears of some good banlists' arbitaryiness.
2024-12-15 19:50:53 +03:00
wowario
b79968a7d8 Merge pull request 'add gcc13 dependency' (#493) from wowario/wownero:gcc into master
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/493
2024-12-15 16:14:47 +00:00
wowario
c7fc4993cb add gcc13 dependency 2024-12-15 19:11:34 +03:00
wowario
4b4882082e Merge pull request 'Update checkpoints and bump version' (#492) from wowario/wownero:checkpoints into master
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/492
2024-12-15 13:20:19 +00:00
wowario
2f7d418bda bump version 2024-12-15 10:50:17 +03:00
wowario
2d01af02ef update checkpoints 2024-12-15 10:49:25 +03:00
wowario
1ff387c933 cmake: boost: fix header-only library search, bump minimum (#491)
Co-authored-by: tobtoht <tob@featherwallet.org>
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/491
2024-12-15 07:25:29 +00:00
wowario
054abe1fa4 Merge pull request 'Revert Miniupnpc commits for gitian builds' (#490) from wowario/wownero:revert into master
Reviewed-on: https://codeberg.org/wownero/wownero/pulls/490
2024-12-15 07:24:16 +00:00
wowario
d6e7550793 Revert "cmake: add different parameters to add_monero_library."
This reverts commit 4bbad537aa.
2024-12-15 10:00:02 +03:00
wowario
194b88bf4f Revert "cmake: remove extera cmake/FindMiniupnpc.cmake and only rely on external/miniupnpc."
This reverts commit 31f5bc908d.
2024-12-15 09:59:35 +03:00
wowario
50c24fb1bb Revert "external: update miniupnpc to 2.2.8"
This reverts commit 5fe3cf2349.
2024-12-15 09:58:58 +03:00
wowario
60386e7cf4 RingCT start height 2024-12-14 09:56:43 +03:00
wowario
ff0fb4b6ed revert revert sanity check 2024-12-14 09:53:01 +03:00
30 changed files with 401 additions and 114 deletions

View File

@@ -644,7 +644,7 @@ function (monero_add_library name)
endfunction()
function (monero_add_library_with_deps)
cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;LINKS;PRIVATE_LINKS;INCLUDES;PRIVATE_INCLUDES;SOURCES" ${ARGN})
cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN})
source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES})
# Define a ("virtual") object library and an actual library that links those
@@ -659,22 +659,6 @@ function (monero_add_library_with_deps)
if (MONERO_ADD_LIBRARY_DEPENDS)
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
endif()
if (MONERO_ADD_LIBRARY_LINKS)
target_link_libraries(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_LINKS})
target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_LINKS})
endif()
if (MONERO_ADD_LIBRARY_PRIVATE_LINKS)
target_link_libraries(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS})
target_link_libraries(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_LINKS})
endif()
if (MONERO_ADD_LIBRARY_INCLUDES)
target_include_directories(${objlib} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES})
target_include_directories(${MONERO_ADD_LIBRARY_NAME} PUBLIC ${MONERO_ADD_LIBRARY_INCLUDES})
endif()
if (MONERO_ADD_LIBRARY_PRIVATE_INCLUDES)
target_include_directories(${objlib} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES})
target_include_directories(${MONERO_ADD_LIBRARY_NAME} PRIVATE ${MONERO_ADD_LIBRARY_PRIVATE_INCLUDES})
endif()
set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
target_compile_definitions(${objlib}
PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
@@ -1092,29 +1076,39 @@ if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options locale)
# Find Boost headers
set(BOOST_MIN_VER 1.62)
find_package(Boost ${BOOST_MIN_VER} QUIET REQUIRED)
if(NOT Boost_FOUND)
die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (>=${BOOST_MIN_VER}) or the equivalent")
elseif(Boost_FOUND)
message(STATUS "Found Boost Version: ${Boost_VERSION_STRING}")
set(BOOST_COMPONENTS filesystem thread date_time chrono serialization program_options locale)
# Boost System is header-only since 1.69
if (Boost_VERSION_STRING VERSION_LESS 1.69.0)
list(APPEND BOOST_COMPONENTS system)
endif()
# Boost Regex is header-only since 1.77
if (Boost_VERSION_STRING VERSION_LESS 1.77.0)
list(APPEND BOOST_COMPONENTS regex)
endif()
message(STATUS "Boost components: ${BOOST_COMPONENTS}")
# Find required Boost libraries
find_package(Boost ${BOOST_MIN_VER} QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
endif()
add_definitions(-DBOOST_ASIO_ENABLE_SEQUENTIAL_STRAND_ALLOCATION)
add_definitions(-DBOOST_NO_AUTO_PTR)
add_definitions(-DBOOST_UUID_DISABLE_ALIGNMENT) # This restores UUID's std::has_unique_object_representations property
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND)
die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (>=1.58) or the equivalent")
elseif(Boost_FOUND)
message(STATUS "Found Boost Version: ${Boost_VERSION}")
if (Boost_VERSION VERSION_LESS 10 AND Boost_VERSION VERSION_LESS 1.62.0 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1))
set(BOOST_BEFORE_1_62 true)
endif()
if (NOT Boost_VERSION VERSION_LESS 10 AND Boost_VERSION VERSION_LESS 106200 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1))
set(BOOST_BEFORE_1_62 true)
endif()
if (BOOST_BEFORE_1_62)
message(FATAL_ERROR "Boost ${Boost_VERSION} (older than 1.62) is too old to link with OpenSSL ${OPENSSL_VERSION} (1.1 or newer) found at ${OPENSSL_INCLUDE_DIR} and ${OPENSSL_LIBRARIES}. "
"Update Boost or install OpenSSL 1.0 and set path to it when running cmake: "
"cmake -DOPENSSL_ROOT_DIR='/usr/include/openssl-1.0'")
endif()
endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
@@ -1207,6 +1201,7 @@ endif()
if(NOT ZMQ_LIB)
message(FATAL_ERROR "Could not find required libzmq")
endif()
include_directories(${ZMQ_INCLUDE_PATH})
if(PGM_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${PGM_LIBRARY}")
endif()
@@ -1220,7 +1215,15 @@ if(PROTOLIB_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${PROTOLIB_LIBRARY}")
endif()
if(SODIUM_LIBRARY)
message(STATUS "ZMQ_LIB: ${ZMQ_LIB};${SODIUM_LIBRARY}")
set(ZMQ_LIB "${ZMQ_LIB};${SODIUM_LIBRARY}")
find_path(SODIUM_INCLUDE_PATH sodium/crypto_verify_32.h)
if (SODIUM_INCLUDE_PATH)
message(STATUS "SODIUM_INCLUDE_PATH: ${SODIUM_INCLUDE_PATH}")
include_directories(${SODIUM_INCLUDE_PATH})
else()
message(FATAL_ERROR "Could not find required sodium/crypto_verify_32.h")
endif()
endif()
if(BSD_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${BSD_LIBRARY}")

View File

@@ -89,7 +89,7 @@ Dates are provided in the format YYYY-MM-DD.
| - | 2020-06-28 | Hallucinogenic Hypnotoad | v0.8.0.0 | v0.8.0.2 | Dandelion++ support
| 253,999 | 2020-10-09 | Illiterate Illuminati | v0.9.0.0 | v0.9.3.3 | Dynamic coinbase unlock (up to 1 mo.), Deterministic unlock times, Enforce maximum coinbase amount, show_qr_code wallet command, CLSAG
| 331,170 | 2021-07-04 | Junkie Jeff | v0.10.0.0 | v0.10.2.0 | Bulletproofs+, Miner Block Header Signing, Vote by Block, Change coinbase unlock time to 1 day, Reset difficulty and switch back to Monero's difficulty algorithm
| 514,000 | 2023-04-01 | Kunty Karen | v0.11.0.0 | v0.11.2.0 | View tags, fee changes, adjusted dynamic block weight algorithm, multisig security fixes, RPC broadcast node donation sub-address, Limit tx_extra max size to ~1kb, 12-hour difficulty adjustment window
| 514,000 | 2023-04-01 | Kunty Karen | v0.11.0.0 | v0.11.3.0 | View tags, fee changes, adjusted dynamic block weight algorithm, multisig security fixes, RPC broadcast node donation sub-address, Limit tx_extra max size to ~1kb, 12-hour difficulty adjustment window
X's indicate that these details have not been determined as of commit date.
@@ -128,15 +128,16 @@ Packaging for your favorite distribution would be a welcome contribution!
* Arch Linux/Manjaro
sudo pacman -Syu --needed base-devel cmake boost openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd
sudo pacman -Syu --needed base-devel cmake boost openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd gcc13
git clone https://codeberg.org/wownero/wownero && cd wownero
export CC=gcc-13 CXX=g++-13
make -j2
* Debian/Ubuntu
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz
sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz gcc-13 g++-13
git clone https://codeberg.org/wownero/wownero && cd wownero
make -j2
CC="gcc-13" CXX="g++-13" make -j2
## Running Binaries

59
cmake/FindMiniupnpc.cmake Normal file
View File

@@ -0,0 +1,59 @@
# --------------------------------- FindMiniupnpc Start ---------------------------------
# Locate miniupnp library
# This module defines
# MINIUPNP_FOUND, if false, do not try to link to miniupnp
# MINIUPNP_LIBRARY, the miniupnp variant
# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
# MINIUPNPC_VERSION_1_7_OR_HIGHER, set if we detect the version of miniupnpc is 1.7 or higher
#
# Note that the expected include convention is
# #include "miniupnpc.h"
# and not
# #include <miniupnpc/miniupnpc.h>
# This is because, the miniupnpc location is not standardized and may exist
# in locations other than miniupnpc/
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
# Already in cache, be silent
set(MINIUPNP_FIND_QUIETLY TRUE)
endif ()
find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
HINTS $ENV{MINIUPNP_INCLUDE_DIR}
PATH_SUFFIXES miniupnpc
)
find_library(MINIUPNP_LIBRARY miniupnpc
HINTS $ENV{MINIUPNP_LIBRARY}
)
find_library(MINIUPNP_STATIC_LIBRARY libminiupnpc.a
HINTS $ENV{MINIUPNP_STATIC_LIBRARY}
)
set(MINIUPNP_INCLUDE_DIRS ${MINIUPNP_INCLUDE_DIR})
set(MINIUPNP_LIBRARIES ${MINIUPNP_LIBRARY})
set(MINIUPNP_STATIC_LIBRARIES ${MINIUPNP_STATIC_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
MiniUPnPc DEFAULT_MSG
MINIUPNP_INCLUDE_DIR
MINIUPNP_LIBRARY
)
IF(MINIUPNPC_FOUND)
file(STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+")
if(MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)")
set(MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}")
if (${MINIUPNPC_API_VERSION} GREATER "10" OR ${MINIUPNPC_API_VERSION} EQUAL "10")
message(STATUS "Found miniupnpc API version " ${MINIUPNPC_API_VERSION})
set(MINIUPNP_FOUND true)
set(MINIUPNPC_VERSION_1_7_OR_HIGHER true)
endif()
endif()
ENDIF()
mark_as_advanced(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY)
# --------------------------------- FindMiniupnpc End ---------------------------------

View File

@@ -74,6 +74,7 @@ namespace epee
public:
using char_type = std::uint8_t;
using Ch = char_type;
using value_type = char_type;
//! Increase internal buffer by at least `byte_stream_increase` bytes.
byte_stream() noexcept
@@ -86,6 +87,7 @@ namespace epee
~byte_stream() noexcept = default;
byte_stream& operator=(byte_stream&& rhs) noexcept;
std::uint8_t* data() noexcept { return buffer_.get(); }
const std::uint8_t* data() const noexcept { return buffer_.get(); }
std::uint8_t* tellp() const noexcept { return next_write_; }
std::size_t available() const noexcept { return end_ - next_write_; }

View File

@@ -171,6 +171,13 @@
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body); \
return true; \
} \
epee::serialization::storage_entry params_; \
params_ = epee::serialization::storage_entry(epee::serialization::section()); \
if(!ps.get_value("params", params_, nullptr)) \
{ \
epee::serialization::section params_section; \
ps.set_value("params", std::move(params_section), nullptr); \
} \
if(false) return true; //just a stub to have "else if"

View File

@@ -71,8 +71,6 @@ namespace string_tools
std::string get_current_module_path();
#endif
void set_module_name_and_folder(const std::string& path_to_process_);
void trim_left(std::string& str);
void trim_right(std::string& str);
//----------------------------------------------------------------------------
inline std::string& trim(std::string& str)
{

View File

@@ -152,7 +152,11 @@ namespace epee
{
std::size_t space_needed = 0;
for (const auto& source : sources)
{
if (std::numeric_limits<std::size_t>::max() - space_needed < source.size())
throw std::bad_alloc{};
space_needed += source.size();
}
if (space_needed)
{
@@ -162,9 +166,9 @@ namespace epee
for (const auto& source : sources)
{
assert(source.size() <= out.size()); // see check above
std::memcpy(out.data(), source.data(), source.size());
if (out.remove_prefix(source.size()) < source.size())
throw std::bad_alloc{}; // size_t overflow on space_needed
out.remove_prefix(source.size());
}
storage_ = std::move(storage);
}

View File

@@ -1,5 +1,4 @@
#include "readline_buffer.h"
#include "string_tools.h"
#include <readline/readline.h>
#include <readline/history.h>
#include <iostream>
@@ -174,7 +173,7 @@ static void handle_line(char* line)
line_stat = rdln::full;
the_line = line;
std::string test_line = line;
epee::string_tools::trim_right(test_line);
boost::trim_right(test_line);
if(!test_line.empty())
{
if (!same_as_last_line(test_line))

View File

@@ -174,19 +174,6 @@ namespace string_tools
}
//----------------------------------------------------------------------------
void trim_left(std::string& str)
{
boost::trim_left(str);
return;
}
//----------------------------------------------------------------------------
void trim_right(std::string& str)
{
boost::trim_right(str);
return;
}
std::string pad_string(std::string s, size_t n, char c, bool prepend)
{
if (s.size() < n)

View File

@@ -35,13 +35,10 @@
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
# others.
if(NOT MSVC)
add_compile_options(-D_GNU_SOURCE)
endif()
find_package(Miniupnpc REQUIRED)
message(STATUS "Using in-tree miniupnpc")
set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE)
set(UPNPC_BUILD_TESTS FALSE CACHE BOOL "Disable miniupnp internal tests." FORCE)
add_subdirectory(miniupnp/miniupnpc)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON)

Binary file not shown.

View File

@@ -233,6 +233,7 @@ namespace cryptonote
ADD_CHECKPOINT2(489400, "b14f49eae77398117ea93435676100d8b655a804689f73a5a4d0d5e71160d603", "0x1123c39bb52f7e");
ADD_CHECKPOINT2(491200, "cedba73ad35ce7f51aaca2beb36dc32d79ecc716d146eb8211e6a815f3666c4a", "0x11334734abbd17");
ADD_CHECKPOINT2(497100, "2c4c70ac1ada94151f19d67ccf1aa4e846e6067f49f67c85cc03f78e768ea42b", "0x116906bc97a751");
ADD_CHECKPOINT2(691500, "ed8e2507c0938b7eab7b02eccfb3506aeb591e51fbf6cf145fcc60ea2d351025", "0x163a280f2ce8e3");
return true;
}

View File

@@ -1242,12 +1242,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
// just the latter (because the rollback was done above).
rollback_blockchain_switching(disconnected_chain, split_height);
// FIXME: Why do we keep invalid blocks around? Possibly in case we hear
// about them again so we can immediately dismiss them, but needs some
// looking into.
const crypto::hash blkid = cryptonote::get_block_hash(bei.bl);
add_block_as_invalid(bei, blkid);
MERROR("The block was inserted as invalid while connecting new alternative chain, block_id: " << blkid);
m_db->remove_alt_block(blkid);
alt_ch_iter++;
@@ -1255,7 +1250,6 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
{
const auto &bei = *alt_ch_to_orph_iter++;
const crypto::hash blkid = cryptonote::get_block_hash(bei.bl);
add_block_as_invalid(bei, blkid);
m_db->remove_alt_block(blkid);
}
return false;
@@ -2471,7 +2465,7 @@ bool Blockchain::get_output_distribution(uint64_t amount, uint64_t from_height,
{
case STAGENET: start_height = stagenet_hard_forks[3].height; break;
case TESTNET: start_height = testnet_hard_forks[3].height; break;
case MAINNET: start_height = mainnet_hard_forks[3].height; break;
case MAINNET: start_height = 0; break;
case FAKECHAIN: start_height = 0; break;
default: return false;
}
@@ -5672,7 +5666,7 @@ void Blockchain::cancel()
}
#if defined(PER_BLOCK_CHECKPOINT)
static const char expected_block_hashes_hash[] = "c321396d82f3987943018dfb0f974e39f8d21b2df360fcc3916a178504b1470d";
static const char expected_block_hashes_hash[] = "3ee7be44d391f20b389ed17b17443ffa26889ac943a57b4e493b833db67159c5";
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
{
if (get_checkpoints == nullptr || !m_fast_sync)

View File

@@ -696,6 +696,16 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
std::ifstream ifs(ban_list_path.string());
for (std::string line; std::getline(ifs, line); )
{
// ignore comments after '#' character
const size_t pound_idx = line.find('#');
if (pound_idx != std::string::npos)
line.resize(pound_idx);
// trim whitespace and ignore empty lines
boost::trim(line);
if (line.empty())
continue;
auto subnet = net::get_ipv4_subnet_address(line);
if (subnet)
{

View File

@@ -133,6 +133,7 @@ namespace lmdb
//! \pre `!is_end()` \return Current key
K get_key() const noexcept
{
static_assert(std::is_trivially_copyable<K>(), "key is not memcpy safe");
assert(!is_end());
K out;
std::memcpy(std::addressof(out), key.data(), sizeof(out));

View File

@@ -55,7 +55,7 @@ namespace lmdb
static expect<F> get_value(MDB_val value) noexcept
{
static_assert(std::is_same<U, V>(), "bad MONERO_FIELD?");
static_assert(std::is_pod<F>(), "F must be POD");
static_assert(std::is_trivially_copyable<F>(), "F must be memcpy safe");
static_assert(sizeof(F) + offset <= sizeof(U), "bad field type and/or offset");
if (value.mv_size != sizeof(U))

View File

@@ -111,6 +111,7 @@ namespace lmdb
template<typename T, std::size_t offset = 0>
inline int less(MDB_val const* left, MDB_val const* right) noexcept
{
static_assert(std::is_trivially_copyable<T>(), "memcpy will not work");
if (!left || !right || left->mv_size < sizeof(T) + offset || right->mv_size < sizeof(T) + offset)
{
assert("invalid use of custom comparison" == 0);

View File

@@ -162,8 +162,8 @@ namespace lmdb
G get_value() const noexcept
{
static_assert(std::is_same<U, T>(), "bad MONERO_FIELD usage?");
static_assert(std::is_pod<U>(), "value type must be pod");
static_assert(std::is_pod<G>(), "field type must be pod");
static_assert(std::is_trivially_copyable<U>(), "value type must be memcpy safe");
static_assert(std::is_trivially_copyable<G>(), "field type must be memcpy safe");
static_assert(sizeof(G) + uoffset <= sizeof(U), "bad field and/or offset");
assert(sizeof(G) + uoffset <= values.size());
assert(!is_end());

View File

@@ -60,9 +60,9 @@
#include "cryptonote_core/cryptonote_core.h"
#include "net/parse.h"
#include <miniupnpc.h>
#include <upnpcommands.h>
#include <upnperrors.h>
#include <miniupnp/miniupnpc/miniupnpc.h>
#include <miniupnp/miniupnpc/upnpcommands.h>
#include <miniupnp/miniupnpc/upnperrors.h>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"
@@ -531,6 +531,16 @@ namespace nodetool
std::istringstream iss(banned_ips);
for (std::string line; std::getline(iss, line); )
{
// ignore comments after '#' character
const size_t pound_idx = line.find('#');
if (pound_idx != std::string::npos)
line.resize(pound_idx);
// trim whitespace and ignore empty lines
boost::trim(line);
if (line.empty())
continue;
auto subnet = net::get_ipv4_subnet_address(line);
if (subnet)
{
@@ -2968,8 +2978,7 @@ namespace nodetool
UPNPUrls urls;
IGDdatas igdData;
char lanAddress[64];
char wanaddr[64]; /* up address of the IGD on the WAN */
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanaddr, sizeof wanaddr);
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
freeUPNPDevlist(deviceList);
if (result > 0) {
if (result == 1) {
@@ -3037,8 +3046,7 @@ namespace nodetool
UPNPUrls urls;
IGDdatas igdData;
char lanAddress[64];
char wanaddr[64]; /* up address of the IGD on the WAN */
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress, wanaddr, sizeof wanaddr);
result = UPNP_GetValidIGD(deviceList, &urls, &igdData, lanAddress, sizeof lanAddress);
freeUPNPDevlist(deviceList);
if (result > 0) {
if (result == 1) {

View File

@@ -96,31 +96,12 @@ monero_private_headers(daemon_rpc_server
monero_add_library(rpc_base
${rpc_base_sources}
${rpc_base_headers}
${rpc_base_private_headers}
LINKS
common
epee
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
PRIVATE_LINKS
${EXTRA_LIBRARIES})
${rpc_base_private_headers})
monero_add_library(rpc
${rpc_sources}
${rpc_headers}
${rpc_private_headers}
LINKS
rpc_base
common
cryptonote_core
cryptonote_protocol
net
version
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
PRIVATE_LINKS
${EXTRA_LIBRARIES})
${rpc_private_headers})
monero_add_library(rpc_pub
${rpc_pub_sources}
@@ -137,6 +118,30 @@ monero_add_library(daemon_rpc_server
${daemon_rpc_server_headers}
${daemon_rpc_server_private_headers})
target_link_libraries(rpc_base
PUBLIC
common
epee
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
PRIVATE
${EXTRA_LIBRARIES})
target_link_libraries(rpc
PUBLIC
rpc_base
common
cryptonote_core
cryptonote_protocol
net
version
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
PRIVATE
${EXTRA_LIBRARIES})
target_link_libraries(rpc_pub
PUBLIC
epee

View File

@@ -8886,6 +8886,22 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
PAUSE_READLINE();
auto formatter = boost::format("%8.8s %6.6s %8.8s %25.25s %20.20s %64.64s %15.15s %14.14s %s %s - %s");
message_writer(console_color_default, false) << formatter
% "Block"
% "In/Out"
% "Locked?"
% "Timestamp"
% "Amount"
% "Tx Hash"
% "Tx Payment ID"
% "Tx Fee"
% "Destination(s)"
% "Index"
% "Tx Note";
formatter = boost::format("%8.8llu %6.6s %8.8s %25.25s %20.20s %64.64s %15.15s %14.14s %s %s - %s");
for (const auto& transfer : all_transfers)
{
const auto color = transfer.type == "failed" ? console_color_red : transfer.confirmed ? ((transfer.direction == "in" || transfer.direction == "block") ? console_color_green : console_color_magenta) : console_color_default;
@@ -8902,8 +8918,6 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
}
}
auto formatter = boost::format("%8.8llu %6.6s %8.8s %25.25s %20.20s %s %s %14.14s %s %s - %s");
message_writer(color, false) << formatter
% transfer.block
% transfer.direction

View File

@@ -1,5 +1,5 @@
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
#define DEF_MONERO_VERSION "0.11.2.0"
#define DEF_MONERO_VERSION "0.11.3.0"
#define DEF_MONERO_RELEASE_NAME "Kunty Karen"
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
#define DEF_MONERO_VERSION_IS_RELEASE @VERSION_IS_RELEASE@

View File

@@ -1280,6 +1280,11 @@ bool wallet2::has_stagenet_option(const boost::program_options::variables_map& v
return command_line::get_arg(vm, options().stagenet);
}
bool wallet2::has_proxy_option() const
{
return !m_proxy.empty();
}
std::string wallet2::device_name_option(const boost::program_options::variables_map& vm)
{
return command_line::get_arg(vm, options().hw_device);
@@ -1364,12 +1369,15 @@ std::unique_ptr<wallet2> wallet2::make_dummy(const boost::program_options::varia
}
//----------------------------------------------------------------------------------------------------
bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options, const std::string& proxy)
{
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
if(m_http_client->is_connected())
m_http_client->disconnect();
CHECK_AND_ASSERT_MES2(m_proxy.empty() || proxy.empty() , "It is not possible to set global proxy (--proxy) and daemon specific proxy together.");
if(m_proxy.empty())
CHECK_AND_ASSERT_MES(set_proxy(proxy), false, "failed to set proxy address");
const bool changed = m_daemon_address != daemon_address;
m_daemon_address = std::move(daemon_address);
m_daemon_login = std::move(daemon_login);
@@ -1404,7 +1412,8 @@ bool wallet2::set_proxy(const std::string &address)
//----------------------------------------------------------------------------------------------------
bool wallet2::init(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, const std::string &proxy_address, uint64_t upper_transaction_weight_limit, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
{
CHECK_AND_ASSERT_MES(set_proxy(proxy_address), false, "failed to set proxy address");
m_proxy = proxy_address;
CHECK_AND_ASSERT_MES(set_proxy(m_proxy), false, "failed to set proxy address");
m_checkpoints.init_default_checkpoints(m_nettype);
m_is_initialized = true;
m_upper_transaction_weight_limit = upper_transaction_weight_limit;
@@ -6143,7 +6152,7 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
bool r = true;
if (use_fs)
{
load_from_file(m_wallet_file, cache_file_buf, std::numeric_limits<size_t>::max());
r = load_from_file(m_wallet_file, cache_file_buf, std::numeric_limits<size_t>::max());
THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, m_wallet_file);
}
@@ -8799,8 +8808,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
// check we're clear enough of rct start, to avoid corner cases below
THROW_WALLET_EXCEPTION_IF(rct_offsets.size() <= CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE,
error::get_output_distribution, "Not enough rct outputs");
//THROW_WALLET_EXCEPTION_IF(rct_offsets.back() <= max_rct_index,
//error::get_output_distribution, "Daemon reports suspicious number of rct outputs");
THROW_WALLET_EXCEPTION_IF(rct_offsets.back() <= max_rct_index,
error::get_output_distribution, "Daemon reports suspicious number of rct outputs");
}
// get histogram for the amounts we need

View File

@@ -971,6 +971,12 @@ private:
std::string path() const;
/*!
* \brief has_proxy_option Check the global proxy (--proxy) has been defined or not.
* \return returns bool representing the global proxy (--proxy).
*/
bool has_proxy_option() const;
/*!
* \brief verifies given password is correct for default wallet keys file
*/
@@ -1001,7 +1007,8 @@ private:
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect);
bool set_daemon(std::string daemon_address = "http://localhost:8080",
boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true,
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect);
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect,
const std::string &proxy = "");
bool set_proxy(const std::string &address);
void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); }
@@ -1834,6 +1841,7 @@ private:
cryptonote::account_base m_account;
boost::optional<epee::net_utils::http::login> m_daemon_login;
std::string m_daemon_address;
std::string m_proxy;
std::string m_wallet_file;
std::string m_keys_file;
std::string m_mms_file;

View File

@@ -3465,7 +3465,7 @@ namespace tools
if (!wal)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "Failed to open wallet";
er.message = "Failed to open wallet : " + (!er.message.empty() ? er.message : "Unknown.");
return false;
}
@@ -4437,6 +4437,13 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
if (m_wallet->has_proxy_option() && !req.proxy.empty())
{
er.code = WALLET_RPC_ERROR_CODE_PROXY_ALREADY_DEFINED;
er.message = "It is not possible to set daemon specific proxy when --proxy is defined.";
return false;
}
std::vector<std::vector<uint8_t>> ssl_allowed_fingerprints;
ssl_allowed_fingerprints.reserve(req.ssl_allowed_fingerprints.size());
@@ -4480,7 +4487,7 @@ namespace tools
if (!req.username.empty() || !req.password.empty())
daemon_login.emplace(req.username, req.password);
if (!m_wallet->set_daemon(req.address, daemon_login, req.trusted, std::move(ssl_options)))
if (!m_wallet->set_daemon(req.address, daemon_login, req.trusted, std::move(ssl_options), req.proxy))
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = std::string("Unable to set daemon");

View File

@@ -2598,6 +2598,7 @@ namespace wallet_rpc
std::string ssl_ca_file;
std::vector<std::string> ssl_allowed_fingerprints;
bool ssl_allow_any_cert;
std::string proxy;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
@@ -2610,6 +2611,7 @@ namespace wallet_rpc
KV_SERIALIZE(ssl_ca_file)
KV_SERIALIZE(ssl_allowed_fingerprints)
KV_SERIALIZE_OPT(ssl_allow_any_cert, false)
KV_SERIALIZE_OPT(proxy, (std::string)"")
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;

View File

@@ -0,0 +1,17 @@
# magicfolk
255.255.255.0 # Saruman the White
128.128.128.0 # Gandalf the Gray
150.75.0.0 # Radagast the Brown
99.98.0.0/16 # All of Misty Mountain
# personal enemies
1.2.3.4 # this woman used to give me swirlies
6.7.8.9 # I just don't like the cut of his jib
1.0.0.7#Literally James Bond, he wrecked my aston martin
100.98.1.13 # Earl from HOA
100.98.1.0/24 #The rest of the HOA for good measure
#
#7.7.7.7
#^^^We're chill now, she's truly an angel

View File

@@ -29,8 +29,11 @@
#include <cstdint>
#include <gtest/gtest.h>
#include <vector>
#include "serialization/keyvalue_serialization.h"
#include "storages/portable_storage.h"
#include "storages/portable_storage_template_helper.h"
#include "span.h"
TEST(epee_binary, two_keys)
@@ -54,3 +57,68 @@ TEST(epee_binary, duplicate_key)
epee::serialization::portable_storage storage{};
EXPECT_FALSE(storage.load_from_binary(data));
}
namespace
{
template<typename t_param>
struct ParentObjWithOptChild
{
t_param params;
ParentObjWithOptChild(): params{} {}
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(params)
END_KV_SERIALIZE_MAP()
};
struct ObjWithOptChild
{
bool test_value;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(test_value, true);
END_KV_SERIALIZE_MAP()
};
}
TEST(epee_binary, serialize_deserialize)
{
ParentObjWithOptChild<ObjWithOptChild> o;
std::string o_json;
o.params.test_value = true;
EXPECT_TRUE(epee::serialization::store_t_to_json(o, o_json));
EXPECT_TRUE(o.params.test_value);
EXPECT_TRUE(epee::serialization::load_t_from_json(o, o_json));
EXPECT_TRUE(o.params.test_value);
ParentObjWithOptChild<ObjWithOptChild> o2;
std::string o2_json;
o.params.test_value = false;
EXPECT_TRUE(epee::serialization::store_t_to_json(o2, o2_json));
EXPECT_FALSE(o2.params.test_value);
EXPECT_TRUE(epee::serialization::load_t_from_json(o2, o2_json));
EXPECT_FALSE(o2.params.test_value);
// compiler sets default value of test_value to false
ParentObjWithOptChild<ObjWithOptChild> o3;
std::string o3_json;
EXPECT_TRUE(epee::serialization::store_t_to_json(o3, o3_json));
EXPECT_FALSE(o3.params.test_value);
EXPECT_TRUE(epee::serialization::load_t_from_json(o3, o3_json));
EXPECT_FALSE(o3.params.test_value);
// test optional field default initialization.
ParentObjWithOptChild<ObjWithOptChild> o4;
std::string o4_json = "{\"params\": {}}";
EXPECT_TRUE(epee::serialization::load_t_from_json(o4, o4_json));
EXPECT_TRUE(o4.params.test_value);
}

View File

@@ -35,6 +35,7 @@
#include "cryptonote_core/i_core_events.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
#include "unit_tests_utils.h"
#include <condition_variable>
#define MAKE_IPV4_ADDRESS(a,b,c,d) epee::net_utils::ipv4_network_address{MAKE_IP(a,b,c,d),0}
@@ -114,6 +115,18 @@ static bool is_blocked(Server &server, const epee::net_utils::network_address &a
return true;
}
}
if (address.get_type_id() != epee::net_utils::address_type::ipv4)
return false;
const epee::net_utils::ipv4_network_address ipv4_address = address.as<epee::net_utils::ipv4_network_address>();
// check if in a blocked ipv4 subnet
const std::map<epee::net_utils::ipv4_network_subnet, time_t> subnets = server.get_blocked_subnets();
for (const auto &subnet : subnets)
if (subnet.first.matches(ipv4_address))
return true;
return false;
}
@@ -266,6 +279,78 @@ TEST(ban, ignores_port)
ASSERT_FALSE(is_blocked(server,MAKE_IPV4_ADDRESS_PORT(1,2,3,4,6)));
}
TEST(ban, file_banlist)
{
test_core pr_core;
cryptonote::t_cryptonote_protocol_handler<test_core> cprotocol(pr_core, NULL);
Server server(cprotocol);
cprotocol.set_p2p_endpoint(&server);
auto create_node_dir = [](){
boost::system::error_code ec;
auto path = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path("daemon-%%%%%%%%%%%%%%%%", ec);
if (ec)
return boost::filesystem::path{};
auto success = boost::filesystem::create_directory(path, ec);
if (!ec && success)
return path;
return boost::filesystem::path{};
};
const auto node_dir = create_node_dir();
ASSERT_TRUE(!node_dir.empty());
auto auto_remove_node_dir = epee::misc_utils::create_scope_leave_handler([&node_dir](){
boost::filesystem::remove_all(node_dir);
});
boost::program_options::variables_map vm;
boost::program_options::store(
boost::program_options::command_line_parser({
"--data-dir",
node_dir.string(),
"--ban-list",
(unit_test::data_dir / "node" / "banlist_1.txt").string()
}).options([]{
boost::program_options::options_description options_description{};
cryptonote::core::init_options(options_description);
Server::init_options(options_description);
return options_description;
}()).run(),
vm
);
ASSERT_TRUE(server.init(vm));
// Test cases (look in the banlist_1.txt file)
// magicfolk
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(255,255,255,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(128,128,128,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(150,75,0,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,98,0,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,98,0,255,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,98,1,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,98,1,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,98,255,255,9999)) );
EXPECT_FALSE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(99,99,0,0,9999)) );
// personal enemies
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(1,2,3,4,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(6,7,8,9,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(1,0,0,7,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(1,0,0,7,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(100,98,1,13,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(100,98,1,0,9999)) );
EXPECT_TRUE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(100,98,1,255,9999)) );
EXPECT_FALSE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(100,98,2,0,9999)) );
EXPECT_FALSE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(100,98,0,255,9999)) );
// angel
EXPECT_FALSE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(007,007,007,007,9999)) );
// random IP
EXPECT_FALSE( is_blocked(server, MAKE_IPV4_ADDRESS_PORT(145,036,205,235,9999)) );
}
TEST(node_server, bind_same_p2p_port)
{
struct test_data_t