Skip to content

Commit

Permalink
Filter out the failed solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
raychu86 committed Oct 20, 2023
1 parent 8b8a707 commit 543f728
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ledger/src/advance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
let (solutions, solutions_root, combined_proof_target) = match candidate_solutions.is_empty() {
true => (None, Field::<N>::zero(), 0u128),
false => {
// Only select the candidate solutions that are valid.
let latest_epoch_challenge = self.latest_epoch_challenge()?;
let coinbase_verifying_key = self.coinbase_puzzle.coinbase_verifying_key();
let candidate_solutions = cfg_into_iter!(candidate_solutions)
.filter(|solution| {
solution
.verify(coinbase_verifying_key, &latest_epoch_challenge, self.latest_proof_target())
.unwrap_or(false)
})
.collect::<Vec<_>>();
// TODO (raychu86): Optimize this. We are currently double verifying the solutions.
// Accumulate the prover solutions.
let solutions = self.coinbase_puzzle.accumulate(
candidate_solutions,
Expand Down

0 comments on commit 543f728

Please sign in to comment.