-
Notifications
You must be signed in to change notification settings - Fork 92
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 defaultsTxPriority
to use gas price. - This ignores the
sdk.Context
priority 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.Context
priority, these intended priorities may not be respected.
shouldUseEVM
Function- Currently retains
cosmosFee
by 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
cosmosPool
config priority (using static fee checker) andshouldUseEVM
(using incomplete dynamic fee checker logic).
- Currently retains
To-Be
- Use
sdk.Context
priority 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
TxFeeChecker
of theDeductFeeDecorator
for cosmos txs in the EVMMempool, ensuring consistency with how fees and tips are applied during execution.- This can be done by using
sdk.Context
priority for cosmos txs in the EVMMempool.
- This can be done by using
- Unify CosmosPool priority setup, making it consistent across:
cosmosPool
configshouldUseEVM
decision logic
Current Limitations
- Extra setup is currently required for
cosmosPool
when configuringTxFeeChecker
. extractCosmosEffectiveTip
only partially implements dynamic fee calculation.- Inconsistencies exist between static and dynamic fee checker defaults across the mempool.
cosmosPool
default config uses static fee checker for calculating priority, which is same with gas priceshouldUseEVM
decision logic uses incomplete dynamic fee checker for calculating priority, which calculates based on priority tip
Suggestions
- Update
cosmosPool
to respectsdk.Context
priority values. - Replace
extractCosmosEffectiveTip
logic with the same priority calculation used inDeductFeeDecorator
. - Ensure
cosmosPool
config andshouldUseEVM
share a single consistent priority algorithm.
cloudgray, mmsqe and Vvaradinov
Metadata
Metadata
Assignees
Labels
No labels