Past & Future of Gas on Ethereum

Introduction to the origins, evolution, and potential multidimensional future of the transaction-cost model on Ethereum mainnet

Takens Theorem
Etherscan Blog
9 min readJun 5, 2024

--

I screen captured this moment; from Etherscan in 2022

Origins

The concept of “gas” originated in Ethereum’s famous white paper, written by Vitalik Buterin in 2014. The paper defined the concept of gas as a protective mechanism, to help with runaway computation or to avoid denial-of-service (DoS) attacks. To accomplish this, gas acts as a transaction-cost model associated with computation and data usage.

Visual fusion of white and yellow papers in Ethereum’s history; details here

The unit cost for gas is a running price in “gwei,” with a gwei equal to 1/10⁹ of one ether. When you transact on Ethereum, you compute how much gas you need (your transaction’s compute and data), then calculate your fee by multiplying the gas price in gwei by that gas amount (plus a potential priority fee). This invokes a cute metaphor. When you transact on Ethereum, you “pay for gas.” Your transaction can “run out of gas” and error out.

Downsides of this metaphor are obvious. It can be the subject of unfortunate puns. More seriously, the metaphor could also cause misattribution of Ethereum’s operation as “burning gas” (e.g., see here). At the time of this writing, this misunderstanding would be especially unfortunate: Since fall 2022, Ethereum’s energy requirements dropped by several orders of magnitude due to proof-of-stake consensus (“The Merge”).

These simplistic metaphors for “gas” conceal its most important complexity. As Ethereum has evolved from hard fork to hard fork, a major issue has been the gas market: how transaction pricing gets determined by the Ethereum network at any given time. Gas not only protects from runaway computation and DoS attacks. It also prices transactions based on demand. If more people use Ethereum, the network is more popular, then those participating in consensus are rewarded. The cost can keep rising, throttling network use until demand cools off.

Record-breaking gas spike during the NFT bull market; source: Etherscan

From a protocol-design standpoint, several factors can affect how this gas market fluctuates. For example, block size imposes a constraint on how much compute and data usage can go into the network as a unit of time. On Ethereum at the time of this writing, we get a block committed each 12 seconds. Block space gets filled with particular commands that user transactions require. These commands, OPCODES, may call data from memory or update memory and so on. Gas is determined by how these commands are assembled for each transaction, and optimizing for gas cost has become an art form itself.

History to Today

Over the years, Ethereum has made big changes in these dynamics. Some changes involved altering cost of OPCODES or changing allowable block size.

Among Ethereum’s biggest changes is upgrading to a gas-market dynamic that is much more predictable. Early Ethereum involved a “wild west” market demand model, pricing was set unsystematically (but stabilized from the collective supply and demand of miners and users). After the “London” upgrade in summer 2021, Ethereum now has an explicit mathematical formulation that adjusts gas prices (now known as “base fee”) from block to block based on demand.

EIP-1559 is beautiful; see T. Roughgarden’s lovely technical report.

The 2021 London upgrade was very successful. The gas pricing mechanism (technically yet fondly known as “EIP-1559”) worked quite well, stabilizing gas prices once implemented. Blocks ticked along, and users eventually came to appreciate the smooth predictability of this pricing mechanism.

Gas price across London; image by the author, shared back in 2021

This upgrade in London became the basis for parts of the “Dencun” upgrade from a just few months ago this year. We summarized the Dencun upgrade in a recent post here. The major change to this upgrade is that it introduced a new and separate transaction-cost model: data blobs and blob fees. These blob fees have a market dynamic like the one in London (summarized by Vitalik nicely here), and helped make transacting on Ethereum’s second layers (L2s) cheaper (see here for a summary of L2s).

In other words, there are now two fee markets on Ethereum. The main one, gas from Ethereum’s first days, is now priced with EIP-1559. The second, a data storage market on consensus layer, is priced with the same formalism (but tuned to blobs of data).

Dencun had an immediate impact. Cost of transacting on L2s plummeted. Though cause may be debated, a corresponding drop in gas price occurred on Ethereum’s main network (“mainnet”). Indeed, for much of last month in May 2024, it was not uncommon to see single-digit base fee for gas, even on weekdays when usage usually causes spikes.

Gas today, at the time of this writing; happy day; it may yet rise again!

The implementation of these changes has been for the most part astoundingly smooth and elegant. Even major recent upgrades to Ethereum — like altering its entire transaction-cost model — have been implemented with no interruption to Ethereum’s block production. So what other protocol innovation could be on the way?

The Future?

I create digital objects on Ethereum. Expressions of our space, aesthetically driven by data. Some of my projects are on chain, and required intensive gas expense to encode and implement these projects. I became quite sensitive to gas price changes, especially in September 2021 when the so-called “Loot” derivatives erupted. I wrote about it here with 0xKofi, with some gas price analysis.

From article co-authored with 0xKofi on NFT Now.

The plot above shows a little piece of events in September 2021. An NFT project would be released. In a mania, users would descend upon it. The pricing dynamic would erupt, causing gas base fee to spike. I recall some frustration at being throttled myself and I wondered, “What could tune this market dynamic?”

One thought I entertained was that we could “fractionate” or split up the gas pricing mechanism to be multivariate by specific use. You might weight gas prices somehow, maybe by transaction type or by project? “Loot has lots of demand; let Loot users absorb that cost,” I thought at the time. Consider a mall metaphor. Imagine shoppers descending on a mall. But the shops are not equally interesting. Some are more popular than others. Ethereum’s pricing mechanism could be based on a simple temporal window that stores how popular a given “shop” (contract) is. Seems sensible at first. Maybe you’ll get throttled (high gas price) to get into Apple; at the Container Store, maybe less so.

This model won’t work; see text.

This won’t work. This is because block builders can choose what transactions to include. So there could be a destabilizing dynamic as price rises for some contracts and not others; builders might ignore the less interesting contracts, slowing all transactions in favor of Loot derivatives.

Another approach is not to fractionate gas expense by local usage, such as contract, but rather by network resource. A network resource, when throttled, evenly influences everyone. Indeed, this is what Ethereum did in Dencun. A certain kind of data availability (as it’s called) is now its own market, separate from the original compute and data storage on mainnet. Cost of transacting is now two dimensional.

In a recent post, Vitalik Buterin makes this idea explicit. The reasoning here is that Ethereum’s main pricing for gas combines compute and data in one composite calculation. Because of this, just enough compute and just enough data together can raise a transaction to exceed permissible expense. This can be true even if compute and data individually is under their respective limits. This excludes invalid blocks of transactions shown in Vitalik’s graph here, shown in “Problem 1.”

From post “Multidimensional gas pricing” by Vitalik

Decoupling dimensions of gas use has the benefit of focusing a transaction expense in proportion to a user’s desired network resource. Another example that Vitalik considers is the growth of the Ethereum network state itself. Much as the blob market is tuned to blobs, and gas to compute/data, pricing state accumulation (like adding a new contract) could be priced in its own ideal fashion. Vitalik puts it this way:

“This shows one of the powerful properties of multidimensional gas: it lets us separately ask the questions of (i) what is the ideal average usage, and (ii) what is the safe per-block maximum usage, for each resource. Rather than setting gas prices based on per-block maximums, and letting average usage follow, we have degrees of freedom to set parameters, tuning each one based on what is safe for the network.” (his emphasis)

His post then goes into some detail about how this could work, focusing on implications of the maximum boundaries (horizontal and vertical lines) shown in the diagram above. These boundaries suggest that a check of the maximum demanded resource would work to keep total resources within these bounds: max(resource 1, resource 2, …, resource k). An approach like this could provide a workable heuristic to implement multidimensional gas in an EIP-1559-like scheme. Vitalik compares it to an interesting recent EIP, EIP-7623, which proposes something quite related by setting transaction data cost based on a decoupling of a transaction’s compute vs. data requirements.

What could this mean for users, developers, other stakeholders? Vitalik argues that a more complex scheme like this is extensible, tunable, adapting to the needs of the network and users in interesting ways. Vitalik ends the post, “do we accept somewhat more ugliness at the EVM level, in order to safely unlock significant L1 scalability gains, and if so, which specific proposal works best for protocol economics and application developers?”

The scalability here would come from throughput increases associated with each “decoupled resource” of multidimensional gas. By decoupling resources that were before mutually constrained, it can proportionally free up network resources on the basis of a model for protocol design and user need. He talks about many challenges to such a model. Not the least of them would be application and wallet developers who’d have to adapt to such promising ugliness.

I love these ideas about multidimensional gas because they take the core concept in Ethereum — its transaction-cost model — and devise a multidimensional specification that is, in the abstract, the very design process for a cryptocurrency protocol in general. What are our dimensions, what constraints should be impose? Where are costs in compute, centralization, data load, etc., incurred? This is an innovative discussion, but in some ways it’s a reframing of the originating questions of designing trust-minimized, decentralized ledgers in general.

Back in early 2021, I shared a very simple little illustration of this:

Conclusion

Vitalik’s post invited some constructive critique. Ethereum team lead Péter Szilágyi raised a concern that increasing the degrees of freedom and therefore the complexity of these resource constraints in the mempool for transactions creates many more ways in which specialized actors may capitalize upon this complexity. This could increase risk of centralization and censorship. Nevertheless, the history of gas and its potential future give further credence to the Ethereum community as one willing to embrace bold economic and technical experimentation.

I’m on X and on Farcaster. I create things and write other things and very much welcome you to check out my wares here. I wrote this for free and for fun. I sometimes own things I mention.

--

--

Takens Theorem
Etherscan Blog

Dynamic distributed data displays. Intermittent. Friendly.