-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(mempool)!: respect gas wanted returned by ante handler #25338
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?
Changes from all commits
4cd29a5
b54349d
7be0362
8937edb
0936ce1
99707c4
a4d9cfd
c434a76
010dfe1
24b265d
d4980fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,30 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type Tx struct { | ||
Tx sdk.Tx | ||
GasWanted uint64 | ||
} | ||
|
||
func NewMempoolTx(tx sdk.Tx, gasWanted uint64) Tx { | ||
return Tx{ | ||
Tx: tx, | ||
GasWanted: gasWanted, | ||
} | ||
} | ||
|
||
type InsertOption struct { | ||
GasWanted uint64 | ||
} | ||
|
||
type Mempool interface { | ||
// Insert attempts to insert a Tx into the app-side mempool returning | ||
// an error upon failure. | ||
Insert(context.Context, sdk.Tx) error | ||
|
||
// InsertWithOption with a custom option, e.g. gas wanted. | ||
InsertWithOption(context.Context, sdk.Tx, InsertOption) error | ||
|
||
// Select returns an Iterator over the app-side mempool. If txs are specified, | ||
// then they shall be incorporated into the Iterator. The Iterator is not thread-safe to use. | ||
Select(context.Context, [][]byte) Iterator | ||
|
@@ -31,7 +50,7 @@ type ExtMempool interface { | |
Mempool | ||
|
||
// SelectBy use callback to iterate over the mempool, it's thread-safe to use. | ||
SelectBy(context.Context, [][]byte, func(sdk.Tx) bool) | ||
SelectBy(context.Context, [][]byte, func(Tx) bool) | ||
} | ||
|
||
// Iterator defines an app-side mempool iterator interface that is as minimal as | ||
|
@@ -43,7 +62,7 @@ type Iterator interface { | |
Next() Iterator | ||
|
||
// Tx returns the transaction at the current position of the iterator. | ||
Tx() sdk.Tx | ||
Tx() Tx | ||
} | ||
Comment on lines
+65
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainIterator.Tx now returns wrapper Tx — breaking change: verify all usages are updated. Audit for code still asserting sdk.Tx directly from Iterator.Tx(). Run: Expected: call sites use iter.Tx().Tx (or equivalent) after this change. 🏁 Script executed: #!/bin/bash
# Find Iterator.Tx() usages and spot unwraps expecting sdk.Tx.
rg -nP --type=go -C3 '\.Tx\(\)\s*[\),]' # method call contexts
rg -nP --type=go -C3 '\.Tx\(\)\.' # chained member access implying wrapper usage
rg -nP --type=go -C3 '=\s*iter\.Tx\(\)' # direct assignment patterns Length of output: 3411 Iterator.Tx now returns wrapper Tx — update all call sites that still treat it as sdk.Tx Call sites still passing/assigning iter.Tx() must unwrap (.Tx) or accept the wrapper:
Tests already access the inner Tx in several places (e.g., types/mempool/mempool_test.go:142; types/mempool/priority_nonce_test.go:391, 938, 973) — ensure expectations/ assertions match the wrapper change. 🤖 Prompt for AI Agents
|
||
|
||
var ( | ||
|
@@ -53,7 +72,7 @@ var ( | |
|
||
// SelectBy is compatible with old interface to avoid breaking api. | ||
// In v0.52+, this function is removed and SelectBy is merged into Mempool interface. | ||
func SelectBy(ctx context.Context, mempool Mempool, txs [][]byte, callback func(sdk.Tx) bool) { | ||
func SelectBy(ctx context.Context, mempool Mempool, txs [][]byte, callback func(Tx) bool) { | ||
if ext, ok := mempool.(ExtMempool); ok { | ||
ext.SelectBy(ctx, txs, callback) | ||
return | ||
|
Uh oh!
There was an error while loading. Please reload this page.