From b39b8ce6887db53da9fa1cf987f27a735d36034b Mon Sep 17 00:00:00 2001 From: Jort Date: Tue, 7 Jan 2025 16:13:50 -0800 Subject: [PATCH] merge name and address checking to id check --- .../move-binary-format/src/compatibility.rs | 15 ++++++++------- .../move-binary-format/src/inclusion_mode.rs | 16 +++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/external-crates/move/crates/move-binary-format/src/compatibility.rs b/external-crates/move/crates/move-binary-format/src/compatibility.rs index a243dc4704b05..ba2552fbe095a 100644 --- a/external-crates/move/crates/move-binary-format/src/compatibility.rs +++ b/external-crates/move/crates/move-binary-format/src/compatibility.rs @@ -376,13 +376,14 @@ impl InclusionCheck { ) -> Result<(), M::Error> { let mut context = M::default(); - // Module checks - if old_module.name != new_module.name { - context.module_name_mismatch(&old_module.name, &new_module.name); - } - - if old_module.address != new_module.address { - context.module_address_mismatch(&old_module.address, &new_module.address); + // module's name and address are unchanged + if old_module.address != new_module.address || old_module.name != new_module.name { + context.module_id_mismatch( + &old_module.address, + &old_module.name, + &new_module.address, + &new_module.name, + ); } if old_module.file_format_version > new_module.file_format_version { diff --git a/external-crates/move/crates/move-binary-format/src/inclusion_mode.rs b/external-crates/move/crates/move-binary-format/src/inclusion_mode.rs index e229d765ef7b9..a71ed4a4e74ec 100644 --- a/external-crates/move/crates/move-binary-format/src/inclusion_mode.rs +++ b/external-crates/move/crates/move-binary-format/src/inclusion_mode.rs @@ -1,15 +1,16 @@ use crate::compatibility::InclusionCheck; use crate::normalized::{Enum, Function, Struct}; use move_core_types::account_address::AccountAddress; -use move_core_types::identifier::Identifier; +use move_core_types::identifier::{IdentStr, Identifier}; pub trait InclusionCheckMode: Default { type Error; - fn module_name_mismatch(&mut self, old_address: &Identifier, new_address: &Identifier); - fn module_address_mismatch( + fn module_id_mismatch( &mut self, old_address: &AccountAddress, + old_name: &IdentStr, new_address: &AccountAddress, + new_name: &IdentStr, ); fn file_format_version_downgrade(&mut self, old_version: u32, new_version: u32); fn struct_new(&mut self, name: &Identifier, new_struct: &Struct); @@ -45,15 +46,12 @@ impl Default for InclusionCheckExecutionMode { impl InclusionCheckMode for InclusionCheckExecutionMode { type Error = (); - fn module_name_mismatch(&mut self, _old_address: &Identifier, _new_address: &Identifier) { - self.is_subset = false; - self.is_equal = false; - } - - fn module_address_mismatch( + fn module_id_mismatch( &mut self, _old_address: &AccountAddress, + _old_name: &IdentStr, _new_address: &AccountAddress, + _new_name: &IdentStr, ) { self.is_subset = false; self.is_equal = false;