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

Size limited containers; Refactored Buffer and BufferView #1373

Merged
merged 22 commits into from
Oct 28, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/Hunter/hunter-gate-url.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

HunterGate(
URL "https://github.com/soramitsu/soramitsu-hunter/archive/refs/tags/v0.23.257-soramitsu33.zip"
SHA1 "8e7052df7f20840e1f3823aea35a9daf917eb8e8"
URL "https://github.com/soramitsu/soramitsu-hunter/archive/refs/tags/v0.23.257-soramitsu34.zip"
SHA1 "f136380ef45a9874278e8fb8e17d1e69dc9f10f4"
LOCAL
)
1 change: 0 additions & 1 deletion core/api/service/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ add_library(chain_api_service
impl/chain_api_impl.cpp
)
target_link_libraries(chain_api_service
buffer
api_service
api_chain_requests
hexutil
Expand Down
1 change: 0 additions & 1 deletion core/api/service/child_state/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ add_library(child_state_api_service
)
target_link_libraries(child_state_api_service
api_child_state_requests
buffer
api_service
trie_storage
blob
Expand Down
3 changes: 1 addition & 2 deletions core/api/service/child_state/impl/child_state_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ namespace kagome::api {
OUTCOME_TRY(value_opt, getStorage(child_storage_key, key, block_hash_opt));
if (value_opt.has_value()) {
storage::trie::PolkadotCodec codec;
auto hash =
codec.hash256(common::Buffer(gsl::make_span(value_opt.value())));
auto hash = codec.hash256(value_opt.value());
return hash;
}
return std::nullopt;
Expand Down
1 change: 0 additions & 1 deletion core/api/service/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ add_library(internal_api_service
impl/internal_api_impl.cpp
)
target_link_libraries(internal_api_service
buffer
api_service
)
1 change: 0 additions & 1 deletion core/api/service/state/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ add_library(state_api_service
)
target_link_libraries(state_api_service
api_state_requests
buffer
api_service
trie_storage
blob
Expand Down
1 change: 0 additions & 1 deletion core/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ target_link_libraries(chain_spec
Boost::filesystem
p2p::p2p_multiaddress
p2p::p2p_peer_id
buffer
sr25519_types
)
kagome_install(chain_spec)
Expand Down
1 change: 0 additions & 1 deletion core/authorship/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ add_library(block_builder
)
target_link_libraries(block_builder
outcome
buffer
logger
scale::scale
)
Expand Down
1 change: 0 additions & 1 deletion core/blockchain/impl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ add_library(blockchain_common
target_link_libraries(blockchain_common
blob
Boost::boost
buffer
database_error
in_memory_storage
trie_storage
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain/impl/block_storage_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace kagome::blockchain {
SL_TRACE(logger_, "Removing block {}...", block);

auto hash_to_idx_key =
prependPrefix(Buffer{block.hash}, Prefix::ID_TO_LOOKUP_KEY);
prependPrefix(block.hash, Prefix::ID_TO_LOOKUP_KEY);
if (auto res = storage_->remove(hash_to_idx_key); res.has_error()) {
logger_->error("could not remove hash-to-idx from the storage: {}",
res.error().message());
Expand Down
6 changes: 3 additions & 3 deletions core/blockchain/impl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace kagome::blockchain {
prefix::Prefix::ID_TO_LOOKUP_KEY);
},
[](const common::Hash256 &hash) {
return prependPrefix(common::Buffer{hash},
prefix::Prefix::ID_TO_LOOKUP_KEY);
return prependPrefix(hash, prefix::Prefix::ID_TO_LOOKUP_KEY);
});

OUTCOME_TRY(key_opt, map.tryLoad(key));
Expand All @@ -41,7 +40,8 @@ namespace kagome::blockchain {
}
auto root = trie.getRoot();
if (root == nullptr) {
return codec.hash256(common::Buffer{0});
static const auto zero_hash = codec.hash256(common::Buffer{0});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing mocks may conflict

return zero_hash;
}
auto encode_res = codec.encodeNode(*root);
BOOST_ASSERT_MSG(encode_res.has_value(), "Trie encoding failed");
Expand Down
3 changes: 1 addition & 2 deletions core/blockchain/impl/storage_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ namespace kagome::blockchain {
const common::Buffer &value) {
auto block_lookup_key = numberAndHashToLookupKey(num, block_hash);

auto hash_to_idx_key =
prependPrefix(Buffer{block_hash}, Prefix::ID_TO_LOOKUP_KEY);
auto hash_to_idx_key = prependPrefix(block_hash, Prefix::ID_TO_LOOKUP_KEY);
OUTCOME_TRY(map.put(hash_to_idx_key, block_lookup_key));

auto value_lookup_key = prependPrefix(block_lookup_key, prefix);
Expand Down
9 changes: 0 additions & 9 deletions core/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ target_link_libraries(hexutil
)
kagome_install(hexutil)

add_library(buffer
buffer.hpp
buffer.cpp
)
target_link_libraries(buffer
hexutil
)
kagome_install(buffer)

add_library(blob
blob.hpp
blob.cpp
Expand Down
2 changes: 2 additions & 0 deletions core/common/blob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ namespace kagome::common {
template <size_t size_>
class Blob : public std::array<byte_t, size_> {
public:
// Next line is required at least for the scale-codec
static constexpr bool is_static_collection = true;

using const_narref = const byte_t (&)[size_];
using const_narptr = const byte_t (*)[size_];
/**
Expand Down
204 changes: 0 additions & 204 deletions core/common/buffer.cpp

This file was deleted.

Loading