Is there a status-call/api that a OCW could invoke in order to establish if the actual running node instance is fully synced? Maybe listening to a frame_system event? Or knowing the total blocks number and comparing with the latest one? TIA.

NB: To better understand the UC, I have a RPC subscribed to an OCW. I want the RPC to be available, only once the node is fully synced. So I need the OCW to determine this before enabling the RPC calls.

  • You are asking from a Pallet? This does not make sense, a Pallet does not know anything about the chain except the block it is being executed in.
    – Shawn Tabrizi
    Commented Mar 23, 2022 at 22:19
  • Sorry @ShawnTabrizi, It's a typo, I meant from an OCW perspective. Commented Mar 23, 2022 at 22:26
  • 1
    Makes much more sense! :)
    – Shawn Tabrizi
    Commented Mar 23, 2022 at 22:33

2 Answers 2


Adding to what Bryan said, you can just call the RPC system.health. The response isSyncing will be false if the node is in sync. No need for an OCW.

enter image description here

  • Thank you @joepetrowski, this is what I was really after. Would this isSyncing boolean remain false after syncing, but during new block importing? Cheers! Commented Mar 24, 2022 at 20:48
  • 2
    No, I'm not sure of the exact logic behind it, but I think once it's generally caught up (if the current block height is within N blocks of the highest known block) then it is not "syncing" anymore and is just doing normal block import to remain in sync. Commented Mar 25, 2022 at 6:54
  • Thanks @joepetrowski. Commented Mar 25, 2022 at 13:49

OCW don't determine if a node is fully synced. It got notified by txpool when new block is imported


Note importing is different than syncing (bulk importing) so OCW are only invoked after the blockchain is fully synced.

This PR may have more context https://github.com/paritytech/substrate/pull/5200

Not exactly sure what's your requirement but it doesn't sounds relating to OCW much. Your custom RPC handler should be able to query syncing status and decide what to do. OCW can't determine behaviour of RPC call.

If the goal is only enable certain RPC when the node is fully synced, you can just do it in the RPC handler without OCW at all.

  • Great answer @Brayn Chen, thank you. Commented Mar 24, 2022 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.