As some people have already noticed, there are many “spam” transactions in the network in the past few days. This has caused quite a few problems, including ChainDB size grows rapidly, nodes with small RAM fails to sync blocks and mine, etc.
The root cause of such “attack” is because transaction (txn) fee is zero. Currently the txn fee mechanism in NKN is fully decentralized and determined by the free market, similar to Ethereum: when miner is building a block, he will first pack txn with high txn fee (gas fee), and because miner can only include a certain number of txn (size) into a block, the txn fee will be dynamically determined by how many people are sending txn. This mechanism works well when there are many people sending txn on the chain, but NKN is still very young and there are not so many txn at the moment. As a result, most blocks contain only a few txn, and the market has determined that the txn fee should be zero at the moment. Apparently, someone took advantage of this free market decision and decided to spam the network.
Many people have asked us (the dev team) to “solve” the problem. Technically we can set a minimal txn fee in the code and stop the attack once for all, but then it becomes purely centralized, and we don’t want that.
But that does not mean there is no real decentralized solution. There is one way to solve the problem while still stay fully decentralized and free market determined price, but it requires your action, I mean EVERY one of you as a miner. See below for more information.
In v1.0.6-beta, we introduced a much more complete system such that each miner can set up the strategy about what txn fee can be accepted. In particular, there are 2 relevant parameters you can set in config.json
that can help resolve the current situation:
-
MinTxnFee
: this parameter controls the minimal txn fee your node will accept. The unit of this parameter is 10^-8 NKN, i.e. setting it to 100,000,000 means 1 NKN. We recommend setting this value to some moderate number first (e.g.10000000
, equivalent to 0.1 NKN per txn) and adjust it based on whether it’s effective. -
NumLowFeeTxnPerBlock
: this parameter controls at most how many low fee (less than MinTxnFee) txn your node will put into a block when it is the block proposer. We recommend setting this value to some small but positive number (e.g.4
) such that attack can be greatly reduced while existing awesome dapps (e.g. d-chat) can still work for free, and one-click miner can still remain one-click.
By default, both of these values are zero prior to v1.0.6-beta, which means zero fee transactions can still be sent freely. In v1.0.6-beta, the default values have been changed and baked in to prevent the spam attack. We suggest everyone upgrade to v1.0.6-beta as soon as possible in response to the attack and save everyone’s disk space.
All you need to do is to upgrade your node to v1.0.6-beta, and that’s all since the default values are already baked in the code to prevent spam attacks. And you can skip the last part of this article.
PS: upgrading or setting these values will NOT affect your chance of mining a block
Only for advanced users
Only if you want different values than the default ones and know what you are doing, you can manually set these 2 parameters in config.json
. In case you are not familiar with json format, here is an example you can copy and paste into config.json
(below is the default values, remember to change them to the ones you want):
"MinTxnFee": 10000000,
"NumLowFeeTxnPerBlock": 4,
You can put these 2 lines right after the BeneficiaryAddr
line so the beginning of config.json
looks like:
{
"BeneficiaryAddr": "XXXXXXX",
"MinTxnFee": 10000000,
"NumLowFeeTxnPerBlock": 4,
...