Skip to content

Commit c9f3674

Browse files
authored
Merge pull request #2786 from div72/boost-1.87
diagnose, rpc: fix compilation with boost 1.87
2 parents 9a62b1d + bd44d1e commit c9f3674

File tree

11 files changed

+57
-137
lines changed

11 files changed

+57
-137
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ env:
77
jobs:
88
test-linux:
99
name: ${{ matrix.name }}
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-24.04
1111
strategy:
1212
matrix:
1313
include:
14-
- name: ARM [GOAL install] [buster]
14+
- name: ARM [GOAL install] [bullseye]
1515
script-id: arm
1616
- name: Win32
1717
script-id: win32
@@ -21,7 +21,7 @@ jobs:
2121
script-id: linux_i386
2222
- name: x86_64 Linux [GOAL install] [GUI] [focal] [no depends]
2323
script-id: native
24-
- name: x86_64 Linux [GOAL install] [GUI] [bionic] [no depends]
24+
- name: x86_64 Linux [GOAL install] [GUI] [noble] [no depends]
2525
script-id: native_old
2626
- name: x86_64 Linux [ASan] [LSan] [UBSan] [integer] [jammy] [no depends]
2727
script-id: native_asan

.github/workflows/cmake-ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
- name: Install dependencies
151151
run: brew install --overwrite
152152
${{matrix.deps}}
153-
boost@1.85
153+
boost
154154
ccache
155155
libzip
156156
ninja
@@ -168,7 +168,6 @@ jobs:
168168
-DCMAKE_C_COMPILER_LAUNCHER=ccache
169169
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
170170
${{matrix.options}}
171-
-DBOOST_ROOT=$(brew --prefix [email protected])
172171
-DENABLE_TESTS=ON
173172
- name: Restore cache
174173
uses: actions/cache/restore@v4
@@ -196,8 +195,6 @@ jobs:
196195
retention-days: 7
197196

198197
test-msys2:
199-
# MSYS2 is rolling release, only latest Boost is available.
200-
if: false
201198
runs-on: windows-latest
202199
defaults:
203200
run:

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
169169
# Allow to find old Boost (pre 1.70) with new CMake (3.30 and later).
170170
cmake_policy(SET CMP0167 OLD)
171171
endif()
172-
find_package(Boost ${BOOST_MINIMUM_VERSION}...<1.87.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
172+
find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
173+
if(Boost_VERSION VERSION_LESS 1.70.0)
174+
find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
175+
else()
176+
# Better upstream-provided CMake config is available.
177+
find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS ${BOOST_COMPONENTS} CONFIG REQUIRED)
178+
endif()
173179

174180
if(BUNDLED_OPENSSL)
175181
hunter_add_package(OpenSSL)

cd/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export HOST=${HOST:-$("$BASE_ROOT_DIR/depends/config.guess")}
3232
# Whether to prefer BusyBox over GNU utilities
3333
export USE_BUSY_BOX=${USE_BUSY_BOX:-false}
3434
export CONTAINER_NAME=${CONTAINER_NAME:-ci_unnamed}
35-
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:18.04}
35+
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:20.04}
3636
# See man 7 debconf
3737
export DEBIAN_FRONTEND=noninteractive
3838
export CCACHE_SIZE=${CCACHE_SIZE:-300M}

ci/test/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export RUN_SECURITY_TESTS=${RUN_SECURITY_TESTS:-false}
3737
export TEST_RUNNER_ENV=${TEST_RUNNER_ENV:-}
3838
export RUN_FUZZ_TESTS=${RUN_FUZZ_TESTS:-false}
3939
export CONTAINER_NAME=${CONTAINER_NAME:-ci_unnamed}
40-
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:18.04}
40+
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:20.04}
4141
# Randomize test order.
4242
# See https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/rt_param_reference/random.html
4343
export BOOST_TEST_RANDOM=${BOOST_TEST_RANDOM:-1}

ci/test/00_setup_env_arm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [ -n "$QEMU_USER_CMD" ]; then
1818
fi
1919
export CONTAINER_NAME=ci_arm_linux
2020
# Use debian to avoid 404 apt errors when cross compiling
21-
export DOCKER_NAME_TAG="debian:buster"
21+
export DOCKER_NAME_TAG="debian:bullseye"
2222
export USE_BUSY_BOX=true
2323
export RUN_UNIT_TESTS=true
2424
export RUN_FUNCTIONAL_TESTS=false

ci/test/00_setup_env_native_old.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_old
10-
export DOCKER_NAME_TAG=ubuntu:18.04
10+
export DOCKER_NAME_TAG=ubuntu:20.04
1111
export PACKAGES="gcc-8 g++-8 libqt5gui5 libqt5core5a qtbase5-dev libqt5dbus5 qttools5-dev qttools5-dev-tools libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-iostreams-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libqrencode-dev libzip-dev zlib1g zlib1g-dev libcurl4-openssl-dev"
1212
export RUN_UNIT_TESTS=true
1313
# export RUN_FUNCTIONAL_TESTS=false

src/rpc/protocol.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ class SSLIOStreamDevice : public boost::iostreams::device<boost::iostreams::bidi
143143
bool connect(const std::string& server, const std::string& port)
144144
{
145145
boost::asio::ip::tcp::resolver resolver(GetIOService(stream));
146-
boost::asio::ip::tcp::resolver::query query(server.c_str(), port.c_str());
147-
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
148-
boost::asio::ip::tcp::resolver::iterator end;
149-
boost::system::error_code error = boost::asio::error::host_not_found;
150-
while (error && endpoint_iterator != end)
151-
{
146+
boost::system::error_code error;
147+
148+
for (const auto& res : resolver.resolve(server, port)) {
152149
stream.lowest_layer().close();
153-
stream.lowest_layer().connect(*endpoint_iterator++, error);
150+
stream.lowest_layer().connect(res, error);
151+
152+
if (!error) {
153+
return true;
154+
}
154155
}
155-
if (error)
156-
return false;
157-
return true;
156+
157+
return false;
158158
}
159159

160160
private:

src/rpc/server.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,19 @@ bool ClientAllowed(const boost::asio::ip::address& address)
500500
{
501501
// Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses
502502
if (address.is_v6()
503-
&& (address.to_v6().is_v4_compatible()
504-
|| address.to_v6().is_v4_mapped()))
505-
return ClientAllowed(address.to_v6().to_v4());
503+
&& (address.to_v6() <= boost::asio::ip::make_address_v6("::ffff:ffff")
504+
|| address.to_v6().is_v4_mapped())) {
505+
auto address6 = address.to_v6();
506+
auto bytes = address6.to_bytes();
507+
508+
return ClientAllowed(boost::asio::ip::address_v4({bytes[12], bytes[13], bytes[14], bytes[15]}));
509+
}
506510

507511
if (address == asio::ip::address_v4::loopback()
508512
|| address == asio::ip::address_v6::loopback()
509513
|| (address.is_v4()
510514
// Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet)
511-
&& (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000))
515+
&& (address.to_v4().to_bytes()[0] == 127)))
512516
return true;
513517

514518
const string strAddress = address.to_string();
@@ -661,7 +665,7 @@ void StartRPCThreads()
661665
acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error);
662666

663667
acceptor->bind(endpoint);
664-
acceptor->listen(socket_base::max_connections);
668+
acceptor->listen(socket_base::max_listen_connections);
665669

666670
RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
667671

@@ -684,7 +688,7 @@ void StartRPCThreads()
684688
acceptor->open(endpoint.protocol());
685689
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
686690
acceptor->bind(endpoint);
687-
acceptor->listen(socket_base::max_connections);
691+
acceptor->listen(socket_base::max_listen_connections);
688692

689693
RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
690694

src/wallet/diagnose.cpp

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool Diagnose::m_hasPoolProjects = false;
1515
bool Diagnose::m_configured_for_investor_mode = false;
1616
std::unordered_map<Diagnose::TestNames, Diagnose*> Diagnose::m_name_to_test_map;
1717
CCriticalSection Diagnose::cs_diagnostictests;
18-
boost::asio::io_service Diagnose::s_ioService;
18+
boost::asio::io_context Diagnose::s_ioService;
1919

2020
/**
2121
* The function check the time is correct on your PC. It checks the skew in the clock.
@@ -102,102 +102,39 @@ void VerifyClock::timerHandle(
102102
void VerifyClock::connectToNTPHost()
103103
{
104104
m_startedTesting = true;
105-
boost::asio::ip::udp::resolver resolver(s_ioService);
106105

107106
try {
108107
FastRandomContext rng;
109108

110109
std::string ntp_host = m_ntp_hosts[rng.randrange(m_ntp_hosts.size())];
111110

112-
#if BOOST_VERSION > 106501
113-
// results_type is only in boost 1.66 and above.
114-
boost::asio::ip::udp::resolver::results_type receiver_endpoint;
111+
boost::asio::ip::udp::resolver resolver(s_ioService);
112+
auto resolved = resolver.resolve(boost::asio::ip::udp::v4(), ntp_host, "ntp");
115113

116-
receiver_endpoint = resolver.resolve(boost::asio::ip::udp::v4(), ntp_host, "ntp");
114+
if (m_udpSocket.is_open())
115+
m_udpSocket.close();
116+
m_udpSocket.open(boost::asio::ip::udp::v4());
117+
boost::asio::connect(m_udpSocket, resolved);
117118

118-
if (receiver_endpoint == boost::asio::ip::udp::resolver::iterator()) {
119-
// If can not connect to server, then finish the test with a warning.
120-
clkReportResults(0, true);
121-
} else {
122-
if (m_udpSocket.is_open())
123-
m_udpSocket.close();
124-
m_udpSocket.open(boost::asio::ip::udp::v4());
125-
126-
// Let's put the send here to reduce the complexity of this. No need for the send to be async.
127-
size_t bytes_transferred = 0;
128-
129-
try {
130-
bytes_transferred = m_udpSocket.send_to(boost::asio::buffer(m_sendBuf), *receiver_endpoint);
131-
} catch (boost::system::error_code& e) {
132-
clkReportResults(0, true);
133-
}
134-
135-
if (bytes_transferred != 48) {
136-
clkReportResults(0, true);
137-
} else {
138-
m_udpSocket.async_receive_from(
139-
boost::asio::buffer(m_recvBuf),
140-
m_sender_endpoint,
141-
boost::bind(&VerifyClock::sockRecvHandle, this,
142-
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
143-
}
144-
}
119+
size_t bytes_transferred = m_udpSocket.send(boost::asio::buffer(m_sendBuf));
145120

146-
#else
147-
boost::asio::ip::udp::resolver::query query(
148-
boost::asio::ip::udp::v4(),
149-
ntp_host,
150-
"ntp");
151-
152-
boost::asio::ip::udp::resolver::iterator endpoint_iterator = resolver.resolve(query);
153-
154-
if (endpoint_iterator == boost::asio::ip::udp::resolver::iterator()) {
155-
// If can not connect to server, then finish the test with a warning.
121+
if (bytes_transferred != 48) {
156122
clkReportResults(0, true);
157123
} else {
158-
if (m_udpSocket.is_open())
159-
m_udpSocket.close();
160-
m_udpSocket.open(boost::asio::ip::udp::v4());
161-
162-
// Let's put the send here to reduce the complexity of this. No need for the send to be async.
163-
size_t bytes_transferred = 0;
164-
165-
try {
166-
bytes_transferred = m_udpSocket.send_to(boost::asio::buffer(m_sendBuf), *endpoint_iterator);
167-
} catch (boost::system::error_code& e) {
168-
clkReportResults(0, true);
169-
}
170-
171-
if (bytes_transferred != 48) {
172-
clkReportResults(0, true);
173-
} else {
174-
boost::asio::ip::udp::endpoint sender_endpoint;
175-
176-
m_udpSocket.async_receive_from(
177-
boost::asio::buffer(m_recvBuf),
178-
sender_endpoint,
179-
boost::bind(&VerifyClock::sockRecvHandle, this,
180-
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
181-
}
124+
m_udpSocket.async_receive(
125+
boost::asio::buffer(m_recvBuf),
126+
boost::bind(&VerifyClock::sockRecvHandle, this,
127+
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
182128
}
183-
#endif
184129
} catch (...) {
185130
clkReportResults(0, true);
186131
}
187132
}
188133

189-
void VerifyTCPPort::handle_connect(const boost::system::error_code& err,
190-
boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
134+
void VerifyTCPPort::handle_connect(const boost::system::error_code& err)
191135
{
192136
if (!err) {
193137
this->TCPFinished();
194-
} else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
195-
// The connection failed. Try the next endpoint in the list.
196-
m_tcpSocket.close();
197-
boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
198-
m_tcpSocket.async_connect(endpoint,
199-
boost::bind(&VerifyTCPPort::handle_connect, this,
200-
boost::asio::placeholders::error, ++endpoint_iterator));
201138
} else {
202139
m_tcpSocket.close();
203140
m_results = WARNING;

0 commit comments

Comments
 (0)