Repository navigation
Conversation
Channels cleared seen_shares on every prev_hash change. When the tip went A to B and back to A with the same coinbase and merkle root, a proof accepted under A was not seen any more and was credited again under the returning job ID. Client channels now keep seen_shares across tip changes. The queue is already capped at MAX_SEEN_SHARES and evicts oldest-first, so clearing it was never needed to bound memory. flush_seen_shares is removed. Server channels cannot do the same, since their set is a hard budget sized for one prev_hash. ShareAccounting::on_prev_hash_change replaces flush_seen_shares: it keeps the set of the prev_hash being left, tagged with that prev_hash, and makes it current again if the next change returns to it. Keeping that set without the tag is not enough: on the way back to A it would be replaced by B's set and A's hashes would be dropped anyway. The budget still applies to the current set, so a server channel holds at most twice its budget. A revisit across more than one tip (A to B to C to A) is not covered. stratum-mining#2396
channels_sv2 breaks its API, so it takes a major bump. stratum_translation exposes channels_sv2::bip141::StripBip141Error in StratumTranslationError, and stratum-core re-exports both, so taking channels_sv2 10 breaks them too.
Jolah1
force-pushed
the
fix-seen-shares-tip-revisit
branch
from
November 13, 2026 04:02
9094ea2 to
b0fbd38
Compare
Contributor
Author
|
Rebased on main, conflicts are gone. Main now sets the server tip through update_chain_tip, so on_prev_hash_change is called from there, which also covers activate_future_job. The two server tests now check that A's hash |
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.
close #2396
close https://github.com/project-loupe/audit-stratum/issues/251
close https://github.com/project-loupe/audit-stratum/issues/267
close https://github.com/project-loupe/audit-stratum/issues/244
Channels cleared
seen_shareson everyprev_hashchange, so after A→B→A a proof accepted under A could be counted again under the returning job.Client channels now keep
seen_sharesacross tip changes. The queue is already capped atMAX_SEEN_SHARESwith oldest-first eviction, so memory stays bounded.flush_seen_sharesis removed.Server channels can't do that, since the set is a hard budget sized for one
prev_hash.ShareAccounting::on_prev_hash_change(prev_hash, new_prev_hash)replacesflush_seen_shares. It keeps the set of the tip being left, tagged with itsprev_hash, and makes it current again if the next change returns to it. Both server channels call it fromupdate_chain_tip, so it coverson_set_new_prev_hashandactivate_future_job. The extended channel also calls it fromon_set_custom_mining_job, which flushed too but wasn't listed in the issue.This differs from the server fix suggested in the issue. Keeping the previous set and checking both doesn't cover A→B→A: on B→A the kept set becomes B's and A's is dropped anyway. I tried it against the new tests and all three
server A→B→A cases still fail. Only the current set is checked, since header hashes commit to
prev_hashand stale-job shares are rejected before the duplicate check.Tests:
test_repeated_prev_hash_keeps_seen_sharesin client extended, server extended and server standard now also goes A→B→A: the share under B goes through, and the original proof under the returning job isDuplicateShare. The two server tests also check that A's hash is not in the set while the tip is on B, and is back on the return.test_custom_job_returning_to_previous_prev_hash_keeps_seen_shares: the same round trip throughon_set_custom_mining_job.seen_shares_are_kept_for_the_previous_prev_hash: unit test for the swap, an unchangedprev_hash, and A→B→C→A where the older set is gone.All the A→B→A tests fail with the old flush.
Side effects:
flush_seen_sharesis gone on both sides, so this is breaking. channels_sv2 goes 9.0.0 -> 10.0.0, and stratum_translation and stratum-core, which expose it, go to 0.7.0 and 0.8.0. sv2-apps doesn't call it and its main builds against this branch, so no companion PR.