Skip to content

Commit

Permalink
Improve Move call type checking part1 (MystenLabs#529)
Browse files Browse the repository at this point in the history
* Moved type checking to separate module
  • Loading branch information
oxade authored Feb 23, 2022
1 parent 7dd265d commit ae20572
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 308 deletions.
6 changes: 3 additions & 3 deletions sui/src/sui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async fn genesis(
);
let sui_lib = sui_framework::get_sui_framework_modules(&genesis_conf.sui_framework_lib_path)?;
let lib_object =
Object::new_package(sui_lib, SuiAddress::default(), TransactionDigest::genesis());
Object::new_package(sui_lib, SuiAddress::default(), TransactionDigest::genesis())?;
preload_modules.push(lib_object);

info!(
Expand All @@ -174,7 +174,7 @@ async fn genesis(
move_lib,
SuiAddress::default(),
TransactionDigest::genesis(),
);
)?;
preload_modules.push(lib_object);

// Build custom move packages
Expand All @@ -194,7 +194,7 @@ async fn genesis(
)?;

let object =
Object::new_package(modules, SuiAddress::default(), TransactionDigest::genesis());
Object::new_package(modules, SuiAddress::default(), TransactionDigest::genesis())?;
info!("Loaded package [{}] from {:?}.", object.id(), path);
// Writing package id to network.conf for user to retrieve later.
config.loaded_move_packages.push((path, object.id()));
Expand Down
1 change: 1 addition & 0 deletions sui_core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ impl ModuleResolver for AuthorityStore {
match self.get_object(&ObjectID::from(*module_id.address()))? {
Some(o) => match &o.data {
Data::Package(c) => Ok(c
.serialized_module_map()
.get(module_id.name().as_str())
.cloned()
.map(|m| m.into_vec())),
Expand Down
1 change: 1 addition & 0 deletions sui_core/src/authority/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl ModuleResolver for AuthorityTemporaryStore {
match self.read_object(&ObjectID::from(*module_id.address())) {
Some(o) => match &o.data {
Data::Package(c) => Ok(c
.serialized_module_map()
.get(module_id.name().as_str())
.cloned()
.map(|m| m.into_vec())),
Expand Down
11 changes: 8 additions & 3 deletions sui_core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ async fn test_publish_dependent_module_ok() {
// create a genesis state that contains the gas object and genesis modules
let genesis_module_objects = genesis::clone_genesis_modules();
let genesis_module = match &genesis_module_objects[0].data {
Data::Package(m) => CompiledModule::deserialize(m.values().next().unwrap()).unwrap(),
Data::Package(m) => {
CompiledModule::deserialize(m.serialized_module_map().values().next().unwrap()).unwrap()
}
_ => unreachable!(),
};
// create a module that depends on a genesis module
Expand Down Expand Up @@ -462,7 +464,9 @@ async fn test_publish_non_existing_dependent_module() {
// create a genesis state that contains the gas object and genesis modules
let genesis_module_objects = genesis::clone_genesis_modules();
let genesis_module = match &genesis_module_objects[0].data {
Data::Package(m) => CompiledModule::deserialize(m.values().next().unwrap()).unwrap(),
Data::Package(m) => {
CompiledModule::deserialize(m.serialized_module_map().values().next().unwrap()).unwrap()
}
_ => unreachable!(),
};
// create a module that depends on a genesis module
Expand Down Expand Up @@ -1489,6 +1493,7 @@ async fn test_hero() {
)
.await
.unwrap();
println!("ERRRR {:?}", effects.status);
assert!(matches!(effects.status, ExecutionStatus::Success { .. }));

// 7. Give them a boar!
Expand Down Expand Up @@ -1785,7 +1790,7 @@ fn get_genesis_package_by_module(genesis_objects: &[Object], module: &str) -> Ob
.iter()
.find_map(|o| match o.data.try_as_package() {
Some(p) => {
if p.keys().any(|name| name == module) {
if p.serialized_module_map().keys().any(|name| name == module) {
Some(o.to_object_reference())
} else {
None
Expand Down
Loading

0 comments on commit ae20572

Please sign in to comment.