From 999560013bb3ab15115e42b1634e6a6f04f0e1ed Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 24 Oct 2023 12:35:20 +0300 Subject: [PATCH] Merge Iroha1 `develop` into `main` (#3960) Co-authored-by: safinsaf Co-authored-by: Grzegorz Bazior (Yodiss PSA) Co-authored-by: Sudhanshu <76694373+sudhanshu-k@users.noreply.github.com> Co-authored-by: Roopesh Saravanan Co-authored-by: Vincent Autefage Co-authored-by: G. Bazior --- .github/build-iroha1.src.yml | 5 +- .github/chatops-gen-matrix.sh | 2 +- .github/workflows/build-iroha1.yml | 5 +- docs/source/getting_started/index.rst | 2 +- goSrc/src/vmCaller/iroha/commands.go | 4 +- iroha-lib/README.md | 1 + iroha-lib/examples/CMakeLists.txt | 78 ++++++++++--------- iroha-lib/model/Query.cpp | 10 +++ iroha-lib/model/Query.hpp | 1 + iroha-lib/model/Tx.cpp | 11 +++ iroha-lib/model/generators/QueryGenerator.cpp | 13 ++++ iroha-lib/model/generators/QueryGenerator.hpp | 4 + ...014-gtest-remove-werror-compile-flag.patch | 38 +++++++++ 13 files changed, 128 insertions(+), 46 deletions(-) create mode 100644 vcpkg/patches/0014-gtest-remove-werror-compile-flag.patch diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index d0398abf244..6501a6dc97b 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -208,10 +208,10 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build ubuntu debug release normal gcc-10" + echo >/tmp/comment_body "/build ubuntu debug release normal gcc-10"$'\n' "/build macos debug clang" fi ;; push) commit_message_body_build_spec >/tmp/comment_body || { - echo "/build macos ubuntu debug release normal gcc-10" + echo "/build ubuntu debug release normal gcc-10" } >/tmp/comment_body ;; workflow_dispatch) echo >/tmp/comment_body "${{github.event.inputs.build_spec}}" ;; *) echo >&2 "::error::Unexpected event"; false ;; @@ -221,6 +221,7 @@ jobs: id: matrixes run: | set -x + cat /tmp/comment_body cat /tmp/comment_body | .github/chatops-gen-matrix.sh echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" diff --git a/.github/chatops-gen-matrix.sh b/.github/chatops-gen-matrix.sh index 39b306e452a..a16432d4ce2 100755 --- a/.github/chatops-gen-matrix.sh +++ b/.github/chatops-gen-matrix.sh @@ -19,7 +19,7 @@ echoerr(){ readonly ALL_oses="ubuntu macos windows" ALL_build_types="Debug Release" ALL_cmake_opts="normal burrow ursa" ALL_compilers="gcc-9 gcc-10 clang-10 clang llvm msvc" readonly DEFAULT_oses="ubuntu macos windows" DEFAULT_build_types="Debug" DEFAULT_cmake_opts="normal burrow ursa" readonly DEFAULT_ubuntu_compilers="gcc-9" AVAILABLE_ubuntu_compilers="gcc-9 gcc-10 clang-10" -readonly DEFAULT_macos_compilers="clang" AVAILABLE_macos_compilers="clang" ## Also "llvm gcc-10" but they fail +readonly DEFAULT_macos_compilers="clang" AVAILABLE_macos_compilers="clang gcc-10" ## Also "llvm gcc-10" but they fail readonly DEFAULT_windows_compilers="msvc" AVAILABLE_windows_compilers="msvc" ## Also "clang mingw cygwin" but they are redundant --help-buildspec(){ diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 1bd649e4c67..8c3c2028184 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -223,10 +223,10 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build ubuntu debug release normal gcc-10" + echo >/tmp/comment_body "/build ubuntu debug release normal gcc-10"$'\n' "/build macos debug clang" fi ;; push) commit_message_body_build_spec >/tmp/comment_body || { - echo "/build macos ubuntu debug release normal gcc-10" + echo "/build ubuntu debug release normal gcc-10" } >/tmp/comment_body ;; workflow_dispatch) echo >/tmp/comment_body "${{github.event.inputs.build_spec}}" ;; *) echo >&2 "::error::Unexpected event"; false ;; @@ -235,6 +235,7 @@ jobs: id: matrixes run: | set -x + cat /tmp/comment_body cat /tmp/comment_body | .github/chatops-gen-matrix.sh echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" diff --git a/docs/source/getting_started/index.rst b/docs/source/getting_started/index.rst index 00d1bde7b2c..aea2ef5c6dd 100644 --- a/docs/source/getting_started/index.rst +++ b/docs/source/getting_started/index.rst @@ -15,7 +15,7 @@ To keep things simple, we will use Docker. Prerequisites ------------- For this guide, you need a machine with ``Docker`` installed. -You can read how to install it on a `Docker's website `_. +You can read how to install it on a `Docker's website `_. .. note:: Of course you can build Iroha from scratch, modify its code and launch a customized node! If you are curious how to do that — you can check :ref:`build-guide` section. diff --git a/goSrc/src/vmCaller/iroha/commands.go b/goSrc/src/vmCaller/iroha/commands.go index 1c3653cb961..39e41647be1 100644 --- a/goSrc/src/vmCaller/iroha/commands.go +++ b/goSrc/src/vmCaller/iroha/commands.go @@ -479,9 +479,7 @@ func GetAccountTransactions(accountID string, txPaginationMeta *iroha_model.TxPa if err != nil { return []*pb.Transaction{}, err } - if err != nil { - return []*pb.Transaction{}, err - } + metaPayload := MakeQueryPayloadMeta() query := &pb.Query{Payload: &pb.Query_Payload{ Meta: &metaPayload, diff --git a/iroha-lib/README.md b/iroha-lib/README.md index 864f48e3023..2759d23e82b 100755 --- a/iroha-lib/README.md +++ b/iroha-lib/README.md @@ -126,6 +126,7 @@ iroha_lib::GrpcClient( - [x] [getAssetInfo](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-asset-info) - [x] [getRoles](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-roles) - [x] [getRolePermissions](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-role-permissions) +- [x] [getPeers](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-peers) ## Compatibility and release policy diff --git a/iroha-lib/examples/CMakeLists.txt b/iroha-lib/examples/CMakeLists.txt index fe8eaf0a6fc..76bbdf799f1 100644 --- a/iroha-lib/examples/CMakeLists.txt +++ b/iroha-lib/examples/CMakeLists.txt @@ -1,51 +1,55 @@ -####### irohalib_tx_example: -add_executable(irohalib_tx_example - TxExample.cpp -) +if (APPLE) + message("iroha-lib does not support MacOS currently!") +else() + ###### irohalib_tx_example: + add_executable(irohalib_tx_example + TxExample.cpp + ) -target_link_libraries(irohalib_tx_example - iroha_lib_model - logger_manager -) + target_link_libraries(irohalib_tx_example + iroha_lib_model + logger_manager + ) -add_install_step_for_bin(irohalib_tx_example) + add_install_step_for_bin(irohalib_tx_example) -####### irohalib_batch_example: -add_executable(irohalib_batch_example - BatchExample.cpp -) + ###### irohalib_batch_example: + add_executable(irohalib_batch_example + BatchExample.cpp + ) -target_link_libraries(irohalib_batch_example - iroha_lib_model - logger_manager -) + target_link_libraries(irohalib_batch_example + iroha_lib_model + logger_manager + ) -add_install_step_for_bin(irohalib_batch_example) + add_install_step_for_bin(irohalib_batch_example) -####### irohalib_query_example: -add_executable(irohalib_query_example - QueryExample.cpp -) + ###### irohalib_query_example: + add_executable(irohalib_query_example + QueryExample.cpp + ) -target_link_libraries(irohalib_query_example - iroha_lib_model - logger_manager -) + target_link_libraries(irohalib_query_example + iroha_lib_model + logger_manager + ) -add_install_step_for_bin(irohalib_query_example) + add_install_step_for_bin(irohalib_query_example) -####### irohalib_domainassetcreation_example: -add_executable(irohalib_domainassetcreation_example - DomainAssetCreation.cpp -) + ###### irohalib_domainassetcreation_example: + add_executable(irohalib_domainassetcreation_example + DomainAssetCreation.cpp + ) -target_link_libraries(irohalib_domainassetcreation_example - iroha_lib_model - logger_manager - gflags -) + target_link_libraries(irohalib_domainassetcreation_example + iroha_lib_model + logger_manager + gflags + ) -add_install_step_for_bin(irohalib_domainassetcreation_example) + add_install_step_for_bin(irohalib_domainassetcreation_example) +endif() diff --git a/iroha-lib/model/Query.cpp b/iroha-lib/model/Query.cpp index 2cac63cb172..7e1847157a4 100644 --- a/iroha-lib/model/Query.cpp +++ b/iroha-lib/model/Query.cpp @@ -135,6 +135,16 @@ Query& Query::getRolePermissions( return *this; } +Query& Query::getPeers(const std::string& account_id) +{ + protobuf_query_ = *query_generator_.generateGetPeers( + account_id, + counter_, + created_time_); + return *this; +} + + const iroha::protocol::Query Query::signAndAddSignature() { auto signature = iroha::sign( diff --git a/iroha-lib/model/Query.hpp b/iroha-lib/model/Query.hpp index 5c089ad27bf..1e59e0b51a6 100644 --- a/iroha-lib/model/Query.hpp +++ b/iroha-lib/model/Query.hpp @@ -41,6 +41,7 @@ class Query { Query& getRolePermissions( const std::string& account_id, const std::string& role_id); + Query& getPeers(const std::string& account_id); const iroha::protocol::Query signAndAddSignature(); diff --git a/iroha-lib/model/Tx.cpp b/iroha-lib/model/Tx.cpp index 7decba7fe67..416c4c11747 100644 --- a/iroha-lib/model/Tx.cpp +++ b/iroha-lib/model/Tx.cpp @@ -143,6 +143,17 @@ Tx& Tx::removePeer(const std::string& pubkey) return *this; } +Tx& Tx::removeSignatory( + const std::string& account_id, + const std::string& pubkey) +{ + auto cmd = cmd_generator_.generateRemoveSignatory( + account_id, + pubkey); + addCommand(*cmd); + return *this; +} + Tx& Tx::revokePermission( const std::string& account_id, const iroha::protocol::GrantablePermission permission) diff --git a/iroha-lib/model/generators/QueryGenerator.cpp b/iroha-lib/model/generators/QueryGenerator.cpp index 9d4238b981c..45c08203ccf 100644 --- a/iroha-lib/model/generators/QueryGenerator.cpp +++ b/iroha-lib/model/generators/QueryGenerator.cpp @@ -210,4 +210,17 @@ std::shared_ptr QueryGenerator::generateGetRolePermissio return query; } +std::shared_ptr QueryGenerator::generateGetPeers( + const std::string& account_id, + uint64_t counter, + const uint64_t created_time) +{ + auto query = generateQuery( + account_id, + counter, + created_time); + query->mutable_payload()->mutable_get_peers(); + return query; +} + } diff --git a/iroha-lib/model/generators/QueryGenerator.hpp b/iroha-lib/model/generators/QueryGenerator.hpp index 76cbecc3e2f..b97f981b8a7 100644 --- a/iroha-lib/model/generators/QueryGenerator.hpp +++ b/iroha-lib/model/generators/QueryGenerator.hpp @@ -64,6 +64,10 @@ class QueryGenerator { uint64_t counter, const uint64_t created_time, const std::string& role_id); + std::shared_ptr generateGetPeers( + const std::string& account_id, + uint64_t counter, + const uint64_t created_time); private: std::shared_ptr generateQuery( diff --git a/vcpkg/patches/0014-gtest-remove-werror-compile-flag.patch b/vcpkg/patches/0014-gtest-remove-werror-compile-flag.patch new file mode 100644 index 00000000000..70dcb755f13 --- /dev/null +++ b/vcpkg/patches/0014-gtest-remove-werror-compile-flag.patch @@ -0,0 +1,38 @@ +diff --git a/ports/gtest/portfile.cmake b/ports/gtest/portfile.cmake +index 11ac1140a..5226367cd 100644 +--- a/ports/gtest/portfile.cmake ++++ b/ports/gtest/portfile.cmake +@@ -12,6 +12,7 @@ vcpkg_from_github( + 0002-Fix-z7-override.patch + fix-main-lib-path.patch + fix-build-failure-in-gcc-11.patch ++ removing-werror-compiler-flag.patch + ) + + string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" GTEST_FORCE_SHARED_CRT) +diff --git a/ports/gtest/removing-werror-compiler-flag.patch b/ports/gtest/removing-werror-compiler-flag.patch +new file mode 100644 +index 000000000..2b7339da4 +--- /dev/null ++++ b/ports/gtest/removing-werror-compiler-flag.patch +@@ -0,0 +1,20 @@ ++diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake ++index 4439cb9..e385a5a 100644 ++--- a/googletest/cmake/internal_utils.cmake +++++ b/googletest/cmake/internal_utils.cmake ++@@ -82,13 +82,13 @@ macro(config_compiler_and_linker) ++ # http://stackoverflow.com/questions/3232669 explains the issue. ++ set(cxx_base_flags "${cxx_base_flags} -wd4702") ++ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ++- set(cxx_base_flags "-Wall -Wshadow -Werror -Wconversion") +++ set(cxx_base_flags "-Wall -Wshadow -Wconversion") ++ set(cxx_exception_flags "-fexceptions") ++ set(cxx_no_exception_flags "-fno-exceptions") ++ set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") ++ set(cxx_no_rtti_flags "-fno-rtti") ++ elseif (CMAKE_COMPILER_IS_GNUCXX) ++- set(cxx_base_flags "-Wall -Wshadow -Werror") +++ set(cxx_base_flags "-Wall -Wshadow") ++ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) ++ set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else") ++ endif()