# FIP-0064

Title | Add Parameters to Base Fee Mechanism |
---|---|

Author | Guy Goren |

Discussions-To | https://github.com/filecoin-project/FIPs/discussions/686 |

Status | Draft |

Type | Technical (Core) |

Created | 2023-06-05 |

## Spec Sections

# FIP-0064: Add Parameters to Base Fee Mechanism

The first part of this discussion

## Simple Summary

Add a time based weighted averaging of the block sizes for the base-fee calculation. Specifically, the weights correspond to a geometric series.

## Abstract

The current formula for setting the base fee follows the original EIP-1559 (with minor adaptions to fit a tipset setting): \(b[i+1]\triangleq b[i] \cdot \left( 1+\frac{1}{8} \cdot \frac{s[i]-s^* }{s^* }\right)\) where $i$ enumerates the epoch, $s^*$ is a predetremined block size (the “desired” size), $b[i]$ is the base fee at epoch $i$, and $s[i]$ is the average size of a block in the tipset of epoch $i$. This formula considers only the average block size $s[i]$ from the last epoch. This mechanism might lead to incentives for users to bribe miners in order to reduce the base fee or, in an analogous manner, for miners to collude with sophisticated users for the benefit of both. (See Motivation section.)

We propose to consider the history of block sizes via a time weighted average with a geometric sequence as the weights. In particular, we suggest the following update rule: \(b[i+1]\triangleq b[i] \cdot \left( 1+\frac{1}{8} \cdot \frac{s_{\textit{avg}}[i]-s^* }{s^* }\right)\) where $s_{\textit{avg}}[i]$ is defined by \(s_{\textit{avg}}[i] \triangleq \frac{1-q}{q}\sum_{k=1}^{\infty} q^k\cdot s[i-k+1], \hspace{1cm} q\in (0,1).\)

## Change Motivation

This change serves to reduce bribe motivation in the case that demand for blockspace becomes high due to FVM (see Incentive Considerations section). Additionaly, this change will reduce oscillations and support a more stable fee setting mechanism.

Following the FVM launch, and as activity ramps up, we should prepare for increased competition for block space. This may lead to previously negligible incentive misalignments becoming more significant.

For determining which messages enter a block, Filecoin uses a mechnism that was proposed in EIP-1559. This mechanism introduced a base fee, which is a portion of the transaction fee that is burned and not awarded to miners, and which varies according to the fill rate of blocks. A target block size is defined, such that if a block is fuller than the target size, the base fee increases and if it is emptier, the base fee reduces.

Research on the subject (focused on ethereum) have revealed issues with this transaction fee mechanism. It has been shown to be unstable in certain cases. Moreover, it has been shown that the dynamic nature of the base fee, which is influenced by the fill rate of blocks, opens the door for manipulation by both miners and users. The desired behavior of the system under stable, high demand is for it to reach an equilibrium where the base fee – $b$ – is the significant part of the gas fee and the tip is relatively small – denoted $\varepsilon$ (for reference, Ethereum often has $\frac{b}{\varepsilon}\approx 20$). According to Roughgarden this is a rational equilibrium under the assumption that miners do not think ahead. However, we expect a miner to optimize its behavior by also considering its future payoffs. In essence, since neither the miner nor the user are getting the burnt fee, by colluding they can both tap into the burnt fee for a win-win situation for them both.

A theoretical work describes how both miners and users can initiate an attack. For example, we can imagine that users who wish to pay lower costs will coordinate the attack. Roughly, a user (or group of users) that has transactions with a total $g$ amount of gas bribes the miner of the current block (no matter the miner’s power) to propose an empty block instead. The cost of such a bribe is only $\varepsilon \times {s^* }$ – the tip times the target block size. Consequently, the base fee reduces in the next block. If we accept that EIP1559 reaches its goals, e.g., users would typicaly use a simple and honest bidding strategy of reporting their maximal willingness to pay plus adding a small tip ($\varepsilon$), then in the honest users’ steady state, gas proposals leave the miners with an $\varepsilon$ tip. Given that other users are na"ive (or slow to react), our bribing user will include its transactions with any tip larger than $\varepsilon$ – making the attack profitable whenever $g \frac{b^* }{8} >s^* \varepsilon$.

## Specification

The following equation describes the main part of the change, that is, replacing $s[i]$ by $s_{\textit{avg}}[i]$. For $q\in (0,1)$,

\[s_{\textit{avg}}[i] \triangleq \frac{1-q}{q}\sum_{k=1}^{\infty } q^k\cdot s[i-k+1]\]which simplifies to the recursive form \(s_{\textit{avg}}[i] = (1-q)\cdot s[i] + q\cdot s_{\textit{avg} }[i-1].\)

This scheme is parametrized by $q$ which determins the concentration of the average. Roughly, smaller $q$ values result in $s_\textit{avg}$ resembling the very last block sizes, while larger $q$ values smoothen the average over a longer history.

### Additional info

EIP-1559 allows for a variable block size, but a valid block size must be in the range $s[i]\in[0,2s^*]$.

Unlike Ethereum, Filecoin determines the value of $s[i]$ not by a single block’s size but by the average size of a block in the previous tipset. This affects the issue from both sides. On the positive side, the averaging reduces the profitability of bribing a single miner. On the negative side, given the possibility to choose different tipsets to build ontop, a rational miner might be incentivized to choose the “emptier” tipset in order to reduce the base fee for its current block, thus affecting both the present and future.

## Design Rationale

An intuitive option for the Transaction Fee Mechanism (TFM) that adjusts supply and demand economically is *First price auction*, which is well known and studied. Nevertheless, in Filecoin the choice was to use EIP-1559 for the TFM. In this proposal, our design goal is to improve the TFM (of EIP-1559) by mitigating known problems that it raises. It is important to note that these problems do not yet impact the Filecoin network. If Filecoin gains traction, however, this problem is likely to emerge. We may want to prepare for this beforehand.

The full suggestion is actually composed of two parts: (i) using an average over epochs of block sizes rather than only the latest, and (ii) using an adaptive learning rate. The first part is the basis of the proposal. The second is only an additional improvement (that depends on the first part being implemented). This FIP, therefore, discusses only the first part and leaves the second part for a later time.

### $s_\textit{avg}[i]$ instead of $s[i]$

The change is based on this work that described a rational strategy in which bribes are profitabe. Choosing to average based on a geometric series weights results in two desired properties: (i) the computation and space complexity are both in O(1), and (ii) the average gradually phases out the impact of a single outlier block without causing significant fluctuations in the base fee.

## Backwards Compatibility

This change requires a hard fork since the base fee is enforced (for blocks to be considerd valid).

## Test Cases

Too early to say

## Security Considerations

The more complicated a mechanism is, the more it is vulnerable to unforseen security threats. EIP-1559 describes only one potential mechanism. Though we hope to mitigate risks to this mechanism, unforeseen risks could yet emerge over time.

## Incentive Considerations

The proposal is designed to improve the incentive compatability of the TFM. A game theory analysis shows that a TFM based on EIP-1559 encourages bribes. Roughly, because the base fee in the next block depends on the size of the the current block, a miner that creates an empty block reduces the base fee of the next block by a factor of $\frac{1}{8}$. The opportunity cost for mining an empty block instead of a normal block is only the tips it contains. Thus, the cost of bribing a miner is only compensating it for the lost tips. In case the base fee is significantly larger than the tips, the bribing user gains a siginificant reduction in the base fees of the next block, making the bribe profitable.

One of the main goals of EIP-1559 was to simplify the bidding for users. It was articulated theoreticaly by Roughgarden as users bidding their honest valuations being an optimal strategy. In contrast, when using first price auctions for the TFM (as done by Bitcoin and previously in Ethereum), it is typically sub-optimal for a user to bid its honest valuation. In other words, a TFM that encourages users to not fully reveal their preferences is considerd less good. However, one may argue that a TFM that encourages bribes is worse than a TFM that encourages not revealing one’s full preferences.

Although a first price auction is a safe bet regarding TFMs, Filecoin chooses to use EIP-1559 and burn transaction fees (perhaps for reasons other than game-theoretic ones). We therefore suggest to mitigate the current incentives for bribes using the above proposal.

## Product Considerations

Beside mitigating the incentives for bribes, we see another potential benefit from a product perspective.

- The new averaging mechanism would reduce spikes and extreme oscillations of the base fee.

The above should lead to a better user experience. For example, with this proposal, it would be less likely for an SP to be surprised by an outrageous base fee exactly when it wants to post its proofs.

## Implementation

None currently.

## Copyright

Copyright and related rights waived via CC0.

## Citation

Please cite this document as:

Guy Goren, "FIP-0064: Add Parameters to Base Fee Mechanism [DRAFT]," *Filecoin Improvement Proposals*, no. 0064, June 2023. [Online serial]. Available: https://fips.filecoin.io/fips/fip-0064.