diff --git a/Cargo.lock b/Cargo.lock index 76173dd88da0d..fd95c37b012c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,7 +185,6 @@ dependencies = [ "aptos-api-types", "aptos-config", "aptos-crypto", - "aptos-framework-releases", "aptos-genesis-tool", "aptos-global-constants", "aptos-logger", @@ -203,6 +202,7 @@ dependencies = [ "executor", "executor-types", "fail", + "framework", "futures", "goldenfile", "hex", @@ -480,7 +480,6 @@ dependencies = [ "anyhow", "aptos-config", "aptos-crypto", - "aptos-framework-releases", "aptos-global-constants", "aptos-management", "aptos-secure-storage", @@ -492,6 +491,7 @@ dependencies = [ "bcs", "consensus-types", "executor", + "framework", "rand 0.8.4", "serde 1.0.136", "storage-interface", @@ -699,7 +699,6 @@ dependencies = [ "aptos-config", "aptos-crypto", "aptos-data-client", - "aptos-framework-releases", "aptos-genesis-tool", "aptos-infallible", "aptos-logger", @@ -723,6 +722,7 @@ dependencies = [ "executor", "executor-types", "fail", + "framework", "futures", "hex", "jemallocator", @@ -940,7 +940,6 @@ dependencies = [ "anyhow", "aptos-config", "aptos-crypto", - "aptos-framework-releases", "aptos-logger", "aptos-types", "aptos-workspace-hack", @@ -3246,7 +3245,6 @@ version = "0.0.0" dependencies = [ "anyhow", "aptos-config", - "aptos-framework-releases", "aptos-genesis-tool", "aptos-logger", "aptos-rest-client", @@ -3258,6 +3256,7 @@ dependencies = [ "async-trait", "base64", "debug-interface", + "framework", "futures", "hyper", "hyper-proxy", @@ -3289,12 +3288,12 @@ name = "forge-cli" version = "0.0.0" dependencies = [ "anyhow", - "aptos-framework-releases", "aptos-rest-client", "aptos-sdk", "aptos-workspace-hack", "async-trait", "forge", + "framework", "itertools", "rand_core 0.6.3", "structopt", @@ -7647,7 +7646,6 @@ dependencies = [ "aptos", "aptos-config", "aptos-crypto", - "aptos-framework-releases", "aptos-genesis-tool", "aptos-global-constants", "aptos-infallible", diff --git a/api/Cargo.toml b/api/Cargo.toml index 475c85183b434..39900a23ce6f3 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -42,7 +42,6 @@ rand = "0.8.3" reqwest = { version = "0.11.2", features = ["blocking", "json"], default_features = false } aptos-crypto = { path = "../crates/aptos-crypto" } -aptos-framework-releases = { path = "../aptos-move/framework/aptos-framework/releases" } aptos-genesis-tool = {path = "../config/management/genesis", features = ["testing"] } aptos-global-constants = { path = "../config/global-constants" } aptos-mempool = { path = "../mempool", features = ["fuzzing"] } @@ -53,6 +52,7 @@ aptos-vm = { path = "../aptos-move/aptos-vm" } aptosdb = { path = "../storage/aptosdb", features = ["fuzzing"] } executor = { path = "../execution/executor" } executor-types = { path = "../execution/executor-types" } +framework = { path = "../aptos-move/framework" } mempool-notifications = { path = "../state-sync/inter-component/mempool-notifications" } vm-validator = { path = "../vm-validator" } diff --git a/api/src/tests/test_context.rs b/api/src/tests/test_context.rs index 0a905f5874473..b4b66362f9abe 100644 --- a/api/src/tests/test_context.rs +++ b/api/src/tests/test_context.rs @@ -51,13 +51,10 @@ pub fn new_test_context(test_name: &'static str) -> TestContext { tmp_dir.create_as_dir().unwrap(); let mut rng = ::rand::rngs::StdRng::from_seed([0u8; 32]); - let builder = ValidatorBuilder::new( - &tmp_dir, - aptos_framework_releases::current_module_blobs().to_vec(), - ) - .publishing_option(VMPublishingOption::open()) - .min_price_per_gas_unit(0) - .randomize_first_validator_ports(false); + let builder = ValidatorBuilder::new(&tmp_dir, framework::aptos::module_blobs()) + .publishing_option(VMPublishingOption::open()) + .min_price_per_gas_unit(0) + .randomize_first_validator_ports(false); let (root_keys, genesis, genesis_waypoint, validators) = builder.build(&mut rng).unwrap(); let validator_owner = validators[0].storage().get(OWNER_ACCOUNT).unwrap().value; diff --git a/aptos-move/framework/src/aptos.rs b/aptos-move/framework/src/aptos.rs index ca1597bed3397..361f34e3cc9ca 100644 --- a/aptos-move/framework/src/aptos.rs +++ b/aptos-move/framework/src/aptos.rs @@ -15,18 +15,9 @@ use std::collections::BTreeMap; const APTOS_MODULES_DIR: &str = "aptos-framework/sources"; static APTOS_PKG: Lazy = Lazy::new(|| super::package("aptos-framework")); -pub fn aptos_modules_full_path() -> String { - format!("{}/{}", env!("CARGO_MANIFEST_DIR"), APTOS_MODULES_DIR) -} - pub fn files() -> Vec { let mut files = move_stdlib::move_stdlib_files(); - files.extend(files_no_dependencies()); - files -} - -pub fn files_no_dependencies() -> Vec { - let mut files = super::move_files_in_path(APTOS_MODULES_DIR); + files.extend(super::move_files_in_path(APTOS_MODULES_DIR)); files.extend(super::move_files_in_path(super::CORE_MODULES_DIR)); files } diff --git a/aptos-move/framework/src/lib.rs b/aptos-move/framework/src/lib.rs index 51d062064fe9d..104f272b135bc 100644 --- a/aptos-move/framework/src/lib.rs +++ b/aptos-move/framework/src/lib.rs @@ -3,7 +3,7 @@ #![forbid(unsafe_code)] -use move_command_line_common::files::{extension_equals, find_filenames, MOVE_EXTENSION}; +use move_command_line_common::files::{extension_equals, find_filenames, MOVE_EXTENSION, MOVE_COMPILED_EXTENSION}; use move_compiler::{ compiled_unit::{CompiledUnit, NamedCompiledModule}, shared::{NumberFormat, NumericalAddress}, @@ -31,6 +31,32 @@ pub fn core_modules_full_path() -> String { format!("{}/{}", env!("CARGO_MANIFEST_DIR"), CORE_MODULES_DIR) } + +/// Load the serialized modules from the specified paths. +pub fn load_modules_from_paths(paths: &[PathBuf]) -> Vec> { + find_filenames(paths, |path| { + extension_equals(path, MOVE_COMPILED_EXTENSION) + }) + .expect("module loading failed") + .iter() + .map(|file_name| std::fs::read(file_name).unwrap()) + .collect::>() +} + +pub(crate) fn module_blobs(pkg: &CompiledPackage) -> Vec> { + pkg.transitive_compiled_units() + .iter() + .filter_map(|unit| match unit { + CompiledUnit::Module(NamedCompiledModule { module, .. }) => { + let mut bytes = vec![]; + module.serialize(&mut bytes).unwrap(); + Some(bytes) + } + CompiledUnit::Script(_) => None, + }) + .collect() +} + pub(crate) fn move_files_in_path(path: &str) -> Vec { let modules_path = path_in_crate(path); find_filenames(&[modules_path], |p| extension_equals(p, MOVE_EXTENSION)).unwrap() @@ -58,17 +84,3 @@ pub(crate) fn package(name: &str) -> CompiledPackage { .compile_package(&path_in_crate(name), &mut Vec::new()) .unwrap() } - -pub(crate) fn module_blobs(pkg: &CompiledPackage) -> Vec> { - pkg.transitive_compiled_units() - .iter() - .filter_map(|unit| match unit { - CompiledUnit::Module(NamedCompiledModule { module, .. }) => { - let mut bytes = vec![]; - module.serialize(&mut bytes).unwrap(); - Some(bytes) - } - CompiledUnit::Script(_) => None, - }) - .collect() -} diff --git a/aptos-node/Cargo.toml b/aptos-node/Cargo.toml index 84b597c924471..79e757100993f 100644 --- a/aptos-node/Cargo.toml +++ b/aptos-node/Cargo.toml @@ -24,7 +24,6 @@ aptos-api = { path = "../api" } aptos-config = { path = "../config" } aptos-crypto = { path = "../crates/aptos-crypto" } aptos-data-client = { path = "../state-sync/aptos-data-client" } -aptos-framework-releases = { path = "../aptos-move/framework/aptos-framework/releases" } aptos-genesis-tool = {path = "../config/management/genesis", features = ["testing"] } aptos-infallible = { path = "../crates/aptos-infallible" } aptos-logger = { path = "../crates/aptos-logger" } @@ -46,6 +45,7 @@ debug-interface = { path = "../crates/debug-interface" } event-notifications = { path = "../state-sync/inter-component/event-notifications" } executor = { path = "../execution/executor" } executor-types = { path = "../execution/executor-types" } +framework = { path = "../aptos-move/framework" } mempool-notifications = { path = "../state-sync/inter-component/mempool-notifications" } network = { path = "../network" } network-builder = { path = "../network/builder" } diff --git a/aptos-node/src/main.rs b/aptos-node/src/main.rs index db0e9076287ab..9034f8aebd383 100644 --- a/aptos-node/src/main.rs +++ b/aptos-node/src/main.rs @@ -73,9 +73,9 @@ fn main() { None }; let genesis_modules = if let Some(module_paths) = args.genesis_modules { - aptos_framework_releases::load_modules_from_paths(&module_paths) + framework::load_modules_from_paths(&module_paths) } else { - aptos_framework_releases::current_module_blobs().to_vec() + framework::aptos::module_blobs() }; aptos_node::load_test_environment( args.config, diff --git a/config/management/genesis/Cargo.toml b/config/management/genesis/Cargo.toml index c84a93f37340c..1cc973c93789e 100644 --- a/config/management/genesis/Cargo.toml +++ b/config/management/genesis/Cargo.toml @@ -22,7 +22,6 @@ executor = { path = "../../../execution/executor" } bcs = "0.1.2" aptos-config = { path = "../.."} aptos-crypto = { path = "../../../crates/aptos-crypto" } -aptos-framework-releases = { path = "../../../aptos-move/framework/aptos-framework/releases" } aptos-global-constants = { path = "../../global-constants" } aptos-management = { path = ".." } aptos-secure-storage = { path = "../../../secure/storage" } @@ -31,6 +30,7 @@ aptos-workspace-hack = { version = "0.1", path = "../../../crates/aptos-workspac aptos-temppath = { path = "../../../crates/aptos-temppath" } aptos-vm = { path = "../../../aptos-move/aptos-vm" } aptosdb = { path = "../../../storage/aptosdb" } +framework = { path = "../../../aptos-move/framework" } storage-interface = { path = "../../../storage/storage-interface" } vm-genesis = { path = "../../../aptos-move/vm-genesis" } diff --git a/config/management/genesis/src/command.rs b/config/management/genesis/src/command.rs index 04343de69a493..11aa7880abab5 100644 --- a/config/management/genesis/src/command.rs +++ b/config/management/genesis/src/command.rs @@ -226,13 +226,13 @@ pub mod tests { // Step 2) Upload the Move modules let tempdir = aptos_temppath::TempPath::new(); tempdir.create_as_dir().unwrap(); - for b in aptos_framework_releases::current_module_blobs() { + for b in framework::aptos::module_blobs() { let mut temppath = aptos_temppath::TempPath::new_with_temp_dir(tempdir.path().to_path_buf()); temppath.create_as_file().unwrap(); temppath.persist(); // otherwise, file will disappear before we call set_move_modules let mut file = File::create(temppath.path()).unwrap(); - file.write_all(b).unwrap(); + file.write_all(&b).unwrap(); file.sync_all().unwrap(); } helper diff --git a/config/management/genesis/src/config_builder.rs b/config/management/genesis/src/config_builder.rs index 0d3825258c1d8..4e56138e5166b 100644 --- a/config/management/genesis/src/config_builder.rs +++ b/config/management/genesis/src/config_builder.rs @@ -11,13 +11,11 @@ use rand::{rngs::StdRng, SeedableRng}; pub fn test_config() -> (NodeConfig, Ed25519PrivateKey) { let path = TempPath::new(); path.create_as_dir().unwrap(); - let (root_keys, _genesis, _genesis_waypoint, validators) = ValidatorBuilder::new( - path.path(), - aptos_framework_releases::current_module_blobs().to_vec(), - ) - .template(NodeConfig::default_for_validator()) - .build(StdRng::from_seed([0; 32])) - .unwrap(); + let (root_keys, _genesis, _genesis_waypoint, validators) = + ValidatorBuilder::new(path.path(), framework::aptos::module_blobs().to_vec()) + .template(NodeConfig::default_for_validator()) + .build(StdRng::from_seed([0; 32])) + .unwrap(); let mut configs = validators.into_iter().map(|v| v.config).collect::>(); let key = root_keys.root_key; diff --git a/storage/inspector/Cargo.toml b/storage/inspector/Cargo.toml index 879509015904f..c22b122668bdc 100644 --- a/storage/inspector/Cargo.toml +++ b/storage/inspector/Cargo.toml @@ -13,7 +13,6 @@ anyhow = "1.0.52" structopt = "0.3.21" tempfile = "3.2.0" -aptos-framework-releases = { path = "../../aptos-move/framework/aptos-framework/releases" } aptosdb = { path = "../aptosdb" } aptos-config = { path = "../../config" } aptos-crypto = { path = "../../crates/aptos-crypto" } diff --git a/testsuite/forge-cli/Cargo.toml b/testsuite/forge-cli/Cargo.toml index 905dbdc4888d1..3e153e0e77936 100644 --- a/testsuite/forge-cli/Cargo.toml +++ b/testsuite/forge-cli/Cargo.toml @@ -22,7 +22,7 @@ tokio = { version = "1.8.1", features = ["full"] } testcases = { path = "../testcases" } url = "2.2.2" aptos-workspace-hack = { version = "0.1", path = "../../crates/aptos-workspace-hack" } -aptos-framework-releases = { path = "../../aptos-move/framework/aptos-framework/releases" } +framework = { path = "../../aptos-move/framework" } [[bin]] name = "forge" diff --git a/testsuite/forge-cli/src/main.rs b/testsuite/forge-cli/src/main.rs index ef69b686f718f..7d4b38ab7ee99 100644 --- a/testsuite/forge-cli/src/main.rs +++ b/testsuite/forge-cli/src/main.rs @@ -340,7 +340,7 @@ fn local_test_suite() -> ForgeConfig<'static> { .with_aptos_tests(&[&FundAccount, &TransferCoins]) .with_admin_tests(&[&GetMetadata]) .with_network_tests(&[&RestartValidator, &EmitTransaction]) - .with_genesis_modules_bytes(aptos_framework_releases::current_module_blobs().to_vec()) + .with_genesis_modules_bytes(framework::aptos::module_blobs()) } fn k8s_test_suite() -> ForgeConfig<'static> { diff --git a/testsuite/forge/Cargo.toml b/testsuite/forge/Cargo.toml index b16b17b503320..a9d2aab686b17 100644 --- a/testsuite/forge/Cargo.toml +++ b/testsuite/forge/Cargo.toml @@ -39,7 +39,6 @@ url = "2.2.2" debug-interface = { path = "../../crates/debug-interface" } aptos-config = { path = "../../config" } -aptos-framework-releases = { path = "../../aptos-move/framework/aptos-framework/releases" } aptos-genesis-tool = { path = "../../config/management/genesis" } aptos-logger = { path = "../../crates/aptos-logger" } aptos-retrier = { path = "../../crates/aptos-retrier" } @@ -48,4 +47,5 @@ aptos-rest-client = { path = "../../crates/aptos-rest-client"} aptos-secure-storage = { path = "../../secure/storage" } aptos-transaction-builder = { path = "../../sdk/transaction-builder" } aptos-workspace-hack = { version = "0.1", path = "../../crates/aptos-workspace-hack" } +framework = { path = "../../aptos-move/framework" } transaction-emitter = { path = "../../crates/transaction-emitter" } diff --git a/testsuite/forge/src/backend/local/swarm.rs b/testsuite/forge/src/backend/local/swarm.rs index 5343910f29c89..13ed9645d36a5 100644 --- a/testsuite/forge/src/backend/local/swarm.rs +++ b/testsuite/forge/src/backend/local/swarm.rs @@ -150,7 +150,7 @@ impl LocalSwarmBuilder { let (root_keys, genesis, genesis_waypoint, validators) = ValidatorBuilder::new( &dir, self.genesis_modules - .unwrap_or_else(|| aptos_framework_releases::current_module_blobs().to_vec()), + .unwrap_or_else(framework::aptos::module_blobs), ) .num_validators(self.number_of_validators) .template(self.template) diff --git a/testsuite/smoke-test/Cargo.toml b/testsuite/smoke-test/Cargo.toml index e3b6098c3ca72..606a244beaf1f 100644 --- a/testsuite/smoke-test/Cargo.toml +++ b/testsuite/smoke-test/Cargo.toml @@ -19,10 +19,8 @@ walkdir = "2.3.1" reqwest = { version = "0.11.2", features = ["json"] } aptos = { path = "../../crates/aptos" } -aptos-framework-releases = { path = "../../aptos-move/framework/aptos-framework/releases" } aptos-config = { path = "../../config" } aptos-crypto = { path = "../../crates/aptos-crypto" } -framework = { path = "../../aptos-move/framework" } aptos-rest-client = { path = "../../crates/aptos-rest-client" } aptos-sdk = { path = "../../sdk" } aptos-temppath = { path = "../../crates/aptos-temppath" } @@ -30,6 +28,7 @@ aptos-transaction-builder = { path = "../../sdk/transaction-builder" } aptos-types = { path = "../../types" } aptos-workspace-hack = { version = "0.1", path = "../../crates/aptos-workspace-hack" } forge = { path = "../forge" } +framework = { path = "../../aptos-move/framework" } move-command-line-common = { git = "https://github.com/diem/move", rev = "3fe033b112eae7df2d15ab3467624165ae510caa" } move-ir-compiler = { git = "https://github.com/diem/move", rev = "3fe033b112eae7df2d15ab3467624165ae510caa" } move-stdlib = { git = "https://github.com/diem/move", rev = "3fe033b112eae7df2d15ab3467624165ae510caa" } diff --git a/testsuite/smoke-test/tests/forge-aptos.rs b/testsuite/smoke-test/tests/forge-aptos.rs index 10285554a09bc..a935fd025b0b5 100644 --- a/testsuite/smoke-test/tests/forge-aptos.rs +++ b/testsuite/smoke-test/tests/forge-aptos.rs @@ -17,7 +17,7 @@ fn main() -> Result<()> { &ModulePublish, &ErrorReport, ]) - .with_genesis_modules_bytes(aptos_framework_releases::current_module_blobs().to_vec()); + .with_genesis_modules_bytes(framework::aptos::module_blobs()); let options = Options::from_args(); forge_main(tests, LocalFactory::from_workspace()?, &options) diff --git a/x.toml b/x.toml index b9b6841b1f51d..274da954e090b 100644 --- a/x.toml +++ b/x.toml @@ -165,6 +165,7 @@ members = [ "testcases", "aptos-e2e-tests-replay", + "aptos-framework-releases", "aptos-fuzz", "aptos-fuzzer", "aptos-keygen",