Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: Iroha 1: Mac: Repair benchmark #3345

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/iroha-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN apt-get update && \
# other
curl file ccache libssl-dev \
gcovr cppcheck doxygen rsync graphviz graphviz-dev vim zip unzip pkg-config \
jq \
jq autoconf \
postgresql postgresql-contrib; \
if [ $(uname -m) = "x86_64" ] ;then \
apt-get -y --no-install-recommends install \
Expand Down
1 change: 1 addition & 0 deletions iroha-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <rapidjson/rapidjson.h>
#include <boost/filesystem.hpp>
#include <iostream>
#include <fstream>

#include "backend/protobuf/proto_block_json_converter.hpp"
#include "backend/protobuf/queries/proto_query.hpp"
Expand Down
1 change: 1 addition & 0 deletions irohad/ametsuchi/impl/flat_file/flat_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <iomanip>
#include <iostream>
#include <sstream>
#include <fstream>

#include "common/files.hpp"
#include "common/result.hpp"
Expand Down
18 changes: 10 additions & 8 deletions irohad/ametsuchi/impl/rocksdb_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ namespace iroha::ametsuchi {
Args &&... args) {
assert(format != nullptr);
return expected::makeError(
DbError{code, fmt::format(format, std::forward<Args>(args)...)});
DbError{code, fmt::format(fmt::runtime(format), std::forward<Args>(args)...)});
}

template <typename T>
Expand Down Expand Up @@ -1019,7 +1019,7 @@ namespace iroha::ametsuchi {
S const &fmtstring,
Args &&... args) {
keyBuffer().clear();
fmt::format_to(keyBuffer(), fmtstring, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(keyBuffer()), fmtstring, std::forward<Args>(args)...);

valueBuffer().clear();
rocksdb::Slice const slice(keyBuffer().data(), keyBuffer().size());
Expand Down Expand Up @@ -1052,7 +1052,7 @@ namespace iroha::ametsuchi {
S const &fmtstring,
Args &&... args) {
keyBuffer().clear();
fmt::format_to(keyBuffer(), fmtstring, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(keyBuffer()), fmtstring, std::forward<Args>(args)...);

rocksdb::Slice const slice(keyBuffer().data(), keyBuffer().size());
if (auto c = cache(); c && c->isCacheable(slice.ToStringView())
Expand All @@ -1074,7 +1074,7 @@ namespace iroha::ametsuchi {
S const &fmtstring,
Args &&... args) {
keyBuffer().clear();
fmt::format_to(keyBuffer(), fmtstring, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(keyBuffer()), fmtstring, std::forward<Args>(args)...);

rocksdb::Slice const slice(keyBuffer().data(), keyBuffer().size());
if (auto c = cache(); c && c->isCacheable(slice.ToStringView())) {
Expand All @@ -1092,7 +1092,7 @@ namespace iroha::ametsuchi {
S const &fmtstring,
Args &&... args) {
keyBuffer().clear();
fmt::format_to(keyBuffer(), fmtstring, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(keyBuffer()), fmt::runtime(fmtstring), std::forward<Args>(args)...);

rocksdb::ReadOptions ro;
ro.fill_cache = false;
Expand All @@ -1112,7 +1112,7 @@ namespace iroha::ametsuchi {
S const &fmtstring,
Args &&... args) {
keyBuffer().clear();
fmt::format_to(keyBuffer(), fmtstring, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(keyBuffer()), fmtstring, std::forward<Args>(args)...);
return enumerate(it, std::forward<F>(func));
}

Expand Down Expand Up @@ -1482,15 +1482,17 @@ namespace iroha::ametsuchi {
return value;
}

template <typename RetT, kDbOperation kOp, kDbEntry kSc, typename... Args>
template <typename RetT, kDbOperation kOp, kDbEntry kSc, typename StrFormat, typename... Args>
inline expected::Result<std::optional<RetT>, DbError> dbCall(
RocksDbCommon &common,
RocksDBPort::ColumnFamilyType cf_type,
const StrFormat& formatstr,
Args &&... args) {
auto status = executeOperation<kOp, kSc>(
common,
[&] { return fmt::format(std::forward<Args>(args)...); },
[&] { return fmt::format(fmt::runtime(formatstr), std::forward<Args>(args)...); },
cf_type,
formatstr,
std::forward<Args>(args)...);
RDB_ERROR_CHECK(status);
return loadValue<kOp, RetT>(common, status);
Expand Down
7 changes: 4 additions & 3 deletions irohad/ametsuchi/impl/rocksdb_wsv_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "ametsuchi/impl/executor_common.hpp"
#include "ametsuchi/impl/rocksdb_common.hpp"
#include "ametsuchi/ledger_state.hpp"
#include "backend/protobuf/permissions.hpp"
#include "interfaces/common_objects/account.hpp"
#include "interfaces/common_objects/account_asset.hpp"
#include "interfaces/common_objects/asset.hpp"
Expand Down Expand Up @@ -149,9 +148,10 @@ namespace iroha::ametsuchi {
return {};
},
[&]() {
using underlying_type_for_grantable = std::underlying_type_t<decltype(permission)>;
return fmt::format("Insert account {} grantable permission {} for {}",
account_id,
permission,
static_cast<underlying_type_for_grantable>(permission),
permittee_account_id);
});
}
Expand Down Expand Up @@ -189,9 +189,10 @@ namespace iroha::ametsuchi {
return {};
},
[&]() {
using underlying_type_for_grantable = std::underlying_type_t<decltype(permission)>;
return fmt::format("Delete account {} grantable permission {} for {}",
account_id,
permission,
static_cast<underlying_type_for_grantable>(permission),
permittee_account_id);
});
}
Expand Down
6 changes: 3 additions & 3 deletions irohad/util/shepherd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/

#include <iostream>

#include "util/proto_status_tools.hpp"
#include <type_traits>

#include <gflags/gflags.h>
#include "common/irohad_version.hpp"
Expand Down Expand Up @@ -49,7 +48,8 @@ DEFINE_bool(status, false, "Watch daemon statuses.");
DEFINE_validator(status, &validateSingleAction);

bool printStatus(const iroha::utility_service::Status &status) {
::fmt::print("{}", status);
using underlying_statys_type = typename std::underlying_type_t<std::decay_t<decltype(status)>>;
::fmt::print("{}", static_cast<underlying_statys_type>(status));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libs/common/to_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace iroha {

template <typename T>
inline auto toString(const T &o) -> std::enable_if_t<
boost::optional_detail::is_optional_related<T>::value,
boost::optional_detail::is_optional_or_tag<T>::value,
std::string> {
return detail::toStringDereferenced(o);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ProtoBlockJsonConverter::serialize(const interface::Block &block) const
google::protobuf::util::MessageToJsonString(proto_block, &result);

if (not status.ok()) {
return iroha::expected::makeError(status.error_message());
return iroha::expected::makeError(status.message());
}
return iroha::expected::makeValue(result);
}
Expand All @@ -35,7 +35,7 @@ ProtoBlockJsonConverter::deserialize(
iroha::protocol::Block block;
auto status = google::protobuf::util::JsonStringToMessage(json, &block);
if (not status.ok()) {
return iroha::expected::makeError(status.error_message());
return iroha::expected::makeError(status.message());
}
std::unique_ptr<interface::Block> result =
std::make_unique<Block>(std::move(block.block_v1()));
Expand Down
2 changes: 1 addition & 1 deletion shared_model/converters/protobuf/json_proto_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace shared_model {
if (status.ok()) {
return result;
}
return status.error_message();
return status.message();
}
} // namespace protobuf
} // namespace converters
Expand Down
59 changes: 59 additions & 0 deletions vcpkg/patches/0002-Added-patch-to-enable-building-on-MacOS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From 344a8b3963b3a9075d1e779107b4ce6ea7f73a63 Mon Sep 17 00:00:00 2001
From: Grzegorz Bazior <bazior@agh.edu.pl>
Date: Fri, 31 Mar 2023 17:26:11 +0200
Subject: [PATCH] Added patch to enable building on MacOS

Signed-off-by: Grzegorz Bazior <bazior@agh.edu.pl>
---
ports/benchmark/fixedBuildingForMac.patch | 26 +++++++++++++++++++++++
ports/benchmark/portfile.cmake | 1 +
2 files changed, 27 insertions(+)
create mode 100644 ports/benchmark/fixedBuildingForMac.patch

diff --git a/ports/benchmark/fixedBuildingForMac.patch b/ports/benchmark/fixedBuildingForMac.patch
new file mode 100644
index 000000000..36a45adf7
--- /dev/null
+++ b/ports/benchmark/fixedBuildingForMac.patch
@@ -0,0 +1,26 @@
+From b976cab799c7fb20a5ceadd368431125ac0d99c4 Mon Sep 17 00:00:00 2001
+From: Grzegorz Bazior <bazior@agh.edu.pl>
+Date: Fri, 31 Mar 2023 16:20:55 +0200
+Subject: [PATCH] Fixed building for MacOS - there were unused variable
+
+Signed-off-by: Your Name <you@example.com>
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9ab265e..0cc0e4a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -20,7 +20,7 @@ option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
+ option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
+ option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF)
+ option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF)
+-option(BENCHMARK_ENABLE_WERROR "Build Release candidates with -Werror." ON)
++option(BENCHMARK_ENABLE_WERROR "Build Release candidates with -Werror." OFF)
+ option(BENCHMARK_FORCE_WERROR "Build Release candidates with -Werror regardless of compiler issues." OFF)
+
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
+--
+2.34.1
+
diff --git a/ports/benchmark/portfile.cmake b/ports/benchmark/portfile.cmake
index 8e8cef314..36676e59c 100644
--- a/ports/benchmark/portfile.cmake
+++ b/ports/benchmark/portfile.cmake
@@ -6,6 +6,7 @@ vcpkg_from_github(
REF v1.7.1
SHA512 396af1c1d3eaa2b78c6d23b1472f6088db85a294056ae1c2366dc5c0becdc8f141ba8fc3a235033324ab0a41c2298f5d242ef09b9b6f69d9877de6bcb2062efd
HEAD_REF master
+ PATCHES fixedBuildingForMac.patch
)

vcpkg_cmake_configure(
--
2.34.1

69 changes: 0 additions & 69 deletions vcpkg/patches/0002-rxcpp-from-master-2020-08-22.patch

This file was deleted.

69 changes: 0 additions & 69 deletions vcpkg/patches/0005-disable-prometheus-logs.patch

This file was deleted.