--- tags: eip1559, sharding --- # Shard fee market ## Current implementation, no missing blobs For shard $s \in S$, there is a series of `sample_count` $G_1, G_2, ...$ and a target sample count per slot equal to $T$, for every slot $k \in K$. After $G_4$ is realised, given basefee $b_0$, we compute the new basefee $b_4$ (basefee after 4th slot) as: $$b_4 = b_0 \times g(\frac{G_1}{2T})\times g(\frac{G_2}{2T})\times g(\frac{G_3}{2T})\times g(\frac{G_4}{2T})$$ where $g(x) = (1 + \frac{x - 0.5}{d'})$, $x \in [0,1]$ is how full the block is (0 = empty, 1 = full), and $d' = e \times w \times d$ - $e = 32$, epoch size - $w = 4$, window size - $d = 8$, adjustment parameter After $G_5$ is realised, we compute $b_5$ as: $$ \begin{aligned} b_5 & = b_4 \times g(\frac{G_2}{2T}) \times g(\frac{G_3}{2T}) \times g(\frac{G_4}{2T}) \times g(\frac{G_5}{2T}) \\ & = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T})^2 \times g(\frac{G_4}{2T})^2 \times g(\frac{G_5}{2T}) \end{aligned} $$ After $G_6$: $$ \begin{aligned} b_6 = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T})^3 \times g(\frac{G_4}{2T})^3 \times g(\frac{G_5}{2T})^2 \times g(\frac{G_6}{2T}) \end{aligned} $$ After $G_7$: $$ \begin{aligned} b_7 = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T})^3 \times g(\frac{G_4}{2T})^4 \times g(\frac{G_5}{2T})^3 \times g(\frac{G_6}{2T})^2 \times g(\frac{G_7}{2T}) \end{aligned} $$ After $G_8$: $$b_8 = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T})^3 \times g(\frac{G_4}{2T})^4 \times g(\frac{G_5}{2T})^4 \times g(\frac{G_6}{2T})^3 \times g(\frac{G_7}{2T})^2 \times g(\frac{G_8}{2T})$$ etc. $G_n$: $$b_n = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T})^3 \times \Big[ \prod_{k = 4}^{n-3} g(\frac{G_k}{2T})^4 \Big] \times g(\frac{G_{n-2}}{2T})^3 \times g(\frac{G_{n-1}}{2T})^2 \times g(\frac{G_n}{2T})$$ (for the first 3 slots, you could do - $b_1 = b_0 \times g(\frac{G_1}{2T})$ - $b_2 = b_1 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})$ - $b_3 = b_2 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T}) \times g(\frac{G_3}{2T})$ then you'd get the "clean" formula $$b_n = b_0 \times \Big[ \prod_{k = 1}^{n-3} g(\frac{G_k}{2T})^4 \Big] \times g(\frac{G_{n-2}}{2T})^3 \times g(\frac{G_{n-1}}{2T})^2 \times g(\frac{G_n}{2T})$$ ) ### Exponential version The multiplicative form of basefee update is an approximation of the exponential function ($\exp(x) ~ 1+x$ for $x$ small). We look at properties of the exponential version, $b \leftarrow b \exp(\frac{G_k - T}{d' T})$ **All blocks full for one epoch:** $$b \leftarrow b \Big[ \exp(\frac{2T - T}{d' T}) \Big]^{w \times e} = b \exp(w \times e \times\frac{1}{e \times w \times d}) = b \exp(\frac{1}{d})$$ **Basefee formula:** We use the "clean" formula $$ \begin{aligned} b_{k+1} & = b_k \exp(\frac{G_{k-3} - T}{d'T}) \exp(\frac{G_{k-2} - T}{d'T}) \exp(\frac{G_{k-1} - T}{d'T}) \exp(\frac{G_{k} - T}{d'T}) \\ & = b_k \exp(\frac{G_{k-3} + G_{k-2} + G_{k-1} + G_{k} - 4T}{d'T}) \\ & = \dots \\ & = b_0 \exp\Big( \frac{4 \cdot \sum_{\ell = 1}^{k-3} [G_\ell - T] + 3 \cdot [G_{k-2} - T] + 2 \cdot [G_{k-1} - T] + [G_k - T]}{d'T} \Big) \end{aligned} $$ ## Missing blobs There is a window of $W > w$ slots for an expected blob to appear. While a blob is missing, it is not counted in the `sample_count` of its slot. Suppose a blob that should fill 20% of slot 3 only arrives by slot 5. Then: $$b_4 = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T}) \times g(\frac{G_3}{2T}) \times g(\frac{G_4}{2T})$$ but $$ \begin{aligned} b_5 & = b_0 \times g(\frac{G_1}{2T}) \times g(\frac{G_2}{2T})^2 \times g(\frac{G_3}{2T}) \times g(\frac{G_3}{2T} + 0.2) \times g(\frac{G_4}{2T})^2 \times g(\frac{G_5}{2T}) \end{aligned} $$ For a block at slot $k$, we denote $G^{(1)}_k, G^{(2)}_k, ..., G^{(w)}_k$ the size of the block evaluated at the end of the slot for the basefee update ($G^{(1)}_k$), at the end of the next slot for the next basefee update ($G^{(2)}_k$), etc, until the slot after window size $w$ ($G^{(w)}_k$). With the exponential formula (assuming $w = 4$): $$ b_{k+1} = b_0 \exp\Big( \frac{\sum_{\ell = 1}^{k-3} \sum_{w' = 1}^w [G_\ell^{(w')} - T] + \sum_{w' = 1}^{w-1} [G_{k-2}^{(w')} - T] + \sum_{w' = 1}^{w-2} \cdot [G_{k-1}^{(w')} - T] + [G_k^{(w')} - T]}{d'T} \Big) $$ Note that $G_k^{(w')} \leq G_k^{(w'')}$ for $w' \leq w''$: while a blob has not been published, it is counted as zero in the block size, hence the block size can only grow over the window size. For our purposes, this could be problematic. Denote by $K(k, w)$ all the pairs $(\ell, w')$ over which we are summing in the expression above, for $1 \leq \ell \leq k$ and $1 \leq w' \leq w$ (it's almost all the pairs in that domain, except for the last few $\ell$'s, where the full window size hasn't been applied yet). We want the long-term average of block sizes to be $T$, so if $G_\ell^{(w)}$ is the final size of the block at slot $\ell$ (because a blob published after $w$ is ignored), then we want to have $$\frac{1}{|K(k, w)|} \sum_{(\ell, w') \in K(k, w)} G_\ell^{(w)} \sim T$$ By the exponential formula above, we know that we will have: $$\frac{1}{|K(k, w)|} \sum_{(\ell, w') \in K(k, w)} G_\ell^{(w')} \sim T$$ We know this fact for the same reason we know that basefee in 1559 moves such that the average gas used by a block is close to 15M gas (even if in reality, a little more than that due to the imbalance of the multiplicative approximation of the exponential, but the deviation is bounded). So since we know $G_k^{(w')} \leq G_k^{(w)}$ for all $w' \leq w$, we also know that $$T \sim \frac{1}{|K(k, w)|} \sum_{(\ell, w') \in K(k, w)} G_\ell^{(w')} \leq \frac{1}{|K(k, w)|} \sum_{(\ell, w') \in K(k, w)} G_\ell^{(w)}$$ In other words, the average block size should find itself higher than the target block size, as a result of basefee underpricing a resource that eventually appears. This would not be an issue if accounting for the presence of a blob was done after $W$ slots, past the time where we know for sure that if the blob hasn't been published, it won't be published in the future either (or it will be ignored if published). ## What we want out of the fee market / Efficiency Assume for now that there is only room for one blob per slot, and builders compete on price to be included. All blobs are fixed size. Either the block has a blob in it, and we apply $g(1)$ to the price, or the block doesn't have a blob, and we apply $g(0)$. A shard blob builder may claim to send a blob of size $G$, but eventually fail to do so. It is their turn to send from slot $k$. If the blob isn't received by $k+W$ (question: what is $W$ ?), then the blob is considered missing. The price for blob sender at $k+1$ is determined by the blob sizes in previous slots, given the formula above. Yet if a blob between $k+1-W$ and $k$ is missing, we are "overcharging" the user at $k+1$ for the space they claim then. We need to define "overcharging" better to get a sense of what we mean, but to do so, we need to find out the market price of the blob at $k+1$. There is a demand for blob space, such that to be included at slot $k$ a builder $u$ is willing to pay $v(u, k)$. Often we simplify such that the time preference of the builder is nil, in which case we look at $v_u = v(u)$. If all builders always send their blob truthfully, and there is a set of builders $M(k)$ waiting to be included at slot $k$, we should include the builder with the highest value among all builders $v^{(1)}$ and the builder should pay something like the second-highest value $v^{(2)}$. The market price is then $v^{(2)}$. When a builder ends up not publishing their blob, there is an efficiency loss. Assuming the defaulting builder had the highest value for the blob, they paid $v^{(2)}$ and received no value. If the defaulting builder didn't exist, builder with value $v^{(2)}$ would have published their blob, for cost $v^{(3)}$, receiving payoff of $v^{(2)} - v^{(3)}$ instead of 0. ## Questions - How should we think about the value for inclusion of builders? Are they indifferent w/r/t the shard they publish to, or do they have preference for one/a set of shards over all others? Is there a mix of both types in the population of builders? - How should we think about builders' preference for time? In the execution layer fee market, we know there are some users who don't have time preference vs some who have (DEXes, drops, etc.) We sort of expect the second class to have either some inclusion guarantee by increasing their max priority fee (e.g., for Uniswap transactions) or sophisticated strategies (for NFT drops). The fee market could be such that often, basefee undershoots and tip auctions reappear, but given these two profiles of users who have time preferences, it seems that should it be the case that basefee is too low, those who might suffer for it already plan ahead, so there isn't much of a risk of tip auctions affecting other classes of users. That means we could be fine with basefee moving "too slowly" (more price precision, but also more latency).