Compare commits

..

15 Commits

Author SHA1 Message Date
wowario
d30de97e5e Merge pull request 'wallet stuff' (#408) from wowario/wownero:wallet into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/408
2021-07-19 18:38:10 +00:00
wowario
122fc4aa56 prevent mining within wallet and node 2021-07-19 21:21:51 +03:00
wowario
0c748617c4 revert requested_outputs_count 2021-07-19 20:03:02 +03:00
wowario
08aad7d135 Merge pull request 'connection: fix implementation' (#407) from wowario/wownero:connection into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/407
2021-07-16 14:23:19 +00:00
anon
16fc6408d9 connection: fix implementation 2021-07-16 15:59:03 +03:00
anon
1fecf628b4 connection: add segfault and deadlocks demo 2021-07-16 15:58:52 +03:00
wowario
2bdd70d65d Merge pull request 'remove 32 bit builds' (#406) from wowario/wownero:gitian2 into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/406
2021-07-15 20:18:15 +00:00
wowario
4b24a52ecd remove 32 bit builds 2021-07-15 20:54:13 +03:00
wowario
0dba26ab80 Merge pull request 'bump version' (#405) from wowario/wownero:version into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/405
2021-07-14 18:57:42 +00:00
wowario
47c13b50b9 bump version 2021-07-14 21:56:23 +03:00
wowario
ab30fb2ebe Merge pull request 'remove test project' (#404) from wowario/wownero:gitian into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/404
2021-07-14 18:53:21 +00:00
wowario
0a6ad9686f remove test project 2021-07-14 20:35:38 +03:00
wowario
9da6e41b98 Merge pull request 'add back unbound' (#403) from wowario/wownero:v3 into master
Reviewed-on: https://git.wownero.com/wownero/wownero/pulls/403
2021-07-14 12:58:38 +00:00
wowario
dd88245898 add seed nodes 2021-07-14 15:09:39 +03:00
wowario
57fdbe2902 add back unbound 2021-07-14 14:54:11 +03:00
25 changed files with 1597 additions and 1141 deletions

View File

@@ -54,7 +54,7 @@ jobs:
- uses: eine/setup-msys2@v2
with:
update: true
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf-c mingw-w64-x86_64-libusb mingw-w64-x86_64-unbound git
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf-c mingw-w64-x86_64-libusb git
- name: build
run: |
ccache --max-size=150M

4
.gitmodules vendored
View File

@@ -12,3 +12,7 @@
path = external/RandomWOW
url = https://git.wownero.com/wownero/RandomWOW
branch = 1.1.9-wow
[submodule "external/unbound"]
path = external/unbound
url = https://github.com/monero-project/unbound
branch = monero

View File

@@ -307,6 +307,7 @@ if(NOT MANUAL_SUBMODULES)
message(STATUS "Checking submodules")
check_submodule(external/miniupnp)
check_submodule(external/unbound)
check_submodule(external/rapidjson)
check_submodule(external/RandomWOW)
check_submodule(external/supercop)
@@ -611,7 +612,8 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
add_subdirectory(external)
# Final setup for libunbound
include_directories(${UNBOUND_INCLUDE_DIR})
include_directories(${UNBOUND_INCLUDE})
link_directories(${UNBOUND_LIBRARY_DIRS})
# Final setup for easylogging++
include_directories(${EASYLOGGING_INCLUDE})
@@ -1027,6 +1029,7 @@ if(STATIC)
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)
add_definitions(-DBOOST_ASIO_ENABLE_SEQUENTIAL_STRAND_ALLOCATION)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND)

View File

@@ -91,7 +91,7 @@ Dates are provided in the format YYYY-MM-DD.
| 160,777 | 2019-11-20 | Gaping Goatse | v0.7.0.0 | v0.7.1.0 | Only allow >= 2 outputs, change to the block median used to calculate penalty, rct sigs in coinbase forbidden, 4 unlock time as protocol rule
| - | 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.0.2 | 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
| 331,170 | 2021-07-04 | Junkie Jeff | v0.10.0.0 | v0.10.0.3 | 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
X's indicate that these details have not been determined as of commit date.

View File

@@ -42,19 +42,12 @@
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
# Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups)
set(TEST_PROJECT "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp")
file(WRITE "${TEST_PROJECT}/CMakeLists.txt" [=[
cmake_minimum_required(VERSION 3.5)
project(test)
option (CCACHE "")
file(WRITE "${CMAKE_SOURCE_DIR}/test.cpp" "int main() { return 0; }")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE}")
add_executable(test test.cpp)
]=])
try_compile(RET "${TEST_PROJECT}/build" "${TEST_PROJECT}" "test" CMAKE_FLAGS -DCCACHE="${CCACHE_FOUND}")
unset(TEST_PROJECT)
if (${RET})
# Create a temporary file with a simple program.
set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
file(WRITE "${TEMP_CPP_FILE}" "int main() { return 0; }")
# And run the found ccache on it.
execute_process(COMMAND "${CCACHE_FOUND}" "${CMAKE_CXX_COMPILER}" "${TEMP_CPP_FILE}" RESULT_VARIABLE RET)
if (${RET} EQUAL 0)
# Success
message(STATUS "Found usable ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")

View File

@@ -1,8 +1,8 @@
package=expat
$(package)_version=2.4.1
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_4_1
$(package)_version=2.2.4
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_4
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=2f9b6a580b94577b150a7d5617ad4643a4301a6616ff459307df3e225bcfbf40
$(package)_sha256_hash=03ad85db965f8ab2d27328abcf0bc5571af6ec0a414874b2066ee3fdd372019e
define $(package)_set_vars
$(package)_config_opts=--enable-static

View File

@@ -1,8 +1,8 @@
package=ldns
$(package)_version=1.7.1
$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/
$(package)_version=1.6.17
$(package)_download_path=https://www.nlnetlabs.nl/downloads/ldns/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=8ac84c16bdca60e710eea75782356f3ac3b55680d40e1530d7cea474ac208229
$(package)_sha256_hash=8b88e059452118e8949a2752a55ce59bc71fa5bc414103e17f5b6b06f9bcc8cd
$(package)_dependencies=openssl
define $(package)_set_vars

View File

@@ -1,4 +1,4 @@
packages:=boost openssl zeromq libiconv expat ldns unbound
packages:=boost openssl zeromq libiconv
native_packages := native_ccache

View File

@@ -1,12 +1,12 @@
package=unbound
$(package)_version=1.13.1
$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/
$(package)_version=1.6.8
$(package)_download_path=https://www.unbound.net/downloads/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=8504d97b8fc5bd897345c95d116e0ee0ddf8c8ff99590ab2b4bd13278c9f50b8
$(package)_sha256_hash=e3b428e33f56a45417107448418865fe08d58e0e7fea199b855515f60884dd49
$(package)_dependencies=openssl expat ldns
define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) --with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only
$(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) --with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_w64=--enable-static-exe --sysconfdir=/etc --prefix=$(host_prefix) --target=$(host_prefix)
$(package)_build_opts_mingw32=LDFLAGS="$($(package)_ldflags) -lpthread"

View File

@@ -24,8 +24,6 @@ SET(Readline_INCLUDE_DIR @prefix@/include)
SET(Readline_LIBRARY @prefix@/lib/libreadline.a)
SET(Terminfo_LIBRARY @prefix@/lib/libtinfo.a)
SET(UNBOUND_INCLUDE_DIR @prefix@/include)
SET(UNBOUND_LIBRARIES @prefix@/lib/libunbound.a)
SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE)

View File

@@ -44,13 +44,17 @@
#include <cassert>
#include <map>
#include <memory>
#include <condition_variable>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/array.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/thread/thread.hpp>
#include <boost/optional.hpp>
#include "byte_slice.h"
#include "net_utils_base.h"
#include "syncobj.h"
@@ -86,6 +90,181 @@ namespace net_utils
public i_service_endpoint,
public connection_basic
{
private:
using string_t = std::string;
using handler_t = t_protocol_handler;
using context_t = typename handler_t::connection_context;
using connection_t = connection<handler_t>;
using connection_ptr = boost::shared_ptr<connection_t>;
using ssl_support_t = epee::net_utils::ssl_support_t;
using timer_t = boost::asio::steady_timer;
using duration_t = timer_t::duration;
using lock_t = std::mutex;
using condition_t = std::condition_variable_any;
using lock_guard_t = std::lock_guard<lock_t>;
using unique_lock_t = std::unique_lock<lock_t>;
using byte_slice_t = epee::byte_slice;
using ec_t = boost::system::error_code;
using handshake_t = boost::asio::ssl::stream_base::handshake_type;
using io_context_t = boost::asio::io_service;
using strand_t = boost::asio::io_service::strand;
using socket_t = boost::asio::ip::tcp::socket;
using write_queue_t = std::deque<byte_slice_t>;
using read_buffer_t = std::array<uint8_t, 0x2000>;
using network_throttle_t = epee::net_utils::network_throttle;
using network_throttle_manager_t = epee::net_utils::network_throttle_manager;
unsigned int host_count(int delta = 0);
duration_t get_default_timeout();
duration_t get_timeout_from_bytes_read(size_t bytes) const;
void start_timer(duration_t duration, bool add = {});
void async_wait_timer();
void cancel_timer();
void start_handshake();
void start_read();
void start_write();
void start_shutdown();
void cancel_socket();
void cancel_handler();
void interrupt();
void on_interrupted();
void terminate();
void on_terminating();
bool send(byte_slice_t message);
bool start_internal(
bool is_income,
bool is_multithreaded,
boost::optional<network_address> real_remote
);
struct state_t {
struct stat_t {
struct {
network_throttle_t throttle{"speed_in", "throttle_speed_in"};
} in;
struct {
network_throttle_t throttle{"speed_out", "throttle_speed_out"};
} out;
};
struct data_t {
struct {
read_buffer_t buffer;
} read;
struct {
write_queue_t queue;
bool wait_consume;
} write;
};
struct ssl_t {
bool enabled;
bool forced;
bool detected;
bool handshaked;
};
struct socket_t {
bool connected;
bool wait_handshake;
bool cancel_handshake;
bool wait_read;
bool handle_read;
bool cancel_read;
bool wait_write;
bool handle_write;
bool cancel_write;
bool wait_shutdown;
bool cancel_shutdown;
};
struct timer_t {
bool wait_expire;
bool cancel_expire;
bool reset_expire;
};
struct timers_t {
struct throttle_t {
timer_t in;
timer_t out;
};
timer_t general;
throttle_t throttle;
};
enum status_t {
TERMINATED,
RUNNING,
INTERRUPTED,
TERMINATING,
WASTED,
};
struct protocol_t {
size_t reference_counter;
bool released;
bool initialized;
bool wait_release;
bool wait_init;
size_t wait_callback;
};
lock_t lock;
condition_t condition;
status_t status;
socket_t socket;
ssl_t ssl;
timers_t timers;
protocol_t protocol;
stat_t stat;
data_t data;
};
using status_t = typename state_t::status_t;
struct timers_t {
timers_t(io_context_t &io_context):
general(io_context),
throttle(io_context)
{}
struct throttle_t {
throttle_t(io_context_t &io_context):
in(io_context),
out(io_context)
{}
timer_t in;
timer_t out;
};
timer_t general;
throttle_t throttle;
};
io_context_t &io_context;
t_connection_type connection_type;
context_t context{};
strand_t strand;
timers_t timers;
connection_ptr self{};
bool local{};
string_t host{};
state_t state{};
handler_t handler;
public:
typedef typename t_protocol_handler::connection_context t_connection_context;
@@ -142,58 +321,6 @@ namespace net_utils
virtual bool add_ref();
virtual bool release();
//------------------------------------------------------
bool do_send_chunk(byte_slice chunk); ///< will send (or queue) a part of data. internal use only
boost::shared_ptr<connection<t_protocol_handler> > safe_shared_from_this();
bool shutdown();
/// Handle completion of a receive operation.
void handle_receive(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a read operation.
void handle_read(const boost::system::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a write operation.
void handle_write(const boost::system::error_code& e, size_t cb);
/// reset connection timeout timer and callback
void reset_timer(boost::posix_time::milliseconds ms, bool add);
boost::posix_time::milliseconds get_default_timeout();
boost::posix_time::milliseconds get_timeout_from_bytes_read(size_t bytes);
/// host connection count tracking
unsigned int host_count(const std::string &host, int delta = 0);
/// Buffer for incoming data.
boost::array<char, 8192> buffer_;
size_t buffer_ssl_init_fill;
t_connection_context context;
// TODO what do they mean about wait on destructor?? --rfree :
//this should be the last one, because it could be wait on destructor, while other activities possible on other threads
t_protocol_handler m_protocol_handler;
//typename t_protocol_handler::config_type m_dummy_config;
size_t m_reference_count = 0; // reference count managed through add_ref/release support
boost::shared_ptr<connection<t_protocol_handler> > m_self_ref; // the reference to hold
critical_section m_self_refs_lock;
critical_section m_chunking_lock; // held while we add small chunks of the big do_send() to small do_send_chunk()
critical_section m_shutdown_lock; // held while shutting down
t_connection_type m_connection_type;
// for calculate speed (last 60 sec)
network_throttle m_throttle_speed_in;
network_throttle m_throttle_speed_out;
boost::mutex m_throttle_speed_in_mutex;
boost::mutex m_throttle_speed_out_mutex;
boost::asio::deadline_timer m_timer;
bool m_local;
bool m_ready_to_close;
std::string m_host;
public:
void setRpcStation();
};

File diff suppressed because it is too large Load Diff

View File

@@ -110,6 +110,11 @@ namespace net_utils
//! Search against internal fingerprints. Always false if `behavior() != user_certificate_check`.
bool has_fingerprint(boost::asio::ssl::verify_context &ctx) const;
//! configure ssl_stream handshake verification
void configure(
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
boost::asio::ssl::stream_base::handshake_type type,
const std::string& host = {}) const;
boost::asio::ssl::context create_context() const;
/*! \note If `this->support == autodetect && this->verification != none`,

View File

@@ -31,6 +31,8 @@
#include <boost/asio/ssl.hpp>
#include <boost/cerrno.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/asio/strand.hpp>
#include <condition_variable>
#include <boost/lambda/lambda.hpp>
#include <openssl/ssl.h>
#include <openssl/pem.h>
@@ -472,12 +474,10 @@ bool ssl_options_t::has_fingerprint(boost::asio::ssl::verify_context &ctx) const
return false;
}
bool ssl_options_t::handshake(
void ssl_options_t::configure(
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
boost::asio::ssl::stream_base::handshake_type type,
boost::asio::const_buffer buffer,
const std::string& host,
std::chrono::milliseconds timeout) const
const std::string& host) const
{
socket.next_layer().set_option(boost::asio::ip::tcp::no_delay(true));
@@ -522,30 +522,101 @@ bool ssl_options_t::handshake(
return true;
});
}
}
auto& io_service = GET_IO_SERVICE(socket);
boost::asio::steady_timer deadline(io_service, timeout);
deadline.async_wait([&socket](const boost::system::error_code& error) {
if (error != boost::asio::error::operation_aborted)
bool ssl_options_t::handshake(
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
boost::asio::ssl::stream_base::handshake_type type,
boost::asio::const_buffer buffer,
const std::string& host,
std::chrono::milliseconds timeout) const
{
configure(socket, type, host);
auto start_handshake = [&]{
using ec_t = boost::system::error_code;
using timer_t = boost::asio::steady_timer;
using strand_t = boost::asio::io_service::strand;
using lock_t = std::mutex;
using lock_guard_t = std::lock_guard<lock_t>;
using condition_t = std::condition_variable_any;
using socket_t = boost::asio::ip::tcp::socket;
auto &io_context = GET_IO_SERVICE(socket);
if (io_context.stopped())
io_context.reset();
strand_t strand(io_context);
timer_t deadline(io_context, timeout);
struct state_t {
lock_t lock;
condition_t condition;
ec_t result;
bool wait_timer;
bool wait_handshake;
bool cancel_timer;
bool cancel_handshake;
};
state_t state{};
state.wait_timer = true;
auto on_timer = [&](const ec_t &ec){
lock_guard_t guard(state.lock);
state.wait_timer = false;
state.condition.notify_all();
if (not state.cancel_timer) {
state.cancel_handshake = true;
ec_t ec;
socket.next_layer().cancel(ec);
}
};
state.wait_handshake = true;
auto on_handshake = [&](const ec_t &ec, size_t bytes_transferred){
lock_guard_t guard(state.lock);
state.wait_handshake = false;
state.condition.notify_all();
state.result = ec;
if (not state.cancel_handshake) {
state.cancel_timer = true;
ec_t ec;
deadline.cancel(ec);
}
};
deadline.async_wait(on_timer);
strand.post(
[&]{
socket.async_handshake(
type,
boost::asio::buffer(buffer),
strand.wrap(on_handshake)
);
}
);
while (!io_context.stopped())
{
socket.next_layer().close();
io_context.poll_one();
lock_guard_t guard(state.lock);
state.condition.wait_for(
state.lock,
std::chrono::milliseconds(30),
[&]{
return not state.wait_timer and not state.wait_handshake;
}
);
if (not state.wait_timer and not state.wait_handshake)
break;
}
});
boost::system::error_code ec = boost::asio::error::would_block;
socket.async_handshake(type, boost::asio::buffer(buffer), boost::lambda::var(ec) = boost::lambda::_1);
if (io_service.stopped())
{
io_service.reset();
}
while (ec == boost::asio::error::would_block && !io_service.stopped())
{
// should poll_one(), can't run_one() because it can block if there is
// another worker thread executing io_service's tasks
// TODO: once we get Boost 1.66+, replace with run_one_for/run_until
std::this_thread::sleep_for(std::chrono::milliseconds(30));
io_service.poll_one();
}
if (state.result.value()) {
ec_t ec;
socket.next_layer().shutdown(socket_t::shutdown_both, ec);
socket.next_layer().close(ec);
}
return state.result;
};
const auto ec = start_handshake();
if (ec)
{

View File

@@ -49,7 +49,7 @@ files: []
script: |
WRAP_DIR=$HOME/wrapped
HOSTS="x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu i686-linux-gnu"
HOSTS="x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu"
FAKETIME_HOST_PROGS=""
FAKETIME_PROGS="date"
HOST_CFLAGS="-O2 -g"

View File

@@ -23,12 +23,6 @@ packages:
- "rename"
- "cmake"
alternatives:
-
package: "i686-w64-mingw32-g++"
path: "/usr/bin/i686-w64-mingw32-g++-posix"
-
package: "i686-w64-mingw32-gcc"
path: "/usr/bin/i686-w64-mingw32-gcc-posix"
-
package: "x86_64-w64-mingw32-g++"
path: "/usr/bin/x86_64-w64-mingw32-g++-posix"
@@ -41,7 +35,7 @@ remotes:
files: []
script: |
WRAP_DIR=$HOME/wrapped
HOSTS="i686-w64-mingw32 x86_64-w64-mingw32"
HOSTS="x86_64-w64-mingw32"
FAKETIME_HOST_PROGS="windres objcopy"
FAKETIME_PROGS="date zip"
HOST_CFLAGS="-O2 -g"

View File

@@ -55,12 +55,26 @@ set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
find_package(Unbound)
if(NOT UNBOUND_INCLUDE_DIR)
die("Could not find libunbound")
if(NOT UNBOUND_INCLUDE_DIR OR STATIC)
# NOTE: If STATIC is true, CMAKE_FIND_LIBRARY_SUFFIXES has been reordered.
# unbound has config tests which used OpenSSL libraries, so -ldl may need to
# be set in this case.
# The unbound CMakeLists.txt can set it, since it's also needed for the
# static OpenSSL libraries set up there after with target_link_libraries.
add_subdirectory(unbound)
set(UNBOUND_STATIC true PARENT_SCOPE)
set(UNBOUND_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/unbound/libunbound" PARENT_SCOPE)
set(UNBOUND_LIBRARY "unbound" PARENT_SCOPE)
set(UNBOUND_LIBRARY_DIRS "${LIBEVENT2_LIBDIR}" PARENT_SCOPE)
else()
message(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}")
if(UNBOUND_LIBRARIES)
message(STATUS "Found libunbound library")
message(STATUS "Found libunbound shared library")
set(UNBOUND_STATIC false PARENT_SCOPE)
set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE)
set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE)
set(UNBOUND_LIBRARY_DIRS "" PARENT_SCOPE)
else()
die("Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent")
endif()

1
external/unbound vendored Submodule

Submodule external/unbound added at 0f6c0579d6

View File

@@ -99,7 +99,7 @@ monero_add_library(common
target_link_libraries(common
PUBLIC
cncrypto
${UNBOUND_LIBRARIES}
${UNBOUND_LIBRARY}
${LIBUNWIND_LIBRARIES}
${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}

View File

@@ -368,110 +368,7 @@ bool t_command_parser_executor::print_transaction_pool_stats(const std::vector<s
bool t_command_parser_executor::start_mining(const std::vector<std::string>& args)
{
if(!args.size())
{
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
return true;
}
cryptonote::address_parse_info info;
cryptonote::network_type nettype = cryptonote::MAINNET;
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, args.front()))
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, args.front()))
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, args.front()))
{
bool dnssec_valid;
std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
[](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, address_str))
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, address_str))
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str))
{
std::cout << "Invalid syntax: Target account address has wrong format. For more details, use the help command." << std::endl;
return true;
}
else
{
nettype = cryptonote::STAGENET;
}
}
else
{
nettype = cryptonote::TESTNET;
}
}
}
else
{
nettype = cryptonote::STAGENET;
}
}
else
{
nettype = cryptonote::TESTNET;
}
}
if (info.is_subaddress)
{
tools::fail_msg_writer() << "You can't use a subaddress to mine. You need to use your wallet's main address, which starts with \"Wo\"." << std::endl;
return true;
}
if(nettype != cryptonote::MAINNET)
std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << " address, make sure this is intentional!" << std::endl;
uint64_t threads_count = 1;
bool do_background_mining = false;
bool ignore_battery = false;
if(args.size() > 4)
{
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
return true;
}
if(args.size() == 4)
{
if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
{
ignore_battery = true;
}
else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
{
std::cout << "Invalid syntax: Invalid combination of parameters. For more details, use the help command." << std::endl;
return true;
}
}
if(args.size() >= 3)
{
if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
{
do_background_mining = true;
}
else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
{
std::cout << "Invalid syntax: Invalid combination of parameters. For more details, use the help command." << std::endl;
return true;
}
}
if(args.size() >= 2)
{
if (args[1] == "auto" || args[1] == "autodetect")
{
threads_count = 0;
}
else
{
bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]);
threads_count = (ok && 0 < threads_count) ? threads_count : 1;
}
}
m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery);
std::cout << "You can't mine within wownerod. To mine, restart node like this: ./wownerod --start-mining YOUR-ADDRESS --spendkey SECRET-SPENDKEY" << std::endl;
return true;
}

View File

@@ -680,7 +680,7 @@ namespace nodetool
if (m_nettype == cryptonote::TESTNET)
{
full_addrs.insert("207.254.29.107:11180");
full_addrs.insert("51.81.32.130:11180");
full_addrs.insert("135.148.138.255:11180");
}
else if (m_nettype == cryptonote::STAGENET)
{
@@ -697,6 +697,8 @@ namespace nodetool
full_addrs.insert("188.166.237.187:34567"); // sg1.wownodes.com
full_addrs.insert("51.161.131.176:34567"); // node.suchwow.xyz
full_addrs.insert("167.114.196.241:34567"); // wowbux.org
full_addrs.insert("135.148.138.255:34567");
full_addrs.insert("207.254.29.107:34567");
}
return full_addrs;
}

View File

@@ -3186,6 +3186,7 @@ bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<st
message_writer() << tr("\"transfer <address> <amount>\" - Send WOW to an address.");
message_writer() << tr("\"show_transfers [in|out|pending|failed|pool]\" - Show transactions.");
message_writer() << tr("\"sweep_all <address>\" - Send whole balance to another wallet.");
message_writer() << tr("\"spendkey\" - Show secret spend key used for mining.");
message_writer() << tr("\"seed\" - Show secret 25 words that can be used to recover this wallet.");
message_writer() << tr("\"refresh\" - Synchronize wallet with the Wownero network.");
message_writer() << tr("\"status\" - Check current status of wallet.");
@@ -4766,9 +4767,6 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
m_wallet->callback(this);
bool skip_check_backround_mining = !command_line::get_arg(vm, arg_command).empty();
if (!skip_check_backround_mining)
check_background_mining(password);
if (welcome)
message_writer(console_color_yellow, true) << tr("If you are new to Wownero, type \"welcome\" for a brief overview.");
@@ -5342,34 +5340,7 @@ bool simple_wallet::save_watch_only(const std::vector<std::string> &args/* = std
//----------------------------------------------------------------------------------------------------
void simple_wallet::start_background_mining()
{
COMMAND_RPC_MINING_STATUS::request reqq;
COMMAND_RPC_MINING_STATUS::response resq;
bool r = m_wallet->invoke_http_json("/mining_status", reqq, resq);
std::string err = interpret_rpc_response(r, resq.status);
if (!r)
return;
if (!err.empty())
{
fail_msg_writer() << tr("Failed to query mining status: ") << err;
return;
}
if (!resq.is_background_mining_enabled)
{
COMMAND_RPC_START_MINING::request req;
COMMAND_RPC_START_MINING::response res;
req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
req.threads_count = 1;
req.do_background_mining = true;
req.ignore_battery = false;
bool r = m_wallet->invoke_http_json("/start_mining", req, res);
std::string err = interpret_rpc_response(r, res.status);
if (!err.empty())
{
fail_msg_writer() << tr("Failed to setup background mining: ") << err;
return;
}
}
success_msg_writer() << tr("Background mining enabled. Thank you for supporting the Wownero network.");
message_writer(console_color_red, false) << tr("Background mining not available.");
}
//----------------------------------------------------------------------------------------------------
void simple_wallet::stop_background_mining()
@@ -5462,60 +5433,7 @@ void simple_wallet::check_background_mining(const epee::wipeable_string &passwor
//----------------------------------------------------------------------------------------------------
bool simple_wallet::start_mining(const std::vector<std::string>& args)
{
if (!m_wallet->is_trusted_daemon())
{
fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon");
return true;
}
if (!try_connect_to_daemon())
return true;
if (!m_wallet)
{
fail_msg_writer() << tr("wallet is null");
return true;
}
COMMAND_RPC_START_MINING::request req = AUTO_VAL_INIT(req);
req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
bool ok = true;
size_t arg_size = args.size();
if(arg_size >= 3)
{
if (!parse_bool_and_use(args[2], [&](bool r) { req.ignore_battery = r; }))
return true;
}
if(arg_size >= 2)
{
if (!parse_bool_and_use(args[1], [&](bool r) { req.do_background_mining = r; }))
return true;
}
if(arg_size >= 1)
{
uint16_t num = 1;
ok = string_tools::get_xtype_from_string(num, args[0]);
ok = ok && 1 <= num;
req.threads_count = num;
}
else
{
req.threads_count = 1;
}
if (!ok)
{
PRINT_USAGE(USAGE_START_MINING);
return true;
}
COMMAND_RPC_START_MINING::response res;
bool r = m_wallet->invoke_http_json("/start_mining", req, res);
std::string err = interpret_rpc_response(r, res.status);
if (err.empty())
success_msg_writer() << tr("Mining started in daemon");
else
fail_msg_writer() << tr("mining has NOT been started: ") << err;
fail_msg_writer() << tr("You can't mine within the wallet. To mine, restart node like this: ./wownerod --start-mining YOUR-ADDRESS --spendkey SECRET-SPENDKEY");
return true;
}
//----------------------------------------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
#define DEF_MONERO_VERSION "0.10.0.2"
#define DEF_MONERO_VERSION "0.10.0.3"
#define DEF_MONERO_RELEASE_NAME "Junkie Jeff"
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
#define DEF_MONERO_VERSION_IS_RELEASE @VERSION_IS_RELEASE@

View File

@@ -8672,12 +8672,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
const uint64_t amount = td.is_rct() ? 0 : td.amount();
std::unordered_set<uint64_t> seen_indices;
// request more for rct in base recent (locked) coinbases are picked, since they're locked for longer
uint64_t approx_blockchain_height = m_nettype == TESTNET ? 0 : (time(NULL) - 1522624244)/311;
uint64_t unlock_height = td.m_block_height + std::max<uint64_t>(CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE, CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS);
if (td.m_tx.unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER && td.m_tx.unlock_time > unlock_height)
unlock_height = td.m_tx.unlock_time;
uint64_t blocks_to_unlock = unlock_height > approx_blockchain_height ? unlock_height - approx_blockchain_height : 0;
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? blocks_to_unlock - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0) + 288;
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2 - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
size_t start = req.outputs.size();
bool use_histogram = amount != 0 || !has_rct_distribution;
@@ -8993,12 +8988,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
for(size_t idx: selected_transfers)
{
const transfer_details &td = m_transfers[idx];
uint64_t approx_blockchain_height = m_nettype == TESTNET ? 0 : (time(NULL) - 1522624244)/311;
uint64_t unlock_height = td.m_block_height + std::max<uint64_t>(CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE, CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS);
if (td.m_tx.unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER && td.m_tx.unlock_time > unlock_height)
unlock_height = td.m_tx.unlock_time;
uint64_t blocks_to_unlock = unlock_height > approx_blockchain_height ? unlock_height - approx_blockchain_height : 0;
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? blocks_to_unlock - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0) + 288;
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2 - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
outs.push_back(std::vector<get_outs_entry>());
outs.back().reserve(fake_outputs_count + 1);
const rct::key mask = td.is_rct() ? rct::commit(td.amount(), td.m_mask) : rct::zeroCommit(td.amount());

View File

@@ -31,6 +31,8 @@
#include <boost/chrono/chrono.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <condition_variable>
#include <mutex>
#include "gtest/gtest.h"
@@ -278,6 +280,11 @@ TEST(test_epee_connection, test_lifetime)
ASSERT_TRUE(shared_state->get_connections_count() == 0);
constexpr auto DELAY = 30;
constexpr auto TIMEOUT = 1;
while (server.get_connections_count()) {
server.get_config_shared()->del_in_connections(
server.get_config_shared()->get_in_connections_count()
);
}
server.get_config_shared()->set_handler(new command_handler_t(DELAY), &command_handler_t::destroy);
for (auto i = 0; i < N; ++i) {
tag = create_connection();
@@ -334,7 +341,7 @@ TEST(test_epee_connection, test_lifetime)
),
&command_handler_t::destroy
);
for (auto i = 0; i < N; ++i) {
for (auto i = 0; i < N * N * N; ++i) {
{
connection_ptr conn(new connection_t(io_context, shared_state, {}, {}));
conn->socket().connect(endpoint);
@@ -344,6 +351,7 @@ TEST(test_epee_connection, test_lifetime)
}
ASSERT_TRUE(shared_state->get_connections_count() == 1);
shared_state->del_out_connections(1);
while (shared_state->sock_count);
ASSERT_TRUE(shared_state->get_connections_count() == 0);
}
@@ -454,7 +462,11 @@ TEST(test_epee_connection, test_lifetime)
}
for (;workers.size(); workers.pop_back())
workers.back().join();
while (server.get_connections_count()) {
server.get_config_shared()->del_in_connections(
server.get_config_shared()->get_in_connections_count()
);
}
});
for (auto& w: workers) {
@@ -464,3 +476,241 @@ TEST(test_epee_connection, test_lifetime)
server.timed_wait_server_stop(5 * 1000);
server.deinit_server();
}
TEST(test_epee_connection, ssl_shutdown)
{
struct context_t: epee::net_utils::connection_context_base {
static constexpr size_t get_max_bytes(int) noexcept { return -1; }
static constexpr int handshake_command() noexcept { return 1001; }
static constexpr bool handshake_complete() noexcept { return true; }
};
struct command_handler_t: epee::levin::levin_commands_handler<context_t> {
virtual int invoke(int, const epee::span<const uint8_t>, epee::byte_stream&, context_t&) override { return {}; }
virtual int notify(int, const epee::span<const uint8_t>, context_t&) override { return {}; }
virtual void callback(context_t&) override {}
virtual void on_connection_new(context_t&) override {}
virtual void on_connection_close(context_t&) override { }
virtual ~command_handler_t() override {}
static void destroy(epee::levin::levin_commands_handler<context_t>* ptr) { delete ptr; }
};
using handler_t = epee::levin::async_protocol_handler<context_t>;
using io_context_t = boost::asio::io_service;
using endpoint_t = boost::asio::ip::tcp::endpoint;
using server_t = epee::net_utils::boosted_tcp_server<handler_t>;
using socket_t = boost::asio::ip::tcp::socket;
using ssl_socket_t = boost::asio::ssl::stream<socket_t>;
using ssl_context_t = boost::asio::ssl::context;
using ec_t = boost::system::error_code;
endpoint_t endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 5263);
server_t server(epee::net_utils::e_connection_type_P2P);
server.init_server(endpoint.port(),
endpoint.address().to_string(),
0,
"",
false,
true,
epee::net_utils::ssl_support_t::e_ssl_support_enabled
);
server.get_config_shared()->set_handler(new command_handler_t, &command_handler_t::destroy);
server.run_server(2, false);
ssl_context_t ssl_context{boost::asio::ssl::context::sslv23};
io_context_t io_context;
ssl_socket_t socket(io_context, ssl_context);
ec_t ec;
socket.next_layer().connect(endpoint, ec);
EXPECT_EQ(ec.value(), 0);
socket.handshake(boost::asio::ssl::stream_base::client, ec);
EXPECT_EQ(ec.value(), 0);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
while (server.get_config_shared()->get_connections_count() < 1);
server.get_config_shared()->del_in_connections(1);
while (server.get_config_shared()->get_connections_count() > 0);
server.send_stop_signal();
EXPECT_TRUE(server.timed_wait_server_stop(5 * 1000));
server.deinit_server();
socket.next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
socket.next_layer().close(ec);
socket.shutdown(ec);
}
TEST(test_epee_connection, ssl_handshake)
{
using io_context_t = boost::asio::io_service;
using work_t = boost::asio::io_service::work;
using work_ptr = std::shared_ptr<work_t>;
using workers_t = std::vector<std::thread>;
using socket_t = boost::asio::ip::tcp::socket;
using ssl_socket_t = boost::asio::ssl::stream<socket_t>;
using ssl_socket_ptr = std::unique_ptr<ssl_socket_t>;
using ssl_options_t = epee::net_utils::ssl_options_t;
io_context_t io_context;
work_ptr work(std::make_shared<work_t>(io_context));
workers_t workers;
auto constexpr N = 2;
while (workers.size() < N) {
workers.emplace_back([&io_context]{
io_context.run();
});
}
ssl_options_t ssl_options{{}};
auto ssl_context = ssl_options.create_context();
for (size_t i = 0; i < N * N * N; ++i) {
ssl_socket_ptr ssl_socket(new ssl_socket_t(io_context, ssl_context));
ssl_socket->next_layer().open(boost::asio::ip::tcp::v4());
for (size_t i = 0; i < N; ++i) {
io_context.post([]{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
});
}
EXPECT_EQ(
ssl_options.handshake(
*ssl_socket,
ssl_socket_t::server,
{},
{},
std::chrono::milliseconds(0)
),
false
);
ssl_socket->next_layer().close();
ssl_socket.reset();
}
work.reset();
for (;workers.size(); workers.pop_back())
workers.back().join();
}
TEST(boosted_tcp_server, strand_deadlock)
{
using context_t = epee::net_utils::connection_context_base;
using lock_t = std::mutex;
using unique_lock_t = std::unique_lock<lock_t>;
struct config_t {
using condition_t = std::condition_variable_any;
using lock_guard_t = std::lock_guard<lock_t>;
void notify_success()
{
lock_guard_t guard(lock);
success = true;
condition.notify_all();
}
lock_t lock;
condition_t condition;
bool success;
};
struct handler_t {
using config_type = config_t;
using connection_context = context_t;
using byte_slice_t = epee::byte_slice;
using socket_t = epee::net_utils::i_service_endpoint;
handler_t(socket_t *socket, config_t &config, context_t &context):
socket(socket),
config(config),
context(context)
{}
void after_init_connection()
{
unique_lock_t guard(lock);
if (not context.m_is_income) {
guard.unlock();
socket->do_send(byte_slice_t{"."});
}
}
void handle_qued_callback()
{
}
bool handle_recv(const char *data, size_t bytes_transferred)
{
unique_lock_t guard(lock);
if (not context.m_is_income) {
if (context.m_recv_cnt == 1024) {
guard.unlock();
socket->do_send(byte_slice_t{"."});
}
}
else {
if (context.m_recv_cnt == 1) {
for(size_t i = 0; i < 1024; ++i) {
guard.unlock();
socket->do_send(byte_slice_t{"."});
guard.lock();
}
}
else if(context.m_recv_cnt == 2) {
guard.unlock();
socket->close();
}
}
return true;
}
void release_protocol()
{
unique_lock_t guard(lock);
if(not context.m_is_income
and context.m_recv_cnt == 1024
and context.m_send_cnt == 2
) {
guard.unlock();
config.notify_success();
}
}
lock_t lock;
socket_t *socket;
config_t &config;
context_t &context;
};
using server_t = epee::net_utils::boosted_tcp_server<handler_t>;
using endpoint_t = boost::asio::ip::tcp::endpoint;
endpoint_t endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 5262);
server_t server(epee::net_utils::e_connection_type_P2P);
server.init_server(
endpoint.port(),
endpoint.address().to_string(),
{},
{},
{},
true,
epee::net_utils::ssl_support_t::e_ssl_support_disabled
);
server.run_server(2, {});
server.async_call(
[&]{
context_t context;
ASSERT_TRUE(
server.connect(
endpoint.address().to_string(),
std::to_string(endpoint.port()),
5,
context,
"0.0.0.0",
epee::net_utils::ssl_support_t::e_ssl_support_disabled
)
);
}
);
{
unique_lock_t guard(server.get_config_object().lock);
EXPECT_TRUE(
server.get_config_object().condition.wait_for(
guard,
std::chrono::seconds(5),
[&] { return server.get_config_object().success; }
)
);
}
server.send_stop_signal();
server.timed_wait_server_stop(5 * 1000);
server.deinit_server();
}