channels_sv2 hardening companion - #826
Draft
plebhash wants to merge 7 commits into
Draft
Conversation
plebhash
force-pushed
the
2026-09-02-channels-sv2-hardening
branch
from
September 2, 2026 19:19
e1522ca to
c6ddf6e
Compare
plebhash
force-pushed
the
2026-09-02-channels-sv2-hardening
branch
4 times, most recently
from
September 4, 2026 14:11
3a7567b to
4cb31a0
Compare
… code
channels_sv2 now refuses a zero max_target at the channel boundary:
StandardChannel/ExtendedChannel::new_for_pool return
OpenChannelInvalidMaxTarget and update_channel returns
UpdateChannelInvalidMaxTarget, both carrying the
max-target-out-of-range error code. Route them the way the
invalid-nominal-hashrate variants already are: OpenMiningChannel.Error
on open, UpdateChannel.Error on update. Without this the open path
disconnected the downstream on a well-formed but unattainable request,
and the update path hit its `unreachable!()` arm, so one
UpdateChannel { max_target: 0 } from any downstream took the pool down.
Companion of stratum-mining/stratum #2333.
Downstream (server channels): channels_sv2 now refuses a zero max_target with OpenChannelInvalidMaxTarget / UpdateChannelInvalidMaxTarget, carrying the max-target-out-of-range error code. Route them the way the invalid-nominal-hashrate variants already are, so the downstream gets OpenMiningChannel.Error / UpdateChannel.Error instead of a disconnect or a bare "internal-error". Upstream (client channel): ExtendedChannel::new and set_target are now fallible and return InvalidTarget for a zero target, since no share can meet one and its difficulty is not representable in share accounting. An upstream advertising such a target is a protocol-level error, so handle it like a malformed SetExtranoncePrefix: log and fall back. Companion of stratum-mining/stratum #2333.
channels_sv2's client ExtendedChannel::new and set_target are now fallible and return InvalidTarget for a zero target, since no share can meet one and its difficulty is not representable in share accounting. Every translator channel takes its target from the upstream (OpenExtendedMiningChannelSuccess.target on open, SetTarget afterwards), so an error there means the upstream sent something unattainable: log and fall back, with a new FailedToProcessSetTarget kind next to the existing FailedToProcess* ones for the SetTarget path. The aggregated downstream channels copy the aggregated channel's own, already validated target, so a failure there is an internal inconsistency and shuts down like the missing-allocator case beside it. Companion of stratum-mining/stratum #2333.
channels_sv2's client ExtendedJob is now a struct with named fields instead of a (message, extranonce_prefix, target) tuple. The aggregated-channel handling read the job message positionally; it reads job_message now. No behavior change. Companion of stratum-mining/stratum #2336.
…ling policy channels_sv2's GroupChannel constructors take version_rolling_allowed instead of hardcoding it, and ExtendedChannel::on_group_channel_job now refuses a group job that permits rolling on a channel whose policy forbids it. The pool opens every extended channel with rolling allowed, so the group channel is built with the same value. Companion of stratum-mining/stratum #2336.
…ion-rolling policy channels_sv2's GroupChannel constructors take version_rolling_allowed instead of hardcoding it, and ExtendedChannel::on_group_channel_job now refuses a group job that permits rolling on a channel whose policy forbids it. The JDC opens every downstream extended channel with rolling allowed, so the group channel is built with the same value. Companion of stratum-mining/stratum #2336.
plebhash
force-pushed
the
2026-09-02-channels-sv2-hardening
branch
from
September 6, 2026 22:31
4cb31a0 to
1dd6808
Compare
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.
companion stratum-mining/stratum#2336
draft due to e1522ca (avoids accidental merging)
but ready for review