Skip to content

Conversation

cloudgray
Copy link
Contributor

@cloudgray cloudgray commented Aug 27, 2025

Description

This PR should be merged after PR #512.

Summary

  • AnteHandler now allows evmDenom as the sole feeDenom. (staking bond denom is excluded)
  • Update default cosmosPoolConfig to use ctx.priority as the priority of cosmos tx
  • Update effectiveTip calculation of cosmos tx to be aligned with anteHandler effectiveTip calcualtion

Code review guide

The review scope of this PR is as below.
Other changes belongs to PR #512.

  • ante/cosmos/min_gas_price.go
  • mempool/iterator.go
  • mempool/mempool.go

Closes: #510


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@cloudgray cloudgray marked this pull request as ready for review August 27, 2025 13:01
@cloudgray cloudgray requested review from a team as code owners August 27, 2025 13:01
// TODO: is the handling of stake necessary here? Why not adjust the tests to contain the correct denom?
validFees := len(feeCoins) == 0 || (len(feeCoins) == 1 && slices.Contains([]string{evmDenom, sdk.DefaultBondDenom}, feeCoins.GetDenomByIndex(0)))
// only allow user to pass in evm coin as transaction fee
validFees := len(feeCoins) == 0 || (len(feeCoins) == 1 && slices.Contains([]string{evmDenom}, feeCoins.GetDenomByIndex(0)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a helper function that we can test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied (8c25160)

tx, err := s.factory.BuildCosmosTx(key.Priv, txArgs)
s.Require().NoError(err)

fmt.Printf("DEBUG: Created cosmos transaction successfully\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not use fmt in any of our testing. we can use t.Log()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll apply this comment in PR #512 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied in PR #512 (fd4e829)

@@ -0,0 +1,153 @@
package mempool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to test_helpers.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll apply this comment in PR #512 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied in PR #512 (b39c89d)

Copy link

@canu0205 canu0205 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments regarding using context priority also in the iterator. Besides that, thank you for your work!

@@ -287,6 +318,10 @@ func (i *EVMMempoolIterator) extractCosmosEffectiveTip(tx sdk.Tx) *uint256.Int {
}

effectiveTip := new(uint256.Int).Sub(gasPrice, baseFee)
if effectiveTip.Cmp(gasTipCap) > 0 {
effectiveTip = gasTipCap

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use context priority here too. Since if cosmos tx doesn't set TxFeeChecker, it falls thru checkTxFeeWIthValidatorMinGasPrices which calculates priority based on gas price.

Therefore, in this case, there would be discrepancy in the priority of the context and the priority calculated in this function.

My suggestion is getting a context with blockchain and then retain priority from that context. In this case, this function extractCosmosEffectiveTip might not needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this. We should lean into fully supporting context priority. Alongside this, we should set the default context priority for Cosmos EVM to be the effective gas tip, allowing people to modify it if they wish.


// calculateCosmosEffectiveTip calculates the effective tip for a Cosmos transaction
// This aligns with EVM transaction prioritization: effective_tip = gas_price - base_fee
func (s *IntegrationTestSuite) calculateCosmosEffectiveTip(feeAmount int64, gasLimit uint64, baseFee *big.Int) *big.Int {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priority tip is also needed when calculating cosmos effective tip

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied (db33377)

TxGas = 100_000
)

// createCosmosSendTransactionWithKey creates a simple bank send transaction with the specified key

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment unmatched with the function signature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied (db33377)

return tx
}

// createEVMTransaction creates an EVM transaction using the provided key

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment unmatched with the function signature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied (db33377)

return nil
}

// checkTxs call abci CheckTx for a transaction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo checkTxs -> checkTx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied (db33377)

@cloudgray cloudgray self-assigned this Sep 1, 2025
Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding onto what @canu0205 is saying, we should fully lean into ctx.Priority() everywhere Cosmos comparisons are used, with the assumption that the ctx.Priority() behaves sensibly.

Because we're generalizing this to be customizable, we should also set the default priority to be effectiveTip-based for all Cosmos transactions. This should be available in EVMD as a reference and should be easily extensible and modifiable.

@@ -287,6 +318,10 @@ func (i *EVMMempoolIterator) extractCosmosEffectiveTip(tx sdk.Tx) *uint256.Int {
}

effectiveTip := new(uint256.Int).Sub(gasPrice, baseFee)
if effectiveTip.Cmp(gasTipCap) > 0 {
effectiveTip = gasTipCap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this. We should lean into fully supporting context priority. Alongside this, we should set the default context priority for Cosmos EVM to be the effective gas tip, allowing people to modify it if they wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Align CosmosPool priority logic with the antehandler’s priority setup
4 participants