Skip to content

Avoid duplicate PoW validation for mined candidates - #2411

Open
a-shannon wants to merge 9 commits into
ergoplatform:masterfrom
a-shannon:fix/pow-validation-dedup
Open

a-shannon wants to merge 9 commits into
ergoplatform:masterfrom
a-shannon:fix/pow-validation-dedup

Conversation

@a-shannon

@a-shannon a-shannon commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Closes #2346.

Each submitted solution validates each attempted mining candidate once and reuses that result. If the current solution is invalid and no previous candidate exists, the generator now returns a normal error with the PoW failure reason and cause, preserving the current candidate for later valid work. It no longer restarts on cachedPreviousCandidate.get.

A previous candidate is validated before block publication. If both candidates reject, the existing cache-clearing behavior is preserved. The previous-candidate log is emitted only when that candidate exists.

Review increments

Integration

This PR targets master; #2429 targets v6.0.7. Both now handle an absent previous candidate. Preserve that protection and this PR's single-validation behavior when integrating the overlapping changes.

The cumulative diff still includes shared H/D/R support from #2535, G synchronization changes from #2511, and X cache wake-up from #2549. Integrate R before G and the relevant shared increments before the PoW change. The entire #2535 branch is not a prerequisite of #2511. See the tracker for integration order.

GitHub currently reports conflicts with master. This focused update does not rebase the shared changes.

Validation

At 36cff18ca, local Scala 2.12.20 / JDK 17 validation covers 47 distinct tests: 37 candidate-generation/property cases and 10 mining API cases. After strengthening cause and announcement assertions, the four affected actor cases were rerun and passed; unchanged coverage was reused.

The new first-solution regression fails on 1fa1076e9 with None.get and an absent normal reply. It now verifies the error cause, retained cached-object identity, no block publication on rejection, and successful subsequent submission. The fallback cases check both valid and invalid previous solutions, publication behavior, and one validation per attempted header.

Independent source review of the exact production and test increment found no remaining blockers. No current-head CI run is available yet; the preceding head's eight green checks do not validate this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double PoW validation elimination when miner submits a solution for previous block candidate

1 participant