Skip to content

Commit

Permalink
Allow module publishing skipping compatability checks.
Browse files Browse the repository at this point in the history
Closes: #478
  • Loading branch information
wrwg authored and bors-diem committed Mar 21, 2023
1 parent 770ab6c commit 4a41ad6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion language/move-vm/runtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl VMRuntime {
sender: AccountAddress,
data_store: &mut impl DataStore,
_gas_status: &mut GasStatus,
compat_check: bool,
) -> VMResult<()> {
// deserialize the modules. Perform bounds check. After this indexes can be
// used with the `[]` operator
Expand Down Expand Up @@ -113,7 +114,7 @@ impl VMRuntime {
// changing the bytecode format to include an `is_upgradable` flag in the CompiledModule.
for module in &compiled_modules {
let module_id = module.self_id();
if data_store.exists_module(&module_id)? {
if data_store.exists_module(&module_id)? && compat_check {
let old_module_ref = self.loader.load_module(&module_id, data_store)?;
let old_module = old_module_ref.module();
let old_m = normalized::Module::new(old_module);
Expand Down
16 changes: 15 additions & 1 deletion language/move-vm/runtime/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,28 @@ impl<'r, 'l, S: MoveResolver> Session<'r, 'l, S> {
///
/// In case an invariant violation occurs, the whole Session should be considered corrupted and
/// one shall not proceed with effect generation.
///
/// This operation performs compatibility checks if a module is replaced. See also
/// `move_binary_format::compatibility`.
pub fn publish_module_bundle(
&mut self,
modules: Vec<Vec<u8>>,
sender: AccountAddress,
gas_status: &mut GasStatus,
) -> VMResult<()> {
self.runtime
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status)
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status, true)
}

/// Same like `publish_module_bundle` but relaxes compatibility checks.
pub fn publish_module_bundle_relax_compatibility(
&mut self,
modules: Vec<Vec<u8>>,
sender: AccountAddress,
gas_status: &mut GasStatus,
) -> VMResult<()> {
self.runtime
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status, false)
}

pub fn num_mutated_accounts(&self, sender: &AccountAddress) -> u64 {
Expand Down

0 comments on commit 4a41ad6

Please sign in to comment.