Setup Dynamic Fees

This recipe outlines how to setup a delegate to accept dynamic fees. We'll outline differences between the various dynamic fee configuration settings and explore how they can be used to run an efficient and economical node.

Find Your Config Directory

First things first, you need to find your config directory. If you installed Ark Core using Commander, you can typically find this folder at ~/.ark/config/.

The file we'll access from this folder is network.json. If you see it, you're in the right place.

Edit Your Dynamic Fee Constants

Your node needs to signal to the network that it accepts dynamic fees. For this, open up your network.json file:

nano ~/.ark/config/network.json

There are two separate settings here worth configuring: the dynamicFees constants, which can be found under the constants key, and the dynamic fees themselves.

You can use dynamic fee constants to alter how the dynamic fee formula is applied in your Ark Core node. The fees config key in your constants section should look like this:

{
    "fees": {
        "dynamic": false,
        "dynamicFees": {
          "minFeePool": 1000,
          "minFeeBroadcast": 1000,
          "addonBytes": {
            "transfer": 100,
            "secondSignature": 250,
            "delegateRegistration": 500,
            "vote": 100,
            "multiSignature": 500,
            "ipfs": 250,
            "timelockTransfer": 500,
            "multiPayment": 500,
            "delegateResignation": 500
          }
        },
    }
}

Notice the first two keys in the dynamicFees object: minFeePool and minFeeBroadcast.

The minFeePool value represents the minimum fee in Arktoshi per byte a transaction should have to be included in the configured node's transaction pool. Similarly, minFeeBroadcast represents the minimum fee in Arktoshi per byte a transaction should have in order to be broadcast to peers for possible inclusion elsewhere in the network. Differentating between these two values can allow forgers to filter out low-fee transactions from their nodes without rejecting them from the network altogether.

Below minFeeBroadcast you'll find the addonBytes object, which sets byte values to be added onto specific transaction types when calculating fees. The minimum fee calculation adds this addonBytes value to each transaction's length in bytes before multiplying by the node's arktoshi-per-byte value:

const calculatedFee = (addonBytesValue + transactionSizeInBytes) * arktoshiPerByte

Edit Your Dynamic Fees

If you're interested in changing your dynamic fees, the configuration you want to edit is near the bottom of your network.json file. It has two keys, height and fees, which look like this:

{
    "height": 10,
    "fees": {
        "dynamic": true
    }
}

The dynamic keys in fees tells us whether or not dynamic fees should be enabled, and the height key tells the node at which network height the policy should take effect. The default configuration, as shown above, enables dynamic fees from height 10 onwards. If we were to change dynamic to false, the node would instead disable dynamic fees from height 10 onwards.

Change Your Transaction Pool Size

It is also possible to alter the economic tradeoff of dynamic fees by altering the max size of your transaction pool. The behavior specified in the ARK_MAX_TRANSACTIONS_IN_POOL environment variable takes effect once the pool hits the specified number of transactions.

Once that happens, your node checks the fee of each incoming transaction and only includes them in its pool of forgable transactions if the incoming fee is greater than the smallest fee currently in the pool and evicts the smallest fee transaction from the pool in order to obey the cap defined by ARK_MAX_TRANSACTIONS_IN_POOL.

Note that, as fee transactions are only executed upon block creation, removing a transaction from the pool in this manner does not result in a charge to the "losing" transaction.

By default, the max transaction pool size is set to 100000. To change this value, edit your .env file:

ARK_MAX_TRANSACTIONS_IN_POOL=1234567

Restart Your Node

With a node restart, your dynamic fees should be working as intended. Feel free to test this using the utilities in core-tester-cli following the process in the tester cli recipe.

Last Updated: 12/7/2018, 1:25:28 AM