[null, null, {"document_url": "https://monero.stackexchange.com/questions/4562/how-does-the-dynamic-blocksize-and-the-dynamic-fees-work-together-in-monero", "unformatted_src": "https://i.stack.imgur.com/gP3Sz.png", "src": "https://i.stack.imgur.com/gP3Sz.png", "formatted_filename": "gP Sz", "alt_text": "Block Reward Penalty"}, null, {"document_url": "https://monero.stackexchange.com/questions/4562/how-does-the-dynamic-blocksize-and-the-dynamic-fees-work-together-in-monero", "unformatted_src": "https://i.stack.imgur.com/aUHFb.png", "src": "https://i.stack.imgur.com/aUHFb.png", "formatted_filename": "aUHFb", "alt_text": "enter image description here"}, null, null, null]


How does the dynamic blocksize and the dynamic fees work together in Monero?


This mechanism is unique to Monero because it's the only cryptocurrency to have both blocksize and transaction fee dictated by an algorithm, how was this achieved and what is the rationale behind such system?

transaction-fees mining-theory dynamic-blocksize-limit block-reward spam-attack
asked Jul 11 '17 at 17:11 

up vote 8 down vote accepted

In addition to the excellent summary by ArticMine already given, here below is shortened & updated version of my research on the topic.

Dynamic Blocksize Penalty

This is the penalty which will be subtracted from the block reward. In practice it means that whenever a penalty is triggered, the start of tail emission will be slightly postponed (it will start later to "give back" the penalized amount), and once tail emission kicks in it will be an effective coin burn because the block emission will no longer depend on current emission as it will be fixed at 0.6 monero per 2-minute-block, as explained by ArticMine.

It can be written as:

P = R * (W - 1) ^ 2,

where P is the dynamic blocksize penalty (monero), R the block emission (monero), and W the blocksize expansion factor (unitless).

The expansion factor is W = B / M where B is the blocksize (kB) of the examined block, and M the blocksize median of previous 100 blocks (kB). For example, an expansion factor of 1.10 means a 10% increase so if the median is 300kB, the expanded block would be 330kB.

At its simplest form, it could be rewritten as:

p = (W - 1) ^ 2

where p = P / R, and can be called relative blocksize penalty (unitless).

For example, blocksize increase of 20% above the median would mean 4% (= 20 ^ 2 / 100%) penalty, increase of 40% would mean 16% (= 40 ^ 2 / 100%) penalty, regardless of the actual value of current median and block emission. This is always true, and easy to remember.

Note that there are no arbitrary constants. The only special treatment is for M < M_0, where M_0 is the minimum penalty-free blocksize, presently at 300kB. The function of this is to prevent unwanted edge cases, too high fee/TX and allow some number of transactions to fit in a block regardless of the current median. While it is a constant, it will become irrelevant once M is stable above it due to regular network use.

To illustrate, imagine if there were 100 empty blocks. The median would be 0 and nobody could transact since there's a hard cap at 2 * M and 2 * 0 == 0. For this reason, M_0 is introduced and used in place of M until M > M_0, allowing normal functioning of the network even after times of no or minimal use. Once the network grows big enough, the median will likely never drop below M_0 and it will become completely irrelevant.

The relationship can also be observed in the below chart. Dynamic Neutral Fee Formula

This is the fee (monero / kB) needed to compensate the penalty for a given blocksize increase. It can be written as:

F_n = (R / M) * (W - 1).

where R, M and W have been defined above.

We can also express the fee in relative terms normalized to size of block median:

f_n = (W - 1),

where f_n = (F_n * M) / R.

This means that if there are transactions in the TX-pool offering such fee with which the total fees in a 100% full block would be some % of current block emission, the miner could increase the block for the same % and earn the same block reward.

We can plot the relationship for various f_n, as seen below. Wherever the parabolas cross the x-axis, is the point of neutral blocksize increase. The "sweet spot" is the tip of each parabola, where the miner would earn the maximum possible for a given fee. These are joined by a curve called the optimum curve. For any given TX-pool state, a miner should arrange his block such that it lies as close as possible to that curve.

The current dynamic minimum fee is the curve for f_n = 1.2% which is arbitrarily chosen. It could be any other. It matches priority = 1 in the wallet setting. This means that if everyone offered the minimum fee, miners would still have incentive to increase the blocksize up to 1.2% if the TX-pool is full.

Practical Consequences

answered Jul 11 '17 at 22:36 
I posted on BCT back in 2016 some of the basics: https://bitcointalk.org/index.php?topic=753252.msg13591241#msg13591241

The penalty paid by the miner is equal to the block reward multiplied by the percentage increase of the blocksize over the median squared. This is the Cryptonote penalty function which is present in all Cryptonote coins. There are important consequences for this.

1) A rational miner will not pay any additional penalty unless she is compensated for the penalty loss in fees

2) A rational miner will order transactions in order of profitability so it is the least profitable transaction that is used to test the penalty

3) 1 and 2 mean that the miner profits from the penalty and consequently has an incentive to keep the blocksize small.

4) The law of supply and demand will keep the total amount of fees per block in a range that over time is proportional to the block reward. The position in the range is determined by the demand for transactions vs price in fees to overcome the penalty.

5) There is an effective coin burn in order to increase the block size or to maintain a block size over the minimum.This occurs because there is no refund for mining a block smaller then the median. This coin burn occurs because during the regular emission, the onset of the tail emission is delayed, and during the tail emission the penalty coins are not replaced.

6) A spam attack to bloat the Monero blockchain becomes economically equivalent to a 51% attack.

4 above is critical. It caps the total fees per block to a range that falls with the emission. This means that if the emission falls to zero so do the fees and the coin becomes insecure. It means that Cryptonote coins, such as Bytecoin, that do not have a tail emission will eventually become insecure, since their fees all also fall to zero. It also means that scaling proportions that have a less severe penalty than in Monero or no penalty will also makes a coin without a tail emission such as Bitcoin insecure. A good example of this is Bitcoin Unlimited.

4 also allows the creation of dynamic fees in Monero by setting the per byte fees to be proportional to the block reward divided by median blocksize. This allows for the setting of fee levels that correspond to various points in the penalty or how much penalty the sender is willing to pay in order to get her transaction mined.

In order for the dynamic blocksize to work one needs both the penalty and the tail emission. One cannot add a Monero style penalty on a permanent basis to coins such as Bitcoin, Litecoin, Ethereum Classic or Dash. It could be added with some risk for a fixed number of blocks by requiring the the block reward be over a certain threshold in order the adaptive blocksize to operate. It could be added to coins such as Ethereum or Dogecoin because they have a tail emission; however to my knowledge this has not been done. A much weaker scaling requirement as was done in Ethereum could fail to a spam attack, as could adding something like Bitcoin Unlimited to Dogecoin.

Source: ArticMine

answered Jul 11 '17 at 17:11 
Not the answer you're looking for? Browse other questions tagged transaction-fees mining-theory dynamic-blocksize-limit block-reward spam-attack or ask your own question.


How does the dynamic fee calculation work?
Transaction fees are very high for small transactions
Are there any fair strategies to dynamically adjust the transaction fee?


How will transaction fees be calculated after RingCT?
Does Monero use replace-by-fee?
Is it viable to attack Monero by artificially bloating blocks and make it harder to run a full node due to the increased blockchain burden?
How much does Mymonero take as fees per transaction?
How do fees affect tx priority and how did these specific high fee tx's sit unconfirmed for > 1hr
Will a large and sustained increase in Monero transactions resolve the current issues of the dynamic block size penalty function?
How to calculate exact Monero transaction fee?
Why are Monero fees visible?

