Skip to content

Commit

Permalink
error: further simplify the execution failure status that is committe…
Browse files Browse the repository at this point in the history
…d to chain
  • Loading branch information
bmwill committed Jun 17, 2022
1 parent 8f38511 commit 72d9024
Show file tree
Hide file tree
Showing 47 changed files with 199 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ task 6 'run'. lines 86-88:
written: object(109), object(111), object(112)

task 7 'run'. lines 89-89:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidSharedChildUse, source: None } }
Error: MiscellaneousError

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,10 @@ created: object(103)
written: object(102)

task 2 'run'. lines 26-26:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: None } }
Error: MiscellaneousError

task 3 'run'. lines 28-28:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: None } }
Error: MiscellaneousError

task 4 'run'. lines 30-30:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidNonEntryFunction, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 2 tasks

task 1 'publish'. lines 5-24:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 2 tasks

task 1 'publish'. lines 5-25:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 2 tasks

task 1 'publish'. lines 5-26:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModuleVerificationFailure, source: None } }
Error: MiscellaneousError
4 changes: 2 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,7 @@ task 2 'run'. lines 10-10:
written: object(104), object(105)

task 3 'run'. lines 12-12:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeError, source: None } }
Error: MiscellaneousError

task 4 'run'. lines 14-14:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: TypeError, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ created: object(103)
written: object(102)

task 2 'run'. lines 14-16:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidFunctionSignature, source: None } }
Error: MiscellaneousError

task 3 'run'. lines 17-17:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VmError, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
processed 2 tasks

task 0 'run'. lines 7-9:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VmError, source: None } }
Error: MiscellaneousError

task 1 'run'. lines 10-10:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: FunctionNotFound, source: None } }
Error: MiscellaneousError
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 2 tasks

task 1 'publish'. lines 8-10:
Error: Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: ModulePublishFailure, source: None } }
Error: MiscellaneousError
9 changes: 5 additions & 4 deletions crates/sui-core/src/generate_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::*;
use move_core_types::{
language_storage::TypeTag,
value::{MoveStructLayout, MoveTypeLayout},
vm_status::AbortLocation,
};
use pretty_assertions::assert_str_eq;
use serde_reflection::{Registry, Result, Samples, Tracer, TracerConfig};
Expand All @@ -14,9 +15,9 @@ use sui_types::{
base_types::{self, ObjectDigest, ObjectID, TransactionDigest, TransactionEffectsDigest},
batch::UpdateItem,
crypto::{get_key_pair, AuthoritySignature, Signature},
error::ExecutionErrorKind,
messages::{
CallArg, ExecutionStatus, ObjectInfoRequestKind, SingleTransactionKind, TransactionKind,
CallArg, ExecutionFailureStatus, ExecutionStatus, ObjectInfoRequestKind,
SingleTransactionKind, TransactionKind,
},
object::{Data, Owner},
};
Expand Down Expand Up @@ -58,10 +59,10 @@ fn get_registry() -> Result<Registry> {
tracer.trace_value(&mut samples, &teff)?;

// 2. Trace the main entry point(s) + every enum separately.
// tracer.trace_type::<SuiError>(&samples)?;
tracer.trace_type::<ExecutionErrorKind>(&samples)?;
tracer.trace_type::<Owner>(&samples)?;
tracer.trace_type::<ExecutionStatus>(&samples)?;
tracer.trace_type::<ExecutionFailureStatus>(&samples)?;
tracer.trace_type::<AbortLocation>(&samples)?;
tracer.trace_type::<CallArg>(&samples)?;
tracer.trace_type::<Data>(&samples)?;
tracer.trace_type::<TypeTag>(&samples)?;
Expand Down
13 changes: 6 additions & 7 deletions crates/sui-core/src/unit_tests/gas_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use super::move_integration_tests::build_and_try_publish_test_package;
use move_core_types::account_address::AccountAddress;
use move_core_types::ident_str;
use sui_adapter::genesis;
use sui_types::error::ExecutionErrorKind;
use sui_types::gas_coin::GasCoin;
use sui_types::object::GAS_VALUE_FOR_TESTING;
use sui_types::{
Expand Down Expand Up @@ -167,7 +166,7 @@ async fn test_native_transfer_insufficient_gas_reading_objects() {
let effects = result.response.unwrap().signed_effects.unwrap().effects;
assert_eq!(
effects.status.unwrap_err(),
ExecutionErrorKind::InsufficientGas
ExecutionFailureStatus::InsufficientGas
);
}

Expand Down Expand Up @@ -207,12 +206,12 @@ async fn test_native_transfer_insufficient_gas_execution() {

assert_eq!(
effects.status.unwrap_err(),
ExecutionErrorKind::InsufficientGas,
ExecutionFailureStatus::InsufficientGas,
);
}

#[tokio::test]
async fn test_publish_gas() -> SuiResult {
async fn test_publish_gas() -> anyhow::Result<()> {
let (sender, sender_key) = get_key_pair();
let gas_object_id = ObjectID::random();
let authority_state = init_state_with_ids(vec![(sender, gas_object_id)]).await;
Expand Down Expand Up @@ -296,7 +295,7 @@ async fn test_publish_gas() -> SuiResult {
let gas_cost = effects.gas_used;
let err = effects.status.unwrap_err();

assert_eq!(err, ExecutionErrorKind::InsufficientGas);
assert_eq!(err, ExecutionFailureStatus::InsufficientGas);

// Make sure that we are not charging storage cost at failure.
assert_eq!(gas_cost.storage_cost, 0);
Expand Down Expand Up @@ -326,7 +325,7 @@ async fn test_publish_gas() -> SuiResult {
let effects = response.signed_effects.unwrap().effects;
let gas_cost = effects.gas_used;
let err = effects.status.unwrap_err();
assert_eq!(err, ExecutionErrorKind::InsufficientGas,);
assert_eq!(err, ExecutionFailureStatus::InsufficientGas);
assert_eq!(gas_cost.storage_cost, 0);
assert_eq!(gas_cost.storage_rebate, 0);
Ok(())
Expand Down Expand Up @@ -449,7 +448,7 @@ async fn test_move_call_gas() -> SuiResult {
let gas_cost = effects.gas_used;
let err = effects.status.unwrap_err();
// We will run out of gas during VM execution.
assert!(matches!(err, ExecutionErrorKind::VmError));
assert!(matches!(err, ExecutionFailureStatus::InsufficientGas));
let gas_object = authority_state.get_object(&gas_object_id).await?.unwrap();
let expected_gas_balance = expected_gas_balance - gas_cost.gas_used() + gas_cost.storage_rebate;
assert_eq!(
Expand Down
3 changes: 1 addition & 2 deletions crates/sui-core/src/unit_tests/move_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use move_package::BuildConfig;
use sui_types::{
crypto::KeyPair,
crypto::{get_key_pair, Signature},
error::ExecutionErrorKind,
event::{Event, EventType, TransferType},
messages::ExecutionStatus,
object::OBJECT_START_VERSION,
Expand Down Expand Up @@ -405,7 +404,7 @@ async fn test_object_owning_another_object() {
// we expect this to be and error due to Deleting an Object Owned Object
assert!(matches!(
effects.status.unwrap_err(),
ExecutionErrorKind::DeleteObjectOwnedObject
ExecutionFailureStatus::MiscellaneousError,
));

// Remove the child from the parent.
Expand Down
59 changes: 21 additions & 38 deletions crates/sui-core/tests/staged/sui.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
AbortLocation:
ENUM:
0:
Module:
NEWTYPE:
TYPENAME: ModuleId
1:
Script: UNIT
AccountAddress:
NEWTYPESTRUCT:
TUPLEARRAY:
Expand Down Expand Up @@ -61,48 +69,17 @@ ExecutionDigests:
TYPENAME: TransactionDigest
- effects:
TYPENAME: TransactionEffectsDigest
ExecutionErrorKind:
ExecutionFailureStatus:
ENUM:
0:
InsufficientGas: UNIT
1:
TransferUnowned: UNIT
MoveAbort:
TUPLE:
- TYPENAME: AbortLocation
- U64
2:
TransferNonCoin: UNIT
3:
TransferInsufficientBalance: UNIT
4:
InvalidTransactionUpdate: UNIT
5:
ObjectNotFound: UNIT
6:
DeleteObjectOwnedObject: UNIT
7:
FunctionNotFound: UNIT
8:
ModuleNotFound: UNIT
9:
InvalidFunctionSignature: UNIT
10:
InvalidFunctionVisibility: UNIT
11:
InvalidNonEntryFunction: UNIT
12:
ExecutionInvariantViolation: UNIT
13:
TypeError: UNIT
14:
CircularObjectOwnership: UNIT
15:
MissingObjectOwner: UNIT
16:
InvalidSharedChildUse: UNIT
17:
ModulePublishFailure: UNIT
18:
ModuleVerificationFailure: UNIT
19:
VmError: UNIT
MiscellaneousError: UNIT
ExecutionStatus:
ENUM:
0:
Expand All @@ -111,9 +88,15 @@ ExecutionStatus:
Failure:
STRUCT:
- error:
TYPENAME: ExecutionErrorKind
TYPENAME: ExecutionFailureStatus
Identifier:
NEWTYPESTRUCT: STR
ModuleId:
STRUCT:
- address:
TYPENAME: AccountAddress
- name:
TYPENAME: Identifier
MoveCall:
STRUCT:
- package:
Expand Down
10 changes: 2 additions & 8 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! This module contains the transactional test runner instantiation for the Sui adapter
use crate::{args::*, in_memory_storage::InMemoryStorage};
use anyhow::{anyhow, bail};
use anyhow::bail;
use bimap::btree::BiBTreeMap;
use move_binary_format::{file_format::CompiledScript, CompiledModule};
use move_bytecode_utils::module_cache::GetModule;
Expand Down Expand Up @@ -46,7 +46,6 @@ use sui_types::{
SUI_ADDRESS_LENGTH,
},
crypto::{get_key_pair_from_rng, KeyPair, Signature},
error::SuiError,
event::Event,
gas,
messages::{ExecutionStatus, Transaction, TransactionData, TransactionEffects},
Expand Down Expand Up @@ -505,7 +504,7 @@ impl<'a> SuiTestAdapter<'a> {
deleted: deleted_ids,
events,
}),
ExecutionStatus::Failure { error, .. } => Err(self.render_sui_error(error.into())),
ExecutionStatus::Failure { error, .. } => Err(error.into()),
}
}

Expand Down Expand Up @@ -600,11 +599,6 @@ impl<'a> SuiTestAdapter<'a> {
.join(", ")
}

fn render_sui_error(&self, sui_error: SuiError) -> anyhow::Error {
let error_string: String = format!("{}", sui_error);
anyhow!(self.stabilize_str(&error_string))
}

fn stabilize_str(&self, input: impl AsRef<str>) -> String {
fn candidate_is_hex(s: &str) -> bool {
const HEX_STR_LENGTH: usize = SUI_ADDRESS_LENGTH * 2;
Expand Down
Loading

0 comments on commit 72d9024

Please sign in to comment.