From 1949a9902a62e98ea2552b6d0f3eeddce5318cf4 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Wed, 22 Jun 2022 13:15:40 -0500 Subject: [PATCH 01/13] GH-426 Fix issues seen with libff when trying to use mandel with mandel.cdt. Update CMakeLists.txt to create a parallel mandel-config.cmake for use until mandel goes through renaming. Update path to libff in fc libraries when using build from src. Add install directions for current mandel use with mandel.cdt (or others). --- CMakeLists.txt | 3 +++ CMakeModules/EosioTesterBuild.cmake.in | 2 +- README.md | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a94586a8..ca93bc8f0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,11 +193,14 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eosio.version.hpp DESTINATION ${CMAKE_ set(EOS_ROOT_DIR ${CMAKE_BINARY_DIR}) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/eosio-config.cmake @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/mandel-config.cmake @ONLY) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/EosioTesterBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/eosio/EosioTester.cmake @ONLY) set(EOS_ROOT_DIR ${CMAKE_INSTALL_PREFIX}) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/modules/eosio-config.cmake @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/eosio-config.cmake.in ${CMAKE_BINARY_DIR}/modules/mandel-config.cmake @ONLY) install(FILES ${CMAKE_BINARY_DIR}/modules/eosio-config.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/eosio COMPONENT dev EXCLUDE_FROM_ALL) +install(FILES ${CMAKE_BINARY_DIR}/modules/mandel-config.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/mandel COMPONENT dev EXCLUDE_FROM_ALL) configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/EosioTester.cmake.in ${CMAKE_BINARY_DIR}/modules/EosioTester.cmake @ONLY) install(FILES ${CMAKE_BINARY_DIR}/modules/EosioTester.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/eosio COMPONENT dev EXCLUDE_FROM_ALL) diff --git a/CMakeModules/EosioTesterBuild.cmake.in b/CMakeModules/EosioTesterBuild.cmake.in index 2037d1daaa..7300e55425 100644 --- a/CMakeModules/EosioTesterBuild.cmake.in +++ b/CMakeModules/EosioTesterBuild.cmake.in @@ -60,7 +60,7 @@ else() find_library(libsecp256k1 secp256k1 @CMAKE_BINARY_DIR@/libraries/fc/secp256k1 NO_DEFAULT_PATH) endif() -find_library(libff ff @CMAKE_BINARY_DIR@/libraries/fc/libraries/ff NO_DEFAULT_PATH) +find_library(libff ff @CMAKE_BINARY_DIR@/libraries/fc/libraries/ff/libff NO_DEFAULT_PATH) find_library(libwasm WASM @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WASM NO_DEFAULT_PATH) find_library(libwast WAST @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/WAST NO_DEFAULT_PATH) find_library(libir IR @CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/IR NO_DEFAULT_PATH) diff --git a/README.md b/README.md index 546ea29c09..509937d76c 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,18 @@ We support the following CMake options: I highly recommend the ccache options. They don't speed up the first clean build, but they speed up future clean builds after the first build. +### Installing for use with mandel.cdt (or others) + +``` +git submodule update --init --recursive +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j $(nproc) +make install +cmake --install . --component dev +``` + ### Running tests ``` From 5f05de1c4659625af48eece175d364af301ef4c5 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Wed, 22 Jun 2022 13:31:28 -0500 Subject: [PATCH 02/13] GH-426 - Forgot CMAKE_INSTALL_PREFIX. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 509937d76c..8e863d9767 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ I highly recommend the ccache options. They don't speed up the first clean build git submodule update --init --recursive mkdir build cd build -cmake -DCMAKE_BUILD_TYPE=Release .. +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local .. make -j $(nproc) make install cmake --install . --component dev From b955a8b7f3c2c55c06fa1b9965027fb58a76bbcb Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Wed, 22 Jun 2022 14:08:26 -0500 Subject: [PATCH 03/13] GH-426 - Combine install commands into one-liner. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 8e863d9767..de33aca053 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,7 @@ git submodule update --init --recursive mkdir build cd build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local .. -make -j $(nproc) -make install -cmake --install . --component dev +make -j $(nproc) dev-install ``` ### Running tests From 2d05d354fb5dff0b57b92d4aed39149ef97a102d Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Thu, 23 Jun 2022 09:03:14 -0500 Subject: [PATCH 04/13] GH-426 - Genericize install location and add more detailed instructions. --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de33aca053..67b4ec673c 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,17 @@ We support the following CMake options: I highly recommend the ccache options. They don't speed up the first clean build, but they speed up future clean builds after the first build. -### Installing for use with mandel.cdt (or others) +### Installing mandel dev for use with mandel.cdt (or others) + +The following instructions will install mandel and the development packages. Installing is not strictly necessary. Instructions are provided, for example, in `mandel.cdt` for development and testing against a `mandel` source build directory (which may be preferable). + +**Warning:** It is highly recommended to select a `CMAKE_INSTALL_PREFIX` location different than the default `/usr/local`. Here, `$HOME/mandeldev` is used as an example that should be safe for most dev systems, but each developer should determine if another location is better suited to their specific needs. ``` git submodule update --init --recursive mkdir build cd build -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local .. +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$HOME/mandeldev .. make -j $(nproc) dev-install ``` From 697e0363072022e1bd32bc91a0f6f006fa618e04 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Thu, 23 Jun 2022 14:34:04 -0500 Subject: [PATCH 05/13] GH-426 - Remove notes on mandel dev install. Mandel dev install is no longer the recommendation. For users utilizing native contract unit testing, make install no longer installs the required header and libraries. It's recommended to utilize the headers and libraries directly from mandel's build directory, or to use the mandel-dev package. Installation of these headers and libraries can still be performed with a make dev-install if absolutely needed. --- README.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/README.md b/README.md index 67b4ec673c..546ea29c09 100644 --- a/README.md +++ b/README.md @@ -64,20 +64,6 @@ We support the following CMake options: I highly recommend the ccache options. They don't speed up the first clean build, but they speed up future clean builds after the first build. -### Installing mandel dev for use with mandel.cdt (or others) - -The following instructions will install mandel and the development packages. Installing is not strictly necessary. Instructions are provided, for example, in `mandel.cdt` for development and testing against a `mandel` source build directory (which may be preferable). - -**Warning:** It is highly recommended to select a `CMAKE_INSTALL_PREFIX` location different than the default `/usr/local`. Here, `$HOME/mandeldev` is used as an example that should be safe for most dev systems, but each developer should determine if another location is better suited to their specific needs. - -``` -git submodule update --init --recursive -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$HOME/mandeldev .. -make -j $(nproc) dev-install -``` - ### Running tests ``` From 920aac42684b47167fc2532fde0f1ebbb1069ebc Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:54:55 -0400 Subject: [PATCH 06/13] use /usr/bin/env to find bash --- scripts/install_deps.sh | 2 +- scripts/pinned_build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 59ae8b69ee..e2bab6d69c 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#!/usr/bin/env bash apt-get update apt-get update --fix-missing diff --git a/scripts/pinned_build.sh b/scripts/pinned_build.sh index dc55ef1241..559018ed2b 100755 --- a/scripts/pinned_build.sh +++ b/scripts/pinned_build.sh @@ -1,4 +1,4 @@ -#! /usr/bin/bash +#!/usr/bin/env bash echo "Mandel Pinned Build" From ecdb730ee2bfc4dd41e3f9045080a3bcaa41c36b Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:57:04 -0400 Subject: [PATCH 07/13] don't use cmake -S as that doesn't work on cmake 3.10 --- scripts/pinned_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pinned_build.sh b/scripts/pinned_build.sh index 559018ed2b..fcae2967b6 100755 --- a/scripts/pinned_build.sh +++ b/scripts/pinned_build.sh @@ -130,7 +130,7 @@ pushdir ${MANDEL_DIR} # build Mandel echo "Building Mandel ${SCRIPT_DIR}" -try cmake -DCMAKE_TOOLCHAIN_FILE=${SCRIPT_DIR}/pinned_toolchain.cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${LLVM_DIR}/lib/cmake -DCMAKE_PREFIX_PATH=${BOOST_DIR}/bin -S${SCRIPT_DIR}/.. +try cmake -DCMAKE_TOOLCHAIN_FILE=${SCRIPT_DIR}/pinned_toolchain.cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${LLVM_DIR}/lib/cmake -DCMAKE_PREFIX_PATH=${BOOST_DIR}/bin ${SCRIPT_DIR}/.. try make -j${JOBS} try cpack From cfdce0133f12485dda64da99a254c822b95ca9da Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Fri, 24 Jun 2022 13:58:42 -0400 Subject: [PATCH 08/13] remove unused LIBPQXX variable --- scripts/pinned_build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/pinned_build.sh b/scripts/pinned_build.sh index fcae2967b6..bae29d9576 100755 --- a/scripts/pinned_build.sh +++ b/scripts/pinned_build.sh @@ -31,7 +31,6 @@ JOBS=$3 CLANG_VER=11.0.1 BOOST_VER=1.70.0 LLVM_VER=7.1.0 -LIBPQXX_VER=7.2.1 ARCH=`uname -m` SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; START_DIR="$(pwd)" From a4fa84d0d1c54a4d3aedec69ef9220600d38aced Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:02:21 -0400 Subject: [PATCH 09/13] add python3 in install_deps.sh --- scripts/install_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index e2bab6d69c..89cceed969 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -3,4 +3,4 @@ apt-get update apt-get update --fix-missing DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata -apt-get -y install zip unzip libncurses5 wget git build-essential cmake curl libcurl4-openssl-dev libgmp-dev libssl-dev libusb-1.0.0-dev libzstd-dev time pkg-config zlib1g-dev libtinfo-dev bzip2 libbz2-dev +apt-get -y install zip unzip libncurses5 wget git build-essential cmake curl libcurl4-openssl-dev libgmp-dev libssl-dev libusb-1.0.0-dev libzstd-dev time pkg-config zlib1g-dev libtinfo-dev bzip2 libbz2-dev python3 From f0e13b4652b1780b603991b97d352256cac86046 Mon Sep 17 00:00:00 2001 From: Leo Ribeiro Date: Thu, 30 Jul 2020 18:49:12 -0400 Subject: [PATCH 10/13] adds http1.1 support and better response handling --- programs/cleos/httpc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 26e3b5b1dd..1b958ea038 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -195,7 +195,7 @@ namespace eosio { namespace client { namespace http { boost::asio::streambuf request; std::ostream request_stream(&request); auto host_header_value = format_host_header(url); - request_stream << "POST " << url.path << " HTTP/1.0\r\n"; + request_stream << "POST " << url.path << " HTTP/1.1\r\n"; request_stream << "Host: " << host_header_value << "\r\n"; request_stream << "content-length: " << postjson.size() << "\r\n"; request_stream << "Accept: */*\r\n"; @@ -253,14 +253,15 @@ namespace eosio { namespace client { namespace http { throw; } - const auto response_result = fc::json::from_string(re); if( print_response ) { std::cerr << "RESPONSE:" << std::endl << "---------------------" << std::endl - << fc::json::to_pretty_string( response_result ) << std::endl + << re << std::endl << "---------------------" << std::endl; } + if( status_code == 200 || status_code == 201 || status_code == 202 ) { + auto response_result = fc::json::from_string(re); return response_result; } else if( status_code == 404 ) { // Unknown endpoint @@ -278,6 +279,7 @@ namespace eosio { namespace client { namespace http { } } } else { + auto response_result = fc::json::from_string(re); auto &&error_info = response_result.as().error; // Construct fc exception from error const auto &error_details = error_info.details; @@ -292,6 +294,6 @@ namespace eosio { namespace client { namespace http { } EOS_ASSERT( status_code == 200, http_request_fail, "Error code ${c}\n: ${msg}\n", ("c", status_code)("msg", re) ); - return response_result; + return variant(); } }}} From 3618276910018a2ccbd4689259c485a9c0be12b3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Aug 2020 10:32:27 -0500 Subject: [PATCH 11/13] Revert back to pretty print of response unless unable to convert to variant --- programs/cleos/httpc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 1b958ea038..8fb2b70dd4 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -253,15 +253,21 @@ namespace eosio { namespace client { namespace http { throw; } + fc::variant response_result; + try { + response_result = fc::json::from_string(re); + } catch(...) { + // re reported below if print_response requested + } + if( print_response ) { std::cerr << "RESPONSE:" << std::endl << "---------------------" << std::endl - << re << std::endl + << ( response_result.is_null() ? re : fc::json::to_pretty_string( response_result ) ) << std::endl << "---------------------" << std::endl; } if( status_code == 200 || status_code == 201 || status_code == 202 ) { - auto response_result = fc::json::from_string(re); return response_result; } else if( status_code == 404 ) { // Unknown endpoint @@ -279,7 +285,6 @@ namespace eosio { namespace client { namespace http { } } } else { - auto response_result = fc::json::from_string(re); auto &&error_info = response_result.as().error; // Construct fc exception from error const auto &error_details = error_info.details; @@ -294,6 +299,6 @@ namespace eosio { namespace client { namespace http { } EOS_ASSERT( status_code == 200, http_request_fail, "Error code ${c}\n: ${msg}\n", ("c", status_code)("msg", re) ); - return variant(); + return response_result; } }}} From 059cee4650c6e19953c6edd54e229f4978fb6dc2 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Aug 2020 14:19:06 -0500 Subject: [PATCH 12/13] Better handling of invalid response --- programs/cleos/httpc.cpp | 55 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 8fb2b70dd4..ecdb1541e1 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -267,38 +267,37 @@ namespace eosio { namespace client { namespace http { << "---------------------" << std::endl; } - if( status_code == 200 || status_code == 201 || status_code == 202 ) { - return response_result; - } else if( status_code == 404 ) { - // Unknown endpoint - if (url.path.compare(0, chain_func_base.size(), chain_func_base) == 0) { - throw chain::missing_chain_api_plugin_exception(FC_LOG_MESSAGE(error, "Chain API plugin is not enabled")); - } else if (url.path.compare(0, wallet_func_base.size(), wallet_func_base) == 0) { - throw chain::missing_wallet_api_plugin_exception(FC_LOG_MESSAGE(error, "Wallet is not available")); - } else if (url.path.compare(0, history_func_base.size(), history_func_base) == 0) { - throw chain::missing_history_api_plugin_exception(FC_LOG_MESSAGE(error, "History API plugin is not enabled")); - } else if (url.path.compare(0, net_func_base.size(), net_func_base) == 0) { - throw chain::missing_net_api_plugin_exception(FC_LOG_MESSAGE(error, "Net API plugin is not enabled")); - } else if (url.path.compare(0, trace_api_func_base.size(), trace_api_func_base) == 0) { - if ( re.find("Trace API:") == string::npos ) { - throw chain::missing_trace_api_plugin_exception(FC_LOG_MESSAGE(error, "Trace API plugin is not enabled")); + if( !response_result.is_null() ) { + if( status_code == 200 || status_code == 201 || status_code == 202 ) { + return response_result; + } else if( status_code == 404 ) { + // Unknown endpoint + if (url.path.compare(0, chain_func_base.size(), chain_func_base) == 0) { + throw chain::missing_chain_api_plugin_exception(FC_LOG_MESSAGE(error, "Chain API plugin is not enabled")); + } else if (url.path.compare(0, wallet_func_base.size(), wallet_func_base) == 0) { + throw chain::missing_wallet_api_plugin_exception(FC_LOG_MESSAGE(error, "Wallet is not available")); + } else if (url.path.compare(0, history_func_base.size(), history_func_base) == 0) { + throw chain::missing_history_api_plugin_exception(FC_LOG_MESSAGE(error, "History API plugin is not enabled")); + } else if (url.path.compare(0, net_func_base.size(), net_func_base) == 0) { + throw chain::missing_net_api_plugin_exception(FC_LOG_MESSAGE(error, "Net API plugin is not enabled")); + } + } else { + auto &&error_info = response_result.as().error; + // Construct fc exception from error + const auto &error_details = error_info.details; + + fc::log_messages logs; + for (auto itr = error_details.begin(); itr != error_details.end(); itr++) { + const auto& context = fc::log_context(fc::log_level::error, itr->file.data(), itr->line_number, itr->method.data()); + logs.emplace_back(fc::log_message(context, itr->message)); } - } - } else { - auto &&error_info = response_result.as().error; - // Construct fc exception from error - const auto &error_details = error_info.details; - - fc::log_messages logs; - for (auto itr = error_details.begin(); itr != error_details.end(); itr++) { - const auto& context = fc::log_context(fc::log_level::error, itr->file.data(), itr->line_number, itr->method.data()); - logs.emplace_back(fc::log_message(context, itr->message)); - } - throw fc::exception(logs, error_info.code, error_info.name, error_info.what); + throw fc::exception(logs, error_info.code, error_info.name, error_info.what); + } } - EOS_ASSERT( status_code == 200, http_request_fail, "Error code ${c}\n: ${msg}\n", ("c", status_code)("msg", re) ); + EOS_ASSERT( status_code == 200 && !response_result.is_null(), http_request_fail, + "Error code ${c}\n: ${msg}\n", ("c", status_code)("msg", re) ); return response_result; } }}} From b4edcfabce06ff44687bc8f119bf108c6245290c Mon Sep 17 00:00:00 2001 From: Keke Li Date: Wed, 17 Feb 2021 14:13:46 -0800 Subject: [PATCH 13/13] As this function is a common used function, and the exception maybe not an error. remove the error notice line. --- programs/cleos/httpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index ecdb1541e1..f5b3514b75 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -258,6 +258,7 @@ namespace eosio { namespace client { namespace http { response_result = fc::json::from_string(re); } catch(...) { // re reported below if print_response requested + print_response = true; } if( print_response ) {