hiero-ledger / hiero-ledger/hiero-consensus-node

Add tag validation to `StateUtils#unwrap`

Open
#25,253 0 comments 0 reactions 0 assignees View on GitHub
Platform Tech Debt Reduced
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.