Skip to content
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

Add more conditions to CoinSelection.verifySelection function. #2972

Merged
merged 12 commits into from
Oct 13, 2021

Conversation

jonathanknowles
Copy link
Contributor

@jonathanknowles jonathanknowles commented Oct 13, 2021

Issue Number

ADP-1037

Summary

This PR adds further conditions to the pre-existing CoinSelection.verifySelection function.

We now verify that every selection output (regardless of whether it is an ordinary output or a generated change output):

  • does not have an ada quantity below the minimum set by the protocol.
  • does not have a serialized size that exceeds the limit set by the protocol.
  • does not have any token quantities that exceed the limit set by the protocol.

This PR also adjusts verifySelection to report all errors it encounters, rather than just the first error.

Example Failure

The following example shows multiple verification failures:

multiple-verification-failures

@jonathanknowles jonathanknowles changed the title Add more checks to CoinSelection.verifySelection function. Add more conditions to CoinSelection.verifySelection function. Oct 13, 2021
@jonathanknowles jonathanknowles self-assigned this Oct 13, 2021
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-5 branch from a8d1fd1 to fa73b01 Compare October 13, 2021 05:36
The `selectionHasValidSurplus` function will mark a selection as invalid
if it has a surplus that is greater than the maximum cost, as defined by
the by `selectionMaximumCost` function.

Therefore, we should include this maximum cost in the error report.
@jonathanknowles
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 13, 2021
2972: Add more conditions to `CoinSelection.verifySelection` function. r=jonathanknowles a=jonathanknowles

## Issue Number

ADP-1037

## Summary

This PR adds further conditions to the pre-existing `CoinSelection.verifySelection` function.

We now verify that every selection output (regardless of whether it is an ordinary output or a generated change output):

- does not have an ada quantity below the minimum set by the protocol.
- does not have a serialized size that exceeds the limit set by the protocol.
- does not have any token quantities that exceed the limit set by the protocol.

This PR also adjusts `verifySelection` to report **_all_** errors it encounters, rather than just the first error.

## Example Failure

The following example shows multiple verification failures:

![multiple-verification-failures](https://user-images.githubusercontent.com/206319/137082445-9a81a86e-d924-4fcc-96c4-7c67137be01a.png)




Co-authored-by: Jonathan Knowles <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 13, 2021

Build failed:

Saw this very strange error in the log:

Installing library in /nix/store/94fsjywg2ih0vka65fmxynr6yg3yvxld-cardano-wallet-core-lib-cardano-wallet-core-x86_64-unknown-linux-musl-2021.9.29/lib/x86_64-linux-ghc-8.10.5/cardano-wallet-core-2021.9.29-B80KJB5wujMGnj3Lx0fzf
post-installation fixup
patching script interpreter paths in /nix/store/94fsjywg2ih0vka65fmxynr6yg3yvxld-cardano-wallet-core-lib-cardano-wallet-core-x86_64-unknown-linux-musl-2021.9.29
checking for references to /build/ in /nix/store/94fsjywg2ih0vka65fmxynr6yg3yvxld-cardano-wallet-core-lib-cardano-wallet-core-x86_64-unknown-linux-musl-2021.9.29...
patchelf: wrong ELF type

I'll see if it's a sporadic error by re-running the failed jobs.

EDIT: I re-ran the failed jobs and they all passed. I'll initiate another merge attempt.

@jonathanknowles
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 13, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 27479e4 into master Oct 13, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/adp-1037/test-coin-selection-5 branch October 13, 2021 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants