Skip to main content

sui_verifier_latest/
lib.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4pub mod verifier;
5
6pub mod entry_points_verifier;
7pub mod global_storage_access_verifier;
8pub mod id_leak_verifier;
9pub mod meter;
10pub mod one_time_witness_verifier;
11pub mod private_generics;
12pub mod private_generics_verifier_v2;
13pub mod struct_with_key_verifier;
14pub mod tx_context_restrictions_verifier;
15
16use move_core_types::{
17    account_address::AccountAddress, ident_str, identifier::IdentStr, vm_status::StatusCode,
18};
19use sui_types::error::ExecutionError;
20use sui_types::execution_status::ExecutionErrorKind;
21
22pub const INIT_FN_NAME: &IdentStr = ident_str!("init");
23pub const TEST_SCENARIO_MODULE_NAME: &str = "test_scenario";
24
25pub type FunctionIdent<'a> = (AccountAddress, &'a IdentStr, &'a IdentStr);
26
27fn verification_failure(error: String) -> ExecutionError {
28    ExecutionError::new_with_source(ExecutionErrorKind::SuiMoveVerificationError, error)
29}
30
31fn to_verification_timeout_error(error: String) -> ExecutionError {
32    ExecutionError::new_with_source(ExecutionErrorKind::SuiMoveVerificationTimedout, error)
33}
34
35/// Runs the Move verifier and checks if the error counts as a Move verifier timeout
36/// NOTE: this function only check if the verifier error is a timeout
37/// All other errors are ignored
38pub fn check_for_verifier_timeout(major_status_code: &StatusCode) -> bool {
39    [
40        StatusCode::PROGRAM_TOO_COMPLEX,
41        // Do we want to make this a substatus of `PROGRAM_TOO_COMPLEX`?
42        StatusCode::TOO_MANY_BACK_EDGES,
43        StatusCode::BORROWLOC_EXISTS_BORROW_ERROR,
44        StatusCode::COPYLOC_EXISTS_BORROW_ERROR,
45        StatusCode::DEPRECATED_BYTECODE_FORMAT,
46        StatusCode::REFERENCE_SAFETY_INCONSISTENT,
47        StatusCode::VEC_BORROW_ELEMENT_EXISTS_MUTABLE_BORROW_ERROR,
48        StatusCode::CALL_BORROWED_MUTABLE_REFERENCE_ERROR,
49    ]
50    .contains(major_status_code)
51}