Skip to content

Commit 00c2112

Browse files
authored
core/txpool/blobpool: return ErrAlreadyKnown for duplicate txs (ethereum#29210)
Signed-off-by: Lee Bousfield <ljbousfield@gmail.com>
1 parent b393ad8 commit 00c2112

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

core/txpool/blobpool/blobpool.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,12 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
11311131
next = p.state.GetNonce(from)
11321132
)
11331133
if uint64(len(p.index[from])) > tx.Nonce()-next {
1134-
// Account can support the replacement, but the price bump must also be met
11351134
prev := p.index[from][int(tx.Nonce()-next)]
1135+
// Ensure the transaction is different than the one tracked locally
1136+
if prev.hash == tx.Hash() {
1137+
return txpool.ErrAlreadyKnown
1138+
}
1139+
// Account can support the replacement, but the price bump must also be met
11361140
switch {
11371141
case tx.GasFeeCapIntCmp(prev.execFeeCap.ToBig()) <= 0:
11381142
return fmt.Errorf("%w: new tx gas fee cap %v <= %v queued", txpool.ErrReplaceUnderpriced, tx.GasFeeCap(), prev.execFeeCap)

core/txpool/blobpool/blobpool_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,14 @@ func TestAdd(t *testing.T) {
984984
},
985985
},
986986
adds: []addtx{
987-
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
987+
{ // New account, 1 tx pending: reject duplicate nonce 0
988988
from: "alice",
989989
tx: makeUnsignedTx(0, 1, 1, 1),
990+
err: txpool.ErrAlreadyKnown,
991+
},
992+
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
993+
from: "alice",
994+
tx: makeUnsignedTx(0, 1, 1, 2),
990995
err: txpool.ErrReplaceUnderpriced,
991996
},
992997
{ // New account, 1 tx pending: accept nonce 1
@@ -1009,10 +1014,10 @@ func TestAdd(t *testing.T) {
10091014
tx: makeUnsignedTx(3, 1, 1, 1),
10101015
err: nil,
10111016
},
1012-
{ // Old account, 1 tx in chain, 1 tx pending: reject replacement nonce 1 (ignore price for now)
1017+
{ // Old account, 1 tx in chain, 1 tx pending: reject duplicate nonce 1
10131018
from: "bob",
10141019
tx: makeUnsignedTx(1, 1, 1, 1),
1015-
err: txpool.ErrReplaceUnderpriced,
1020+
err: txpool.ErrAlreadyKnown,
10161021
},
10171022
{ // Old account, 1 tx in chain, 1 tx pending: accept nonce 2 (ignore price for now)
10181023
from: "bob",

0 commit comments

Comments
 (0)