Skip to content

Commit

Permalink
Improve Move call type checking part1 (#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

1 comment on commit ae20572

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bench results

�[0m�[0m�[1m�[32m Finished�[0m release [optimized + debuginfo] target(s) in 1.45s
�[0m�[0m�[1m�[32m Running�[0m target/release/bench
�[2m2022-02-23T02:13:45.177835Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Starting benchmark: TransactionsAndCerts
�[2m2022-02-23T02:13:45.177871Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing accounts.
�[2m2022-02-23T02:13:45.180548Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Open database on path: "/tmp/DB_10AB2BE347BD1D30F138B2B27015EB8D5C580E4E"
�[2m2022-02-23T02:13:50.441319Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing transactions.
�[2m2022-02-23T02:13:59.071275Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m Listening to TCP traffic on 127.0.0.1:9555
�[2m2022-02-23T02:14:00.072786Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Number of TCP connections: 2
�[2m2022-02-23T02:14:00.072822Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Set max_in_flight to 500
�[2m2022-02-23T02:14:00.072826Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Sending requests.
�[2m2022-02-23T02:14:00.079091Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-23T02:14:00.083209Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-23T02:14:00.979725Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 5000 packets
�[2m2022-02-23T02:14:01.752283Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-23T02:14:01.794546Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-23T02:14:01.867019Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 10000 packets
�[2m2022-02-23T02:14:02.756846Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 15000 packets
�[2m2022-02-23T02:14:03.530823Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-23T02:14:03.610262Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-23T02:14:03.644000Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 20000 packets
�[2m2022-02-23T02:14:04.533559Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 25000 packets
�[2m2022-02-23T02:14:05.341485Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-23T02:14:05.432373Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-23T02:14:05.441081Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 30000 packets
�[2m2022-02-23T02:14:06.336887Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 35000 packets
�[2m2022-02-23T02:14:07.072790Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-23T02:14:07.194871Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-23T02:14:07.216693Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 40000 packets
�[2m2022-02-23T02:14:08.114426Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 45000 packets
�[2m2022-02-23T02:14:08.871522Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-23T02:14:09.005158Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 50000 packets
�[2m2022-02-23T02:14:09.014240Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-23T02:14:09.899406Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 55000 packets
�[2m2022-02-23T02:14:10.620499Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-23T02:14:10.763406Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-23T02:14:10.786909Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 60000 packets
�[2m2022-02-23T02:14:11.694001Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 65000 packets
�[2m2022-02-23T02:14:12.440479Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-23T02:14:12.579292Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-23T02:14:12.583858Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 70000 packets
�[2m2022-02-23T02:14:13.483140Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 75000 packets
�[2m2022-02-23T02:14:14.351409Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-23T02:14:14.460637Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 80000 packets
�[2m2022-02-23T02:14:14.508081Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-23T02:14:14.509587Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Received 80000 responses.
�[2m2022-02-23T02:14:14.679650Z�[0m �[33m WARN�[0m �[2mbench�[0m�[2m:�[0m Completed benchmark for TransactionsAndCerts
Total time: 14436748us, items: 40000, tx/sec: 2770.7070872193653

Please sign in to comment.