Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

Review Fee Calculation (Backport from Cardano-SL) #70

Merged
merged 3 commits into from
Nov 26, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Nov 21, 2018

Linked Issue

input-output-hk/cardano-sl/pull/3861

Acceptance criteria:

¯\_(ツ)_/¯

Comments

This is just a backport of the fix done in cardano-sl/develop and cardano-sl/release-2.0.0 until we get this submodules setup correctly done....

Checklist

  • I've kept this PR simple, on-the-spot, free of cosmetic changes.
  • I have reviewed my commit messages and history.
  • I've assigned a reviewer.
  • I acknowledge my changes may require an update in the wiki.
  • I have added a reference to this PR to the corresponding issue.

  • I've checked the checklist

So, basically, by conflating a bit the selected entries and changes, a
lot of things become easier.  At the price of one thing: fairness.

The previous code was splitting fee across change proportionally to
inputs.  So here, I just split the fee across all changes, regardless of
the input. So everyone's got to pay the same part of for the
transaction.

One could see it as another type of fairness 🙃 ...  But
that's also a lot simpler to handle, because we can just manipulate all
inputs and all changes directly and compute fee for those directly.
Copy link
Contributor

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

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

Unsafe usage of error should be removed and replaced with the error mechanism in the CoinSelT stack.


let neInps = case inps' of
[] -> error "adjustForFees: empty list of inputs"
i:is -> i :| is
Copy link
Contributor

Choose a reason for hiding this comment

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

CoinSelT has an error branch. We should be using that instead of error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that here, those aren't error case we want to handle but actual invariant violation.
The kerbel uses this error "pattern" in multiple places to put light on invariant. This is not something we want to shove in our error type.


let neOuts = case outs' of
[] -> error "adjustForFees: empty list of outputs"
o:os -> o :| os
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

src/Cardano/Wallet/Kernel/CoinSelection/Generic/Fees.hs Outdated Show resolved Hide resolved
@KtorZ KtorZ dismissed parsonsmatt’s stale review November 26, 2018 10:54

dismissing remaining review comments: not sure if you're in Regensburg training or not? Plus. this is really just a backport from cardano-sl so I'd rather have no conceptual changes done within this PR; but rather in a second one as a follow-up.

@KtorZ KtorZ merged commit a94388a into develop Nov 26, 2018
@KtorZ KtorZ deleted the KtorZ/RCD-44-45/review-fee-calculation-backport branch November 26, 2018 10:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants