-
Notifications
You must be signed in to change notification settings - Fork 697
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
Refactor: fee antehandler #2228
Comments
updates:
The above fee checks can prevent malicious tx submitters, but it cannot prevent malicious validator. Block proposer can change the fee antehandler and propose the tx that does not pass fee checks in fee antehandler, since present fee antehandler only checks in The solution is to do fee check logic in
Please note, the above mentioned refactor is Consensus breaking !!! |
updates: For global fees, it still can contain zero and non-zero coins, when use global fees in fee antehandler, split it into two groups: zero and non-zero coins.
|
closed by #2327 |
Summary
Gaia fee antehandler introduction
Gaia fee antehandler takes
min_gas_price
, Global fee into a combined fee requirement. The combined fee:min_gas_price
and global fee ifmin_gas_price
and global_fee have the same denom. Otherwise, take the global fee.For point 2, present gaia fee antehandler allows zero coins globalfee, for example,
globalfee=[0stake]
means the chain does not want to charge transaction fees, but if there is volunteer paid fee, it should be in the denom ofstake
.Concerns
Globalfee is
sdk.DecCoins
type, but cosmos-sdksdk.DecCoins
are sanitized to remove zero coins in it, so several methods fromsdk.DecCoins
are over-written in gaia fee antehandler.Even though present fee antehandler logic works, allowing zero coins in global fee makes the fee check logic in antehandler complicated and difficult to maintain.
Type
Code Debt
Design Debt
Impact
Simplify gaia fee antehandler, the present logic is complex and hard to maintain, need to maintain extra methods that overwritten sdk's methods.
### Potential state-breakingFor the hub, this refactor means users cannot propose zero coins in globalfee through gov proposal. If global fee is empty, thebond_denom
will be used to check the paid fee denoms. This is potential state-breaking if in param store, globalfee params already contain zero coins (assume someone proposed zero coins as globalfee before this refactor). Please see below solutions, step4: upgrade handler, for how to deal with this scenarios.Proposed Solution
Proposal:
## proposal 1:Globalfee does not allow zero coins, this meansglobalfee=[0stake]
is invalid setup.- If the chain does not want to charge fees (above mentioned point 2), it can setglobalfee=[]
, if globalfee empty, we can use bonding denom to check the denoms of the global fee.- If the chain allows any other denoms as paid fee denom, it has to set a value in global fee, for example,globalfee=[0.0001stake]
This can simplify the logic, but disables one possibility:bonding denom = uatom
, but the chain want to set0stake
as globalfee (the chain does not charge tx fee, but tx still pays, it has to be stake (not a bonding denom of the chain.) )So in summary:after refactor, globalfee does not allow zero coins.- if chain want to set globalfee=[0uatom] (uatom is bond-denom), it can set globalfee=[]- if chain want to set globalfee=[0stake] (uatom is bond-denom), it has to setup as globalfee=[x stake], (x > 0)Proposal 2:
globalfee can contain zero coins, in the fee check antehandler: split the
combinedFeeRequirement
(get a combined fee requirement from local fee(min-gas-prices in app.toml) and global fee) into zero and non-zero coins:combinedFeeRequirement = nonZeroCoinFeesReq + zeroCoinFeesDenomReq
split the paidfee according to the
nonZeroCoinFeesReq
andzeroCoinFeesDenomReq
denoms:paidfee= feeCoinsNoZeroDenom + feeCoinsZeroDenom
steps:
feeCoinsZeroDenom
, tx pass.feeCoinsZeroDenom
, checkfeeCoinsNoZeroDenom
's amountIsAnyGTE
thannonZeroCoinFeesReq
paidfee=[]
, and there is zero coins incombinedFeeRequirement
, tx pass.example:
globalfee=[0uatom,1stake,1photon]
,min-gas-prices=[]
in app.toml.combinedFeeRequirement=[0uatom,1stake,1photon]
.nonZeroCoinFeesReq=[1stake,1photon]
,zeroCoinFeesReq=[0uatom]
.fail in step 1.
pass denom checks, then split paid fee,
feeCoinsZeroDenom=[1uatom]
,feeCoinsNoZeroDenom=[2photon]
,feeCoinsZeroDenom
is not empty, direct pass tx.pass denom checks, then split paid fee,
feeCoinsZeroDenom=[]
,feeCoinsNoZeroDenom=[2photon]
,feeCoinsZeroDenom
empty, checkfeeCoinsNoZeroDenom
IsAnyGTE
thannonZeroCoinFeesReq
, passpass denoms checks, then split paid fee,
feeCoinsZeroDenom=[]
,feeCoinsNoZeroDenom=[]
,feeCoinsZeroDenom
empty, if directly checkfeeCoinsNoZeroDenom
IsAnyGTE
thannonZeroCoinFeesReq
, this tx will fail, so check ifcombinedFeeRequirement
is also empty first before checkIsAnyGTE
pass denom checks, then split paid fee,
feeCoinsZeroDenom=[]
,feeCoinsNoZeroDenom=[0.5photon]
,feeCoinsZeroDenom
empty, checkfeeCoinsNoZeroDenom
IsAnyGTE
thannonZeroCoinFeesReq
fail.For Admin Use
The text was updated successfully, but these errors were encountered: