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

Feat(near-client): Chunk distribution via message bus #10480

Merged
merged 17 commits into from
Feb 20, 2024
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
18 changes: 17 additions & 1 deletion chain/chunks/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use near_primitives::{
types::EpochId,
};

#[derive(Message, Debug, strum::IntoStaticStr)]
#[derive(Message, Debug, strum::IntoStaticStr, PartialEq)]
#[rtype(result = "()")]
pub enum ShardsManagerRequestFromClient {
/// Processes the header seen from a block we received, if we have not already received the
Expand Down Expand Up @@ -50,4 +50,20 @@ pub enum ShardsManagerRequestFromClient {
/// proofs, but cannot be marked as complete because the previous block isn't available),
/// and completes them if so.
CheckIncompleteChunks(CryptoHash),
/// Process a `PartialEncodedChunk` obtained via the Chunk Distribution Network feature.
/// If the chunk turns out to be invalid then request from the p2p network instead.
ProcessOrRequestChunk {
candidate_chunk: PartialEncodedChunk,
request_header: ShardChunkHeader,
prev_hash: CryptoHash,
},
/// Similar to `ProcessOrRequestChunk` but for orphan chunks.
/// Process a `PartialEncodedChunk` obtained via the Chunk Distribution Network feature.
/// If the chunk turns out to be invalid then request from the p2p network instead.
ProcessOrRequestChunkForOrphan {
candidate_chunk: PartialEncodedChunk,
request_header: ShardChunkHeader,
epoch_id: EpochId,
ancestor_hash: CryptoHash,
},
}
21 changes: 21 additions & 0 deletions chain/chunks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,27 @@ impl ShardsManager {
ShardsManagerRequestFromClient::CheckIncompleteChunks(prev_block_hash) => {
self.check_incomplete_chunks(&prev_block_hash)
}
ShardsManagerRequestFromClient::ProcessOrRequestChunk {
candidate_chunk,
request_header,
prev_hash,
} => {
if let Err(err) = self.process_partial_encoded_chunk(candidate_chunk.into()) {
warn!(target: "chunks", ?err, "Error processing partial encoded chunk");
self.request_chunk_single(&request_header, prev_hash, false);
}
}
ShardsManagerRequestFromClient::ProcessOrRequestChunkForOrphan {
candidate_chunk,
request_header,
ancestor_hash,
epoch_id,
} => {
if let Err(e) = self.process_partial_encoded_chunk(candidate_chunk.into()) {
warn!(target: "chunks", "Error processing partial encoded chunk: {:?}", e);
self.request_chunks_for_orphan(vec![request_header], &epoch_id, ancestor_hash);
}
}
}
}

Expand Down
Loading
Loading