Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Downloader could got a wrong blockHash in a reorg situation #120

Open
joanestebanr opened this issue Jan 16, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@joanestebanr
Copy link
Contributor

joanestebanr commented Jan 16, 2025

Bug Report

When downloader receive no logs create a 'empty' block. The empty block hash is obtaniner requesting this to RPC . But the hash maybe is not aligned with the logs call. Example:

  1. GetLogs100, 110) [ Hash(110) -> X ] --> return empty list
  2. ⚡ (reorg!! now Hash(110) = Z and also have logs
  3. ❌ GetBlockHeader(110) -> Z

Description

This bug is reproduced in case of reorg between getLogs call and getBlockHeader

Expected behavior

The empty block must belong to the same 'chain' as the GetLogs calls

Proposed solutions

To be sure that all the blocks belong to the same chain we propose next solution:

  • Ask for finalized block number fbn

  • Ask logs for current range [ n - m ]
    - Returns log block x -> next_range = [ x - ( x+ block_chunk) ]
    - Returns empty:
    - if ( fbn - n > block_chunck ) -> create empty block with getHeader(fbn+block_chunk)
    - we have enough blocks on finalized zone to create a empty block
    - next_range = [ (fbn + block_chunck) - m + block_chunck ]
    - else
    - We just increase the range:
    - next_range = [ n - m + block_chunck ]

  • We also suggest to add a new field to EVMBlockHeader struct to say if this block is in finalized zone or not (to avoid sending to reorgDetector)

Pros:

  • Reduce the number of calls to RPC
  • Reduce the load to reorg detector (specially in the initial stage of syncing from scratch)

Cons:

  • The chunckSize it's not always respected and the maxnium request range is going to be greater
  • Increase complexity
@joanestebanr joanestebanr added the bug Something isn't working label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant