Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f40c165
Updates guide for CandidateBacking
montekki Jun 24, 2020
4031bc7
Move assignment types to primitives
montekki Jun 25, 2020
7f23f7d
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jun 25, 2020
45ead89
Initial implementation.
montekki Jun 27, 2020
81220d8
More functionality
montekki Jul 1, 2020
7572a13
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jul 2, 2020
a7d5e86
use assert_matches
montekki Jul 2, 2020
697accf
Changes to report misbehaviors
montekki Jul 2, 2020
2ce747e
Some fixes after a review
montekki Jul 3, 2020
af9f34a
Remove a blank line
montekki Jul 3, 2020
245cc96
Update guide and some types
montekki Jul 4, 2020
63124aa
Adds run_job function
montekki Jul 4, 2020
1b744ed
Some comments and refactorings
montekki Jul 4, 2020
96ba9dd
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jul 4, 2020
481ab97
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jul 7, 2020
f52aa09
Fix review
montekki Jul 7, 2020
0f8e2b9
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jul 7, 2020
e4aed7c
Remove warnings
montekki Jul 7, 2020
05d7dc6
Use summary in kicking off validation
montekki Jul 7, 2020
994eefd
Parallelize requests
montekki Jul 8, 2020
d879df6
Validation provides local and global validation params
montekki Jul 8, 2020
fef54e1
Test issued validity tracking
montekki Jul 8, 2020
e8fd8f3
Nits from review
montekki Jul 9, 2020
e137f37
Merge branch 'master' into fs-candidate-backing-subsystem
montekki Jul 9, 2020
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
Prev Previous commit
Next Next commit
Use summary in kicking off validation
  • Loading branch information
montekki committed Jul 7, 2020
commit 05d7dc69b23b8b387cb7a38e4efcd2c3e342beae
22 changes: 13 additions & 9 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use statement_table::{
#[derive(Debug, derive_more::From)]
enum Error {
NotInValidatorSet,
CandidateNotFound,
LocalValidationDataMissing,
JobNotFound(Hash),
InvalidSignature,
Expand Down Expand Up @@ -393,25 +394,28 @@ impl CandidateBackingJob {
/// Kick off validation work and distribute the result as a signed statement.
async fn kick_off_validation_work(
&mut self,
candidate: AbridgedCandidateReceipt,
) -> Result<(), Error> {
let pov = self.request_pov_from_distribution(candidate.to_descriptor()).await?;
let v = self.request_candidate_validation(candidate.clone(), pov).await?;
summary: TableSummary,
) -> Result<ValidationResult, Error> {
let candidate = self.table.get_candidate(&summary.candidate).ok_or(Error::CandidateNotFound)?;
let candidate = candidate.clone();
let descriptor = candidate.to_descriptor();
Copy link
Contributor

@rphmeier rphmeier Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clone should not be necessary with to_descriptor. At least the version in master takes &self

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion to_descriptor is not the reason.
clone is happening because table.get_candidate returns an Option<&Candidate> and we have to clone it to pass it by value into the validation.

let candidate_hash = candidate.hash();
let pov = self.request_pov_from_distribution(descriptor).await?;
let v = self.request_candidate_validation(candidate, pov).await?;

let statement = match v {
ValidationResult::Valid => {
let candidate_hash = candidate.hash();
self.issued_validity.insert(candidate_hash);
Statement::Valid(candidate_hash)
}
ValidationResult::Invalid => Statement::Invalid(candidate.hash()),
ValidationResult::Invalid => Statement::Invalid(candidate_hash),
};

if let Some(signed_statement) = self.sign_statement(statement) {
self.distribute_signed_statement(signed_statement).await?;
}

Ok(())
Ok(v)
}

/// Import the statement and kick off validation work if it is a part of our assignment.
Expand All @@ -420,9 +424,9 @@ impl CandidateBackingJob {
statement: SignedFullStatement,
) -> Result<(), Error> {
if let Some(summary) = self.import_statement(&statement).await? {
if let Statement::Seconded(candidate) = statement.into_payload() {
if let Statement::Seconded(_) = statement.payload() {
if summary.group_id == self.assignment {
self.kick_off_validation_work(candidate).await?;
self.kick_off_validation_work(summary).await?;
}
}
}
Expand Down