hiero-ledger / hiero-ledger/hiero-consensus-node
Add tag validation to `StateUtils#unwrap`
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
`StateUtils#unwrap` currently skips the protobuf tag without validating it. This allowed a bug in `VirtualMapStateImpl` where `pushQueue`/`popQueue` wrapped queue metadata with `stateId` instead of `STATE_VALUE_QUEUE_STATE` (8001) — the mismatch went undetected because `unwrap` never checked what it was unwrapping.
Add an `expectedTag` parameter to `unwrap` so callers declare which field number they expect, and throw `IllegalStateException` on mismatch. Update all call sites in `VirtualMapStateImpl` to pass the appropriate tag (`stateId` for elements/singletons/kv, `STATE_VALUE_QUEUE_STATE` for queue metadata).
Contributor guide
Research direction
Start with StateUtils#unwrap and the unwrap call sites in VirtualMapStateImpl. Trace the element, singleton, key-value, and queue-metadata paths to confirm which expected tag each caller should provide. Done means mismatched tags throw IllegalStateException and all listed callers pass the appropriate tag, including STATE_VALUE_QUEUE_STATE for queue metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100