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

av-store: clean up StoreAvailableData message #3984

Merged
3 commits merged into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,6 @@ fn process_message(
},
AvailabilityStoreMessage::StoreAvailableData(
candidate,
_our_index,
n_validators,
available_data,
tx,
Expand Down
7 changes: 0 additions & 7 deletions node/core/av-store/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ fn store_block_works() {
let (tx, rx) = oneshot::channel();
let block_msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
Some(validator_index),
n_validators,
available_data.clone(),
tx,
Expand Down Expand Up @@ -476,7 +475,6 @@ fn store_pov_and_query_chunk_works() {
let (tx, rx) = oneshot::channel();
let block_msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
None,
n_validators,
available_data,
tx,
Expand Down Expand Up @@ -523,7 +521,6 @@ fn query_all_chunks_works() {
let (tx, rx) = oneshot::channel();
let block_msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_hash_1,
None,
n_validators,
available_data,
tx,
Expand Down Expand Up @@ -612,7 +609,6 @@ fn stored_but_not_included_data_is_pruned() {
let (tx, rx) = oneshot::channel();
let block_msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
None,
n_validators,
available_data.clone(),
tx,
Expand Down Expand Up @@ -665,7 +661,6 @@ fn stored_data_kept_until_finalized() {
let (tx, rx) = oneshot::channel();
let block_msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
None,
n_validators,
available_data.clone(),
tx,
Expand Down Expand Up @@ -901,7 +896,6 @@ fn forkfullness_works() {
let (tx, rx) = oneshot::channel();
let msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_1_hash,
None,
n_validators,
available_data_1.clone(),
tx,
Expand All @@ -914,7 +908,6 @@ fn forkfullness_works() {
let (tx, rx) = oneshot::channel();
let msg = AvailabilityStoreMessage::StoreAvailableData(
candidate_2_hash,
None,
n_validators,
available_data_2.clone(),
tx,
Expand Down
17 changes: 1 addition & 16 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ fn table_attested_to_backed(

async fn store_available_data(
sender: &mut JobSender<impl SubsystemSender>,
id: Option<ValidatorIndex>,
n_validators: u32,
candidate_hash: CandidateHash,
available_data: AvailableData,
Expand All @@ -303,7 +302,6 @@ async fn store_available_data(
sender
.send_message(AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
id,
n_validators,
available_data,
tx,
Expand All @@ -321,7 +319,6 @@ async fn store_available_data(
// This returns `Err()` iff there is an internal error. Otherwise, it returns either `Ok(Ok(()))` or `Ok(Err(_))`.
async fn make_pov_available(
sender: &mut JobSender<impl SubsystemSender>,
validator_index: Option<ValidatorIndex>,
n_validators: usize,
pov: Arc<PoV>,
candidate_hash: CandidateHash,
Expand All @@ -347,14 +344,7 @@ async fn make_pov_available(
{
let _span = span.as_ref().map(|s| s.child("store-data").with_candidate(candidate_hash));

store_available_data(
sender,
validator_index,
n_validators as u32,
candidate_hash,
available_data,
)
.await?;
store_available_data(sender, n_validators as u32, candidate_hash, available_data).await?;
}

Ok(Ok(()))
Expand Down Expand Up @@ -409,7 +399,6 @@ struct BackgroundValidationParams<S: overseer::SubsystemSender<AllMessages>, F>
candidate: CandidateReceipt,
relay_parent: Hash,
pov: PoVData,
validator_index: Option<ValidatorIndex>,
n_validators: usize,
span: Option<jaeger::Span>,
make_command: F,
Expand All @@ -427,7 +416,6 @@ async fn validate_and_make_available(
candidate,
relay_parent,
pov,
validator_index,
n_validators,
span,
make_command,
Expand Down Expand Up @@ -484,7 +472,6 @@ async fn validate_and_make_available(
} else {
let erasure_valid = make_pov_available(
&mut sender,
validator_index,
n_validators,
pov.clone(),
candidate.hash(),
Expand Down Expand Up @@ -719,7 +706,6 @@ impl CandidateBackingJob {
candidate: candidate.clone(),
relay_parent: self.parent,
pov: PoVData::Ready(pov),
validator_index: self.table_context.validator.as_ref().map(|v| v.index()),
n_validators: self.table_context.validators.len(),
span,
make_command: ValidatedCandidateCommand::Second,
Expand Down Expand Up @@ -1033,7 +1019,6 @@ impl CandidateBackingJob {
candidate: attesting.candidate,
relay_parent: self.parent,
pov,
validator_index: self.table_context.validator.as_ref().map(|v| v.index()),
n_validators: self.table_context.validators.len(),
span,
make_command: ValidatedCandidateCommand::Attest,
Expand Down
8 changes: 4 additions & 4 deletions node/core/backing/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ fn backing_second_works() {
assert_matches!(
virtual_overseer.recv().await,
AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, _, _, _, tx)
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, .., tx)
) if candidate_hash == candidate.hash() => {
tx.send(Ok(())).unwrap();
}
Expand Down Expand Up @@ -495,7 +495,7 @@ fn backing_works() {
assert_matches!(
virtual_overseer.recv().await,
AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, _, _, _, tx)
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, .., tx)
) if candidate_hash == candidate_a.hash() => {
tx.send(Ok(())).unwrap();
}
Expand Down Expand Up @@ -853,7 +853,7 @@ fn backing_misbehavior_works() {
assert_matches!(
virtual_overseer.recv().await,
AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, _, _, _, tx)
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, .., tx)
) if candidate_hash == candidate_a.hash() => {
tx.send(Ok(())).unwrap();
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ fn backing_dont_second_invalid() {
assert_matches!(
virtual_overseer.recv().await,
AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, _, _, _, tx)
AvailabilityStoreMessage::StoreAvailableData(candidate_hash, .., tx)
) if candidate_hash == candidate_b.hash() => {
tx.send(Ok(())).unwrap();
}
Expand Down
1 change: 0 additions & 1 deletion node/core/dispute-participation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ async fn participate(
// in the dispute
ctx.send_message(AvailabilityStoreMessage::StoreAvailableData(
candidate_hash,
None,
n_validators,
available_data.clone(),
store_available_data_tx,
Expand Down
1 change: 0 additions & 1 deletion node/core/dispute-participation/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async fn store_available_data(virtual_overseer: &mut VirtualOverseer, success: b
_,
_,
_,
_,
tx,
)) => {
if success {
Expand Down
11 changes: 2 additions & 9 deletions node/subsystem-types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,10 @@ pub enum AvailabilityStoreMessage {
tx: oneshot::Sender<Result<(), ()>>,
},

/// Store a `AvailableData` in the AV store.
/// If `ValidatorIndex` is present store corresponding chunk also.
/// Store a `AvailableData` and all of its chunks in the AV store.
///
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
StoreAvailableData(
CandidateHash,
Option<ValidatorIndex>,
u32,
AvailableData,
oneshot::Sender<Result<(), ()>>,
),
StoreAvailableData(CandidateHash, u32, AvailableData, oneshot::Sender<Result<(), ()>>),
ordian marked this conversation as resolved.
Show resolved Hide resolved
}

impl AvailabilityStoreMessage {
Expand Down