diff --git a/moveos/moveos/src/vm/moveos_vm.rs b/moveos/moveos/src/vm/moveos_vm.rs index 4f8160ba2a..12d7effb76 100644 --- a/moveos/moveos/src/vm/moveos_vm.rs +++ b/moveos/moveos/src/vm/moveos_vm.rs @@ -464,18 +464,20 @@ where } }; - self.resolve_pending_init_functions()?; + if action_result.is_ok() { + self.resolve_pending_init_functions()?; + // Check if there are modules upgrading + let module_flag = self.tx_context().get::().map_err(|e| { + PartialVMError::new(StatusCode::UNKNOWN_VALIDATION_STATUS) + .with_message(e.to_string()) + .finish(Location::Undefined) + })?; + let is_upgrade = module_flag.map_or(false, |flag| flag.is_upgrade); + if is_upgrade { + self.vm.mark_loader_cache_as_invalid(); + }; + } - // Check if there are modules upgrading - let module_flag = self.tx_context().get::().map_err(|e| { - PartialVMError::new(StatusCode::UNKNOWN_VALIDATION_STATUS) - .with_message(e.to_string()) - .finish(Location::Undefined) - })?; - let is_upgrade = module_flag.map_or(false, |flag| flag.is_upgrade); - if is_upgrade { - self.vm.mark_loader_cache_as_invalid(); - }; action_result }