nervosnetwork / ckb

The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.
https://www.nervos.org
MIT License
1.15k stars 228 forks source link

How to determine if the node is in the "looking for assume-valid-target" stage? #4485

Closed yanguoyu closed 3 months ago

yanguoyu commented 3 months ago

Feature Request

Is your feature request related to a problem? Please describe.

To better show the synchronization process, we will inform the user that they are in the early synchronization stage, which is 'looking for assume-valid-target'. So we need to know how to get that the ckb node is looking for assume-valid-target

Describe the solution you'd like

Now we are using log matching for determination. But the log changes several times. So I want to know if there is a more accurate way to determine this.

Describe alternatives you've considered

Could we use the sync_status to get the best_known_block_number, and check whether the best_known_block_number is less than the assume-valid-target block number?

eval-exec commented 3 months ago

Could we use the sync_status to get the best_known_block_number , and check whether the best_known_block_number is less than the assume-valid-target block number?

Technically possible. However, strictly speaking, it's possible that when best_known_block_number > assume-valid-target number, best_known_block_number and assume-valid-target are not on the same chain (though this probability is extremely low)."

yanguoyu commented 3 months ago

Could we use the sync_status to get the best_known_block_number , and check whether the best_known_block_number is less than the assume-valid-target block number?

Technically possible. However, strictly speaking, it's possible that when best_known_block_number > assume-valid-target number, best_known_block_number and assume-valid-target are not on the same chain (though this probability is extremely low)."

Are you planning to expose an interface to retrieve this state?

eval-exec commented 3 months ago

Could we use the sync_status to get the best_known_block_number , and check whether the best_known_block_number is less than the assume-valid-target block number?

Technically possible. However, strictly speaking, it's possible that when best_known_block_number > assume-valid-target number, best_known_block_number and assume-valid-target are not on the same chain (though this probability is extremely low)."

Are you planning to expose an interface to retrieve this state?

Yes, we are currently planning to expose assume_valid_target_found: bool in the sync_state RPC interface to determine if CKB has found an assume-valid-target.