Most of the pos chains use a simple model where the txns(short for transactions) are chosen based on whether the block proposer wants to include the txn and earn the fee from the executed computation which seems to be a good enough model for most days until something big event comes along like a hyped nft mint or some hft bots see an arbitrage opportunity filling up blocks of spam executions because when a lot of people are willing to give huge wads of money to interact with the same state it drives up gas prices for everyone. There is one very cool way Solana has worked on it.
Solana Fee Model (the easy way)
Solana has a different fee model than Ethereum, while in Ethereum transaction fee is calculated by the blockspace covered which treats all interactions the same but Solana has an accounts model.
In accounts there are two types of instructions read and write. Whenever there is an interaction the user has to pre-define the states its program/contract is gonna touch and only interacts with that piece of that state, not the whole chain which makes it easier to read the same state for as many users as possible.
But when many parties try to write to the same state the fees spike only impacts that specific program and not the whole fee market on the Solana network which keeps the normal users who wanna interact with other states safe from higher fees. It isolates the impact on that specific state. Solana is able to execute this because it is one of the first chains to introduce parallel execution & multithreading with global state management
.
With this change having different gas fees for every contract forms a local fee market kinda like paying different amounts of money for groceries at different places. If you live in a posh neighborhood (big-name mint) then you are probably willing to pay more for groceries but that should not impact how other people pay for their groceries. Defi contract interactions take a lot of blockspace and when the contract which mints/swaps tokens is not optimized for gas consumption there are problems leading to the network being totally unusable for a normal user. I have myself paid upwards of $5 fee for just a simple swap(in bear market) while I could literally buy 4 meals for myself with that kinda money. Most days 15% of the eth gas is paid while using uniswap which other claim could be reduced if the contract was more gas efficient.
Eth gas fee usage as of 8th march 2023
Gas fee is a necessary evil
One of the biggest advocates for gas fees is that it prevents spam transactions and prevents attackers from filling up the blockspace as high gas fees would cost more to interact. Solana transactions being the cheapest(as a user) there is a huge risk of getting the system DDos ed from attack vectors, it’s not important the spammer might have bad intentions. HFT seems like a juicy opportunity in a fast & cheap system like Solana but one of the biggest problems faced is that these HFT(high-frequency trading) bots could fill blockspace with txns and deny user transaction execution for a long time. One of the ways to solve this is->
Application fee
As most of the programs that receive spam are either defi smart contracts or mint contracts, with the implementation of the base fee and application fee, devs will be able to incorporate fees that everyone would have to pay in order to interact with the smart contract and that fee could be refunded if they actually end up interacting.
This would penalize the behavior of bad transactions who just want to check liquidity and front-run normal users.
what if the transaction is urgent?
One of the proposals/updates has allowed priority execution of a program with a higher fee. This would not have a direct effect on the global fee markets but will drive the validator profits making it more attractive to run a Solana node. Validators try to optimize for
- \((additional\ fee+base\ fee)/Compute-units\)
But What if many agents are willing to pay high fees to access the same state? wouldn’t that fill the blockspace?
Nope because all the txns are sequential and at once only one agent can access the state and the amount of time that a block can spend on a single state/thread is capped so that whenever there is a spike for a specific program, all the transaction will be serialized, executed one by one its amount won’t affect regular transactions. A Solana block is capped at 48 million compute units where the max amount a single program can use is 12 million or 1/4 of the total blockspace.
one of the biggest improvements in the fee markets could be when Firedancer goes mainnet, with the FD's block pre-packing algo
it will be able to map the amount of compute units a transaction is going to take making it easier for validators to calculate it beforehand and package the block more efficiently.
I am not sure even Ethereum’s rollup-centric roadmap could pull this off cause the fee model + structure will still be the same, rn rollups cost nearly 50 cents for a transaction while Upi in India costs nothing and works a lot faster than eth so we really need to think whether we are actually solving problems or working on pseudo-problems, especially with the recent blowup in the talks of zkevm and app chains.
Ps: This will be a series of blog posts lining up some of the technical advancements made by solana which for some reason no one is talking about right now.
Big shout out to Jacob and Joe for keeping up with all my dumb questions!
Resources used →
One of the best 🧵
Eli5 thread by anantoly on the feemartkets and the new improvements
https://github.com/solana-labs/solana/issues/21883
https://github.com/solana-labs/solana/issues/23211
https://github.com/solanalabs/solana/blob/master/docs/src/proposals/fee_transaction_priority.md
https://github.com/solana-foundation/solana-improvement-documents/pulls
An amazing piece by Jito Labs