Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests
Browse files Browse the repository at this point in the history
areshand committed Dec 4, 2024
1 parent 9942247 commit 508aafd
Showing 31 changed files with 89 additions and 332 deletions.
Original file line number Diff line number Diff line change
@@ -285,7 +285,9 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::ReconfigureWithDkg => AptosFeatureFlag::_DEPRECATED_RECONFIGURE_WITH_DKG,
FeatureFlag::KeylessAccounts => AptosFeatureFlag::KEYLESS_ACCOUNTS,
FeatureFlag::KeylessButZklessAccounts => AptosFeatureFlag::KEYLESS_BUT_ZKLESS_ACCOUNTS,
FeatureFlag::RemoveDetailedError => AptosFeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH,
FeatureFlag::RemoveDetailedError => {
AptosFeatureFlag::_DEPRECATED_REMOVE_DETAILED_ERROR_FROM_HASH
},
FeatureFlag::JwkConsensus => AptosFeatureFlag::JWK_CONSENSUS,
FeatureFlag::ConcurrentFungibleAssets => AptosFeatureFlag::CONCURRENT_FUNGIBLE_ASSETS,
FeatureFlag::RefundableBytes => AptosFeatureFlag::REFUNDABLE_BYTES,
@@ -430,7 +432,9 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::_DEPRECATED_RECONFIGURE_WITH_DKG => FeatureFlag::ReconfigureWithDkg,
AptosFeatureFlag::KEYLESS_ACCOUNTS => FeatureFlag::KeylessAccounts,
AptosFeatureFlag::KEYLESS_BUT_ZKLESS_ACCOUNTS => FeatureFlag::KeylessButZklessAccounts,
AptosFeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH => FeatureFlag::RemoveDetailedError,
AptosFeatureFlag::_DEPRECATED_REMOVE_DETAILED_ERROR_FROM_HASH => {
FeatureFlag::RemoveDetailedError
},
AptosFeatureFlag::JWK_CONSENSUS => FeatureFlag::JwkConsensus,
AptosFeatureFlag::CONCURRENT_FUNGIBLE_ASSETS => FeatureFlag::ConcurrentFungibleAssets,
AptosFeatureFlag::REFUNDABLE_BYTES => FeatureFlag::RefundableBytes,
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
@@ -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(),
))
}

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
@@ -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(),
)
}

19 changes: 4 additions & 15 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
@@ -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))
}
Original file line number Diff line number Diff line change
@@ -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<VMOutput, VMStatus> {
@@ -135,7 +134,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> {
module_write_set,
fee_statement,
TransactionStatus::Keep(execution_status),
txn_aux_data,
))
}
}
14 changes: 4 additions & 10 deletions aptos-move/e2e-move-tests/src/harness.rs
Original file line number Diff line number Diff line change
@@ -196,12 +196,11 @@ impl MoveHarness {

/// Runs a signed transaction. On success, applies the write set.
pub fn run_raw(&mut self, txn: SignedTransaction) -> TransactionOutput {
let mut output = self.executor.execute_transaction(txn);
let output = self.executor.execute_transaction(txn);
if matches!(output.status(), TransactionStatus::Keep(_)) {
self.executor.apply_write_set(output.write_set());
self.executor.append_events(output.events().to_vec());
}
output.fill_error_status();
output
}

@@ -239,12 +238,11 @@ impl MoveHarness {
&mut self,
txn_block: Vec<SignedTransaction>,
) -> Vec<TransactionOutput> {
let mut result = assert_ok!(self.executor.execute_block(txn_block));
for output in &mut result {
let result = assert_ok!(self.executor.execute_block(txn_block));
for output in &result {
if matches!(output.status(), TransactionStatus::Keep(_)) {
self.executor.apply_write_set(output.write_set());
}
output.fill_error_status();
}
result
}
@@ -979,11 +977,7 @@ impl MoveHarness {
offset,
txns.len()
);
let mut outputs = harness.run_block_get_output(txns);
let _ = outputs
.iter_mut()
.map(|t| t.fill_error_status())
.collect::<Vec<_>>();
let outputs = harness.run_block_get_output(txns);
for (idx, (error, output)) in errors.into_iter().zip(outputs.iter()).enumerate() {
if error == SUCCESS {
assert_success!(
15 changes: 4 additions & 11 deletions aptos-move/e2e-move-tests/src/tests/code_publishing.rs
Original file line number Diff line number Diff line change
@@ -242,17 +242,10 @@ fn code_publishing_upgrade_loader_cache_consistency() {
|_| {},
),
];
let result = h.run_block_get_output(txns);
assert_success!(result[0].status().to_owned());
assert_success!(result[1].status().to_owned());
assert_eq!(
result[2]
.auxiliary_data()
.get_detail_error_message()
.unwrap()
.status_code(),
StatusCode::BACKWARD_INCOMPATIBLE_MODULE_UPDATE
)
let result = h.run_block(txns);
assert_success!(result[0]);
assert_success!(result[1]);
assert_vm_status!(result[2], StatusCode::BACKWARD_INCOMPATIBLE_MODULE_UPDATE)
}

#[test]
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
@@ -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))
);
}
Original file line number Diff line number Diff line change
@@ -21,18 +21,7 @@ Ok(
code_offset: 2,
},
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: MISSING_DATA,
message: Some(
"Failed to move resource from f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1",
),
},
),
},
),
auxiliary_data: None,
},
],
)
@@ -126,18 +115,7 @@ Ok(
code_offset: 2,
},
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: MISSING_DATA,
message: Some(
"Failed to borrow global resource from f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1",
),
},
),
},
),
auxiliary_data: None,
},
],
)
Loading

0 comments on commit 508aafd

Please sign in to comment.