diff --git a/Cargo.lock b/Cargo.lock index ede93be3fbc97..994670cca8e4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,7 +274,7 @@ dependencies = [ [[package]] name = "aptos" -version = "4.2.6" +version = "4.3.0" dependencies = [ "anyhow", "aptos-api-types", diff --git a/aptos-move/e2e-move-tests/src/tests/large_package_publishing.rs b/aptos-move/e2e-move-tests/src/tests/large_package_publishing.rs index 97cdbd86ae695..159dcc6ceb1b3 100644 --- a/aptos-move/e2e-move-tests/src/tests/large_package_publishing.rs +++ b/aptos-move/e2e-move-tests/src/tests/large_package_publishing.rs @@ -21,7 +21,7 @@ use move_core_types::{ account_address::AccountAddress, parser::parse_struct_tag, vm_status::StatusCode, }; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, option::Option, path::Path}; +use std::{collections::BTreeMap, option::Option, path::Path, str::FromStr}; /// Number of transactions needed for staging code chunks before publishing to accounts or objects /// This is used to derive object address for testing object code deployment feature @@ -143,7 +143,7 @@ impl LargePackageTestContext { package_code, publish_type, Some(self.object_address), - LARGE_PACKAGES_MODULE_ADDRESS, + AccountAddress::from_str(LARGE_PACKAGES_MODULE_ADDRESS).unwrap(), ) } } diff --git a/aptos-move/framework/src/chunked_publish.rs b/aptos-move/framework/src/chunked_publish.rs index 8ef04aeb3fbd9..8d64d5b591b8f 100644 --- a/aptos-move/framework/src/chunked_publish.rs +++ b/aptos-move/framework/src/chunked_publish.rs @@ -23,7 +23,7 @@ pub fn chunk_package_and_create_payloads( package_code: Vec>, publish_type: PublishType, object_address: Option, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> Vec { // Chunk the metadata let mut metadata_chunks = create_chunks(metadata); @@ -105,11 +105,11 @@ fn large_packages_stage_code_chunk( metadata_chunk: Vec, code_indices: Vec, code_chunks: Vec>, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( ModuleId::new( - AccountAddress::from_hex_literal(large_packages_module_address).unwrap(), + large_packages_module_address, ident_str!("large_packages").to_owned(), ), ident_str!("stage_code_chunk").to_owned(), @@ -127,11 +127,11 @@ fn large_packages_stage_code_chunk_and_publish_to_account( metadata_chunk: Vec, code_indices: Vec, code_chunks: Vec>, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( ModuleId::new( - AccountAddress::from_hex_literal(large_packages_module_address).unwrap(), + large_packages_module_address, ident_str!("large_packages").to_owned(), ), ident_str!("stage_code_chunk_and_publish_to_account").to_owned(), @@ -149,11 +149,11 @@ fn large_packages_stage_code_chunk_and_publish_to_object( metadata_chunk: Vec, code_indices: Vec, code_chunks: Vec>, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( ModuleId::new( - AccountAddress::from_hex_literal(large_packages_module_address).unwrap(), + large_packages_module_address, ident_str!("large_packages").to_owned(), ), ident_str!("stage_code_chunk_and_publish_to_object").to_owned(), @@ -172,11 +172,11 @@ fn large_packages_stage_code_chunk_and_upgrade_object_code( code_indices: Vec, code_chunks: Vec>, code_object: AccountAddress, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( ModuleId::new( - AccountAddress::from_hex_literal(large_packages_module_address).unwrap(), + large_packages_module_address, ident_str!("large_packages").to_owned(), ), ident_str!("stage_code_chunk_and_upgrade_object_code").to_owned(), @@ -192,11 +192,11 @@ fn large_packages_stage_code_chunk_and_upgrade_object_code( // Cleanup account's `StagingArea` resource. pub fn large_packages_cleanup_staging_area( - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( ModuleId::new( - AccountAddress::from_hex_literal(large_packages_module_address).unwrap(), + large_packages_module_address, ident_str!("large_packages").to_owned(), ), ident_str!("cleanup_staging_area").to_owned(), diff --git a/crates/aptos/CHANGELOG.md b/crates/aptos/CHANGELOG.md index 882dd1dd4ac76..ff469c04b0232 100644 --- a/crates/aptos/CHANGELOG.md +++ b/crates/aptos/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to the Aptos CLI will be captured in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format set out by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased + +## [4.3.0] - 2024/10/30 +- Allow for setting large-packages module for chunking publish mode with `--large-packages-module-address` - [`Fix`] Remove unwraps to make outputs go through regular error handling ## [4.2.6] - 2024/10/23 diff --git a/crates/aptos/Cargo.toml b/crates/aptos/Cargo.toml index ca6e7627773b0..4f31c89554ae3 100644 --- a/crates/aptos/Cargo.toml +++ b/crates/aptos/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "aptos" description = "Aptos tool for management of nodes and interacting with the blockchain" -version = "4.2.6" +version = "4.3.0" # Workspace inherited keys authors = { workspace = true } diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index f5bc8c8eb128d..581a0caaeec3e 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -2353,6 +2353,10 @@ pub struct ChunkedPublishOption { pub(crate) chunked_publish: bool, /// Address of the `large_packages` move module for chunked publishing - #[clap(long, default_value = LARGE_PACKAGES_MODULE_ADDRESS)] - pub(crate) large_packages_module_address: String, + /// + /// By default, on the module is published at `0x0e1ca3011bdd07246d4d16d909dbb2d6953a86c4735d5acf5865d962c630cce7` + /// on Testnet and Mainnet. On any other network, you will need to first publish it from the framework + /// under move-examples/large_packages. + #[clap(long, default_value = LARGE_PACKAGES_MODULE_ADDRESS, value_parser = crate::common::types::load_account_arg)] + pub(crate) large_packages_module_address: AccountAddress, } diff --git a/crates/aptos/src/move_tool/mod.rs b/crates/aptos/src/move_tool/mod.rs index c0f9dd27d6b95..4b9b6e2dfb196 100644 --- a/crates/aptos/src/move_tool/mod.rs +++ b/crates/aptos/src/move_tool/mod.rs @@ -820,7 +820,7 @@ impl AsyncTryInto for &PublishPackage { package, PublishType::AccountDeploy, None, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )?; let size = &chunked_publish_payloads @@ -1012,7 +1012,7 @@ fn create_chunked_publish_payloads( package: BuiltPackage, publish_type: PublishType, object_address: Option, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> CliTypedResult { let compiled_units = package.extract_code(); let metadata = package.extract_metadata()?; @@ -1050,7 +1050,7 @@ impl CliCommand for PublishPackage { submit_chunked_publish_transactions( chunked_package_payloads.payloads, &self.txn_options, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, ) .await } else { @@ -1156,7 +1156,7 @@ impl CliCommand for CreateObjectAndPublishPackage { package, PublishType::AccountDeploy, None, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; let staging_tx_count = (mock_payloads.len() - 1) as u64; @@ -1182,7 +1182,7 @@ impl CliCommand for CreateObjectAndPublishPackage { package, PublishType::ObjectDeploy, None, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; @@ -1197,7 +1197,7 @@ impl CliCommand for CreateObjectAndPublishPackage { submit_chunked_publish_transactions( payloads, &self.txn_options, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, ) .await } else { @@ -1294,7 +1294,7 @@ impl CliCommand for UpgradeObjectPackage { built_package, PublishType::ObjectUpgrade, Some(self.object_address), - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; @@ -1308,7 +1308,7 @@ impl CliCommand for UpgradeObjectPackage { submit_chunked_publish_transactions( payloads, &self.txn_options, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, ) .await } else { @@ -1385,7 +1385,7 @@ impl CliCommand for DeployObjectCode { package, PublishType::AccountDeploy, None, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; let staging_tx_count = (mock_payloads.len() - 1) as u64; @@ -1411,7 +1411,7 @@ impl CliCommand for DeployObjectCode { package, PublishType::ObjectDeploy, None, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; @@ -1426,7 +1426,7 @@ impl CliCommand for DeployObjectCode { submit_chunked_publish_transactions( payloads, &self.txn_options, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, ) .await } else { @@ -1529,7 +1529,7 @@ impl CliCommand for UpgradeCodeObject { package, PublishType::ObjectUpgrade, Some(self.object_address), - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, )? .payloads; @@ -1543,7 +1543,7 @@ impl CliCommand for UpgradeCodeObject { submit_chunked_publish_transactions( payloads, &self.txn_options, - &self.chunked_publish_option.large_packages_module_address, + self.chunked_publish_option.large_packages_module_address, ) .await } else { @@ -1594,7 +1594,7 @@ fn build_package_options( async fn submit_chunked_publish_transactions( payloads: Vec, txn_options: &TransactionOptions, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> CliTypedResult { let mut publishing_result = Err(CliError::UnexpectedError( "No payload provided for batch transaction run".to_string(), @@ -1666,7 +1666,7 @@ async fn submit_chunked_publish_transactions( async fn is_staging_area_empty( txn_options: &TransactionOptions, - large_packages_module_address: &str, + large_packages_module_address: AccountAddress, ) -> CliTypedResult { let url = txn_options.rest_options.url(&txn_options.profile_options)?; let client = Client::new(url); @@ -1702,8 +1702,8 @@ pub struct ClearStagingArea { pub(crate) txn_options: TransactionOptions, /// Address of the `large_packages` move module for chunked publishing - #[clap(long, default_value = LARGE_PACKAGES_MODULE_ADDRESS)] - pub(crate) large_packages_module_address: String, + #[clap(long, default_value = LARGE_PACKAGES_MODULE_ADDRESS, value_parser = crate::common::types::load_account_arg)] + pub(crate) large_packages_module_address: AccountAddress, } #[async_trait] @@ -1718,7 +1718,7 @@ impl CliCommand for ClearStagingArea { &self.large_packages_module_address, self.txn_options.profile_options.account_address()? ); - let payload = large_packages_cleanup_staging_area(&self.large_packages_module_address); + let payload = large_packages_cleanup_staging_area(self.large_packages_module_address); self.txn_options .submit_transaction(payload) .await diff --git a/crates/aptos/src/test/mod.rs b/crates/aptos/src/test/mod.rs index 3413934aed1f1..c92fa415c0bd9 100644 --- a/crates/aptos/src/test/mod.rs +++ b/crates/aptos/src/test/mod.rs @@ -896,7 +896,10 @@ impl CliTestFramework { }, chunked_publish_option: ChunkedPublishOption { chunked_publish: false, - large_packages_module_address: LARGE_PACKAGES_MODULE_ADDRESS.to_string(), + large_packages_module_address: AccountAddress::from_str( + LARGE_PACKAGES_MODULE_ADDRESS, + ) + .unwrap(), }, } .execute()