Skip to content

Commit

Permalink
Only execute the init function when module publishing is successful. (#…
Browse files Browse the repository at this point in the history
…2237)

* If it is successful, execute the init function
  • Loading branch information
steelgeek091 committed Jul 20, 2024
1 parent aae15d6 commit ec94857
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions moveos/moveos/src/vm/moveos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ModuleUpgradeFlag>().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::<ModuleUpgradeFlag>().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
}

Expand Down

0 comments on commit ec94857

Please sign in to comment.