Skip to content

Commit

Permalink
unify packages in ptb logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tzakian committed Jan 9, 2025
1 parent 06c989c commit 9bbf9a6
Show file tree
Hide file tree
Showing 4 changed files with 404 additions and 8 deletions.
24 changes: 16 additions & 8 deletions crates/sui-types/src/move_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub struct UpgradeInfo {
// serde_bytes::ByteBuf is an analog of Vec<u8> with built-in fast serialization.
#[serde_as]
#[derive(Eq, PartialEq, Debug, Clone, Deserialize, Serialize, Hash)]
#[serde(rename_all = "camelCase")]
pub struct MovePackage {
id: ObjectID,
/// Most move packages are uniquely identified by their ID (i.e. there is only one version per
Expand All @@ -111,7 +112,7 @@ pub struct MovePackage {
version: SequenceNumber,
// TODO use session cache
#[serde_as(as = "BTreeMap<_, Bytes>")]
module_map: BTreeMap<String, Vec<u8>>,
pub module_map: BTreeMap<String, Vec<u8>>,

/// Maps struct/module to a package version where it was first defined, stored as a vector for
/// simple serialization and deserialization.
Expand Down Expand Up @@ -606,18 +607,25 @@ where
{
let mut normalized_modules = BTreeMap::new();
for bytecode in modules {
let module =
CompiledModule::deserialize_with_config(bytecode, binary_config).map_err(|error| {
SuiError::ModuleDeserializationFailure {
error: error.to_string(),
}
})?;
let normalized_module = normalized::Module::new(&module);
let normalized_module = normalize_module(bytecode, binary_config)?;
normalized_modules.insert(normalized_module.name.to_string(), normalized_module);
}
Ok(normalized_modules)
}

pub fn normalize_module<'a>(
bytecode: &'a Vec<u8>,
binary_config: &BinaryConfig,
) -> SuiResult<normalized::Module> {
let module =
CompiledModule::deserialize_with_config(bytecode, binary_config).map_err(|error| {
SuiError::ModuleDeserializationFailure {
error: error.to_string(),
}
})?;
Ok(normalized::Module::new(&module))
}

pub fn normalize_deserialized_modules<'a, I>(modules: I) -> BTreeMap<String, normalized::Module>
where
I: Iterator<Item = &'a CompiledModule>,
Expand Down
1 change: 1 addition & 0 deletions sui-execution/latest/sui-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod execution_engine;
pub mod execution_mode;
pub mod execution_value;
pub mod gas_charger;
pub mod package_unification;
pub mod programmable_transactions;
pub mod temporary_store;
pub mod type_layout_resolver;
Expand Down
Loading

0 comments on commit 9bbf9a6

Please sign in to comment.