rawdb: recover witness size from filesystem metadata miss#2200
Open
AaronAjose wants to merge 1 commit into0xPolygon:developfrom
Open
rawdb: recover witness size from filesystem metadata miss#2200AaronAjose wants to merge 1 commit into0xPolygon:developfrom
AaronAjose wants to merge 1 commit into0xPolygon:developfrom
Conversation
|
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.



Description
This PR fixes a data-consistency bug in filesystem-backed witness storage.
fsWitnessStore.WriteWitness writes witness blobs to disk first (tmp + rename) and writes witnessSizeKey to DB afterward. If the file write succeeds but DB Put fails, the process exits via log.Crit. After restart, the file may exist while DB size metadata is missing.
Before this change, ReadWitnessSize only read DB metadata and returned nil when missing. In WIT pagination/metadata paths, that becomes 0/unavailable, which can silently fail witness page serving for data that is actually present on disk.
This PR adds a fallback in ReadWitnessSize: when DB size metadata is missing and witness storage is filesystem-backed, size is recovered from os.Stat on the witness file. A unit test was added to validate this crash-residue scenario (file exists + size key missing).
Changes
Breaking changes
None.
Nodes audience
This primarily affects nodes using filesystem witness storage (--witness.filestore) and only on recovery paths where DB size metadata is missing while witness files exist on disk.
No new flags or config behavior changes were introduced.
Checklist
Cross repository changes
Heimdall PR link: N/A
matic-cli PR link: N/A
Testing
Manual tests
Not executed in this cycle.
Note: full Go test/build validation is currently blocked unless Go >=1.26.2 toolchain is available (project go.mod requirement).
Additional comments
Added unit test: