Skip to content
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

support txn replacement when mempool is full #127

Open
wants to merge 19 commits into
base: testnet/v0.5.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add account nonce operator to rewind account nonce if tx removed by f…
…ull of mempool
  • Loading branch information
Solovyov1796 committed Mar 12, 2025
commit 08000544c96041c205e6b06ce442defaf20198ed
28 changes: 28 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1068,3 +1068,31 @@ func GetMaccPerms() map[string][]string {
}
return perms
}

type accountNonceOp struct {
ak evmtypes.AccountKeeper
}

type AccountNonceOp interface {
GetAccountNonce(ctx sdk.Context, address string) uint64
SetAccountNonce(ctx sdk.Context, address string, nonce uint64)
}

func NewAccountNonceOp(app *App) AccountNonceOp {
return &accountNonceOp{
ak: app.accountKeeper,
}
}

func (ano *accountNonceOp) GetAccountNonce(ctx sdk.Context, address string) uint64 {
bzAcc, _ := sdk.AccAddressFromBech32(address)
acc := ano.ak.GetAccount(ctx, bzAcc)
return acc.GetSequence()
}

func (ano *accountNonceOp) SetAccountNonce(ctx sdk.Context, address string, nonce uint64) {
bzAcc, _ := sdk.AccAddressFromBech32(address)
acc := ano.ak.GetAccount(ctx, bzAcc)
acc.SetSequence(nonce)
ano.ak.SetAccount(ctx, acc)
}