-
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
Re-write balanceTransaction using Node.evaluateTransactionBalance #3100
Conversation
97084f0
to
80fa40c
Compare
9ca963a
to
f8ba97c
Compare
bors try |
tryBuild failed: |
bafe8cd
to
416c120
Compare
bors try |
tryBuild succeeded: |
ca83c55
to
0c470e1
Compare
0c470e1
to
6f9a10c
Compare
3150: Prepare for rewriting balanceTransaction r=Anviking a=Anviking - [x] Add `evaluateTransactionBalance` to `TransactionLayer` - [x] Add `guardTxBalanced` to `balanceTransaction` - Tested indirectly by the fact that `guardTxBalanced` doesn't fail in our existing integration and unit tests. - [x] Add golden tests for `balanceTransaction` to ensure there are no regressions in #3100 ### Comments Preparation for #3100 ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> ADP-1372 Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
403fba6
to
ae8a220
Compare
bors try |
If `SelectionStrategyOptimal` results in the tx max size being exceeded, try again with `SelectionStrategyMinimal`.
- Wrap very long lines. - Use 4 character indents. https://input-output-hk.github.io/adrestia/code/Coding-Standards#limit-line-length-to-80-characters
- Rename the property to make it clear that it checks more things than just whether the result is balanced. - make the feeExcess expectation better motivated. - polish a few other old comments
- Use 4-space indents everywhere. - Avoid vertical alignment. - Ensure that case expressions and pattern guards are indented one level to the left of their handlers.
These were introduced in a prior PR, but we might as well clean them up while we're adjusting this function. https://input-output-hk.github.io/adrestia/code/Coding-Standards#limit-line-length-to-80-characters
1138a59
to
df3c9ba
Compare
-- 'assignScriptRedeemers'. This should make the problem (1) unlikely, | ||
-- but not necessarily impossible. | ||
-- | ||
-- We should investigate and make sure to handle this better. |
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.
👍🏻
lib/core/src/Cardano/Wallet.hs
Outdated
transform | ||
|
||
lift $ traceWith tr $ MsgSelectionForBalancingStart | ||
(CS.toExternalUTxOMap $ UTxOIndex.toMap internalUtxoAvailable) |
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.
I suspect this conversion can be avoided if we don't require ourselves to include a UTxO
value in the MsgSelectionForBalancingStart
value, since we only ever care about the size, which is the same before and after applying toExternalUTxOMap
.
I'll push a commit that removes this conversion.
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.
Fixed in 80f346c.
When recording details about the UTxO set in the log, we generally only care about the size of the UTxO set, rather than its composition. Therefore, we don't need to require ourselves to produce a value of type `UTxO` in order to create a log entry: we just need to obtain the size of the available UTxO set. Therefore, we can avoid converting from the coin selection's internal map of UTxO entries to values of the wallet's `UTxO` type, which requires traversing the entire UTxO set and converting every single entry. We can't avoid traversing the wallet's UTxO set at least once, in order to make a value of type `UTxOIndex`, but we can avoid doing it multiple times.
…lue`. This allows us to replace the pattern guard and the unsafe conversion with a single checked conversion.
60fcb27
to
0b57295
Compare
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.
This looks reasonable to me. I see that you've highlighted all areas for further work with TODO
comments and links to tickets, which is great.
Thanks for making this PR!
👍🏻
bors r+ |
Build succeeded: |
evaluateTransactionBalance
prop_balanceTransactionBalanced
Future work
Comments
First part introducing goldens and the evaluateTransactionBalance function: #3150
Issue Number
ADP-1372