Skip to content

Commit

Permalink
[AN-Issue-1347] Implemented Automated transaction execution flow (#136)
Browse files Browse the repository at this point in the history
* [AN-Issue-1347] Implemented Automated transasction execution flow

* Updated automated task prologue and added e2e tests

- Added chain-id verification and task availability check by task index
- Added e2e tests for AutoamtedTransaction

* Fixed test failure

* Added task sender check in automated_transaction_prologue

---------

Co-authored-by: Aregnaz Harutyunyan <>
  • Loading branch information
aregng authored Dec 30, 2024
1 parent 94c8edf commit 70f4027
Show file tree
Hide file tree
Showing 16 changed files with 1,172 additions and 53 deletions.
32 changes: 24 additions & 8 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ use std::{
marker::Sync,
sync::Arc,
};
use crate::automated_transaction_processor::AutomatedTransactionProcessor;

static EXECUTION_CONCURRENCY_LEVEL: OnceCell<usize> = OnceCell::new();
static NUM_EXECUTION_SHARD: OnceCell<usize> = OnceCell::new();
Expand Down Expand Up @@ -151,6 +152,8 @@ macro_rules! unwrap_or_discard {
};
}

pub(crate) use unwrap_or_discard;

pub(crate) fn get_system_transaction_output(
session: SessionExt,
fee_statement: FeeStatement,
Expand Down Expand Up @@ -271,7 +274,7 @@ impl AptosVM {
}

#[inline(always)]
fn features(&self) -> &Features {
pub(crate) fn features(&self) -> &Features {
self.move_vm.env.features()
}

Expand Down Expand Up @@ -397,7 +400,7 @@ impl AptosVM {
)
}

fn fee_statement_from_gas_meter(
pub(crate) fn fee_statement_from_gas_meter(
txn_data: &TransactionMetadata,
gas_meter: &impl AptosGasMeter,
storage_fee_refund: u64,
Expand Down Expand Up @@ -488,7 +491,7 @@ impl AptosVM {
}
}

fn inject_abort_info_if_available(&self, status: ExecutionStatus) -> ExecutionStatus {
pub(crate) fn inject_abort_info_if_available(&self, status: ExecutionStatus) -> ExecutionStatus {
match status {
ExecutionStatus::MoveAbort {
location: AbortLocation::Module(module),
Expand Down Expand Up @@ -747,7 +750,7 @@ impl AptosVM {
Ok(())
}

fn validate_and_execute_entry_function(
pub(crate) fn validate_and_execute_entry_function(
&self,
resolver: &impl AptosMoveResolver,
session: &mut SessionExt,
Expand Down Expand Up @@ -1053,7 +1056,7 @@ impl AptosVM {
Ok(storage_refund)
}

fn charge_change_set_and_respawn_session<'r, 'l>(
pub(crate) fn charge_change_set_and_respawn_session<'r, 'l>(
&'l self,
user_session: UserSession<'r, 'l>,
resolver: &'r impl AptosMoveResolver,
Expand Down Expand Up @@ -1506,7 +1509,7 @@ impl AptosVM {
}

/// Resolve a pending code publish request registered via the NativeCodeContext.
fn resolve_pending_code_publish(
pub(crate) fn resolve_pending_code_publish(
&self,
session: &mut SessionExt,
gas_meter: &mut impl AptosGasMeter,
Expand Down Expand Up @@ -1923,6 +1926,7 @@ impl AptosVM {
})
}


/// Main entrypoint for executing a user transaction that also allows the customization of the
/// gas meter to be used.
pub fn execute_user_transaction_with_custom_gas_meter<G, F>(
Expand Down Expand Up @@ -2596,11 +2600,23 @@ impl AptosVM {
self.process_validator_transaction(resolver, txn.clone(), log_context)?;
(vm_status, output)
},
Transaction::AutomatedTransaction(_) => {
unimplemented!("AutomatedTransaction execution is coming soon")
Transaction::AutomatedTransaction(txn) => {
AutomatedTransactionProcessor::new(self).execute_transaction(resolver, txn, log_context)
},
})
}

pub(crate) fn gas_params_internal(&self) -> &Result<AptosGasParameters, String> {
&self.gas_params
}

pub(crate) fn move_vm(&self) -> &MoveVmExt {
&self.move_vm
}

pub(crate) fn gas_feature_version(&self) -> u64 {
self.gas_feature_version
}
}

// Executor external API
Expand Down
Loading

0 comments on commit 70f4027

Please sign in to comment.