iotaledger / iotaledger/product-core
[Bug]: Preserve order of Move.history.json entries
- Dominant language
- Rust
- Stars
- 0
- Forks
- 2
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
### Bug description
There is an issue with the `Move.history.json` file used by the `PackageRegistry` to store the network environments and related network aliases. The JSON content changes every time. It’s generated, with the entries being reordered randomly.
This behavior results from:
* A `HashMap` is used in the `PackageRegistry` to store the `aliases` and `envs`
* `serde_json` - used for serialization + deserialization - doesn't use the [`preserve_order` feature flag](https://docs.rs/serde_json/latest/serde_json/enum.Value.html).
Probable fixes:
* Use an `IndexMap` to store the `aliases` and `envs` in the `PackageRegistry`
* Enable the `preserve_order` feature flag for `serde_json`
### Expected behavior
The `Move.history.json` file shall only be altered in case the Move package has been published to a new environment or a package upgrade has been processed.
Otherwise the `Move.history.json` file must remain unchanged.
### Can the issue reliably be reproduced?
Yes
### Example repository
-
### Steps to reproduce
-
### Language
Rust
### Language Version
v0.8.7
### Version
-
### Hardware specifications
-
### Additional info
As a workaround, so far, we should not commit altered Move.history.json files except their have been published or upgraded packages (No upgrade && No publish --> No Move.history.json commit.
Contributor guide
Research direction
Start by locating the PackageRegistry implementation and the code that reads and serializes Move.history.json, focusing on the aliases and envs HashMaps. Reproduce the issue by processing the history without a publish or upgrade and compare the generated JSON. Done means entries retain their existing order and the file remains unchanged unless a publish or upgrade occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100