feat: check for priv_validator_state.json explcitly and create if does not exist#694
feat: check for priv_validator_state.json explcitly and create if does not exist#694blockchainluffy wants to merge 1 commit intomainfrom
Conversation
| Str("privValKeyFile", privValKeyFile). | ||
| Str("stateFile", privValStateFile). | ||
| Msg("Found private validator") | ||
| if tmos.FileExists(privValStateFile) { |
There was a problem hiding this comment.
The goal of this PR it to allow operators rebuilding a node after a consensus failure to only preserve priv_validator_key.json and then resync, without manually reconstructing priv_validator_state.json.
The current implementation is not safe enough though. Right now it recreates priv_validator_state.json whenever the key exists and the state file is missing. That is too broad, because it also covers cases where old chain/app data is still present. In that situation, we would be silently resetting the validator signing state on a non-fresh node.
I think we should narrow the behavior:
- If
priv_validator_key.jsonexists,priv_validator_state.jsonis missing, and the node’s local chain/app data has been wiped for a full resync, recreatepriv_validator_state.jsonautomatically. - If
priv_validator_state.jsonis missing but existing chain/app data is still present, fail fast with a clear operator error instead of silently recreating it.
That gives us the recovery flow we want for operators, without making validator-state resets implicit in every missing-file case. The runbook should also be explicit later: preserve priv_validator_key.json, wipe local chain/app state, then restart and resync.
closes #695