Include the declared gas fee in MAYAChain/THORChain fees - #1084
Open
j0ntz wants to merge 1 commit into
Open
Conversation
Contributor
Author
Both chains price a transaction by a flat network fee, so the engines report that fee and declare a token gas fee of 1 base unit. The signer pays both: the ante handler collects the declared gas fee before the message runs. Reporting only the flat fee put a max send one base unit over the balance, so the chain accepted the transaction and then reverted it as insufficient funds while the app showed a successful send.
j0ntz
force-pushed
the
jon/cacao-max-send
branch
from
August 10, 2026 20:09
057bfc6 to
2e667be
Compare
j0ntz
marked this pull request as ready for review
August 10, 2026 20:09
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or 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
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
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Asana task
Asana: https://app.asana.com/1/9976422036640/project/1201386023359434/task/1214062657363212
A CACAO max send never left the wallet. The app reported "Transaction Success"
and wrote a sent transaction into history, but nothing moved on-chain.
MAYAChain and THORChain price a transaction by a flat network fee rather than by
gas, so
MayachainEngineandThorchainEnginequote that flat fee and declare atoken gas fee of 1 base unit. The signer pays BOTH: the ante handler collects the
declared gas fee before the message runs. Only the flat fee was reported as
networkFee, and since the cosmos plugin has nogetMaxSpendable, edge-core-jsbinary-searches
makeSpendandcheckBalancesonly enforcesamount + networkFee <= balance. A max send therefore landed onbalance - flatFee, whose real cost isbalance + 1. The chain accepted it atCheckTx and then reverted it in DeliverTx as
insufficient funds.The two engines now share a
makeMidgardFeehelper onMidgardEnginethat ownsthe declared gas coin and folds its amount into the reported
networkFee.Evidence the declared fee is a real deduction, from mayanode: every MsgSend's
first
transferevent paysauth_info.fee.amountto the fee collectormaya17xpfvakm2amg962yls6f84z3kell8c5lkfyhgj, separate from the 2000000000native-fee split (txs
78BA4DCE97C88FC72886DAC67FF67A8B1C22E83C85D38CF8718B51D491E34F77and
128511AD8D479524A2E1F6C5C9DE77029AE2E5EAFA4F5A0F946385536F033E49).Verification
Driven in the app on the iOS simulator with this branch baked in via
updot,sending between two CACAO wallets on
edge-funds.BFBC11AF…code 1,insufficient funds544BA17E…code 0An ordinary non-max send was driven afterwards and also lands
code 0(
051A9C29…),with the sender debited
amount + 2000000000 + 1.test/cosmos/midgardCalculateFee.test.tscovers the fee arithmetic.verify-repo.shpasses (install, prepare, eslint, mocha).Notes for review
calculateFeehas the same shape andthe chain is what MAYAChain forked from. Its public nodes were unreachable from
the machine this ran on, so RUNE was not exercised on-chain. The change is safe
either way: if RUNE does not charge the declared fee, a max send merely leaves
1 base unit (1e-8 RUNE) behind rather than failing.
0.2000000001instead of0.2, becausethe reported fee is the amount the chain actually takes. Rounding that back to
a pretty
0.2for display would reintroduce the failure if it were also usedfor the max calculation, so it is left accurate here.
Note
Cursor Bugbot is generating a summary for commit 2e667be. Configure here.