diff --git a/vms/platformvm/block/builder/helpers_test.go b/vms/platformvm/block/builder/helpers_test.go index dde442e1a1c8..7b3ec5eab620 100644 --- a/vms/platformvm/block/builder/helpers_test.go +++ b/vms/platformvm/block/builder/helpers_test.go @@ -228,7 +228,7 @@ func newEnvironment(t *testing.T) *environment { res.sender, p2pNetwork, validators, - gossip.NoOpAccumulator[*txs.Tx]{}, + gossip.NoOpAccumulator[*network.Tx]{}, gossip.NoOpGossiper{}, p2p.NoOpHandler{}, txGossipHandlerID, diff --git a/vms/platformvm/network/gossip.go b/vms/platformvm/network/gossip.go index c999521d359e..5c9e90b3c99e 100644 --- a/vms/platformvm/network/gossip.go +++ b/vms/platformvm/network/gossip.go @@ -5,6 +5,8 @@ package network import ( "context" + "errors" + "fmt" "sync" "time" @@ -21,6 +23,8 @@ var ( _ gossip.Gossipable = (*Tx)(nil) _ gossip.Marshaller[*Tx] = (*TxMarshaller)(nil) _ gossip.Set[*Tx] = (*VerifierMempool)(nil) + + ErrTxPending = errors.New("tx pending") ) // txGossipHandler is the handler called when serving gossip messages @@ -81,6 +85,12 @@ type VerifierMempool struct { } func (v *VerifierMempool) Add(tx *Tx) error { + if v.Mempool.Has(tx.ID()) { + err := fmt.Errorf("tx %s dropped: %w", tx.ID(), ErrTxPending) + v.Mempool.MarkDropped(tx.ID(), err) + return err + } + if err := v.verifier.VerifyTx(tx.Tx); err != nil { v.Mempool.MarkDropped(tx.ID(), err) return err