Repository: aptos-labs/aptos-core
File: aptos-move/aptos-release-builder/src/components/framework.rs (Rust)

Code before:

        let script_name = package_path
            .file_name()
            .unwrap()
            .to_str()
            .unwrap()
            .to_string();

        // If this file is the first framework file being generated (if `result.is_empty()` is true),
        // its `next_execution_hash` should be the `next_execution_hash` value being passed in.
        // If the `result` vector is not empty, the current file's `next_execution_hash` should be the
        // hash of the latest framework file being generated (the hash of result.last()).
        // For example, let's say we are going to generate these files:
        // 0-move-stdlib.move	2-aptos-framework.move	4-gas-schedule.move	6-features.move
        // 1-aptos-stdlib.move	3-aptos-token.move	5-version.move		7-consensus-config.move
        // The first framework file being generated is 3-aptos-token.move. It's using the next_execution_hash being passed in (so in this case, the hash of 4-gas-schedule.move being passed in mod.rs).
        // The second framework file being generated would be 2-aptos-framework.move, and it's using the hash of 3-aptos-token.move (which would be result.last()).

        let options = BuildOptions {
            with_srcs: true,
            with_abis: false,
            with_source_maps: false,
            with_error_map: true,
            skip_fetch_latest_git_deps: false,
            bytecode_version: Some(config.bytecode_version),
            experiments: vec![
                "inlining-optimization=on".to_string(),
                "optimize-extra=on".to_string(),
                "across-package-inlining=on".to_string(),
                "inlining-optimization-to-non-primary-targets=on".to_string(),
            ],
            ..BuildOptions::default()
        };
        let package = BuiltPackage::build(package_path, options)?;
        let release = ReleasePackage::new(package)?;

        if is_multi_step {
            // If we're generating a multi-step proposal
            let next_execution_hash_bytes = if result.is_empty() {
                next_execution_hash
            } else {
                get_execution_hash(&result)
            };
            release.generate_script_proposal_multi_step(
                account,
                move_script_path.clone(),
                next_execution_hash_bytes,
            )?;
        } else if is_testnet {
            // If we're generating a single-step proposal on testnet
            release.generate_script_proposal_testnet(account, move_script_path.clone())?;

Review comment (suggestion):
I suggest we just add a new experiment `"extended-framework-optimizations=on"`​ and let the other ones inherit, so we do not have to repeat this and risk divergence.

Code after:

        let script_name = package_path
            .file_name()
            .unwrap()
            .to_str()
            .unwrap()
            .to_string();

        // If this file is the first framework file being generated (if `result.is_empty()` is true),
        // its `next_execution_hash` should be the `next_execution_hash` value being passed in.
        // If the `result` vector is not empty, the current file's `next_execution_hash` should be the
        // hash of the latest framework file being generated (the hash of result.last()).
        // For example, let's say we are going to generate these files:
        // 0-move-stdlib.move	2-aptos-framework.move	4-gas-schedule.move	6-features.move
        // 1-aptos-stdlib.move	3-aptos-token.move	5-version.move		7-consensus-config.move
        // The first framework file being generated is 3-aptos-token.move. It's using the next_execution_hash being passed in (so in this case, the hash of 4-gas-schedule.move being passed in mod.rs).
        // The second framework file being generated would be 2-aptos-framework.move, and it's using the hash of 3-aptos-token.move (which would be result.last()).

        let options = BuildOptions {
            with_srcs: true,
            with_abis: false,
            with_source_maps: false,
            with_error_map: true,
            skip_fetch_latest_git_deps: false,
            bytecode_version: Some(config.bytecode_version),
            experiments: vec!["extended-framework-optimizations=on".to_string()],
            ..BuildOptions::default()
        };
        let package = BuiltPackage::build(package_path, options)?;
        let release = ReleasePackage::new(package)?;

        if is_multi_step {
            // If we're generating a multi-step proposal
            let next_execution_hash_bytes = if result.is_empty() {
                next_execution_hash
            } else {
                get_execution_hash(&result)
            };
            release.generate_script_proposal_multi_step(
                account,
                move_script_path.clone(),
                next_execution_hash_bytes,
            )?;
        } else if is_testnet {
            // If we're generating a single-step proposal on testnet
            release.generate_script_proposal_testnet(account, move_script_path.clone())?;
        } else {
            // If we're generating a single-step proposal on mainnet
            release.generate_script_proposal(account, move_script_path.clone())?;
        }