A "block reorganization" refers to a situation where the distributed ledger undergoes a significant revision, typically due to the discovery of a longer valid chain of blocks. This revision results in the replacement of one or more blocks in the blockchain with an alternative set of blocks. More on this at https://en.bitcoin.it/wiki/Chain_Reorganization.
Nodes deployed with Chainstack follow the canonical chain. If there is a block reorganization, the nodes will automatically follow the longest chain that has been determined.
How do you spot these?
When subscribing to incoming blocks, you might notice the block number shift in block hash. This doesn't happen very often, but it does happen.
Notice that this block number has uncle rewards https://etherscan.io/block/3887081
How do I handle reorgs?
If you're indexing the blockchain, you don't want to store an uncle or reorg block data.
- don't index too close to the tip of the chain, as it can happen
- implement a delay when doing
eth_getBlockByNumber
oreth_getBlockReceipt
- keep an eye out for reorgs and how often they happen via the block explorer like https://etherscan.io/blocks_forked and https://polygonscan.com/blocks_forked
Comments
0 comments
Article is closed for comments.