-
Notifications
You must be signed in to change notification settings - Fork 689
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
fix: don't panic if new flat head is not reachable #7724
Conversation
@mzhangmzz moved heights comparison inside |
core/store/src/flat_state.rs
Outdated
}; | ||
// If new head height is not greater than current head height, new head is not a child of flat head, so we | ||
// return Ok. | ||
if new_head_height <= current_head_height { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wonder if it's cleaner to not change this function and check at the its callsite to ignore the "BlockNotFoundError". A lot of the checks you did here is included at get_deltas_between_blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. If get_deltas_between_blocks
fails, then new code fails as well.
In `tests::client::process_blocks::test_query_final_state`, there is a chain with two forks: ``` /// /-------> 6 /// 1 -> 2 -> 3 -> 4 /// \---> 5 ``` When (5) is postprocessed, flat head moves from (2) to (3). When then (6) is postprocessed, the last final block it sees is (2). It attempts to move flat head from (3) to (2) and the node crashes. Also we can't simply take final head which always moves forward, due to catchups. So we add comparison of old and new heights. ## Testing https://buildkite.com/nearprotocol/nearcore-flat-state/builds/62#01838983-7f4d-4bd1-9eea-a376da2e0a62
In
tests::client::process_blocks::test_query_final_state
, there is a chain with two forks:When (5) is postprocessed, flat head moves from (2) to (3).
When then (6) is postprocessed, the last final block it sees is (2). It attempts to move flat head from (3) to (2) and the node crashes.
Also we can't simply take final head which always moves forward, due to catchups. So we add comparison of old and new heights.
Testing
https://buildkite.com/nearprotocol/nearcore-flat-state/builds/62#01838983-7f4d-4bd1-9eea-a376da2e0a62