A pull request on github for dynamic fee calculation was just submitted. How does this new dynamic fee calculation work?
According to the pull request from moneromooo-monero on behalf of ArticMine:
The dynamic fee is based on the block size in a past window, and the current block reward. It is expressed by kB. This function calculates an estimate for a dynamic fee which will be valid for the next grace_blocks
The fee will vary based on the base reward and the current block size limit: fee = (R/R0) * (M0/M) * F0 R: base reward R0: reference base reward (10 monero) M: block size limit M0: minimum block size limit (60000) F0: 0.002 monero
According to this recent study, there are some theoretical (but serious) security risks in situations where transaction fees exceed block rewards. (R/R0) will help keep fees in check by reducing them as block reward falls to buffer against this risk.
(M0/M) acts as a sanity check. When blocks are mostly empty it does not make sense to increase the cap. If the network (that previously had relatively empty blocks) is temporarily spammed in order to increase the block size limit, the network does not benefit so the (M0/M) will punish miners by reducing transaction fees. However when legitimate network usage increases over time the amount of increased transactions will compensate for the reduction in transaction fees as the block size cap scales naturally.
With regard to your spam attack tag and how this will change things:
Transaction fees will scale downwards on a per tx basis in the case of an increasing block size limit as the result of the "M" being larger in the (M0/M) part of the equation. However total transaction fees will increase overall as the number of transactions more than cancels out the reduced fee per tx. Spamming the network to increase the block size will remain expensive after this pull request is activated. In addition, for the reason described below such an impact on tx fees would only be temporary.
It is important to note that the (M0/M) portion of new dynamic fee calculation scales in both directions. Appropriate transaction fees differ based on network utilization which is capable of both increasing and decreasing due to countless unpredictable market factors. This new dynamic tx fee formula allows for both upwards and downwards tx fee scaling.
In the meantime, some more information has been presented here: