| Information | - |
| --- | --- |
| Version | 07c0ff4eb |
| Platform | All |
| Installation | N/A |
See comments below.
I see that delegation fee is still shown incorrectly. Looking at our own integration tests fees config:
fees:
certificate: 42
coefficient: 1
constant: 14
so, if I understand correctly, the fee for delegation fee should be 42 + 14 = 56. (if paid from one utxo)
Delegation fee endpoint shows = 58
Delegating to stake pool takes fee = 58
The same goes for transactions.
Tx fee (for single utxo tx) is calculated = 17 (instead of 16).
That is for both, making tx and tx fee.
So... tests do not catch that, Perhaps it would be better to have fee in the integration tests being part of hardcoded TestData rather than calculated by feeEstimator?
Refering to this -> https://github.com/input-output-hk/cardano-wallet/pull/1145/commits/3eee4a23f77ca8e99600c62717b5f8c122b5119d
@piotr-iohk you're forgetting the coefficient part. 1 means that each input or output cost 1. So, in the case of a standard delegation that requires only one UTxO, it'll typically cost 58 because it requires one input (the UTxO) and one change output!
Only if your input is exactly of the right amount (i.e. 57 coins) will you be able to pay 57, because no change output is needed. 56 will never be possible however because you always need an input.
We have integration tests testing for these edge-cases (sorry, I see the QA section on this ticket is empty :| ... ), let me find that back for you.
So,
We are creating a wallet with a single UTxO that is exactly 57 coins (constant fee + certificate fee + coefficient fee for a single input). This is enough to create a delegation certificate. Perhaps it would be good to add an extra assertion on the resulting transaction to show that it actually has no outputs!
Here's an example where we have a wallet that has 56 coins (the minimal fee - 1) and, it's not able to join.
The assertion in this one might seem a bit counter-intuitive. The wallet is empty and the server returns that it can't create a delegation certificate, because it is missing 56 lovelace! Why 56 and not 57 ? Because of the way the algorithm works. We only require additional inputs _when needed_ and at this stage, we know that the wallet hasn't even enough to cover for the flat fees (constant + certificate) and we haven't selected a single input yet! Ultimately, we could catch that edge-case and return a more meaningful error like "your wallet is empty"
OK, so is this correct then?
fees:
certificate: 42
coefficient: 1
constant: 14
delegation_fee = constant + certificate + (coefficient * (inputs + outputs))
tx_fee = constant + (coefficient * (inputs + outputs))
Ultimately, we could catch that edge-case and return a more meaningful error like "your wallet is empty"
I'd be in favor of this idea. :)
OK, so is this correct then?
Yes!
@piotr-iohk see also: https://github.com/input-output-hk/cardano-wallet/blob/master/lib/jormungandr/test/integration/Main.hs#L170-L193
lgtm :+1: