Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit 0ce8e4b

Browse files
authored
[loader] Cache CompiledModule separately from Module (#970)
Separates verification, which blesses `CompiledModule`s from loading which caches `Module`s: - Renames the existing cache as `loaded_modules`. - Moves `CompiledModule` out of `Module` and into its own cache -- `compiled_modules` -- populated during verification (which now no longer populates `loaded_modules`). - `ModuleCache::insert` now recursively adds `Module`s, `Function`s, and `Struct`s (ensuring dependency modules are loaded first), assuming the all dependencies have been verified (failing otherwise). - Public APIs into the loader that previously returned `Arc<Module>` now also return a `Arc<CompiledModule>`. This change is motivated by the fact that in the presence of package upgrades, a single `CompiledModule` can end up being stamped out as multiple `Module`s Test Plan: ``` move$ rm -rf ~/.move && cargo nextest ```
1 parent 8729cf2 commit 0ce8e4b

File tree

5 files changed

+371
-328
lines changed

5 files changed

+371
-328
lines changed

language/move-vm/integration-tests/src/tests/loader_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ impl Adapter {
8888

8989
for module in modules {
9090
let mut binary = vec![];
91-
module
92-
.serialize(&mut binary)
93-
.unwrap_or_else(|_| panic!("failure in module serialization: {:#?}", module));
91+
module.serialize(&mut binary).unwrap_or_else(|e| {
92+
panic!("failure in module serialization: {e:?}\n{:#?}", module)
93+
});
9494
session
9595
.publish_module(binary, WORKING_ACCOUNT, &mut UnmeteredGasMeter)
96-
.unwrap_or_else(|_| panic!("failure publishing module: {:#?}", module));
96+
.unwrap_or_else(|e| panic!("failure publishing module: {e:?}\n{:#?}", module));
9797
}
9898
let (changeset, _) = session.finish().expect("failure getting write set");
9999
self.store
@@ -106,9 +106,9 @@ impl Adapter {
106106

107107
for module in modules {
108108
let mut binary = vec![];
109-
module
110-
.serialize(&mut binary)
111-
.unwrap_or_else(|_| panic!("failure in module serialization: {:#?}", module));
109+
module.serialize(&mut binary).unwrap_or_else(|e| {
110+
panic!("failure in module serialization: {e:?}\n{:#?}", module)
111+
});
112112
session
113113
.publish_module(binary, WORKING_ACCOUNT, &mut UnmeteredGasMeter)
114114
.expect_err("publishing must fail");

0 commit comments

Comments
 (0)