paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.8k stars 652 forks source link

Fix edge case where state sync is not triggered #5635

Closed liuchengxu closed 2 weeks ago

liuchengxu commented 3 weeks ago

This PR addresses an issue where state sync may fail to start if the conditions required for its initiation are not met when a finalized block notification is received. pending_state_sync_attempt is introduced to trigger the state sync later when the conditions are satisfied.

This issue was spotted when I worked on #5406, specifically, queue_blocks was not empty when the finalized block notification was received, and then the state sync was stalled. cc @dmitry-markin

liuchengxu commented 2 weeks ago

@bkchr Please click the button again, fmt wasn't good in the applied suggestion :(