-
Notifications
You must be signed in to change notification settings - Fork 104
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
Open
cloudgray
wants to merge
24
commits into
cosmos:main
Choose a base branch
from
cloudgray:fix/cosmos-tx-priority
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fca99f2
WIP: test(mempool): add integration test
cloudgray 3591815
WIP: test(mempool): add integration test
cloudgray ad31857
test(mempool): refactor integration test
cloudgray a656805
test(mempool): fix integration test
cloudgray 5a384a7
test(mempool): refactor integration test
cloudgray d74f5ad
chore: modify comments
cloudgray 9a4d096
Merge branch 'main' into test/appside-mempool
cloudgray abbe071
test(mempool): add PrepareProposal check to integration test
cloudgray 603c890
chore: fix lint
cloudgray bc522eb
chore: update changelog
cloudgray 375fee6
Merge branch 'main' into test/appside-mempool
cloudgray dbe047b
test(mempool): modify testcode
cloudgray 29fd29f
chore: fix lint
cloudgray 142fbca
chore: fix lint
cloudgray 5d29424
fix(ante): remove bond denom from allowed fee denom
cloudgray 66811c5
fix(mempool): calculation of priority of cosmos tx
cloudgray 9449d73
test(mempool): fix mempool integration test
cloudgray 60a2cc7
Merge branch 'main' into fix/cosmos-tx-priority
cloudgray 8c25160
add unit test for cosmos tx feeCoins validation
cloudgray 155b2b9
chore: fix lint
cloudgray db33377
chore: modify test helper function and comments
cloudgray 272d598
Merge branch 'main' into fix/cosmos-tx-priority
cloudgray ca3cdb2
chore: resolve merge conflict
cloudgray ac9cd72
chore: update CHANGELOG.md
cloudgray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package cosmos_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/evm/ante/cosmos" | ||
|
||
sdkmath "cosmossdk.io/math" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func TestIsValidFeeCoins(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
feeCoins sdk.Coins | ||
allowedDenoms []string | ||
expectedResult bool | ||
}{ | ||
{ | ||
name: "empty fee coins should be valid", | ||
feeCoins: sdk.Coins{}, | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: true, | ||
}, | ||
{ | ||
name: "nil fee coins should be valid", | ||
feeCoins: nil, | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: true, | ||
}, | ||
{ | ||
name: "single allowed denom should be valid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(1000))), | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: true, | ||
}, | ||
{ | ||
name: "single allowed denom from multiple allowed should be valid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(1000))), | ||
allowedDenoms: []string{"uatom", "stake", "wei"}, | ||
expectedResult: true, | ||
}, | ||
{ | ||
name: "single disallowed denom should be invalid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("forbidden", sdkmath.NewInt(1000))), | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: false, | ||
}, | ||
{ | ||
name: "single disallowed denom with empty allowed list should be invalid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(1000))), | ||
allowedDenoms: []string{}, | ||
expectedResult: false, | ||
}, | ||
{ | ||
name: "multiple fee coins should be invalid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(1000)), sdk.NewCoin("stake", sdkmath.NewInt(500))), | ||
allowedDenoms: []string{"uatom", "stake"}, | ||
expectedResult: false, | ||
}, | ||
{ | ||
name: "multiple fee coins with one allowed should be invalid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(1000)), sdk.NewCoin("forbidden", sdkmath.NewInt(500))), | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: false, | ||
}, | ||
{ | ||
name: "empty allowed denoms with empty fee coins should be valid", | ||
feeCoins: sdk.Coins{}, | ||
allowedDenoms: []string{}, | ||
expectedResult: true, | ||
}, | ||
{ | ||
name: "case sensitive denom matching", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("UATOM", sdkmath.NewInt(1000))), | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: false, | ||
}, | ||
{ | ||
name: "zero amount allowed denom should be valid", | ||
feeCoins: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(0))), | ||
allowedDenoms: []string{"uatom"}, | ||
expectedResult: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
result := cosmos.IsValidFeeCoins(tt.feeCoins, tt.allowedDenoms) | ||
require.Equal(t, tt.expectedResult, result, "IsValidFeeCoins returned unexpected result") | ||
}) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thrucheckTxFeeWIthValidatorMinGasPrices
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.