From e5d87528ec68b548b36ae2807cef67f0bb2ca71a Mon Sep 17 00:00:00 2001 From: Bo Wu Date: Thu, 21 Nov 2024 14:34:13 -0800 Subject: [PATCH] update tests --- .../aptos_test_harness/borrow_in_loop.exp | 4 ++-- .../aptos_test_harness/diamond_clicker.exp | 2 +- aptos-move/aptos-vm-types/src/output.rs | 11 +---------- aptos-move/aptos-vm-types/src/tests/utils.rs | 3 +-- aptos-move/aptos-vm/src/aptos_vm.rs | 19 ++++--------------- .../user_transaction_sessions/epilogue.rs | 4 +--- aptos-move/e2e-move-tests/src/tests/vm.rs | 11 +---------- ...__scripts__script_bad_sig_function_dep.exp | 4 +++- ...sts__scripts__script_code_unverifiable.exp | 4 +++- ...ed_type_argument_module_does_not_exist.exp | 4 +++- ...ipts__script_non_existing_function_dep.exp | 4 +++- ...ripts__script_none_existing_module_dep.exp | 4 +++- ...pt_type_argument_module_does_not_exist.exp | 4 +++- ...y_txn__test_arbitrary_script_execution.exp | 4 +++- ...t_script_dependency_fails_verification.exp | 4 +++- ...ansitive_dependency_fails_verification.exp | 4 +++- ...type_tag_dependency_fails_verification.exp | 4 +++- ...ansitive_dependency_fails_verification.exp | 4 +++- types/src/on_chain_config/aptos_features.rs | 2 +- types/src/proptest_types.rs | 3 +-- types/src/transaction/mod.rs | 11 +++-------- 21 files changed, 49 insertions(+), 65 deletions(-) diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/borrow_in_loop.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/borrow_in_loop.exp index 69a5b16b8f3671..f7386474fbc021 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/borrow_in_loop.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/borrow_in_loop.exp @@ -4,7 +4,7 @@ task 1 'publish'. lines 4-26: Error: VMError with status STLOC_UNSAFE_TO_DESTROY_ERROR at location Module ModuleId { address: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6, name: Identifier("m") } at index 0 for function definition at code offset 11 in function definition 0 task 2 'run'. lines 28-28: -Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None) +Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR)) task 3 'run'. lines 30-44: -Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None) +Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(STLOC_UNSAFE_TO_DESTROY_ERROR)) diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.exp index 85b58331f150d4..2ad9de1be64e93 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.exp @@ -73,4 +73,4 @@ bug: BYTECODE VERIFICATION FAILED task 3 'run'. lines 70-70: -Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None) +Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR)) diff --git a/aptos-move/aptos-vm-types/src/output.rs b/aptos-move/aptos-vm-types/src/output.rs index df477b1b1c33e3..d8c4ace6d7aaab 100644 --- a/aptos-move/aptos-vm-types/src/output.rs +++ b/aptos-move/aptos-vm-types/src/output.rs @@ -34,7 +34,6 @@ pub struct VMOutput { module_write_set: ModuleWriteSet, fee_statement: FeeStatement, status: TransactionStatus, - auxiliary_data: TransactionAuxiliaryData, } impl VMOutput { @@ -43,14 +42,12 @@ impl VMOutput { module_write_set: ModuleWriteSet, fee_statement: FeeStatement, status: TransactionStatus, - auxiliary_data: TransactionAuxiliaryData, ) -> Self { Self { change_set, module_write_set, fee_statement, status, - auxiliary_data, } } @@ -60,7 +57,6 @@ impl VMOutput { module_write_set: ModuleWriteSet::empty(), fee_statement: FeeStatement::zero(), status, - auxiliary_data: TransactionAuxiliaryData::default(), } } @@ -102,10 +98,6 @@ impl VMOutput { &self.status } - pub fn auxiliary_data(&self) -> &TransactionAuxiliaryData { - &self.auxiliary_data - } - pub fn materialized_size(&self) -> u64 { let mut size = 0; for (state_key, write_size) in self @@ -179,7 +171,6 @@ impl VMOutput { module_write_set, fee_statement, status, - auxiliary_data, } = self; let (write_set, events) = change_set .try_combine_into_storage_change_set(module_write_set)? @@ -189,7 +180,7 @@ impl VMOutput { events, fee_statement.gas_used(), status, - auxiliary_data, + TransactionAuxiliaryData::default(), )) } diff --git a/aptos-move/aptos-vm-types/src/tests/utils.rs b/aptos-move/aptos-vm-types/src/tests/utils.rs index 2cd4fbb5b4a4ec..71bee8d9ead3f3 100644 --- a/aptos-move/aptos-vm-types/src/tests/utils.rs +++ b/aptos-move/aptos-vm-types/src/tests/utils.rs @@ -16,7 +16,7 @@ use aptos_types::{ fee_statement::FeeStatement, on_chain_config::CurrentTimeMicroseconds, state_store::{state_key::StateKey, state_value::StateValueMetadata}, - transaction::{ExecutionStatus, TransactionAuxiliaryData, TransactionStatus}, + transaction::{ExecutionStatus, TransactionStatus}, write_set::WriteOp, }; use move_binary_format::errors::PartialVMResult; @@ -252,7 +252,6 @@ pub(crate) fn build_vm_output( ModuleWriteSet::new(false, module_write_set.into_iter().collect()), FeeStatement::new(GAS_USED, GAS_USED, 0, 0, 0), STATUS, - TransactionAuxiliaryData::default(), ) } diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index 1622b461330a59..fa33ac1a4a3f81 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -70,8 +70,8 @@ use aptos_types::{ authenticator::AnySignature, signature_verified_transaction::SignatureVerifiedTransaction, BlockOutput, EntryFunction, ExecutionError, ExecutionStatus, ModuleBundle, Multisig, MultisigTransactionPayload, Script, SignedTransaction, Transaction, TransactionArgument, - TransactionAuxiliaryData, TransactionOutput, TransactionPayload, TransactionStatus, - VMValidatorResult, ViewFunctionOutput, WriteSetPayload, + TransactionOutput, TransactionPayload, TransactionStatus, VMValidatorResult, + ViewFunctionOutput, WriteSetPayload, }, vm_status::{AbortLocation, StatusCode, VMStatus}, }; @@ -186,7 +186,6 @@ pub(crate) fn get_system_transaction_output( ModuleWriteSet::empty(), FeeStatement::zero(), TransactionStatus::Keep(ExecutionStatus::Success), - TransactionAuxiliaryData::default(), )) } @@ -471,7 +470,7 @@ impl AptosVM { } } - let (txn_status, txn_aux_data) = TransactionStatus::from_vm_status( + let txn_status = TransactionStatus::from_vm_status( error_vm_status.clone(), self.features() .is_enabled(FeatureFlag::CHARGE_INVARIANT_VIOLATION), @@ -493,7 +492,6 @@ impl AptosVM { resolver, module_storage, status, - txn_aux_data, log_context, change_set_configs, traversal_context, @@ -541,7 +539,6 @@ impl AptosVM { resolver: &impl AptosMoveResolver, module_storage: &impl AptosModuleStorage, status: ExecutionStatus, - txn_aux_data: TransactionAuxiliaryData, log_context: &AdapterLogSchema, change_set_configs: &ChangeSetConfigs, traversal_context: &mut TraversalContext, @@ -672,13 +669,7 @@ impl AptosVM { ) })?; - epilogue_session.finish( - fee_statement, - status, - txn_aux_data, - change_set_configs, - module_storage, - ) + epilogue_session.finish(fee_statement, status, change_set_configs, module_storage) } fn success_transaction_cleanup( @@ -728,7 +719,6 @@ impl AptosVM { let output = epilogue_session.finish( fee_statement, ExecutionStatus::Success, - TransactionAuxiliaryData::default(), change_set_configs, module_storage, )?; @@ -2307,7 +2297,6 @@ impl AptosVM { module_write_set, FeeStatement::zero(), TransactionStatus::Keep(ExecutionStatus::Success), - TransactionAuxiliaryData::default(), ); Ok((VMStatus::Executed, output)) } diff --git a/aptos-move/aptos-vm/src/move_vm_ext/session/user_transaction_sessions/epilogue.rs b/aptos-move/aptos-vm/src/move_vm_ext/session/user_transaction_sessions/epilogue.rs index 0d1c4e19d04e5c..673941f5f876e4 100644 --- a/aptos-move/aptos-vm/src/move_vm_ext/session/user_transaction_sessions/epilogue.rs +++ b/aptos-move/aptos-vm/src/move_vm_ext/session/user_transaction_sessions/epilogue.rs @@ -17,7 +17,7 @@ use crate::{ use aptos_gas_algebra::Fee; use aptos_types::{ fee_statement::FeeStatement, - transaction::{ExecutionStatus, TransactionAuxiliaryData, TransactionStatus}, + transaction::{ExecutionStatus, TransactionStatus}, }; use aptos_vm_types::{ change_set::VMChangeSet, module_and_script_storage::module_storage::AptosModuleStorage, @@ -104,7 +104,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> { self, fee_statement: FeeStatement, execution_status: ExecutionStatus, - txn_aux_data: TransactionAuxiliaryData, change_set_configs: &ChangeSetConfigs, module_storage: &impl AptosModuleStorage, ) -> Result { @@ -135,7 +134,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> { module_write_set, fee_statement, TransactionStatus::Keep(execution_status), - txn_aux_data, )) } } diff --git a/aptos-move/e2e-move-tests/src/tests/vm.rs b/aptos-move/e2e-move-tests/src/tests/vm.rs index a7fea434e5571b..ea5736d11faad8 100644 --- a/aptos-move/e2e-move-tests/src/tests/vm.rs +++ b/aptos-move/e2e-move-tests/src/tests/vm.rs @@ -41,15 +41,6 @@ fn failed_transaction_cleanup_charges_gas(status_code: StatusCode) { balance, ) .1; - - assert_eq!( - output - .auxiliary_data() - .get_detail_error_message() - .unwrap() - .status_code(), - status_code - ); let write_set: Vec<(&StateKey, &WriteOp)> = output .concrete_write_set_iter() .map(|(k, v)| (k, assert_some!(v))) @@ -59,6 +50,6 @@ fn failed_transaction_cleanup_charges_gas(status_code: StatusCode) { assert!(!output.status().is_discarded()); assert_ok_eq!( output.status().as_kept_status(), - ExecutionStatus::MiscellaneousError(None) + ExecutionStatus::MiscellaneousError(Some(status_code)) ); } diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp index 9aa3663a3fdc9e..20de00dffbee63 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + TYPE_MISMATCH, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp index 0716e44bde3afa..dda1f76afcd1bc 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + NEGATIVE_STACK_SIZE_WITHIN_BLOCK, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp index c383918b5692ed..3371039e2ea90a 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + LINKER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp index 69cc92770c691e..475985803d731d 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + LOOKUP_FAILED, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp index c383918b5692ed..3371039e2ea90a 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + LINKER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp index c383918b5692ed..3371039e2ea90a 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + LINKER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp index 08b93c02d50db4..106201e0a6b0d6 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + CODE_DESERIALIZATION_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_dependency_fails_verification.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_dependency_fails_verification.exp index 9d508c1e4da5eb..d491de7c0bc8a6 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_dependency_fails_verification.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_dependency_fails_verification.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + UNEXPECTED_VERIFIER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_transitive_dependency_fails_verification.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_transitive_dependency_fails_verification.exp index 9d508c1e4da5eb..d491de7c0bc8a6 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_transitive_dependency_fails_verification.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_script_transitive_dependency_fails_verification.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + UNEXPECTED_VERIFIER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_dependency_fails_verification.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_dependency_fails_verification.exp index 9d508c1e4da5eb..d491de7c0bc8a6 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_dependency_fails_verification.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_dependency_fails_verification.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + UNEXPECTED_VERIFIER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_transitive_dependency_fails_verification.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_transitive_dependency_fails_verification.exp index 9d508c1e4da5eb..d491de7c0bc8a6 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_transitive_dependency_fails_verification.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_type_tag_transitive_dependency_fails_verification.exp @@ -18,7 +18,9 @@ Ok( gas_used: 3, status: Keep( MiscellaneousError( - None, + Some( + UNEXPECTED_VERIFIER_ERROR, + ), ), ), auxiliary_data: V1( diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 4b4faa2f2dd6ee..5b622a8dc20487 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -64,7 +64,7 @@ pub enum FeatureFlag { _DEPRECATED_RECONFIGURE_WITH_DKG = 45, KEYLESS_ACCOUNTS = 46, KEYLESS_BUT_ZKLESS_ACCOUNTS = 47, - REMOVE_DETAILED_ERROR_FROM_HASH = 48, + REMOVE_DETAILED_ERROR_FROM_HASH = 48, // This feature is not used JWK_CONSENSUS = 49, CONCURRENT_FUNGIBLE_ASSETS = 50, REFUNDABLE_BYTES = 51, diff --git a/types/src/proptest_types.rs b/types/src/proptest_types.rs index 6ecd73ef8d6ac0..25179e0d1abe53 100644 --- a/types/src/proptest_types.rs +++ b/types/src/proptest_types.rs @@ -499,8 +499,7 @@ impl TransactionPayload { prop_compose! { fn arb_transaction_status()(vm_status in any::()) -> TransactionStatus { - let (txn_status, _) = TransactionStatus::from_vm_status(vm_status, true); - txn_status + TransactionStatus::from_vm_status(vm_status, true) } } diff --git a/types/src/transaction/mod.rs b/types/src/transaction/mod.rs index dbd4d7ba9721c9..4832c42712598c 100644 --- a/types/src/transaction/mod.rs +++ b/types/src/transaction/mod.rs @@ -960,14 +960,10 @@ impl TransactionStatus { } } - pub fn from_vm_status( - vm_status: VMStatus, - charge_invariant_violation: bool, - ) -> (Self, TransactionAuxiliaryData) { + pub fn from_vm_status(vm_status: VMStatus, charge_invariant_violation: bool) -> Self { let status_code = vm_status.status_code(); - let txn_aux = TransactionAuxiliaryData::from_vm_status(&vm_status); // TODO: keep_or_discard logic should be deprecated from Move repo and refactored into here. - let status = match vm_status.keep_or_discard() { + match vm_status.keep_or_discard() { Ok(recorded) => match recorded { // TODO(bowu):status code should be removed from transaction status KeptVMStatus::MiscellaneousError => { @@ -984,8 +980,7 @@ impl TransactionStatus { TransactionStatus::Discard(code) } }, - }; - (status, txn_aux) + } } pub fn from_executed_vm_status(vm_status: VMStatus) -> Self {