diff options
Diffstat (limited to 'src')
7 files changed, 12 insertions, 79 deletions
diff --git a/src/buildtool/execution_api/common/bytestream_utils.cpp b/src/buildtool/execution_api/common/bytestream_utils.cpp index 2afc3e60..13759eba 100644 --- a/src/buildtool/execution_api/common/bytestream_utils.cpp +++ b/src/buildtool/execution_api/common/bytestream_utils.cpp @@ -60,13 +60,6 @@ namespace { } } // namespace -ByteStreamUtils::ReadRequest::ReadRequest( - std::string instance_name, - bazel_re::Digest const& digest) noexcept - : instance_name_{std::move(instance_name)}, - hash_{digest.hash()}, - size_{static_cast<std::size_t>(digest.size_bytes())} {} - ByteStreamUtils::ReadRequest::ReadRequest(std::string instance_name, ArtifactDigest const& digest) noexcept : instance_name_{std::move(instance_name)}, diff --git a/src/buildtool/execution_api/common/bytestream_utils.hpp b/src/buildtool/execution_api/common/bytestream_utils.hpp index ecfd2a97..a9d5ff59 100644 --- a/src/buildtool/execution_api/common/bytestream_utils.hpp +++ b/src/buildtool/execution_api/common/bytestream_utils.hpp @@ -23,11 +23,6 @@ #include "src/buildtool/crypto/hash_function.hpp" #include "src/utils/cpp/expected.hpp" -namespace build::bazel::remote::execution::v2 { -class Digest; -} -namespace bazel_re = build::bazel::remote::execution::v2; - class ByteStreamUtils final { static constexpr auto* kBlobs = "blobs"; static constexpr auto* kUploads = "uploads"; @@ -44,9 +39,6 @@ class ByteStreamUtils final { class ReadRequest final { public: explicit ReadRequest(std::string instance_name, - bazel_re::Digest const& digest) noexcept; - - explicit ReadRequest(std::string instance_name, ArtifactDigest const& digest) noexcept; [[nodiscard]] auto ToString() && noexcept -> std::string; diff --git a/src/buildtool/execution_api/remote/TARGETS b/src/buildtool/execution_api/remote/TARGETS index b7b29d0c..34dd8c16 100644 --- a/src/buildtool/execution_api/remote/TARGETS +++ b/src/buildtool/execution_api/remote/TARGETS @@ -29,7 +29,6 @@ , ["src/buildtool/common/remote", "port"] , ["src/buildtool/common/remote", "retry_config"] , ["src/buildtool/crypto", "hash_function"] - , ["src/buildtool/crypto", "hash_info"] , ["src/buildtool/execution_api/bazel_msg", "bazel_msg"] , ["src/buildtool/execution_api/common", "artifact_blob_container"] , ["src/buildtool/execution_api/common", "bytestream_utils"] diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp index f6919488..179ac0db 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp @@ -333,18 +333,18 @@ auto BazelCasClient::UpdateSingleBlob(std::string const& instance_name, } auto BazelCasClient::IncrementalReadSingleBlob(std::string const& instance_name, - bazel_re::Digest const& digest) + ArtifactDigest const& digest) const noexcept -> ByteStreamClient::IncrementalReader { return stream_->IncrementalRead( ByteStreamUtils::ReadRequest{instance_name, digest}); } -auto BazelCasClient::ReadSingleBlob( - std::string const& instance_name, - bazel_re::Digest const& digest) const noexcept -> std::optional<BazelBlob> { +auto BazelCasClient::ReadSingleBlob(std::string const& instance_name, + ArtifactDigest const& digest) const noexcept + -> std::optional<ArtifactBlob> { if (auto data = stream_->Read( ByteStreamUtils::ReadRequest{instance_name, digest})) { - return BazelBlob{digest, std::move(*data), /*is_exec=*/false}; + return ArtifactBlob{digest, std::move(*data), /*is_exec=*/false}; } return std::nullopt; } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp index abde3ae2..370bb7ca 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp @@ -35,7 +35,6 @@ #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/crypto/hash_function.hpp" -#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/common/artifact_blob_container.hpp" #include "src/buildtool/execution_api/remote/bazel/bytestream_client.hpp" #include "src/buildtool/logging/logger.hpp" @@ -97,7 +96,7 @@ class BazelCasClient { /// \returns Incremental bytestream reader. [[nodiscard]] auto IncrementalReadSingleBlob( std::string const& instance_name, - bazel_re::Digest const& digest) const noexcept + ArtifactDigest const& digest) const noexcept -> ByteStreamClient::IncrementalReader; /// \brief Read single blob via bytestream @@ -105,8 +104,8 @@ class BazelCasClient { /// \param[in] digest Blob digest to read /// \returns The blob successfully read [[nodiscard]] auto ReadSingleBlob(std::string const& instance_name, - bazel_re::Digest const& digest) - const noexcept -> std::optional<BazelBlob>; + ArtifactDigest const& digest) + const noexcept -> std::optional<ArtifactBlob>; /// @brief Split single blob into chunks /// @param[in] hash_function Hash function to be used for creation of diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp index 49ef0166..4b6989ec 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp @@ -21,7 +21,6 @@ #include <utility> #include "src/buildtool/common/artifact_digest_factory.hpp" -#include "src/buildtool/common/bazel_digest_factory.hpp" #include "src/buildtool/common/protocol_traits.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp" #include "src/buildtool/execution_api/common/content_blob_container.hpp" @@ -30,7 +29,6 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/back_map.hpp" -#include "src/utils/cpp/expected.hpp" #include "src/utils/cpp/gsl.hpp" #include "src/utils/cpp/path.hpp" @@ -134,8 +132,7 @@ auto BazelNetworkReader::DumpRawTree(Artifact::ObjectInfo const& info, auto BazelNetworkReader::DumpBlob(Artifact::ObjectInfo const& info, DumpCallback const& dumper) const noexcept -> bool { - auto reader = cas_.IncrementalReadSingleBlob( - instance_name_, ArtifactDigestFactory::ToBazel(info.digest)); + auto reader = cas_.IncrementalReadSingleBlob(instance_name_, info.digest); auto data = reader.Next(); while (data and not data->empty()) { try { @@ -173,25 +170,13 @@ auto BazelNetworkReader::MakeAuxiliaryMap( return result; } -auto BazelNetworkReader::ReadSingleBlob(bazel_re::Digest const& digest) +auto BazelNetworkReader::ReadSingleBlob(ArtifactDigest const& digest) const noexcept -> std::optional<ArtifactBlob> { auto blob = cas_.ReadSingleBlob(instance_name_, digest); - if (not blob) { - return std::nullopt; - } - auto hash_info = Validate(*blob); - if (not hash_info) { + if (not blob or not Validate(*blob)) { return std::nullopt; } - return ArtifactBlob{ - ArtifactDigest{*std::move(hash_info), blob->data->size()}, - blob->data, - blob->is_exec}; -} - -auto BazelNetworkReader::ReadSingleBlob(ArtifactDigest const& digest) - const noexcept -> std::optional<ArtifactBlob> { - return ReadSingleBlob(ArtifactDigestFactory::ToBazel(digest)); + return blob; } auto BazelNetworkReader::ReadIncrementally( @@ -262,33 +247,6 @@ auto BazelNetworkReader::Validate(ArtifactBlob const& blob) const noexcept return rehashed == blob.digest; } -auto BazelNetworkReader::Validate(BazelBlob const& blob) const noexcept - -> std::optional<HashInfo> { - // validate digest - auto requested_hash_info = - BazelDigestFactory::ToHashInfo(hash_function_.GetType(), blob.digest); - if (not requested_hash_info) { - Logger::Log(LogLevel::Warning, - "BazelNetworkReader: {}", - std::move(requested_hash_info).error()); - return std::nullopt; - } - - // rehash data - auto rehashed_info = HashInfo::HashData( - hash_function_, *blob.data, requested_hash_info->IsTree()); - - // ensure rehashed data produce the same hash - if (*requested_hash_info != rehashed_info) { - Logger::Log(LogLevel::Warning, - "Requested {}, but received {}", - requested_hash_info->Hash(), - rehashed_info.Hash()); - return std::nullopt; - } - return rehashed_info; -} - namespace { [[nodiscard]] auto FindBorderIterator( std::vector<ArtifactDigest>::const_iterator const& begin, diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp index 4dc4b821..0b0df21f 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp @@ -29,8 +29,6 @@ #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/bazel_types.hpp" #include "src/buildtool/crypto/hash_function.hpp" -#include "src/buildtool/crypto/hash_info.hpp" -#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/common/artifact_blob_container.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp" #include "src/buildtool/file_system/git_repo.hpp" @@ -93,18 +91,12 @@ class BazelNetworkReader final { std::vector<bazel_re::Directory>&& full_tree) const noexcept -> std::optional<DirectoryMap>; - [[nodiscard]] auto ReadSingleBlob(bazel_re::Digest const& digest) - const noexcept -> std::optional<ArtifactBlob>; - [[nodiscard]] auto BatchReadBlobs( std::vector<ArtifactDigest> const& digests) const noexcept -> std::vector<ArtifactBlob>; [[nodiscard]] auto Validate(ArtifactBlob const& blob) const noexcept -> bool; - - [[nodiscard]] auto Validate(BazelBlob const& blob) const noexcept - -> std::optional<HashInfo>; }; class BazelNetworkReader::IncrementalReader final { |