paritytech / paritytech/parity-scale-codec
Encoding must be unique. But BinaryHeap encoding order seems arbitrary
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 287
- Forks
- 103
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
Currently BinaryHeap is encoding by iterating on it using BinaryHeap::iter.
but the function doc says:
Returns an iterator visiting all values in the underlying vector, in arbitrary order.
Thus the order of encoding is not guarantee. I'm afraid this order can change in between rust release and compilation host and target. isn't it ?
If this order can change between rust release or platform host or target then there is bug here for BinaryHeap.
Furthermore maybe we should make actually the encoding unique like by sorting it and assert it is sorted when decoding. (assert by returning error otherwise).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the BinaryHeap encoding implementation and tracing its use of BinaryHeap::iter. Determine whether iteration order can vary across Rust releases or platforms, then define and verify the expected deterministic encoding and decoding behavior with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100