cp: skip commitment history integrity checks when disabled#20839
Merged
Conversation
…#20835) ## Summary `seg integrity` runs `CommitmentHistVal` and `StateRootVerifyByHistory` regardless of whether commitment history is persisted on the datadir. Both depend on commitment history `.v` files: - `CheckCommitmentHistVal` iterates `.v` files; when none exist it returns nil after logging `files=0`, which silently masks misconfiguration as a passing check. - `CheckCommitmentHistAtBlkRange` would fail confusingly when trying to read history that isn't there. This PR reads `rawdb.ReadDBCommitmentHistoryEnabled` once at the start of `doIntegrity` and skips both checks with an informative log line when the flag is off. Mirrors the existing `BorEvents` / `BorSpans` chain-guard pattern in the same dispatch switch. The other commitment checks (`CommitmentRoot`, `CommitmentKvi`, `CommitmentKvDeref`, `StateVerify`) operate on the domain `.kv` files and don't depend on history, so they remain unconditional. ## Test plan - [x] `make lint` clean - [x] `go build ./cmd/utils/app/...` succeeds - [x] On a no-history datadir, run `seg integrity --check CommitmentHistVal` and confirm the skip log appears and the command exits 0 instead of "passing" with files=0 - [x] On a history-enabled datadir, confirm `CommitmentHistVal` and `StateRootVerifyByHistory` still execute as before
AskAlexSharov
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #20835 to
release/3.4.