Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand committed Nov 22, 2024
1 parent 0f9c1d0 commit fd5f4ba
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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))
11 changes: 1 addition & 10 deletions aptos-move/aptos-vm-types/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub struct VMOutput {
module_write_set: ModuleWriteSet,
fee_statement: FeeStatement,
status: TransactionStatus,
auxiliary_data: TransactionAuxiliaryData,
}

impl VMOutput {
Expand All @@ -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,
}
}

Expand All @@ -60,7 +57,6 @@ impl VMOutput {
module_write_set: ModuleWriteSet::empty(),
fee_statement: FeeStatement::zero(),
status,
auxiliary_data: TransactionAuxiliaryData::default(),
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)?
Expand All @@ -189,7 +180,7 @@ impl VMOutput {
events,
fee_statement.gas_used(),
status,
auxiliary_data,
TransactionAuxiliaryData::default(),
))
}

Expand Down
3 changes: 1 addition & 2 deletions aptos-move/aptos-vm-types/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
)
}

Expand Down
19 changes: 4 additions & 15 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -186,7 +186,6 @@ pub(crate) fn get_system_transaction_output(
ModuleWriteSet::empty(),
FeeStatement::zero(),
TransactionStatus::Keep(ExecutionStatus::Success),
TransactionAuxiliaryData::default(),
))
}

Expand Down Expand Up @@ -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),
Expand All @@ -493,7 +492,6 @@ impl AptosVM {
resolver,
module_storage,
status,
txn_aux_data,
log_context,
change_set_configs,
traversal_context,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -728,7 +719,6 @@ impl AptosVM {
let output = epilogue_session.finish(
fee_statement,
ExecutionStatus::Success,
TransactionAuxiliaryData::default(),
change_set_configs,
module_storage,
)?;
Expand Down Expand Up @@ -2307,7 +2297,6 @@ impl AptosVM {
module_write_set,
FeeStatement::zero(),
TransactionStatus::Keep(ExecutionStatus::Success),
TransactionAuxiliaryData::default(),
);
Ok((VMStatus::Executed, output))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<VMOutput, VMStatus> {
Expand Down Expand Up @@ -135,7 +134,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> {
module_write_set,
fee_statement,
TransactionStatus::Keep(execution_status),
txn_aux_data,
))
}
}
11 changes: 1 addition & 10 deletions aptos-move/e2e-move-tests/src/tests/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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))
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
TYPE_MISMATCH,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
NEGATIVE_STACK_SIZE_WITHIN_BLOCK,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
LINKER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
LOOKUP_FAILED,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
LINKER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
LINKER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
CODE_DESERIALIZATION_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
UNEXPECTED_VERIFIER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
UNEXPECTED_VERIFIER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
UNEXPECTED_VERIFIER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
Some(
UNEXPECTED_VERIFIER_ERROR,
),
),
),
auxiliary_data: V1(
Expand Down
2 changes: 1 addition & 1 deletion types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions types/src/proptest_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,7 @@ impl TransactionPayload {

prop_compose! {
fn arb_transaction_status()(vm_status in any::<VMStatus>()) -> TransactionStatus {
let (txn_status, _) = TransactionStatus::from_vm_status(vm_status, true);
txn_status
TransactionStatus::from_vm_status(vm_status, true)
}
}

Expand Down
11 changes: 3 additions & 8 deletions types/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -984,8 +980,7 @@ impl TransactionStatus {
TransactionStatus::Discard(code)
}
},
};
(status, txn_aux)
}
}

pub fn from_executed_vm_status(vm_status: VMStatus) -> Self {
Expand Down

0 comments on commit fd5f4ba

Please sign in to comment.