celestiaorg / celestia-app

Celestia consensus node
https://celestiaorg.github.io/celestia-app/
Apache License 2.0
345 stars 292 forks source link

chainbuilder: graceful shutdown #3921

Open Wondertan opened 1 month ago

Wondertan commented 1 month ago

Summary

Graceful shutdown for chainbuilder in case shutdown was requested during chain generation, making it aware of all the necessary conditions for the validator to run successfully right after.

Problem Definition

chainbuilder may take days to generate a long chain, which may stop for whatever reason. However, stopping chain generation, as it currently is, makes the resulting chain unusable, and running the validator over fails for various reasons.

Proposal

It's hard to tell how hard to implement this feature and what exactly needs to be done. Potentially, this depends on whether CometBFT components support graceful shutdown. Generally, the exact proposal is to catch the first CTRL-C via notify.Context, which terminates chain generation on the current block and ensures all the prerequisites for the block are met. Also, optionally, for the following CTRL+C we could terminate the process forcefully(this is how it works in the node)