Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
A fast-path for requesting AvailableData from backing validators (#…
Browse files Browse the repository at this point in the history
…2453)

* guide changes for a fast-path requesting from backing validators

* add backing group to availability recovery message

* add new phase to interaction

* typos

* add full data messages

* handle new network messages

* dispatch full data requests

* cleanup

* check chunk index

* test for invalid recovery

* tests

* Typos.

* fix some grumbles

* be more explicit about error handling and control flow

* fast-path param

* use with_chunks_only in Service

Co-authored-by: Robert Klotzner <robert.klotzner@gmx.at>
  • Loading branch information
rphmeier and eskimor authored Feb 17, 2021
1 parent b0ff3d4 commit f778e52
Show file tree
Hide file tree
Showing 11 changed files with 948 additions and 194 deletions.
16 changes: 12 additions & 4 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use polkadot_primitives::v1::{
ValidatorIndex, Hash, SessionIndex, SessionInfo, CandidateHash,
CandidateReceipt, BlockNumber, PersistedValidationData,
ValidationCode, CandidateDescriptor, PoV, ValidatorPair, ValidatorSignature, ValidatorId,
CandidateIndex,
CandidateIndex, GroupIndex,
};
use polkadot_node_primitives::ValidationResult;
use polkadot_node_primitives::approval::{
Expand Down Expand Up @@ -268,6 +268,7 @@ enum Action {
candidate_index: CandidateIndex,
session: SessionIndex,
candidate: CandidateReceipt,
backing_group: GroupIndex,
},
Conclude,
}
Expand Down Expand Up @@ -391,6 +392,7 @@ async fn handle_actions(
candidate_index,
session,
candidate,
backing_group,
} => {
let block_hash = indirect_cert.block_hash;
let validator_index = indirect_cert.validator;
Expand All @@ -408,6 +410,7 @@ async fn handle_actions(
validator_index,
block_hash,
candidate_index as _,
backing_group,
).await?
}
Action::Conclude => { conclude = true; }
Expand Down Expand Up @@ -1050,7 +1053,7 @@ fn process_wakeup(

let tranche_now = state.clock.tranche_now(state.slot_duration_millis, block_entry.slot());

let should_trigger = {
let (should_trigger, backing_group) = {
let approval_entry = match candidate_entry.approval_entry(&relay_block) {
Some(e) => e,
None => return Ok(Vec::new()),
Expand All @@ -1065,12 +1068,14 @@ fn process_wakeup(
session_info.needed_approvals as _,
);

should_trigger_assignment(
let should_trigger = should_trigger_assignment(
&approval_entry,
&candidate_entry,
tranches_to_approve,
tranche_now,
)
);

(should_trigger, approval_entry.backing_group())
};

let (mut actions, maybe_cert) = if should_trigger {
Expand Down Expand Up @@ -1105,6 +1110,7 @@ fn process_wakeup(
candidate_index: i as _,
session: block_entry.session(),
candidate: candidate_entry.candidate_receipt().clone(),
backing_group,
});
}
}
Expand Down Expand Up @@ -1142,6 +1148,7 @@ async fn launch_approval(
validator_index: ValidatorIndex,
block_hash: Hash,
candidate_index: usize,
backing_group: GroupIndex,
) -> SubsystemResult<()> {
let (a_tx, a_rx) = oneshot::channel();
let (code_tx, code_rx) = oneshot::channel();
Expand All @@ -1150,6 +1157,7 @@ async fn launch_approval(
ctx.send_message(AvailabilityRecoveryMessage::RecoverAvailableData(
candidate.clone(),
session_index,
Some(backing_group),
a_tx,
).into()).await;

Expand Down
3 changes: 3 additions & 0 deletions node/network/availability-recovery/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub enum Error {
#[error("failed to query a chunk from store")]
CanceledQueryChunk(#[source] oneshot::Canceled),

#[error("failed to query full data from store")]
CanceledQueryFullData(#[source] oneshot::Canceled),

#[error("failed to query session info")]
CanceledSessionInfo(#[source] oneshot::Canceled),

Expand Down
Loading

0 comments on commit f778e52

Please sign in to comment.