Skip to content

Commit 3c81d55

Browse files
PlasmaPowerbuddh0
authored andcommitted
core/txpool/blobpool: return ErrAlreadyKnown for duplicate txs (ethereum#29210)
Signed-off-by: Lee Bousfield <[email protected]>
1 parent c1496e7 commit 3c81d55

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

core/txpool/blobpool/blobpool.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,12 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
11331133
next = p.state.GetNonce(from)
11341134
)
11351135
if uint64(len(p.index[from])) > tx.Nonce()-next {
1136-
// Account can support the replacement, but the price bump must also be met
11371136
prev := p.index[from][int(tx.Nonce()-next)]
1137+
// Ensure the transaction is different than the one tracked locally
1138+
if prev.hash == tx.Hash() {
1139+
return txpool.ErrAlreadyKnown
1140+
}
1141+
// Account can support the replacement, but the price bump must also be met
11381142
switch {
11391143
case tx.GasFeeCapIntCmp(prev.execFeeCap.ToBig()) <= 0:
11401144
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
@@ -992,9 +992,14 @@ func TestAdd(t *testing.T) {
992992
},
993993
},
994994
adds: []addtx{
995-
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
995+
{ // New account, 1 tx pending: reject duplicate nonce 0
996996
from: "alice",
997997
tx: makeUnsignedTx(0, 1, 1, 1),
998+
err: txpool.ErrAlreadyKnown,
999+
},
1000+
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
1001+
from: "alice",
1002+
tx: makeUnsignedTx(0, 1, 1, 2),
9981003
err: txpool.ErrReplaceUnderpriced,
9991004
},
10001005
{ // New account, 1 tx pending: accept nonce 1
@@ -1017,10 +1022,10 @@ func TestAdd(t *testing.T) {
10171022
tx: makeUnsignedTx(3, 1, 1, 1),
10181023
err: nil,
10191024
},
1020-
{ // Old account, 1 tx in chain, 1 tx pending: reject replacement nonce 1 (ignore price for now)
1025+
{ // Old account, 1 tx in chain, 1 tx pending: reject duplicate nonce 1
10211026
from: "bob",
10221027
tx: makeUnsignedTx(1, 1, 1, 1),
1023-
err: txpool.ErrReplaceUnderpriced,
1028+
err: txpool.ErrAlreadyKnown,
10241029
},
10251030
{ // Old account, 1 tx in chain, 1 tx pending: accept nonce 2 (ignore price for now)
10261031
from: "bob",

0 commit comments

Comments
 (0)