From 79f742af5c619cef67c56afbc479934406bd6493 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Tue, 12 Sep 2023 13:32:57 -0500 Subject: [PATCH 01/10] Cleanup unnecessary dependency on chain_plugin. --- tests/trx_generator/CMakeLists.txt | 4 ++-- tests/trx_generator/main.cpp | 2 +- tests/trx_generator/trx_generator.cpp | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/trx_generator/CMakeLists.txt b/tests/trx_generator/CMakeLists.txt index fab2a72eeb..957dcebe58 100644 --- a/tests/trx_generator/CMakeLists.txt +++ b/tests/trx_generator/CMakeLists.txt @@ -2,9 +2,9 @@ add_executable(trx_generator main.cpp trx_generator.cpp trx_provider.cpp) target_include_directories(trx_generator PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(trx_generator PRIVATE eosio_chain fc chain_plugin ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) +target_link_libraries(trx_generator PRIVATE eosio_chain fc Boost::program_options ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) add_executable(trx_generator_tests trx_generator_tests.cpp trx_provider.cpp trx_generator.cpp) -target_link_libraries(trx_generator_tests PRIVATE eosio_chain fc chain_plugin ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) +target_link_libraries(trx_generator_tests PRIVATE eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) target_include_directories(trx_generator_tests PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_test(trx_generator_tests trx_generator_tests) diff --git a/tests/trx_generator/main.cpp b/tests/trx_generator/main.cpp index 60c20e3f7e..fab8fba31c 100644 --- a/tests/trx_generator/main.cpp +++ b/tests/trx_generator/main.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include #include #include diff --git a/tests/trx_generator/trx_generator.cpp b/tests/trx_generator/trx_generator.cpp index dda297422f..a78a223b0e 100644 --- a/tests/trx_generator/trx_generator.cpp +++ b/tests/trx_generator/trx_generator.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -235,7 +234,7 @@ namespace eosio::testing { stop_generation(); ilog("Create Initial Transaction with action data."); - _abi = abi_serializer(fc::json::from_file(_usr_trx_config._abi_data_file_path).as(), abi_serializer::create_yield_function( abi_serializer_max_time )); + _abi = chain::abi_serializer(fc::json::from_file(_usr_trx_config._abi_data_file_path).as(), chain::abi_serializer::create_yield_function( abi_serializer_max_time )); fc::variant unpacked_actions_data_json = json_from_file_or_string(_usr_trx_config._actions_data_json_file_or_str); fc::variant unpacked_actions_auths_data_json = json_from_file_or_string(_usr_trx_config._actions_auths_json_file_or_str); ilog("Loaded actions data: ${data}", ("data", fc::json::to_pretty_string(unpacked_actions_data_json))); From 785e5afe437d1bd2633b05d96d16543e7bd1a3a8 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Tue, 12 Sep 2023 14:32:28 -0500 Subject: [PATCH 02/10] Add find_package. --- tests/trx_generator/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/trx_generator/CMakeLists.txt b/tests/trx_generator/CMakeLists.txt index 957dcebe58..7c32d74cf1 100644 --- a/tests/trx_generator/CMakeLists.txt +++ b/tests/trx_generator/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(Boost 1.67 REQUIRED COMPONENTS program_options) + add_executable(trx_generator main.cpp trx_generator.cpp trx_provider.cpp) target_include_directories(trx_generator PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) From fc64e0f7fdd47e5c376929370a4d826c7e201c21 Mon Sep 17 00:00:00 2001 From: Peter Oschwald Date: Tue, 12 Sep 2023 15:23:18 -0500 Subject: [PATCH 03/10] Add Boost::program_options to target_link_libraries for trx_generator_tests as well. Move include from hpp into cpp. Remove find_package. --- tests/trx_generator/CMakeLists.txt | 4 +--- tests/trx_generator/trx_generator.cpp | 1 + tests/trx_generator/trx_generator.hpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/trx_generator/CMakeLists.txt b/tests/trx_generator/CMakeLists.txt index 7c32d74cf1..d1946a156b 100644 --- a/tests/trx_generator/CMakeLists.txt +++ b/tests/trx_generator/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(Boost 1.67 REQUIRED COMPONENTS program_options) - add_executable(trx_generator main.cpp trx_generator.cpp trx_provider.cpp) target_include_directories(trx_generator PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) @@ -7,6 +5,6 @@ target_include_directories(trx_generator PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CM target_link_libraries(trx_generator PRIVATE eosio_chain fc Boost::program_options ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) add_executable(trx_generator_tests trx_generator_tests.cpp trx_provider.cpp trx_generator.cpp) -target_link_libraries(trx_generator_tests PRIVATE eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) +target_link_libraries(trx_generator_tests PRIVATE eosio_chain fc Boost::program_options ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) target_include_directories(trx_generator_tests PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_test(trx_generator_tests trx_generator_tests) diff --git a/tests/trx_generator/trx_generator.cpp b/tests/trx_generator/trx_generator.cpp index a78a223b0e..f3c57082ca 100644 --- a/tests/trx_generator/trx_generator.cpp +++ b/tests/trx_generator/trx_generator.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/trx_generator/trx_generator.hpp b/tests/trx_generator/trx_generator.hpp index 1112444777..83736cd83b 100644 --- a/tests/trx_generator/trx_generator.hpp +++ b/tests/trx_generator/trx_generator.hpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include From 4fbc5512034eb00f7201bbc4a83c8d26b50f426e Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:32:27 -0400 Subject: [PATCH 04/10] add yield for Secure Enclave wallet's to_string() call --- plugins/wallet_plugin/se_wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wallet_plugin/se_wallet.cpp b/plugins/wallet_plugin/se_wallet.cpp index 8f461401ac..18f745ddb7 100644 --- a/plugins/wallet_plugin/se_wallet.cpp +++ b/plugins/wallet_plugin/se_wallet.cpp @@ -371,7 +371,7 @@ bool se_wallet::import_key(string wif_key) { string se_wallet::create_key(string key_type) { EOS_ASSERT(key_type.empty() || key_type == "R1", chain::unsupported_key_type_exception, "Secure Enclave wallet only supports R1 keys"); - return my->create().to_string(); + return my->create().to_string({}); } bool se_wallet::remove_key(string key) { From a3a7cea1d86da0f755e25ec04a0a9e56c2e4aeda Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:36:32 -0400 Subject: [PATCH 05/10] add `typename` needed for some clang compilers here --- libraries/chain/webassembly/runtimes/eos-vm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/webassembly/runtimes/eos-vm.cpp b/libraries/chain/webassembly/runtimes/eos-vm.cpp index 345e8cd94b..813affc045 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm.cpp @@ -287,7 +287,7 @@ std::unique_ptr eos_vm_profile_runtime::inst #endif template -thread_local eos_vm_runtime::context_t eos_vm_runtime::_exec_ctx; +thread_local typename eos_vm_runtime::context_t eos_vm_runtime::_exec_ctx; template thread_local eos_vm_backend_t eos_vm_runtime::_bkend; } From c9a40f6e2abdc0bcbbd71d752f65f93c7454b1da Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:40:38 -0400 Subject: [PATCH 06/10] remove now unneeded macOS z/bz2/lzma/zstd iostreams workaround --- libraries/libfc/CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libraries/libfc/CMakeLists.txt b/libraries/libfc/CMakeLists.txt index 859f4162df..27c1aa4ba0 100644 --- a/libraries/libfc/CMakeLists.txt +++ b/libraries/libfc/CMakeLists.txt @@ -66,19 +66,6 @@ file( GLOB_RECURSE fc_headers ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h ) add_library(fc ${fc_sources} ${fc_headers}) -# Yuck: newer CMake files from boost iostreams will effectively target_link_libraries(Boost::iostreams z;bz2;lzma;zstd) -# without first "finding" those libraries. This resolves to simple -lz -lbz2 etc: it'll look for those libraries in the linker's -# library search path. This is most problematic on macOS where something like libzstd isn't in the standard search path. Historically -# fc would just "-L/usr/local/lib" as a heavy handed way to make sure something like -lzstd can be found in brew's library path. But -# that isn't sufficient for something like ARM homebrew. Let's just "null" these libraries out since we're already linking to zlib -# explicitly anyways via a proper find_package(ZLIB) below. -if(APPLE) - add_library(z INTERFACE) - add_library(bz2 INTERFACE) - add_library(lzma INTERFACE) - add_library(zstd INTERFACE) -endif() - find_path(GMP_INCLUDE_DIR NAMES gmp.h) find_library(GMP_LIBRARY gmp) if(NOT GMP_LIBRARY MATCHES ${CMAKE_SHARED_LIBRARY_SUFFIX}) From 57335b8c988af0bd558a1228e73e59c46e9e69d6 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:53:43 -0400 Subject: [PATCH 07/10] bump abieos submodule to branch with rapidjson c++20 fix --- tests/abieos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/abieos b/tests/abieos index 08145090b6..1f3c93d68b 160000 --- a/tests/abieos +++ b/tests/abieos @@ -1 +1 @@ -Subproject commit 08145090b6407b91fbab5721b624d2b3001ef84f +Subproject commit 1f3c93d68b14be577cdc5d94a468adf407dbd022 From 62ed7337a03a230fd60de7423dd6c7c5ef09c620 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:06:44 -0400 Subject: [PATCH 08/10] bump abieos submodule to main w/ rapidjson c++20 warn fix --- tests/abieos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/abieos b/tests/abieos index 1f3c93d68b..7e77b20a39 160000 --- a/tests/abieos +++ b/tests/abieos @@ -1 +1 @@ -Subproject commit 1f3c93d68b14be577cdc5d94a468adf407dbd022 +Subproject commit 7e77b20a3927a41695f7ae969b736bdb4a8e0a74 From aee9599ebfd7bf94bfb392b0563b45f63e7f62d3 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:27:14 -0400 Subject: [PATCH 09/10] add some additional test cases in modexp benchmark --- benchmark/modexp.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/benchmark/modexp.cpp b/benchmark/modexp.cpp index 627a719a50..8c98ccb5da 100644 --- a/benchmark/modexp.cpp +++ b/benchmark/modexp.cpp @@ -1,4 +1,5 @@ #include +#include #include @@ -24,15 +25,14 @@ void modexp_benchmarking() { return result; }; - static constexpr unsigned int start_num_bytes = 128; // 64 - static constexpr unsigned int end_num_bytes = 256; // 512 - static constexpr unsigned int delta_num_bytes = 128; // 64 + static constexpr unsigned int start_num_bytes = 8; + static constexpr unsigned int end_num_bytes = 256; static_assert(start_num_bytes <= end_num_bytes); - static_assert(delta_num_bytes > 0); - static_assert((end_num_bytes - start_num_bytes) % delta_num_bytes == 0); + static_assert((start_num_bytes & (start_num_bytes - 1)) == 0); + static_assert((end_num_bytes & (end_num_bytes - 1)) == 0); - for (unsigned int n = start_num_bytes, slot = 0; n <= end_num_bytes; n += delta_num_bytes, ++slot) { + for (unsigned int n = start_num_bytes; n <= end_num_bytes; n *= 2) { auto base = generate_random_bytes(r, n); auto exponent = generate_random_bytes(r, n); auto modulus = generate_random_bytes(r, n); @@ -41,7 +41,21 @@ void modexp_benchmarking() { fc::modexp(base, exponent, modulus); }; - benchmarking(std::to_string(n*8) + " bit width", f); + auto even_and_odd = [&](const std::string& bm) { + //some modexp implementations have drastically different performance characteristics depending on whether the modulus is + // even or odd (this can determine whether Montgomery multiplication is used). So test both cases. + modulus.back() &= ~1; + benchmarking(std::to_string(n*8) + " bit even M, " + bm, f); + modulus.back() |= 1; + benchmarking(std::to_string(n*8) + " bit odd M, " + bm, f); + }; + + //some modexp implementations need to take a minor different path if base is greater than modulus, try both + FC_ASSERT(modulus[0] != '\xff'); + base.front() = 0; + even_and_odd("BM"); } // Running the above benchmark (using commented values for num_trials and *_num_bytes) with a release build on an AMD 3.4 GHz CPU From d3275c209f5146a882710ad70ae840ce4153faa4 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:13:42 -0400 Subject: [PATCH 10/10] check that MSB of modulus is not 0 otherwise B