Skip to content

Conversation

chrisgitiota
Copy link
Contributor

@chrisgitiota chrisgitiota commented Jul 16, 2025

Description of change

product_common::PackageRegistry now supports the full package version history. It uses a Move.history.json file to import the version history and known environments (as being previously done with Move.lock files).

The Move.history.json file

  • should be located in the same directory as the Move.lock file
  • contains all data that is provided by the PackageRegistry
  • should be added to the git repository of the product that uses the PackageRegistry
  • will be integrated into build rust binaries at build time (using include_str!()) - like the previously used Move.lock file had been integrated in the build
  • should not be used to store the history of localnet networks, as this would mass up the file. For this purpose the MoveHistoryManager described below, offers a aliases_to_ignore list which is set to localnet per default.

For example the Move.history.json for the recent (not latest) Identity package would look like this:

{
  "aliases": {
    "devnet": "e678123a",
    "testnet": "2304aa97",
    "mainnet": "6364aad5"
  },
  "envs": {
    "6364aad5": ["0x84cf5d12de2f9731a89bb519bc0c982a941b319a33abefdd5ed2054ad931de08"],
    "e678123a": [
      "0xe6fa03d273131066036f1d2d4c3d919b9abbca93910769f26a924c7a01811103",
      "0x6a976d3da90db5d27f8a0c13b3268a37e582b455cfc7bf72d6461f6e8f668823"
    ],
    "2304aa97": [
      "0x222741bbdff74b42df48a7b4733185e9b24becb8ccfbafe8eac864ab4e4cc555",
      "0x3403da7ec4cd2ff9bdf6f34c0b8df5a2bd62c798089feb0d2ebf1c2e953296dc"
    ]
  }
}

Product build.rs scripts

The Move.history.json for a product can be created manually or automatically using the MoveHistoryManager in buils.rs scripts .

See the docs of the MoveHistoryManager for further details.

An example for a build.rs script using the MoveHistoryManager to manage its Move.history.json file can be found in the Notarization - Full package history PR.

Links to any relevant issues

Will fix: NOTARIZATION_PACKAGE_REGISTRY: Support full package address version history #71

…y using a Move.package-history.toml file

The `Move.package-history.toml` file
* should be located in the same directory as the `Move.lock` file
* contains all necessary data
* can be maintained manually or by using a package-history CLI tool
@chrisgitiota chrisgitiota added the enhancement New feature or request label Jul 16, 2025
@itsyaasir itsyaasir requested review from itsyaasir and UMR1352 July 22, 2025 08:59
@UMR1352

This comment was marked as outdated.

UMR1352

This comment was marked as outdated.

@itsyaasir

This comment was marked as outdated.

@chrisgitiota chrisgitiota marked this pull request as draft August 7, 2025 13:42
@chrisgitiota chrisgitiota marked this pull request as ready for review August 11, 2025 14:58
Copy link
Contributor

@UMR1352 UMR1352 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nitpicks, feel free to disregard anything you don't agree with

/// # Errors
/// This method may return errors from the underlying `init()` or `update()` functions
/// if there are issues reading or writing files.
pub fn manage_history_file(&self, console_out: impl Fn(String)) -> anyhow::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of an impl Fn(String) maybe it'd be better to use &mut impl std::fmt::Write

Comment on lines 213 to 236
if self.move_lock_file_exists() {
if self.history_file_exists() {
// If the output file already exists, update it.
console_out(format!("File `{move_history_path}` already exists, updating..."));
self
.update()
.expect("Successfully updating `Move.history.json` file with `Move.lock` content");
console_out(format!(
"Successfully updated`{move_history_path}` with content of `{move_lock_path}`"
));
} else {
// If the output file does not exist, create it.
console_out(format!("File `{move_history_path}` does not exist, creating..."));
self
.init()
.expect("Successfully creating a `Move.history.json` file with `Move.lock` content");
console_out(format!(
"Successfully created file `{move_history_path}` with content of `{move_lock_path}` content"
));
}
} else {
console_out(format!("File `{move_history_path}` does not exist, skipping..."));
}
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce nesting with early returns

///
/// Doesn't check if any of the provided paths are invalid or if the `Move.lock` file cannot be parsed.
/// Functions `init` and `update` will handle those checks.
pub fn new(move_lock_path: &Path, history_file_path: &Path, aliases_to_ignore: Option<Vec<String>>) -> Self {

This comment was marked as outdated.

console_out(format!("File `{move_history_path}` does not exist, creating..."));
self
.init()
.expect("Successfully creating a `Move.history.json` file with `Move.lock` content");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you be sure this doesn't fail? I'd probably just forward the error

Copy link
Contributor Author

@chrisgitiota chrisgitiota Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, has been a relict from a former version where this code has been placed in the build.rs file

* Narrow down serde_json Value to type String to avoid the need for fn `remove_first_and_last_char_from_string`
* Use anyhow `with_context` instead `context` where `format!` is used
* Use `serde_json::to_string_pretty` to avoid the need for fn `to_prettified_string`
# Conflicts:
#	Cargo.toml
#	product_common/Cargo.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: NOTARIZATION_PACKAGE_REGISTRY: Support full package address version history
3 participants