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

Enhance reporting of coin selections in the log. #2668

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented May 25, 2021

Issue Number

ADP-890

Overview

This PR enhances the reporting of successful coin selection attempts in the log.

It creates two types of reports:

  • A summarized report that includes just the most important data points associated with a selection. Each data point can be serialized to a single line of text.
  • A detailed report that includes all the inputs, outputs, and change outputs of a selection.

This makes it possible to turn on the reporting of summarized coin selection reports (which are short, and fixed-length) without turning on the reporting of detailed coin selection reports (which can be extremely lengthy).

Example output of a summarized report:

SelectionReportSummarized:
  computedFee: 2.143653
  totalAdaBalanceIn: 9700.225038
  totalAdaBalanceOut: 9698.081385
  adaBalanceOfSelectedInputs: 9700.225038
  adaBalanceOfExtraInput: 0.000000
  adaBalanceOfRequestedOutputs: 2164.303103
  adaBalanceOfGeneratedChangeOutputs: 7533.778282
  numberOfSelectedInputs: 47
  numberOfRequestedOutputs: 1
  numberOfGeneratedChangeOutputs: 4
  numberOfUniqueNonAdaAssetsInSelectedInputs: 719
  numberOfUniqueNonAdaAssetsInRequestedOutputs: 0
  numberOfUniqueNonAdaAssetsInGeneratedChangeOutputs: 719
  sizeOfRemainingUtxoSet: 0

The primary use of this instance is to provide information in the log
that's useful for debugging coin selections.

However, the existing instance doesn't provide much of a summary, which
makes it hard at a glance to understand the important properties of a
selection.

This change enhances the `Buildable` instance, giving the output a
fixed-length prefix that has several data points useful for debugging.

Example output:

```
computed fee: 0.999345
total ada balance in: 2322.500607
total ada balance out: 2321.501262
ada balance of selected inputs: 2322.500607
ada balance of extra input: 0.000000
ada balance of requested outputs: 2164.303103
ada balance of generated change outputs: 157.198159
number of selected inputs: 13
number of requested outputs: 1
number of generated change outputs: 2
number of unique non-ada assets in selected inputs: 323
number of unique non-ada assets in requested outputs: 0
number of unique non-ada assets in generated change outputs: 323
size of remaining utxo: 34
```
This allows the multi-line output of a serialized selection result to
start on a separate line.
@jonathanknowles jonathanknowles self-assigned this May 25, 2021
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@rvl
Copy link
Contributor

rvl commented May 26, 2021

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 26, 2021

Canceled.

@jonathanknowles jonathanknowles changed the title Enhance Buildable instance for SelectionResult. Enhance reporting of coin selections in the log. May 26, 2021
The `Fmt.genericF` function provides neatly-formatted output for record types,
where each record field is rendered as `name: value` pair on a separate line.
…eports.

This makes it possible to turn on the reporting of summarized coin
selection reports (which are short, and fixed-length) without turning on
the reporting of detailed coin selection reports (which can be extremely
long).
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/enhance-buildable-instance-for-selection-result branch from b669f0c to 61acff3 Compare May 26, 2021 06:00
(view #txOutputMinimumAdaQuantity $ constraints tl pp)
(calcMinimumCost tl pp tx)
(tokenBundleSizeAssessor tl)
(selectionCriteria)
liftIO $ traceWith tr $ MsgSelectionDone sel
case mSel of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to just trace Either e SelectionResult and perform the reporting at the time of log formatting, and/or do further tracer transforms. That way, your functions aren't cluttered up with logging code.

@jonathanknowles
Copy link
Member Author

bors r+

@jonathanknowles
Copy link
Member Author

bors cancel

@jonathanknowles
Copy link
Member Author

(Will try to merge this again after the release is done.)

@jonathanknowles
Copy link
Member Author

bors cancel

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 26, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 93daf60 into master May 26, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/enhance-buildable-instance-for-selection-result branch May 26, 2021 11:44
@rvl
Copy link
Contributor

rvl commented May 27, 2021

I think the command is bors r-, but never mind - good to have this in the release.
Thanks for improving the logging.

@jonathanknowles
Copy link
Member Author

I think the command is bors r-

Weird! I checked the bors reference, and it claims that these are equivalent:

Syntax Description
bors cancel Equivalent to bors r-

I guess it's a bug in the reference guide, or the command no longer exists (if it once did).

Thanks for improving the logging.

Sure! 👍🏻

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.

None yet

2 participants