-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use evaluateTransactionFee in calculate-min-fee #642
Merged
newhoggy
merged 2 commits into
main
from
newhoggy/use-evaluateTransactionFee-in-calculateMinFee
Mar 18, 2024
Merged
Use evaluateTransactionFee in calculate-min-fee #642
newhoggy
merged 2 commits into
main
from
newhoggy/use-evaluateTransactionFee-in-calculateMinFee
Mar 18, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
smelc
reviewed
Mar 11, 2024
smelc
reviewed
Mar 11, 2024
carbolymer
approved these changes
Mar 11, 2024
d6fbf0b
to
93890cb
Compare
Cardano.Api.estimateTransactionFee is deprecated and tends to over-estimate transaction fees. There is a deprecation note currently attached to Cardano.Api.estimateTransactionFee, saying that Cardano.Api.evaluateTransactionFee should be used instead. https://github.com/IntersectMBO/cardano-api/blob/1c10a287093ea1396c4c0ef0c92460f60bab690f/cardano-api/internal/Cardano/Api/Fees.hs#L190 Therefore, cardano-cli should be updated to use Cardano.Api.evaluateTransactionFee in the handler for calculate-min-fee. The existing golden test for calculate-min-fee was adjusted and another golden test with a babbage transaction was added.
93890cb
to
32c2d75
Compare
3 tasks
🎉 |
Jimbo4350
reviewed
Mar 26, 2024
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.
LGTM. We can now use calcMinFeeTx
for a more accurate fee calculation.
|
||
liftIO $ putStrLn $ (show fee :: String) <> " Lovelace" | ||
|
||
UnwitnessedCliFormattedTxBody anyTxBody -> do | ||
InAnyShelleyBasedEra sbe txbody <- pure anyTxBody | ||
UnwitnessedCliFormattedTxBody (InAnyShelleyBasedEra sbe txbody) -> do |
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.
We can get rid UnwitnessedCliFormattedTxBody
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog
Context
Original PR: #534
Cardano.Api.estimateTransactionFee
(currently used by Cardano CLIcalculate-min-fee
) tends to overestimate transaction fees. Furthermore, inspecting the code,estimateTransactionFee
appears to only apply the olda * x + b
fee formula to the transaction size (augmented to take into account the user-provided Shelley and Byron witness counts). This is not how fees should be calculated for later eras.A deprecation note is currently attached to
Cardano.Api.estimateTransactionFee
, saying thatCardano.Api.evaluateTransactionFee
should be used instead. Inspecting the code, evaluateTransactionFee calls the Cardano Ledger's era-aware fee calculation functionCardano.Ledger.Shelley.API.Wallet.evaluateTransactionFee
, which in turn calls theEraTx
class functiongetMinFeeTx
that is instantiated for every Cardano Ledger era.https://github.com/IntersectMBO/cardano-api/blob/1c10a287093ea1396c4c0ef0c92460f60bab690f/cardano-api/internal/Cardano/Api/Fees.hs#L190
Therefore, cardano-cli should be updated to use Cardano.Api.evaluateTransactionFee in the handler for calculate-min-fee.
https://twitter.com/amw7/status/1740008349905928326
How to trust this PR
New golden test to calculate the min fee of a Babbage transaction body with Babbage protocol parameters, comparing against the known minimum fee (below which the transaction gets rejected when submitted to node).
https://github.com/IntersectMBO/cardano-cli/pull/534/files#diff-8d95bc46c5ef4bbab74b92c6b29635f1c3792d1e084d8c7668b0ce75bf9d2b52
Checklist