Skip to content

Commit

Permalink
For the FC module, never add the base block to base tree (#2876)
Browse files Browse the repository at this point in the history
why:
  The `base` block is ancestor to all blocks of the base tree bust stays
  outside the tree.

  Some fringe condition uses an opportunistic fix when the `cursor` is not in
  the base tree, which is legit if `cursor != base`.
  • Loading branch information
mjfh authored Nov 26, 2024
1 parent f72dc00 commit 0e793ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nimbus/core/chain/forked_chain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,14 @@ proc latestBlock*(c: ForkedChainRef): Block =
c.blocks.withValue(c.cursorHash, val) do:
return val.blk
do:
# This can happen if block pointed by cursorHash is not loaded yet
result = c.db.getEthBlock(c.cursorHash).expect("cursorBlock exists")
c.blocks[c.cursorHash] = BlockDesc(
blk: result,
receipts: c.db.getReceipts(result.header.receiptsRoot).
expect("receipts exists"),
)
if c.cursorHash != c.baseHash:
# This can happen if the block pointed to by cursorHash is not loaded yet
c.blocks[c.cursorHash] = BlockDesc(
blk: result,
receipts: c.db.getReceipts(result.header.receiptsRoot).
expect("receipts exists"),
)

proc headerByNumber*(c: ForkedChainRef, number: BlockNumber): Result[Header, string] =
if number > c.cursorHeader.number:
Expand Down

0 comments on commit 0e793ae

Please sign in to comment.