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 be performed using in-memory state.
How this works
The checks now being performed are significantly simpler to understand. Previously, the checks would:
Verify that the blk.Height() is greater than the last accepted height.
Verify that the blk.ID() is not currently in the processing block tree.
Verify that the parent.Status() was either accepted or parent.ID() is currently in the processing block tree.
Because the blk.Height() was verified to be greater than the last accepted height, we knew that if parent.Status() was accepted then the parent block was the last accepted block.
We now directly verify that:
The blk.ID() is not currently in the processing block tree.
The parent.ID() is either the last accepted block or is currently in the processing block tree.
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 be performed using in-memory state.How this works
The checks now being performed are significantly simpler to understand. Previously, the checks would:
blk.Height()
is greater than the last accepted height.blk.ID()
is not currently in the processing block tree.parent.Status()
was either accepted orparent.ID()
is currently in the processing block tree.Because the
blk.Height()
was verified to be greater than the last accepted height, we knew that ifparent.Status()
was accepted then theparent
block was the last accepted block.We now directly verify that:
blk.ID()
is not currently in the processing block tree.parent.ID()
is either the last accepted block or is currently in the processing block tree.How this was tested