Compare commits

...

2 Commits

Author SHA1 Message Date
Ori Newman
74d5181bea add more check 2023-09-25 01:55:06 +03:00
Ori Newman
0bbb307f84 Reject from mempool txs with too many outputs of less than 1 KAS 2023-09-25 01:36:54 +03:00
2 changed files with 22 additions and 0 deletions

View File

@@ -138,6 +138,11 @@ func (tp *transactionsPool) allReadyTransactions() []*externalapi.DomainTransact
if len(mempoolTransaction.ParentTransactionsInPool()) == 0 {
result = append(result, mempoolTransaction.Transaction().Clone()) //this pointer leaves the mempool, and gets its utxo set to nil, hence we clone.
}
if numOutsLessThanOneKas, isSpamming := isTXSpamming(mempoolTransaction.Transaction()); isSpamming {
log.Warnf("Filtered from allReadyTransactions transaction %s with %d outputs with less than 1 KAS", mempoolTransaction.TransactionID(), numOutsLessThanOneKas)
continue
}
}
return result

View File

@@ -2,6 +2,7 @@ package mempool
import (
"fmt"
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
"github.com/kaspanet/kaspad/infrastructure/logger"
@@ -16,6 +17,11 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
fmt.Sprintf("validateAndInsertTransaction %s", consensushashing.TransactionID(transaction)))
defer onEnd()
if numOutsLessThanOneKas, isSpamming := isTXSpamming(transaction); isSpamming {
log.Warnf("Rejected from mempool transaction %s with %d outputs with less than 1 KAS", consensushashing.TransactionID(transaction), numOutsLessThanOneKas)
return nil, nil
}
// Populate mass in the beginning, it will be used in multiple places throughout the validation and insertion.
mp.consensusReference.Consensus().PopulateMass(transaction)
@@ -63,3 +69,14 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
return acceptedTransactions, nil
}
func isTXSpamming(transaction *externalapi.DomainTransaction) (int, bool) {
numOutsLessThanOneKas := 0
for _, output := range transaction.Outputs {
if output.Value < constants.SompiPerKaspa {
numOutsLessThanOneKas += 1
}
}
return numOutsLessThanOneKas, numOutsLessThanOneKas > len(transaction.Inputs)
}