Skip to content

Commit 4a41ad6

Browse files
wrwgbors-diem
authored andcommitted
Allow module publishing skipping compatability checks.
Closes: #478
1 parent 770ab6c commit 4a41ad6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

language/move-vm/runtime/src/runtime.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl VMRuntime {
7474
sender: AccountAddress,
7575
data_store: &mut impl DataStore,
7676
_gas_status: &mut GasStatus,
77+
compat_check: bool,
7778
) -> VMResult<()> {
7879
// deserialize the modules. Perform bounds check. After this indexes can be
7980
// used with the `[]` operator
@@ -113,7 +114,7 @@ impl VMRuntime {
113114
// changing the bytecode format to include an `is_upgradable` flag in the CompiledModule.
114115
for module in &compiled_modules {
115116
let module_id = module.self_id();
116-
if data_store.exists_module(&module_id)? {
117+
if data_store.exists_module(&module_id)? && compat_check {
117118
let old_module_ref = self.loader.load_module(&module_id, data_store)?;
118119
let old_module = old_module_ref.module();
119120
let old_m = normalized::Module::new(old_module);

language/move-vm/runtime/src/session.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,28 @@ impl<'r, 'l, S: MoveResolver> Session<'r, 'l, S> {
177177
///
178178
/// In case an invariant violation occurs, the whole Session should be considered corrupted and
179179
/// one shall not proceed with effect generation.
180+
///
181+
/// This operation performs compatibility checks if a module is replaced. See also
182+
/// `move_binary_format::compatibility`.
180183
pub fn publish_module_bundle(
181184
&mut self,
182185
modules: Vec<Vec<u8>>,
183186
sender: AccountAddress,
184187
gas_status: &mut GasStatus,
185188
) -> VMResult<()> {
186189
self.runtime
187-
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status)
190+
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status, true)
191+
}
192+
193+
/// Same like `publish_module_bundle` but relaxes compatibility checks.
194+
pub fn publish_module_bundle_relax_compatibility(
195+
&mut self,
196+
modules: Vec<Vec<u8>>,
197+
sender: AccountAddress,
198+
gas_status: &mut GasStatus,
199+
) -> VMResult<()> {
200+
self.runtime
201+
.publish_module_bundle(modules, sender, &mut self.data_cache, gas_status, false)
188202
}
189203

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

0 commit comments

Comments
 (0)