Skip to content

defer channels_sv2::client share acceptance to upstream acknowledgement#2090

Merged
GitGab19 merged 3 commits into
stratum-mining:mainfrom
plebhash:2026-02-18-fix-client-share-accounting-update
Feb 19, 2026
Merged

defer channels_sv2::client share acceptance to upstream acknowledgement#2090
GitGab19 merged 3 commits into
stratum-mining:mainfrom
plebhash:2026-02-18-fix-client-share-accounting-update

Conversation

@plebhash
Copy link
Copy Markdown
Member

@plebhash plebhash commented Feb 18, 2026

close #2089

breaking change on channels_sv2, bumps major version

we replace channels_sv2::client::ShareAccounting::update_share_accounting with:

  • track_validated_share (still called from validate_share)
  • on_share_acknowledgement (called from the on_share_acknowledgement introduced into the channels layer)

application layer calls on_share_acknowledgement on channels every time a SubmitSharesSuccess arrives

companion stratum-mining/sv2-apps#283

@plebhash plebhash force-pushed the 2026-02-18-fix-client-share-accounting-update branch from b3dc8e9 to 89e5841 Compare February 18, 2026 20:05
Copy link
Copy Markdown
Member

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest of the changes look good

pub fn on_share_acknowledgement(
&mut self,
new_submits_accepted_count: u32,
new_shares_sum: f64,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can make new_share_sum a u64, based on the comments in the sv2-apps PR: stratum-mining/sv2-apps#283 (comment) . There’s no real need to keep it as an f64, it looks like an inaccuracy that slipped through during the initial iteration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the new_shares_sum represent the amount of work acknowledged by the server in a specific SubmitSharesSuccess, that's why it's a f64.

But I might be wrong here.

Copy link
Copy Markdown
Member Author

@plebhash plebhash Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember seeing work being reported as floating point on Braiins UI, and also contemplating the fact that strictly speaking, work is a unit of difficulty, and therefore it can (and maybe should) be tracked as floating point numbers (like rust bitcoin does)

this is specially true when we're operating at diff ranges 0 < diff < 1, where we have no relevant data unless we're working with floating point numbers

but as @Shourya742 correctly points out, this was kind of a failed attempt at retaining granular data, because SubmitSharesSuccess.new_shares_sum is U64, which forces everyone to truncate and makes an internal representation based on f64 pretty much useless

FWIW there's some extra context on stratum-mining/sv2-spec#126


with that said, I'd like to avoid expanding the scope of this PR to also cover for this, because that's not the problem #2089 we're trying to solve

created #2092 to keep track of it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acc to spec, its the sum of share acknowledged in the batch,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not aware of that PR. Thanks for mentioning that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acc to spec, its the sum of share acknowledged in the batch,

no, you're confusing it with new_submits_accepted_count

please see stratum-mining/sv2-spec#126, I drafted this while interacting with Braiins

Copy link
Copy Markdown
Member

@GitGab19 GitGab19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, just a minor thing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to bump PATCH here to publish it on our next release

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Green from me, once Gitgab's comments are addressed.

@GitGab19 GitGab19 merged commit dda2a47 into stratum-mining:main Feb 19, 2026
14 checks passed
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.

ShareAccounting in channels_sv2 has to be refined wrt shares acceptance management

3 participants