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

fix(consensus): Check Equihash solutions with n=200, k=9 parameters #8474

Merged
merged 3 commits into from
Apr 29, 2024
Merged
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
11 changes: 6 additions & 5 deletions zebra-chain/src/work/equihash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ impl Solution {
/// Returns `Ok(())` if `EquihashSolution` is valid for `header`
#[allow(clippy::unwrap_in_result)]
pub fn check(&self, header: &Header) -> Result<(), Error> {
// TODO:
// - Add Equihash parameters field to `testnet::Parameters`
// - Update `Solution::Regtest` variant to hold a `Vec` to support arbitrary parameters - rename to `Other`
let n = 200;
let k = 9;
let nonce = &header.nonce;
let (solution, n, k) = match self {
Solution::Common(solution) => (solution.as_slice(), 200, 9),
Solution::Regtest(solution) => (solution.as_slice(), 48, 5),
};

let mut input = Vec::new();
header
Expand All @@ -84,7 +85,7 @@ impl Solution {
// This data is kept constant during solver runs, so the verifier API takes it separately.
let input = &input[0..Solution::INPUT_LENGTH];

equihash::is_valid_solution(n, k, input, nonce.as_ref(), solution)?;
equihash::is_valid_solution(n, k, input, nonce.as_ref(), self.value())?;

Ok(())
}
Expand Down
Loading