fix fork detection for forks starting before the finalized checkpoint #232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this fixes an issue in the fork detection which was recently triggered in devnet-6:
![Screenshot from 2025-02-03 23-35-09](https://private-user-images.githubusercontent.com/491045/409320660-54980dc5-64d1-441c-9e16-02d69e260e7c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjA3OTIsIm5iZiI6MTczOTE2MDQ5MiwicGF0aCI6Ii80OTEwNDUvNDA5MzIwNjYwLTU0OTgwZGM1LTY0ZDEtNDQxYy05ZTE2LTAyZDY5ZTI2MGU3Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQwNDA4MTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05YTI5MTQ0YTMwYTU5M2NhNDYzYjRhZDE0NmUzMmNiMThjOGU1MTI0NGJhM2MyNTA0YTY1ZjNkNzBiNDMyMDA1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.-Nxdty7H8Bk-qiE2HVJiZn0IQijKniyE6tfCM7P43Ew)
Root case of the issue has been, that the orphaned chain at slot 1502 started at slot 1185 (epoch 37), and built on top of slot 1067 (epoch 33).
When receiving the orphaned block at slot 1185, dora had already finalized and dropped all blocks from epoch 33 from cache, so the new fork was not detected (no other block in cache building on top of the same parent).
This PR fixes the fork detection, to properly detect such forks by checking for relevant blocks in the db