Optimism
Pronto para usar isso em produção?
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Optimism
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
A chain reorganization (reorg) is when the canonical history of OP Mainnet changes: blocks your application already saw are replaced by a different sequence, so a transaction once at the head can move to a new block or disappear entirely. On OP Mainnet (chain ID 10), the single sequencer produces blocks in a steady ~2s order, so day-to-day reorgs of confirmed blocks are uncommon compared to PoW chains — but the chain is an optimistic rollup that only becomes truly final once its batch is settled on Ethereum L1, so unfinalized blocks near the head are not guaranteed permanent and can be reorganized during sequencer or derivation hiccups. If your application commits state from those unfinalized blocks and a reorg follows, you end up with balances, indexes, or order books that reflect a history that no longer exists — which is exactly why every serious OP Mainnet integration must detect and handle reorgs rather than assume the head is immutable.
parentHash does not match the hash you stored for the previous height, or the same block number suddenly reporting a different hash. Polling eth_getBlockByNumber/eth_getBlockByHash and comparing hashes, as the examples do, surfaces these breaks.monitorReorgs does); in a subscription system, check that each new header's parentHash matches the last header you processed. Either way, a mismatch triggers the recovery path.findCommonAncestor helper), roll back every state change derived from the orphaned blocks, then replay forward along the new canonical chain. Keying your storage by block hash makes this a clean replace.newBlockHeaders subscription for low-latency parent-hash checks on a ~2s-block chain; keep polling as a fallback for gap recovery after a dropped connection, since a subscription that silently stops would otherwise miss reorgs entirely.