Repository navigation
fix: payout rounding drift, Kaspa shared-template nonce race, and lost aux submissions - #14
Merged
Conversation
…t aux submissions BitcoinPayoutHandler (sendmany branch): the amount actually sent on-chain was rounded to payoutDecimalPlaces, but the balance debited afterwards and the Payment row recorded were the un-rounded amount. The sub-unit remainder was silently destroyed on every payout instead of staying in the miner's balance for a future cycle. Now debits and records exactly the rounded amount that was sent (via a new payoutBalances array built from the same rounded `amounts` dictionary used for the RPC call); the per-sendtoaddress fallback branch already did this correctly and is unchanged. KaspaJob.ProcessShareInternal: mutated the shared BlockTemplate.Header.Nonce in place, then read it back to serialize/hash. BlockTemplate is shared across every connection working this job, so two shares submitted concurrently (normal under real traffic) could interleave: one thread sets the nonce, another thread's SerializeHeader runs against that nonce before the first thread reads it back, so a share gets validated against the wrong nonce entirely. Now clones the header per call and works on the clone, never touching the shared BlockTemplate. AuxPowManager.SubmitAuxBlockAsync / BitcoinJobManager: a submitblock/ getauxblock transport failure or timeout was treated identically to a definite daemon rejection - the caller removed the dedup entry and recorded nothing, even though the daemon may have already accepted the block server-side before the connection dropped. That silently lost the aux block (and its reward) with no trace. Now distinguishes "outcome unknown" (via the existing PayoutErrorClassifier.IsOutcomeUnknown) from a definite rejection: on an unknown outcome, logs an error, sends an AdminNotification, keeps the dedup entry (never resubmits it) and skips the DB write - the admin is expected to verify the aux chain manually rather than the pool silently guessing either way. Build-verified: dotnet build (Release, SkipNativeLibBuild=true), 0 errors. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
ProcessShareInternalmutated the sharedBlockTemplate.Header.Noncein place then read it back - a real race under concurrent share submission (normal traffic) that could validate a share against the wrong nonce. Now works on a per-call clone of the header.Test plan
dotnet build(Release, SkipNativeLibBuild=true) — 0 errors, only pre-existing warnings🤖 Generated with Claude Code