ArkDev.wrld | NFT Worlds

ArkDev.wrld | NFT Worlds

01-05-2022

05:07

I'm going to break down what happened with the @OthersideMeta mint and HOW and WHY it could have went way smoother with proper gas optimizations. Get ready, this is a long one. Let's dive in and start with some proper context on how transactions and gas works...

When you submit a transaction to the Ethereum network, in this case minting an Otherdeed, "gas" is measured and a relative fee is paid Gas is a unit that measures the amount of computational effort required to execute specific operations on Ethereum More compute work = more gas

What's compute work in the context of a transaction? Any computational operation performed while processing the transaction. This can be basic arithmetic, looking up referential data from other contracts, logical operations, etc, etc.

Now that we have some context... What's gas optimization? Gas optimization is primarily writing more performant smart contract code to achieve the same outcomes but with much less computational work, meaning less "gas" used - less computational work.

Why would gas optimization have made things any better? Less gas used means 2 things.. 1. Cheaper gas fees to mint (Fees are gas units required multiplied by gas/gwei price) 2. More importantly.. More transactions per block can be processed. (THIS IS SUPER IMPORTANT)

Ethereum processes a block of transactions roughly every 12 to 14 seconds. These blocks have a maximum amount of TOTAL GAS that can be used across all transactions included in the block. This is the block gas limit.

Because a block can only include so many transactions up to the block gas limit for total gas used across all included transactions, transactions included in the block have to be cherry picked based on which transactions are willing to pay the highest fee per unit of gas used.

In simpler terms. You have a bus (block) with a fixed volume, and people (transactions) of varying size, there are far too many people to let them all on the bus, so you prioritize only letting people on the bus based on their size relative to the amount they're willing to pay.

And this is where gas optimization comes into play. If you can reduce the average size of all people trying to fit on the bus (gas used per mint), you can fit more people (transactions) on each bus (block). A bus (block) comes every 12 to 15 seconds.

Had proper gas optimization been done, the network could have processed significantly more mints per block, meaning the ensuing gas war would have been drastically less both from a gas fee cost and duration standpoint.

More mints per block means mints should process sooner, all mints processing sooner means less stacked up network congestion of transactions waiting to be processed over time, less people fighting each block paying more than the next person in gas fees to get their transaction in

So how much gas did a mint take? Well, let's look at the gas used for minting 2 otherdeeds from a real transaction, here: We see roughly 351,840 units of gas are used to mint 2 Otherdeeds in a transaction.

Nearly every mint transaction I've seen minted 2 Otherdeeds, so let's use 351,840 gas units as the basis of what a mint transaction uses. If this is the case, with the current max block limit size being 30,000,000 gas units, a maximum of 85 mints could happen every block

There's a lot on the optimization side that could have been done, one of the most significant changes would have been the removal of the usage of ERC721Enumerable in the smart contract. This alone would of reduced gas usage by roughly 60% to 70% per transaction..

Couple this with using something like ERC721A given how many transactions were minting 2 (multiple) tokens.. I believe we could have seen a gas unit reduction of 70% to 80%. Let's call it a savings of 75% for playing out how this would have changed things.

In most cases, these 2 optimizations are 5 to 10 minute changes. They can be done with little to no changes to existing contract logic. We're talking a copy/paste type change here in nearly every case.

Instead of 351,840 gas units to mint 2 otherdeeds.. With these optimizations I estimate around 87,960 gas units to mint. This also means 75% relative reduction in the transaction fees paid by minters.. but I believe it would of been more than that due to less network congestion

At 87,960 gas units per mint.. We could fit up to 341 mints per block instead of 85.. This is a massive difference. This is up to 4x more mints processed per block..

This also would have meant that there would have been significantly less transactions with insanely high gas price offered for them to be processed for a time interval. Then for those transactions with high gas prices offered, they'd of been processed significantly sooner.

All in all, gas optimizations at this scale would have meant a dramatically different experience for everyone, and likely upwards of $70M+ less spent by everyone on just gas fees for this mint.

It's hard not to point a finger here. Whomever worked on the Otherdeeds contract should have been well aware of the scale this mint was going to be and should have recognized the significance that prioritizing gas optimizations would have had in the overall outcome.

Anyways, if you made it this far I hope you learned a little bit or at least found this interesting!



Follow us on Twitter

to be informed of the latest developments and updates!


You can easily use to @tivitikothread bot for create more readable thread!
Donate 💲

You can keep this app free of charge by supporting 😊

for server charges...