-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gateway_balances): handle overflow exception #4355
Conversation
|
@intelliot FYI: This is an important one, some issuers reported to Xumm support that explorers, Xumm, everything suddenly doesn't report their incoming TrustLines and obligations anymore. This fix addresses that bug that now lives on all nodes. |
After some thought: a better long term solution is to use an arbitrary precision (or much larger precision) floating point library (boost/multiprecision/cpp_dec_float ?) for these summing totals. But for now this is a suitable patch that can easily go into the next build |
Is there risk that an API consumer will overlook the |
The sum is not being returned at all. I'm approving this because bogus data is not being returned and it fixes the problem users are having. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
The API docs will need to be updated to reflect this (@mDuo13 ?).
Yes but that’s a gotcha with delivered amount also. Needs proper documentation to make sure implementations check for the overflow key. It’s probably better to continue returning a k-v pair for the currency in question otherwise at point of overflow the client would stop even displaying their currency at all and just say error. Which is already what the behaviour was. |
@RichardAH |
Probably the most sensible value to place there is MAX_FLOAT. Or actually compute the value properly with an arbitrary precision floating point library and return this? |
I did a little exploring of this pull request. I've never looked in Given the fix, it looks like we believe that adding a positive non-XRP If I got that right, then I think there are some things worth thinking through.
If the above steps make sense, then a possible fix might look like this:
While I was working on this I wrote a unit test so I could validate some of these assumptions. The top-most commit on this branch includes the proposed fix as well as the unit test: https://github.com/scottschurr/rippled/commits/RichardAH-gateway_balances_overflow You're welcome to cherrypick that commit if you want to. |
Flagging @godexsoft since this change may impact the behavior of clio. |
@WietseWind @RichardAH please review the comment from Scott S above, at your convenience. |
Thanks for this, I've cherry-picked it. LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. We have added similar code in clio too.
High Level Overview of Change
There's a bug in the sum totalling routine for
gateway_balances
. It's quite possible to overflow the sum total and cause an rpc internal error to be returned (exception caught high up).Of the possible ways to deal with this I decided to stop summing at the point of overflow, return the last good sum and signal to the end user that an overflow occurred with a new JSON field. Possibly there is a better way to do it but this seemed to be the most backwards compatible to me.36ffe0c removed the "overflow" field. Instead, the server returns the maximum possibleSTAmount
.Example account:
On a stock node:
On a node running
this PR0d0464f:Context of Change
Type of Change