Spam Protection

From NEM Wiki
Jump to: navigation, search

NEM uses localized spam protection. It is activated after all blocks have reached full capacity and only the accounts producing spam are affected. The spamming accounts have their transactions fees increasingly raised in relation to the spam they produce. They therefore can still spam, but it increasingly costs more in proportion to their spam volume. At the same time normal accounts in the network keep their low transaction costs.

Method

When a new transaction is created and delivered to a node, the node

1. Puts the transaction into its unconfirmed transaction cache

2. Broadcasts the transaction to other nodes (if the transaction is valid) There is also a poll mechanism for unconfirmed transactions during each block chain synchronization round. This allows nodes that do not have their port 7890 open (and therefore cannot receive broadcasts) to learn about new unconfirmed transactions. Low transaction fees might tempt some bad actor in the network to flood the network with new transactions in order to disturb the network. It is therefore needed to limit the number of unconfirmed transactions which are handled by the nodes.

Simply limiting the number of unconfirmed transactions that a node accepts is bad because normal actors still should be able to send a transaction even when someone is spamming the network. Limiting the number of unconfirmed transactions per account is also not an option since the attacker can create as many accounts as (s)he wants. NEM does filtering in a smarter way. A custom spam filter decides whether a new unconfirmed transaction should be processed or rejected. It works the following way:

• Consider the unconfirmed transaction cache as having 1000 slots

• As long as less than 120 slots are filled, no transaction is rejected

• Otherwise if there are already fs filled slots and a new unconfirmed transaction with signer A arrives, the fair share of slots for account A in the cache is calculated as

// Need to install mathjax and type this up again.

If A occupies less slots than its fair share, the new unconfirmed transaction is accepted. Note that you can increase the chance that your new transaction is accepted by voluntarily increasing the transaction fees.