-
Notifications
You must be signed in to change notification settings - Fork 95
fix(mempool): align cosmos tx priority with priority setup of anteHandler #534
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
base: main
Are you sure you want to change the base?
Conversation
ante/cosmos/min_gas_price.go
Outdated
// 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))) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,153 @@ | |||
package mempool |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo checkTxs -> checkTx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied (db33377)
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
Description
Summary
Code review guide
The review scope of this PR is as below.
Other changes belongs to PR #512.
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...
main
branch