While the code changes themselves are relatively minor, the rationale behind them is more complex and involves careful handling of specific sync scenarios. I recommend going through the PR commit by commit. Each commit includes detailed explanations in the messages to provide context for the necessity of these changes. cc @dmitry-markin
During local testing for issue #5406, I encountered additional edge cases that required fixing. These should be the final adjustments before I submit part 2 at https://github.com/paritytech/polkadot-sdk/issues/5406#issuecomment-2325064863.
While the code changes themselves are relatively minor, the rationale behind them is more complex and involves careful handling of specific sync scenarios. I recommend going through the PR commit by commit. Each commit includes detailed explanations in the messages to provide context for the necessity of these changes. cc @dmitry-markin