-
Notifications
You must be signed in to change notification settings - Fork 39
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
Feature: request chunk protocol v2 #2144
Merged
Merged
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cd6c696
feature: add type for chunk index
xDimon 8ac2c02
refactor: add prefix "-obsolete" for previous protocol version and re…
xDimon abf583c
draft
xDimon 9be5a4f
draft
xDimon fb9ab25
feature: extent node feature and add function to compute chunk_index …
xDimon 90b984a
refactor: signature some funcs
xDimon 0908daa
feature: zombietest 0013-systematic-chunk-recovery
xDimon 558679e
git: Merge branch 'master' into feature/req_chunk_v2
xDimon 19665ea
Update and enable 13 test
kamilsa 3423353
Merge remote-tracking branch 'origin/feature/req_chunk_v2' into featu…
kamilsa 5c49e87
Return 4 kagome validators in 0001
kamilsa a136d64
Add empty line
kamilsa 2ab0d9d
feature: add metrics of total number of started/finished recoveries
xDimon fa136b8
feature: add metrics of total number of started/finished recoveries
xDimon 1d1ed2f
Merge branch 'master' into feature/req_chunk_v2
xDimon 0282430
hotfix
xDimon f4c384b
fix: review issues
xDimon 8c8b8ed
fix: exception
xDimon 72263f3
git: Merge branch 'master' into feature/req_chunk_v2
xDimon 7fd3a3b
git: Merge branch 'master' into feature/req_chunk_v2
xDimon 1ca24f6
Merge branch 'master' into feature/req_chunk_v2
xDimon 0dab997
fix: review issues
xDimon d18d3b1
update: switch clang-format to version 16
xDimon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
core/network/impl/protocols/protocol_fetch_chunk_obsolete.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Copyright Quadrivium LLC | ||
* All Rights Reserved | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "network/protocol_base.hpp" | ||
|
||
#include <memory> | ||
|
||
#include <libp2p/connection/stream.hpp> | ||
#include <libp2p/host/host.hpp> | ||
|
||
#include "blockchain/genesis_block_hash.hpp" | ||
#include "log/logger.hpp" | ||
#include "network/common.hpp" | ||
#include "network/impl/protocols/request_response_protocol.hpp" | ||
#include "network/impl/stream_engine.hpp" | ||
#include "parachain/validator/parachain_processor.hpp" | ||
#include "utils/non_copyable.hpp" | ||
|
||
namespace kagome::network { | ||
|
||
struct ReqPovProtocolImpl; | ||
|
||
class FetchChunkProtocolObsolete final | ||
xDimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: public RequestResponseProtocol<FetchChunkRequest, | ||
FetchChunkResponseObsolete, | ||
ScaleMessageReadWriter>, | ||
NonCopyable, | ||
NonMovable { | ||
public: | ||
FetchChunkProtocolObsolete() = delete; | ||
~FetchChunkProtocolObsolete() override = default; | ||
|
||
FetchChunkProtocolObsolete( | ||
libp2p::Host &host, | ||
const application::ChainSpec & /*chain_spec*/, | ||
const blockchain::GenesisBlockHash &genesis_hash, | ||
std::shared_ptr<parachain::ParachainProcessorImpl> pp) | ||
: RequestResponseProtocol< | ||
FetchChunkRequest, | ||
FetchChunkResponseObsolete, | ||
ScaleMessageReadWriter>{kFetchChunkProtocolName, | ||
host, | ||
make_protocols(kFetchChunkProtocolObsolete, | ||
genesis_hash, | ||
kProtocolPrefixPolkadot), | ||
log::createLogger(kFetchChunkProtocolName, | ||
"req_chunk_protocol")}, | ||
pp_{std::move(pp)} { | ||
BOOST_ASSERT(pp_); | ||
} | ||
|
||
private: | ||
std::optional<outcome::result<ResponseType>> onRxRequest( | ||
RequestType request, std::shared_ptr<Stream> /*stream*/) override { | ||
base().logger()->info("Fetching chunk request.(chunk={}, candidate={})", | ||
request.chunk_index, | ||
request.candidate); | ||
auto res = pp_->OnFetchChunkRequest(std::move(request)); | ||
if (res.has_error()) { | ||
base().logger()->error("Fetching chunk response failed.(error={})", | ||
res.error()); | ||
return res.as_failure(); | ||
} | ||
|
||
if (auto chunk = if_type<const network::Chunk>(res.value())) { | ||
base().logger()->info("Fetching chunk response with data."); | ||
return outcome::success(network::ChunkObsolete{ | ||
.data = std::move(chunk.value().get().data), | ||
.proof = std::move(chunk.value().get().proof), | ||
}); | ||
} | ||
|
||
base().logger()->info("Fetching chunk response empty."); | ||
return outcome::success(network::Empty{}); | ||
} | ||
|
||
void onTxRequest(const RequestType &request) override { | ||
base().logger()->debug("Fetching chunk candidate: {}, index: {}", | ||
request.candidate, | ||
request.chunk_index); | ||
} | ||
|
||
inline static const auto kFetchChunkProtocolName = "FetchChunkProtocol_v1"s; | ||
std::shared_ptr<parachain::ParachainProcessorImpl> pp_; | ||
}; | ||
|
||
} // namespace kagome::network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove this function?