Conversation
Add an opt-in `validate_deadlines` config flag (default false) that independently re-derives each new best deadline before trusting it. On a failing disk a scoop can be read back corrupted and hash to a bogus low (good) deadline. That bogus deadline gets submitted (and fails network verification) and, worse, is recorded as the account's best quality, filtering out genuine solutions found later in other warps/files. This is a best-effort safeguard for users with bad drives. When enabled, the nonce submission task regenerates the canonical scoop from (account_id, seed, nonce, scoop) via the scalar (non-SIMD) code path, recomputes the quality, and compares it to the on-disk value. On mismatch (or any decode/regeneration error) the candidate is rejected: best is not updated and nothing is submitted, so a genuine solution can still win. Re-derivation runs only on the rare new-best event over a single small scoop, a fair tradeoff for the protection it provides. - pocx_hashlib: add scalar generate_scoop_scalar, calculate_quality_raw_scalar and calculate_quality_from_height_scalar (generate_nonces_32 + find_best_quality_32) - pocx_miner: add validate_deadlines to Cfg/CfgBuilder and miner_config.yaml - pocx_miner: add revalidation gate in create_nonce_submission_tasks - tests: scalar/SIMD quality equivalence and corruption detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
validate_deadlinesconfig flag (defaultfalse) that independently re-derives every new best deadline before the miner trusts it — a best-effort safeguard for users with failing hard drives.Problem
A failing disk can read a scoop back corrupted, which then hashes to an essentially random — and sometimes lower (better) — deadline. Today that bogus deadline is:
best_quality, so a genuine, slightly-higher deadline found later (in another warp/file) is filtered out by theadjusted_quality < best_qualitygate. The bad solution overshadows a valid one locally.Fix
When
validate_deadlinesis enabled, the nonce-submission task — the single place that tracks and updates best — re-derives the canonical scoop from(account_id, seed, nonce, scoop)through the scalar (non-SIMD) code path, recomputes the quality, and compares it against the on-disk value. On mismatch (or any decode/regeneration error) the candidate is rejected: best is not updated and nothing is submitted, so a genuine solution can still win.The scalar and SIMD quality computations are bit-identical (already asserted by existing tests), so a healthy scoop always reproduces its quality exactly; only corrupt data mismatches. Re-derivation runs only on the rare new-best event over a single small scoop — a fair tradeoff for the protection it provides.
Changes
generate_scoopto share its loop, add scalargenerate_scoop_scalar,calculate_quality_raw_scalar, andcalculate_quality_from_height_scalar(built ongenerate_nonces_32+find_best_quality_32).validate_deadlines(defaultfalse) toCfg,CfgBuilder, andminer_config.yaml.revalidate_deadlinegate increate_nonce_submission_tasks.Known limitation
find_best_qualityreturns only the single minimum per warp buffer. If a corrupt scoop and a genuine better scoop live in the same warp buffer, rejecting the corrupt one does not recover the genuine one (it was never surfaced). This PR fixes the cross-warp/cross-file overshadowing, which is the main harm; intra-warp masking would require re-scanning inside the hasher and is out of scope.Verification
cargo test -p pocx_hashlib— 53 passed (incl. newtest_scalar_quality_matches_simd,test_validate_deadline_detects_corruption).cargo test -p pocx_miner— 29 passed.cargo fmt --all --check— clean.cargo clippy -p pocx_hashlib -p pocx_miner --all-targets -- -D warnings— clean.