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

core/txpool/blobpool: return ErrAlreadyKnown for duplicate txs #29210

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,12 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
next = p.state.GetNonce(from)
)
if uint64(len(p.index[from])) > tx.Nonce()-next {
// Account can support the replacement, but the price bump must also be met
prev := p.index[from][int(tx.Nonce()-next)]
// Ensure the transaction is different than the one tracked locally
if prev.hash == tx.Hash() {
return txpool.ErrAlreadyKnown
}
// Account can support the replacement, but the price bump must also be met
switch {
case tx.GasFeeCapIntCmp(prev.execFeeCap.ToBig()) <= 0:
return fmt.Errorf("%w: new tx gas fee cap %v <= %v queued", txpool.ErrReplaceUnderpriced, tx.GasFeeCap(), prev.execFeeCap)
Expand Down
11 changes: 8 additions & 3 deletions core/txpool/blobpool/blobpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,14 @@ func TestAdd(t *testing.T) {
},
},
adds: []addtx{
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
{ // New account, 1 tx pending: reject duplicate nonce 0
from: "alice",
tx: makeUnsignedTx(0, 1, 1, 1),
err: txpool.ErrAlreadyKnown,
},
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
from: "alice",
tx: makeUnsignedTx(0, 1, 1, 2),
err: txpool.ErrReplaceUnderpriced,
},
{ // New account, 1 tx pending: accept nonce 1
Expand All @@ -1009,10 +1014,10 @@ func TestAdd(t *testing.T) {
tx: makeUnsignedTx(3, 1, 1, 1),
err: nil,
},
{ // Old account, 1 tx in chain, 1 tx pending: reject replacement nonce 1 (ignore price for now)
{ // Old account, 1 tx in chain, 1 tx pending: reject duplicate nonce 1
from: "bob",
tx: makeUnsignedTx(1, 1, 1, 1),
err: txpool.ErrReplaceUnderpriced,
err: txpool.ErrAlreadyKnown,
},
{ // Old account, 1 tx in chain, 1 tx pending: accept nonce 2 (ignore price for now)
from: "bob",
Expand Down
Loading