diff --git a/Cargo.lock b/Cargo.lock index 67ae0c6e5c9..10b66fb6ed5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5633,6 +5633,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "inline_colorization" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1804bdb6a9784758b200007273a8b84e2b0b0b97a8f1e18e763eceb3e9f98a" + [[package]] name = "inotify" version = "0.9.6" @@ -9378,6 +9384,7 @@ dependencies = [ "lsp-types", "move-command-line-common", "move-compiler", + "move-core-types", "move-ir-types", "move-package", "move-symbol-pool", @@ -9422,6 +9429,7 @@ dependencies = [ "move-ir-types", "move-symbol-pool", "serde", + "serde_json", ] [[package]] @@ -9429,6 +9437,7 @@ name = "move-bytecode-utils" version = "0.1.0" dependencies = [ "anyhow", + "indexmap 2.5.0", "move-binary-format", "move-core-types", "petgraph 0.5.1", @@ -9549,11 +9558,13 @@ dependencies = [ "move-symbol-pool", "once_cell", "petgraph 0.5.1", + "rayon", "regex", "serde", "serde_json", "similar", "stacker", + "tempfile", "vfs", ] @@ -9578,6 +9589,7 @@ dependencies = [ "ref-cast", "serde", "serde_bytes", + "serde_with", "thiserror", "uint", ] @@ -9591,6 +9603,7 @@ dependencies = [ "clap", "codespan", "colored", + "indexmap 2.5.0", "move-abstract-interpreter", "move-binary-format", "move-bytecode-source-map", @@ -9608,8 +9621,8 @@ dependencies = [ "anyhow", "bcs", "clap", - "colored", "hex", + "inline_colorization", "move-abstract-interpreter", "move-binary-format", "move-bytecode-source-map", @@ -9900,6 +9913,7 @@ dependencies = [ "move-ir-types", "move-stdlib-natives", "move-symbol-pool", + "move-trace-format", "move-vm-profiler", "move-vm-runtime", "move-vm-test-utils", @@ -9938,6 +9952,7 @@ dependencies = [ "move-binary-format", "move-bytecode-verifier", "move-core-types", + "move-trace-format", "move-vm-config", "move-vm-profiler", "move-vm-types", diff --git a/crates/iota-core/src/unit_tests/authority_tests.rs b/crates/iota-core/src/unit_tests/authority_tests.rs index 208a4631bf5..19624c399ac 100644 --- a/crates/iota-core/src/unit_tests/authority_tests.rs +++ b/crates/iota-core/src/unit_tests/authority_tests.rs @@ -3,7 +3,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::{collections::HashSet, convert::TryInto, env, fs}; +use std::{collections::HashSet, convert::TryInto, env, fs, str::FromStr}; use bcs; use fastcrypto::traits::KeyPair; @@ -47,7 +47,6 @@ use move_core_types::{ ident_str, identifier::{IdentStr, Identifier}, language_storage::{StructTag, TypeTag}, - parser::parse_type_tag, }; use rand::{ Rng, SeedableRng, @@ -3676,7 +3675,7 @@ async fn test_dynamic_field_struct_name_parsing() { assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField)); assert_eq!(json!({"name_str": "Test Name"}), fields[0].name.value); assert_eq!( - parse_type_tag("0x0::object_basics::Name").unwrap(), + TypeTag::from_str("0x0::object_basics::Name").unwrap(), fields[0].name.type_ ) } @@ -3688,7 +3687,10 @@ async fn test_dynamic_field_bytearray_name_parsing() { assert_eq!(fields.len(), 1); assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField)); - assert_eq!(parse_type_tag("vector").unwrap(), fields[0].name.type_); + assert_eq!( + TypeTag::from_str("vector").unwrap(), + fields[0].name.type_ + ); assert_eq!(json!("Test Name".as_bytes()), fields[0].name.value); } @@ -3699,7 +3701,7 @@ async fn test_dynamic_field_address_name_parsing() { assert_eq!(fields.len(), 1); assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField)); - assert_eq!(parse_type_tag("address").unwrap(), fields[0].name.type_); + assert_eq!(TypeTag::from_str("address").unwrap(), fields[0].name.type_); assert_eq!(json!(sender), fields[0].name.value); } @@ -3711,7 +3713,7 @@ async fn test_dynamic_object_field_struct_name_parsing() { assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject)); assert_eq!(json!({"name_str": "Test Name"}), fields[0].name.value); assert_eq!( - parse_type_tag("0x0::object_basics::Name").unwrap(), + TypeTag::from_str("0x0::object_basics::Name").unwrap(), fields[0].name.type_ ) } @@ -3723,7 +3725,10 @@ async fn test_dynamic_object_field_bytearray_name_parsing() { assert_eq!(fields.len(), 1); assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject)); - assert_eq!(parse_type_tag("vector").unwrap(), fields[0].name.type_); + assert_eq!( + TypeTag::from_str("vector").unwrap(), + fields[0].name.type_ + ); assert_eq!(json!("Test Name".as_bytes()), fields[0].name.value); } @@ -3734,7 +3739,7 @@ async fn test_dynamic_object_field_address_name_parsing() { assert_eq!(fields.len(), 1); assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject)); - assert_eq!(parse_type_tag("address").unwrap(), fields[0].name.type_); + assert_eq!(TypeTag::from_str("address").unwrap(), fields[0].name.type_); assert_eq!(json!(sender), fields[0].name.value); } diff --git a/crates/iota-core/src/unit_tests/subscription_handler_tests.rs b/crates/iota-core/src/unit_tests/subscription_handler_tests.rs index c2015b9d508..65678f92bca 100644 --- a/crates/iota-core/src/unit_tests/subscription_handler_tests.rs +++ b/crates/iota-core/src/unit_tests/subscription_handler_tests.rs @@ -82,11 +82,11 @@ impl TestEvent { fn layout() -> MoveStructLayout { MoveStructLayout { type_: Self::type_(), - fields: vec![ + fields: Box::new(vec![ MoveFieldLayout::new(ident_str!("creator").to_owned(), MoveTypeLayout::Address), MoveFieldLayout::new( ident_str!("name").to_owned(), - MoveTypeLayout::Struct(UTF8String::layout()), + MoveTypeLayout::Struct(Box::new(UTF8String::layout())), ), MoveFieldLayout::new( ident_str!("data").to_owned(), @@ -94,9 +94,11 @@ impl TestEvent { ), MoveFieldLayout::new( ident_str!("coins").to_owned(), - MoveTypeLayout::Vector(Box::new(MoveTypeLayout::Struct(GasCoin::layout()))), + MoveTypeLayout::Vector(Box::new(MoveTypeLayout::Struct(Box::new( + GasCoin::layout(), + )))), ), - ], + ]), } } } @@ -128,10 +130,10 @@ impl UTF8String { fn layout() -> MoveStructLayout { MoveStructLayout { type_: Self::type_(), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("bytes").to_owned(), MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - )], + )]), } } } diff --git a/crates/iota-framework/src/lib.rs b/crates/iota-framework/src/lib.rs index 1fb3d8da931..f4b68ba7ed8 100644 --- a/crates/iota-framework/src/lib.rs +++ b/crates/iota-framework/src/lib.rs @@ -14,10 +14,7 @@ use iota_types::{ storage::ObjectStore, }; use move_binary_format::{ - CompiledModule, - binary_config::BinaryConfig, - compatibility::Compatibility, - file_format::{Ability, AbilitySet}, + CompiledModule, binary_config::BinaryConfig, compatibility::Compatibility, }; use move_core_types::gas_algebra::InternalGas; use once_cell::sync::Lazy; @@ -222,23 +219,7 @@ pub async fn compare_system_package( return Some(cur_ref); } - let compatibility = Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: false, - // Checking `entry` linkage is required because system packages are updated in-place, and a - // transaction that was rolled back to make way for reconfiguration should still be runnable - // after a reconfiguration that upgraded the framework. - // - // A transaction that calls a system function that was previously `entry` and is now private - // will fail because its entrypoint became no longer callable. A transaction that calls a - // system function that was previously `public entry` and is now just `public` could also - // fail if one of its mutable inputs was being used in another private `entry` function. - check_private_entry_linking: true, - disallowed_new_abilities: AbilitySet::singleton(Ability::Key), - disallow_change_datatype_type_params: true, - disallow_new_variants: true, - }; + let compatibility = Compatibility::framework_upgrade_check(); let new_pkg = new_object .data diff --git a/crates/iota-graphql-rpc/src/types/move_type.rs b/crates/iota-graphql-rpc/src/types/move_type.rs index 44227f90de5..758f06b9352 100644 --- a/crates/iota-graphql-rpc/src/types/move_type.rs +++ b/crates/iota-graphql-rpc/src/types/move_type.rs @@ -260,8 +260,8 @@ impl TryFrom for MoveTypeLayout { TL::Address => Self::Address, TL::Vector(v) => Self::Vector(Box::new(Self::try_from(*v)?)), - TL::Struct(s) => Self::Struct(s.try_into()?), - TL::Enum(e) => Self::Enum(e.try_into()?), + TL::Struct(s) => Self::Struct((*s).try_into()?), + TL::Enum(e) => Self::Enum((*e).try_into()?), }) } } diff --git a/crates/iota-graphql-rpc/src/types/move_value.rs b/crates/iota-graphql-rpc/src/types/move_value.rs index d0e31fe47e4..cacbf7b7d86 100644 --- a/crates/iota-graphql-rpc/src/types/move_value.rs +++ b/crates/iota-graphql-rpc/src/types/move_value.rs @@ -487,13 +487,13 @@ mod tests { macro_rules! struct_layout { ($type:literal { $($name:literal : $layout:expr),* $(,)?}) => { - A::MoveTypeLayout::Struct(S { + A::MoveTypeLayout::Struct(Box::new(S { type_: StructTag::from_str($type).expect("Failed to parse struct"), - fields: vec![$(MoveFieldLayout { + fields: Box::new(vec![$(MoveFieldLayout { name: ident_str!($name).to_owned(), layout: $layout, - }),*] - }) + }),*]) + })) } } diff --git a/crates/iota-indexer/src/handlers/checkpoint_handler.rs b/crates/iota-indexer/src/handlers/checkpoint_handler.rs index 3d8489f03b9..29b959a5767 100644 --- a/crates/iota-indexer/src/handlers/checkpoint_handler.rs +++ b/crates/iota-indexer/src/handlers/checkpoint_handler.rs @@ -746,7 +746,7 @@ async fn get_move_struct_layout_map( move_core_types::annotated_value::MoveStructLayout, ), IndexerError, - >((struct_tag, move_struct_layout)) + >((struct_tag, *move_struct_layout)) } }) .collect::>(); diff --git a/crates/iota-indexer/src/models/objects.rs b/crates/iota-indexer/src/models/objects.rs index 50aeee95151..482fc5b9ec0 100644 --- a/crates/iota-indexer/src/models/objects.rs +++ b/crates/iota-indexer/src/models/objects.rs @@ -316,7 +316,7 @@ impl StoredObject { )), }?; - Ok(ObjectRead::Exists(oref, object, Some(move_struct_layout))) + Ok(ObjectRead::Exists(oref, object, Some(*move_struct_layout))) } pub async fn try_into_expectant_dynamic_field_info( diff --git a/crates/iota-json/src/lib.rs b/crates/iota-json/src/lib.rs index 77b9759e2ce..bd83ccaf748 100644 --- a/crates/iota-json/src/lib.rs +++ b/crates/iota-json/src/lib.rs @@ -227,7 +227,7 @@ impl IotaJsonValue { with one field of address or u8 vector type" ), }, - MoveTypeLayout::Struct(MoveStructLayout { type_, .. }) if type_ == &ID::type_() => { + MoveTypeLayout::Struct(struct_layout) if struct_layout.type_ == ID::type_() => { Ok(R::MoveValue::Struct(R::MoveStruct(vec![ Self::to_move_value(val, &inner_vec[0].layout.clone())?, ]))) @@ -282,27 +282,27 @@ impl IotaJsonValue { R::MoveValue::U256(convert_string_to_u256(s.as_str())?) } // For ascii and utf8 strings - ( - JsonValue::String(s), - MoveTypeLayout::Struct(MoveStructLayout { type_, fields: _ }), - ) if is_move_string_type(type_) => { + (JsonValue::String(s), MoveTypeLayout::Struct(struct_layout)) + if is_move_string_type(&struct_layout.type_) => + { R::MoveValue::Vector(s.as_bytes().iter().copied().map(R::MoveValue::U8).collect()) } // For ID - (JsonValue::String(s), MoveTypeLayout::Struct(MoveStructLayout { type_, fields })) - if type_ == &ID::type_() => + (JsonValue::String(s), MoveTypeLayout::Struct(struct_layout)) + if struct_layout.type_ == ID::type_() => { - if fields.len() != 1 { + if struct_layout.fields.len() != 1 { bail!( - "Cannot convert string arg {s} to {type_} which is expected to be a struct with one field" + "Cannot convert string arg {s} to {} which is expected to be a struct with one field", + struct_layout.type_ ); }; let addr = IotaAddress::from_str(s)?; R::MoveValue::Address(addr.into()) } - (JsonValue::Object(o), MoveTypeLayout::Struct(MoveStructLayout { fields, .. })) => { + (JsonValue::Object(o), MoveTypeLayout::Struct(struct_layout)) => { let mut field_values = vec![]; - for layout in fields { + for layout in struct_layout.fields.iter() { let field = o .get(layout.name.as_str()) .ok_or_else(|| anyhow!("Missing field {} for struct {ty}", layout.name))?; @@ -311,10 +311,8 @@ impl IotaJsonValue { R::MoveValue::Struct(R::MoveStruct(field_values)) } // Unnest fields - (value, MoveTypeLayout::Struct(MoveStructLayout { fields, .. })) - if fields.len() == 1 => - { - Self::to_move_value(value, &fields[0].layout)? + (value, MoveTypeLayout::Struct(struct_layout)) if struct_layout.fields.len() == 1 => { + Self::to_move_value(value, &struct_layout.fields[0].layout)? } (JsonValue::String(s), MoveTypeLayout::Vector(t)) => { match &**t { @@ -337,8 +335,8 @@ impl IotaJsonValue { }; R::MoveValue::Vector(vec.iter().copied().map(R::MoveValue::U8).collect()) } - MoveTypeLayout::Struct(MoveStructLayout { fields: inner, .. }) => { - Self::handle_inner_struct_layout(inner, val, ty, s)? + MoveTypeLayout::Struct(struct_layout) => { + Self::handle_inner_struct_layout(&struct_layout.fields, val, ty, s)? } _ => bail!("Cannot convert string arg {s} to {ty}"), } @@ -606,37 +604,37 @@ pub fn primitive_type( if resolved_struct == RESOLVED_ASCII_STR { ( true, - Some(MoveTypeLayout::Struct(MoveStructLayout { + Some(MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: resolved_to_struct(RESOLVED_ASCII_STR), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("bytes").into(), MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - )], - })), + )]), + }))), ) } else if resolved_struct == RESOLVED_UTF8_STR { // both structs structs representing strings have one field - a vector of type // u8 ( true, - Some(MoveTypeLayout::Struct(MoveStructLayout { + Some(MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: resolved_to_struct(RESOLVED_UTF8_STR), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("bytes").into(), MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - )], - })), + )]), + }))), ) } else if resolved_struct == RESOLVED_IOTA_ID { ( true, - Some(MoveTypeLayout::Struct(MoveStructLayout { + Some(MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: resolved_to_struct(RESOLVED_IOTA_ID), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("bytes").into(), MoveTypeLayout::Address, - )], - })), + )]), + }))), ) } else { (false, None) diff --git a/crates/iota-json/src/tests.rs b/crates/iota-json/src/tests.rs index 6a899b12ebd..4ebdea2ed27 100644 --- a/crates/iota-json/src/tests.rs +++ b/crates/iota-json/src/tests.rs @@ -622,18 +622,18 @@ fn test_from_str() { fn test_iota_call_arg_string_type() { let arg1 = bcs::to_bytes("Some String").unwrap(); - let string_layout = Some(MoveTypeLayout::Struct(MoveStructLayout { + let string_layout = Some(MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_ASCII_MODULE_NAME.into(), name: STD_ASCII_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout { + fields: Box::new(vec![MoveFieldLayout { name: ident_str!("bytes").into(), layout: MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - }], - })); + }]), + }))); let v = IotaJsonValue::from_bcs_bytes(string_layout.as_ref(), &arg1).unwrap(); assert_eq!(json! {"Some String"}, v.to_json_value()); @@ -643,31 +643,31 @@ fn test_iota_call_arg_string_type() { fn test_iota_call_arg_option_type() { let arg1 = bcs::to_bytes(&Some("Some String")).unwrap(); - let string_layout = MoveTypeLayout::Struct(MoveStructLayout { + let string_layout = MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_ASCII_MODULE_NAME.into(), name: STD_ASCII_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout { + fields: Box::new(vec![MoveFieldLayout { name: ident_str!("bytes").into(), layout: MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - }], - }); + }]), + })); - let option_layout = MoveTypeLayout::Struct(MoveStructLayout { + let option_layout = MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_OPTION_MODULE_NAME.into(), name: STD_OPTION_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout { + fields: Box::new(vec![MoveFieldLayout { name: ident_str!("vec").into(), layout: MoveTypeLayout::Vector(Box::new(string_layout.clone())), - }], - }); + }]), + })); let v = IotaJsonValue::from_bcs_bytes(Some(option_layout).as_ref(), &arg1).unwrap(); @@ -684,7 +684,7 @@ fn test_iota_call_arg_option_type() { #[test] fn test_convert_struct() { - let layout = MoveTypeLayout::Struct(GasCoin::layout()); + let layout = MoveTypeLayout::Struct(Box::new(GasCoin::layout())); let value = json!({"id":"0xf1416fe18c7baa1673187375777a7606708481311cb3548509ec91a5871c6b9a", "balance": "1000000"}); let iota_json = IotaJsonValue::new(value).unwrap(); @@ -706,18 +706,18 @@ fn test_convert_struct() { fn test_convert_string_vec() { let test_vec = vec!["0xbbb", "test_str"]; let bcs = bcs::to_bytes(&test_vec).unwrap(); - let string_layout = MoveTypeLayout::Struct(MoveStructLayout { + let string_layout = MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_ASCII_MODULE_NAME.into(), name: STD_ASCII_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout { + fields: Box::new(vec![MoveFieldLayout { name: ident_str!("bytes").into(), layout: MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - }], - }); + }]), + })); let layout = MoveTypeLayout::Vector(Box::new(string_layout)); @@ -741,31 +741,31 @@ fn test_string_vec_df_name_child_id_eq() { ] }); - let string_layout = MoveTypeLayout::Struct(MoveStructLayout { + let string_layout = MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_ASCII_MODULE_NAME.into(), name: STD_ASCII_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout { + fields: Box::new(vec![MoveFieldLayout { name: ident_str!("bytes").into(), layout: MoveTypeLayout::Vector(Box::new(MoveTypeLayout::U8)), - }], - }); + }]), + })); - let layout = MoveTypeLayout::Struct(MoveStructLayout { + let layout = MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_: StructTag { address: MOVE_STDLIB_ADDRESS, module: STD_ASCII_MODULE_NAME.into(), name: STD_ASCII_STRUCT_NAME.into(), type_params: vec![], }, - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( Identifier::from_str("labels").unwrap(), MoveTypeLayout::Vector(Box::new(string_layout)), - )], - }); + )]), + })); let iota_json = IotaJsonValue::new(name).unwrap(); let bcs2 = iota_json.to_bcs_bytes(&layout).unwrap(); diff --git a/crates/iota-move-build/src/lib.rs b/crates/iota-move-build/src/lib.rs index 260c2ce2ef8..61fc0e700bb 100644 --- a/crates/iota-move-build/src/lib.rs +++ b/crates/iota-move-build/src/lib.rs @@ -26,7 +26,7 @@ use move_binary_format::{ CompiledModule, normalized::{self, Type}, }; -use move_bytecode_utils::{layout::SerdeLayoutBuilder, module_cache::GetModule}; +use move_bytecode_utils::{Modules, layout::SerdeLayoutBuilder, module_cache::GetModule}; use move_compiler::{ compiled_unit::AnnotatedCompiledModule, diagnostics::{Diagnostics, report_diagnostics_to_buffer, report_warnings}, @@ -45,7 +45,7 @@ use move_package::{ }, package_hooks::{PackageHooks, PackageIdentifier}, resolution::resolution_graph::{Package, ResolvedGraph}, - source_package::parsed_manifest::{CustomDepInfo, SourceManifest}, + source_package::parsed_manifest::{OnChainInfo, SourceManifest}, }; use move_symbol_pool::Symbol; use serde_reflection::Registry; @@ -318,11 +318,10 @@ impl CompiledPackage { &self, with_unpublished_deps: bool, ) -> Vec { - let all_modules = self.package.all_modules_map(); - let graph = all_modules.compute_dependency_graph(); + let all_modules = Modules::new(self.get_modules_and_deps()); // SAFETY: package built successfully - let modules = graph.compute_topological_order().unwrap(); + let modules = all_modules.compute_topological_order().unwrap(); if with_unpublished_deps { // For each transitive dependent module, if they are not to be published, they @@ -602,14 +601,10 @@ impl PackageHooks for IotaPackageHooks { ] } - fn custom_dependency_key(&self) -> Option { - None - } - - fn resolve_custom_dependency( + fn resolve_on_chain_dependency( &self, _dep_name: move_symbol_pool::Symbol, - _info: &CustomDepInfo, + _info: &OnChainInfo, ) -> anyhow::Result<()> { Ok(()) } @@ -618,7 +613,9 @@ impl PackageHooks for IotaPackageHooks { &self, manifest: &SourceManifest, ) -> anyhow::Result { - if !cfg!(debug_assertions) && manifest.package.edition == Some(Edition::DEVELOPMENT) { + if (!cfg!(debug_assertions) || cfg!(test)) + && manifest.package.edition == Some(Edition::DEVELOPMENT) + { return Err(Edition::DEVELOPMENT.unknown_edition_error()); } Ok(manifest.package.name) diff --git a/crates/iota-node/src/main.rs b/crates/iota-node/src/main.rs index 09b001d78bb..673d1666f42 100644 --- a/crates/iota-node/src/main.rs +++ b/crates/iota-node/src/main.rs @@ -44,8 +44,8 @@ fn main() { // figure out how to eliminate crashes in prod because of this. // ProtocolConfig::poison_get_for_min_version(); - move_vm_profiler::gas_profiler_feature_enabled! { - panic!("Cannot run the iota-node binary with gas-profiler feature enabled"); + move_vm_profiler::tracing_feature_enabled! { + panic!("Cannot run the iota-node binary with tracing feature enabled"); } let args = Args::parse(); diff --git a/crates/iota-open-rpc/src/examples.rs b/crates/iota-open-rpc/src/examples.rs index a98c62a0623..51a391a5749 100644 --- a/crates/iota-open-rpc/src/examples.rs +++ b/crates/iota-open-rpc/src/examples.rs @@ -1111,7 +1111,7 @@ impl RpcExampleProvider { }, MoveStructLayout { type_: struct_tag, - fields: Vec::new(), + fields: Box::new(Vec::new()), }, ) .unwrap(), diff --git a/crates/iota-package-resolver/src/lib.rs b/crates/iota-package-resolver/src/lib.rs index 05ed900b686..099c5e7d4cb 100644 --- a/crates/iota-package-resolver/src/lib.rs +++ b/crates/iota-package-resolver/src/lib.rs @@ -1503,10 +1503,10 @@ impl<'l> ResolutionContext<'l> { } ( - MoveTypeLayout::Struct(MoveStructLayout { + MoveTypeLayout::Struct(Box::new(MoveStructLayout { type_, - fields: resolved_fields, - }), + fields: Box::new(resolved_fields), + })), field_depth + 1, ) } @@ -1531,10 +1531,10 @@ impl<'l> ResolutionContext<'l> { } ( - MoveTypeLayout::Enum(MoveEnumLayout { + MoveTypeLayout::Enum(Box::new(MoveEnumLayout { type_, variants: resolved_variants, - }), + })), field_depth + 1, ) } diff --git a/crates/iota-replay/src/data_fetcher.rs b/crates/iota-replay/src/data_fetcher.rs index 70749a03dbe..19851d6a9fd 100644 --- a/crates/iota-replay/src/data_fetcher.rs +++ b/crates/iota-replay/src/data_fetcher.rs @@ -23,7 +23,7 @@ use iota_types::{ }, }; use lru::LruCache; -use move_core_types::parser::parse_struct_tag; +use move_core_types::language_storage::StructTag; use parking_lot::RwLock; use rand::Rng; @@ -555,7 +555,7 @@ impl DataFetcher for RemoteFetcher { reverse: bool, ) -> Result, ReplayEngineError> { let struct_tag_str = EPOCH_CHANGE_STRUCT_TAG.to_string(); - let struct_tag = parse_struct_tag(&struct_tag_str)?; + let struct_tag = StructTag::from_str(&struct_tag_str)?; let mut epoch_change_events: Vec = vec![]; let mut has_next_page = true; diff --git a/crates/iota-source-validation/src/toolchain.rs b/crates/iota-source-validation/src/toolchain.rs index 56c6cda08b8..88515eb744b 100644 --- a/crates/iota-source-validation/src/toolchain.rs +++ b/crates/iota-source-validation/src/toolchain.rs @@ -41,7 +41,7 @@ use tracing::{debug, info}; pub(crate) const CURRENT_COMPILER_VERSION: &str = env!("CARGO_PKG_VERSION"); const LEGACY_COMPILER_VERSION: &str = CURRENT_COMPILER_VERSION; // TODO: update this when Move 2024 is released -const PRE_TOOLCHAIN_MOVE_LOCK_VERSION: u64 = 0; // Used to detect lockfiles pre-toolchain versioning support +const PRE_TOOLCHAIN_MOVE_LOCK_VERSION: u16 = 0; // Used to detect lockfiles pre-toolchain versioning support const CANONICAL_UNIX_BINARY_NAME: &str = "iota"; const CANONICAL_WIN_BINARY_NAME: &str = "iota.exe"; diff --git a/crates/iota-transactional-test-runner/src/args.rs b/crates/iota-transactional-test-runner/src/args.rs index 2379237cc51..da43f0190c9 100644 --- a/crates/iota-transactional-test-runner/src/args.rs +++ b/crates/iota-transactional-test-runner/src/args.rs @@ -11,12 +11,12 @@ use iota_types::{ programmable_transaction_builder::ProgrammableTransactionBuilder, transaction::{Argument, CallArg, ObjectArg}, }; -use move_command_line_common::{ - parser::{Parser as MoveCLParser, parse_u64, parse_u256}, - values::{ParsableValue, ParsedValue, ValueToken}, -}; use move_compiler::editions::Flavor; use move_core_types::{ + parsing::{ + parser::{Parser as MoveCLParser, parse_u64, parse_u256}, + values::{ParsableValue, ParsedValue, ValueToken}, + }, runtime_value::{MoveStruct, MoveValue}, u256::U256, }; diff --git a/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/parser.rs b/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/parser.rs index e1fbf7a8596..2681fc0b367 100644 --- a/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/parser.rs +++ b/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/parser.rs @@ -9,11 +9,14 @@ use iota_types::{ base_types::ObjectID, transaction::{Argument, Command, ProgrammableMoveCall}, }; -use move_command_line_common::{ - parser::{Parser, Token}, - types::{ParsedType, TypeToken}, +use move_core_types::{ + account_address::AccountAddress, + identifier::Identifier, + parsing::{ + parser::{Parser, Token}, + types::{ParsedType, TypeToken}, + }, }; -use move_core_types::{account_address::AccountAddress, identifier::Identifier}; use super::token::CommandToken; use crate::programmable_transaction_test_parser::token::{ diff --git a/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/token.rs b/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/token.rs index cc02eee8a40..8fc2a69b476 100644 --- a/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/token.rs +++ b/crates/iota-transactional-test-runner/src/programmable_transaction_test_parser/token.rs @@ -5,8 +5,7 @@ use std::fmt::{self, Display}; use anyhow::bail; -use move_command_line_common::parser::Token; -use move_core_types::identifier; +use move_core_types::{identifier, parsing::parser::Token}; #[derive(Eq, PartialEq, Debug, Clone, Copy)] pub enum CommandToken { diff --git a/crates/iota-transactional-test-runner/src/test_adapter.rs b/crates/iota-transactional-test-runner/src/test_adapter.rs index 268fe616239..10d264c0967 100644 --- a/crates/iota-transactional-test-runner/src/test_adapter.rs +++ b/crates/iota-transactional-test-runner/src/test_adapter.rs @@ -66,9 +66,7 @@ use iota_types::{ }; use move_binary_format::CompiledModule; use move_bytecode_utils::module_cache::GetModule; -use move_command_line_common::{ - address::ParsedAddress, files::verify_and_create_named_address_mapping, -}; +use move_command_line_common::files::verify_and_create_named_address_mapping; use move_compiler::{ Flags, FullyCompiledProgram, editions::{Edition, Flavor}, @@ -79,6 +77,7 @@ use move_core_types::{ ident_str, identifier::IdentStr, language_storage::{ModuleId, TypeTag}, + parsing::address::ParsedAddress, }; use move_symbol_pool::Symbol; use move_transactional_test_runner::{ diff --git a/crates/iota-types/Cargo.toml b/crates/iota-types/Cargo.toml index 9d229d4ed41..034325deb0a 100644 --- a/crates/iota-types/Cargo.toml +++ b/crates/iota-types/Cargo.toml @@ -104,10 +104,9 @@ harness = false [features] default = [] test-utils = [] -gas-profiler = [ - "move-vm-profiler/gas-profiler", - "move-vm-test-utils/gas-profiler", - "move-vm-types/gas-profiler", +tracing = [ + "move-vm-profiler/tracing", + "move-vm-test-utils/tracing", ] fuzzing = ["move-core-types/fuzzing", "dep:proptest-derive", "dep:proptest"] diff --git a/crates/iota-types/src/balance.rs b/crates/iota-types/src/balance.rs index fa7e354cc7a..54b8749809b 100644 --- a/crates/iota-types/src/balance.rs +++ b/crates/iota-types/src/balance.rs @@ -86,10 +86,10 @@ impl Balance { pub fn layout(type_param: TypeTag) -> MoveStructLayout { MoveStructLayout { type_: Self::type_(type_param), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("value").to_owned(), MoveTypeLayout::U64, - )], + )]), } } } diff --git a/crates/iota-types/src/coin.rs b/crates/iota-types/src/coin.rs index 6336c75168c..177f8479318 100644 --- a/crates/iota-types/src/coin.rs +++ b/crates/iota-types/src/coin.rs @@ -99,16 +99,16 @@ impl Coin { pub fn layout(type_param: TypeTag) -> MoveStructLayout { MoveStructLayout { type_: Self::type_(type_param.clone()), - fields: vec![ + fields: Box::new(vec![ MoveFieldLayout::new( ident_str!("id").to_owned(), - MoveTypeLayout::Struct(UID::layout()), + MoveTypeLayout::Struct(Box::new(UID::layout())), ), MoveFieldLayout::new( ident_str!("balance").to_owned(), - MoveTypeLayout::Struct(Balance::layout(type_param)), + MoveTypeLayout::Struct(Box::new(Balance::layout(type_param))), ), - ], + ]), } } diff --git a/crates/iota-types/src/id.rs b/crates/iota-types/src/id.rs index 0610c6aaa4b..e65b35a2b26 100644 --- a/crates/iota-types/src/id.rs +++ b/crates/iota-types/src/id.rs @@ -61,10 +61,10 @@ impl UID { pub fn layout() -> MoveStructLayout { MoveStructLayout { type_: Self::type_(), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("id").to_owned(), - MoveTypeLayout::Struct(ID::layout()), - )], + MoveTypeLayout::Struct(Box::new(ID::layout())), + )]), } } } @@ -86,10 +86,10 @@ impl ID { pub fn layout() -> MoveStructLayout { MoveStructLayout { type_: Self::type_(), - fields: vec![MoveFieldLayout::new( + fields: Box::new(vec![MoveFieldLayout::new( ident_str!("bytes").to_owned(), MoveTypeLayout::Address, - )], + )]), } } } diff --git a/crates/iota-types/src/layout_resolver.rs b/crates/iota-types/src/layout_resolver.rs index d6cbed972f7..417099199f0 100644 --- a/crates/iota-types/src/layout_resolver.rs +++ b/crates/iota-types/src/layout_resolver.rs @@ -40,7 +40,7 @@ pub fn get_layout_from_struct_tag( pub fn into_struct_layout(layout: A::MoveDatatypeLayout) -> Result { match layout { - A::MoveDatatypeLayout::Struct(s) => Ok(s), + A::MoveDatatypeLayout::Struct(s) => Ok(*s), A::MoveDatatypeLayout::Enum(e) => Err(IotaError::ObjectSerialization { error: format!("Expected struct layout but got an enum {e:?}"), }), diff --git a/crates/iota-types/src/lib.rs b/crates/iota-types/src/lib.rs index 962434c3c2b..f9805889354 100644 --- a/crates/iota-types/src/lib.rs +++ b/crates/iota-types/src/lib.rs @@ -162,7 +162,7 @@ pub fn iota_framework_address_concat_string(suffix: &str) -> String { /// with no remaining suffix. This function is intended for use within the /// authority codebases. pub fn parse_iota_address(s: &str) -> anyhow::Result { - use move_command_line_common::address::ParsedAddress; + use move_core_types::parsing::address::ParsedAddress; Ok(ParsedAddress::parse(s)? .into_account_address(&resolve_address)? .into()) @@ -173,7 +173,7 @@ pub fn parse_iota_address(s: &str) -> anyhow::Result { /// if `s` matches this format exactly, with no remaining input. This function /// is intended for use within the authority codebases. pub fn parse_iota_module_id(s: &str) -> anyhow::Result { - use move_command_line_common::types::ParsedModuleId; + use move_core_types::parsing::types::ParsedModuleId; ParsedModuleId::parse(s)?.into_module_id(&resolve_address) } @@ -183,7 +183,7 @@ pub fn parse_iota_module_id(s: &str) -> anyhow::Result { /// format exactly, with no remaining input. This function is intended for use /// within the authority codebases. pub fn parse_iota_fq_name(s: &str) -> anyhow::Result<(ModuleId, String)> { - use move_command_line_common::types::ParsedFqName; + use move_core_types::parsing::types::ParsedFqName; ParsedFqName::parse(s)?.into_fq_name(&resolve_address) } @@ -193,7 +193,7 @@ pub fn parse_iota_fq_name(s: &str) -> anyhow::Result<(ModuleId, String)> { /// matches this format exactly, with no remaining input. This function is /// intended for use within the authority codebase. pub fn parse_iota_struct_tag(s: &str) -> anyhow::Result { - use move_command_line_common::types::ParsedStructType; + use move_core_types::parsing::types::ParsedStructType; ParsedStructType::parse(s)?.into_struct_tag(&resolve_address) } @@ -202,7 +202,7 @@ pub fn parse_iota_struct_tag(s: &str) -> anyhow::Result { /// only if `s` matches this format exactly, with no remaining input. This /// function is intended for use within the authority codebase. pub fn parse_iota_type_tag(s: &str) -> anyhow::Result { - use move_command_line_common::types::ParsedType; + use move_core_types::parsing::types::ParsedType; ParsedType::parse(s)?.into_type_tag(&resolve_address) } diff --git a/crates/iota-types/src/object.rs b/crates/iota-types/src/object.rs index 63ef7c06824..ef3f6fdbe6d 100644 --- a/crates/iota-types/src/object.rs +++ b/crates/iota-types/src/object.rs @@ -295,7 +295,7 @@ impl MoveObject { } })?; match layout { - MoveTypeLayout::Struct(l) => Ok(l), + MoveTypeLayout::Struct(l) => Ok(*l), _ => unreachable!( "We called build_with_types on Struct type, should get a struct layout" ), diff --git a/crates/iota-types/src/object/balance_traversal.rs b/crates/iota-types/src/object/balance_traversal.rs index 3e9c9ef87c6..14b101d9a3f 100644 --- a/crates/iota-types/src/object/balance_traversal.rs +++ b/crates/iota-types/src/object/balance_traversal.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use move_core_types::{ - annotated_visitor::{self, StructDriver, Traversal}, + annotated_visitor::{self, StructDriver, Traversal, ValueDriver}, language_storage::{StructTag, TypeTag}, }; @@ -31,12 +31,12 @@ impl BalanceTraversal { } } -impl Traversal for BalanceTraversal { +impl<'b, 'l> Traversal<'b, 'l> for BalanceTraversal { type Error = annotated_visitor::Error; fn traverse_struct( &mut self, - driver: &mut StructDriver<'_, '_, '_>, + driver: &mut StructDriver<'_, 'b, 'l>, ) -> Result<(), Self::Error> { let Some(coin_type) = is_balance(&driver.struct_layout().type_) else { // Not a balance, search recursively for balances among fields. @@ -51,9 +51,13 @@ impl Traversal for BalanceTraversal { } } -impl Traversal for Accumulator { +impl<'b, 'l> Traversal<'b, 'l> for Accumulator { type Error = annotated_visitor::Error; - fn traverse_u64(&mut self, value: u64) -> Result<(), Self::Error> { + fn traverse_u64( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u64, + ) -> Result<(), Self::Error> { self.total += value; Ok(()) } @@ -236,7 +240,7 @@ mod tests { /// Create a Coin layout for testing purposes. fn coin_t(tag: &str) -> A::MoveTypeLayout { layout_(&format!("0x2::coin::Coin<{tag}>"), vec![ - ("id", A::MoveTypeLayout::Struct(UID::layout())), + ("id", A::MoveTypeLayout::Struct(Box::new(UID::layout()))), ("balance", bal_t(tag)), ]) } @@ -265,7 +269,10 @@ mod tests { .map(|(name, layout)| A::MoveFieldLayout::new(Identifier::new(name).unwrap(), layout)) .collect(); - A::MoveTypeLayout::Struct(A::MoveStructLayout { type_, fields }) + A::MoveTypeLayout::Struct(Box::new(A::MoveStructLayout { + type_, + fields: Box::new(fields), + })) } /// BCS encode Move value. diff --git a/crates/iota-types/src/object/bounded_visitor.rs b/crates/iota-types/src/object/bounded_visitor.rs index d8ccf434bf4..6efe1f3c4d1 100644 --- a/crates/iota-types/src/object/bounded_visitor.rs +++ b/crates/iota-types/src/object/bounded_visitor.rs @@ -6,7 +6,7 @@ use anyhow::bail; use move_core_types::{ account_address::AccountAddress, annotated_value as A, - annotated_visitor::{self, StructDriver, VecDriver, Visitor}, + annotated_visitor::{self, StructDriver, ValueDriver, VecDriver, Visitor}, language_storage::TypeTag, u256::U256, }; @@ -152,49 +152,85 @@ impl BoundedVisitor { } } -impl Visitor for BoundedVisitor { +impl<'b, 'l> Visitor<'b, 'l> for BoundedVisitor { type Value = A::MoveValue; type Error = Error; - fn visit_u8(&mut self, value: u8) -> Result { + fn visit_u8( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u8, + ) -> Result { Ok(A::MoveValue::U8(value)) } - fn visit_u16(&mut self, value: u16) -> Result { + fn visit_u16( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u16, + ) -> Result { Ok(A::MoveValue::U16(value)) } - fn visit_u32(&mut self, value: u32) -> Result { + fn visit_u32( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u32, + ) -> Result { Ok(A::MoveValue::U32(value)) } - fn visit_u64(&mut self, value: u64) -> Result { + fn visit_u64( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u64, + ) -> Result { Ok(A::MoveValue::U64(value)) } - fn visit_u128(&mut self, value: u128) -> Result { + fn visit_u128( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: u128, + ) -> Result { Ok(A::MoveValue::U128(value)) } - fn visit_u256(&mut self, value: U256) -> Result { + fn visit_u256( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: U256, + ) -> Result { Ok(A::MoveValue::U256(value)) } - fn visit_bool(&mut self, value: bool) -> Result { + fn visit_bool( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: bool, + ) -> Result { Ok(A::MoveValue::Bool(value)) } - fn visit_address(&mut self, value: AccountAddress) -> Result { + fn visit_address( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: AccountAddress, + ) -> Result { Ok(A::MoveValue::Address(value)) } - fn visit_signer(&mut self, value: AccountAddress) -> Result { + fn visit_signer( + &mut self, + _driver: &ValueDriver<'_, 'b, 'l>, + value: AccountAddress, + ) -> Result { Ok(A::MoveValue::Signer(value)) } fn visit_vector( &mut self, - driver: &mut VecDriver<'_, '_, '_>, + driver: &mut VecDriver<'_, 'b, 'l>, ) -> Result { let mut elems = vec![]; while let Some(elem) = driver.next_element(self)? { @@ -206,12 +242,12 @@ impl Visitor for BoundedVisitor { fn visit_struct( &mut self, - driver: &mut StructDriver<'_, '_, '_>, + driver: &mut StructDriver<'_, 'b, 'l>, ) -> Result { let tag = driver.struct_layout().type_.clone().into(); self.debit_type_size(&tag)?; - for field in &driver.struct_layout().fields { + for field in driver.struct_layout().fields.iter() { self.debit(field.name.len())?; } @@ -232,7 +268,7 @@ impl Visitor for BoundedVisitor { fn visit_variant( &mut self, - driver: &mut annotated_visitor::VariantDriver<'_, '_, '_>, + driver: &mut annotated_visitor::VariantDriver<'_, 'b, 'l>, ) -> Result { let type_ = driver.enum_layout().type_.clone().into(); @@ -459,7 +495,10 @@ mod tests { .map(|(name, layout)| A::MoveFieldLayout::new(Identifier::new(name).unwrap(), layout)) .collect(); - A::MoveTypeLayout::Struct(A::MoveStructLayout { type_, fields }) + A::MoveTypeLayout::Struct(Box::new(A::MoveStructLayout { + type_, + fields: Box::new(fields), + })) } /// BCS encode Move value. diff --git a/crates/iota-upgrade-compatibility-transactional-tests/tests/tests.rs b/crates/iota-upgrade-compatibility-transactional-tests/tests/tests.rs index 8fe573d592b..7e9dbe9a355 100644 --- a/crates/iota-upgrade-compatibility-transactional-tests/tests/tests.rs +++ b/crates/iota-upgrade-compatibility-transactional-tests/tests/tests.rs @@ -8,7 +8,6 @@ use iota_move_build::{BuildConfig, IotaPackageHooks}; use move_binary_format::{ CompiledModule, compatibility::{Compatibility, InclusionCheck}, - file_format::AbilitySet, normalized, }; @@ -54,47 +53,12 @@ fn check_all_compatibilities( assert_eq!(base.len(), upgraded.len()); let compatibility_types = [ + // Full compat skip check private entry linking + Compatibility::upgrade_check(), + // Full compat but allow any new abilities Compatibility::full_check(), - // Full compat but allow private entry functions to change - Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: true, - check_private_entry_linking: false, - disallowed_new_abilities: AbilitySet::ALL, - disallow_change_datatype_type_params: true, - disallow_new_variants: true, - }, - // Full compat but allow private entry functions and friends to change - Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: false, - check_private_entry_linking: false, - disallowed_new_abilities: AbilitySet::ALL, - disallow_change_datatype_type_params: true, - disallow_new_variants: true, - }, - // Full compat but allow friends to change - Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: false, - check_private_entry_linking: true, - disallowed_new_abilities: AbilitySet::ALL, - disallow_change_datatype_type_params: true, - disallow_new_variants: true, - }, - // Full compat but allow new enum variants to be added - Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: true, - check_private_entry_linking: true, - disallowed_new_abilities: AbilitySet::ALL, - disallow_change_datatype_type_params: true, - disallow_new_variants: true, - }, + // Full compat only disallow new key ability + Compatibility::framework_upgrade_check(), Compatibility::no_check(), ]; diff --git a/crates/iota/Cargo.toml b/crates/iota/Cargo.toml index 8f6435f5f12..bf13542d328 100644 --- a/crates/iota/Cargo.toml +++ b/crates/iota/Cargo.toml @@ -126,5 +126,5 @@ name = "ptb_files_tests" harness = false [features] -gas-profiler = ["iota-types/gas-profiler", "iota-execution/gas-profiler"] +tracing = ["iota-types/tracing", "iota-execution/tracing"] indexer = ["dep:diesel", "dep:iota-indexer", "dep:iota-graphql-rpc"] diff --git a/crates/iota/src/client_commands.rs b/crates/iota/src/client_commands.rs index dfb34bb8808..051ab49f9a9 100644 --- a/crates/iota/src/client_commands.rs +++ b/crates/iota/src/client_commands.rs @@ -775,10 +775,10 @@ impl IotaClientCommands { tx_digest, profile_output, } => { - move_vm_profiler::gas_profiler_feature_disabled! { + move_vm_profiler::tracing_feature_disabled! { bail!( - "gas-profiler feature is not enabled, rebuild or reinstall with \ - --features gas-profiler" + "tracing feature is not enabled, rebuild or reinstall with \ + --features tracing" ); }; diff --git a/crates/iota/src/client_ptb/ast.rs b/crates/iota/src/client_ptb/ast.rs index e07b2dec8d7..8a1bc1bb30b 100644 --- a/crates/iota/src/client_ptb/ast.rs +++ b/crates/iota/src/client_ptb/ast.rs @@ -8,11 +8,13 @@ use iota_types::{ Identifier, TypeTag, base_types::{ObjectID, RESOLVED_ASCII_STR, RESOLVED_STD_OPTION, RESOLVED_UTF8_STR}, }; -use move_command_line_common::{ - address::{NumericalAddress, ParsedAddress}, - types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType}, +use move_core_types::{ + parsing::{ + address::{NumericalAddress, ParsedAddress}, + types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType}, + }, + runtime_value::MoveValue, }; -use move_core_types::runtime_value::MoveValue; use super::error::{PTBResult, Span, Spanned}; use crate::{err, error, sp}; diff --git a/crates/iota/src/client_ptb/builder.rs b/crates/iota/src/client_ptb/builder.rs index c64514e2f48..c1c5930eee6 100644 --- a/crates/iota/src/client_ptb/builder.rs +++ b/crates/iota/src/client_ptb/builder.rs @@ -24,12 +24,14 @@ use miette::Severity; use move_binary_format::{ CompiledModule, binary_config::BinaryConfig, file_format::SignatureToken, }; -use move_command_line_common::{ - address::{NumericalAddress, ParsedAddress}, - parser::NumberFormat, -}; use move_core_types::{ - account_address::AccountAddress, annotated_value::MoveTypeLayout, ident_str, + account_address::AccountAddress, + annotated_value::MoveTypeLayout, + ident_str, + parsing::{ + address::{NumericalAddress, ParsedAddress}, + parser::NumberFormat, + }, }; use move_package::BuildConfig; diff --git a/crates/iota/src/client_ptb/parser.rs b/crates/iota/src/client_ptb/parser.rs index 65c5a7ad11b..e77ad857923 100644 --- a/crates/iota/src/client_ptb/parser.rs +++ b/crates/iota/src/client_ptb/parser.rs @@ -5,7 +5,7 @@ use std::iter::Peekable; use iota_types::{Identifier, base_types::ObjectID}; -use move_command_line_common::{ +use move_core_types::parsing::{ address::{NumericalAddress, ParsedAddress}, parser::{parse_u8, parse_u16, parse_u32, parse_u64, parse_u128, parse_u256}, types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType}, diff --git a/crates/iota/src/unit_tests/profiler_tests.rs b/crates/iota/src/unit_tests/profiler_tests.rs index ac053d7b032..2baaef80a74 100644 --- a/crates/iota/src/unit_tests/profiler_tests.rs +++ b/crates/iota/src/unit_tests/profiler_tests.rs @@ -3,18 +3,18 @@ // SPDX-License-Identifier: Apache-2.0 /// This test exists to make sure that the feature gating for all the code under -/// `gas-profiler` remains fully connected such that if and only if we enable -/// the feature here, the `gas-profiler` feature gets enabled anywhere. +/// `tracing` remains fully connected such that if and only if we enable the +/// feature here, the `tracing` feature gets enabled anywhere. /// /// If this test fails, check for the following. /// -/// Any crate that has code decorated with #[cfg(feature = "gas-profiler")] -/// needs to have a feature declared in its Cargo.toml named `gas-profiler`. If -/// moving / refactoring code with this decorator from a crate to a different -/// crate, it is likely needed to copy over some of the feature declaration -/// defined in the original crate. Also ensure we do not include the feature in -/// any dependency of the dependencies section so that the feature won't get -/// partially enabled as default. +/// Any crate that has code decorated with #[cfg(feature = "tracing")] needs to +/// have a feature declared in its Cargo.toml named `tracing`. If moving / +/// refactoring code with this decorator from a crate to a different crate, it +/// is likely needed to copy over some of the feature declaration defined in the +/// original crate. Also ensure we do not include the feature in any dependency +/// of the dependencies section so that the feature won't get partially enabled +/// as default. /// /// Each crate defines its own version of the feature with the same name. We can /// think of these features as a tree structure where the root is defined here @@ -25,18 +25,18 @@ /// current crate depends on. /// /// Note this crate will always have the feature enabled in testing due to the -/// addition of `iota = { path = ".", features = ["gas-profiler"] }` to our +/// addition of `iota = { path = ".", features = ["tracing"] }` to our /// dev-dependencies. -#[cfg(feature = "gas-profiler")] +#[cfg(feature = "tracing")] #[test] fn test_macro_shows_feature_enabled() { - move_vm_profiler::gas_profiler_feature_disabled! { + move_vm_profiler::tracing_feature_disabled! { panic!("gas profile feature graph became disconnected"); } } -#[cfg(feature = "gas-profiler")] +#[cfg(feature = "tracing")] #[tokio::test(flavor = "multi_thread")] async fn test_profiler() { use std::fs; diff --git a/crates/iota/tests/cli_tests.rs b/crates/iota/tests/cli_tests.rs index aaded6cecdb..6fe877844ea 100644 --- a/crates/iota/tests/cli_tests.rs +++ b/crates/iota/tests/cli_tests.rs @@ -4512,6 +4512,7 @@ async fn test_move_new() -> Result<(), anyhow::Error> { verbose_mode: false, seed: None, rand_num_iters: None, + trace_execution: None, }, }), } diff --git a/docs/content/developer/dev-cheat-sheet.mdx b/docs/content/developer/dev-cheat-sheet.mdx index aa067459d45..d0a20214c45 100644 --- a/docs/content/developer/dev-cheat-sheet.mdx +++ b/docs/content/developer/dev-cheat-sheet.mdx @@ -19,7 +19,7 @@ Quick reference on best practices for IOTA Network developers. |`iota keytool list`|to list all the address.| |`iota move new first_package`|to create new move package.| |`pnpm create @iota/dapp --template react-client-dapp`| to setup React app with dApp kit| -|`cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features gas-profiler iota`|To get the latest version of CLI| +|`cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features tracing iota`|To get the latest version of CLI| |`iota client active-address`|to get the current address.| |`iota client -–help`|to list out all commands of iota client.| |`iota client new-address Scheme`|to generate address , **Scheme** - (ed25519,secp256k1,secp256r1)| diff --git a/docs/content/references/cli.mdx b/docs/content/references/cli.mdx index aa229d53742..c5e26087d0c 100644 --- a/docs/content/references/cli.mdx +++ b/docs/content/references/cli.mdx @@ -14,12 +14,12 @@ IOTA provides a command line interface (CLI) tool to interact with the IOTA netw To get the latest version of the CLI, you can run the following command from a terminal or console. Be sure to replace `` with `develop`, `devnet`, `testnet`, or `mainnet` to get the desired version. For more information on the branches available, see [IOTA Environment Setup](/developer/getting-started/iota-environment.mdx). ```shell -cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features gas-profiler iota +cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features tracing iota ``` :::info -The `--features gas-profiler` flag is necessary only if you want to run gas profiles for transactions. +The `--features tracing` flag is necessary only if you want to run gas profiles for transactions. ::: diff --git a/docs/content/references/cli/client.mdx b/docs/content/references/cli/client.mdx index 87060609c08..953960f16ac 100644 --- a/docs/content/references/cli/client.mdx +++ b/docs/content/references/cli/client.mdx @@ -472,10 +472,10 @@ and produce a gas profile. Similar to the `replay` command, this command fetches Full node specified in the client environment that are needed to execute the transaction. During the local execution of the transaction, this command records all the Move function invocations and the gas cost breakdown for each invocation. -To enable the profiler, you must either install or build the IOTA Client binary locally with the `--features gas-profiler` flag. +To enable the profiler, you must either install or build the IOTA Client binary locally with the `--features tracing` flag. ```shell -cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features gas-profiler iota +cargo install --locked --git https://github.com/iotaledger/iota.git --branch --features tracing iota ``` The command outputs a profile to the current working directory in the format `gas_profile_{tx_digest}_{unix_timestamp}.json`. diff --git a/iota-execution/Cargo.toml b/iota-execution/Cargo.toml index 4899d7bdbf0..2cbad944365 100644 --- a/iota-execution/Cargo.toml +++ b/iota-execution/Cargo.toml @@ -30,10 +30,10 @@ petgraph = "0.6" [features] default = [] -gas-profiler = [ - "iota-adapter-latest/gas-profiler", - "move-vm-config/gas-profiler", - "move-vm-runtime-latest/gas-profiler", - # "iota-adapter-$CUT/gas-profiler", - # "move-vm-runtime-$CUT/gas-profiler", +tracing = [ + "iota-adapter-latest/tracing", + "move-vm-config/tracing", + "move-vm-runtime-latest/tracing", + # "iota-adapter-$CUT/tracing", + # "move-vm-runtime-$CUT/tracing", ] diff --git a/iota-execution/latest/iota-adapter/Cargo.toml b/iota-execution/latest/iota-adapter/Cargo.toml index 452e5c1dd45..93461caa5c7 100644 --- a/iota-execution/latest/iota-adapter/Cargo.toml +++ b/iota-execution/latest/iota-adapter/Cargo.toml @@ -37,10 +37,9 @@ move-vm-runtime = { path = "../../../external-crates/move/crates/move-vm-runtime move-vm-types.workspace = true [features] -gas-profiler = [ - "iota-types/gas-profiler", - "move-vm-config/gas-profiler", - "move-vm-profiler/gas-profiler", - "move-vm-runtime/gas-profiler", - "move-vm-types/gas-profiler", +tracing = [ + "iota-types/tracing", + "move-vm-config/tracing", + "move-vm-profiler/tracing", + "move-vm-runtime/tracing", ] diff --git a/iota-execution/latest/iota-adapter/src/adapter.rs b/iota-execution/latest/iota-adapter/src/adapter.rs index 295facc2e8f..e85d25989ea 100644 --- a/iota-execution/latest/iota-adapter/src/adapter.rs +++ b/iota-execution/latest/iota-adapter/src/adapter.rs @@ -24,7 +24,7 @@ mod checked { use move_bytecode_verifier::verify_module_with_config_metered; use move_bytecode_verifier_meter::{Meter, Scope}; use move_core_types::account_address::AccountAddress; - #[cfg(feature = "gas-profiler")] + #[cfg(feature = "tracing")] use move_vm_config::runtime::VMProfilerConfig; use move_vm_config::{ runtime::{VMConfig, VMRuntimeLimitsConfig}, @@ -47,9 +47,9 @@ mod checked { protocol_config: &ProtocolConfig, _enable_profiler: Option, ) -> Result { - #[cfg(not(feature = "gas-profiler"))] + #[cfg(not(feature = "tracing"))] let vm_profiler_config = None; - #[cfg(feature = "gas-profiler")] + #[cfg(feature = "tracing")] let vm_profiler_config = _enable_profiler.clone().map(|path| VMProfilerConfig { full_path: path, track_bytecode_instructions: false, @@ -73,6 +73,7 @@ mod checked { binary_config: to_binary_config(protocol_config), rethrow_serialization_type_layout_errors: protocol_config .rethrow_serialization_type_layout_errors(), + max_type_to_layout_nodes: None, // protocol_config.max_type_to_layout_nodes_as_option(), }) .map_err(|_| IotaError::ExecutionInvariantViolation) } diff --git a/iota-execution/latest/iota-adapter/src/programmable_transactions/context.rs b/iota-execution/latest/iota-adapter/src/programmable_transactions/context.rs index cfe7ff20ee5..d1a0d63869b 100644 --- a/iota-execution/latest/iota-adapter/src/programmable_transactions/context.rs +++ b/iota-execution/latest/iota-adapter/src/programmable_transactions/context.rs @@ -200,7 +200,7 @@ mod checked { // Set the profiler if in CLI #[skip_checked_arithmetic] - move_vm_profiler::gas_profiler_feature_enabled! { + move_vm_profiler::tracing_feature_enabled! { use move_vm_profiler::GasProfiler; use move_vm_types::gas::GasMeter; diff --git a/iota-execution/latest/iota-adapter/src/programmable_transactions/execution.rs b/iota-execution/latest/iota-adapter/src/programmable_transactions/execution.rs index 60dff0ae180..f471314560c 100644 --- a/iota-execution/latest/iota-adapter/src/programmable_transactions/execution.rs +++ b/iota-execution/latest/iota-adapter/src/programmable_transactions/execution.rs @@ -709,16 +709,7 @@ mod checked { UpgradePolicy::Additive => InclusionCheck::Subset.check(cur_module, new_module), UpgradePolicy::DepOnly => InclusionCheck::Equal.check(cur_module, new_module), UpgradePolicy::Compatible => { - let compatibility = Compatibility { - check_datatype_and_pub_function_linking: true, - check_datatype_layout: true, - check_friend_linking: false, - check_private_entry_linking: false, - disallowed_new_abilities: AbilitySet::ALL, - disallow_change_datatype_type_params: true, - // We disallow adding new variants to enums for now - disallow_new_variants: true, - }; + let compatibility = Compatibility::upgrade_check(); compatibility.check(cur_module, new_module) } diff --git a/iota-execution/latest/iota-move-natives/src/object_runtime/mod.rs b/iota-execution/latest/iota-move-natives/src/object_runtime/mod.rs index 099f3c8537d..21fa434dfe9 100644 --- a/iota-execution/latest/iota-move-natives/src/object_runtime/mod.rs +++ b/iota-execution/latest/iota-move-natives/src/object_runtime/mod.rs @@ -696,10 +696,13 @@ pub fn get_all_uids( struct UIDTraversalV1<'i>(&'i mut BTreeSet); struct UIDCollectorV1<'i>(&'i mut BTreeSet); - impl AV::Traversal for UIDTraversalV1<'_> { + impl<'i, 'b, 'l> AV::Traversal<'b, 'l> for UIDTraversalV1<'i> { type Error = AV::Error; - fn traverse_struct(&mut self, driver: &mut AV::StructDriver) -> Result<(), Self::Error> { + fn traverse_struct( + &mut self, + driver: &mut AV::StructDriver<'_, 'b, 'l>, + ) -> Result<(), Self::Error> { if driver.struct_layout().type_ == UID::type_() { while driver.next_field(&mut UIDCollectorV1(self.0))?.is_some() {} } else { @@ -709,9 +712,13 @@ pub fn get_all_uids( } } - impl AV::Traversal for UIDCollectorV1<'_> { + impl<'i, 'b, 'l> AV::Traversal<'b, 'l> for UIDCollectorV1<'i> { type Error = AV::Error; - fn traverse_address(&mut self, value: AccountAddress) -> Result<(), Self::Error> { + fn traverse_address( + &mut self, + _driver: &AV::ValueDriver<'_, 'b, 'l>, + value: AccountAddress, + ) -> Result<(), Self::Error> { self.0.insert(value.into()); Ok(()) }