Skip to content

Maximum rounding error exceeded #425

@jholdstock

Description

@jholdstock

User @sebitt27 reported the following error from their pool https://decred.miningandco.com/

2023-10-29 09:56:03.440 [ERR] POOL: unable to process payments: generatePayoutTxDetails: difference between total output values and the provided inputs (0.00000569 DCR) exceeds the maximum allowed for rounding errors (0.000005 DCR)

They mentioned the pool has >=500 clients. I have identified the following as a potential cause of the issue:

dcrpool/pool/paymentmgr.go

Lines 276 to 280 in 794bb7b

// Reduce the amount by an atom if float conversion accuracy was
// above the actual value.
if accuracy > 0 {
amt -= dcrutil.Amount(1)
}

When calculating reward payments, any rounding errors are always resolved by reducing the payment by one atom. Hundreds of clients can cause this -1 to be triggered hundreds of times, leading too a huge rounding error which exceeds the hard-coded maximum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions