Closed scottschurr closed 2 weeks ago
Attention: Patch coverage is 97.14286%
with 1 line
in your changes missing coverage. Please review.
Project coverage is 71.3%. Comparing base (
263e984
) to head (e5dbc1d
).
Proposed commit message:
fixReducedOffersV2: prevent offers from blocking order books:
Fixes issue #4937.
The fixReducedOffersV1 amendment fixed certain forms of offer
modification that could lead to blocked order books. Reduced
offers can block order books if the effective quality of the
reduced offer is worse than the quality of the original offer
(from the perspective of the taker). It turns out that, for
small values, the quality of the reduced offer can be
significantly affected by the rounding mode used during
scaling computations.
Issue #4937 identified an additional code path that modified
offers in a way that could lead to blocked order books. This
commit changes the rounding in that newly located code path so
the quality of the modified offer is never worse than the
quality of the offer as it was originally placed.
It is possible that additional ways of producing blocking
offers will come to light. Therefore there may be a future
need for a V3 amendment.
High Level Overview of Change
In issue https://github.com/XRPLF/rippled/issues/4937 @shortthefomo reported additional instances of order book blocking since the
fixReducedOffersV1
amendment went live. Thanks to that report I was able to identify an additional case where blocking offers could be generated. This pull request fixes the newly identified case.Context of Change
Having order books occasionally blocked by offers that were modified so that their quality was worse than the originally placed quality has been a problem for a while. Three different ways that this could occur were identified and addressed by amendment
fixReducedOffersV1
. All three of those case were addressed by carefully looking at and fixing the numeric rounding applied during calculations.This new amendment,
fixReducedOffersV2
, identifies and fixes an additional rounding case that was missed during the research forfixReducedOffersV1
.Beyond the fix itself, there are two kinds of unit test additions in this pull request.
There's a new test that directly exercises the failing case both with and without the amendment. It demonstrates that the old rounding behavior could lead to blocked order books. It also shows that with the new rounding behavior the order books are no longer blocked for this range of cases.
A few pre-existing test cases failed due to the changed rounding. Those test cases were examined and the tests patched to handle the new rounding behavior.
Type of Change
API Impact
None.