Skip to content

Commit

Permalink
surface detailed txn error info
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand authored and aptos-bot committed Apr 29, 2022
1 parent 8face68 commit afbc745
Show file tree
Hide file tree
Showing 73 changed files with 370 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0x9e937cad7eb1f106b39a41b30fd3136bf2bfe83833402c059739188b1c535823",
"vm_status": "Transaction Executed and Committed with Error MALFORMED",
"accumulator_root_hash": "0xed295d37eb4c5230ce3b16b1c350490a749640678acab6b67ab4eeb850a6e44f",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0xcc3225247027f93c97b554eeb6916af63584ed3913fac1e36706e5e0429715e9",
"vm_status": "Transaction Executed and Committed with Error LINKER_ERROR",
"accumulator_root_hash": "0x1c117522be906f5ae57d1b64c0bfc68a321cf939cc01cbb2fd651c4d3f940496",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0x11a3cea077b7b0c5f7cd0eb3a8a69d8dd6b1610333a0fb0187a6d4d83d3bf8f1",
"vm_status": "Transaction Executed and Committed with Error FAILED_TO_DESERIALIZE_ARGUMENT",
"accumulator_root_hash": "0xcc86fac7123f562fa1be03253303b1e29c1431c1c1bcd7d61d1bf630201581fe",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0x28ca1287846826cd276063d674b7f9ac7ca9257a753ae8d2b0e53ea738ef7c09",
"vm_status": "Transaction Executed and Committed with Error LINKER_ERROR",
"accumulator_root_hash": "0xd3e3f6fc14545d96c82e250bf96a0ee769cbb0b4f477dc294c920784921e9d45",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0x3f294c1adee9d52b818a048d7cb006400a1f34268ba6a2a9373c191f2336358d",
"vm_status": "Transaction Executed and Committed with Error FUNCTION_RESOLUTION_FAILURE",
"accumulator_root_hash": "0xb31e4d152eaf93c2410c3704b31f1a1d4981679715e69a878b95f5b6c3a2a862",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0xc36eb37d2fc0f88de5a3b1e66ad3a2916983adbeaab9f98e4322f7abe5433e25",
"vm_status": "Transaction Executed and Committed with Error CODE_DESERIALIZATION_ERROR",
"accumulator_root_hash": "0x56f1ee2717a18370b4cebafd42a120dcd6a329b06b1f2a6cca98eb450d1e26b1",
"changes": [
{
"type": "write_resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
"gas_used": "1",
"success": false,
"vm_status": "Move bytecode deserialization / verification failed, including script function not found or invalid arguments",
"accumulator_root_hash": "0x61a7e49a61a5ae7f468d45bb2a9ac4cf9fef339b8ea01f19a14c772195a59c20",
"vm_status": "Transaction Executed and Committed with Error NUMBER_OF_ARGUMENTS_MISMATCH",
"accumulator_root_hash": "0x193cdf5a5449c17ee0750befed25ce39ae385dc51f08f9c601efd44e20148e73",
"changes": [
{
"type": "write_resource",
Expand Down
32 changes: 19 additions & 13 deletions api/types/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ use aptos_types::{
chain_id::ChainId,
contract_event::ContractEvent,
state_store::state_key::StateKey,
transaction::{ModuleBundle, RawTransaction, Script, ScriptFunction, SignedTransaction},
vm_status::{AbortLocation, KeptVMStatus},
transaction::{
ExecutionStatus, ModuleBundle, RawTransaction, Script, ScriptFunction, SignedTransaction,
},
vm_status::AbortLocation,
write_set::WriteOp,
};
use aptos_vm::move_vm_ext::MoveResolverExt;
Expand Down Expand Up @@ -558,11 +560,11 @@ impl<'a, R: MoveResolverExt + ?Sized> MoveConverter<'a, R> {
))
}

fn explain_vm_status(&self, status: &KeptVMStatus) -> String {
fn explain_vm_status(&self, status: &ExecutionStatus) -> String {
match status {
KeptVMStatus::MoveAbort(location, abort_code) => match &location {
ExecutionStatus::MoveAbort { location, code} => match &location {
AbortLocation::Module(module_id) => {
let explanation = error_explain::get_explanation(module_id, *abort_code);
let explanation = error_explain::get_explanation(module_id, *code);
explanation
.map(|ec| {
format!(
Expand All @@ -574,14 +576,14 @@ impl<'a, R: MoveResolverExt + ?Sized> MoveConverter<'a, R> {
)
})
.unwrap_or_else(|| {
format!("Move abort: code {} at {}", abort_code, location)
format!("Move abort: code {} at {}", code, location)
})
}
AbortLocation::Script => format!("Move abort: code {}", abort_code),
AbortLocation::Script => format!("Move abort: code {}", code),
},
KeptVMStatus::Executed => "Executed successfully".to_owned(),
KeptVMStatus::OutOfGas => "Out of gas".to_owned(),
KeptVMStatus::ExecutionFailure {
ExecutionStatus::Success => "Executed successfully".to_owned(),
ExecutionStatus::OutOfGas => "Out of gas".to_owned(),
ExecutionStatus::ExecutionFailure {
location,
function,
code_offset,
Expand All @@ -598,9 +600,13 @@ impl<'a, R: MoveResolverExt + ?Sized> MoveConverter<'a, R> {
func_name, code_offset
)
}
KeptVMStatus::MiscellaneousError => {
"Move bytecode deserialization / verification failed, including script function not found or invalid arguments"
.to_owned()
ExecutionStatus::MiscellaneousError( code ) => {
code.map_or(
"Move bytecode deserialization / verification failed, including script function not found or invalid arguments".to_owned(),
|e| format!(
"Transaction Executed and Committed with Error {:#?}", e
)
)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ use aptos_types::{
block_metadata::BlockMetadata,
on_chain_config::{VMConfig, VMPublishingOption, Version},
transaction::{
ChangeSet, ModuleBundle, SignatureCheckedTransaction, SignedTransaction, Transaction,
TransactionOutput, TransactionPayload, TransactionStatus, VMValidatorResult,
ChangeSet, ExecutionStatus, ModuleBundle, SignatureCheckedTransaction, SignedTransaction,
Transaction, TransactionOutput, TransactionPayload, TransactionStatus, VMValidatorResult,
WriteSetPayload,
},
vm_status::{KeptVMStatus, StatusCode, VMStatus},
vm_status::{StatusCode, VMStatus},
write_set::{WriteSet, WriteSetMut},
};
use fail::fail_point;
Expand Down Expand Up @@ -269,7 +269,7 @@ impl AptosVM {
session,
gas_status.remaining_gas(),
txn_data,
KeptVMStatus::Executed,
ExecutionStatus::Success,
)?,
))
}
Expand Down Expand Up @@ -612,7 +612,7 @@ impl AptosVM {
session,
gas_status.remaining_gas(),
&txn_data,
KeptVMStatus::Executed,
ExecutionStatus::Success,
)?;
Ok((VMStatus::Executed, output))
}
Expand Down Expand Up @@ -749,7 +749,7 @@ impl AptosVM {
write_set,
events,
0,
TransactionStatus::Keep(KeptVMStatus::Executed),
TransactionStatus::Keep(ExecutionStatus::Success),
),
))
}
Expand Down Expand Up @@ -934,7 +934,7 @@ impl VMAdapter for AptosVM {
WriteSet::default(),
Vec::new(),
0,
TransactionStatus::Keep(KeptVMStatus::Executed),
TransactionStatus::Keep(ExecutionStatus::Success),
);
(VMStatus::Executed, output, Some("state_checkpoint".into()))
}
Expand Down
6 changes: 3 additions & 3 deletions aptos-move/aptos-vm/src/aptos_vm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use aptos_types::{
ConfigStorage, OnChainConfig, VMConfig, VMPublishingOption, Version, APTOS_VERSION_3,
},
state_store::state_key::StateKey,
transaction::{TransactionOutput, TransactionStatus},
vm_status::{KeptVMStatus, StatusCode, VMStatus},
transaction::{ExecutionStatus, TransactionOutput, TransactionStatus},
vm_status::{StatusCode, VMStatus},
write_set::{WriteOp, WriteSet, WriteSetMut},
};
use fail::fail_point;
Expand Down Expand Up @@ -647,7 +647,7 @@ pub(crate) fn get_transaction_output<A: AccessPathCache, S: MoveResolverExt>(
session: SessionExt<S>,
gas_left: GasUnits<GasCarrier>,
txn_data: &TransactionMetadata,
status: KeptVMStatus,
status: ExecutionStatus,
) -> Result<TransactionOutput, VMStatus> {
let gas_used: u64 = txn_data.max_gas_amount().sub(gas_left).get();

Expand Down
19 changes: 11 additions & 8 deletions aptos-move/e2e-tests-replay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use aptos_types::{
block_metadata::BlockMetadata,
on_chain_config::Version,
transaction::{
Script, ScriptFunction, Transaction, TransactionArgument, TransactionOutput,
TransactionPayload, TransactionStatus, WriteSetPayload,
ExecutionStatus, Script, ScriptFunction, Transaction, TransactionArgument,
TransactionOutput, TransactionPayload, TransactionStatus, WriteSetPayload,
},
};
use aptos_vm::{
Expand Down Expand Up @@ -46,7 +46,7 @@ use move_core_types::{
language_storage::{ModuleId, TypeTag},
resolver::MoveResolver,
value::MoveValue,
vm_status::{KeptVMStatus, VMStatus},
vm_status::VMStatus,
};
use move_stackless_bytecode_interpreter::{
concrete::{
Expand Down Expand Up @@ -156,14 +156,17 @@ fn compare_output(expect_output: &TransactionOutput, actual_output: VMResult<Ses
let actual_status = &err.into_vm_status();
match (expect_status, actual_status) {
(
TransactionStatus::Keep(KeptVMStatus::MoveAbort(expect_loc, expect_code)),
TransactionStatus::Keep(ExecutionStatus::MoveAbort {
location: expect_loc,
code: expect_code,
}),
VMStatus::MoveAbort(actual_loc, actual_code),
) => {
assert_eq!(expect_loc, actual_loc);
assert_eq!(expect_code, actual_code);
}
(
TransactionStatus::Keep(KeptVMStatus::ExecutionFailure {
TransactionStatus::Keep(ExecutionStatus::ExecutionFailure {
location: expect_loc,
function: expect_func,
code_offset: expect_offset,
Expand Down Expand Up @@ -696,7 +699,7 @@ impl<'env> TraceReplayer<'env> {
// ignore out-of-gas cases
if matches!(
expect_output.status(),
TransactionStatus::Keep(KeptVMStatus::OutOfGas)
TransactionStatus::Keep(ExecutionStatus::OutOfGas)
) {
return;
}
Expand Down Expand Up @@ -944,7 +947,7 @@ fn replay_trace<P: AsRef<Path>>(
Transaction::GenesisTransaction(_) => {
if !matches!(
res.status(),
TransactionStatus::Keep(KeptVMStatus::Executed)
TransactionStatus::Keep(ExecutionStatus::Success)
) {
if flags.warning {
eprintln!(
Expand All @@ -958,7 +961,7 @@ fn replay_trace<P: AsRef<Path>>(
Transaction::BlockMetadata(block_metadata) => {
if !matches!(
res.status(),
TransactionStatus::Keep(KeptVMStatus::Executed)
TransactionStatus::Keep(ExecutionStatus::Success)
) {
if flags.warning {
eprintln!(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Ok([TransactionOutput { write_set: WriteSet(WriteSetMut { write_set: [(AccessPath(AccessPath { address: 000000000000000000000000000000000000000000000000000000000a550c18, path: 010000000000000000000000000000000000000000000000000000000000000001074163636f756e74074163636f756e7400 }), Value(20872d108c30648f16843e29655b181edc12dcc9318ec7d90d98a52801cdcd96c90100000000000000000000000000000000000000000000000000000000000000000000000a550c18)), (AccessPath(AccessPath { address: 000000000000000000000000000000000000000000000000000000000a550c18, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0742616c616e636500 }), Value(f5ffffffffffffff)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 010000000000000000000000000000000000000000000000000000000000000001074163636f756e74074163636f756e7400 }), Value(201636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e900000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 01000000000000000000000000000000000000000000000000000000000000000104475549440947656e657261746f7200 }), Value(0200000000000000)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0742616c616e636500 }), Value(0000000000000000)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0e5472616e736665724576656e747300 }), Value(00000000000000002800000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e900000000000000002801000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9))] }), events: [], gas_used: 92, status: Keep(EXECUTED) }])
Ok([TransactionOutput { write_set: WriteSet(WriteSetMut { write_set: [(AccessPath(AccessPath { address: 000000000000000000000000000000000000000000000000000000000a550c18, path: 010000000000000000000000000000000000000000000000000000000000000001074163636f756e74074163636f756e7400 }), Value(20872d108c30648f16843e29655b181edc12dcc9318ec7d90d98a52801cdcd96c90100000000000000000000000000000000000000000000000000000000000000000000000a550c18)), (AccessPath(AccessPath { address: 000000000000000000000000000000000000000000000000000000000a550c18, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0742616c616e636500 }), Value(f5ffffffffffffff)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 010000000000000000000000000000000000000000000000000000000000000001074163636f756e74074163636f756e7400 }), Value(201636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e900000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 01000000000000000000000000000000000000000000000000000000000000000104475549440947656e657261746f7200 }), Value(0200000000000000)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0742616c616e636500 }), Value(0000000000000000)), (AccessPath(AccessPath { address: 1636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9, path: 0100000000000000000000000000000000000000000000000000000000000000010854657374436f696e0e5472616e736665724576656e747300 }), Value(00000000000000002800000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e900000000000000002801000000000000001636331b85359efd8b9ba888caff7a063eebd722df1633f4bf38f1e2087222e9))] }), events: [], gas_used: 92, status: Keep(Success) }])
Loading

0 comments on commit afbc745

Please sign in to comment.