Skip to content

Commit

Permalink
Merge branch 'main' into mem_map_test
Browse files Browse the repository at this point in the history
  • Loading branch information
linh2931 authored Sep 14, 2023
2 parents 38250a5 + 85280f5 commit cfab778
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
28 changes: 21 additions & 7 deletions benchmark/modexp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <fc/crypto/modular_arithmetic.hpp>
#include <fc/exception/exception.hpp>

#include <random>

Expand All @@ -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);
Expand All @@ -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' && modulus[0] != 0);
base.front() = 0;
even_and_odd("B<M");
base.front() = '\xff';
even_and_odd("B>M");
}

// Running the above benchmark (using commented values for num_trials and *_num_bytes) with a release build on an AMD 3.4 GHz CPU
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/webassembly/runtimes/eos-vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ std::unique_ptr<wasm_instantiated_module_interface> eos_vm_profile_runtime::inst
#endif

template<typename Impl>
thread_local eos_vm_runtime<Impl>::context_t eos_vm_runtime<Impl>::_exec_ctx;
thread_local typename eos_vm_runtime<Impl>::context_t eos_vm_runtime<Impl>::_exec_ctx;
template<typename Impl>
thread_local eos_vm_backend_t<Impl> eos_vm_runtime<Impl>::_bkend;
}
Expand Down
13 changes: 0 additions & 13 deletions libraries/libfc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion plugins/wallet_plugin/se_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/abieos
Submodule abieos updated 1 files
+1 −1 external/rapidjson
4 changes: 2 additions & 2 deletions tests/trx_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 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)
2 changes: 1 addition & 1 deletion tests/trx_generator/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <trx_provider.hpp>
#include <trx_generator.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <fc/bitutil.hpp>
#include <fc/io/raw.hpp>
#include <iostream>
Expand Down
4 changes: 2 additions & 2 deletions tests/trx_generator/trx_generator.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <trx_generator.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <iostream>
#include <fc/log/logger.hpp>
#include <boost/algorithm/string.hpp>
#include <eosio/chain/chain_id_type.hpp>
#include <boost/program_options.hpp>
#include <eosio/chain/name.hpp>
#include <fc/bitutil.hpp>
#include <fc/io/raw.hpp>
Expand Down Expand Up @@ -235,7 +235,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_def>(), 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_def>(), 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)));
Expand Down
1 change: 0 additions & 1 deletion tests/trx_generator/trx_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <trx_provider.hpp>
#include <string>
#include <vector>
#include <boost/program_options.hpp>
#include <eosio/chain/transaction.hpp>
#include <eosio/chain/asset.hpp>
#include <eosio/chain/abi_serializer.hpp>
Expand Down

0 comments on commit cfab778

Please sign in to comment.