Polygon's block reorg problem
And why transactions from up to 32 blocks ago (~1 min) can be invalidated
This is an updated version of my Reddit post from a week ago that includes the new protocol from the SpringLength update (which was part of the Delhi update) on Jan 17, 2023.
TL;DR
The Polygon PoS network has a unique block production mechanism (of sprintLength = 16) where 32-depth reorgs (1 min Tx reversals) can happen as easily as 1-depth reorgs on other blockchains. It has more double-digit-depths reorgs than its competitors. This article explains why that's happening.
You should assume that Polygon PoS transactions take 1 min for probabilistic finality before it’s safe to interact with them.
Intro
There are a lot of things I like about Polygon: it's fast, it's cheap, it has a thriving developer community. Like most EVM-blockchains, it has easily-auditable smart contracts.
However, it does have a serious design flaw unique to its blockchain where high-depth block reorgs are happening DAILY.
You can view these on Polygonscan’s Forked Blocks page.
Block reorgs are when previous blocks are invalidated. They can happen if a validator misses including the blocks of the previous validator (often due to network error). Any transactions from the reorged blocks are removed from the blockchain, as if they never happened. This can be very dangerous because they are effectively reversing transactions from the recent past.
Depths measures the number of blocks that had past between the reorged block and the blocks replacing it. Most blockchains that have probabilistic finality tend to have reorgs occasionally, but they're usually only of 1 depths, which means only the previous block was overwritten.
For example, Bitcoin has already had at least two 1-block reorgs in Jan 2023. That's not a big issue since most nodes and exchanges already wait 3-6 blocks before assuming probabilistic finality. But if transactions from 30-100 blocks ago get reversed, that's a big issue, and that’s what was happening with the Polygon PoS network.
Many DeFi apps are built to execute quickly and might not check for reorgs from 30-100 blocks ago. Also, if your transfer affected another action (like an off-chain merchandise purchase), one of the 2 parties is going to get the short end of the stick once the transaction is reversed.
Before the Delhi update on Jan 17, 2023, Polygon PoS could experience reorgs of up to 128 blocks depths, or a dangerously-high 5 minutes in the past. Post-update, that’s been reduced to 32 blocks (1 min).
Reorgs are happening frequently on Polygon at high (10+ blocks) depths
Polygon PoS has had 670 reorgs in the past 125 days, or about **5 reorgs a day**
A third of these had double-digit block reorg depth
Every week, there's usually at least one with a reorg depth of 30+ blocks. At 2-second block times, that's about a minute of blocks re-written.
Here's one from a month ago that had a reorg depth of 120 blocks. That's transactions from 4 minutes before getting re-written. While that’s still an order of magnitude faster finality than slow networks like Bitcoin, it’s bad for a fast blockchain like Polygon PoS, where people assume it only takes seconds for finality.
The only other blockchain with more frequent invalid blocks is Solana (by a wide margin)
2/3rds of the reorgs are caused by a single validator, which is also #3 on the list of top validators. I wonder if someone could reach out to that validator and figure out why it’s skipping so many blocks from other validators.
Compared to similar blockchains
Faster block times usually lead to more reorgs while more centralization leads to fewer block reorgs.
Ethereum:
Only had 1 reorg every 4 days
Reorgs are all at 1 depths, which isn’t bad at all
Thus, you only need to wait ~24 seconds probabilistic finality
It also has a separate deterministic finality gadget (Casper), but beyond this topic.
Binance Smart Chain:
Only has a handful of reorgs in the past 100 days
All its reorgs are under 5 depths.
Polygon is closer to BSC with its fast 2s block times and fewer-than-100 validators. But it makes orders of magnitude more reorgs than BSC, and at higher-depths.
So why are reorgs so prevalent on Polygon PoS compared to other chains?
Polygon uses 2 blockchain protocols for consensus: a GETH-based blockchain (Bor) for block production and a Tenderment-based blockchain (Heimdall) for validation.
Polygon is unique in that it uses sprints for efficiency. Polygon's Bor block producers will produce sprintLength number of blocks in a row on Bor instead of switching every block before delivering them to Heimdall.
In Proof of Stake networks, it’s not uncommon to miss blocks from the previous block producer or validator. With sprints, if a validator accidentally missed blocks from the previous block producer's sprint, they can reorg up to a depth of 2x sprintLength blocks. That’s why this problem is unique to the Polygon PoS network.
At 16 sprintLength, this means a max of a 32-depth block reorg.
Recent PIP-5 update reduced the max reorg depths from 128 blocks to 32
The recent PIP-5 update included in the Delhi update (Jan 17, 2023 ) reduced SprintLength from 64 to 16. This only reduced the max reorg depth from 128 blocks to 32.
What this means is that you still get reorgs just often as before, but probabilistic finality is faster (at about 32 blocks or 1 minute). That’s much better than before, but still ugly.
Conclusion:
Be careful when dealing with Polygon PoS transactions. Assume that it takes 1 minute before it’s safe to interact with them for anything that requires an off-chain action.