diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index 827645cf61544..c185e0e0b17e5 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -2061,13 +2061,22 @@ impl AptosVM { ) })); - if !self.features().is_account_abstraction_enabled() { + if self.features().is_account_abstraction_enabled() { + let max_aa_gas = match self.gas_params(&log_context) { + Ok(vm_params) => vm_params.vm.txn.max_aa_gas, + Err(err) => { + panic!("TODO: what to do here"); + // return VMValidatorResult::new(Some(err.status_code()), 0); + }, + }; + if max_aa_gas < txn_data.max_gas_amount() { + // Reset initial gas after validation with max_aa_gas. + unwrap_or_discard!(gas_meter.adjust_initial_gas(txn_data.max_gas_amount())); + } + } else { assert_eq!(initial_gas, gas_meter.balance()); } - // Reset initial gas after validation with max_aa_gas. - unwrap_or_discard!(gas_meter.adjust_initial_gas(txn_data.max_gas_amount())); - let storage_gas_params = unwrap_or_discard!(self.storage_gas_params(log_context)); let change_set_configs = &storage_gas_params.change_set_configs; let (prologue_change_set, mut user_session) = unwrap_or_discard!(prologue_session @@ -2191,13 +2200,19 @@ impl AptosVM { let is_approved_gov_script = is_approved_gov_script(resolver, txn, &txn_metadata); let vm_params = self.gas_params(log_context)?.vm.clone(); - let max_aa_gas = vm_params.txn.max_aa_gas; + + let initial_balance = if self.features().is_account_abstraction_enabled() { + vm_params.txn.max_aa_gas.min(txn.max_gas_amount().into()) + } else { + txn.max_gas_amount().into() + }; + let mut gas_meter = make_gas_meter( self.gas_feature_version(), vm_params, self.storage_gas_params(log_context)?.clone(), is_approved_gov_script, - max_aa_gas, + initial_balance, ); let (status, output) = self.execute_user_transaction_impl( @@ -3113,13 +3128,18 @@ impl VMValidator for AptosVM { }, }; - let max_aa_gas = vm_params.txn.max_aa_gas; + let initial_balance = if self.features().is_account_abstraction_enabled() { + vm_params.txn.max_aa_gas.min(txn_data.max_gas_amount().into()) + } else { + txn_data.max_gas_amount() + }; + let mut gas_meter = make_prod_gas_meter( self.gas_feature_version(), vm_params, storage_gas_params, is_approved_gov_script, - max_aa_gas, + initial_balance, ); let storage = TraversalStorage::new(); diff --git a/crates/transaction-emitter-lib/src/emitter/submission_worker.rs b/crates/transaction-emitter-lib/src/emitter/submission_worker.rs index 9563e78648b59..9f8d8ac7d859e 100644 --- a/crates/transaction-emitter-lib/src/emitter/submission_worker.rs +++ b/crates/transaction-emitter-lib/src/emitter/submission_worker.rs @@ -491,7 +491,23 @@ pub async fn submit_transactions( .counts(); if let Some(failure) = failures.first() { sample!(SampleRate::Duration(Duration::from_secs(60)), { - let sender = txns[failure.transaction_index].sender(); + let first_failed_txn = &txns[failure.transaction_index]; + let sender = first_failed_txn.sender(); + use aptos_types::transaction::TransactionPayload::*; + let payload = match first_failed_txn.payload() { + Script(_) => "script".to_string(), + ModuleBundle(_) => "module_bundle".to_string(), + EntryFunction(entry_function) => format!("entry {}::{}", entry_function.module(), entry_function.function()), + Multisig(_) => "multisig".to_string(), + }; + + let failured_txn_info = format!( + "due to {:?}, for account {}, max gas {}, payload {}", + failure, + first_failed_txn.sender(), + first_failed_txn.max_gas_amount(), + payload, + ); let last_transactions = if let Ok(account) = client.get_account_bcs(sender).await { @@ -513,12 +529,11 @@ pub async fn submit_transactions( .map_or(-1, |v| v.into_inner() as i64); warn!( - "[{:?}] Failed to submit {} txns in a batch, first failure due to {:?}, for account {}, chain id: {:?}, first asked: {}, failed seq nums: {:?}, failed error codes: {:?}, balance of {} and last transaction for account: {:?}", + "[{:?}] Failed to submit {} txns in a batch, first failure: {}, chain id: {:?}, first asked: {}, failed seq nums: {:?}, failed error codes: {:?}, balance of {} and last transaction for account: {:?}", client.path_prefix_string(), failures.len(), - failure, - sender, - txns[0].chain_id(), + failured_txn_info, + first_failed_txn.chain_id(), txns[0].sequence_number(), failures.iter().map(|f| txns[f.transaction_index].sequence_number()).collect::>(), by_error, diff --git a/third_party/move/move-core/types/src/vm_status.rs b/third_party/move/move-core/types/src/vm_status.rs index c9b44d1dd692d..0d34d3f59addc 100644 --- a/third_party/move/move-core/types/src/vm_status.rs +++ b/third_party/move/move-core/types/src/vm_status.rs @@ -565,9 +565,14 @@ pub enum StatusCode { SEQUENCE_NUMBER_TOO_BIG = 24, // The gas currency is not registered as a TransactionFee currency BAD_TRANSACTION_FEE_CURRENCY = 25, - // DEPRECATED. The feature requested is intended for a future Diem version instead of the current - // This code is deprecated as it is discarded. Use the verification error code - // FEATURE_NOT_ENABLED instead. + // Discards a transaction, because newly added code path hasn't yet been enabled, + // and transactions were discarded before the feature was introduced. + // To be used for example when new variants in the transaction - like new payload or authenticator + // types are introduced, that wouldn't be deserialized successfully by the previous binary. + // + // When the feature is "double" gated, i.e. new bytecode version introduces new things, + // but we don't want all the be enabled at the same time, such that it is safe to abort, + // use the verification error code FEATURE_NOT_ENABLED instead. FEATURE_UNDER_GATING = 26, // The number of secondary signer addresses is different from the number of secondary // public keys provided. @@ -731,7 +736,13 @@ pub enum StatusCode { TEST_VARIANT_TYPE_MISMATCH_ERROR = 1129, // A variant list is empty ZERO_VARIANTS_ERROR = 1130, - // A feature is not enabled. + // A feature is not enabled, and transaction will abort and be committed on chain. + // Use only when there is no backward incompatibility concern - as it is + // double-gated by an additional flag, i.e. new bytecode version introduces new things, + // but we don't want all the be enabled at the same time, such that it is safe to abort. + // + // If we are introducing code, that previous binary would discard such a transaction, + // you need to use FEATURE_UNDER_GATING flag instead. FEATURE_NOT_ENABLED = 1131, // Reserved error code for future use