Thursday, August 18, 2022

Forking Ethereum

The problems caused by making vulnerable software immutable were revealed by the first major "smart contract". The Decentralized Autonomous Organization (The DAO) was released on 30th April 2016, but on 27th May 2016 Dino Mark, Vlad Zamfir, and Emin Gün Sirer posted A Call for a Temporary Moratorium on The DAO, pointing out some of its vulnerabilities; it was ignored. Three weeks later, when The DAO contained about 10% of all the Ether in circulation, these vulnerabilities were exploited:
allowing the removal of more than 3m ethers.

Subsequent exploitations allowed for more funds to be removed, which ultimately triggered a ‘white hat’ effort by token-holders to secure the remaining funds. That, in turn, triggered reprisals from others seeking to exploit the same flaw.

An effort to blacklist certain addresses tied to The DAO attackers was also stymied mid-rollout after researchers identified a security vulnerability, thus forcing the hard fork option.
The "hard fork" split the Ethereum blockchain into two. On the fork that became today's Ethereum the coins in The DAO ended up in a new "smart contract" from whence they could be recovered by the investors. On the fork that became today's Ethereum Classic, the coins stayed in the various attackers' wallets and were renamed ETC. When ETC started trading on 27th July 2016 it opened at $0.60; ETH was trading at $12.97. Since then, ETH peaked at $4.8K and ETC peaked at $137, so it is clear which fork the market preferred.

Back in February Laura Shin published Austrian Programmer And Ex Crypto CEO Likely Stole $11 Billion Of Ether claiming to identify the perpetrator. The headline overhypes the story. The 3.6M ETH stolen from The DAO wasn't worth $11B at the time of the theft, more like $43M. After the hard fork, the 3.6M ETC was worth under $3M; back in February it was worth about $100M.

Now, as the Ethereum team attempts to finalize their long-delayed goal of switching from Proof-of-Work to Proof-of-Stake, another hard fork looms. Below the fold, I look into why this time things are much more complex.

Why Will It Fork?

Starting in 2015 there was a long-running debate in the Bicoin community about the wisdom of increasing the block size. To oversimplify, the "big block" side included mostly developers and exchanges, who wanted wide adoption driven by many small cheap transactions, and the "small block" side included mostly miners, who wanted scarcity of transactions thus encouraging speculation and increasing miner's fee income. The "small block" side won the argument, which in 2017 led the "big block" side to hard fork to create Bitcoin Cash. At the fork Bitcoin was trading around $2.8K, and Bitcoin Cash around $400. They are now about $23K and $135 respectively.

The fact that the side with fewer miners lost is significant. The exchanges in effect voted for the side of the fork that had the most mining power.

The problem for Ethereum that will motivate a hard fork is that, even more than it was in 2017, Proof-of-Work mining is a capital-intensive industry. After what Ethereum calls "the merge" there will be a large investment in GPUs and ASICs that can no longer earn a return mining Ethereum. Olga Kharif reports in Crypto Miner Pushback Suggests Ethereum Offshoots Are Coming that:
A growing number of factions are making plans for forks that will copy the current software and, with a few tweaks, continue to essentially run the old version of Ethereum using miners.

One effort, called EthereumPOW, is spearheaded by Hongcai “Chandler” Guo, who used to be a large Ethereum miner in China but is now semi-retired and living near San Francisco. Several Chinese companies manufacturing Ethereum mining equipment -- which will be made nearly obsolete by the Merge -- have asked him to start the forking effort, he said.
...
Miners may simply end up supporting a fork as a way to keep going. After the Merge, they face the choice of migrating to supporting smaller chains like Ethereum Classic, repurposing gear or even selling their machines. Hive Blockchain Technologies Ltd. said Friday it would consider switching to mining Ethereum Classic.
Mining on Ethereum Classic wouldn't be a fork, but it wouldn't be nearly as profitable as mining Ethereum has been. As has always been true despite the delays, Vitalik Buterin is optimistic about "the merge":
Ethereum co-founder Vitalik Buterin said the blockchain’s software transition is unlikely to be significantly impacted even if some miners gravitate to alternative chains to mint tokens.
...
“I don’t expect Ethereum to really be significantly harmed by another fork,” Buterin said in a webinar on Saturday. “In general my impression from pretty much everyone I talk to in Ethereum ecosystem, they have been completely supportive of the proof-of-stake effort and the ecosystem has been quite united around it.”
Emily Nicole reports in Ethereum Founder Buterin Forecasts Blockchain Merge on Sept. 15 that:
Following a final test stage of the Merge known as Goerli earlier this week, Buterin said the proof-of-work version of Ethereum now only has a rough “fixed number” of mining slots. This means developers can be more certain about when the official network upgrade might begin.

A previous forecast set a date between Sept. 15 and Sept. 20. There is another call between Ethereum developers next week to hammer out any last-minute hiccups to the Merge, at which a definite date will be settled upon.
Vildana Hajric and Olga Kharif report on the market's reaction in Derivatives Suggest a ‘Sell-the-News’ End to the Ethereum Rally:
Ether is surging in anticipation of a groundbreaking software upgrade to its blockchain. Sophisticated traders are positioning for the rally to continue until that happens -- and then for the cryptocurrency to plummet afterward.

Speculators in derivatives markets are scooping up call options to bet on an Ether advance into September, when the upgrade is supposed to happen. Yet futures and options are suggesting they’re expecting the price to drop after the event in what analysts at Glassnode say could be a “sell-the-news”-type of situation.
...
Many investors are likely to borrow Ether before the Merge by using other assets as collateral, in order to get more forked proof-of-work-chain’s coins, said Marc Zeller, head of developer relations at Aave.

And as they seek to grab more EthereumPOW tokens, investors are expected to prepare software bots to crawl various DeFi apps on the forked EthereumPOW chain and exchange worthless assets such as stablecoins not supported on the chain for EthereumPOW, he said.

“The second the Merge happens there will be front-running bots that will instantly find every block of POW to empty liquidity pools of Uniswap and others on EthereumPOW,” he said. “The goal is to sell as many tokens as they can -- to get as many EthPOW -- the only asset on EthereumPOW chain that may have some kind of value.”

What Will The Fork Mean?

When The DAO fiasco caused the Ethereum Classic fork, the result was that wallets that contained an ETH before the fork contained an ETH on the Ethereum blockchain and an ETC on the Ethereum Classic blockchain. Future transactions on one blockchain didn't affect the other, so each coin could be sold independently. But if "the merge" causes a fork, the situation is more complex because the Ethereum blockchain now contains a huge number of "smart contracts", not just coins.

Jon Reiter examines the effects of the looming fork in A Forking Catastrophe:
But when you fork a chain you also fork the smart contracts and all that related state. This did not exist on a large scale in 2016.
...
At first this looks like a minor problem. So your NFTs get duplicated just like your ETH. But you’d kind of expect the chain that ends up with the valuable ETH version to also get the valuable NFTs. That’s fine.
I'm not so sure it is fine. After the fork, each chain has an independent NFT pointing to the same resource. Both are controlled by the same wallet, so if the owner wants to sell they can create transactions on both blockchains moving it to the buyer's wallet. In that way there is no ambiguity about ownership of the NFT. But if one fork is more popular, the seller will likely only transact on that fork. So now there is a NFT on one chain claiming that the buyer owns the resource, and another on the other chain claiming the seller still owns it. That's fine because the seller won't try to assert that they still own the NFT. But suppose the seller's wallet gets compromised, the thief won't know or care that the NFT isn't supposed to be used as a claim on the resource, they'll just go ahead and sell the NFT on the less popular chain.

Reiter continues:
When we have off-chain assets we want to bring on chain, we wrap or bridge them. Both USD and BTC are “external” assets from the Ethereum perspective. What we end up with is a deposit locked somewhere (the WBTC bridge, Circle’s corporate bank accounts, whatever) and then some ERC20 token on Ethereum that lets us trade it.

Someone or some group maintains these bridges. And that person or group is going to need to decide how to handle the merge. They plainly do not have the resources to redeem twice and so must do something.

Ok this isn’t so bad is it? Each bridge facility publishes their own choice and then we move on right? Wrong.

The easiest way to see the problem is to consider liquidity pools within Automated Market Makers (AMMs). The precise details don’t matter here. Just know these are smart contracts that hold pools of assets and use them for trading. These smart contracts, and their associated pools, will get cloned as part of the merge.

So what is the problem? Let’s say we have a Uniswap pool that contains USDC and WBTC. What happens if the USDC folk choose fork 1 and the WBTC folk choose fork 2? What are we even trading then?

And it gets so much worse. Curve is a protocol that can AMM more than two tokens at once. Look at the Curve “3 Pool” here. This thing contains DAI, USDC and USDT. Clearly if the USDC and USDT folk choose different forks, we have a problem. But DAI? That comes out of MakerDAO via a mechanism where people deposit collateral to mint new stablecoins. And that collateral? It contains all manner of wrapped tokens. Go look for yourself.

For this single curve pool to still work sensibly we need USDC, USDT, the MakerDAO people who run DAI and the team behind every bit of wrapped collateral deposited into DAI to agree on the same fork. Oh wait, one more thing: DAI accepts Uniswap LP tokens. Which means we also need every token accepted into a MakerDAO-approved Uniswap liquidity pool to be on the same page too. And MakerDAO accepts GUSD so the Winklevoss twins must agree too for good measure.
Notice how many centralized decisions are needed to make this "decentralized" world work? And how many of the centralized decisions have to go the same way? As we can see from the disagreement between Buterin and the miners, this is so not going to happen.

Postscript

These forks demonstrate that anyone talking about "the" blockchain, as in "recorded immutably on the blockchain" as opposed to "recorded immutably on a blockchain" doesn't understand the technology. There are a vast multitude of blockchains out there.

8 comments:

David. said...

Many people, including Timothy B. Lee and David Gerard are writing things like:

"Next month's switch to a new method called "proof-of-stake" is expected to cut Ethereum's energy consumption by a factor of 1,000."

Or:

"the merge of the ETH blockchain into the new Beacon Chain system, formerly ETH2, is scheduled for some time between 15 and 20 September 2022.

If it happens this time, then hooray! Proof-of-work mining is a crime against humanity. Using a country’s worth of electricity, and thus pumping huge amounts of carbon dioxide into the air, is unconscionable."

That the merge will reduce Ethereum's environmental impact is true, but misleading. Current Ethereum miners won't simply turn off their mining rigs, they will attempt to continue earning a return on their investment by mining on the EthereumPOW fork, or other cryptocurrencies. Eventually, probably more quickly than if the merge didn't happen, these rigs will become uneconomic and be turned off.

So eventually the merge might reduce the aggregate environmental impact of cryptocurrencies. Or it might not. For example, the miners currently mining ETH might re-invest in BTC mining. It is too soon to tell.

This isn't to say I disagree with the rest of what Lee or Gerard wrote.

Tardigrade said...

"“The second the Merge happens there will be front-running bots that will instantly find every block of POW to empty liquidity pools of Uniswap and others on EthereumPOW,” he said. “The goal is to sell as many tokens as they can -- to get as many EthPOW -- the only asset on EthereumPOW chain that may have some kind of value.”"

Wire fraud. Swapping "counterfeit or spurious coins, obligations, or securities" for ePOW doesn't stop being wire fraud because of smart contracts.

The mess that would be EthereumPOW seems like a heck of a lot of trouble even compared to cryptocurrencies in general. And that trouble seems like it would decrease the value of ePOW even compared to ETC. Would any large miner bother to fork the current chain when they could just switch to the ETC chain, or better yet market a "brand new chain", supported by ETH's largest miners, that traders can get in on the ground floor of?

David. said...

Eyeballing this graph it looks like ETH mining only got into the $10M/day and up range in late 2020. according to this graph BTC mining got into the same range in late 2017.

Given the limited economic life of mining hardware, BTC miners have probably turned over their hardware 3 times since then. ETH miners who got in when it passed $10M/day probably re-invested in GPUs quite recently, which means their new rigs aren't that depreciated and they will need to mine something with them for say another 9 months at least.

Things are even worse for the guys who invested in Bitmain's E9 ETH mining ASIC, launched in July 2022. And for Bitmain, who presumably put a lot of R&D and NRE into the E9.

I think there is going to be a significant fork next month because there is a lot of money that needs it.

David. said...

When someone says "stored on the blockchain" it is a tell that they don't understand the technology. See Jeff John Roberts' There are too many blockchains. When will some of them die?:

"“What is dead may never die” is the motto of a nautical clan from the Game of Thrones series, but it’s equally fitting for the crypto world, where many blockchains are clearly dead but somehow refuse to die.

If you doubt it, go to CoinMarketCap and you’ll see thousands of blockchains that have no viability or purpose but whose tokens still trade as if they do. Some of the most valuable chains appear to be little more than the husks from earlier eras, propped up by small tribes of bag-holders."

David. said...

For future reference, the ETH hash rate is currently 958TH/s whereas the ETC hash rate is 48.5TH/s, or about 5% of ETH's.

David. said...

The merge happened. ETH is down from about $1850 to about $1450 over the last month, and from about $1600 since the merge. The ETC hash rate went from about 50TH/s to about 200TH/s, so about 1/6 of the ETH mining power moved to ETC.

David. said...

Initially, the EthereumPOW (ETHW) hash rate was about 80TH/s, or about 8% of the previous ETH hash rate. It is now down around 32TH/s, or about 3%. The ETC hash rate is around 160TH/s, or about 12% of the previous ETH hash rate. Thus currently about 85% of the previous ETH hash rate is elsewhere, or has been turned off.

David. said...

David Gerard and Amy Castor report:

"So where have the miners gone? Nowhere, for the most part — only 27% are still mining anything. 73% of Ethereum miners have just given up: “About 10.6 million RTX 3070 equivalents have stopped mining since the merge.”