Skip to content

Conversation

@rajarshimaitra
Copy link
Contributor

@rajarshimaitra rajarshimaitra commented Sep 10, 2021

As per the review club discussion on #22009 , it was observed that there were other two fee scenarios in which selection waste could be zero.

These are:

  • (LTF - Fee) == Change Cost
  • (LTF - Fee) == Excess

Even though these are obvious by the definition of waste metric, adding tests for them can be helpful in explaining its behavior
to new readers of the code base, along with pinning the behavior for future.

This PR adds those two cases to waste calculation unit test.

Also let me know if I am missing more scenarios.

@theStack
Copy link
Contributor

Concept ACK

@murchandamus
Copy link
Contributor

Concept ACK

These are:

* (Fee - LTF) == Change Cost

* (Fee - LTF) == Excess

Strictly speaking it should be:

  • (Fee - LTF) + Change Cost = 0
    ⇒ (Fee - LTF) == -1×Change Cost

  • (Fee - LTF) + Excess = 0
    ⇒ (Fee - LTF) == -1×Excess

@achow101
Copy link
Member

ACK c976ee0a0ca00fe8a7de5c806560da35c2f48729

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Left a nit on the comment explaining the test

@rajarshimaitra
Copy link
Contributor Author

Thanks @xekyo for the review and agreed. It should be reversed.

Updated everywhere..

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK 0ce33016eb905f5ac3709ed95ae02db0f97885a2

Perhaps update the commit message and pull description with @xekyo's calculations in #22938 (comment). Edit: never mind, it seems fine now IIUC.

@murchandamus
Copy link
Contributor

ACK 0ce33016eb905f5ac3709ed95ae02db0f97885a2

@rajarshimaitra
Copy link
Contributor Author

Thanks @jonatack for the review. Those were good suggestions.

Updated the comment description.
Updated commit message.
Updated with braced initialization.

@murchandamus
Copy link
Contributor

Re-ack a2a9c23

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Code review re-ACK a2a9c23e261ad88c0133b407c6e1b4c54f90a860 per git diff 0ce3301 a2a9c23

Sub-atomic consistency nits, but definitely ignore unless you have to rebase or something (and maybe even then).

There are two more cases where waste can be 0, when:
 - (Fee - LTF) == -Change Cost
 - (Fee - LTF) == -Excess

Adding these two conditions explicitly in the unit test will help
pin the behavior, also demonstrate waste calculation scenarios to new
readers.
@rajarshimaitra
Copy link
Contributor Author

rajarshimaitra commented Sep 24, 2021

@jonatack Sorry for my silly overlooks.. Updated now only..

@jonatack
Copy link
Member

Tested re-ACK efcaefc

@achow101
Copy link
Member

ACK efcaefc

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

ACK efcaefc

@meshcollider meshcollider merged commit a8bbd4c into bitcoin:master Sep 28, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants