# Recreating Batch Balancer with Explicit proof fees Here we show to design an explicit proof fee mechanism that reproduces the network revenue dynamics we currently have from the batch balancer. This is not necessarily the goal of the explicit proof fee mechanism, as we may want not just to reproduce the status quo, but to improve on it. To model current network revenue will require certain assumptions, that would then be built into the explicit fee mechanism, which means it is not possible to exactly reproduce the current dynamics, but this is how we would go about approximating the current status through explicit fees. ## Modeling batch balancer revenue dynamics Let us consider one specific type of message at the moment, either PreCommit/PreCommitAggregate or ProveCommit/ProveCommitAggregate, which both function with the same batch balancer mechanism, so would be modeled the same way. In this section we want to model the following: **suppose there is a certain amount of demand to submit this particular proof, and a certain amount of demand for all other types of gas usage, then what is the resulting total network revenue?** For this type of message, we say there is an amount of demand $D^m_t$, at a given time (or epoch) $t$, which is the number of individual such messages that would be sent to be included on chain if it was free. We will sometimes avoid writing the time-dependence subscript explicitly, to simplify notation. This demand for number of messages, can be translated into a demand for gas usage if we know how much gas each message consumes. This part is tricky in that it depends on batch balancer dynamics. **We first explore a simplified model**, where there are only large SP's, that when batching becomes rational, would send the largest possible batches. We define the demand for gas usage as $$ D^g_t=D^m_t\cdot G(r)$$ Where $G(r)$ is the gas usage per message, which depends on the base fee, $r$. In this simple model we define $$G(r)=\left\{\begin{array}{ccc} g_1&{\rm if}&r<r^*,\\ g_2&{\rm if}& r\ge r^*.\end{array}\right.$$ where $g_1$ is the gas consumption of a single (unbatched) message, and $g_2<g_1$ is the gas consumption per message when the message is sent in the maximum sized batch. $r^*$ is the value of the base fee at which it becomes rational to batch (and we assume everyone suddenly maximally batches). Having the demand for gas usage $D^g_t$, if we assume a distribution of how much SP's are willing to pay for their gas usage, we can estimate how much gas makes it on-chain. Assume senders of this message follow a distribution $F_m(v)$, defined such that the percentage of messages that will be paid at a price per gas unit of $v$. Similarly, we lump together the rest of messages that will be part of the block, and model them as following a distribution $F_o(v)$. We suppose there is an external demand for gas for using other messages, $D_o$. Given this input, and the demand for the particular message, $D_g$, we can obtain both the corresponding equilibrium base fee, and block distribution. Assume a target block size, $B^T$, and assume the proof messages will occupy a fraction $a$ of the block, with $0\le a\le 1$ then we can compute the resulting equilibrium base fee $r$ and block distribution, $a$, by solving the following set of two equations: $$ \frac{aB^T}{D_g}=F_m(r+b(r)),$$ $$ \frac{(1-a)B^T}{D_0}=F_0(r).$$ We solve for $a$ an $r$ from these equations. Then from these we can compute the total network revenue. SP's that submit the proof most not only pay for the gas usage, but the batch balancer fee, if they choose to batch, and we are assuming they will maximally batch for sufficiently high base fee. We define the batching fee as $$b(r)=\left\{\begin{array}{ccc} 0& {\rm for}& r<r^*,\\ b_{\rm max}& {\rm for}& r\ge r^*.\end{array}\right.$$ Once we have these, the total network revenue is given by $$TNR=a*B^T(r+b(r))+(1-a)B^Tr$$ **To summarize**, in this section we found a mapping from:demand for number of proofs $D_m$, and demand for other gas usage $D_o$, to total network revenue, given the following assumptions: * Assume that all SP's maximally batch as soon as it is rational, and don't batch otherwise (this assumption will be softened in a later section). * Assume a distribution for how much SP's are willing to pay per unit of gas for this proof, and a separate distribution for how much users are willing to pay for other types of messages. ### Not all SP's maximally batch Suppose $r>r^*$, such that it is rational to submit proofs in the largest possible batches. In this section we will assume that the batching decision for each SP is less trivial. We assume each SP at that epoch wants to send $N$ proofs, where we draw $N$ out of some distribution of SP batch sizes, $$N\sim f_B$$ Given that an SP has $N$ messages to send, the gas usage per message will now depend not only on the base fee, but on the number of messages, so we define a mapping, $$ D^g_t=D^m_t\cdot G(r,N).$$ The function $G(r,N)$ now takes the form, $$G(r,N)=\left\{\begin{array}{ccc} g_1&{\rm if}&r<r^*_N,\\ g_2(N)&{\rm if}& r\ge r^*_N.\end{array}\right.$$ Where now the critical base fee $r^*_N$ depends on the number of proofs, whether it is rational to batch or not (this is dictated by the batch balancer specifications). The gas usage per message when batching, $g_2(N)$ will now also depend on how large is the batch. If we assume there is a demand in number of proofs, $D^m_N$ for SPs with $N$ of messages to send, $$D^g_N=D^m G(r,N)f_B(N)$$ The batch balancer fee paid also depends on the number of proofs sent by the SP, $$b(r,N)=\left\{\begin{array}{ccc} 0& {\rm for}& r<r^*_N,\\ b_{N}& {\rm for}& r\ge r^*_N.\end{array}\right.$$ The equations to map from gas usage demand $D^g, D^o$ to base fee and block distribution, look the same as before, but there is a unique equation for SP's with each number $N$, $$ \frac{a_NB^T}{D^g_N}=F_m(r+b(r,N)),$$ $$ \frac{(1-\sum_{N=1}^{N_{\rm max}}a_N)B^T}{D_0}=F_0(r).$$ Note this is now a system of $N_{\rm max}+1$ equations that need to be solved to obtain the base fee $r$, and the $a_1,\dots,a_{N_{\rm max}}$. The total network revenue is then given by $$TNR=B^Tr+B^T\sum_{N=1}^{N_{\rm max}}a_N*b(r,N)$$ ## Modeling explicit proof fees revenue dynamics ### Maximal batching simplified model Here we model network revenue in the case where when it is rational, we assume every SP maximally batches. Since we have removed the batch balancer mechanism, it is always rational in this case. We assume there is an external demand for sending the proof message, $D_m$. We assume each of this messages consumes an amount of gas $g_2$, so that $$D_g=g_2 D_m$$ We take the rest of the assumptions on value distributions from the previous sections We assume there is an explicit proof fee, we call $f$. The block distribution, $a_f$ and base fee, $r_f$ can be found by solving the equations again, $$ \frac{a_fB^T}{D_g}=F_m(r_f+f),$$ $$ \frac{(1-a_f)B^T}{D_0}=F_0(r_f).$$ we explicitly denote these with the subscript $f$, to differentiate from the results of the previous section. Total network revenue is then, $$TNR_f=a_f*B^T*f+B^Tr$$ **The condition that explicit fees reproduce the dynamics from the batch balancer, then means the requirement** $$r_f+a_f*f=r_b+a_b*b(r)$$ for every choice of $D_o,D_m$. We can use this to solve for $f$, to figure out what explicit fees we need to reproduce current dynamics. ### Not all SP’s maximally batch We again assume the number of messages that will be sent (always as a batch now) is drawn from some distribution, $$N\sim f_B.$$ We can now define the mapping from demand for messages $D_m$ to demand for gas usage, $D_g$, as $$D^g_N=D_m \cdot g_2(N)f_B(N).$$ where now we assume the messages will always be batched, regardless of base fee. We can then map from demand for gas usage, to equilibrium base fee and block distribution, $$ \frac{a^N_fB^T}{D^g_N}=F_m(r+f),$$ $$ \frac{(1-\sum_{N=1}^{N_{\rm max}}a_N)B^T}{D_0}=F_o(r).$$ Again, this is a system of $N_{\rm max}+1$ equations that need to be solved to obtain the base fee $r$, and the $a_1,\dots,a_{N_{\rm max}}$. The total network revenue is then given by $$TNR=B^Tr_f+B^T\sum_{N=1}^{N_{\rm max}}a_f^N*f.$$ If we want this result to reproduce the dynamics of the batch balancer, then we need to find an explicit fee, $f$, such that we satisfy, $$B^Tr_f+B^T\sum_{N=1}^{N_{\rm max}}a_f^N*f=B^Tr_b+B^T\sum_{N=1}^{N_{\rm max}}a^N_b*b(r,N).$$ Note that the answer we obtain here would necessarily depend on the assumptions of our model, such as the distributions, $f_b, F_M, F_o$. ## Batch balancer details $$C_s^n=g_s\cdot n\cdot r.$$ $$C_b^n=g_b^n\cdot r+{\rm BatchGasCharge}.$$ $$\gamma=5\,{\rm nanoFIL}$$ $$\frac{1}{d}=\frac{1}{20}$$ $${\rm BatchGasCharge}=\frac{{\rm Max}(\gamma,r)}{d}\bar{g}_s\cdot n.$$ $$r^*=\frac{\gamma}{d\left(1-\frac{g_b^{n_{\rm max}}}{g_s\cdot n_{\rm max}}\right)}$$ Denote current expected block reward for 1.5 years, as $R_{1.5}$ ### Asymptotes of explicit proof fees, Suppose the fee $f=xR$, is fixed as a proportion of the expected block rewards, $R$ We can place a higher bound $x_{\rm max}$ by reproducing what the batch balancer does at high levels of demand. $$x_{\rm max}=\frac{\gamma g_s}{d\,R_{1.5}}$$ which is the constant cost of the BatchGasCharge. For very low demand (for large negative net onboarding rate), the minimum asymptote would look like, $$X_{\rm min}=\frac{(g_s-(g^{n_{\rm max}}_b/n_{\rm max}))r}{R_{1.5}},$$ This is the cost of forcing users to send single messages, instead of more efficiently sending batch messages, The fee is the different in gas usage between single and maximally batched messages. We notice that this still depends on the base fee, so the actual minimum fee is when the base fee drops to its minimum, $$X_{\rm min}=\frac{g_s-(g^{n_{\rm max}}_b/n_{\rm max})r_{\rm min}}{R_{1.5}},$$ This would be our minimum proof fee, as onboarding rate goes to negative infinity. We also know what the proof fee should do at the criticial point, $r^*$ when there is enough demand that we start to allow batching. **We can choose to identify this with the case that net onboarding rate is zero.** We know what the proof fee looks like at this point, $$X_0=\frac{(g_b^{n_{\rm max}}/n_{\rm max})\gamma}{d^2\left(1-\frac{(g_b^{n_{\rm max}}/n_{\rm max})}{g_s}\right)R_{1.5}}$$ If we denote on boarding rate as $O$, it is convenient then to parametrize the proof fee in terms of the exponentiated quantity $$\omega=e^O,$$ We want $x(\omega)$, to be a function of $\omega$ such that, $$x(0)=x_{\rm min}$$ $$x(1)=x_0$$ $$\lim_{\omega\to\infty}x(\omega)=x_{\rm max}$$ We can parametrize this with a sigmoid function centered at $\omega=1$, $$x(\omega)=a\sigma(b\omega-1)+c$$ With the above constraints, we can solve for the parameters $a,b,c$, which gives us $$a=2(x_{\rm max}-x_{0}),$$ $$ b=-\sigma^{(-1)}\left(\frac{x_{\rm min}+x_{\rm max}-2x_0}{2(x_{\rm max}-x_0)}\right),$$ $$ c=2x_0-x_{\rm max}.$$