Skip to content

Commit

Permalink
transactional-tests: also provide the rich error in the exp files
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jun 17, 2022
1 parent 72d9024 commit 98d674f
Show file tree
Hide file tree
Showing 45 changed files with 167 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ task 6 'run'. lines 86-88:
written: object(109), object(111), object(112)

task 7 'run'. lines 89-89:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidSharedChildUse, source: Some("When an (either direct or indirect) child object of a shared object is passed as a Move argument,either the child object's type or the shared object's type must be defined in the same module as the called function. This is violated by object fake(109) (defined in module 'T1::O1'), whose ancestor fake(111) is a shared object (defined in module 'T2::O2'), and neither are defined in this module 'T1::O1'") } }

task 8 'run'. lines 91-91:
written: object(109), object(111), object(114)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ created: object(103)
written: object(102)

task 2 'run'. lines 26-26:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: Some("Can only call `entry` functions") } }

task 3 'run'. lines 28-28:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: Some("Can only call `entry` functions") } }

task 4 'run'. lines 30-30:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: Some("Can only call `entry` functions") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 2 tasks

task 1 'publish'. lines 5-24:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Expected exactly one parameter for _::M1::init of type &mut sui::tx_context::TxContext") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 2 tasks

task 1 'publish'. lines 5-25:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("_::M1. 'init' function must be private") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 2 tasks

task 1 'publish'. lines 5-26:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("_::M1, 'init' function cannot have return values") } }
6 changes: 4 additions & 2 deletions crates/sui-adapter-transactional-tests/tests/sui/freeze.exp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ task 2 'run'. lines 10-10:
written: object(104), object(105)

task 3 'run'. lines 12-12:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeError, source: Some("Only owned object can be passed by-value, violation found in argument 0") } }

task 4 'run'. lines 14-14:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeError, source: Some("Argument 0 is expected to be mutable, immutable object found") } }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ created: object(103)
written: object(102)

task 2 'run'. lines 14-16:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidFunctionSignature, source: Some("Expected 2 arguments calling function 'create', but found 1") } }

task 3 'run'. lines 17-17:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VmError, source: Some(VMError { major_status: FAILED_TO_DESERIALIZE_ARGUMENT, sub_status: None, message: None, exec_state: None, location: Undefined, indices: [], offsets: [] }) } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'run'. lines 7-9:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VmError, source: Some(VMError { major_status: LINKER_ERROR, sub_status: None, message: Some("Cannot find ModuleId { address: _, name: Identifier(\"object_basics\") } in data cache"), exec_state: None, location: Undefined, indices: [], offsets: [] }) } }

task 1 'run'. lines 10-10:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: FunctionNotFound, source: Some("Could not resolve function 'foo' in module sui::object_basics") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 2 tasks

task 1 'publish'. lines 8-10:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModulePublishFailure, source: Some("Publishing module M with non-zero address is not allowed") } }
4 changes: 2 additions & 2 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl AuthorityState {
let transaction_dependencies = input_objects.transaction_dependencies();
let mut temporary_store =
AuthorityTemporaryStore::new(self.database.clone(), input_objects, transaction_digest);
let effects = execution_engine::execute_transaction_to_effects(
let (effects, _execution_error) = execution_engine::execute_transaction_to_effects(
shared_object_refs,
&mut temporary_store,
certificate.data.clone(),
Expand All @@ -594,7 +594,7 @@ impl AuthorityState {
&self._native_functions,
gas_status,
self.committee.load().epoch,
)?;
);

self.metrics.total_effects.inc();
self.metrics
Expand Down
5 changes: 2 additions & 3 deletions crates/sui-core/src/epoch/tests/reconfiguration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async fn test_start_epoch_change() {
),
tx_digest,
);
let effects = execution_engine::execute_transaction_to_effects(
let (effects, _) = execution_engine::execute_transaction_to_effects(
vec![],
&mut temporary_store,
transaction.data.clone(),
Expand All @@ -152,8 +152,7 @@ async fn test_start_epoch_change() {
&state._native_functions,
SuiGasStatus::new_with_budget(1000, 1, 1),
state.committee.load().epoch,
)
.unwrap();
);
let signed_effects = effects.to_sign_effects(0, &state.name, &*state.secret);
assert_eq!(
state
Expand Down
23 changes: 13 additions & 10 deletions crates/sui-core/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use sui_types::gas_coin::GasCoin;
use sui_types::object::{MoveObject, Owner, OBJECT_START_VERSION};
use sui_types::{
base_types::{ObjectID, ObjectRef, SuiAddress, TransactionDigest, TxContext},
error::SuiResult,
event::{Event, TransferType},
gas::{self, SuiGasStatus},
messages::{
Expand All @@ -39,11 +38,11 @@ pub fn execute_transaction_to_effects<S: BackingPackageStore>(
native_functions: &NativeFunctionTable,
gas_status: SuiGasStatus,
epoch: EpochId,
) -> SuiResult<TransactionEffects> {
) -> (TransactionEffects, Option<ExecutionError>) {
let mut tx_ctx = TxContext::new(&transaction_data.signer(), &transaction_digest, epoch);

let gas_object_ref = *transaction_data.gas_payment_object_ref();
let (gas_cost_summary, status) = execute_transaction(
let (gas_cost_summary, execution_result) = execute_transaction(
temporary_store,
transaction_data,
gas_object_ref.0,
Expand All @@ -52,6 +51,14 @@ pub fn execute_transaction_to_effects<S: BackingPackageStore>(
native_functions,
gas_status,
);

let (status, execution_error) = match execution_result {
Ok(()) => (ExecutionStatus::Success, None),
Err(error) => (
ExecutionStatus::new_failure(error.to_execution_status()),
Some(error),
),
};
debug!(
computation_gas_cost = gas_cost_summary.computation_cost,
storage_gas_cost = gas_cost_summary.storage_cost,
Expand All @@ -71,7 +78,7 @@ pub fn execute_transaction_to_effects<S: BackingPackageStore>(
status,
gas_object_ref,
);
Ok(effects)
(effects, execution_error)
}

fn charge_gas_for_object_read<S>(
Expand All @@ -98,7 +105,7 @@ fn execute_transaction<S: BackingPackageStore>(
move_vm: &Arc<MoveVM>,
native_functions: &NativeFunctionTable,
mut gas_status: SuiGasStatus,
) -> (GasCostSummary, ExecutionStatus) {
) -> (GasCostSummary, Result<(), ExecutionError>) {
// We must charge object read gas inside here during transaction execution, because if this fails
// we must still ensure an effect is committed and all objects versions incremented.
let mut result = charge_gas_for_object_read(temporary_store, &mut gas_status);
Expand Down Expand Up @@ -228,11 +235,7 @@ fn execute_transaction<S: BackingPackageStore>(
}

let cost_summary = gas_status.summary(result.is_ok());
let status = match result {
Ok(()) => ExecutionStatus::Success,
Err(error) => ExecutionStatus::new_failure(error),
};
(cost_summary, status)
(cost_summary, result)
}

fn transfer_coin<S>(
Expand Down
41 changes: 26 additions & 15 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,22 @@ impl<'a> SuiTestAdapter<'a> {
let shared_object_refs: Vec<_> = input_objects.filter_shared_objects();
let mut temporary_store =
AuthorityTemporaryStore::new(self.storage.clone(), input_objects, transaction_digest);
let TransactionEffects {
status,
events,
created,
// TODO display all these somehow
transaction_digest: _,
mutated: _,
unwrapped: _,
deleted: _,
wrapped: _,
gas_object: _,
..
} = execution_engine::execute_transaction_to_effects(
let (
TransactionEffects {
status,
events,
created,
// TODO display all these somehow
transaction_digest: _,
mutated: _,
unwrapped: _,
deleted: _,
wrapped: _,
gas_object: _,
..
},
execution_error,
) = execution_engine::execute_transaction_to_effects(
shared_object_refs,
&mut temporary_store,
transaction.data,
Expand All @@ -469,7 +472,7 @@ impl<'a> SuiTestAdapter<'a> {
gas_status,
// TODO: Support different epochs in transactional tests.
0,
)?;
);
let (_objects, _active_inputs, written, deleted, _events) = temporary_store.into_inner();
let created_set: BTreeSet<_> = created.iter().map(|((id, _, _), _)| *id).collect();
let mut created_ids: Vec<_> = created_set.iter().copied().collect();
Expand Down Expand Up @@ -504,7 +507,15 @@ impl<'a> SuiTestAdapter<'a> {
deleted: deleted_ids,
events,
}),
ExecutionStatus::Failure { error, .. } => Err(error.into()),
ExecutionStatus::Failure { error, .. } => {
Err(anyhow::anyhow!(self.stabilize_str(format!(
"Transaction Effects Status: {}\nExecution Error: {}",
error,
execution_error.expect(
"to have an execution error if a transaction's status is a failure"
)
))))
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions crates/sui-types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,8 @@ impl std::fmt::Display for ExecutionFailureStatus {
impl std::error::Error for ExecutionFailureStatus {}

impl ExecutionStatus {
pub fn new_failure(error: ExecutionError) -> ExecutionStatus {
ExecutionStatus::Failure {
error: error.to_execution_status(),
}
pub fn new_failure(error: ExecutionFailureStatus) -> ExecutionStatus {
ExecutionStatus::Failure { error }
}

pub fn is_ok(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 6-16:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: std::option::Option<T0>") } }

task 1 'publish'. lines 18-28:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: vector<std::option::Option<T0>>") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 1 task

task 0 'publish'. lines 6-17:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: _::m::S") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 6-21:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: _::m::Obj<_::m::NoStore>") } }

task 1 'publish'. lines 23-35:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: _::m::Obj<T0>") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 1 task

task 0 'publish'. lines 6-17:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: vector<_::m::S>") } }
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
processed 4 tasks

task 0 'publish'. lines 4-11:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Entry function foo cannot have return values") } }

task 1 'publish'. lines 13-20:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Entry function foo cannot have return values") } }

task 2 'publish'. lines 22-29:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Entry function foo cannot have return values") } }

task 3 'publish'. lines 32-39:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Entry function foo cannot have return values") } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-31:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [Exists(StructDefinitionIndex(0)), ExistsGeneric(StructDefInstantiationIndex(0)), ImmBorrowGlobal(StructDefinitionIndex(0)), ImmBorrowGlobalGeneric(StructDefInstantiationIndex(0)), MutBorrowGlobal(StructDefinitionIndex(0)), MutBorrowGlobalGeneric(StructDefInstantiationIndex(0)), MoveFrom(StructDefinitionIndex(0)), MoveFromGeneric(StructDefInstantiationIndex(0)), MoveTo(StructDefinitionIndex(0)), MoveToGeneric(StructDefInstantiationIndex(0))]") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [ImmBorrowGlobal(StructDefinitionIndex(0))]") } }

task 1 'publish'. lines 17-27:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [ImmBorrowGlobalGeneric(StructDefInstantiationIndex(0))]") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MutBorrowGlobal(StructDefinitionIndex(0))]") } }

task 1 'publish'. lines 17-27:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MutBorrowGlobalGeneric(StructDefInstantiationIndex(0))]") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 4-14:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [Exists(StructDefinitionIndex(0))]") } }

task 1 'publish'. lines 16-25:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [ExistsGeneric(StructDefInstantiationIndex(0))]") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 4-20:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MoveFrom(StructDefinitionIndex(0))]") } }

task 1 'publish'. lines 22-38:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MoveFromGeneric(StructDefInstantiationIndex(0))]") } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MoveTo(StructDefinitionIndex(0))]") } }

task 1 'publish'. lines 17-27:
Error: MiscellaneousError
Error: Transaction Effects Status: MiscellaneousError
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: Some("Access to Move global storage is not allowed. Found in function no: [MoveToGeneric(StructDefInstantiationIndex(0))]") } }
Loading

0 comments on commit 98d674f

Please sign in to comment.