-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
Summary
The current design of the experimental EVMMempool does not consistently respect the sdk.Context priority initialized during the antehandler.
- For EVM txs, this only leads to a scaling discrepancy, since Cosmos EVM already employs the same priority calculation mechanism.
- For Cosmos txs, however, it introduces inconsistencies in priority handling.
This issue proposes aligning CosmosPool priority logic with the antehandler’s priority setup and ensuring consistent use of same priority calculation across the mempool.
As-Is
- CosmosPool Priority Setup
- In
NewExperimentalEVMMempool, when configuringcosmosPool, it defaultsTxPriorityto use gas price. - This ignores the
sdk.Contextpriority set in the antehandler (unlikepriority_nonce.go’s default). - If the app uses
DynamicTxFeeChecker, the correct priority should be the priority tip, not the raw gas price.
- In
// Create Cosmos Mempool from configuration
cosmosPoolConfig := config.CosmosPoolConfig
if cosmosPoolConfig == nil {
// Default configuration
defaultConfig := sdkmempool.PriorityNonceMempoolConfig[math.Int]{}
defaultConfig.TxPriority = sdkmempool.TxPriority[math.Int]{
GetTxPriority: func(goCtx context.Context, tx sdk.Tx) math.Int {
cosmosTxFee, ok := tx.(sdk.FeeTx)
if !ok {
return math.ZeroInt()
}
found, coin := cosmosTxFee.GetFee().Find(bondDenom)
if !found {
return math.ZeroInt()
}
gasPrice := coin.Amount.Quo(math.NewIntFromUint64(cosmosTxFee.GetGas()))
return gasPrice
},
Compare: func(a, b math.Int) int {
return a.BigInt().Cmp(b.BigInt())
},
MinValue: math.ZeroInt(),
}
cosmosPoolConfig = &defaultConfig
}- Babylon Genesis Context
- In Babylon, certain Cosmos txs are explicitly prioritized via the antehandler.
- Since the mempool ignores
sdk.Contextpriority, these intended priorities may not be respected.
shouldUseEVMFunction- Currently retains
cosmosFeeby callingextractCosmosEffectiveTip. - This computes priority only as
gas_price - base_fee, missing the min(gas_price - base_fee, priority_tip) rule used byDeductFeeDecorator. - This creates discrepancies between
cosmosPoolconfig priority (using static fee checker) andshouldUseEVM(using incomplete dynamic fee checker logic).
- Currently retains
To-Be
- Use
sdk.Contextpriority for Cosmos txs in the EVMMempool, so antehandler logic is preserved.
func NewDefaultTxPriority() TxPriority[int64] {
return TxPriority[int64]{
GetTxPriority: func(goCtx context.Context, _ sdk.Tx) int64 {
return sdk.UnwrapSDKContext(goCtx).Priority()
},
Compare: func(a, b int64) int {
return skiplist.Int64.Compare(a, b)
},
MinValue: math.MinInt64,
}
}- Adopt the same priority calculation logic as the
TxFeeCheckerof theDeductFeeDecoratorfor cosmos txs in the EVMMempool, ensuring consistency with how fees and tips are applied during execution.- This can be done by using
sdk.Contextpriority for cosmos txs in the EVMMempool.
- This can be done by using
- Unify CosmosPool priority setup, making it consistent across:
cosmosPoolconfigshouldUseEVMdecision logic
Current Limitations
- Extra setup is currently required for
cosmosPoolwhen configuringTxFeeChecker. extractCosmosEffectiveTiponly partially implements dynamic fee calculation.- Inconsistencies exist between static and dynamic fee checker defaults across the mempool.
cosmosPooldefault config uses static fee checker for calculating priority, which is same with gas priceshouldUseEVMdecision logic uses incomplete dynamic fee checker for calculating priority, which calculates based on priority tip
Suggestions
- Update
cosmosPoolto respectsdk.Contextpriority values. - Replace
extractCosmosEffectiveTiplogic with the same priority calculation used inDeductFeeDecorator. - Ensure
cosmosPoolconfig andshouldUseEVMshare a single consistent priority algorithm.
cloudgray, mmsqe and Vvaradinov
Metadata
Metadata
Assignees
Labels
No labels