-
Notifications
You must be signed in to change notification settings - Fork 213
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
Fix remaining fee calculation #1578
Conversation
currently fails as expected with: ``` Generated an unbalanced tx! Too much left for fees : fee (raw) = 164282 : fee (dangling) = 167722 , diff = 200000 selection = inputs: - 1st 30 (~ 1000000 @ 66616b65...72657373) outputs: - 800000 @ 66616b65...72657373 change: [] CallStack (from HasCallStack): error, called at src/Cardano/Wallet/Primitive/Fee.hs:330:18 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee remainingFee, called at src/Cardano/Wallet/Primitive/Fee.hs:207:22 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee ```
The former actually makes assumption based on the output of the later. Testing these function in isolation makes little sense. Grouping them into one function makes it easier to understand the surrounding context and what is happening. Further refactoring is needed in order to now fix the issue with dangling fee
They should actually have the same semantic within this context.
bors try |
tryBuild failed |
-- The new requested fee after adding the output. | ||
δ_dangling = φ_original -- by construction of the change output | ||
|
||
extraChng = Coin (δ_original - φ_original) |
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.
👍
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.
looks fine
bors r+ |
1578: Fix remaining fee calculation r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1561 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 938a3a0 📍 **add regression test triggering the unbalanced invariant** currently fails as expected with: ``` Generated an unbalanced tx! Too much left for fees : fee (raw) = 164282 : fee (dangling) = 167722 , diff = 200000 selection = inputs: - 1st 30 (~ 1000000 @ 66616b65...72657373) outputs: - 800000 @ 66616b65...72657373 change: [] CallStack (from HasCallStack): error, called at src/Cardano/Wallet/Primitive/Fee.hs:330:18 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee remainingFee, called at src/Cardano/Wallet/Primitive/Fee.hs:207:22 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee ``` - 1041fac 📍 **refactor: merge 'remainingFee' and 'rebalanceChangeOutput'** The former actually makes assumption based on the output of the later. Testing these function in isolation makes little sense. Grouping them into one function makes it easier to understand the surrounding context and what is happening. Further refactoring is needed in order to now fix the issue with dangling fee - 1758a30 📍 **use dustThreshold instead of 'Coin 0'** They should actually have the same semantic within this context. - 7194126 📍 **fix remaining fee calculation** - a17462c 📍 **fix unit test now correctly divying fee across change outputs** - 1534124 📍 **property test fee balancing** And allow transaction to be unbalanced if the node allows it # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
And allow transaction to be unbalanced if the node allows it
1534124
to
5c88126
Compare
Canceled |
bors r+ |
1578: Fix remaining fee calculation r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1561 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 938a3a0 📍 **add regression test triggering the unbalanced invariant** currently fails as expected with: ``` Generated an unbalanced tx! Too much left for fees : fee (raw) = 164282 : fee (dangling) = 167722 , diff = 200000 selection = inputs: - 1st 30 (~ 1000000 @ 66616b65...72657373) outputs: - 800000 @ 66616b65...72657373 change: [] CallStack (from HasCallStack): error, called at src/Cardano/Wallet/Primitive/Fee.hs:330:18 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee remainingFee, called at src/Cardano/Wallet/Primitive/Fee.hs:207:22 in cardano-wallet-core-2020.4.7-Be8Kf2A2Kpl7z2pVyjHPdZ:Cardano.Wallet.Primitive.Fee ``` - 1041fac 📍 **refactor: merge 'remainingFee' and 'rebalanceChangeOutput'** The former actually makes assumption based on the output of the later. Testing these function in isolation makes little sense. Grouping them into one function makes it easier to understand the surrounding context and what is happening. Further refactoring is needed in order to now fix the issue with dangling fee - 1758a30 📍 **use dustThreshold instead of 'Coin 0'** They should actually have the same semantic within this context. - 7194126 📍 **fix remaining fee calculation** - a17462c 📍 **fix unit test now correctly divying fee across change outputs** - 1534124 📍 **property test fee balancing** And allow transaction to be unbalanced if the node allows it # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@@ -161,7 +167,7 @@ spec = do | |||
}) (Right $ FeeOutput | |||
{ csInps = [20,20,20] | |||
, csOuts = [14,18,19] | |||
, csChngs = [6] | |||
, csChngs = [4,1,1] |
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.
NOTE: To be fixed.
Rework Fee Balancing (see also cardano-foundation/cardano-wallet#1578)
Issue Number
#1561
Overview
938a3a0
📍 add regression test triggering the unbalanced invariant
currently fails as expected with:
1041fac
📍 refactor: merge 'remainingFee' and 'rebalanceChangeOutput'
The former actually makes assumption based on the output of the later. Testing these
function in isolation makes little sense. Grouping them into one function makes it
easier to understand the surrounding context and what is happening.
Further refactoring is needed in order to now fix the issue with dangling fee
1758a30
📍 use dustThreshold instead of 'Coin 0'
They should actually have the same semantic within this context.
7194126
📍 fix remaining fee calculation
a17462c
📍 fix unit test now correctly divying fee across change outputs
1534124
📍 property test fee balancing
And allow transaction to be unbalanced if the node allows it
Comments