diff --git a/Cargo.lock b/Cargo.lock index 0be7c0d3cf709..57cf1cc01cd1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14213,6 +14213,8 @@ dependencies = [ "move-binary-format", "move-bytecode-utils", "move-core-types", + "move-disassembler", + "move-ir-types", "mysten-metrics", "schemars", "serde", @@ -15715,14 +15717,11 @@ dependencies = [ "im", "indexmap 2.2.6", "itertools 0.13.0", - "jsonrpsee", "lru 0.10.0", "move-binary-format", "move-bytecode-utils", "move-command-line-common", "move-core-types", - "move-disassembler", - "move-ir-types", "move-vm-profiler", "move-vm-test-utils", "move-vm-types", diff --git a/crates/sui-json-rpc-types/Cargo.toml b/crates/sui-json-rpc-types/Cargo.toml index 01507d5fb441b..b8f58baef59d8 100644 --- a/crates/sui-json-rpc-types/Cargo.toml +++ b/crates/sui-json-rpc-types/Cargo.toml @@ -27,6 +27,8 @@ tabled.workspace = true move-binary-format.workspace = true move-core-types.workspace = true move-bytecode-utils.workspace = true +move-disassembler.workspace = true +move-ir-types.workspace = true mysten-metrics.workspace = true sui-types.workspace = true diff --git a/crates/sui-json-rpc-types/src/sui_object.rs b/crates/sui-json-rpc-types/src/sui_object.rs index c19e7f9048c1d..7b2cf37a122dc 100644 --- a/crates/sui-json-rpc-types/src/sui_object.rs +++ b/crates/sui-json-rpc-types/src/sui_object.rs @@ -770,9 +770,31 @@ impl SuiData for SuiParsedData { } fn try_from_package(package: MovePackage) -> Result { - Ok(Self::Package(SuiMovePackage { - disassembled: package.disassemble()?, - })) + let mut disassembled = BTreeMap::new(); + for bytecode in package.serialized_module_map().values() { + // this function is only from JSON RPC - it is OK to deserialize with max Move binary + // version + let module = move_binary_format::CompiledModule::deserialize_with_defaults(bytecode) + .map_err(|error| SuiError::ModuleDeserializationFailure { + error: error.to_string(), + })?; + let d = move_disassembler::disassembler::Disassembler::from_module_with_max_size( + &module, + move_ir_types::location::Spanned::unsafe_no_loc(()).loc, + *sui_types::move_package::MAX_DISASSEMBLED_MODULE_SIZE, + ) + .map_err(|e| SuiError::ObjectSerializationError { + error: e.to_string(), + })?; + let bytecode_str = d + .disassemble() + .map_err(|e| SuiError::ObjectSerializationError { + error: e.to_string(), + })?; + disassembled.insert(module.name().to_string(), Value::String(bytecode_str)); + } + + Ok(Self::Package(SuiMovePackage { disassembled })) } fn try_as_move(&self) -> Option<&Self::ObjectType> { diff --git a/crates/sui-types/Cargo.toml b/crates/sui-types/Cargo.toml index 5e4d1259df32d..5ebeaba9333d1 100644 --- a/crates/sui-types/Cargo.toml +++ b/crates/sui-types/Cargo.toml @@ -42,13 +42,10 @@ roaring.workspace = true enum_dispatch.workspace = true eyre.workspace = true indexmap.workspace = true -jsonrpsee.workspace = true move-binary-format.workspace = true move-bytecode-utils.workspace = true move-command-line-common.workspace = true move-core-types.workspace = true -move-disassembler.workspace = true -move-ir-types.workspace = true move-vm-test-utils.workspace = true move-vm-types.workspace = true move-vm-profiler.workspace = true diff --git a/crates/sui-types/src/move_package.rs b/crates/sui-types/src/move_package.rs index ec1190a657cd1..49e8798feedce 100644 --- a/crates/sui-types/src/move_package.rs +++ b/crates/sui-types/src/move_package.rs @@ -22,12 +22,9 @@ use move_core_types::{ identifier::{IdentStr, Identifier}, language_storage::StructTag, }; -use move_disassembler::disassembler::Disassembler; -use move_ir_types::location::Spanned; use once_cell::sync::Lazy; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use serde_json::Value; use serde_with::serde_as; use serde_with::Bytes; use std::collections::{BTreeMap, BTreeSet}; @@ -527,10 +524,6 @@ impl MovePackage { }) } - pub fn disassemble(&self) -> SuiResult> { - disassemble_modules(self.module_map.values()) - } - pub fn normalize( &self, binary_config: &BinaryConfig, @@ -604,37 +597,6 @@ pub fn is_test_fun(name: &IdentStr, module: &CompiledModule, fn_info_map: &FnInf } } -pub fn disassemble_modules<'a, I>(modules: I) -> SuiResult> -where - I: Iterator>, -{ - let mut disassembled = BTreeMap::new(); - for bytecode in modules { - // this function is only from JSON RPC - it is OK to deserialize with max Move binary - // version - let module = CompiledModule::deserialize_with_defaults(bytecode).map_err(|error| { - SuiError::ModuleDeserializationFailure { - error: error.to_string(), - } - })?; - let d = Disassembler::from_module_with_max_size( - &module, - Spanned::unsafe_no_loc(()).loc, - *MAX_DISASSEMBLED_MODULE_SIZE, - ) - .map_err(|e| SuiError::ObjectSerializationError { - error: e.to_string(), - })?; - let bytecode_str = d - .disassemble() - .map_err(|e| SuiError::ObjectSerializationError { - error: e.to_string(), - })?; - disassembled.insert(module.name().to_string(), Value::String(bytecode_str)); - } - Ok(disassembled) -} - pub fn normalize_modules<'a, I>( modules: I, binary_config: &BinaryConfig,