Skip to content

feat: check for priv_validator_state.json explcitly and create if does not exist#694

Open
blockchainluffy wants to merge 1 commit intomainfrom
feat/update-chain-init-cmd
Open

feat: check for priv_validator_state.json explcitly and create if does not exist#694
blockchainluffy wants to merge 1 commit intomainfrom
feat/update-chain-init-cmd

Conversation

@blockchainluffy
Copy link
Copy Markdown
Contributor

@blockchainluffy blockchainluffy commented Apr 16, 2026

closes #695

Str("privValKeyFile", privValKeyFile).
Str("stateFile", privValStateFile).
Msg("Found private validator")
if tmos.FileExists(privValStateFile) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json exists, priv_validator_state.json is missing, and the node’s local chain/app data has been wiped for a full resync, recreate priv_validator_state.json automatically.
  • If priv_validator_state.json is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

priv_validator_state.json to be created if it does not exist

2 participants