From 8b45d355d84d6de99b5739aacf8c7db99ecf67f9 Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:19:22 +0200 Subject: [PATCH] build: upgrade grpc to 1.54.3 (#1619) Co-authored-by: battlmonstr --- cmake/cmake_format.yaml | 2 + cmake/compiler_settings.cmake | 7 +- cmake/compiler_settings_sanitize.cmake | 25 ++ cmake/conan.cmake | 36 +- conanfile.py | 18 +- silkworm/core/execution/evm_test.cpp | 2 + .../infra/concurrency/awaitable_future.hpp | 12 +- .../concurrency/awaitable_future_test.cpp | 90 ++--- silkworm/infra/concurrency/co_spawn_sw.hpp | 345 +----------------- .../execution/execution.grpc.pb.cc | 26 +- .../execution/execution.grpc.pb.h | 34 +- .../execution/execution.pb.cc | 0 .../execution/execution.pb.h | 2 +- .../execution/execution_mock.grpc.pb.h | 11 +- .../p2psentry/sentry.grpc.pb.cc | 26 +- .../p2psentry/sentry.grpc.pb.h | 34 +- .../p2psentry/sentry.pb.cc | 0 .../{3.21.4 => 3.21.12}/p2psentry/sentry.pb.h | 2 +- .../p2psentry/sentry_mock.grpc.pb.h | 11 +- .../remote/ethbackend.grpc.pb.cc | 26 +- .../remote/ethbackend.grpc.pb.h | 34 +- .../remote/ethbackend.pb.cc | 0 .../remote/ethbackend.pb.h | 2 +- .../remote/ethbackend_mock.grpc.pb.h | 11 +- .../{3.21.4 => 3.21.12}/remote/kv.grpc.pb.cc | 26 +- .../{3.21.4 => 3.21.12}/remote/kv.grpc.pb.h | 34 +- .../{3.21.4 => 3.21.12}/remote/kv.pb.cc | 0 .../{3.21.4 => 3.21.12}/remote/kv.pb.h | 2 +- .../remote/kv_mock.grpc.pb.h | 11 +- .../txpool/mining.grpc.pb.cc | 26 +- .../txpool/mining.grpc.pb.h | 34 +- .../{3.21.4 => 3.21.12}/txpool/mining.pb.cc | 0 .../{3.21.4 => 3.21.12}/txpool/mining.pb.h | 2 +- .../txpool/mining_mock.grpc.pb.h | 11 +- .../txpool/txpool.grpc.pb.cc | 26 +- .../txpool/txpool.grpc.pb.h | 34 +- .../{3.21.4 => 3.21.12}/txpool/txpool.pb.cc | 0 .../{3.21.4 => 3.21.12}/txpool/txpool.pb.h | 2 +- .../txpool/txpool_mock.grpc.pb.h | 11 +- .../{3.21.4 => 3.21.12}/types/types.pb.cc | 0 .../{3.21.4 => 3.21.12}/types/types.pb.h | 2 +- silkworm/interfaces/generate_grpc.cmake | 13 +- .../api/active_direct_service_test.cpp | 6 +- .../node/execution/api/direct_service.cpp | 3 +- .../execution/api/direct_service_test.cpp | 6 +- silkworm/node/stagedsync/execution_engine.cpp | 29 +- silkworm/node/stagedsync/execution_engine.hpp | 2 +- .../node/stagedsync/execution_engine_test.cpp | 60 ++- .../node/test_util/mock_execution_engine.hpp | 2 +- silkworm/rpc/http/connection.cpp | 2 + silkworm/sentry/rlpx/crypto/hmac.cpp | 5 + .../internals/header_chain_plus_exec_test.cpp | 24 +- third_party/blst/CMakeLists.txt | 6 +- third_party/cmake-conan/conan.cmake | 204 ++++++++--- 54 files changed, 603 insertions(+), 736 deletions(-) create mode 100644 cmake/compiler_settings_sanitize.cmake rename silkworm/interfaces/{3.21.4 => 3.21.12}/execution/execution.grpc.pb.cc (98%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/execution/execution.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/execution/execution.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/execution/execution.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/execution/execution_mock.grpc.pb.h (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/p2psentry/sentry.grpc.pb.cc (98%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/p2psentry/sentry.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/p2psentry/sentry.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/p2psentry/sentry.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/p2psentry/sentry_mock.grpc.pb.h (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/ethbackend.grpc.pb.cc (98%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/ethbackend.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/ethbackend.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/ethbackend.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/ethbackend_mock.grpc.pb.h (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/kv.grpc.pb.cc (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/kv.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/kv.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/kv.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/remote/kv_mock.grpc.pb.h (95%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/mining.grpc.pb.cc (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/mining.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/mining.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/mining.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/mining_mock.grpc.pb.h (95%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/txpool.grpc.pb.cc (97%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/txpool.grpc.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/txpool.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/txpool.pb.h (99%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/txpool/txpool_mock.grpc.pb.h (95%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/types/types.pb.cc (100%) rename silkworm/interfaces/{3.21.4 => 3.21.12}/types/types.pb.h (99%) diff --git a/cmake/cmake_format.yaml b/cmake/cmake_format.yaml index b7b8d5a50a..1b92bc5c8e 100644 --- a/cmake/cmake_format.yaml +++ b/cmake/cmake_format.yaml @@ -5,7 +5,9 @@ parse: PATH_OR_REFERENCE: '*' INSTALL_FOLDER: '*' BUILD: '*' + OPTIONS: '*' PROFILE: '*' + CONF: '*' silkworm_library: flags: - NO_TEST diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index ed0f6847ee..73ff6b60e7 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -14,6 +14,8 @@ limitations under the License. ]] +include(${CMAKE_CURRENT_LIST_DIR}/compiler_settings_sanitize.cmake) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") message("MSVC_VERSION = ${MSVC_VERSION}") @@ -91,10 +93,7 @@ else() message(WARNING "${CMAKE_CXX_COMPILER_ID} is not a supported compiler. Use at your own risk.") endif() -if(SILKWORM_SANITIZE) - set(SILKWORM_SANITIZE_COMPILER_OPTIONS -fno-omit-frame-pointer -fno-sanitize-recover=all - -fsanitize=${SILKWORM_SANITIZE} - ) +if(SILKWORM_SANITIZE_COMPILER_OPTIONS) add_compile_options(${SILKWORM_SANITIZE_COMPILER_OPTIONS}) add_link_options(${SILKWORM_SANITIZE_COMPILER_OPTIONS}) add_compile_definitions(SILKWORM_SANITIZE) diff --git a/cmake/compiler_settings_sanitize.cmake b/cmake/compiler_settings_sanitize.cmake new file mode 100644 index 0000000000..a1ebd10ef7 --- /dev/null +++ b/cmake/compiler_settings_sanitize.cmake @@ -0,0 +1,25 @@ +#[[ + Copyright 2024 The Silkworm Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +]] + +if(SILKWORM_SANITIZE) + # cmake-format: off + set(SILKWORM_SANITIZE_COMPILER_OPTIONS + -fno-omit-frame-pointer + -fno-sanitize-recover=all + -fsanitize=${SILKWORM_SANITIZE} + ) + # cmake-format: on +endif() diff --git a/cmake/conan.cmake b/cmake/conan.cmake index 860fce8846..6d29ab88b9 100644 --- a/cmake/conan.cmake +++ b/cmake/conan.cmake @@ -14,6 +14,8 @@ limitations under the License. ]] +include(${CMAKE_CURRENT_LIST_DIR}/compiler_settings_sanitize.cmake) + function(guess_conan_profile) if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "") set(ARCH_NAME "") @@ -64,9 +66,39 @@ if(NOT DEFINED CONAN_PROFILE) endif() message(STATUS "CONAN_PROFILE: ${CONAN_PROFILE}") +set(CONAN_BUILD "missing") +set(CONAN_CXXFLAGS_ARG) +set(CONAN_OPTIONS) + +if(SILKWORM_SANITIZE_COMPILER_OPTIONS) + set(CONAN_CXXFLAGS ${SILKWORM_SANITIZE_COMPILER_OPTIONS}) + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND CONAN_CXXFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() + + list(JOIN CONAN_CXXFLAGS "\", \"" CONAN_CXXFLAGS_STR) + set(CONAN_CXXFLAGS_STR "[\"${CONAN_CXXFLAGS_STR}\"]") + set(CONAN_CXXFLAGS_ARG "tools.build:cxxflags=${CONAN_CXXFLAGS_STR}") + + list(APPEND CONAN_OPTIONS "boost:zlib=False") + + # libraries that needs to be rebuilt with sanitize flags + # cmake-format: off + set(CONAN_BUILD + abseil + boost + grpc + protobuf + ) + # cmake-format: on +endif() + conan_cmake_install( PATH_OR_REFERENCE "${CONAN_BINARY_DIR}" INSTALL_FOLDER "${CONAN_BINARY_DIR}" - BUILD missing - PROFILE "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}" OPTIONS "${CMAKE_CONAN_OPTIONS}" + BUILD ${CONAN_BUILD} + OPTIONS ${CONAN_OPTIONS} + PROFILE "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}" + CONF "${CONAN_CXXFLAGS_ARG}" ) diff --git a/conanfile.py b/conanfile.py index e42b014ddc..3e769ae826 100644 --- a/conanfile.py +++ b/conanfile.py @@ -25,22 +25,22 @@ def requirements(self): self.requires('ms-gsl/4.0.0') self.requires('nlohmann_json/3.11.3') self.requires('tl-expected/1.1.0') - self.requires('zlib/1.2.13') + self.requires('zlib/1.3.1') if self.settings.arch == 'wasm': return - self.requires('abseil/20220623.0') - self.requires('asio-grpc/2.4.0') + self.requires('abseil/20230125.3') + self.requires('asio-grpc/2.9.2') self.requires('benchmark/1.6.1') - self.requires('boost/1.81.0') + self.requires('boost/1.83.0') self.requires('cli11/2.2.0') self.requires('gmp/6.2.1') - self.requires('grpc/1.48.0') + self.requires('grpc/1.54.3') self.requires('gtest/1.12.1') self.requires('jwt-cpp/0.6.0') self.requires('mimalloc/2.1.2') - self.requires('openssl/1.1.1s') - self.requires('protobuf/3.21.4') + self.requires('openssl/3.2.1') + self.requires('protobuf/3.21.12') self.requires('roaring/1.1.2') self.requires('snappy/1.1.7') self.requires('spdlog/1.12.0') @@ -63,6 +63,10 @@ def configure(self): self.options['mimalloc'].override = True self.options['boost'].asio_no_deprecated = True + if self.settings.os == 'Macos': + CMAKE_OSX_DEPLOYMENT_TARGET = '10.13' + os_version_min_flag = f'-mmacosx-version-min={CMAKE_OSX_DEPLOYMENT_TARGET}' + self.options['boost'].extra_b2_flags = f'cxxflags="{os_version_min_flag}" linkflags="{os_version_min_flag}"' # Disable building unused boost components # note: changing default options above forces a boost rebuild anyway diff --git a/silkworm/core/execution/evm_test.cpp b/silkworm/core/execution/evm_test.cpp index 9dfa2f9f08..fd586ea918 100644 --- a/silkworm/core/execution/evm_test.cpp +++ b/silkworm/core/execution/evm_test.cpp @@ -249,6 +249,7 @@ TEST_CASE("Smart contract with storage", "[core][execution]") { CHECK(state.get_current_storage(contract_address, key0) == new_val); } +#if !(defined(SILKWORM_SANITIZE) && defined(__APPLE__)) TEST_CASE("Maximum call depth", "[core][execution]") { Block block{}; block.header.number = 1'431'916; @@ -317,6 +318,7 @@ TEST_CASE("Maximum call depth", "[core][execution]") { CHECK(res.status == EVMC_INVALID_INSTRUCTION); CHECK(res.data.empty()); } +#endif // SILKWORM_SANITIZE TEST_CASE("DELEGATECALL", "[core][execution]") { Block block{}; diff --git a/silkworm/infra/concurrency/awaitable_future.hpp b/silkworm/infra/concurrency/awaitable_future.hpp index 62b4445d66..07895153a9 100644 --- a/silkworm/infra/concurrency/awaitable_future.hpp +++ b/silkworm/infra/concurrency/awaitable_future.hpp @@ -44,7 +44,7 @@ class AwaitableFuture { AwaitableFuture(AwaitableFuture&&) noexcept = default; AwaitableFuture& operator=(AwaitableFuture&&) noexcept = default; - Task get_async() { + Task get() { try { std::optional result = co_await channel_->async_receive(boost::asio::use_awaitable); co_return std::move(result.value()); @@ -54,14 +54,8 @@ class AwaitableFuture { } } - T get() { - try { - std::optional result = channel_->async_receive(boost::asio::use_future).get(); - return std::move(result.value()); - } catch (const boost::system::system_error& ex) { - close_and_throw_if_cancelled(ex); - throw ex; - } + Task get_async() { + return get(); } private: diff --git a/silkworm/infra/concurrency/awaitable_future_test.cpp b/silkworm/infra/concurrency/awaitable_future_test.cpp index 53f3f309e0..f960a0e121 100644 --- a/silkworm/infra/concurrency/awaitable_future_test.cpp +++ b/silkworm/infra/concurrency/awaitable_future_test.cpp @@ -26,6 +26,8 @@ #include #include +#include + #include "active_component.hpp" namespace silkworm { @@ -46,15 +48,14 @@ class TestException : public std::runtime_error { }; TEST_CASE("awaitable future") { - asio::io_context io; - asio::executor_work_guard work_guard{io.get_executor()}; - AwaitablePromise promise{io.get_executor()}; + test_util::TaskRunner runner; + AwaitablePromise promise{runner.context().get_executor()}; SECTION("trivial use") { auto future = promise.get_future(); promise.set_value(42); - auto value = future.get(); + auto value = runner.run(future.get()); CHECK(value == 42); } @@ -63,7 +64,7 @@ TEST_CASE("awaitable future") { promise.set_value(42); auto future = promise.get_future(); - auto value = future.get(); + auto value = runner.run(future.get()); CHECK(value == 42); } @@ -73,7 +74,7 @@ TEST_CASE("awaitable future") { promise.set_exception(std::make_exception_ptr(TestException())); - CHECK_THROWS_AS(future.get(), TestException); + CHECK_THROWS_AS(runner.run(future.get()), TestException); } SECTION("variation of setting exception instead of value") { @@ -85,7 +86,7 @@ TEST_CASE("awaitable future") { promise.set_exception(std::current_exception()); } - CHECK_THROWS_AS(future.get(), TestException); + CHECK_THROWS_AS(runner.run(future.get()), TestException); } SECTION("setting value two times fails") { @@ -101,14 +102,16 @@ TEST_CASE("awaitable future") { } SECTION("returning the future from a function") { + asio::io_context& io = runner.context(); auto future = create_promise_and_set_value(io.get_executor(), 42); - auto value = future.get(); + auto value = runner.run(future.get()); CHECK(value == 42); } SECTION("returning the future from a function (variation)") { + asio::io_context& io = runner.context(); auto returned_future = [executor = io.get_executor()]() { concurrency::AwaitablePromise promise1{executor}; auto future = promise1.get_future(); @@ -116,50 +119,40 @@ TEST_CASE("awaitable future") { return future; }(); - auto value = returned_future.get(); + auto value = runner.run(returned_future.get()); CHECK(value == 42); } SECTION("writing and reading from different threads") { - auto future = promise.get_future(); - int value{0}; std::thread concurrent( - [&](AwaitableFuture&& moved_future) { - value = moved_future.get(); - io.stop(); + [&](AwaitableFuture moved_future) { + value = runner.run(moved_future.get()); }, - std::move(future)); + promise.get_future()); promise.set_value(42); - io.run(); concurrent.join(); CHECK(value == 42); } SECTION("writing and reading from different threads") { - auto future = promise.get_future(); - int value{0}; std::thread concurrent( - [&](AwaitableFuture&& moved_future) { - value = moved_future.get(); - io.stop(); + [&](AwaitableFuture moved_future) { + value = runner.run(moved_future.get()); }, - std::move(future)); + promise.get_future()); - asio::co_spawn( - io, + runner.run( [&]() -> Task { promise.set_value(42); co_return; - }, - asio::detached); + }()); - io.run(); concurrent.join(); CHECK(value == 42); @@ -168,17 +161,13 @@ TEST_CASE("awaitable future") { SECTION("using coroutines in read in the same io_context, write before read") { int value{0}; - asio::co_spawn( - io, + promise.set_value(42); + + runner.run( [&]() -> Task { auto future = promise.get_future(); - value = co_await future.get_async(); - io.stop(); - }, - asio::detached); - - promise.set_value(42); - io.run(); + value = co_await future.get(); + }()); CHECK(value == 42); } @@ -186,17 +175,13 @@ TEST_CASE("awaitable future") { SECTION("variation of using coroutines in the same io_context, write before read") { auto future = promise.get_future(); + promise.set_value(42); + int value{0}; - asio::co_spawn( - io, + runner.run( [&]() -> Task { - value = co_await future.get_async(); - io.stop(); - }, - asio::detached); - - promise.set_value(42); - io.run(); + value = co_await future.get(); + }()); CHECK(value == 42); } @@ -205,27 +190,25 @@ TEST_CASE("awaitable future") { auto future = promise.get_future(); int value{0}; - auto lambda = [&](AwaitableFuture&& moved_future) -> Task { - value = co_await moved_future.get_async(); - io.stop(); + auto lambda = [&](AwaitableFuture moved_future) -> Task { + value = co_await moved_future.get(); }; - asio::co_spawn(io, lambda(std::move(future)), asio::detached); - promise.set_value(42); - io.run(); + runner.run(lambda(std::move(future))); CHECK(value == 42); } SECTION("using coroutine for both read and write, read before write") { + asio::io_context& io = runner.context(); int value{0}; asio::co_spawn( io, [&]() -> Task { auto future = promise.get_future(); - value = co_await future.get_async(); + value = co_await future.get(); io.stop(); }, asio::detached); @@ -244,6 +227,7 @@ TEST_CASE("awaitable future") { } SECTION("cancellation after read") { + asio::io_context& io = runner.context(); int value{0}; boost::system::error_code code; @@ -253,7 +237,7 @@ TEST_CASE("awaitable future") { [&]() -> Task { auto future = promise.get_future(); try { - value = co_await future.get_async(); + value = co_await future.get(); } catch (const boost::system::system_error& se) { code = se.code(); } diff --git a/silkworm/infra/concurrency/co_spawn_sw.hpp b/silkworm/infra/concurrency/co_spawn_sw.hpp index ec7e818e46..73c0298373 100644 --- a/silkworm/infra/concurrency/co_spawn_sw.hpp +++ b/silkworm/infra/concurrency/co_spawn_sw.hpp @@ -14,360 +14,21 @@ limitations under the License. */ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - #pragma once -#include -#include -#include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include +#include #include -namespace silkworm::concurrency::detail { - -using boost::asio::awaitable; -using boost::asio::cancellation_signal; -using boost::asio::cancellation_slot; -using boost::asio::cancellation_state; -using boost::asio::cancellation_type_t; -using boost::asio::dispatch; -using boost::asio::enable_total_cancellation; -using boost::asio::get_associated_cancellation_slot; -using boost::asio::post; -using boost::asio::result_of; -using boost::asio::use_awaitable_t; -using boost::asio::detail::awaitable_as_function; -using boost::asio::detail::awaitable_handler; -using boost::asio::detail::awaitable_thread_entry_point; -using boost::asio::detail::awaitable_thread_has_context_switched; -using boost::asio::detail::make_co_spawn_work_guard; - -template -awaitable co_spawn_entry_point( - awaitable*, - Executor ex, - F f, - Handler handler) { - auto spawn_work = make_co_spawn_work_guard(ex); - auto handler_work = make_co_spawn_work_guard( - boost::asio::get_associated_executor(handler, ex)); - - (void)co_await (dispatch)( - use_awaitable_t{__FILE__, __LINE__, "co_spawn_entry_point"}); - - (co_await awaitable_thread_has_context_switched{}) = false; - std::exception_ptr e = nullptr; - bool done = false; - try { - T t = co_await f(); - - done = true; - - bool switched = (co_await awaitable_thread_has_context_switched{}); - if (!switched) { - (void)co_await (post)( - use_awaitable_t{__FILE__, - __LINE__, "co_spawn_entry_point"}); - } - - (dispatch)(handler_work.get_executor(), - [handler = std::move(handler), t = std::move(t)]() mutable { - std::move(handler)(std::exception_ptr(), std::move(t)); - }); - - co_return; - } catch (...) { - if (done) { - throw; - } - e = std::current_exception(); - } - - bool switched = (co_await awaitable_thread_has_context_switched{}); - if (!switched) { - (void)co_await (post)( - use_awaitable_t{__FILE__, __LINE__, "co_spawn_entry_point"}); - } - - (dispatch)(handler_work.get_executor(), - [handler = std::move(handler), e]() mutable { - std::move(handler)(e, T()); - }); -} - -template -awaitable co_spawn_entry_point( - awaitable*, - Executor ex, - F f, - Handler handler) { - auto spawn_work = make_co_spawn_work_guard(ex); - auto handler_work = make_co_spawn_work_guard( - boost::asio::get_associated_executor(handler, ex)); - - (void)co_await (dispatch)( - use_awaitable_t{__FILE__, __LINE__, "co_spawn_entry_point"}); - - (co_await awaitable_thread_has_context_switched{}) = false; - std::exception_ptr e = nullptr; - try { - co_await f(); - } catch (...) { - e = std::current_exception(); - } - - bool switched = (co_await awaitable_thread_has_context_switched{}); - if (!switched) { - (void)co_await (post)( - use_awaitable_t{__FILE__, __LINE__, "co_spawn_entry_point"}); - } - - (dispatch)(handler_work.get_executor(), - [handler = std::move(handler), e]() mutable { - std::move(handler)(e); - }); -} - -template -class co_spawn_cancellation_handler { - public: - co_spawn_cancellation_handler(const Handler&, Executor ex) - : signal_(std::make_shared()), - ex_(std::move(ex)) { - } - - cancellation_slot slot() { - return signal_->slot(); - } - - void operator()(cancellation_type_t type) { - auto signal_weak_ptr = std::weak_ptr(signal_); - boost::asio::dispatch(ex_, [signal_weak_ptr = std::move(signal_weak_ptr), type] { - auto signal = signal_weak_ptr.lock(); - if (signal) { - signal->emit(type); - } - }); - } - - private: - std::shared_ptr signal_; - Executor ex_; -}; - -template -class co_spawn_cancellation_handler< - Handler, - Executor, - typename std::enable_if::asio_associated_executor_is_unspecialised, void>::value>::type> { - public: - co_spawn_cancellation_handler(const Handler&, const Executor&) { - } - - cancellation_slot slot() { - return signal_.slot(); - } - - void operator()(cancellation_type_t type) { - signal_.emit(type); - } - - private: - cancellation_signal signal_; -}; - -template -class initiate_co_spawn { - public: - typedef Executor executor_type; - - template - explicit initiate_co_spawn(OtherExecutor ex) - : ex_(std::move(ex)) { - } - - executor_type get_executor() const BOOST_ASIO_NOEXCEPT { - return ex_; - } - - template - void operator()(Handler&& handler, F&& f) const { - typedef typename result_of::type awaitable_type; - typedef typename std::decay::type handler_type; - typedef co_spawn_cancellation_handler cancel_handler_type; - - auto slot = boost::asio::get_associated_cancellation_slot(handler); - cancel_handler_type* cancel_handler = - slot.is_connected() - ? &slot.template emplace(handler, ex_) - : nullptr; - - cancellation_slot proxy_slot( - cancel_handler - ? cancel_handler->slot() - : cancellation_slot()); - - cancellation_state cancel_state(proxy_slot); - - auto a = (co_spawn_entry_point)(static_cast(nullptr), - ex_, - std::forward(f), - std::forward(handler)); - awaitable_handler( - std::move(a), - ex_, - proxy_slot, - cancel_state) - .launch(); - } - - private: - Executor ex_; -}; - -} // namespace silkworm::concurrency::detail +#define co_spawn_sw co_spawn namespace silkworm::concurrency { -template < - typename Executor, - typename T, - typename AwaitableExecutor, - BOOST_ASIO_COMPLETION_TOKEN_FOR( - void(std::exception_ptr, T)) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(std::exception_ptr, T)) - co_spawn_sw( - const Executor& ex, - boost::asio::awaitable a, - CompletionToken&& token, - typename boost::asio::constraint< - (boost::asio::is_executor::value || boost::asio::execution::is_executor::value) && std::is_convertible::value>::type = 0) { - return boost::asio::async_initiate( - detail::initiate_co_spawn(AwaitableExecutor(ex)), - token, - detail::awaitable_as_function(std::move(a))); -} - -template < - typename Executor, - typename AwaitableExecutor, - BOOST_ASIO_COMPLETION_TOKEN_FOR( - void(std::exception_ptr)) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(std::exception_ptr)) - co_spawn_sw( - const Executor& ex, - boost::asio::awaitable a, - CompletionToken&& token, - typename boost::asio::constraint< - (boost::asio::is_executor::value || boost::asio::execution::is_executor::value) && std::is_convertible::value>::type = 0) { - return boost::asio::async_initiate( - detail::initiate_co_spawn(AwaitableExecutor(ex)), - token, - detail::awaitable_as_function(std::move(a))); -} - -template < - typename ExecutionContext, - typename T, - typename AwaitableExecutor, - BOOST_ASIO_COMPLETION_TOKEN_FOR( - void(std::exception_ptr, T)) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(std::exception_ptr, T)) - co_spawn_sw( - ExecutionContext& ctx, - boost::asio::awaitable a, - CompletionToken&& token, - typename boost::asio::constraint< - std::is_convertible::value && std::is_convertible::value>::type = 0) { - return (co_spawn_sw)(ctx.get_executor(), - std::move(a), - std::forward(token)); -} - -template < - typename ExecutionContext, - typename AwaitableExecutor, - BOOST_ASIO_COMPLETION_TOKEN_FOR( - void(std::exception_ptr)) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - void(std::exception_ptr)) - co_spawn_sw( - ExecutionContext& ctx, - boost::asio::awaitable a, - CompletionToken&& token, - typename boost::asio::constraint< - std::is_convertible::value && std::is_convertible::value>::type = 0) { - return (co_spawn_sw)(ctx.get_executor(), - std::move(a), - std::forward(token)); -} - -template < - typename Executor, - typename F, - BOOST_ASIO_COMPLETION_TOKEN_FOR(typename boost::asio::detail::awaitable_signature< - typename boost::asio::result_of::type>::type) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - typename boost::asio::detail::awaitable_signature::type>::type) - co_spawn_sw( - const Executor& ex, - F&& f, - CompletionToken&& token, - typename boost::asio::constraint< - boost::asio::is_executor::value || boost::asio::execution::is_executor::value>::type = 0) { - return boost::asio::async_initiate::type>::type>( - detail::initiate_co_spawn< - typename boost::asio::result_of::type::executor_type>(ex), - token, - std::forward(f)); -} - -template < - typename ExecutionContext, - typename F, - BOOST_ASIO_COMPLETION_TOKEN_FOR(typename boost::asio::detail::awaitable_signature< - typename boost::asio::result_of::type>::type) CompletionToken> -inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( - CompletionToken, - typename boost::asio::detail::awaitable_signature::type>::type = 0) - co_spawn_sw( - ExecutionContext& ctx, F&& f, CompletionToken&& token, - typename boost::asio::constraint< - std::is_convertible::value>::type) { - return (co_spawn_sw)(ctx.get_executor(), - std::forward(f), - std::forward(token)); -} +using namespace boost::asio; template inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( diff --git a/silkworm/interfaces/3.21.4/execution/execution.grpc.pb.cc b/silkworm/interfaces/3.21.12/execution/execution.grpc.pb.cc similarity index 98% rename from silkworm/interfaces/3.21.4/execution/execution.grpc.pb.cc rename to silkworm/interfaces/3.21.12/execution/execution.grpc.pb.cc index de17dbe55d..86b9975149 100644 --- a/silkworm/interfaces/3.21.4/execution/execution.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/execution/execution.grpc.pb.cc @@ -6,19 +6,19 @@ #include "execution/execution.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace execution { static const char* Execution_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/execution/execution.grpc.pb.h b/silkworm/interfaces/3.21.12/execution/execution.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/execution/execution.grpc.pb.h rename to silkworm/interfaces/3.21.12/execution/execution.grpc.pb.h index d65221b291..da68a9d274 100644 --- a/silkworm/interfaces/3.21.4/execution/execution.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/execution/execution.grpc.pb.h @@ -7,23 +7,23 @@ #include "execution/execution.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace execution { diff --git a/silkworm/interfaces/3.21.4/execution/execution.pb.cc b/silkworm/interfaces/3.21.12/execution/execution.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/execution/execution.pb.cc rename to silkworm/interfaces/3.21.12/execution/execution.pb.cc diff --git a/silkworm/interfaces/3.21.4/execution/execution.pb.h b/silkworm/interfaces/3.21.12/execution/execution.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/execution/execution.pb.h rename to silkworm/interfaces/3.21.12/execution/execution.pb.h index 18cfb6affb..febb3593bb 100644 --- a/silkworm/interfaces/3.21.4/execution/execution.pb.h +++ b/silkworm/interfaces/3.21.12/execution/execution.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/execution/execution_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/execution/execution_mock.grpc.pb.h similarity index 97% rename from silkworm/interfaces/3.21.4/execution/execution_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/execution/execution_mock.grpc.pb.h index b225ec740a..77a83de7bd 100644 --- a/silkworm/interfaces/3.21.4/execution/execution_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/execution/execution_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: execution/execution.proto +#ifndef GRPC_MOCK_execution_2fexecution_2eproto__INCLUDED +#define GRPC_MOCK_execution_2fexecution_2eproto__INCLUDED + #include "execution/execution.pb.h" #include "execution/execution.grpc.pb.h" -#include -#include +#include +#include #include namespace execution { @@ -65,5 +68,7 @@ class MockExecutionStub : public Execution::StubInterface { MOCK_METHOD3(PrepareAsyncFrozenBlocksRaw, ::grpc::ClientAsyncResponseReaderInterface< ::execution::FrozenBlocksResponse>*(::grpc::ClientContext* context, const ::google::protobuf::Empty& request, ::grpc::CompletionQueue* cq)); }; -} // namespace execution +} // namespace execution + +#endif // GRPC_MOCK_execution_2fexecution_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.cc b/silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.cc similarity index 98% rename from silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.cc rename to silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.cc index c57aef4316..cbbeb2c6fc 100644 --- a/silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.cc @@ -6,19 +6,19 @@ #include "p2psentry/sentry.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace sentry { static const char* Sentry_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.h b/silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.h rename to silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.h index b68c45a4da..45fc0caf4d 100644 --- a/silkworm/interfaces/3.21.4/p2psentry/sentry.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/p2psentry/sentry.grpc.pb.h @@ -7,23 +7,23 @@ #include "p2psentry/sentry.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace sentry { diff --git a/silkworm/interfaces/3.21.4/p2psentry/sentry.pb.cc b/silkworm/interfaces/3.21.12/p2psentry/sentry.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/p2psentry/sentry.pb.cc rename to silkworm/interfaces/3.21.12/p2psentry/sentry.pb.cc diff --git a/silkworm/interfaces/3.21.4/p2psentry/sentry.pb.h b/silkworm/interfaces/3.21.12/p2psentry/sentry.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/p2psentry/sentry.pb.h rename to silkworm/interfaces/3.21.12/p2psentry/sentry.pb.h index eea6aa22c5..3e5c9b1e62 100644 --- a/silkworm/interfaces/3.21.4/p2psentry/sentry.pb.h +++ b/silkworm/interfaces/3.21.12/p2psentry/sentry.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/p2psentry/sentry_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/p2psentry/sentry_mock.grpc.pb.h similarity index 97% rename from silkworm/interfaces/3.21.4/p2psentry/sentry_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/p2psentry/sentry_mock.grpc.pb.h index b248a8ff45..96c4927604 100644 --- a/silkworm/interfaces/3.21.4/p2psentry/sentry_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/p2psentry/sentry_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: p2psentry/sentry.proto +#ifndef GRPC_MOCK_p2psentry_2fsentry_2eproto__INCLUDED +#define GRPC_MOCK_p2psentry_2fsentry_2eproto__INCLUDED + #include "p2psentry/sentry.pb.h" #include "p2psentry/sentry.grpc.pb.h" -#include -#include +#include +#include #include namespace sentry { @@ -59,5 +62,7 @@ class MockSentryStub : public Sentry::StubInterface { MOCK_METHOD3(PrepareAsyncNodeInfoRaw, ::grpc::ClientAsyncResponseReaderInterface< ::types::NodeInfoReply>*(::grpc::ClientContext* context, const ::google::protobuf::Empty& request, ::grpc::CompletionQueue* cq)); }; -} // namespace sentry +} // namespace sentry + +#endif // GRPC_MOCK_p2psentry_2fsentry_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.cc b/silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.cc similarity index 98% rename from silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.cc rename to silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.cc index 0a2da7338d..0e37cbe405 100644 --- a/silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.cc @@ -6,19 +6,19 @@ #include "remote/ethbackend.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace remote { static const char* ETHBACKEND_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.h b/silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.h rename to silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.h index efde57e642..86cb830571 100644 --- a/silkworm/interfaces/3.21.4/remote/ethbackend.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/remote/ethbackend.grpc.pb.h @@ -7,23 +7,23 @@ #include "remote/ethbackend.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace remote { diff --git a/silkworm/interfaces/3.21.4/remote/ethbackend.pb.cc b/silkworm/interfaces/3.21.12/remote/ethbackend.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/remote/ethbackend.pb.cc rename to silkworm/interfaces/3.21.12/remote/ethbackend.pb.cc diff --git a/silkworm/interfaces/3.21.4/remote/ethbackend.pb.h b/silkworm/interfaces/3.21.12/remote/ethbackend.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/remote/ethbackend.pb.h rename to silkworm/interfaces/3.21.12/remote/ethbackend.pb.h index 8674f7da19..0206884f13 100644 --- a/silkworm/interfaces/3.21.4/remote/ethbackend.pb.h +++ b/silkworm/interfaces/3.21.12/remote/ethbackend.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/remote/ethbackend_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/remote/ethbackend_mock.grpc.pb.h similarity index 97% rename from silkworm/interfaces/3.21.4/remote/ethbackend_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/remote/ethbackend_mock.grpc.pb.h index cca766d03d..faac000fd4 100644 --- a/silkworm/interfaces/3.21.4/remote/ethbackend_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/remote/ethbackend_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: remote/ethbackend.proto +#ifndef GRPC_MOCK_remote_2fethbackend_2eproto__INCLUDED +#define GRPC_MOCK_remote_2fethbackend_2eproto__INCLUDED + #include "remote/ethbackend.pb.h" #include "remote/ethbackend.grpc.pb.h" -#include -#include +#include +#include #include namespace remote { @@ -59,5 +62,7 @@ class MockETHBACKENDStub : public ETHBACKEND::StubInterface { MOCK_METHOD3(PrepareAsyncBorEventRaw, ::grpc::ClientAsyncResponseReaderInterface< ::remote::BorEventReply>*(::grpc::ClientContext* context, const ::remote::BorEventRequest& request, ::grpc::CompletionQueue* cq)); }; -} // namespace remote +} // namespace remote + +#endif // GRPC_MOCK_remote_2fethbackend_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/remote/kv.grpc.pb.cc b/silkworm/interfaces/3.21.12/remote/kv.grpc.pb.cc similarity index 97% rename from silkworm/interfaces/3.21.4/remote/kv.grpc.pb.cc rename to silkworm/interfaces/3.21.12/remote/kv.grpc.pb.cc index 3a4ea289a2..b06544fd36 100644 --- a/silkworm/interfaces/3.21.4/remote/kv.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/remote/kv.grpc.pb.cc @@ -6,19 +6,19 @@ #include "remote/kv.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace remote { static const char* KV_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/remote/kv.grpc.pb.h b/silkworm/interfaces/3.21.12/remote/kv.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/remote/kv.grpc.pb.h rename to silkworm/interfaces/3.21.12/remote/kv.grpc.pb.h index 7b02c6449b..b611efeee4 100644 --- a/silkworm/interfaces/3.21.4/remote/kv.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/remote/kv.grpc.pb.h @@ -7,23 +7,23 @@ #include "remote/kv.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace remote { diff --git a/silkworm/interfaces/3.21.4/remote/kv.pb.cc b/silkworm/interfaces/3.21.12/remote/kv.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/remote/kv.pb.cc rename to silkworm/interfaces/3.21.12/remote/kv.pb.cc diff --git a/silkworm/interfaces/3.21.4/remote/kv.pb.h b/silkworm/interfaces/3.21.12/remote/kv.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/remote/kv.pb.h rename to silkworm/interfaces/3.21.12/remote/kv.pb.h index 737bb4fbec..b3a2e516b0 100644 --- a/silkworm/interfaces/3.21.4/remote/kv.pb.h +++ b/silkworm/interfaces/3.21.12/remote/kv.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/remote/kv_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/remote/kv_mock.grpc.pb.h similarity index 95% rename from silkworm/interfaces/3.21.4/remote/kv_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/remote/kv_mock.grpc.pb.h index 15009f09b0..fc17e2af63 100644 --- a/silkworm/interfaces/3.21.4/remote/kv_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/remote/kv_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: remote/kv.proto +#ifndef GRPC_MOCK_remote_2fkv_2eproto__INCLUDED +#define GRPC_MOCK_remote_2fkv_2eproto__INCLUDED + #include "remote/kv.pb.h" #include "remote/kv.grpc.pb.h" -#include -#include +#include +#include #include namespace remote { @@ -44,5 +47,7 @@ class MockKVStub : public KV::StubInterface { MOCK_METHOD3(PrepareAsyncDomainRangeRaw, ::grpc::ClientAsyncResponseReaderInterface< ::remote::Pairs>*(::grpc::ClientContext* context, const ::remote::DomainRangeReq& request, ::grpc::CompletionQueue* cq)); }; -} // namespace remote +} // namespace remote + +#endif // GRPC_MOCK_remote_2fkv_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.cc b/silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.cc similarity index 97% rename from silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.cc rename to silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.cc index ad60ac6724..165f04f737 100644 --- a/silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.cc @@ -6,19 +6,19 @@ #include "txpool/mining.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace txpool { static const char* Mining_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.h b/silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.h rename to silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.h index 21d4fe4ccf..f0f6386544 100644 --- a/silkworm/interfaces/3.21.4/txpool/mining.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/mining.grpc.pb.h @@ -7,23 +7,23 @@ #include "txpool/mining.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace txpool { diff --git a/silkworm/interfaces/3.21.4/txpool/mining.pb.cc b/silkworm/interfaces/3.21.12/txpool/mining.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/txpool/mining.pb.cc rename to silkworm/interfaces/3.21.12/txpool/mining.pb.cc diff --git a/silkworm/interfaces/3.21.4/txpool/mining.pb.h b/silkworm/interfaces/3.21.12/txpool/mining.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/txpool/mining.pb.h rename to silkworm/interfaces/3.21.12/txpool/mining.pb.h index 5b5c4b1aca..c33281a896 100644 --- a/silkworm/interfaces/3.21.4/txpool/mining.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/mining.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/txpool/mining_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/txpool/mining_mock.grpc.pb.h similarity index 95% rename from silkworm/interfaces/3.21.4/txpool/mining_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/txpool/mining_mock.grpc.pb.h index a630615b93..d6915e252a 100644 --- a/silkworm/interfaces/3.21.4/txpool/mining_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/mining_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: txpool/mining.proto +#ifndef GRPC_MOCK_txpool_2fmining_2eproto__INCLUDED +#define GRPC_MOCK_txpool_2fmining_2eproto__INCLUDED + #include "txpool/mining.pb.h" #include "txpool/mining.grpc.pb.h" -#include -#include +#include +#include #include namespace txpool { @@ -41,5 +44,7 @@ class MockMiningStub : public Mining::StubInterface { MOCK_METHOD3(PrepareAsyncMiningRaw, ::grpc::ClientAsyncResponseReaderInterface< ::txpool::MiningReply>*(::grpc::ClientContext* context, const ::txpool::MiningRequest& request, ::grpc::CompletionQueue* cq)); }; -} // namespace txpool +} // namespace txpool + +#endif // GRPC_MOCK_txpool_2fmining_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.cc b/silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.cc similarity index 97% rename from silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.cc rename to silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.cc index 9278f80cca..8f0ef8afbc 100644 --- a/silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.cc +++ b/silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.cc @@ -6,19 +6,19 @@ #include "txpool/txpool.grpc.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace txpool { static const char* Txpool_method_names[] = { diff --git a/silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.h b/silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.h rename to silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.h index 0d34b61b1f..9617722c27 100644 --- a/silkworm/interfaces/3.21.4/txpool/txpool.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/txpool.grpc.pb.h @@ -7,23 +7,23 @@ #include "txpool/txpool.pb.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace txpool { diff --git a/silkworm/interfaces/3.21.4/txpool/txpool.pb.cc b/silkworm/interfaces/3.21.12/txpool/txpool.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/txpool/txpool.pb.cc rename to silkworm/interfaces/3.21.12/txpool/txpool.pb.cc diff --git a/silkworm/interfaces/3.21.4/txpool/txpool.pb.h b/silkworm/interfaces/3.21.12/txpool/txpool.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/txpool/txpool.pb.h rename to silkworm/interfaces/3.21.12/txpool/txpool.pb.h index 0abc458544..c61b5f6252 100644 --- a/silkworm/interfaces/3.21.4/txpool/txpool.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/txpool.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/3.21.4/txpool/txpool_mock.grpc.pb.h b/silkworm/interfaces/3.21.12/txpool/txpool_mock.grpc.pb.h similarity index 95% rename from silkworm/interfaces/3.21.4/txpool/txpool_mock.grpc.pb.h rename to silkworm/interfaces/3.21.12/txpool/txpool_mock.grpc.pb.h index 9a38c66d74..e1ccb318a8 100644 --- a/silkworm/interfaces/3.21.4/txpool/txpool_mock.grpc.pb.h +++ b/silkworm/interfaces/3.21.12/txpool/txpool_mock.grpc.pb.h @@ -2,11 +2,14 @@ // If you make any local change, they will be lost. // source: txpool/txpool.proto +#ifndef GRPC_MOCK_txpool_2ftxpool_2eproto__INCLUDED +#define GRPC_MOCK_txpool_2ftxpool_2eproto__INCLUDED + #include "txpool/txpool.pb.h" #include "txpool/txpool.grpc.pb.h" -#include -#include +#include +#include #include namespace txpool { @@ -41,5 +44,7 @@ class MockTxpoolStub : public Txpool::StubInterface { MOCK_METHOD3(PrepareAsyncNonceRaw, ::grpc::ClientAsyncResponseReaderInterface< ::txpool::NonceReply>*(::grpc::ClientContext* context, const ::txpool::NonceRequest& request, ::grpc::CompletionQueue* cq)); }; -} // namespace txpool +} // namespace txpool + +#endif // GRPC_MOCK_txpool_2ftxpool_2eproto__INCLUDED diff --git a/silkworm/interfaces/3.21.4/types/types.pb.cc b/silkworm/interfaces/3.21.12/types/types.pb.cc similarity index 100% rename from silkworm/interfaces/3.21.4/types/types.pb.cc rename to silkworm/interfaces/3.21.12/types/types.pb.cc diff --git a/silkworm/interfaces/3.21.4/types/types.pb.h b/silkworm/interfaces/3.21.12/types/types.pb.h similarity index 99% rename from silkworm/interfaces/3.21.4/types/types.pb.h rename to silkworm/interfaces/3.21.12/types/types.pb.h index ef3f1bfb31..10e9889de5 100644 --- a/silkworm/interfaces/3.21.4/types/types.pb.h +++ b/silkworm/interfaces/3.21.12/types/types.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/silkworm/interfaces/generate_grpc.cmake b/silkworm/interfaces/generate_grpc.cmake index 87b656f914..4fc6baf0de 100644 --- a/silkworm/interfaces/generate_grpc.cmake +++ b/silkworm/interfaces/generate_grpc.cmake @@ -18,7 +18,11 @@ set(protobuf_MODULE_COMPATIBLE TRUE) find_package(Protobuf REQUIRED) -set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}") +find_program( + PROTOBUF_PROTOC protoc + PATHS "${protobuf_INCLUDE_DIR}/../bin" NO_CACHE REQUIRED + NO_DEFAULT_PATH +) if(NOT EXISTS "${PROTOBUF_PROTOC}") message(FATAL_ERROR "PROTOBUF_PROTOC not found at '${PROTOBUF_PROTOC}'") endif() @@ -78,6 +82,7 @@ create_symlink_target(generate_types_proto_symlink "${OUT_PATH_SYMLINK}/types" " add_custom_command( OUTPUT ${TYPES_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS} "${TYPES_PROTO}" DEPENDS ${TYPES_PROTO} generate_types_proto_symlink COMMENT "Running C++ gRPC compiler on ${TYPES_PROTO}" @@ -99,6 +104,7 @@ create_symlink_target(generate_execution_grpc_symlink "${OUT_PATH_SYMLINK}/execu add_custom_command( OUTPUT ${EXECUTION_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${EXECUTION_PROTO}" DEPENDS ${EXECUTION_PROTO} generate_execution_grpc_symlink COMMENT "Running C++ gRPC compiler on ${EXECUTION_PROTO}" @@ -124,6 +130,7 @@ create_symlink_target(generate_sentry_grpc_symlink "${OUT_PATH_SYMLINK}/p2psentr add_custom_command( OUTPUT ${SENTRY_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${SENTRY_PROTO}" DEPENDS ${SENTRY_PROTO} generate_sentry_grpc_symlink COMMENT "Running C++ gRPC compiler on ${SENTRY_PROTO}" @@ -149,6 +156,7 @@ create_symlink_target(generate_remote_grpc_symlink "${OUT_PATH_SYMLINK}/remote" add_custom_command( OUTPUT ${KV_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${KV_PROTO}" DEPENDS ${KV_PROTO} generate_remote_grpc_symlink COMMENT "Running C++ gRPC compiler on ${KV_PROTO}" @@ -172,6 +180,7 @@ set(ETHBACKEND_SOURCES_SYMLINK add_custom_command( OUTPUT ${ETHBACKEND_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${ETHBACKEND_PROTO}" DEPENDS ${ETHBACKEND_PROTO} generate_remote_grpc_symlink COMMENT "Running C++ gRPC compiler on ${ETHBACKEND_PROTO}" @@ -197,6 +206,7 @@ create_symlink_target(generate_txpool_grpc_symlink "${OUT_PATH_SYMLINK}/txpool" add_custom_command( OUTPUT ${MINING_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${MINING_PROTO}" DEPENDS ${MINING_PROTO} generate_txpool_grpc_symlink COMMENT "Running C++ gRPC compiler on ${KV_PROTO}" @@ -220,6 +230,7 @@ set(TXPOOL_SOURCES_SYMLINK add_custom_command( OUTPUT ${TXPOOL_SOURCES_SYMLINK} + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${OUT_PATH}" COMMAND ${PROTOBUF_PROTOC} ARGS ${PROTOC_ARGS_GRPC} "${TXPOOL_PROTO}" DEPENDS ${TXPOOL_PROTO} generate_txpool_grpc_symlink COMMENT "Running C++ gRPC compiler on ${TXPOOL_PROTO}" diff --git a/silkworm/node/execution/api/active_direct_service_test.cpp b/silkworm/node/execution/api/active_direct_service_test.cpp index 10d1b50947..e25e6f630b 100644 --- a/silkworm/node/execution/api/active_direct_service_test.cpp +++ b/silkworm/node/execution/api/active_direct_service_test.cpp @@ -113,10 +113,8 @@ TEST_CASE_METHOD(ActiveDirectServiceTest, "ActiveDirectServiceTest::verify_chain for (const auto& [stagedsync_result, api_result] : test_vectors) { SECTION("result: " + std::to_string(stagedsync_result.index())) { EXPECT_CALL(*mock_execution_engine, verify_chain(new_head.hash)) - .WillOnce(InvokeWithoutArgs([&, result = stagedsync_result]() -> stagedsync::VerificationResultFuture { - stagedsync::VerificationResultPromise promise{context().get_executor()}; - promise.set_value(result); - return promise.get_future(); + .WillOnce(InvokeWithoutArgs([result = stagedsync_result]() -> Task { + co_return result; })); auto future = spawn_future(direct_service->validate_chain(new_head)); context().run(); diff --git a/silkworm/node/execution/api/direct_service.cpp b/silkworm/node/execution/api/direct_service.cpp index 7a79927739..d7680025fa 100644 --- a/silkworm/node/execution/api/direct_service.cpp +++ b/silkworm/node/execution/api/direct_service.cpp @@ -38,8 +38,7 @@ Task DirectService::insert_blocks(const Blocks& blocks) { // rpc ValidateChain(ValidationRequest) returns(ValidationReceipt); Task DirectService::validate_chain(BlockNumAndHash number_and_hash) { - auto future_result = exec_engine_.verify_chain(number_and_hash.hash); - const auto verification = co_await future_result.get_async(); + const auto verification = co_await exec_engine_.verify_chain(number_and_hash.hash); ValidationResult validation; if (std::holds_alternative(verification)) { diff --git a/silkworm/node/execution/api/direct_service_test.cpp b/silkworm/node/execution/api/direct_service_test.cpp index 32963cf4dc..dd434718eb 100644 --- a/silkworm/node/execution/api/direct_service_test.cpp +++ b/silkworm/node/execution/api/direct_service_test.cpp @@ -95,10 +95,8 @@ TEST_CASE_METHOD(DirectServiceTest, "DirectService::verify_chain", "[node][execu for (const auto& [stagedsync_result, api_result] : test_vectors) { SECTION("result: " + std::to_string(stagedsync_result.index())) { EXPECT_CALL(*mock_execution_engine, verify_chain(new_head.hash)) - .WillOnce(InvokeWithoutArgs([&, result = stagedsync_result]() -> stagedsync::VerificationResultFuture { - stagedsync::VerificationResultPromise promise{context().get_executor()}; - promise.set_value(result); - return promise.get_future(); + .WillOnce(InvokeWithoutArgs([result = stagedsync_result]() -> Task { + co_return result; })); auto future = spawn_future(direct_service->validate_chain(new_head)); context().run(); diff --git a/silkworm/node/stagedsync/execution_engine.cpp b/silkworm/node/stagedsync/execution_engine.cpp index 9ad6170b4f..924c9adff1 100644 --- a/silkworm/node/stagedsync/execution_engine.cpp +++ b/silkworm/node/stagedsync/execution_engine.cpp @@ -16,10 +16,14 @@ #include "execution_engine.hpp" +#include #include +#include + #include #include +#include namespace silkworm::stagedsync { @@ -134,39 +138,32 @@ std::optional ExecutionEngine::find_forking_point( return {std::move(path)}; } -VerificationResultFuture ExecutionEngine::verify_chain(Hash head_block_hash) { +Task ExecutionEngine::verify_chain(Hash head_block_hash) { log::Info("ExecutionEngine") << "verifying chain " << head_block_hash.to_hex(); if (last_fork_choice_.hash == head_block_hash) { SILK_DEBUG << "ExecutionEngine: chain " << head_block_hash.to_hex() << " already verified"; - VerificationResultPromise promise{io_context_.get_executor()}; - promise.set_value(ValidChain{last_fork_choice_}); - return promise.get_future(); + co_return ValidChain{last_fork_choice_}; } if (!fork_tracking_active_) { auto verification = main_chain_.verify_chain(head_block_hash); // BLOCKING - VerificationResultPromise promise{io_context_.get_executor()}; - promise.set_value(std::move(verification)); - return promise.get_future(); + co_return verification; } auto fork = find_fork_by_head(forks_, head_block_hash); if (fork == forks_.end()) { if (main_chain_.is_finalized_canonical(head_block_hash)) { SILK_DEBUG << "ExecutionEngine: chain " << head_block_hash.to_hex() << " already verified"; - VerificationResultPromise promise{io_context_.get_executor()}; - promise.set_value(ValidChain{last_fork_choice_}); - return promise.get_future(); + co_return ValidChain{last_fork_choice_}; } else { SILK_WARN << "ExecutionEngine: chain " << head_block_hash.to_hex() << " not found at verification time"; - VerificationResultPromise promise{io_context_.get_executor()}; - promise.set_value(ValidationError{}); - return promise.get_future(); + co_return ValidationError{}; } } - return (*fork)->verify_chain(); + auto verify_chain_future = (*fork)->verify_chain(); + co_return (co_await verify_chain_future.get()); } bool ExecutionEngine::notify_fork_choice_update(Hash head_block_hash, @@ -198,7 +195,9 @@ bool ExecutionEngine::notify_fork_choice_update(Hash head_block_hash, } // notify the fork of the update - we need to block here to restore the invariant - auto updated = (*f)->fork_choice(head_block_hash, finalized_block_hash, safe_block_hash).get(); // BLOCKING + auto fork_choice_aw_future = (*f)->fork_choice(head_block_hash, finalized_block_hash, safe_block_hash); + std::future fork_choice_future = concurrency::co_spawn_sw(io_context_, fork_choice_aw_future.get(), use_future); + bool updated = fork_choice_future.get(); // BLOCKING if (!updated) return false; std::unique_ptr fork = std::move(*f); diff --git a/silkworm/node/stagedsync/execution_engine.hpp b/silkworm/node/stagedsync/execution_engine.hpp index c44fb45b27..fb3ed1d5d3 100644 --- a/silkworm/node/stagedsync/execution_engine.hpp +++ b/silkworm/node/stagedsync/execution_engine.hpp @@ -62,7 +62,7 @@ class ExecutionEngine : public Stoppable { virtual void insert_blocks(const std::vector>& blocks); bool insert_block(const std::shared_ptr& block); - virtual VerificationResultFuture verify_chain(Hash head_block_hash); + virtual Task verify_chain(Hash head_block_hash); virtual bool notify_fork_choice_update(Hash head_block_hash, std::optional finalized_block_hash, diff --git a/silkworm/node/stagedsync/execution_engine_test.cpp b/silkworm/node/stagedsync/execution_engine_test.cpp index b9ee915928..e31c3befb1 100644 --- a/silkworm/node/stagedsync/execution_engine_test.cpp +++ b/silkworm/node/stagedsync/execution_engine_test.cpp @@ -16,7 +16,6 @@ #include "execution_engine.hpp" -#include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +38,6 @@ namespace silkworm { -namespace asio = boost::asio; using namespace silkworm::test_util; using namespace stagedsync; @@ -52,7 +51,7 @@ class ExecutionEngine_ForTest : public stagedsync::ExecutionEngine { TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engine]") { test_util::SetLogVerbosityGuard log_guard(log::Level::kWarning); - asio::io_context io; + test_util::TaskRunner runner; Environment::set_stop_before_stage(db::stages::kSendersKey); // only headers, block hashes and bodies auto db_context = db::test_util::TestDatabaseContext(); @@ -65,7 +64,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin db::RWAccess db_access{db_context.get_mdbx_env()}; - ExecutionEngine_ForTest exec_engine{io, node_settings, db_access}; + ExecutionEngine_ForTest exec_engine{runner.context(), node_settings, db_access}; exec_engine.open(); auto& tx = exec_engine.main_chain_.tx(); // mdbx refuses to open a ROTxn when there is a RWTxn in the same thread @@ -179,7 +178,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto is_canonical = exec_engine.is_canonical(new_block_hash); CHECK(!is_canonical); - auto verification = exec_engine.verify_chain(new_block_hash).get(); + auto verification = runner.run(exec_engine.verify_chain(new_block_hash)); CHECK(!holds_alternative(verification)); REQUIRE(holds_alternative(verification)); auto invalid_chain = std::get(verification); @@ -210,19 +209,19 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto is_canonical3 = exec_engine.is_canonical(block3_hash); CHECK(!is_canonical3); - auto verification1 = exec_engine.verify_chain(block1_hash).get(); + auto verification1 = runner.run(exec_engine.verify_chain(block1_hash)); CHECK(!holds_alternative(verification1)); REQUIRE(holds_alternative(verification1)); auto valid_chain1 = std::get(verification1); CHECK(valid_chain1.current_head == BlockId{10, block1_hash}); - auto verification2 = exec_engine.verify_chain(block2_hash).get(); + auto verification2 = runner.run(exec_engine.verify_chain(block2_hash)); CHECK(!holds_alternative(verification2)); REQUIRE(holds_alternative(verification2)); auto valid_chain2 = std::get(verification2); CHECK(valid_chain2.current_head == BlockId{11, block2_hash}); - auto verification3 = exec_engine.verify_chain(block3_hash).get(); + auto verification3 = runner.run(exec_engine.verify_chain(block3_hash)); CHECK(!holds_alternative(verification3)); REQUIRE(holds_alternative(verification3)); auto valid_chain3 = std::get(verification3); @@ -353,7 +352,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto new_block_hash = new_block->header.hash(); - auto verification = exec_engine.verify_chain(new_block_hash).get(); + auto verification = runner.run(exec_engine.verify_chain(new_block_hash)); REQUIRE(holds_alternative(verification)); auto fcu_updated = exec_engine.notify_fork_choice_update(new_block_hash, {}, {}); @@ -401,9 +400,9 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto block2_hash = block2->header.hash(); auto block3_hash = block3->header.hash(); - exec_engine.verify_chain(block1_hash).get(); - exec_engine.verify_chain(block2_hash).get(); - exec_engine.verify_chain(block3_hash).get(); + runner.run(exec_engine.verify_chain(block1_hash)); + runner.run(exec_engine.verify_chain(block2_hash)); + runner.run(exec_engine.verify_chain(block3_hash)); auto fcu_updated = exec_engine.notify_fork_choice_update(block1_hash, {}, {}); CHECK(fcu_updated); @@ -435,9 +434,9 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto block2_hash = block2->header.hash(); auto block3_hash = block3->header.hash(); - exec_engine.verify_chain(block1_hash).get(); - exec_engine.verify_chain(block2_hash).get(); - exec_engine.verify_chain(block3_hash).get(); + runner.run(exec_engine.verify_chain(block1_hash)); + runner.run(exec_engine.verify_chain(block2_hash)); + runner.run(exec_engine.verify_chain(block3_hash)); auto fcu_updated = exec_engine.notify_fork_choice_update(block3_hash, {}, {}); CHECK(fcu_updated); @@ -549,11 +548,11 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto block2a_hash = block2a->header.hash(); auto block2b_hash = block2b->header.hash(); - auto verification1 = exec_engine.verify_chain(block1b_hash).get(); + auto verification1 = runner.run(exec_engine.verify_chain(block1b_hash)); CHECK(!holds_alternative(verification1)); REQUIRE(holds_alternative(verification1)); - auto verification2 = exec_engine.verify_chain(block2b_hash).get(); + auto verification2 = runner.run(exec_engine.verify_chain(block2b_hash)); CHECK(!holds_alternative(verification2)); REQUIRE(holds_alternative(verification2)); @@ -596,11 +595,11 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin INFO(to_hex(block_f1_hash.bytes)); - auto verification1 = exec_engine.verify_chain(block_f1_hash).get(); + auto verification1 = runner.run(exec_engine.verify_chain(block_f1_hash)); CHECK(!holds_alternative(verification1)); REQUIRE(holds_alternative(verification1)); - auto verification2 = exec_engine.verify_chain(block_f2_hash).get(); + auto verification2 = runner.run(exec_engine.verify_chain(block_f2_hash)); CHECK(!holds_alternative(verification2)); REQUIRE(holds_alternative(verification2)); @@ -641,11 +640,11 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto block2a_hash = block2a->header.hash(); auto block2b_hash = block2b->header.hash(); - auto verification1 = exec_engine.verify_chain(block1b_hash).get(); + auto verification1 = runner.run(exec_engine.verify_chain(block1b_hash)); CHECK(!holds_alternative(verification1)); REQUIRE(holds_alternative(verification1)); - auto verification2 = exec_engine.verify_chain(block2b_hash).get(); + auto verification2 = runner.run(exec_engine.verify_chain(block2b_hash)); CHECK(!holds_alternative(verification2)); REQUIRE(holds_alternative(verification2)); @@ -707,7 +706,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto blocks = std::vector>{block1, block2}; exec_engine.insert_blocks(blocks); - exec_engine.verify_chain(block2_hash).get(); + runner.run(exec_engine.verify_chain(block2_hash)); CHECK(db::read_block_number(tx, block1_hash).has_value()); CHECK(db::read_block_number(tx, block2_hash).has_value()); @@ -732,7 +731,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin auto blocks = std::vector>{block1, block2}; exec_engine.insert_blocks(blocks); - exec_engine.verify_chain(block2_hash).get(); + runner.run(exec_engine.verify_chain(block2_hash)); exec_engine.notify_fork_choice_update(block2_hash, current_head_id.hash, {}); CHECK(db::read_block_number(tx, block1_hash).has_value()); @@ -795,8 +794,7 @@ TEST_CASE("ExecutionEngine Integration Test", "[node][execution][execution_engin TEST_CASE("ExecutionEngine") { SetLogVerbosityGuard log_guard(log::Level::kNone); - asio::io_context io; - asio::executor_work_guard work{io.get_executor()}; + test_util::TaskRunner runner; db::test_util::TempChainData context; context.add_genesis_data(); @@ -807,7 +805,7 @@ TEST_CASE("ExecutionEngine") { NodeSettings node_settings = node::test_util::make_node_settings_from_temp_chain_data(context); db::RWAccess db_access{context.env()}; - ExecutionEngine_ForTest exec_engine{io, node_settings, db_access}; + ExecutionEngine_ForTest exec_engine{runner.context(), node_settings, db_access}; exec_engine.open(); auto& tx = exec_engine.main_chain_.tx(); // mdbx refuses to open a ROTxn when there is a RWTxn in the same thread @@ -858,7 +856,7 @@ TEST_CASE("ExecutionEngine") { CHECK(progress == 1); // verifying the chain - auto verification = exec_engine.verify_chain(header1_hash).get(); + auto verification = runner.run(exec_engine.verify_chain(header1_hash)); CHECK(db::stages::read_stage_progress(tx, db::stages::kHeadersKey) == 1); CHECK(db::stages::read_stage_progress(tx, db::stages::kBlockHashesKey) == 1); @@ -925,7 +923,7 @@ TEST_CASE("ExecutionEngine") { // inserting & verifying the block exec_engine.insert_block(block1); - auto verification = exec_engine.verify_chain(block1_hash).get(); + auto verification = runner.run(exec_engine.verify_chain(block1_hash)); REQUIRE(holds_alternative(verification)); auto valid_chain = std::get(verification); @@ -969,7 +967,7 @@ TEST_CASE("ExecutionEngine") { exec_engine.insert_block(block1); exec_engine.insert_block(block2); exec_engine.insert_block(block3); - auto verification = exec_engine.verify_chain(block3_hash).get(); + auto verification = runner.run(exec_engine.verify_chain(block3_hash)); REQUIRE(holds_alternative(verification)); auto valid_chain = std::get(verification); @@ -997,7 +995,7 @@ TEST_CASE("ExecutionEngine") { { // inserting & verifying the block exec_engine.insert_block(block4); - verification = exec_engine.verify_chain(block4_hash).get(); + verification = runner.run(exec_engine.verify_chain(block4_hash)); REQUIRE(holds_alternative(verification)); valid_chain = std::get(verification); @@ -1029,7 +1027,7 @@ TEST_CASE("ExecutionEngine") { { // inserting & verifying the block exec_engine.insert_block(block2b); - verification = exec_engine.verify_chain(block2b_hash).get(); + verification = runner.run(exec_engine.verify_chain(block2b_hash)); REQUIRE(holds_alternative(verification)); valid_chain = std::get(verification); diff --git a/silkworm/node/test_util/mock_execution_engine.hpp b/silkworm/node/test_util/mock_execution_engine.hpp index 612ab4ffe2..380e6bc6d9 100644 --- a/silkworm/node/test_util/mock_execution_engine.hpp +++ b/silkworm/node/test_util/mock_execution_engine.hpp @@ -41,7 +41,7 @@ class MockExecutionEngine : public stagedsync::ExecutionEngine { MOCK_METHOD((void), close, ()); MOCK_METHOD((void), insert_blocks, (const std::vector>&), (override)); - MOCK_METHOD((stagedsync::VerificationResultFuture), verify_chain, (Hash), (override)); + MOCK_METHOD((Task), verify_chain, (Hash), (override)); MOCK_METHOD((bool), notify_fork_choice_update1, (Hash)); MOCK_METHOD((bool), notify_fork_choice_update2, (Hash, Hash)); MOCK_METHOD((bool), notify_fork_choice_update3, (Hash, Hash, Hash)); diff --git a/silkworm/rpc/http/connection.cpp b/silkworm/rpc/http/connection.cpp index 2fcb0a10f5..7079d3c4e7 100644 --- a/silkworm/rpc/http/connection.cpp +++ b/silkworm/rpc/http/connection.cpp @@ -438,7 +438,9 @@ std::string Connection::get_date_time() { Task Connection::compress(const std::string& clear_data, std::string& compressed_data) { boost::iostreams::filtering_ostream out; co_await async_task(workers_.executor(), [&]() -> void { +#ifndef SILKWORM_SANITIZE out.push(boost::iostreams::gzip_compressor()); +#endif out.push(boost::iostreams::back_inserter(compressed_data)); boost::iostreams::copy(boost::make_iterator_range(clear_data), out); }); diff --git a/silkworm/sentry/rlpx/crypto/hmac.cpp b/silkworm/sentry/rlpx/crypto/hmac.cpp index e415de4096..bd12d20067 100644 --- a/silkworm/sentry/rlpx/crypto/hmac.cpp +++ b/silkworm/sentry/rlpx/crypto/hmac.cpp @@ -23,6 +23,9 @@ namespace silkworm::sentry::rlpx::crypto { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + Bytes hmac(ByteView key, ByteView data1, ByteView data2, ByteView data3) { assert(key.size() == 32); @@ -43,4 +46,6 @@ Bytes hmac(ByteView key, ByteView data1, ByteView data2, ByteView data3) { return hash; } +#pragma GCC diagnostic pop + } // namespace silkworm::sentry::rlpx::crypto diff --git a/silkworm/sync/internals/header_chain_plus_exec_test.cpp b/silkworm/sync/internals/header_chain_plus_exec_test.cpp index 17a2e47933..174ecdcd8c 100644 --- a/silkworm/sync/internals/header_chain_plus_exec_test.cpp +++ b/silkworm/sync/internals/header_chain_plus_exec_test.cpp @@ -16,7 +16,6 @@ #include -#include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include #include #include @@ -35,7 +35,6 @@ namespace silkworm { using namespace stagedsync; -namespace asio = boost::asio; class HeaderChainForTest : public HeaderChain { public: // publication of internal members to test methods functioning @@ -75,8 +74,7 @@ class DummyRuleSet : public protocol::RuleSet { TEST_CASE("Headers receiving and saving") { test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); - asio::io_context io; - asio::executor_work_guard work{io.get_executor()}; + test_util::TaskRunner runner; db::test_util::TempChainData context; context.add_genesis_data(); @@ -88,7 +86,7 @@ TEST_CASE("Headers receiving and saving") { db::RWAccess db_access{context.env()}; // creating the ExecutionEngine - ExecutionEngine_ForTest exec_engine{io, node_settings, db_access}; + ExecutionEngine_ForTest exec_engine{runner.context(), node_settings, db_access}; exec_engine.open(); auto& tx = exec_engine.main_chain_.tx(); // mdbx refuses to open a ROTxn when there is a RWTxn in the same thread @@ -202,7 +200,7 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header1b_in_db == header1b); // verify the inserted chain - auto verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); + auto verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); auto valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{2, header2_hash}); @@ -279,7 +277,7 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header2_in_db == header2); // verify the inserted chain - auto verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); + auto verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); auto valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{2, header2_hash}); @@ -320,7 +318,7 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header1b_in_db == header1b); // verify the inserted chain - verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); + verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{2, header2_hash}); @@ -397,7 +395,7 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header2_in_db == header2); // verify the inserted chain - auto verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); + auto verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); auto valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{2, header2_hash}); @@ -441,7 +439,8 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header1b_in_db == header1b); // verify the inserted chain - verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); // this will trigger unwind + // this will trigger unwind + verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{1, header1b_hash}); @@ -512,7 +511,7 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header1b_in_db == header1b); // verify the inserted chain - auto verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); + auto verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); auto valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{1, header1b_hash}); @@ -568,7 +567,8 @@ TEST_CASE("Headers receiving and saving") { REQUIRE(header1b_in_db == header1b); // verify the inserted chain - verification = exec_engine.verify_chain(chain_fork_view.head_hash()).get(); // this will trigger unwind + // this will trigger unwind + verification = runner.run(exec_engine.verify_chain(chain_fork_view.head_hash())); REQUIRE(std::holds_alternative(verification)); valid_chain = std::get(verification); REQUIRE(valid_chain.current_head == BlockId{2, header2_hash}); diff --git a/third_party/blst/CMakeLists.txt b/third_party/blst/CMakeLists.txt index 19be50d247..7440f64f94 100644 --- a/third_party/blst/CMakeLists.txt +++ b/third_party/blst/CMakeLists.txt @@ -24,7 +24,11 @@ elseif(MSVC) set(BLST_BUILD_SCRIPT build.bat) set(BLST_LIB blst.lib) else() - set(BLST_BUILD_SCRIPT ./build.sh) + set(BLST_BUILD_SCRIPT_ARGS "") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(BLST_BUILD_SCRIPT_ARGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() + set(BLST_BUILD_SCRIPT ./build.sh ${BLST_BUILD_SCRIPT_ARGS}) set(BLST_LIB libblst.a) endif() diff --git a/third_party/cmake-conan/conan.cmake b/third_party/cmake-conan/conan.cmake index 8f81da3c39..b1770157b9 100644 --- a/third_party/cmake-conan/conan.cmake +++ b/third_party/cmake-conan/conan.cmake @@ -33,7 +33,7 @@ # but it is only necessary on the end-user side. It is not necessary to create conan # packages, in fact it shouldn't be use for that. Check the project documentation. -# version: 0.18.1 +# version: 0.19.0-dev include(CMakeParseArguments) @@ -55,7 +55,7 @@ function(_get_msvc_ide_version result) set(${result} 15 PARENT_SCOPE) elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) set(${result} 16 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940) + elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1950) set(${result} 17 PARENT_SCOPE) else() message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") @@ -132,18 +132,28 @@ macro(_conan_detect_compiler) set(_CONAN_SETTING_COMPILER_CPPSTD ${CMAKE_CXX_STANDARD}) endif() - if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) - # using GCC + if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU OR ${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC) + # using GCC or QCC # TODO: Handle other params string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) list(GET VERSION_LIST 0 MAJOR) list(GET VERSION_LIST 1 MINOR) - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - if(${MAJOR} GREATER 4) - set(COMPILER_VERSION ${MAJOR}) - endif() - set(_CONAN_SETTING_COMPILER gcc) + + if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) + set(_CONAN_SETTING_COMPILER gcc) + # mimic Conan client autodetection + if (${MAJOR} GREATER_EQUAL 5) + set(COMPILER_VERSION ${MAJOR}) + else() + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + endif() + elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC) + set(_CONAN_SETTING_COMPILER qcc) + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + endif () + set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) + if (USING_CXX) conan_cmake_detect_unix_libcxx(_LIBCXX) set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) @@ -152,7 +162,7 @@ macro(_conan_detect_compiler) string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) list(GET VERSION_LIST 0 MAJOR) list(GET VERSION_LIST 1 MINOR) - set(COMPILER_VERSION ${MAJOR}.${MINOR}) + set(COMPILER_VERSION ${MAJOR}) set(_CONAN_SETTING_COMPILER intel) set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) if (USING_CXX) @@ -164,8 +174,17 @@ macro(_conan_detect_compiler) string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) list(GET VERSION_LIST 0 MAJOR) list(GET VERSION_LIST 1 MINOR) + + # mimic Conan client autodetection + if (${MAJOR} GREATER_EQUAL 13) + set(COMPILER_VERSION ${MAJOR}) + else() + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + endif() + + set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) + set(_CONAN_SETTING_COMPILER apple-clang) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) if (USING_CXX) conan_cmake_detect_unix_libcxx(_LIBCXX) set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) @@ -178,7 +197,16 @@ macro(_conan_detect_compiler) list(GET VERSION_LIST 0 MAJOR) list(GET VERSION_LIST 1 MINOR) set(_CONAN_SETTING_COMPILER clang) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) + + # mimic Conan client autodetection + if (${MAJOR} GREATER_EQUAL 8) + set(COMPILER_VERSION ${MAJOR}) + else() + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + endif() + + set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) + if(APPLE) cmake_policy(GET CMP0025 APPLE_CLANG_POLICY) if(NOT APPLE_CLANG_POLICY STREQUAL NEW) @@ -186,9 +214,6 @@ macro(_conan_detect_compiler) set(_CONAN_SETTING_COMPILER apple-clang) endif() endif() - if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}) - endif() if (USING_CXX) conan_cmake_detect_unix_libcxx(_LIBCXX) set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) @@ -280,7 +305,7 @@ function(conan_cmake_settings result) if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version - compiler.runtime compiler.libcxx compiler.toolset) + compiler.runtime compiler.libcxx compiler.toolset os) endif() # remove any manually specified settings from the autodetected settings @@ -429,7 +454,7 @@ endfunction() function(_collect_settings result) set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version compiler.runtime compiler.libcxx compiler.toolset - compiler.cppstd) + compiler.cppstd os) foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) string(TOUPPER ${ARG} _arg_name) string(REPLACE "." "_" _arg_name ${_arg_name}) @@ -450,17 +475,18 @@ function(conan_cmake_autodetect detected_settings) endfunction() macro(conan_parse_arguments) - set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD) - set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) - set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE - PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO - INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) - cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS + OUTPUT_QUIET NO_IMPORTS SKIP_STD) + set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) + set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE + PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO + INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) + cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) endmacro() function(old_conan_cmake_install) # Calls "conan install" - # Argument BUILD is equivalant to --build={missing, PkgName,...} or + # Argument BUILD is equivalent to --build={missing, PkgName,...} or # --build when argument is 'BUILD all' (which builds all packages from source) # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source # cmake does not identify conan as command, even if it is +x and it is in the path @@ -552,7 +578,7 @@ function(conan_cmake_install) set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET) set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER OUTPUT_FOLDER) set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE - PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) + PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD CONF CONF_HOST CONF_BUILD) cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN}) foreach(arg ${installOptions}) if(ARGS_${arg}) @@ -607,6 +633,12 @@ function(conan_cmake_install) set(flag "--settings:host") elseif("${arg}" STREQUAL "SETTINGS_BUILD") set(flag "--settings:build") + elseif("${arg}" STREQUAL "CONF") + set(flag "--conf") + elseif("${arg}" STREQUAL "CONF_HOST") + set(flag "--conf:host") + elseif("${arg}" STREQUAL "CONF_BUILD") + set(flag "--conf:build") endif() list(LENGTH ARGS_${arg} numargs) foreach(item ${ARGS_${arg}}) @@ -624,9 +656,12 @@ function(conan_cmake_install) if(DEFINED NO_IMPORTS) set(NO_IMPORTS --no-imports) endif() - set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} ${OUTPUT_FOLDER} - ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} - ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) + set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} + ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} + ${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} + ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST} + ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD} + ${CONF} ${CONF_HOST} ${CONF_BUILD}) string(REPLACE ";" " " _install_args "${install_args}") message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") @@ -901,6 +936,30 @@ macro(conan_cmake_run) endif() endmacro() +function(conan_version result) + set(${result} "" PARENT_SCOPE) + + if(NOT CONAN_CMD) + find_program(CONAN_CMD conan) + if(NOT CONAN_CMD AND CONAN_REQUIRED) + message(FATAL_ERROR "Conan executable not found! Please install conan.") + endif() + endif() + + execute_process(COMMAND ${CONAN_CMD} --version + RESULT_VARIABLE return_code + OUTPUT_VARIABLE CONAN_VERSION_OUTPUT + ERROR_VARIABLE CONAN_VERSION_OUTPUT) + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan --version failed='${return_code}'") + endif() + + string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO "${CONAN_VERSION_OUTPUT}") + + set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE) +endfunction() + macro(conan_check) # Checks conan availability in PATH # Arguments REQUIRED, DETECT_QUIET and VERSION are optional @@ -920,25 +979,16 @@ macro(conan_check) if(NOT CONAN_DETECT_QUIET) message(STATUS "Conan: Found program ${CONAN_CMD}") endif() - execute_process(COMMAND ${CONAN_CMD} --version - RESULT_VARIABLE return_code - OUTPUT_VARIABLE CONAN_VERSION_OUTPUT - ERROR_VARIABLE CONAN_VERSION_OUTPUT) - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan --version failed='${return_code}'") - endif() + conan_version(CONAN_DETECTED_VERSION) if(NOT CONAN_DETECT_QUIET) - string(STRIP "${CONAN_VERSION_OUTPUT}" _CONAN_VERSION_OUTPUT) - message(STATUS "Conan: Version found ${_CONAN_VERSION_OUTPUT}") + message(STATUS "Conan: Version found ${CONAN_DETECTED_VERSION}") endif() if(DEFINED CONAN_VERSION) - string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO - "${CONAN_VERSION_OUTPUT}") - if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) - message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ + if(${CONAN_DETECTED_VERSION} VERSION_LESS ${CONAN_VERSION}) + message(FATAL_ERROR "Conan outdated. Installed: ${CONAN_DETECTED_VERSION}, \ required: ${CONAN_VERSION}. Consider updating via 'pip \ install conan==${CONAN_VERSION}'.") endif() @@ -1000,7 +1050,9 @@ macro(conan_config_install) endif() if(DEFINED CONAN_ARGS) - set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"") + # Convert ; seperated multi arg list into space seperated string + string(REPLACE ";" " " l_CONAN_ARGS "${CONAN_ARGS}") + set(CONAN_ARGS_ARGS "--args=${l_CONAN_ARGS}") endif() if(DEFINED CONAN_SOURCE) @@ -1024,3 +1076,71 @@ macro(conan_config_install) message(FATAL_ERROR "Conan config failed='${return_code}'") endif() endmacro() + + +function(conan_cmake_profile) + set(profileOneValueArgs FILEPATH INCLUDE) + set(profileMultiValueArgs SETTINGS OPTIONS CONF ENV BUILDENV RUNENV TOOL_REQUIRES) + cmake_parse_arguments(ARGS "" "${profileOneValueArgs}" "${profileMultiValueArgs}" ${ARGN}) + + if(DEFINED ARGS_FILEPATH) + set(_FN "${ARGS_FILEPATH}") + else() + set(_FN "${CMAKE_CURRENT_BINARY_DIR}/profile") + endif() + message(STATUS "Conan: Creating profile ${_FN}") + file(WRITE ${_FN} "") + + if(DEFINED ARGS_INCLUDE) + file(APPEND ${_FN} "include(${ARGS_INCLUDE})\n") + endif() + + if(DEFINED ARGS_SETTINGS) + file(APPEND ${_FN} "[settings]\n") + foreach(SETTING ${ARGS_SETTINGS}) + file(APPEND ${_FN} ${SETTING} "\n") + endforeach() + endif() + + if(DEFINED ARGS_OPTIONS) + file(APPEND ${_FN} "[options]\n") + foreach(OPTION ${ARGS_OPTIONS}) + file(APPEND ${_FN} ${OPTION} "\n") + endforeach() + endif() + + if(DEFINED ARGS_CONF) + file(APPEND ${_FN} "[conf]\n") + foreach(CONF ${ARGS_CONF}) + file(APPEND ${_FN} ${CONF} "\n") + endforeach() + endif() + + if(DEFINED ARGS_ENV) + file(APPEND ${_FN} "[env]\n") + foreach(ENV ${ARGS_ENV}) + file(APPEND ${_FN} ${ENV} "\n") + endforeach() + endif() + + if(DEFINED ARGS_BUILDENV) + file(APPEND ${_FN} "[buildenv]\n") + foreach(BUILDENV ${ARGS_BUILDENV}) + file(APPEND ${_FN} ${BUILDENV} "\n") + endforeach() + endif() + + if(DEFINED ARGS_RUNENV) + file(APPEND ${_FN} "[runenv]\n") + foreach(RUNENV ${ARGS_RUNENV}) + file(APPEND ${_FN} ${RUNENV} "\n") + endforeach() + endif() + + if(DEFINED ARGS_TOOL_REQUIRES) + file(APPEND ${_FN} "[tool_requires]\n") + foreach(TOOL_REQUIRE ${ARGS_TOOL_REQUIRES}) + file(APPEND ${_FN} ${TOOL_REQUIRE} "\n") + endforeach() + endif() +endfunction()