The SLOAD gas cost problem
On April 14th 2021, at blockheight 12,244,000, the Ethereum network had the Berlin hard fork that included the EIP-2929. This “improvement” was a contentious increase of gas costs for “op code” transactions which are transactions that require the SLOAD computational operation that reads data from the blockchain. This is not the first increase in gas costs. The first SLOAD cost increase occurred in October 2016 with the EIP-150 (from 50 to 200 gas). The second increase came with the EIP-1884 in December 2019 (from 200 gas to 800 gas), right at the time when HEX launched. The last increase in the Berlin forked caused the final increase to 2600 gas, thus a 52-fold increase in cost since Ethereum exists.
The reasoning behind the gas cost rise is based on a concern that inexpensive SLOAD allows spamming the network causing a denial of service issue. However, this is a hypothetical attack, furthermore near impossible during a bull market when the gas price goes to insane levels and such spamming would be immensely costly. Furthermore, the SLOAD computation is needed by any contract that depends on reading data from the blockchain, which is any serious smart contract with business related logic.
Ethereum is a blockchain network where network services are paid in Ether (ETH) by the users in two ways.
The first way is a direct payment of the transaction fee which is paid according to the simple equation: transaction fee = gas price × consumed gas. This fees are paid to prevent the spamming of the network and are thus inevitable.
The second way is trough ETH supply inflation where miners maintaining the network pay themselves by minting block rewards. These rewards are paid regardless of the network usage – they are actually redundant under conditions of full network adoption. The miners need to sell block rewards to pay for the electricity, hardware and other overhead costs associated with the Proof of Work (PoW) consensus mechanism. This causes constant down pressure on the price of the network utility token ETH that devalues the holdings of the users in a bear market, or suppresses price appreciation in a bull market.
The fees on the Ethereum network are auction based, meaning that users bid the gas price and miners give priority to the highest bids. However, blocks have limited space. The block size is measured in gas consumed for the included transactions, which is currently limited to 30 million gas per block (Block Gas Limit). However, there is a throughput bottleneck that in times of network congestion causes backlogs. This causes an inflation in gas prices when users and bots start biding higher and higher to out-compete each other for block space.
Computational operations on the Ethereum blockchain network cost gas (gas is unitless). Each low-level operation has a predefined gas cost that is part of the network consensus and can only be changed by forking. These operations can be as simple as ADD, SUB or MUL, which add, substract or multiply two integers. Or they can read blockchain data such as BALANCE or SLOAD, which retrieve the balance of an address, or reads other data from the blockchain database. There are also more complex operations that are much more costly, such as CREATE.
Some standard operations, like sending ETH have a fixed gas cost (currently 21,000). Sending ERC-20 tokens requires an interaction with a smart contract and costs more (currently up to 65,000). Below is a list of gas costs for some common types of transactions (randomly taken from the blockchain data).
HEX stake start: 62k-95k
HEX endstake: 2310 × days staked + 53694 (online calculator)
Uniswap v2 USDC/HEX: 112k
Uniswap v3 USDC/HEX: 133k
Uniswap v3 ETH/USDC/HEX: 190k-196k
Uniswap v3 ETH/HEX: 100k-160k
Matcha USDC/HEX: 122k
1inch ETH/HEX: 156k-173k
1inch ETH/USDC/HEX: 235k
Metamask swap: 216k
Polygon/Ethereum bridge: 295k
Remove liquidity ETH/HEX: 142k-177k
HEX transfer: 19k-65k
Users can set a gas limit for their transaction. This value sets a cap on how much ETH is allocated to pay the fee. Miners can’t withdraw more fee than the gas limit, and they can’t withdraw all of the allocated when the actual consumed gas is lower. Setting the gas limit higher is thus inconsequential, as long as there is enough ETH available in the account. Setting the gas limit lower causes an “out of gas error” which is a situation where the miners took the pending transaction, performed some of the required operations, but run out of gas before completing them. As part of the consensus, they are entitled to take the incomplete fee as a compensation.
What is important regarding gas limit, therefore, is that you can increase it, but do not decrease it unless you absolutely know better than the wallet estimate on how much gas the transaction truly takes.
This is important in case of network congestion or bidding low on the gas price. For example, this can cause the endstake transaction delay for days. Since the endstake gas consumption depends on the days staked, the transaction can run out of gas if the approval is delayed for days. This can cost a lot in fees. To prevent the “out of gas” error, it is best to increase the gas limit for a few percent (e.g., 10%).
Disclaimer: None of the above is meant to be a financial advice. Never rely on a single source of information and do your own research before any investment. Don’t trust, verify!
If you found any of the above useful and want to give a tip, please use the Ethereum address: 0x4BaE10B7B20A4f92670f03474dbDD6716D2C143f