juanpmcianci
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Results on EIP1559, Part I: Theory. -- Juan Pablo Madrigal Cianci. ## Introduction This writeup is the first of a two-part series of articles that explores EIP-1559 and potential improvements from such a mechanism. In this part, specifically, we will focus on the mechanism's theoretical underpinnings and offer novel insights into its behavior, particularly in relation to the dynamic fee structure. While several works have explored the EIP1559 mechanism from an incentive design point of view (c.f.,[Roughgarden (2020)](https://timroughgarden.org/papers/eip1559.pdf)), there has been a gap in the literature when analyzing the dynamics that control such a mechanism. While not intended to be a scientific contribution, this article aims to close this gap. Specifically, the main contributions of this short writeup are: 1. We present a detailed mathematical exploration of EIP-1559's fee adjustment mechanism, highlighting its strengths and limitations and proposing potential refinements. 2. We introduce new insights into the stochastic processes underlying gas demand and block space usage. To the best of our knowledge, these results are original contributions extending the current understanding of EIP-1559. 3. We discuss how the base fee dynamics can be used to price gas fee derivatives, offering a framework for understanding risk and volatility in Ethereum's gas markets. In the second part of this series, we will explore and discuss several variations and potential improvements to such a mechanism, some of which have been discussed in, e.g., [Reijsbergen et. al (2022)](https://ieeexplore.ieee.org/document/9680496), [Diamandis et. al (2022)](https://arxiv.org/abs/2208.07919), [Madrigal-Cianci (2023)](https://www.youtube.com/watch?v=pRb1BSPZvRk&t=4346s), etc. ### Background EIP-1559, also known as the Ethereum Improvement Proposal 1559, was a major upgrade introduced as part of the London Hard Fork in August 2021. Its primary goal was to improve Ethereum's fee structure, address issues of unpredictability in gas fees, and enhance the user experience by implementing a new mechanism for handling transaction fees (c.f. [Roughgarden (2020)](https://timroughgarden.org/papers/eip1559.pdf)). Before EIP-1559, gas prices were set purely by an auction process, often leading to price volatility. EIP-1559 introduced a dynamic base fee model that adjusts based on network demand, alongside a "burn" mechanism that destroys a portion of the transaction fees, thereby reducing the overall supply of Ether (ETH) over time. **So, how does it work?** Just as cars require gas to run, on-chain transactions require gas to be run. This gas is to be understood as the cost of a unit of compute (or store) power—a finite, scarce resource. This base fee is to be understood as the minimum price (in native token) that users need to pay per gas unit for their transactions to be included in the block. Under the EIP1559 mechanism, the base fee evolves on a block-by-block basis according to the following formula: $$b_{t+1}=b_t\left(1+\phi \frac{G_t^\text{Used}-B^\text{target}}{B^\text{target}}\right),$$ Where $b_t>0$ The base fee in block $t$, $G_t^\text{Used}\geq 0$ is the amount of gas used in block $t$, $B^\text{target}$ is the target gas usage per block, which is a protocol-defined value, typically set to half of the maximum gas limit, ensuring flexibility to accommodate fluctuating network activity, and $\phi$ is a predefined adjustment factor, often referred to as the "step size," or "learning rate" that controls how much the base fee can change from one block to the next. Typically, $\phi$ is small, ensuring smooth adjustments. In the standard implementation of EIP-1559, $\phi=1/8$, $G_t^\text{Used}\in[0,\mathsf{Total\ Block\ Size}]$, and $\mathsf{Total\ Block\ Size}=2B^\text{target}$. As an effort to simplify notation, throughout these notes, we will write \begin{align} X_t&:=\left(\frac{G_t^\text{Used}-B^\text{target}}{B^\text{target}}\right), \end{align} where it can be seen from the discussion above that $-1\leq X_t\leq 1$, with $X_t\approx 1$ implying a very full block, $X_t\approx -1$ representing a very empty block at block $t$, and $X_t\approx 0$ representing a block that is around its target size. This, in turn, means that an empty block reduces the base fee in (1-1/8)=12.5%, and a full one increases it by 12.5%. **Remark**. Notice that the equation above can be seen as an approximation of the more general form \begin{align} b_{t+1}&=b_te^{\phi X_t}, \end{align} indeed, if we perform a Taylor expansion on the exponential, we get: $$b_{t+1}=b_te^{\phi X_t}=b_t\left(1+\phi X_t+\frac{(\phi X_t)^2}{2!}\dots\right)$$ which approximates the original formula for sufficiently small $\phi$. It is worth asking whether there is a specific advantage to using one over the other. The following section explores this in more detail. ## Analysis and Results This section consists of some analysis and (theoretical) results on the inner workings of the EIP1559 mechanism. Specifically, as a bridge from the previous section, we first dive deeper into the choice of the 1559 mechanism and then into the more theoretical results. While the core of our contributions is in the latter, we decided to keep the first for exposition and discussion. ### Linear vs Exponential? We begin this section with an in-depth discussion of the linear-vs-exponential EIP1559. :::info ::question:: - Is there any advantage to using one vs. the other? - Is there a specific rationale behind using the first-order approximation? ::: To the best of my knowledge, the network decided to go with the linearized model purely for simplicity; indeed, the linearized model is much more computationally cheaper to compute on-chain than the exponential. However, there are some disadvantages to using the linearized version. The most noticeable one is the fact that it is not symmetric. This is probably better explained with an example. Let's consider the case where, starting from a base fee $b_0$ t epoch 0, an entire block is sent at epoch 1, followed by an empty block at epoch 2. Beginning at some base fee $b_0$. In this setting, denoted by $b^\mathsf{e}$,$b^\mathsf{l}$ the exponential and linearized base fees, respectively, one has: \begin{aligned} b_2^\mathsf{e}&=b^\mathsf{e}_1e^{-\phi}=b^\mathsf{e}_0e^{-\phi}e^{+\phi}=b^\mathsf{e}_0, \quad \mathsf{and,}\\ b_2^\mathsf{l}&=b^\mathsf{l}_1(1-\frac{1}{8})=b^\mathsf{l}_0(1-\frac{1}{8})(1+\frac{1}{8})=b^\mathsf{l}_0(\frac{63}{64})<b_0^\mathsf{l}, \end{aligned} in this exercise, while the base fee returns to the origin in the exponential case, we are left with a smaller base fee than what we started with in the linearized case. This can, in turn, lend itself to the following behavior. **The Checkerboard strategy (I).** *Suppose a universe exists with one block proposer interested in keeping base fees as low as possible. If this is the only metric that block proposers care about, they will follow a *checkerboard* strategy, where they only fill even-numbered blocks and submit near-empty odd-numbered blocks.* Now, one could argue that this is a dumb argument since, in practice, no blockchain has exactly one block proposer. Let's refine this. **The Checkerboard strategy (II).** *In the same universe as above, suppose there are many other block proposers that could benefit from this strategy, where the $i$-th user has relative mining power $u_i$.* *If, in the long-term, their expected profit for including as few transactions as possible, together with having a small base fee, is larger than what they could expect from including a large number of transactions, they will be inclined to reduce the number of transactions to keep costs low.* Ok, there's the coordination issue, so it evens out. Right? **The Checkerboard strategy (III).** *This strategy is *weakly coordinated*; you don't need to explicitly conspire with others to implement it since the block numbers are the same for everyone. If enough users notice this so that $\sum_i u_i>0.5$, it is easy to show that the base fee will decrease to its minimum in the long term.* This could be a realistic risk for chains where (i) block proposers are incentivized to keep gas costs low, and (ii) block rewards + miner tips are small or non-existent. [Azouvi et. al (2023)](https://arxiv.org/abs/2304.11478) have performed a similar analysis to this. In particular, in their work the authors suggest using a moving average of the usages to mitigate similar attacks. An alternative (albeit related) idea is to use the exponential expansion to accommodate previous gas usages, i.e., setting: $$b_{t+1}=b_te^{\phi X_t}=b_t\left(1+\phi X_t+\frac{(\phi X_{t-1})^2}{2!}+\frac{(\phi X_{t-2})^2}{3!}+\dots\right),$$ truncated to an arbitrary number $J$ of terms as an update mechanism. ### Analysis of the Dynamics. In this section, we present analytical results regarding the dynamics of the base fee in EIP-1559. For simplicity, we will express the EIP-1559 mechanism in terms of the relative block usage $X_t$. We begin by noting the following assumption: **Observation 1**. As observed by $X_t$, demand does not follow a well-defined functional form concerning price, as defined by $b_t$. Observation 1 hints at a hidden, unknown, random process that drives the demand for block space. This process is only **partially observable** by the values of $X_t$.In essence, $Q_t$ represents the underlying demand for block space, which is inherently stochastic. This implies that $X_t$, which reflects block utilization relative to the target, is not a deterministic function of the base fee $b_t$. This behavior is evident from the empirical data shown below, where $X_t$ fluctuates unpredictably in response to changes in the base fee. ![image](https://hackmd.io/_uploads/r1YkGPuTC.png) **Figure 1.** Relative block usage $X_t$ vs. Base fee for Ethereum. This observation is formalized in result 1. #### Formalizing Observation 1. We begin with the following auxiliary result. **Claim 1.** Either one of these statements is valid. (i) *Users as an aggregate are perfectly inelastic* or (ii) *the sequence of random variables $\{X_n, \ n\in\mathbb{N}\}$ are statistically dependent of each other.* > **Proof claim 1.** Suppose that $\{X_n, n\in\mathbb{N}\}$ are statistically independent. Since $X_t$ is a proxy for demand as a function of price (and such a price evolves, as a formula, according to $X_t$), if the random variables $\{X_n, n\in\mathbb{N}\}$ are statistically independent of each other, then, one must have that they do not depend on the current price, that is: \begin{aligned} \frac{\mathrm{d}Q_t}{\mathrm{d} b_{t-1}}=0. \end{aligned} However, since elasticity $\epsilon$ is defined as \begin{aligned} \epsilon:=\frac{\mathrm{d}Q_t}{\mathrm{d} b_{t-1}}\frac{1}{Q_t}, \end{aligned} the reasoning above means that $\epsilon=0$, hence demand is perfectly inelastic. Furthermore, from Observation 1,2, we see that $\epsilon\neq 0$, which implies that the relative gas usages are dependent on each other. This is also easy to verify using a Ljung-Box test on any given sequence of relative gas usages. This, in turn, implies the following (rather obvious) result: **Result 1.** *In EIP-1559, There'sa given stochastic process dictates the evolution of $\{X_n, n\in\mathbb{N}\}$.* :::info :bulb: **Insight.** *The significance of Result 1 lies in the insight that the demand for block space in Ethereum is not independent of past demand. Understanding this dependency is crucial for modeling the base fee's evolution and developing strategies to predict and manage network congestion.* ::: #### Characterizing this process. Given that we now know that these random variables depend on each other and that some underlying stochastic process controls their evolution let's determine their joint distribution function. **Result 2.** Let $Y_t:=\phi\sum_{n=0}^tX_n$. In the exponential version of EIP-1559, the probability density function $f_{Y_t}$ that characterizes the evolution of the (finite-time) process $Y_t=\phi\sum_{n=0}^tX_n$ is given by \begin{align} f_{Y_t}=\mathcal{L}^{-1}\left[\mathbb{E}[b^s_{t+1}](s)\right](y_t), \end{align} with $\mathcal{L}^{-1}[\cdot]$ the *inverse Laplace Transform* operator. > **Sketch of proof result 2.** This stems from the observation that in the exponential 1559 case, one has, for any $s$, that \begin{aligned} \mathbb{E}[b^s_{t+1}]=\mathbb{E}\left[(b_0e^{\phi\sum_{n=0}^tX_n})^s \right]=b_0^s\mathbb{E}\left[e^{ Y_ts} \right], \end{aligned} Now, notice that the right-hand side of the equation above corresponds to the *Moment Generating Function* (MGF) of $Y_t$ parameterized by $s$, that is, \begin{aligned} \mathbb{E}[b^s_{t+1}]= M_{Y_t}(s)=\int_{-\infty}^{\infty}b_{t+1}^sf_{Y_t}(y)\mathrm{d}y, \end{aligned} which is the Laplace transform of $f_{Y_t}$ evaluated at $-s$, i.e., \begin{aligned} \int_{-\infty}^{\infty}e^{Y_t s}f_{Y_t}(y)\mathrm{d}y=:\mathcal{L}[f_{Y_t}](-s). \end{aligned} As such, taking the Inverse Laplace Transform on both sides gives \begin{aligned} \mathcal{L}^{-1}\left[\int_{-\infty}^{\infty}e^{Y_t s}f_{Y_t}(y)\mathrm{d}y\right](y_t)&=\mathcal{L}^{-1}\left[\mathcal{L}[f_{Y_t}](-s)\right](y)=f_{Y_t}(y)\\ &=\mathcal{L}^{-1}\left[M_{Y_t}(s)\right](y)\\ &=\mathcal{L}^{-1}\left[\mathbb{E}[b^s_{t+1}](s)\right](y). \end{aligned} **Corollary to result 2.** In the linear version of EIP-1559, the probability density function $\tilde{f}_{Y_t}$ that characterizes the evolution of the (finite-time) process $Y_t:=\sum_{n=0}^tX_n$ is approximated by $f_{Y_t}$ above. > **Proof.** Indeed, notice that in this case, we have \begin{aligned} \mathbb{E}[b^s_{t+1}]&=\mathbb{E}\left[b^s_0\prod_{n=0}^t(1+\phi X_n)^s \right]\\ &=b^s_0\mathbb{E}\left[\exp\left(s\log\left(\prod_{n=0}^t(1+\phi X_n) \right)\right)\right],\\ &=b_0\left[\exp\left(s\sum_{n=0}^t\log(1+\phi X_n)\right)\right]. \end{aligned} Now, since for $a\in(-1,1]$, we can write $\log(1+a)=\sum_{n=0}^\infty \frac{(-1^n)a^{n+1}}{n+1}$ (c.f. McLaurin Expansion), one then has that $\log(1+a)\approx a$ for small $a$. Applying this to the equation above gives: \begin{aligned} \mathbb{E}\left[b_0\exp\left(s\sum_{n=0}^t\log(1+\phi X_n)\right)\right]&\approx \mathbb{E}\left[b_0\exp\left(s\phi\sum_{n=0}^t X_n\right)\right]\\&=M_{Y_t}(s), \end{aligned} which is, once again, the moment-generating function of $Y_t$. The result follows by applying the same process as in the proof of result 2. :::info :bulb: **Intuition.** Result 2 is important because it allows us to precisely model the cumulative demand for block space over time under EIP-1559. By linking the base fee's expected value to the moment generating function (MGF) of gas usage, we can recover -- at least theoretically -- the full probability distribution of cumulative gas utilization. ::: In either of these cases, it would be interesting to see how well different numerical techniques can approximate such a PDF. This is a direction worth examining in future work. #### Base Fee as a Markov Process **Remark on notation.** *For any given random variable $z$, let $\pi(z)$ denote its Probability Distribution, and let $\pi(z|w)$ denote the probability distribution of $z$ conditioned on $w$. Notice that we are making a notational distinction between Probability Distribution ($\pi$), probability density ($f$), and probability of an event ($\mathbb{P}$).* We can model it as a Markov process to understand better how the base fee $b_t$ evolves. Let $b_{0:t}=\{b_0,b_1,...,b_t\}$. From the law of conditional probability: $$ \pi(b_t,b_{t-1}) = \pi(b_t | b_{t-1}) \pi(b_{t-1}), $$ which recursively becomes: $$ \pi(b_{0:t}):=\pi(b_t,b_{t-1},\dots,b_1,b_0) = \pi(b_t | b_{0:t-1}) \pi(b_{t-1} | b_{0:t-2}) \dots \pi(b_1 | b_0) \pi(b_0). $$ Now, assume, for the time being, that $\pi(b_t|b_{0:t-1})$ satisfies the Markov Property. This assumption is reasobale due to (i) the structural form of the base fee (as it only depends on the rpevious value) and (ii) because the driving random variable, $X_t$, has a fast decaying autocorrelation function, as shown below. This means, in particular, that the random process $X_{t}$ "forgets" its history quite fast. ![image](https://hackmd.io/_uploads/S17_ICe0C.png) This assumption gives us $$\pi(b_t|b_{0:t-1})=\pi(b_t|b_{t-1}).$$ This simplifies the equation above to $$ \pi(b_{0:t}):=\pi(b_t,b_{t-1},\dots,b_1,b_0) = \pi(b_t | b_{t-1}) \pi(b_{t-1} | b_{t-2}) \dots \pi(b_1 | b_0) \pi(b_0). $$ This means the probability distribution of the base fee at time $t$ depends **only** on the base fee at time $t-1$, and this relationship continues back in time. Further expanding, we get: \begin{aligned} \pi(b_t | b_{t-1}) &= \mathbb{P}\left(b_t \in A | b_{t-1} = \tilde{b}_{t-1}\right) \\ &= \mathbb{P}\left(\tilde{b}_{t-1}(1 + \phi X_{t-1}) \in A | b_{t-1} = \tilde{b}_{t-1}\right)\\ &= \mathbb{P}\left(X_{t-1} \in \underbrace{(\tilde{b}_{t-1}^{-1}A-1)\phi^{-1}}_\text{A'} | b_{t-1} = \tilde{b}_{t-1}\right)\\ &= \mathbb{P}\left(X_{t-1} \in A' | b_{t-1} = \tilde{b}_{t-1}\right) \end{aligned} Here, $X_{t-1}$ represents the relative block utilization, and $\phi$ is the EIP-1559 step size. Notice that here, we managed to express the evolution of $b_t$ in terms of block utilization $X_{t-1}$, conditioned on the previous base fee, $b_{t-1}$. This is crucial for two reasons: 1. The equation above induces a Markov kernel, $\nu(\cdot, \cdot)$, where for each $b_t$, $\nu(\cdot, b_t)$ is the probability distribution of $X_t$. Learning the mapping $b_t \mapsto \nu(\cdot, b_t)$ allows us to infer the hidden demand process, $Q_t$, revealing valuable insights about network demand. 2. With sufficient data on the evolution of $b_t$ and $X_t$, we can approximate $\nu$ for any given $b_t$. This opens avenues for using advanced techniques like Bayesian inference, deep learning (e.g., normalizing flows), or measuring transport to estimate demand patterns and gas usage. #### Sampling Algorithm for Base Fee Evolution Based on this framework, we can construct a simple algorithm to simulate the base fee evolution over time: ```python def sample_from_pi_bt(t, b_0, phi, nu): ''' t: Number of steps, b_0: initial base fee, phi: EIP1559 step size, nu: Markov kernel where nu.sample(b_n) returns a sample of X_n conditioned on base fee b_n ''' base_fees = [b_0] for n in range(t): b_prev = base_fees[-1] # Sample block utilization given the base fee Xn = nu.sample(b_prev) # Update base fee using the EIP-1559 formula bn = b_prev * (1 + phi * Xn) base_fees.append(bn) return base_fees ``` This algorithm helps us simulate the base fee's path over time by repeatedly sampling block utilization $X_t$ and adjusting the base fee accordingly. A figure depicting this is shown below. ![image](https://hackmd.io/_uploads/H1MK7JKTC.png) ### Applications of the Model By having access to $\pi(b_{0:t})$ at any time $t$, we gain several insights by estimating the probability of a given event occurring. Some of these include, for example: 1. **Predicting Future Base Fees**. We can estimate the probability of the base fee falling within a specific range at a future time $T$. 2. **Extremes of Base Fee**. This allows us to estimate the maximum or minimum base fees that we expect, providing useful information for users and validators. 3. **Computing Expectations**. With this model, we can compute expectations for various quantities of interest concerning the base fee path $b_t$. This is essential for tasks like Monte Carlo simulations. Here's a Python snippet that estimates an observable using Monte Carlo methods: ```python def Monte_Carlo_Computation(N, a, t, b_0, phi, nu): ''' N: number of Monte Carlo samples a: Quantity of interest as a function of base fee {b_n} t: Number of steps, b_0: initial base fee, phi: EIP-1559 step size, nu: Markov kernel where nu.sample(b_n) returns a sample of X_n conditioned on base fee b_n ''' samples = [] for _ in range(N): # Simulate one path of {b_t, t=0,1,..,T} path = sample_from_pi_bt(t, b_0, phi, nu) # Evaluate the observable as a function of the sampled base fee path samples.append(a(path)) Monte_Carlo_Estimate = mean(samples) Monte_Carlo_Error = std(samples) return Monte_Carlo_Estimate, Monte_Carlo_Error ``` <!-- Let us now look at the dynamics of $b_t$. Specifically, we would like to understand more deeply how $b_t$ evolves over time. Recall that, from the law of conditional probability, it follows that: \begin{aligned} \pi(b_{t})=\pi(b_t|b_{t-1})\pi(b_{t-1}). \end{aligned} Thus, applying this recursively, one gets: \begin{aligned} \pi(b_{t})&=\pi(b_t|b_{t-1})\pi(b_{t-1}|b_{t-2})\dots\pi(b_{1}|b_{0})\pi(b_0). \end{aligned} Notice, furthermore, that \begin{aligned} \pi(b_t|b_{t-1})&=\mathbb{P}\left(b_t\in A|b_{t-1}=\tilde{b}_{t-1}\right)\\ &=\mathbb{P}\left(\tilde{b}_{t-1}\left(1+\phi X_{t-1}\right)\in A|b_{t-1}=\tilde{b}_{t-1}\right)\\ &=\mathbb{P}\left(X_{t-1}\in \tilde{A}|b_{t-1}=\tilde{b}_{t-1}\right), \end{aligned} where $\tilde{A}:=\frac{1}{\phi}\left(\frac{A}{b_{t-1}}-1\right)$ is a translation of the set $A$. Notice then that the equation above expresses the dynamics of $b_t$ in terms of $X_{t-1}$ conditioned on the base fee at time $t-1$, given by $b_{t-1}$. This is important because of two reasons: 1. The last equation above induces a Markov kernel $\nu(\cdot,\cdot)$, where, for each $b_{t}$, $\nu(\cdot,b_{t})$ is the probability distribution of $X_t$. Thus, if one can learn the mapping $b_t\mapsto \nu(\cdot,b_t)$, one can identify this hidden demand process $Q_t$. This in itself is already quite a strong result. It also reveals lots of hidden information in the network. 2. Given sufficient data on the evolution of $ b_t$ and $ X_t$, one can construct an approximation of $ nu$ for any given $ b_t$. Furthermore, given multiple data-driven ways of estimating mappings, such as Bayesian inversion, and novel deep learning techniques, such as normalizing flows and measuring transport, this opens the door to multiple computational and analytical research venues. 3. It induces a simple algorithm to sample from $\pi(b_{t})$, starting at $b_0$, shown below: ```python= #Simple Python code to sample from pi(b_t) def sample_from_pi_bt(t,b_0,phi,nu): ''' t: Number of steps, b_0: initial base fee, phi: EIP1559 step size, nu: Markov kernel, where nu.sample(b_n) returns a sample from X_n conditioned on a base fee b_n ''' base_fees=[b_0] X=[] for n in range(t): b_=base_fees[-1] #samples block utilization given base fee, Xn=nu.sample(b_) # Evolves base fee using 1559, bn=b_*(1+phi*Xn) X.append(Xn) base_fee.append(Bn) ``` The key is to construct `nu` above, which can be approximated from data. 4. The algorithm above gives us access to $\pi(b_t)$ for any $t$, which in turn gives us plenty of information, as it allows us to compute (or more precisely, estimate) quantities of interest such as: - Estimating the probability that the base fee will be on a given range at a future time, $T$, - Estimating the maximum/minimum base fees that we could expect. - Among many, many more. 5. Lastly, since we have access to $\pi(b_t)$ for any $t$, we can use this to compute expectations of arbitrary quantities of interest concerning the price path of $b_t$. This can be done via, e.g., Monte Carlo methods, as explained below: ```python= #Simple Python code to estimate E_pi[a;t] def Monte_Carlo_Computation(N,a,t,b_0,phi,nu): ''' N: number of samples in the Monte Carlo avg. a: Quantity of Interest, as a function of base fee {b_n} t: Number of steps, b_0: initial base fee, phi: EIP1559 step size, nu: Markov kernel, where nu.sample(b_n) returns a sample from X_n conditioned on a base fee b_n ''' samples=[] for n in range(N): #Simulates one path of {b_t, t=0,1,..,T} path_n=sample_from_pi_bt(t,b_0,phi,nu) #evaluate the observable as a function of the sampled base fee sample_n=a(path_n) samples.append(sample_n) Monte_Carlo_Estimate=mean(samples) Monte_Carlo_Error=std(samples) return Monte_Carlo_Estimate, Monte_Carlo_Error ``` --> This can be used as a mechanism for pricing gas derivatives, as discussed below. ### Application. Derivative Pricing We conclude this first part by applying the theory and methodology derived so far: a method for pricing base fee derivatives. Our approach relies on the *Equivalent Martingale Measure* (EMM) and the *Efficient Market Hypothesis* (EMH). #### Pricing with Equivalent Martingale Measure (EMM) The EMM is a tool used in financial mathematics to price derivatives by ensuring that the discounted price of a derivative is a martingale under a particular probability measure. According to the *Martingale Pricing Theory*, the fair price of a derivative depends on the expected value of its future payoff under this Martingale measure. This concept aligns with the Efficient Market Hypothesis, which assumes that all available information is already reflected in asset prices, making it impossible to achieve above-market returns without additional risk. So, how does this work in practice? Suppose we have a *claim* on the base fee that achieves a payoff $\psi(b_T)$ after some time $T$. Given some risk-free interest rate $r$, it follows from the martingale pricing theory that the value $V(\psi)$ of such a claim at time 0 is given by: \begin{aligned} V(\psi(b_0)) = e^{-rT} \mathbb{E}[\psi(b_T)]. \end{aligned} We can then use the Monte Carlo methodology described in the previous section to approximate $\mathbb{E}[\psi(b_T)]$. **This is where the strength of our methodology comes in.** **Example: Vanilla European Call Option.** Let's consider a simple example: a vanilla European call option on the base fee with a strike price of $K$. This contract gives the holder the option, but not the obligation, to pay $K$ in base fees at expiry time $T$. This option would be useful if you anticipate a period of high network congestion and want to ensure you don't pay more than $K$ in base fees. At time $T$, if $b_T > K$, the option is worth $b_T - K$ (the savings you realize). Conversely, the option is worthless if $b_T < K$, as you can send a transaction for a lower price. The payoff function $\psi(b_T)$ is thus given by: $$ \psi(b_T) = \max\{b_T - K, 0\}. $$ The value of the option at time 0 is then: $$ V(\psi(b_0)) = \mathbb{E}\left[e^{-\int_0^T r(u) du} \max\{b_T - K, 0\}\right], $$ where $r$ is the potentially stochastic risk-free rate; since the base fee is denominated in ETH (or gwei), this risk-free rate must use ETH as a numéraire, which implies that it should be, e.g., the staking rewards rate. The expectation can be approximated using Monte Carlo methods, as described earlier. <!-- We conclude this first part by applying the theory derived: a methodology for pricing base fee derivatives. Our methodology is based on the Equivalent Martingale Measure and the Efficient Market Hypothesis. Suppose we have a *claim* on the base fee that achieves a payoff $\psi(b_T; T)$ after some time $ T $. Given some *risk-free* interest rate $r$, it then follows from Martingale Pricing Theory that the value $V(\psi)$ of such a claim at time 0 is given by $$V(\psi(b_0))=e^{-rT}\mathbb{E}[\psi(b_T)].$$ Let's consider several examples. Notice that we are not concerned with the enforceability of such claims but rather with their pricing. **Example.** Consider a vanilla European call option for the base fee with strike $K$. This contract gives its holder the opportunity, but not the obligation, of paying $K$ in base fee at some expiry date $T$. This is useful, for example, if you believe there's a period of high network congestion and you would like to not pay more than $K$ in base fee. If at time $T$, $b_T>K$, this option is worth $b_T-K$ (since this is how much you save). On the other hand, if at time $T$, $b_T<K$, the option is worthless since you can send a transaction for a lower price than $K$. This means that $\psi(b_T)=\max\{b_T-K,0\}$ and as such: $$V(\psi(b_0))=\mathbb{E}\left[e^{-\int_0^T r(u)du}\max\{b_T-K,0\}\right],$$ where we have used $r$ as the potentially stochastic risk-free rate, notice that since the base fee is denominated in ETH (or gwei), this risk-free rate must use ETH as a *numéraire*; this expectation can then be approximated using Monte Carlo methods, as explained above. --> Notice that the same methodology could be used to price more complex instruments, such as American options (which can be exercised at any time $t\leq T$). **Remark.** A similar methodology is presented by the [here](https://ethresear.ch/t/pricing-gas-fee-derivatives/19898) by the [Oiler network team](https://docs.oiler.network/oiler-network/products/pitch-lake); however, their approach consists of fitting specific time-series models to the dynamics of the base fee $b_t$, which can then, in turn, deviate from the *actual* expectation under the *accurate process*. Our methodology is more robust because it builds upon an approximation of the actual dynamics behind the base fee, which are, in turn, computed in a less opinionated way. ## Closing Remarks and Future Directions. In this writeup, we have provided an in-depth analysis of EIP-1559's dynamics, focusing on its mathematical foundations and introducing novel insights into the stochastic processes driving gas demand. We examined the mechanism's fee adjustment formula, explored the distinction between its linear and exponential forms, and proposed potential refinements that address certain weaknesses in the linear approach. Our analysis demonstrated the dependency between gas usage in consecutive blocks, leading to a better understanding of the hidden stochastic demand process. This allowed us to derive a probabilistic model for the cumulative gas utilization and base fee evolution over time, highlighting its importance for predicting gas prices and estimating volatility. We also proposed a method to simulate the base fee as a Markov process, opening the door for more accurate predictions of future fee paths. Additionally, we extended this theoretical framework to practical applications by proposing a methodology for pricing gas derivatives. Through examples like a vanilla European call option, we illustrated how the base fee's stochastic behavior can be leveraged to hedge against future network congestion risks. Our approach, grounded in Martingale Pricing Theory, offers a robust alternative to time-series models commonly used in gas derivative pricing. These results provide a foundation for practical applications in derivative pricing and future research into improving Ethereum's fee dynamics. In the second part, we will explore further refinements and potential improvements to the mechanism to address some of the weaknesses identified in this work. #### Potential Research Directions Future work could focus on developing better numerical techniques for approximating the joint probability distributions we derived, particularly for more complex stochastic processes governing gas demand. In addition, it is worth exploring how incorporating additional network data, such as miner tips or block rewards, can improve the accuracy of our base fee evolution models. Moreover, alternative fee adjustment formulas—such as moving averages or more complex dynamic feedback mechanisms—could lead to more efficient and stable gas pricing models, particularly in high-volatility environments. This is a research direction that we plan to tackle in Part II. ## References. 1. [Reijsbergen et. al (2022)](https://ieeexplore.ieee.org/document/9680496). *Reijsbergen, Daniël, et al. "Transaction fees on a honeymoon: Ethereum's EIP-1559 one month later." 2021 IEEE International Conference on Blockchain (Blockchain). IEEE, 2021.* 2. [Diamandis et. al (2022)](https://arxiv.org/abs/2208.07919). *Diamandis, Theo, et al. "Dynamic pricing for non-fungible resources: Designing multidimensional blockchain fee markets." arXiv preprint arXiv:2208.07919 (2022).* 3. [Madrigal-Cianci (2023)](https://www.youtube.com/watch?v=pRb1BSPZvRk&t=4346s). *Madrigal-Cianci, Juan P. "Gas in the Filecoin Network: Modeling and Uncertainty Quantification". CryptoEconDay @ ETH Denver (2023) (Talk).* 4. [Roughgarden (2020)](https://timroughgarden.org/papers/eip1559.pdf) *Roughgarden, Tim. "Transaction fee mechanism design for the Ethereum blockchain: An economic analysis of EIP-1559." arXiv preprint arXiv:2012.00854 (2020).* 5. [Azouvi et. al (2023)](https://arxiv.org/abs/2304.11478) *Azouvi, Sarah, et al. "Base Fee Manipulation In Ethereum's EIP-1559 Transaction Fee Mechanism." arXiv preprint arXiv:2304.11478 (2023).* <!-- ## Some analysis. What information can we extract from it? - Download gas info on-chain ```sql= SELECT block_number, block_timestamp, size, transaction_count, gas_used, base_fee_per_gas FROM `big query-public-data.goog_blockchain_ethereum_mainnet_us.blocks` WHERE TIMESTAMP_TRUNC(block_timestamp, MONTH) >= TIMESTAMP("2023-01-01") ``` - Data Analysis - Model Fitting - Simulation - Extracting hidden demand ## Pros and cons: Why use it? ## Can we Improve it? ### A Generalized formula - advantages - Issues: - dishonest mining in ETH - weakly coordinated attacks in, e.g., Filecoin ### Multi-dimensional EIP1559 and resource pricing. - Main Idea - Resources ### Adaptive mechanisms ### Other methodologies - Blobs? Multi-Components? ## Conclusions and further research. - Relation to blob markets - What can we use with this? ## References

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully