From e75dc98cf9f11cb6b4da5a9645bbc6c21c9d508c Mon Sep 17 00:00:00 2001 From: Aregnaz Harutyunyan <> Date: Thu, 12 Dec 2024 18:27:30 +0400 Subject: [PATCH] Cosmetic chagnes --- aptos-move/aptos-vm/src/aptos_vm.rs | 108 +++++++++--------- .../doc/automation_registry.md | 2 +- .../sources/automation_registry.move | 2 +- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index 9fe0c10748f6e..43dc2ff475c5f 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -798,8 +798,6 @@ impl AptosVM { Ok(()) } - - fn execute_script_or_entry_function<'a, 'r, 'l>( &'l self, resolver: &'r impl AptosMoveResolver, @@ -915,14 +913,14 @@ impl AptosVM { registration_params.automated_function(), ) })?; - // let register_entry_function = EntryFunction::from(registration_params.clone()); + session.execute(|session| { self.execute_automation_registration( session, gas_meter, traversal_context, txn_data.sender(), - registration_params + registration_params, ) })?; @@ -976,15 +974,54 @@ impl AptosVM { } let args = registration_params.serialized_args_with_sender(sender); - session.execute_function_bypass_visibility(registration_params.module_id(), - registration_params.function(), - registration_params.ty_args(), - args, - gas_meter, - traversal_context)?; + session.execute_function_bypass_visibility( + registration_params.module_id(), + registration_params.function(), + registration_params.ty_args(), + args, + gas_meter, + traversal_context, + )?; Ok(()) } + /// Checks inner payload/entry function of automation registration transaction to be valid. + fn validate_automated_function( + &self, + session: &mut SessionExt, + gas_meter: &mut impl AptosGasMeter, + senders: Vec, + inner_entry_function: &EntryFunction, + ) -> Result<(), VMStatus> { + let function = session.load_function( + inner_entry_function.module(), + inner_entry_function.function(), + inner_entry_function.ty_args(), + )?; + let struct_constructors_enabled = + self.features().is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS); + let actual_args = inner_entry_function.args().to_vec(); + // By constructing args we are making sure that function execution in scope of automated + // task will not fail due to invalid arguments passed + verifier::transaction_arg_validation::validate_combine_signer_and_txn_args( + session, + gas_meter, + senders, + actual_args, + &function, + struct_constructors_enabled, + ) + .map_err(|e| { + VMStatus::error( + StatusCode::INVALID_AUTOMATION_INNER_PAYLOAD, + Some(format!( + "Invalid entry function to be automated in scope of automation registration transaction. Details: {e:?}" + )), + ) + }) + .map(drop) + } + fn charge_change_set( &self, change_set: &mut VMChangeSet, @@ -2378,12 +2415,14 @@ impl AptosVM { match payload { TransactionPayload::Script(_) | TransactionPayload::EntryFunction(_) - | TransactionPayload::AutomationRegistration(_) => transaction_validation::run_script_prologue( - session, - txn_data, - log_context, - traversal_context, - ), + | TransactionPayload::AutomationRegistration(_) => { + transaction_validation::run_script_prologue( + session, + txn_data, + log_context, + traversal_context, + ) + }, TransactionPayload::Multisig(multisig_payload) => { // Still run script prologue for multisig transaction to ensure the same tx // validations are still run for this multisig execution tx, which is submitted by @@ -2559,43 +2598,6 @@ impl AptosVM { }, }) } - - /// Checks inner payload/entry function of automation registration transaction to be valid. - fn validate_automated_function( - &self, - session: &mut SessionExt, - gas_meter: &mut impl AptosGasMeter, - senders: Vec, - inner_entry_function: &EntryFunction, - ) -> Result<(), VMStatus> { - let function = session.load_function( - inner_entry_function.module(), - inner_entry_function.function(), - inner_entry_function.ty_args(), - )?; - let struct_constructors_enabled = - self.features().is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS); - let actual_args = inner_entry_function.args().to_vec(); - // By constructing args we are making sure that function execution in scope of automated - // task will not fail due to invalid arguments passed - verifier::transaction_arg_validation::validate_combine_signer_and_txn_args( - session, - gas_meter, - senders, - actual_args, - &function, - struct_constructors_enabled, - ) - .map_err(|e| { - VMStatus::error( - StatusCode::INVALID_AUTOMATION_INNER_PAYLOAD, - Some(format!( - "Invalid entry function to be automated in scope of automation registration transaction. Details: {e:?}" - )), - ) - }) - .map(drop) - } } // Executor external API diff --git a/aptos-move/framework/supra-framework/doc/automation_registry.md b/aptos-move/framework/supra-framework/doc/automation_registry.md index bb0c1c6f43b59..d1a41344b0084 100644 --- a/aptos-move/framework/supra-framework/doc/automation_registry.md +++ b/aptos-move/framework/supra-framework/doc/automation_registry.md @@ -553,7 +553,7 @@ Registers a new automation task entry. ## Function `get_next_task_index` -List all the automation task ids +Returns next task index in registry
#[view]
diff --git a/aptos-move/framework/supra-framework/sources/automation_registry.move b/aptos-move/framework/supra-framework/sources/automation_registry.move
index e4abcc32e824d..6cb3cf6caac68 100644
--- a/aptos-move/framework/supra-framework/sources/automation_registry.move
+++ b/aptos-move/framework/supra-framework/sources/automation_registry.move
@@ -210,7 +210,7 @@ module supra_framework::automation_registry {
     }
 
     #[view]
-    /// List all the automation task ids
+    /// Returns next task index in registry
     public fun get_next_task_index(): u64 acquires AutomationRegistry {
         let automation_registry = borrow_global(@supra_framework);
         automation_registry.current_index + 1