ava-labs / avalanchego

Go implementation of an Avalanche node.
https://avax.network
BSD 3-Clause "New" or "Revised" License
2.09k stars 646 forks source link

Remove parent lookup from issue #3132

Closed StephenButtolph closed 1 day ago

StephenButtolph commented 1 week ago

Why this should be merged

This PR is part of the effort to remove the usage of .Status() on the block type.

Additionally, this removes a call to getBlock, which could result in a slow DB read. This check can now be performed using in-memory state.

How this works

Previously, the checks would register a dependency if:

  1. Fetching the parent failed. It's expected for block fetching to only fail if the block is not accepted and not verified.
  2. The parent is not decided and not processing.

We now register a dependency if:

  1. The parent is not the last accepted block and the parent is not processing.

So, this check would now register a dependency if the parent block is decided (except for the last accepted block). However, we know that shouldIssueBlock(blk) has returned true at this point in the code. In order for shouldIssueBlock(blk) to return true, the parent is only allowed to be decided if it is the last accepted block.

Therefore, this should not be a change in behavior.

How this was tested