-
Notifications
You must be signed in to change notification settings - Fork 217
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 prop_{create,extend}
in SelectionSpec
.
#2632
Conversation
Running `minimizeFee` a second time should not change the fee excess.
For any selection created by `create` or `extend`, we require that the fee excess cannot be minimized further. So we check the following condition: >>> feeExcess == feeExcessExpected If this condition is ever violated in a test, it's important to know what the actual value of `feeExcess` was. (The value of `feeExcessExpected` is calculated by attempting to minimize the fee excess a second time: this should have no effect, since `minimizeFee` is designed to be idempotent.)
These checks are not only unnecessary, they are incorrect. The original motivation for including them was to check that `create` and `extend` actually do minimize the fee (rather than leaving it unbalanced). But this can be adequately checked by verifying that the fee excess cannot be minimized further, i.e., that `minimizeFee` has no effect, which we already do. Furthermore, these checks are incorrect, as `balance` expects to be provided with outputs with ada quantities that are minimal.
The `balance` function expects to be given outputs whose ada quantities are minimal.
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.
👍
bors r+ |
2632: Fix `prop_{create,extend}` in `SelectionSpec`. r=jonathanknowles a=jonathanknowles # Issue Number #2630 / ADP-898 # Summary This PR fixes the following flaky tests: - `Migration.SelectionSpec.prop_create` - `Migration.SelectionSpec.prop_extend` These tests would both fail around 2% of the time, for the same underlying reason. # Testing This PR was tested by running the entire `SelectionSpec` **1000** times. No failures were observed. # Analysis Both `Selection.create` and `Selection.extend` are required to produce a balanced `Selection` where the fee (and fee excess) is minimized. Both of these functions rely on `minimizeFee`: this function is required to be **idempotent**, so that: > `∀ s. minimizeFee (minimizeFee xs) == minimizeFee s`. To check that `create` and `extend` produce selections with minimal fees, it's sufficient to verify that the selections they return have fees that _cannot be minimized further_. To do this, our pre-existing property tests _already_ call `minimizeFee` and verify that the result does not change: ```hs verify (feeExcess selection == feeExcessExpected) where (feeExcessExpected, _) = minimizeFee constraints (feeExcess selection, outputs selection) ``` However, in addition to this check, we were needlessly asserting that `balance` should be idempotent. The `balance` function is not actually designed for this: it's designed to always be called with outputs that are minimal in their ada quantities. # Changes This PR: - removes the unnecessary and invalid assertion for the idempotency of `balance`. - makes the pre-condition for `balance` explicit with a documentation comment. - adds an explicit idempotency test for `minimizeFee`. - improves error reporting in case of test failures, by displaying the actual fee excess. Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: For some reason the log file is unavailable: https://hydra.iohk.io/build/6225961/log/tail
Seems like |
bors r+ |
2632: Fix `prop_{create,extend}` in `SelectionSpec`. r=jonathanknowles a=jonathanknowles # Issue Number #2630 / ADP-898 # Summary This PR fixes the following flaky tests: - `Migration.SelectionSpec.prop_create` - `Migration.SelectionSpec.prop_extend` These tests would both fail around 2% of the time, for the same underlying reason. # Testing This PR was tested by running the entire `SelectionSpec` **1000** times. No failures were observed. # Analysis Both `Selection.create` and `Selection.extend` are required to produce a balanced `Selection` where the fee (and fee excess) is minimized. Both of these functions rely on `minimizeFee`: this function is required to be **idempotent**, so that: > `∀ s. minimizeFee (minimizeFee s) == minimizeFee s`. To check that `create` and `extend` produce selections with minimal fees, it's sufficient to verify that the selections they return have fees that _cannot be minimized further_. To do this, our pre-existing property tests _already_ call `minimizeFee` and verify that the result does not change: ```hs verify (feeExcess selection == feeExcessExpected) where (feeExcessExpected, _) = minimizeFee constraints (feeExcess selection, outputs selection) ``` However, in addition to this check, we were needlessly asserting that `balance` should be idempotent. The `balance` function is not actually designed for this: it's designed to always be called with outputs that are minimal in their ada quantities. # Changes This PR: - removes the unnecessary and invalid assertion for the idempotency of `balance`. - makes the pre-condition for `balance` explicit with a documentation comment. - adds an explicit idempotency test for `minimizeFee`. - improves error reporting in case of test failures, by displaying the actual fee excess. Co-authored-by: Jonathan Knowles <[email protected]>
Build failed:
|
bors r+ |
2632: Fix `prop_{create,extend}` in `SelectionSpec`. r=Anviking a=jonathanknowles # Issue Number #2630 / ADP-898 # Summary This PR fixes the following flaky tests: - `Migration.SelectionSpec.prop_create` - `Migration.SelectionSpec.prop_extend` These tests would both fail around 2% of the time, for the same underlying reason. # Testing This PR was tested by running the entire `SelectionSpec` **1000** times. No failures were observed. # Analysis Both `Selection.create` and `Selection.extend` are required to produce a balanced `Selection` where the fee (and fee excess) is minimized. Both of these functions rely on `minimizeFee`: this function is required to be **idempotent**, so that: > `∀ s. minimizeFee (minimizeFee s) == minimizeFee s`. To check that `create` and `extend` produce selections with minimal fees, it's sufficient to verify that the selections they return have fees that _cannot be minimized further_. To do this, our pre-existing property tests _already_ call `minimizeFee` and verify that the result does not change: ```hs verify (feeExcess selection == feeExcessExpected) where (feeExcessExpected, _) = minimizeFee constraints (feeExcess selection, outputs selection) ``` However, in addition to this check, we were needlessly asserting that `balance` should be idempotent. The `balance` function is not actually designed for this: it's designed to always be called with outputs that are minimal in their ada quantities. # Changes This PR: - removes the unnecessary and invalid assertion for the idempotency of `balance`. - makes the pre-condition for `balance` explicit with a documentation comment. - adds an explicit idempotency test for `minimizeFee`. - improves error reporting in case of test failures, by displaying the actual fee excess. Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Extract from log (https://hydra.iohk.io/build/6227922/nixlog/1/tail):
Looks like it could be related to: 2564 Re-tagging as |
bors r+ |
Build succeeded: |
Issue Number
#2630 / ADP-898
Summary
This PR fixes the following flaky tests:
Migration.SelectionSpec.prop_create
Migration.SelectionSpec.prop_extend
These tests would both fail around 2% of the time, for the same underlying reason.
Testing
This PR was tested by running the entire
SelectionSpec
1000 times. No failures were observed.Analysis
Both
Selection.create
andSelection.extend
are required to produce a balancedSelection
where the fee (and fee excess) is minimized.Both of these functions rely on
minimizeFee
: this function is required to be idempotent, so that:To check that
create
andextend
produce selections with minimal fees, it's sufficient to verify that the selections they return have fees that cannot be minimized further. To do this, our pre-existing property tests already callminimizeFee
and verify that the result does not change:However, in addition to this check, we were needlessly asserting that
balance
should be idempotent. Thebalance
function is not actually designed for this: it's designed to always be called with outputs that are minimal in their ada quantities.Changes
This PR:
balance
.balance
explicit with a documentation comment.minimizeFee
.