bnb-chain / opbnb

MIT License
403 stars 163 forks source link

fix(op-node): pre-fetching handle L1 reOrg #115

Closed welkin22 closed 9 months ago

welkin22 commented 9 months ago

Description

If L1 experiences a reorganization within 15 blocks, the pre-fetched receipts data will be useless, which will trigger the optimization in https://github.com/bnb-chain/opbnb/pull/87, and the sequencer will continue to produce blocks based on the same L1 block height instead of using the next block. In order to minimize this situation, we need to handle the case where L1 experiences a reorganization within 15 blocks.

Rationale

When we detect that the hash value of the oldest block height in this round does not match the hash value of the latest block height in the previous round, it means that a reorganization has occurred in the L1 chain. We will roll back the current block height variable to 15 blocks ago to avoid problems caused by reorganization within 15 blocks. If it is a reorganization of more than 15 blocks, the reset process will handle it.

Example

none

Changes

Notable changes: