diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index a34c4fcaab..3b7de9a961 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -107,6 +107,12 @@ hunter_config( SECP256K1_ENABLE_MODULE_RECOVERY=ON ) +hunter_config( + scale + URL https://github.com/qdrvm/scale-codec-cpp/archive/975e6bb1531949d02ee27a13b76cd906e6fc71e9.zip + SHA1 7d7a371edf9fa45d07360c306ee62453fe940490 +) + hunter_config( wabt URL https://github.com/qdrvm/wabt/archive/2e9d30c4a67c1b884a8162bf3f3a5a8585cfdb94.tar.gz diff --git a/core/consensus/grandpa/impl/authority_manager_impl.cpp b/core/consensus/grandpa/impl/authority_manager_impl.cpp index e088163ebf..7a31a339fd 100644 --- a/core/consensus/grandpa/impl/authority_manager_impl.cpp +++ b/core/consensus/grandpa/impl/authority_manager_impl.cpp @@ -96,7 +96,8 @@ namespace kagome::consensus::grandpa { std::shared_ptr prev_state; [[unlikely]] if (info.number == 0) { OUTCOME_TRY(list, grandpa_api_->authorities(info.hash)); - auto genesis = std::make_shared(0, std::move(list)); + auto genesis = + std::make_shared(AuthoritySet{0, std::move(list)}); GrandpaIndexedValue value{ .next_set_id = genesis->id, .state = genesis, @@ -197,12 +198,13 @@ namespace kagome::consensus::grandpa { AuthoritySetId set_id, const HasAuthoritySetChange &digests) const { BOOST_ASSERT(digests); - return std::make_shared( + return std::make_shared(AuthoritySet{ set_id, isKusamaHardFork(block_tree_->getGenesisBlockHash(), block) ? kusamaHardForksAuthorities() : digests.forced ? digests.forced->authorities - : digests.scheduled->authorities); + : digests.scheduled->authorities, + }); } outcome::result AuthorityManagerImpl::load( diff --git a/core/network/types/collator_messages.hpp b/core/network/types/collator_messages.hpp index 9d24aecd9d..e82cbef8d6 100644 --- a/core/network/types/collator_messages.hpp +++ b/core/network/types/collator_messages.hpp @@ -13,6 +13,7 @@ #include #include +#include #include "common/blob.hpp" #include "consensus/grandpa/common.hpp" #include "crypto/hasher.hpp" @@ -382,7 +383,7 @@ namespace kagome::network { /// The collator required to author the block, if any. std::optional collator; - auto operator<=>(const ScheduledCore &) const = default; + SCALE_TIE_CMP(ScheduledCore); }; inline const CandidateHash &candidateHash(const CompactStatement &val) { diff --git a/core/runtime/common/runtime_upgrade_tracker_impl.cpp b/core/runtime/common/runtime_upgrade_tracker_impl.cpp index f5f4dbb727..deefbe24ca 100644 --- a/core/runtime/common/runtime_upgrade_tracker_impl.cpp +++ b/core/runtime/common/runtime_upgrade_tracker_impl.cpp @@ -207,7 +207,8 @@ namespace kagome::runtime { == runtime_upgrades_.end(); if (is_new_upgrade) { - runtime_upgrades_.emplace_back(block_info, header.state_root); + runtime_upgrades_.emplace_back( + RuntimeUpgradeData{block_info, header.state_root}); std::ranges::sort(runtime_upgrades_, [](const auto &lhs, const auto &rhs) { diff --git a/core/scale/tie_cmp.hpp b/core/scale/tie_cmp.hpp new file mode 100644 index 0000000000..fda07527db --- /dev/null +++ b/core/scale/tie_cmp.hpp @@ -0,0 +1,25 @@ +/** + * Copyright Quadrivium LLC + * All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +namespace scale { + auto decomposeTie(const auto &value) { + return ::scale::detail::decompose_and_apply(value, [](auto &&...a) { + return std::tie(std::forward(a)...); + }); + } +} // namespace scale + +#define SCALE_TIE_CMP(type) \ + friend bool operator==(const type &l, const type &r) { \ + return ::scale::decomposeTie(l) == ::scale::decomposeTie(r); \ + } \ + friend bool operator<(const type &l, const type &r) { \ + return ::scale::decomposeTie(l) < ::scale::decomposeTie(r); \ + } diff --git a/core/utils/kagome_db_editor.cpp b/core/utils/kagome_db_editor.cpp index ec5cd26639..5a2ee48370 100644 --- a/core/utils/kagome_db_editor.cpp +++ b/core/utils/kagome_db_editor.cpp @@ -376,7 +376,10 @@ Kagome DB Editor - a storage pruner. Allows to reduce occupied disk space. std::vector runtime_upgrade_data{}; runtime_upgrade_data.emplace_back( - last_finalized_block, last_finalized_block_header.state_root); + runtime::RuntimeUpgradeTrackerImpl::RuntimeUpgradeData{ + last_finalized_block, + last_finalized_block_header.state_root, + }); auto encoded_res = check(scale::encode(runtime_upgrade_data)); check(buffer_storage->put(storage::kRuntimeHashesLookupKey, common::Buffer(encoded_res.value())))