Skip to content

represent share work as u64 (where appropriate)#2138

Merged
plebhash merged 1 commit into
stratum-mining:mainfrom
plebhash:2026-04-22-share-work-u64
May 18, 2026
Merged

represent share work as u64 (where appropriate)#2138
plebhash merged 1 commit into
stratum-mining:mainfrom
plebhash:2026-04-22-share-work-u64

Conversation

@plebhash

@plebhash plebhash commented Apr 22, 2026

Copy link
Copy Markdown
Member

close #2092

companion stratum-mining/sv2-apps#449


client side

work acknowledged by upstream arrives over the wire as u64 (SubmitSharesSuccess.new_shares_sum), but for auditability we now track two values:

  • acknowledged_work_sum (u64): what upstream acknowledged over SV2 messages
  • validated_work_sum (f64): what the client validated locally (tracked by job difficulty)

this keeps wire accounting aligned with protocol types, while still allowing client to detect mismatches between what it validated vs what server acknowledged

server side

if we truncated every share's work into u64 before storing it in memory, repeated truncation would cause accumulated accounting drift over time

so on the server side, truncation stays limited to get_last_batch_work_sum (used for crafting SubmitSharesSuccess), while in-memory work accounting remains f64

@plebhash

Copy link
Copy Markdown
Member Author

reverting back to draft, see: #2092 (comment)

@plebhash
plebhash force-pushed the 2026-04-22-share-work-u64 branch from 767d510 to 3a7c287 Compare May 15, 2026 22:24
@plebhash
plebhash marked this pull request as ready for review May 15, 2026 23:57
@plebhash
plebhash requested a review from GitGab19 May 15, 2026 23:57
@plebhash

Copy link
Copy Markdown
Member Author

reverting back to draft, see: #2092 (comment)

adapted to the new direction

now client side keeps track of acknowledged_work_sum: u64 vs validated_work_sum: f64

server side only truncates on get_last_batch_work_sum for the creation of SubmitSharesSuccess message

@GitGab19 GitGab19 left a comment

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.

LGTM

@plebhash
plebhash merged commit d283cb9 into stratum-mining:main May 18, 2026
18 of 20 checks passed
@plebhash
plebhash deleted the 2026-04-22-share-work-u64 branch May 18, 2026 12:19
plebhash added a commit that referenced this pull request May 19, 2026
Adaptation commit (not a direct cherry-pick).

Bumps channels_sv2 4.0.0 -> 4.0.1, mining_sv2 8.0.0 -> 8.0.1, and stratum-core 0.2.1 -> 0.2.2 so release/v1.8.1 changes can be published to crates.io.

Related backport sources: 3a7c287 (#2138), ebc7386 (#2139), 5e1b025 (#2149), 3da394f (#2152).
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.

need to switch ShareAccounting work representation from f64 to u64 on channels_sv2

2 participants