From b29f233955a058ec593ac38272b615b00460e131 Mon Sep 17 00:00:00 2001 From: Todd Nowacki Date: Thu, 21 Apr 2022 14:24:30 -0700 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! fixup! fixup! [adapter][move] Relax object/pure arg ordering. remove return values --- sui_core/src/authority/temporary_store.rs | 4 +-- sui_core/src/execution_engine.rs | 37 ++++++++-------------- sui_programmability/adapter/src/adapter.rs | 8 ++--- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/sui_core/src/authority/temporary_store.rs b/sui_core/src/authority/temporary_store.rs index 034edc88ea1ff..42ff5b86ff336 100644 --- a/sui_core/src/authority/temporary_store.rs +++ b/sui_core/src/authority/temporary_store.rs @@ -54,8 +54,8 @@ impl AuthorityTemporaryStore { }) .collect(); let objects = input_objects - .iter() - .map(|(_, object)| (object.id(), object.clone())) + .into_iter() + .map(|(_, object)| (object.id(), object)) .collect(); Self { package_store, diff --git a/sui_core/src/execution_engine.rs b/sui_core/src/execution_engine.rs index 6174724970fc8..94b07e305848b 100644 --- a/sui_core/src/execution_engine.rs +++ b/sui_core/src/execution_engine.rs @@ -79,12 +79,11 @@ fn execute_transaction( .expect("We constructed the object map so it should always have the gas object id") .clone(); - // unwraps here are safe because we built `inputs` let mut result = Ok(()); // TODO: Since we require all mutable objects to not show up more than // once across single tx, we should be able to run them in parallel. for single_tx in transaction.into_single_transactions() { - match single_tx { + result = match single_tx { SingleTransactionKind::Transfer(Transfer { recipient, object_ref, @@ -95,10 +94,7 @@ fn execute_transaction( .get(&object_ref.0) .unwrap() .clone(); - if let Err(err) = transfer(temporary_store, object, recipient) { - result = Err(err); - break; - } + transfer(temporary_store, object, recipient) } SingleTransactionKind::Call(MoveCall { package, @@ -108,7 +104,7 @@ fn execute_transaction( arguments, }) => { let module_id = ModuleId::new(package.0.into(), module); - result = adapter::execute( + adapter::execute( move_vm, temporary_store, module_id, @@ -117,24 +113,19 @@ fn execute_transaction( arguments, &mut gas_status, tx_ctx, - ); - if result.is_err() { - break; - } - } - SingleTransactionKind::Publish(MoveModulePublish { modules }) => { - if let Err(err) = adapter::publish( - temporary_store, - native_functions.clone(), - modules, - tx_ctx, - &mut gas_status, - ) { - result = Err(err); - break; - } + ) } + SingleTransactionKind::Publish(MoveModulePublish { modules }) => adapter::publish( + temporary_store, + native_functions.clone(), + modules, + tx_ctx, + &mut gas_status, + ), }; + if result.is_err() { + break; + } } if result.is_err() { // Roll back the temporary store if execution failed. diff --git a/sui_programmability/adapter/src/adapter.rs b/sui_programmability/adapter/src/adapter.rs index 2dda558c5dcd2..df1f870f34ee1 100644 --- a/sui_programmability/adapter/src/adapter.rs +++ b/sui_programmability/adapter/src/adapter.rs @@ -124,6 +124,10 @@ fn execute_internal< gas_status: &mut SuiGasStatus, // gas status for the current call operation ctx: &mut TxContext, ) -> SuiResult<()> { + // object_owner_map maps from object ID to its exclusive object owner. + // This map will be used for detecting circular ownership among + // objects, which can only happen to objects exclusively owned + // by objects. let object_owner_map: BTreeMap = object_data .iter() .filter_map(|(id, (owner, _))| match owner { @@ -599,10 +603,6 @@ fn check_transferred_object_invariants( pub struct TypeCheckSuccess { pub module_id: ModuleId, - // object_owner_map maps from object ID to its exclusive object owner. - // This map will be used for detecting circular ownership among - // objects, which can only happen to objects exclusively owned - // by objects. pub object_data: BTreeMap, pub by_value_objects: BTreeSet, pub mutable_ref_objects: BTreeMap,