diff --git a/clarity/src/libclarity.rs b/clarity/src/libclarity.rs index daae7dcfd7..7ce2a4f903 100644 --- a/clarity/src/libclarity.rs +++ b/clarity/src/libclarity.rs @@ -14,20 +14,19 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#![allow(unused_imports)] #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![cfg_attr(test, allow(unused_variables, unused_assignments))] +#[allow(unused_imports)] #[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)] extern crate slog; #[macro_use] extern crate serde_derive; -#[macro_use] extern crate serde_json; #[cfg(any(test, feature = "testing"))] diff --git a/clarity/src/vm/analysis/analysis_db.rs b/clarity/src/vm/analysis/analysis_db.rs index 36e1f8c970..dda74dd5c0 100644 --- a/clarity/src/vm/analysis/analysis_db.rs +++ b/clarity/src/vm/analysis/analysis_db.rs @@ -18,14 +18,14 @@ use std::collections::{BTreeMap, BTreeSet}; use stacks_common::types::StacksEpochId; -use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; +use crate::vm::analysis::errors::{CheckErrors, CheckResult}; use crate::vm::analysis::type_checker::ContractAnalysis; use crate::vm::database::{ ClarityBackingStore, ClarityDeserializable, ClaritySerializable, RollbackWrapper, }; use crate::vm::representations::ClarityName; use crate::vm::types::signatures::FunctionSignature; -use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier, TypeSignature}; +use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier}; use crate::vm::ClarityVersion; pub struct AnalysisDatabase<'a> { diff --git a/clarity/src/vm/analysis/arithmetic_checker/mod.rs b/clarity/src/vm/analysis/arithmetic_checker/mod.rs index 429907b4c6..e0f774d9be 100644 --- a/clarity/src/vm/analysis/arithmetic_checker/mod.rs +++ b/clarity/src/vm/analysis/arithmetic_checker/mod.rs @@ -14,22 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use hashbrown::HashMap; - pub use super::errors::{ check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult, }; -use super::AnalysisDatabase; -use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis}; +use crate::vm::analysis::types::ContractAnalysis; use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed}; -use crate::vm::functions::{tuples, NativeFunctions}; +use crate::vm::functions::NativeFunctions; use crate::vm::representations::SymbolicExpressionType::{ Atom, AtomValue, Field, List, LiteralValue, TraitReference, }; -use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::{ - parse_name_type_pairs, PrincipalData, TupleTypeSignature, TypeSignature, Value, -}; +use crate::vm::representations::{ClarityName, SymbolicExpression}; use crate::vm::variables::NativeVariables; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/analysis/read_only_checker/mod.rs b/clarity/src/vm/analysis/read_only_checker/mod.rs index f60ce11a44..a244bf7101 100644 --- a/clarity/src/vm/analysis/read_only_checker/mod.rs +++ b/clarity/src/vm/analysis/read_only_checker/mod.rs @@ -23,15 +23,12 @@ pub use super::errors::{ use super::AnalysisDatabase; use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis}; use crate::vm::functions::define::DefineFunctionsParsed; -use crate::vm::functions::{tuples, NativeFunctions}; +use crate::vm::functions::NativeFunctions; use crate::vm::representations::SymbolicExpressionType::{ Atom, AtomValue, Field, List, LiteralValue, TraitReference, }; use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::{ - parse_name_type_pairs, PrincipalData, TupleTypeSignature, TypeSignature, Value, -}; -use crate::vm::variables::NativeVariables; +use crate::vm::types::{PrincipalData, Value}; use crate::vm::ClarityVersion; #[cfg(test)] diff --git a/clarity/src/vm/analysis/read_only_checker/tests.rs b/clarity/src/vm/analysis/read_only_checker/tests.rs index 828e5d42bc..1f0d17117b 100644 --- a/clarity/src/vm/analysis/read_only_checker/tests.rs +++ b/clarity/src/vm/analysis/read_only_checker/tests.rs @@ -21,7 +21,7 @@ use rstest_reuse::{self, *}; use stacks_common::types::StacksEpochId; use crate::vm::analysis::type_checker::v2_1::tests::mem_type_check; -use crate::vm::analysis::{type_check, CheckError, CheckErrors}; +use crate::vm::analysis::{type_check, CheckErrors}; use crate::vm::ast::parse; use crate::vm::database::MemoryBackingStore; use crate::vm::tests::test_clarity_versions; diff --git a/clarity/src/vm/analysis/tests/mod.rs b/clarity/src/vm/analysis/tests/mod.rs index 2484ee86cd..01d5e98136 100644 --- a/clarity/src/vm/analysis/tests/mod.rs +++ b/clarity/src/vm/analysis/tests/mod.rs @@ -16,12 +16,8 @@ use stacks_common::types::StacksEpochId; -use crate::vm::analysis::errors::CheckErrors; +use crate::vm::analysis::mem_type_check as mem_run_analysis; use crate::vm::analysis::type_checker::v2_1::tests::mem_type_check; -use crate::vm::analysis::{ - mem_type_check as mem_run_analysis, type_check, AnalysisDatabase, ContractAnalysis, -}; -use crate::vm::ast::parse; use crate::vm::ClarityVersion; #[test] diff --git a/clarity/src/vm/analysis/trait_checker/mod.rs b/clarity/src/vm/analysis/trait_checker/mod.rs index 868c1d378e..87a31a9867 100644 --- a/clarity/src/vm/analysis/trait_checker/mod.rs +++ b/clarity/src/vm/analysis/trait_checker/mod.rs @@ -14,17 +14,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use hashbrown::HashMap; use stacks_common::types::StacksEpochId; -use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; +use crate::vm::analysis::errors::{CheckErrors, CheckResult}; use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis}; use crate::vm::analysis::AnalysisDatabase; -use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed}; -use crate::vm::functions::NativeFunctions; -use crate::vm::representations::SymbolicExpressionType::{Atom, AtomValue, List, LiteralValue}; -use crate::vm::representations::{ClarityName, SymbolicExpression}; -use crate::vm::types::{FunctionType, TraitIdentifier, TypeSignature, Value}; pub struct TraitChecker { epoch: StacksEpochId, diff --git a/clarity/src/vm/analysis/trait_checker/tests.rs b/clarity/src/vm/analysis/trait_checker/tests.rs index b1d9bdb222..ab997afc58 100644 --- a/clarity/src/vm/analysis/trait_checker/tests.rs +++ b/clarity/src/vm/analysis/trait_checker/tests.rs @@ -20,9 +20,8 @@ use rstest::rstest; use rstest_reuse::{self, *}; use stacks_common::types::StacksEpochId; -use crate::vm::analysis::contract_interface_builder::build_contract_interface; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::{type_check, AnalysisDatabase, CheckError}; +use crate::vm::analysis::{type_check, CheckError}; use crate::vm::ast::errors::ParseErrors; use crate::vm::ast::{build_ast, parse}; use crate::vm::database::MemoryBackingStore; diff --git a/clarity/src/vm/analysis/type_checker/mod.rs b/clarity/src/vm/analysis/type_checker/mod.rs index 36aa2519cc..68bbe1873e 100644 --- a/clarity/src/vm/analysis/type_checker/mod.rs +++ b/clarity/src/vm/analysis/type_checker/mod.rs @@ -20,19 +20,11 @@ pub mod v2_1; use stacks_common::types::StacksEpochId; -use super::errors::{ - check_argument_count, check_arguments_at_least, check_arguments_at_most, CheckError, - CheckErrors, CheckResult, -}; +use super::errors::{CheckErrors, CheckResult}; pub use super::types::{AnalysisPass, ContractAnalysis}; use super::AnalysisDatabase; -use crate::vm::costs::{analysis_typecheck_cost, CostTracker, LimitedCostTracker}; -use crate::vm::types::signatures::{ - CallableSubtype, FunctionArgSignature, FunctionReturnsSignature, -}; -use crate::vm::types::{ - FixedFunction, FunctionType, PrincipalData, SequenceSubtype, StringSubtype, TypeSignature, -}; +use crate::vm::costs::CostTracker; +use crate::vm::types::{FunctionType, TypeSignature}; use crate::vm::{ClarityVersion, Value}; impl FunctionType { diff --git a/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs b/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs index 2a11f6839f..f765878254 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/contexts.rs @@ -20,8 +20,7 @@ use hashbrown::{HashMap, HashSet}; use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; use crate::vm::analysis::types::ContractAnalysis; -use crate::vm::contexts::MAX_CONTEXT_DEPTH; -use crate::vm::representations::{ClarityName, SymbolicExpression}; +use crate::vm::representations::ClarityName; use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{FunctionType, TraitIdentifier, TypeSignature}; diff --git a/clarity/src/vm/analysis/type_checker/v2_05/mod.rs b/clarity/src/vm/analysis/type_checker/v2_05/mod.rs index 77083b88cf..82e1e50490 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/mod.rs @@ -20,34 +20,31 @@ pub mod natives; use std::collections::BTreeMap; -use hashbrown::HashMap; use stacks_common::types::StacksEpochId; use self::contexts::ContractContext; pub use self::natives::{SimpleNativeFunction, TypedNativeFunction}; use super::contexts::{TypeMap, TypingContext}; -use super::{AnalysisPass, ContractAnalysis}; +use super::ContractAnalysis; pub use crate::vm::analysis::errors::{ check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult, }; use crate::vm::analysis::AnalysisDatabase; -use crate::vm::contexts::Environment; use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::costs::{ - analysis_typecheck_cost, cost_functions, runtime_cost, ClarityCostFunctionReference, - CostErrors, CostOverflowingMath, CostTracker, ExecutionCost, LimitedCostTracker, + analysis_typecheck_cost, runtime_cost, CostErrors, CostOverflowingMath, CostTracker, + ExecutionCost, LimitedCostTracker, }; -use crate::vm::errors::InterpreterError; use crate::vm::functions::define::DefineFunctionsParsed; use crate::vm::functions::NativeFunctions; use crate::vm::representations::SymbolicExpressionType::{ Atom, AtomValue, Field, List, LiteralValue, TraitReference, }; use crate::vm::representations::{depth_traverse, ClarityName, SymbolicExpression}; -use crate::vm::types::signatures::{FunctionSignature, BUFF_20}; +use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{ parse_name_type_pairs, FixedFunction, FunctionArg, FunctionType, PrincipalData, - QualifiedContractIdentifier, TupleTypeSignature, TypeSignature, Value, + QualifiedContractIdentifier, TypeSignature, Value, }; use crate::vm::variables::NativeVariables; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/analysis/type_checker/v2_05/natives/assets.rs b/clarity/src/vm/analysis/type_checker/v2_05/natives/assets.rs index dfd55e2df2..ad066938ce 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/natives/assets.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/natives/assets.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use super::{no_type, FunctionType, TypeChecker, TypeResult, TypingContext}; -use crate::vm::analysis::errors::{check_argument_count, CheckError, CheckErrors, CheckResult}; +use super::{TypeChecker, TypeResult, TypingContext}; +use crate::vm::analysis::errors::{check_argument_count, CheckErrors}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost}; +use crate::vm::costs::runtime_cost; use crate::vm::representations::SymbolicExpression; -use crate::vm::types::{BlockInfoProperty, TupleTypeSignature, TypeSignature, MAX_VALUE_SIZE}; +use crate::vm::types::TypeSignature; pub fn check_special_get_owner( checker: &mut TypeChecker, diff --git a/clarity/src/vm/analysis/type_checker/v2_05/natives/maps.rs b/clarity/src/vm/analysis/type_checker/v2_05/natives/maps.rs index 497a01da2b..b8d36b2f82 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/natives/maps.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/natives/maps.rs @@ -16,16 +16,13 @@ use stacks_common::types::StacksEpochId; -use super::check_special_tuple_cons; use crate::vm::analysis::type_checker::v2_05::{ - check_arguments_at_least, no_type, CheckError, CheckErrors, TypeChecker, TypeResult, - TypingContext, + check_arguments_at_least, CheckError, CheckErrors, TypeChecker, TypeResult, TypingContext, }; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost}; -use crate::vm::functions::tuples; -use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::{PrincipalData, TypeSignature, Value}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost}; +use crate::vm::representations::SymbolicExpression; +use crate::vm::types::TypeSignature; pub fn check_special_fetch_entry( checker: &mut TypeChecker, diff --git a/clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs b/clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs index 3c5ab99029..11dbd2d04c 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs @@ -19,17 +19,13 @@ use stacks_common::types::StacksEpochId; use super::{ check_argument_count, check_arguments_at_least, no_type, TypeChecker, TypeResult, TypingContext, }; -use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; +use crate::vm::analysis::errors::{CheckError, CheckErrors}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - analysis_typecheck_cost, cost_functions, runtime_cost, CostOverflowingMath, -}; -use crate::vm::errors::{Error as InterpError, InterpreterError, RuntimeErrorType}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost}; use crate::vm::functions::{handle_binding_list, NativeFunctions}; use crate::vm::types::{ BlockInfoProperty, FixedFunction, FunctionArg, FunctionSignature, FunctionType, PrincipalData, TupleTypeSignature, TypeSignature, Value, BUFF_20, BUFF_32, BUFF_33, BUFF_64, BUFF_65, - MAX_VALUE_SIZE, }; use crate::vm::{ClarityName, ClarityVersion, SymbolicExpression, SymbolicExpressionType}; diff --git a/clarity/src/vm/analysis/type_checker/v2_05/natives/options.rs b/clarity/src/vm/analysis/type_checker/v2_05/natives/options.rs index b04f38b44f..55469262df 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/natives/options.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/natives/options.rs @@ -17,11 +17,11 @@ use stacks_common::types::StacksEpochId; use crate::vm::analysis::type_checker::v2_05::{ - check_argument_count, check_arguments_at_least, no_type, CheckError, CheckErrors, TypeChecker, - TypeResult, TypingContext, + check_argument_count, check_arguments_at_least, no_type, CheckErrors, TypeChecker, TypeResult, + TypingContext, }; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost}; use crate::vm::representations::{ClarityName, SymbolicExpression}; use crate::vm::types::TypeSignature; diff --git a/clarity/src/vm/analysis/type_checker/v2_05/natives/sequences.rs b/clarity/src/vm/analysis/type_checker/v2_05/natives/sequences.rs index bed885d147..e1bdb8cbbd 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/natives/sequences.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/natives/sequences.rs @@ -18,17 +18,17 @@ use stacks_common::types::StacksEpochId; use super::{SimpleNativeFunction, TypedNativeFunction}; use crate::vm::analysis::type_checker::v2_05::{ - check_argument_count, check_arguments_at_least, no_type, CheckErrors, CheckResult, TypeChecker, + check_argument_count, check_arguments_at_least, CheckErrors, CheckResult, TypeChecker, TypeResult, TypingContext, }; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost}; use crate::vm::functions::NativeFunctions; use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; pub use crate::vm::types::signatures::{BufferLength, ListTypeData, StringUTF8Length, BUFF_1}; use crate::vm::types::SequenceSubtype::*; use crate::vm::types::StringSubtype::*; -use crate::vm::types::{FunctionType, TypeSignature, Value, MAX_VALUE_SIZE}; +use crate::vm::types::{FunctionType, TypeSignature, Value}; use crate::vm::ClarityVersion; fn get_simple_native_or_user_define( diff --git a/clarity/src/vm/analysis/type_checker/v2_05/tests/assets.rs b/clarity/src/vm/analysis/type_checker/v2_05/tests/assets.rs index 5cfc9ab992..badfba6245 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/tests/assets.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/tests/assets.rs @@ -17,7 +17,6 @@ use stacks_common::types::StacksEpochId; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::AnalysisDatabase; use crate::vm::ast::parse; use crate::vm::database::MemoryBackingStore; use crate::vm::tooling::mem_type_check; @@ -151,8 +150,6 @@ fn test_names_tokens_contracts() { #[test] fn test_bad_asset_usage() { - use crate::vm::analysis::type_check; - let bad_scripts = [ "(ft-get-balance stackoos tx-sender)", "(ft-get-balance u1234 tx-sender)", diff --git a/clarity/src/vm/analysis/type_checker/v2_05/tests/contracts.rs b/clarity/src/vm/analysis/type_checker/v2_05/tests/contracts.rs index bc005e9d30..0eec9c1d67 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/tests/contracts.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/tests/contracts.rs @@ -20,14 +20,11 @@ use {assert_json_diff, serde_json}; use crate::vm::analysis::contract_interface_builder::build_contract_interface; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::{ - mem_type_check, type_check, AnalysisDatabase, CheckError, ContractAnalysis, -}; +use crate::vm::analysis::{mem_type_check, type_check}; use crate::vm::ast::parse; -use crate::vm::costs::LimitedCostTracker; use crate::vm::database::MemoryBackingStore; use crate::vm::types::QualifiedContractIdentifier; -use crate::vm::{ClarityVersion, SymbolicExpression}; +use crate::vm::ClarityVersion; const SIMPLE_TOKENS: &str = "(define-map tokens { account: principal } { balance: uint }) (define-read-only (my-get-token-balance (account principal)) @@ -603,7 +600,6 @@ fn test_same_function_name() { #[test] fn test_expects() { - use crate::vm::analysis::type_check; let okay = "(define-map tokens { id: int } { balance: int }) (define-private (my-get-token-balance) (let ((balance (unwrap! diff --git a/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs b/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs index 1830caf7ce..c314fa319d 100644 --- a/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs @@ -17,20 +17,15 @@ use stacks_common::types::StacksEpochId; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::type_checker::v2_05::{TypeChecker, TypeResult, TypingContext}; -use crate::vm::analysis::types::ContractAnalysis; -use crate::vm::analysis::{mem_type_check, type_check, AnalysisDatabase}; +use crate::vm::analysis::mem_type_check; +use crate::vm::analysis::type_checker::v2_05::TypeResult; +use crate::vm::ast::build_ast; use crate::vm::ast::errors::ParseErrors; -use crate::vm::ast::{build_ast, parse}; -use crate::vm::contexts::OwnedEnvironment; -use crate::vm::database::MemoryBackingStore; -use crate::vm::representations::SymbolicExpression; use crate::vm::types::SequenceSubtype::*; use crate::vm::types::StringSubtype::*; -use crate::vm::types::TypeSignature::{BoolType, IntType, PrincipalType, SequenceType, UIntType}; +use crate::vm::types::TypeSignature::{BoolType, IntType, PrincipalType, UIntType}; use crate::vm::types::{ - FixedFunction, FunctionType, PrincipalData, QualifiedContractIdentifier, TypeSignature, Value, - BUFF_32, BUFF_64, + FixedFunction, FunctionType, QualifiedContractIdentifier, TypeSignature, BUFF_32, BUFF_64, }; use crate::vm::ClarityVersion; @@ -1437,8 +1432,6 @@ fn test_response_inference() { #[test] fn test_function_arg_names() { - use crate::vm::analysis::type_check; - let functions = [ "(define-private (test (x int)) (ok 0)) (define-public (test-pub (x int)) (ok 0)) diff --git a/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs b/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs index d210194ea4..8ac9ee8254 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/contexts.rs @@ -21,9 +21,8 @@ use hashbrown::{HashMap, HashSet}; use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; use crate::vm::analysis::type_checker::is_reserved_word; use crate::vm::analysis::types::ContractAnalysis; -use crate::vm::contexts::MAX_CONTEXT_DEPTH; -use crate::vm::representations::{ClarityName, SymbolicExpression}; -use crate::vm::types::signatures::{CallableSubtype, FunctionSignature}; +use crate::vm::representations::ClarityName; +use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier, TypeSignature}; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/analysis/type_checker/v2_1/mod.rs b/clarity/src/vm/analysis/type_checker/v2_1/mod.rs index 7899b3e27d..17ee17f615 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/mod.rs @@ -19,23 +19,21 @@ pub mod natives; use std::collections::BTreeMap; -use hashbrown::HashMap; use stacks_common::types::StacksEpochId; use self::contexts::ContractContext; pub use self::natives::{SimpleNativeFunction, TypedNativeFunction}; use super::contexts::{TypeMap, TypingContext}; -use super::{AnalysisPass, ContractAnalysis}; +use super::ContractAnalysis; pub use crate::vm::analysis::errors::{ check_argument_count, check_arguments_at_least, check_arguments_at_most, CheckError, CheckErrors, CheckResult, }; use crate::vm::analysis::AnalysisDatabase; -use crate::vm::contexts::Environment; use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::costs::{ - analysis_typecheck_cost, cost_functions, runtime_cost, ClarityCostFunctionReference, - CostErrors, CostOverflowingMath, CostTracker, ExecutionCost, LimitedCostTracker, + analysis_typecheck_cost, runtime_cost, CostErrors, CostOverflowingMath, CostTracker, + ExecutionCost, LimitedCostTracker, }; use crate::vm::diagnostic::Diagnostic; use crate::vm::functions::define::DefineFunctionsParsed; @@ -45,13 +43,13 @@ use crate::vm::representations::SymbolicExpressionType::{ }; use crate::vm::representations::{depth_traverse, ClarityName, SymbolicExpression}; use crate::vm::types::signatures::{ - CallableSubtype, FunctionArgSignature, FunctionReturnsSignature, FunctionSignature, BUFF_20, + CallableSubtype, FunctionArgSignature, FunctionReturnsSignature, FunctionSignature, }; use crate::vm::types::{ - parse_name_type_pairs, CallableData, FixedFunction, FunctionArg, FunctionType, ListData, - ListTypeData, OptionalData, PrincipalData, QualifiedContractIdentifier, ResponseData, - SequenceData, SequenceSubtype, StringSubtype, TraitIdentifier, TupleData, TupleTypeSignature, - TypeSignature, Value, MAX_TYPE_DEPTH, + parse_name_type_pairs, FixedFunction, FunctionArg, FunctionType, ListData, ListTypeData, + OptionalData, PrincipalData, QualifiedContractIdentifier, ResponseData, SequenceData, + SequenceSubtype, StringSubtype, TraitIdentifier, TupleData, TupleTypeSignature, TypeSignature, + Value, MAX_TYPE_DEPTH, }; use crate::vm::variables::NativeVariables; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/analysis/type_checker/v2_1/natives/assets.rs b/clarity/src/vm/analysis/type_checker/v2_1/natives/assets.rs index d94e0fad56..f91c64e1c0 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/natives/assets.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/natives/assets.rs @@ -16,15 +16,12 @@ use stacks_common::consts::TOKEN_TRANSFER_MEMO_LENGTH; -use super::{no_type, FunctionType, TypeChecker, TypeResult, TypingContext}; -use crate::vm::analysis::errors::{check_argument_count, CheckError, CheckErrors, CheckResult}; +use super::{TypeChecker, TypeResult, TypingContext}; +use crate::vm::analysis::errors::{check_argument_count, CheckErrors}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost}; +use crate::vm::costs::runtime_cost; use crate::vm::representations::SymbolicExpression; -use crate::vm::types::{ - BlockInfoProperty, BufferLength, SequenceSubtype, TupleTypeSignature, TypeSignature, - MAX_VALUE_SIZE, -}; +use crate::vm::types::{BufferLength, SequenceSubtype, TypeSignature}; pub fn check_special_get_owner( checker: &mut TypeChecker, diff --git a/clarity/src/vm/analysis/type_checker/v2_1/natives/maps.rs b/clarity/src/vm/analysis/type_checker/v2_1/natives/maps.rs index 7ce4cfad22..676badd14f 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/natives/maps.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/natives/maps.rs @@ -16,15 +16,13 @@ use stacks_common::types::StacksEpochId; -use super::check_special_tuple_cons; use crate::vm::analysis::type_checker::v2_1::{ check_arguments_at_least, CheckError, CheckErrors, TypeChecker, TypeResult, TypingContext, }; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost}; -use crate::vm::functions::tuples; -use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::{PrincipalData, TypeSignature, Value}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost}; +use crate::vm::representations::SymbolicExpression; +use crate::vm::types::TypeSignature; pub fn check_special_fetch_entry( checker: &mut TypeChecker, diff --git a/clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs b/clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs index 7769652d25..6b807ed1da 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs @@ -20,19 +20,14 @@ use super::{ check_argument_count, check_arguments_at_least, check_arguments_at_most, compute_typecheck_cost, no_type, TypeChecker, TypeResult, TypingContext, }; -use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult}; +use crate::vm::analysis::errors::{CheckError, CheckErrors}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - analysis_typecheck_cost, cost_functions, runtime_cost, CostErrors, CostOverflowingMath, - CostTracker, -}; -use crate::vm::errors::{Error as InterpError, RuntimeErrorType}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost, CostErrors, CostTracker}; use crate::vm::functions::{handle_binding_list, NativeFunctions}; use crate::vm::types::signatures::{ CallableSubtype, FunctionArgSignature, FunctionReturnsSignature, SequenceSubtype, ASCII_40, UTF8_40, }; -use crate::vm::types::TypeSignature::SequenceType; use crate::vm::types::{ BlockInfoProperty, BufferLength, BurnBlockInfoProperty, FixedFunction, FunctionArg, FunctionSignature, FunctionType, PrincipalData, StacksBlockInfoProperty, TenureInfoProperty, diff --git a/clarity/src/vm/analysis/type_checker/v2_1/natives/options.rs b/clarity/src/vm/analysis/type_checker/v2_1/natives/options.rs index 772bdd32a4..0e12f802d2 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/natives/options.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/natives/options.rs @@ -17,18 +17,13 @@ use stacks_common::types::StacksEpochId; use super::{ - check_argument_count, check_arguments_at_least, no_type, CheckError, CheckErrors, TypeChecker, - TypeResult, + check_argument_count, check_arguments_at_least, no_type, CheckErrors, TypeChecker, TypeResult, }; use crate::vm::analysis::type_checker::contexts::TypingContext; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - analysis_typecheck_cost, cost_functions, runtime_cost, CostErrors, CostTracker, -}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost, CostErrors, CostTracker}; use crate::vm::representations::{ClarityName, SymbolicExpression}; -use crate::vm::types::signatures::CallableSubtype; use crate::vm::types::TypeSignature; -use crate::vm::ClarityVersion; pub fn check_special_okay( checker: &mut TypeChecker, diff --git a/clarity/src/vm/analysis/type_checker/v2_1/natives/sequences.rs b/clarity/src/vm/analysis/type_checker/v2_1/natives/sequences.rs index c1b3aabb17..0207fe49d8 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/natives/sequences.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/natives/sequences.rs @@ -22,15 +22,14 @@ use crate::vm::analysis::type_checker::v2_1::{ TypeResult, TypingContext, }; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost, CostTracker}; +use crate::vm::costs::{analysis_typecheck_cost, runtime_cost, CostTracker}; use crate::vm::diagnostic::Diagnostic; use crate::vm::functions::NativeFunctions; use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; pub use crate::vm::types::signatures::{BufferLength, ListTypeData, StringUTF8Length, BUFF_1}; use crate::vm::types::SequenceSubtype::*; use crate::vm::types::StringSubtype::*; -use crate::vm::types::{FunctionType, TypeSignature, Value, MAX_VALUE_SIZE}; -use crate::vm::ClarityVersion; +use crate::vm::types::{FunctionType, TypeSignature, Value}; fn get_simple_native_or_user_define( function_name: &str, diff --git a/clarity/src/vm/analysis/type_checker/v2_1/tests/assets.rs b/clarity/src/vm/analysis/type_checker/v2_1/tests/assets.rs index ba120575bd..ab06802f27 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/tests/assets.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/tests/assets.rs @@ -22,8 +22,6 @@ use stacks_common::types::StacksEpochId; use super::contracts::type_check; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::type_checker::v2_1::tests::mem_type_check; -use crate::vm::analysis::AnalysisDatabase; use crate::vm::ast::parse; use crate::vm::database::MemoryBackingStore; use crate::vm::tests::test_clarity_versions; diff --git a/clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs b/clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs index b87177062c..838be9e6bb 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs @@ -30,13 +30,10 @@ use crate::vm::analysis::{ use crate::vm::ast::parse; use crate::vm::costs::LimitedCostTracker; use crate::vm::database::MemoryBackingStore; -use crate::vm::errors::Error; use crate::vm::tests::test_clarity_versions; use crate::vm::types::signatures::CallableSubtype; -use crate::vm::types::{ - PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TypeSignature, -}; -use crate::vm::{ClarityVersion, ContractName, SymbolicExpression}; +use crate::vm::types::{QualifiedContractIdentifier, TypeSignature}; +use crate::vm::{ClarityVersion, SymbolicExpression}; fn mem_type_check_v1(snippet: &str) -> CheckResult<(Option, ContractAnalysis)> { mem_run_analysis(snippet, ClarityVersion::Clarity1, StacksEpochId::latest()) @@ -567,7 +564,6 @@ fn test_same_function_name(#[case] version: ClarityVersion, #[case] epoch: Stack #[test] fn test_expects() { - use crate::vm::analysis::type_check; let okay = "(define-map tokens { id: int } { balance: int }) (define-private (my-get-token-balance) (let ((balance (unwrap! diff --git a/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs b/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs index 498b52dcb0..5ce27eabcb 100644 --- a/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs +++ b/clarity/src/vm/analysis/type_checker/v2_1/tests/mod.rs @@ -22,24 +22,20 @@ use stacks_common::types::StacksEpochId; use super::CheckResult; use crate::vm::analysis::errors::CheckErrors; -use crate::vm::analysis::type_checker::v2_1::{TypeChecker, TypeResult, TypingContext}; -use crate::vm::analysis::type_checker::SequenceSubtype; +use crate::vm::analysis::mem_type_check as mem_run_analysis; +use crate::vm::analysis::type_checker::v2_1::TypeResult; use crate::vm::analysis::types::ContractAnalysis; -use crate::vm::analysis::{mem_type_check as mem_run_analysis, AnalysisDatabase}; +use crate::vm::ast::build_ast; use crate::vm::ast::errors::ParseErrors; -use crate::vm::ast::{build_ast, parse}; -use crate::vm::contexts::OwnedEnvironment; -use crate::vm::representations::SymbolicExpression; use crate::vm::tests::test_clarity_versions; use crate::vm::types::signatures::TypeSignature::OptionalType; use crate::vm::types::signatures::{ListTypeData, StringUTF8Length}; use crate::vm::types::SequenceSubtype::*; use crate::vm::types::StringSubtype::*; use crate::vm::types::TypeSignature::{BoolType, IntType, PrincipalType, SequenceType, UIntType}; -use crate::vm::types::Value::Sequence; use crate::vm::types::{ - BufferLength, FixedFunction, FunctionType, PrincipalData, QualifiedContractIdentifier, - TraitIdentifier, TypeSignature, Value, BUFF_1, BUFF_20, BUFF_21, BUFF_32, BUFF_64, + BufferLength, FixedFunction, FunctionType, QualifiedContractIdentifier, TraitIdentifier, + TypeSignature, BUFF_1, BUFF_20, BUFF_21, BUFF_32, BUFF_64, }; use crate::vm::{execute_v2, ClarityName, ClarityVersion}; @@ -2252,8 +2248,6 @@ fn test_response_inference(#[case] version: ClarityVersion, #[case] epoch: Stack #[test] fn test_function_arg_names() { - use crate::vm::analysis::type_check; - let functions = [ "(define-private (test (x int)) (ok 0)) (define-public (test-pub (x int)) (ok 0)) diff --git a/clarity/src/vm/analysis/types.rs b/clarity/src/vm/analysis/types.rs index 60a93f9c79..5085f2bc46 100644 --- a/clarity/src/vm/analysis/types.rs +++ b/clarity/src/vm/analysis/types.rs @@ -16,14 +16,13 @@ use std::collections::{BTreeMap, BTreeSet}; -use hashbrown::HashMap; use stacks_common::types::StacksEpochId; use crate::vm::analysis::analysis_db::AnalysisDatabase; use crate::vm::analysis::contract_interface_builder::ContractInterface; use crate::vm::analysis::errors::{CheckErrors, CheckResult}; use crate::vm::analysis::type_checker::contexts::TypeMap; -use crate::vm::costs::{CostTracker, ExecutionCost, LimitedCostTracker}; +use crate::vm::costs::LimitedCostTracker; use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier, TypeSignature}; use crate::vm::{ClarityName, ClarityVersion, SymbolicExpression}; diff --git a/clarity/src/vm/ast/definition_sorter/mod.rs b/clarity/src/vm/ast/definition_sorter/mod.rs index bd611851b6..2be40271e6 100644 --- a/clarity/src/vm/ast/definition_sorter/mod.rs +++ b/clarity/src/vm/ast/definition_sorter/mod.rs @@ -17,9 +17,9 @@ use hashbrown::{HashMap, HashSet}; use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; -use crate::vm::ast::types::{BuildASTPass, ContractAST}; +use crate::vm::ast::types::ContractAST; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostTracker, LimitedCostTracker}; +use crate::vm::costs::{runtime_cost, CostTracker}; use crate::vm::functions::define::DefineFunctions; use crate::vm::functions::NativeFunctions; use crate::vm::representations::PreSymbolicExpressionType::{ @@ -27,7 +27,6 @@ use crate::vm::representations::PreSymbolicExpressionType::{ SugaredFieldIdentifier, TraitReference, Tuple, }; use crate::vm::representations::{ClarityName, PreSymbolicExpression}; -use crate::vm::types::Value; use crate::vm::ClarityVersion; #[cfg(test)] diff --git a/clarity/src/vm/ast/definition_sorter/tests.rs b/clarity/src/vm/ast/definition_sorter/tests.rs index 2c993db266..0142052c50 100644 --- a/clarity/src/vm/ast/definition_sorter/tests.rs +++ b/clarity/src/vm/ast/definition_sorter/tests.rs @@ -24,7 +24,7 @@ use crate::vm::ast::definition_sorter::DefinitionSorter; use crate::vm::ast::errors::{ParseErrors, ParseResult}; use crate::vm::ast::expression_identifier::ExpressionIdentifier; use crate::vm::ast::parser; -use crate::vm::ast::types::{BuildASTPass, ContractAST}; +use crate::vm::ast::types::ContractAST; use crate::vm::types::QualifiedContractIdentifier; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/ast/errors.rs b/clarity/src/vm/ast/errors.rs index 56f8e40f86..6c668bacc1 100644 --- a/clarity/src/vm/ast/errors.rs +++ b/clarity/src/vm/ast/errors.rs @@ -21,7 +21,6 @@ use crate::vm::ast::parser::v2::lexer::token::Token; use crate::vm::costs::{CostErrors, ExecutionCost}; use crate::vm::diagnostic::{DiagnosableError, Diagnostic, Level}; use crate::vm::representations::{PreSymbolicExpression, Span}; -use crate::vm::types::{TupleTypeSignature, TypeSignature}; use crate::vm::MAX_CALL_STACK_DEPTH; pub type ParseResult = Result; @@ -308,7 +307,6 @@ impl DiagnosableError for ParseErrors { } fn level(&self) -> crate::vm::diagnostic::Level { - use self::ParseErrors::*; match self { ParseErrors::NoteToMatchThis(_) => Level::Note, ParseErrors::Lexer(lexerError) => lexerError.level(), diff --git a/clarity/src/vm/ast/expression_identifier/mod.rs b/clarity/src/vm/ast/expression_identifier/mod.rs index b8a39362ae..13b9aac2bd 100644 --- a/clarity/src/vm/ast/expression_identifier/mod.rs +++ b/clarity/src/vm/ast/expression_identifier/mod.rs @@ -15,8 +15,7 @@ // along with this program. If not, see . use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; -use crate::vm::ast::types::{BuildASTPass, ContractAST}; -use crate::vm::representations::PreSymbolicExpressionType::List; +use crate::vm::ast::types::ContractAST; use crate::vm::representations::SymbolicExpressionCommon; use crate::vm::ClarityVersion; diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index 5c615f46fa..263fc86526 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -36,10 +36,9 @@ use self::traits_resolver::TraitsResolver; use self::types::BuildASTPass; pub use self::types::ContractAST; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostTracker, LimitedCostTracker}; +use crate::vm::costs::{runtime_cost, CostTracker}; use crate::vm::diagnostic::{Diagnostic, Level}; -use crate::vm::errors::{Error, RuntimeErrorType}; -use crate::vm::representations::{PreSymbolicExpression, SymbolicExpression}; +use crate::vm::representations::PreSymbolicExpression; use crate::vm::types::QualifiedContractIdentifier; use crate::vm::ClarityVersion; @@ -50,7 +49,7 @@ pub fn parse( source_code: &str, version: ClarityVersion, epoch: StacksEpochId, -) -> Result, Error> { +) -> Result, crate::vm::errors::Error> { let ast = build_ast(contract_identifier, source_code, &mut (), version, epoch)?; Ok(ast.expressions) } diff --git a/clarity/src/vm/ast/parser/v1.rs b/clarity/src/vm/ast/parser/v1.rs index 4cef2e5411..32f0b7001e 100644 --- a/clarity/src/vm/ast/parser/v1.rs +++ b/clarity/src/vm/ast/parser/v1.rs @@ -14,20 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::cmp; - use lazy_static::lazy_static; use regex::{Captures, Regex}; -use stacks_common::address::c32::c32_address_decode; use stacks_common::util::hash::hex_bytes; use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; use crate::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER; -use crate::vm::errors::{InterpreterResult as Result, RuntimeErrorType}; use crate::vm::representations::{ - ClarityName, ContractName, PreSymbolicExpression, PreSymbolicExpressionType, MAX_STRING_LEN, + ClarityName, ContractName, PreSymbolicExpression, MAX_STRING_LEN, }; -use crate::vm::types::{PrincipalData, QualifiedContractIdentifier, TraitIdentifier, Value}; +use crate::vm::types::{PrincipalData, TraitIdentifier, Value}; use crate::vm::MAX_CALL_STACK_DEPTH; pub const CONTRACT_MIN_NAME_LENGTH: usize = 1; @@ -734,12 +730,10 @@ pub fn parse_no_stack_limit(input: &str) -> ParseResult. -use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; +use crate::vm::ast::errors::{ParseErrors, ParseResult}; use crate::vm::ast::types::{BuildASTPass, ContractAST}; use crate::vm::representations::PreSymbolicExpression; use crate::vm::representations::PreSymbolicExpressionType::{List, Tuple}; diff --git a/clarity/src/vm/ast/sugar_expander/mod.rs b/clarity/src/vm/ast/sugar_expander/mod.rs index 670796cf4c..f844f5ec39 100644 --- a/clarity/src/vm/ast/sugar_expander/mod.rs +++ b/clarity/src/vm/ast/sugar_expander/mod.rs @@ -16,14 +16,9 @@ use hashbrown::{HashMap, HashSet}; -use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; +use crate::vm::ast::errors::{ParseErrors, ParseResult}; use crate::vm::ast::types::{BuildASTPass, ContractAST, PreExpressionsDrain}; -use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed}; -use crate::vm::functions::NativeFunctions; -use crate::vm::representations::{ - ClarityName, PreSymbolicExpression, PreSymbolicExpressionType, SymbolicExpression, - SymbolicExpressionType, -}; +use crate::vm::representations::{ClarityName, PreSymbolicExpressionType, SymbolicExpression}; use crate::vm::types::{ PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TraitIdentifier, Value, }; @@ -169,14 +164,11 @@ impl SugarExpander { #[cfg(test)] mod test { - use crate::vm::ast::errors::{ParseError, ParseErrors}; use crate::vm::ast::sugar_expander::SugarExpander; use crate::vm::ast::types::ContractAST; - use crate::vm::representations::{ - ContractName, PreSymbolicExpression, Span, SymbolicExpression, - }; - use crate::vm::types::{PrincipalData, QualifiedContractIdentifier, StandardPrincipalData}; - use crate::vm::{ast, Value}; + use crate::vm::representations::{ContractName, PreSymbolicExpression, SymbolicExpression}; + use crate::vm::types::{PrincipalData, QualifiedContractIdentifier}; + use crate::vm::Value; fn make_pre_atom( x: &str, @@ -565,6 +557,9 @@ mod test { ); } + #[cfg(feature = "developer-mode")] + use crate::vm::representations::Span; + #[test] #[cfg(feature = "developer-mode")] fn test_attach_end_line_comment() { diff --git a/clarity/src/vm/ast/traits_resolver/mod.rs b/clarity/src/vm/ast/traits_resolver/mod.rs index 0bb4ba3186..d84e8cb673 100644 --- a/clarity/src/vm/ast/traits_resolver/mod.rs +++ b/clarity/src/vm/ast/traits_resolver/mod.rs @@ -14,20 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use hashbrown::{HashMap, HashSet}; +use hashbrown::HashMap; -use crate::vm::analysis::AnalysisDatabase; use crate::vm::ast::errors::{ParseError, ParseErrors, ParseResult}; -use crate::vm::ast::types::{BuildASTPass, ContractAST, PreExpressionsDrain}; -use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed}; -use crate::vm::functions::NativeFunctions; +use crate::vm::ast::types::{BuildASTPass, ContractAST}; +use crate::vm::functions::define::DefineFunctions; use crate::vm::representations::PreSymbolicExpressionType::{ - Atom, AtomValue, FieldIdentifier, List, SugaredFieldIdentifier, TraitReference, Tuple, + Atom, FieldIdentifier, List, SugaredFieldIdentifier, TraitReference, Tuple, }; -use crate::vm::representations::{ - ClarityName, PreSymbolicExpression, SymbolicExpression, TraitDefinition, -}; -use crate::vm::types::{QualifiedContractIdentifier, TraitIdentifier, Value}; +use crate::vm::representations::{ClarityName, PreSymbolicExpression, TraitDefinition}; +use crate::vm::types::{QualifiedContractIdentifier, TraitIdentifier}; use crate::vm::ClarityVersion; pub struct TraitsResolver {} diff --git a/clarity/src/vm/ast/types.rs b/clarity/src/vm/ast/types.rs index 2071130131..d969ed855f 100644 --- a/clarity/src/vm/ast/types.rs +++ b/clarity/src/vm/ast/types.rs @@ -20,7 +20,6 @@ use hashbrown::{HashMap, HashSet}; use crate::vm::ast::errors::ParseResult; use crate::vm::representations::{PreSymbolicExpression, SymbolicExpression, TraitDefinition}; -use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{QualifiedContractIdentifier, TraitIdentifier}; use crate::vm::{ClarityName, ClarityVersion}; diff --git a/clarity/src/vm/callables.rs b/clarity/src/vm/callables.rs index 4691025a8d..b7572f070e 100644 --- a/clarity/src/vm/callables.rs +++ b/clarity/src/vm/callables.rs @@ -26,14 +26,12 @@ use super::ClarityVersion; use crate::vm::analysis::errors::CheckErrors; use crate::vm::contexts::ContractContext; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost}; +use crate::vm::costs::runtime_cost; use crate::vm::errors::{check_argument_count, Error, InterpreterResult as Result}; -use crate::vm::representations::{ClarityName, Span, SymbolicExpression}; -use crate::vm::types::Value::UInt; +use crate::vm::representations::{ClarityName, SymbolicExpression}; use crate::vm::types::{ - CallableData, FunctionType, ListData, ListTypeData, OptionalData, PrincipalData, - QualifiedContractIdentifier, ResponseData, SequenceData, SequenceSubtype, TraitIdentifier, - TupleData, TupleTypeSignature, TypeSignature, + CallableData, ListData, ListTypeData, OptionalData, PrincipalData, ResponseData, SequenceData, + SequenceSubtype, TraitIdentifier, TupleData, TypeSignature, }; use crate::vm::{eval, Environment, LocalContext, Value}; @@ -377,7 +375,7 @@ impl DefinedFunction { } #[cfg(feature = "developer-mode")] - pub fn get_span(&self) -> Span { + pub fn get_span(&self) -> crate::vm::representations::Span { self.body.span.clone() } } @@ -512,7 +510,9 @@ fn clarity2_implicit_cast(type_sig: &TypeSignature, value: &Value) -> Result. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use std::fmt; use std::mem::replace; use hashbrown::{HashMap, HashSet}; use serde::Serialize; use serde_json::json; -use stacks_common::consts::CHAIN_ID_TESTNET; use stacks_common::types::chainstate::StacksBlockId; use stacks_common::types::StacksEpochId; @@ -30,10 +29,7 @@ use crate::vm::ast::{ASTRules, ContractAST}; use crate::vm::callables::{DefinedFunction, FunctionIdentifier}; use crate::vm::contracts::Contract; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - cost_functions, runtime_cost, ClarityCostFunctionReference, CostErrors, CostTracker, - ExecutionCost, LimitedCostTracker, -}; +use crate::vm::costs::{runtime_cost, CostErrors, CostTracker, ExecutionCost, LimitedCostTracker}; use crate::vm::database::{ ClarityDatabase, DataMapMetadata, DataVariableMetadata, FungibleTokenMetadata, NonFungibleTokenMetadata, @@ -42,11 +38,11 @@ use crate::vm::errors::{ CheckErrors, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; use crate::vm::events::*; -use crate::vm::representations::{ClarityName, ContractName, SymbolicExpression}; +use crate::vm::representations::{ClarityName, SymbolicExpression}; use crate::vm::types::signatures::FunctionSignature; use crate::vm::types::{ - AssetIdentifier, BuffData, CallableData, OptionalData, PrincipalData, - QualifiedContractIdentifier, TraitIdentifier, TypeSignature, Value, + AssetIdentifier, BuffData, CallableData, PrincipalData, QualifiedContractIdentifier, + TraitIdentifier, TypeSignature, Value, }; use crate::vm::version::ClarityVersion; use crate::vm::{ast, eval, is_reserved, stx_transfer_consolidated}; @@ -496,7 +492,7 @@ impl<'a, 'hooks> OwnedEnvironment<'a, 'hooks> { OwnedEnvironment { context: GlobalContext::new( false, - CHAIN_ID_TESTNET, + stacks_common::consts::CHAIN_ID_TESTNET, database, LimitedCostTracker::new_free(), epoch, @@ -519,7 +515,7 @@ impl<'a, 'hooks> OwnedEnvironment<'a, 'hooks> { OwnedEnvironment { context: GlobalContext::new( false, - CHAIN_ID_TESTNET, + stacks_common::consts::CHAIN_ID_TESTNET, database, LimitedCostTracker::new_free(), epoch, @@ -1974,11 +1970,9 @@ mod test { use super::*; use crate::vm::callables::DefineType; - use crate::vm::tests::{ - test_epochs, tl_env_factory, MemoryEnvironmentGenerator, TopLevelMemoryEnvironmentGenerator, - }; + use crate::vm::tests::{test_epochs, tl_env_factory, TopLevelMemoryEnvironmentGenerator}; use crate::vm::types::signatures::CallableSubtype; - use crate::vm::types::{FixedFunction, FunctionArg, FunctionType, StandardPrincipalData}; + use crate::vm::types::StandardPrincipalData; #[test] fn test_asset_map_abort() { diff --git a/clarity/src/vm/contracts.rs b/clarity/src/vm/contracts.rs index 1982665aee..17493a978f 100644 --- a/clarity/src/vm/contracts.rs +++ b/clarity/src/vm/contracts.rs @@ -17,13 +17,11 @@ use stacks_common::types::StacksEpochId; use crate::vm::ast::ContractAST; -use crate::vm::callables::CallableType; -use crate::vm::contexts::{ContractContext, Environment, GlobalContext, LocalContext}; +use crate::vm::contexts::{ContractContext, GlobalContext}; use crate::vm::errors::InterpreterResult as Result; -use crate::vm::representations::SymbolicExpression; +use crate::vm::eval_all; use crate::vm::types::{PrincipalData, QualifiedContractIdentifier}; use crate::vm::version::ClarityVersion; -use crate::vm::{apply, eval_all, Value}; #[derive(Serialize, Deserialize)] pub struct Contract { diff --git a/clarity/src/vm/costs/mod.rs b/clarity/src/vm/costs/mod.rs index a3c7fa7140..d86cd643bd 100644 --- a/clarity/src/vm/costs/mod.rs +++ b/clarity/src/vm/costs/mod.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::collections::BTreeMap; use std::{cmp, fmt}; use hashbrown::HashMap; @@ -23,20 +22,18 @@ use serde::{Deserialize, Serialize}; use stacks_common::types::StacksEpochId; use crate::boot_util::boot_code_id; -use crate::vm::ast::ContractAST; -use crate::vm::contexts::{ContractContext, Environment, GlobalContext, OwnedEnvironment}; +use crate::vm::contexts::{ContractContext, GlobalContext}; use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::database::clarity_store::NullBackingStore; use crate::vm::database::ClarityDatabase; -use crate::vm::errors::{Error, InterpreterResult}; +use crate::vm::errors::InterpreterResult; use crate::vm::types::signatures::FunctionType::Fixed; -use crate::vm::types::signatures::{FunctionSignature, TupleTypeSignature}; +use crate::vm::types::signatures::TupleTypeSignature; use crate::vm::types::Value::UInt; use crate::vm::types::{ - FunctionArg, FunctionType, PrincipalData, QualifiedContractIdentifier, TupleData, - TypeSignature, NONE, + FunctionType, PrincipalData, QualifiedContractIdentifier, TupleData, TypeSignature, }; -use crate::vm::{ast, eval_all, ClarityName, SymbolicExpression, Value}; +use crate::vm::{eval_all, ClarityName, SymbolicExpression, Value}; pub mod constants; pub mod cost_functions; diff --git a/clarity/src/vm/coverage.rs b/clarity/src/vm/coverage.rs index 862c035f98..4e0d64e62b 100644 --- a/clarity/src/vm/coverage.rs +++ b/clarity/src/vm/coverage.rs @@ -3,7 +3,6 @@ use std::fs::File; use std::io::Write; use hashbrown::{HashMap, HashSet}; -use serde_json::Value as JsonValue; use super::functions::define::DefineFunctionsParsed; use super::EvalHook; diff --git a/clarity/src/vm/database/clarity_db.rs b/clarity/src/vm/database/clarity_db.rs index cbb8bcb4de..38101197f2 100644 --- a/clarity/src/vm/database/clarity_db.rs +++ b/clarity/src/vm/database/clarity_db.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use serde_json; -use stacks_common::address::AddressHashMode; use stacks_common::consts::{ BITCOIN_REGTEST_FIRST_BLOCK_HASH, BITCOIN_REGTEST_FIRST_BLOCK_HEIGHT, BITCOIN_REGTEST_FIRST_BLOCK_TIMESTAMP, FIRST_BURNCHAIN_CONSENSUS_HASH, FIRST_STACKS_BLOCK_HASH, @@ -25,8 +23,8 @@ use stacks_common::types::chainstate::{ BlockHeaderHash, BurnchainHeaderHash, ConsensusHash, SortitionId, StacksAddress, StacksBlockId, TrieHash, VRFSeed, }; -use stacks_common::types::{Address, StacksEpoch as GenericStacksEpoch, StacksEpochId}; -use stacks_common::util::hash::{to_hex, Hash160, Sha256Sum, Sha512Trunc256Sum}; +use stacks_common::types::{StacksEpoch as GenericStacksEpoch, StacksEpochId}; +use stacks_common::util::hash::{to_hex, Hash160, Sha512Trunc256Sum}; use super::clarity_store::SpecialCaseHandler; use super::key_value_wrapper::ValueResult; @@ -35,20 +33,18 @@ use crate::vm::ast::ASTRules; use crate::vm::contracts::Contract; use crate::vm::costs::{CostOverflowingMath, ExecutionCost}; use crate::vm::database::structures::{ - ClarityDeserializable, ClaritySerializable, ContractMetadata, DataMapMetadata, - DataVariableMetadata, FungibleTokenMetadata, NonFungibleTokenMetadata, STXBalance, - STXBalanceSnapshot, SimmedBlock, + ClarityDeserializable, ClaritySerializable, DataMapMetadata, DataVariableMetadata, + FungibleTokenMetadata, NonFungibleTokenMetadata, STXBalance, STXBalanceSnapshot, }; use crate::vm::database::{ClarityBackingStore, RollbackWrapper}; use crate::vm::errors::{ - CheckErrors, Error, IncomparableError, InterpreterError, InterpreterResult as Result, - RuntimeErrorType, + CheckErrors, Error, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; use crate::vm::representations::ClarityName; -use crate::vm::types::serialization::{SerializationError, NONE_SERIALIZATION_LEN}; +use crate::vm::types::serialization::NONE_SERIALIZATION_LEN; use crate::vm::types::{ - byte_len_of_serialization, OptionalData, PrincipalData, QualifiedContractIdentifier, - SequenceData, StandardPrincipalData, TupleData, TupleTypeSignature, TypeSignature, Value, NONE, + byte_len_of_serialization, PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, + TupleData, TypeSignature, Value, }; pub const STORE_CONTRACT_SRC_INTERFACE: bool = true; diff --git a/clarity/src/vm/database/clarity_store.rs b/clarity/src/vm/database/clarity_store.rs index 07d48c9504..a37669f499 100644 --- a/clarity/src/vm/database/clarity_store.rs +++ b/clarity/src/vm/database/clarity_store.rs @@ -14,26 +14,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::path::PathBuf; - #[cfg(feature = "canonical")] use rusqlite::Connection; -use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, TrieHash, VRFSeed}; -use stacks_common::util::hash::{hex_bytes, to_hex, Hash160, Sha512Trunc256Sum}; +use stacks_common::types::chainstate::{StacksBlockId, TrieHash}; +use stacks_common::util::hash::{hex_bytes, to_hex, Sha512Trunc256Sum}; use crate::vm::analysis::AnalysisDatabase; use crate::vm::contexts::GlobalContext; #[cfg(feature = "canonical")] -use crate::vm::database::SqliteConnection; use crate::vm::database::{ - BurnStateDB, ClarityDatabase, ClarityDeserializable, ClaritySerializable, HeadersDB, - NULL_BURN_STATE_DB, NULL_HEADER_DB, -}; -use crate::vm::errors::{ - CheckErrors, IncomparableError, InterpreterError, InterpreterResult as Result, - InterpreterResult, RuntimeErrorType, + ClarityDatabase, ClarityDeserializable, ClaritySerializable, NULL_BURN_STATE_DB, NULL_HEADER_DB, }; -use crate::vm::events::StacksTransactionEvent; +use crate::vm::errors::{InterpreterError, InterpreterResult as Result}; use crate::vm::types::{PrincipalData, QualifiedContractIdentifier}; use crate::vm::Value; diff --git a/clarity/src/vm/database/key_value_wrapper.rs b/clarity/src/vm/database/key_value_wrapper.rs index eecbe092ea..4d16d2dae6 100644 --- a/clarity/src/vm/database/key_value_wrapper.rs +++ b/clarity/src/vm/database/key_value_wrapper.rs @@ -26,10 +26,8 @@ use super::{ClarityBackingStore, ClarityDeserializable}; use crate::vm::database::clarity_store::make_contract_hash_key; use crate::vm::errors::{InterpreterError, InterpreterResult}; use crate::vm::types::serialization::SerializationError; -use crate::vm::types::{ - QualifiedContractIdentifier, SequenceData, SequenceSubtype, TupleData, TypeSignature, -}; -use crate::vm::{StacksEpoch, Value}; +use crate::vm::types::{QualifiedContractIdentifier, TypeSignature}; +use crate::vm::Value; #[cfg(feature = "rollback_value_check")] type RollbackValueCheck = String; diff --git a/clarity/src/vm/database/mod.rs b/clarity/src/vm/database/mod.rs index a9c2182806..65236cd88a 100644 --- a/clarity/src/vm/database/mod.rs +++ b/clarity/src/vm/database/mod.rs @@ -13,7 +13,6 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use hashbrown::HashMap; #[cfg(feature = "canonical")] pub use sqlite::MemoryBackingStore; diff --git a/clarity/src/vm/database/sqlite.rs b/clarity/src/vm/database/sqlite.rs index 7bc9a7130f..b5da5efedf 100644 --- a/clarity/src/vm/database/sqlite.rs +++ b/clarity/src/vm/database/sqlite.rs @@ -15,10 +15,7 @@ // along with this program. If not, see . use rusqlite::types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; -use rusqlite::{ - params, Connection, Error as SqliteError, ErrorCode as SqliteErrorCode, OptionalExtension, Row, - Savepoint, -}; +use rusqlite::{params, Connection, OptionalExtension}; use stacks_common::types::chainstate::{BlockHeaderHash, StacksBlockId, TrieHash}; use stacks_common::types::sqlite::NO_PARAMS; use stacks_common::util::db::tx_busy_handler; @@ -30,10 +27,9 @@ use super::{ NULL_BURN_STATE_DB, NULL_HEADER_DB, }; use crate::vm::analysis::{AnalysisDatabase, CheckErrors}; -use crate::vm::contracts::Contract; use crate::vm::costs::ExecutionCost; use crate::vm::errors::{ - Error, IncomparableError, InterpreterError, InterpreterResult as Result, RuntimeErrorType, + IncomparableError, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; use crate::vm::types::QualifiedContractIdentifier; diff --git a/clarity/src/vm/database/structures.rs b/clarity/src/vm/database/structures.rs index b88420ff6a..215c0d10d3 100644 --- a/clarity/src/vm/database/structures.rs +++ b/clarity/src/vm/database/structures.rs @@ -22,12 +22,8 @@ use stacks_common::util::hash::{hex_bytes, to_hex}; use crate::vm::analysis::ContractAnalysis; use crate::vm::contracts::Contract; use crate::vm::database::ClarityDatabase; -use crate::vm::errors::{ - Error, IncomparableError, InterpreterError, InterpreterResult, RuntimeErrorType, -}; -use crate::vm::types::{ - OptionalData, PrincipalData, TupleTypeSignature, TypeSignature, Value, NONE, -}; +use crate::vm::errors::{Error, InterpreterError, RuntimeErrorType}; +use crate::vm::types::{PrincipalData, TypeSignature}; pub trait ClaritySerializable { fn serialize(&self) -> String; diff --git a/clarity/src/vm/docs/contracts.rs b/clarity/src/vm/docs/contracts.rs index 138203db71..70c1b3ecb2 100644 --- a/clarity/src/vm/docs/contracts.rs +++ b/clarity/src/vm/docs/contracts.rs @@ -86,7 +86,7 @@ fn doc_execute(program: &str) -> Result, vm::Error> { DOCS_GENERATION_EPOCH, ); global_context.execute(|g| { - let parsed = vm::ast::build_ast_with_rules( + let parsed = build_ast_with_rules( &contract_id, program, &mut (), diff --git a/clarity/src/vm/docs/mod.rs b/clarity/src/vm/docs/mod.rs index 5b2302a9b2..ae84344179 100644 --- a/clarity/src/vm/docs/mod.rs +++ b/clarity/src/vm/docs/mod.rs @@ -17,11 +17,9 @@ use super::types::signatures::{FunctionArgSignature, FunctionReturnsSignature}; use crate::vm::analysis::type_checker::v2_1::natives::SimpleNativeFunction; use crate::vm::analysis::type_checker::v2_1::TypedNativeFunction; -use crate::vm::costs::ExecutionCost; use crate::vm::functions::define::DefineFunctions; use crate::vm::functions::NativeFunctions; -use crate::vm::types::signatures::ASCII_40; -use crate::vm::types::{FixedFunction, FunctionType, SequenceSubtype, StringSubtype, Value}; +use crate::vm::types::{FixedFunction, FunctionType}; use crate::vm::variables::NativeVariables; use crate::vm::ClarityVersion; @@ -2741,13 +2739,12 @@ pub fn make_json_api_reference() -> String { #[cfg(test)] mod test { - use stacks_common::address::AddressHashMode; use stacks_common::consts::{CHAIN_ID_TESTNET, PEER_VERSION_EPOCH_2_1}; use stacks_common::types::chainstate::{ BlockHeaderHash, BurnchainHeaderHash, ConsensusHash, SortitionId, StacksAddress, StacksBlockId, VRFSeed, }; - use stacks_common::types::{Address, StacksEpochId}; + use stacks_common::types::StacksEpochId; use stacks_common::util::hash::hex_bytes; use super::{get_input_type_string, make_all_api_reference, make_json_api_reference}; @@ -2761,12 +2758,11 @@ mod test { use crate::vm::docs::get_output_type_string; use crate::vm::types::signatures::{FunctionArgSignature, FunctionReturnsSignature, ASCII_40}; use crate::vm::types::{ - BufferLength, FunctionType, PrincipalData, SequenceSubtype, StringSubtype, TupleData, - TypeSignature, + FunctionType, PrincipalData, QualifiedContractIdentifier, TupleData, TypeSignature, }; use crate::vm::{ - ast, eval_all, execute, ClarityVersion, ContractContext, Error, GlobalContext, - LimitedCostTracker, QualifiedContractIdentifier, StacksEpoch, Value, + ast, eval_all, execute, ClarityVersion, ContractContext, GlobalContext, LimitedCostTracker, + StacksEpoch, Value, }; struct DocHeadersDB {} diff --git a/clarity/src/vm/errors.rs b/clarity/src/vm/errors.rs index 911465d4ba..5f2b93c1e5 100644 --- a/clarity/src/vm/errors.rs +++ b/clarity/src/vm/errors.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::error::Error as ErrorTrait; use std::{error, fmt}; #[cfg(feature = "canonical")] @@ -29,7 +28,7 @@ pub use crate::vm::analysis::errors::{ use crate::vm::ast::errors::ParseError; use crate::vm::contexts::StackTrace; use crate::vm::costs::CostErrors; -use crate::vm::types::{TypeSignature, Value}; +use crate::vm::types::Value; #[derive(Debug)] pub struct IncomparableError { @@ -236,7 +235,6 @@ impl From for Value { #[cfg(test)] mod test { use super::*; - use crate::vm::execute; #[test] #[cfg(feature = "developer-mode")] @@ -247,7 +245,7 @@ mod test { _native_:native_div "; - assert_eq!(format!("{}", execute(t).unwrap_err()), expected); + assert_eq!(format!("{}", crate::vm::execute(t).unwrap_err()), expected); } #[test] diff --git a/clarity/src/vm/events.rs b/clarity/src/vm/events.rs index 8acc55e73b..0a4db28713 100644 --- a/clarity/src/vm/events.rs +++ b/clarity/src/vm/events.rs @@ -15,15 +15,10 @@ // along with this program. If not, see . use serde_json::json; -use stacks_common::codec::StacksMessageCodec; -use stacks_common::types::chainstate::StacksAddress; use super::types::serialization::SerializationError; -use crate::vm::analysis::ContractAnalysis; -use crate::vm::costs::ExecutionCost; use crate::vm::types::{ - AssetIdentifier, BuffData, PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, - Value, + AssetIdentifier, BuffData, PrincipalData, QualifiedContractIdentifier, Value, }; #[derive(Debug, Clone, PartialEq)] diff --git a/clarity/src/vm/functions/arithmetic.rs b/clarity/src/vm/functions/arithmetic.rs index 1d52ae4390..a04e813786 100644 --- a/clarity/src/vm/functions/arithmetic.rs +++ b/clarity/src/vm/functions/arithmetic.rs @@ -23,14 +23,12 @@ use crate::vm::costs::runtime_cost; use crate::vm::errors::{ check_argument_count, CheckErrors, InterpreterError, InterpreterResult, RuntimeErrorType, }; -use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::signatures::ListTypeData; -use crate::vm::types::TypeSignature::BoolType; +use crate::vm::representations::SymbolicExpression; use crate::vm::types::{ - ASCIIData, BuffData, CharType, ListData, SequenceData, TypeSignature, UTF8Data, Value, + ASCIIData, BuffData, CharType, SequenceData, TypeSignature, UTF8Data, Value, }; use crate::vm::version::ClarityVersion; -use crate::vm::{apply, eval, lookup_function, CallableType, Environment, LocalContext}; +use crate::vm::{eval, Environment, LocalContext}; struct U128Ops(); struct I128Ops(); diff --git a/clarity/src/vm/functions/assets.rs b/clarity/src/vm/functions/assets.rs index 3dca730928..1d60bc7a75 100644 --- a/clarity/src/vm/functions/assets.rs +++ b/clarity/src/vm/functions/assets.rs @@ -17,17 +17,15 @@ use stacks_common::types::StacksEpochId; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostTracker}; -use crate::vm::database::{ClarityDatabase, ClaritySerializable, STXBalance}; +use crate::vm::costs::{runtime_cost, CostTracker}; +use crate::vm::database::STXBalance; use crate::vm::errors::{ check_argument_count, CheckErrors, Error, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; -use crate::vm::functions::tuples; use crate::vm::representations::SymbolicExpression; use crate::vm::types::{ - AssetIdentifier, BlockInfoProperty, BuffData, CharType, OptionalData, PrincipalData, - SequenceData, TupleData, TypeSignature, Value, + AssetIdentifier, BuffData, PrincipalData, SequenceData, TupleData, TypeSignature, Value, }; use crate::vm::{eval, Environment, LocalContext}; diff --git a/clarity/src/vm/functions/boolean.rs b/clarity/src/vm/functions/boolean.rs index ea8fa2a2d4..08716cfe64 100644 --- a/clarity/src/vm/functions/boolean.rs +++ b/clarity/src/vm/functions/boolean.rs @@ -16,10 +16,8 @@ use crate::vm::contexts::{Environment, LocalContext}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost}; -use crate::vm::errors::{ - check_argument_count, check_arguments_at_least, CheckErrors, InterpreterResult as Result, -}; +use crate::vm::costs::runtime_cost; +use crate::vm::errors::{check_arguments_at_least, CheckErrors, InterpreterResult as Result}; use crate::vm::eval; use crate::vm::representations::SymbolicExpression; use crate::vm::types::{TypeSignature, Value}; diff --git a/clarity/src/vm/functions/conversions.rs b/clarity/src/vm/functions/conversions.rs index 142c1308eb..29fa7df651 100644 --- a/clarity/src/vm/functions/conversions.rs +++ b/clarity/src/vm/functions/conversions.rs @@ -14,22 +14,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use stacks_common::codec::StacksMessageCodec; -use stacks_common::types::StacksEpochId; - use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::costs::runtime_cost; use crate::vm::errors::{ check_argument_count, CheckErrors, InterpreterError, InterpreterResult as Result, }; use crate::vm::representations::SymbolicExpression; -use crate::vm::types::SequenceSubtype::{BufferType, StringType}; -use crate::vm::types::StringSubtype::ASCII; +use crate::vm::types::SequenceSubtype::BufferType; use crate::vm::types::TypeSignature::SequenceType; use crate::vm::types::{ - ASCIIData, BuffData, BufferLength, CharType, SequenceData, TypeSignature, UTF8Data, Value, + ASCIIData, BufferLength, CharType, SequenceData, TypeSignature, UTF8Data, Value, }; -use crate::vm::{apply, eval, lookup_function, Environment, LocalContext}; +use crate::vm::{eval, Environment, LocalContext}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum EndianDirection { diff --git a/clarity/src/vm/functions/crypto.rs b/clarity/src/vm/functions/crypto.rs index 86d92283ca..9cc5f5ae9b 100644 --- a/clarity/src/vm/functions/crypto.rs +++ b/clarity/src/vm/functions/crypto.rs @@ -21,20 +21,15 @@ use stacks_common::types::chainstate::StacksAddress; use stacks_common::util::hash; use stacks_common::util::secp256k1::{secp256k1_recover, secp256k1_verify, Secp256k1PublicKey}; -use crate::vm::callables::{CallableType, NativeHandle}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - constants as cost_constants, cost_functions, runtime_cost, CostTracker, MemoryConsumer, -}; +use crate::vm::costs::runtime_cost; use crate::vm::errors::{ - check_argument_count, check_arguments_at_least, CheckErrors, Error, InterpreterError, - InterpreterResult as Result, RuntimeErrorType, ShortReturnType, + check_argument_count, CheckErrors, InterpreterError, InterpreterResult as Result, }; -use crate::vm::representations::SymbolicExpressionType::{Atom, List}; -use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType}; +use crate::vm::representations::SymbolicExpression; use crate::vm::types::{ - BuffData, CharType, PrincipalData, ResponseData, SequenceData, StacksAddressExtensions, - TypeSignature, Value, BUFF_32, BUFF_33, BUFF_65, + BuffData, SequenceData, StacksAddressExtensions, TypeSignature, Value, BUFF_32, BUFF_33, + BUFF_65, }; use crate::vm::{eval, ClarityVersion, Environment, LocalContext}; diff --git a/clarity/src/vm/functions/database.rs b/clarity/src/vm/functions/database.rs index 12fb1cd3da..4d0f880c65 100644 --- a/clarity/src/vm/functions/database.rs +++ b/clarity/src/vm/functions/database.rs @@ -14,25 +14,20 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::cmp; - use stacks_common::consts::CHAIN_ID_TESTNET; use stacks_common::types::chainstate::StacksBlockId; use stacks_common::types::StacksEpochId; use crate::vm::callables::DefineType; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - constants as cost_constants, cost_functions, runtime_cost, CostTracker, MemoryConsumer, -}; +use crate::vm::costs::{constants as cost_constants, runtime_cost, CostTracker, MemoryConsumer}; use crate::vm::errors::{ check_argument_count, check_arguments_at_least, CheckErrors, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; -use crate::vm::functions::tuples; use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; use crate::vm::types::{ - BlockInfoProperty, BuffData, BurnBlockInfoProperty, OptionalData, PrincipalData, SequenceData, + BlockInfoProperty, BuffData, BurnBlockInfoProperty, PrincipalData, SequenceData, StacksBlockInfoProperty, TenureInfoProperty, TupleData, TypeSignature, Value, BUFF_32, }; use crate::vm::{eval, ClarityVersion, Environment, LocalContext}; diff --git a/clarity/src/vm/functions/define.rs b/clarity/src/vm/functions/define.rs index c9489c4320..1e11ff76e9 100644 --- a/clarity/src/vm/functions/define.rs +++ b/clarity/src/vm/functions/define.rs @@ -20,18 +20,12 @@ use crate::vm::callables::{DefineType, DefinedFunction}; use crate::vm::contexts::{ContractContext, Environment, LocalContext}; use crate::vm::errors::{ check_argument_count, check_arguments_at_least, CheckErrors, InterpreterResult as Result, - RuntimeErrorType, }; use crate::vm::eval; -use crate::vm::representations::SymbolicExpressionType::{ - Atom, AtomValue, Field, List, LiteralValue, -}; +use crate::vm::representations::SymbolicExpressionType::Field; use crate::vm::representations::{ClarityName, SymbolicExpression}; use crate::vm::types::signatures::FunctionSignature; -use crate::vm::types::{ - parse_name_type_pairs, PrincipalData, QualifiedContractIdentifier, TraitIdentifier, - TupleTypeSignature, TypeSignature, Value, -}; +use crate::vm::types::{parse_name_type_pairs, TraitIdentifier, TypeSignature, Value}; define_named_enum!(DefineFunctions { Constant("define-constant"), diff --git a/clarity/src/vm/functions/mod.rs b/clarity/src/vm/functions/mod.rs index a8971b3fa0..3eac4fb19e 100644 --- a/clarity/src/vm/functions/mod.rs +++ b/clarity/src/vm/functions/mod.rs @@ -14,27 +14,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use stacks_common::address::AddressHashMode; -use stacks_common::types::chainstate::StacksAddress; use stacks_common::types::StacksEpochId; -use stacks_common::util::hash; use crate::vm::callables::{cost_input_sized_vararg, CallableType, NativeHandle}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{ - constants as cost_constants, cost_functions, runtime_cost, CostTracker, MemoryConsumer, -}; +use crate::vm::costs::{constants as cost_constants, runtime_cost, CostTracker, MemoryConsumer}; use crate::vm::errors::{ check_argument_count, check_arguments_at_least, CheckErrors, Error, - InterpreterResult as Result, RuntimeErrorType, ShortReturnType, + InterpreterResult as Result, ShortReturnType, }; pub use crate::vm::functions::assets::stx_transfer_consolidated; -use crate::vm::representations::SymbolicExpressionType::{Atom, List}; use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType}; -use crate::vm::types::{ - BuffData, CharType, PrincipalData, ResponseData, SequenceData, TypeSignature, Value, BUFF_32, - BUFF_33, BUFF_65, -}; +use crate::vm::types::{PrincipalData, TypeSignature, Value}; use crate::vm::Value::CallableContract; use crate::vm::{eval, is_reserved, Environment, LocalContext}; diff --git a/clarity/src/vm/functions/options.rs b/clarity/src/vm/functions/options.rs index e3305395a5..edbd2d9908 100644 --- a/clarity/src/vm/functions/options.rs +++ b/clarity/src/vm/functions/options.rs @@ -16,10 +16,10 @@ use crate::vm::contexts::{Environment, LocalContext}; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostTracker, MemoryConsumer}; +use crate::vm::costs::{runtime_cost, CostTracker, MemoryConsumer}; use crate::vm::errors::{ - check_argument_count, check_arguments_at_least, CheckErrors, InterpreterError, - InterpreterResult as Result, RuntimeErrorType, ShortReturnType, + check_arguments_at_least, CheckErrors, InterpreterError, InterpreterResult as Result, + RuntimeErrorType, ShortReturnType, }; use crate::vm::types::{CallableData, OptionalData, ResponseData, TypeSignature, Value}; use crate::vm::Value::CallableContract; diff --git a/clarity/src/vm/functions/principals.rs b/clarity/src/vm/functions/principals.rs index 99246019da..e34e50148e 100644 --- a/clarity/src/vm/functions/principals.rs +++ b/clarity/src/vm/functions/principals.rs @@ -2,23 +2,21 @@ use stacks_common::address::{ C32_ADDRESS_VERSION_MAINNET_MULTISIG, C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_MULTISIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG, }; -use stacks_common::util::hash::hex_bytes; use crate::vm::contexts::GlobalContext; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostTracker}; +use crate::vm::costs::runtime_cost; use crate::vm::errors::{ - check_argument_count, check_arguments_at_least, check_arguments_at_most, CheckErrors, Error, - InterpreterError, InterpreterResult as Result, RuntimeErrorType, + check_argument_count, check_arguments_at_least, check_arguments_at_most, CheckErrors, + InterpreterError, InterpreterResult as Result, }; use crate::vm::representations::{ - ClarityName, SymbolicExpression, CONTRACT_MAX_NAME_LENGTH, CONTRACT_MIN_NAME_LENGTH, + SymbolicExpression, CONTRACT_MAX_NAME_LENGTH, CONTRACT_MIN_NAME_LENGTH, }; use crate::vm::types::signatures::{BUFF_1, BUFF_20}; use crate::vm::types::{ - ASCIIData, BuffData, BufferLength, CharType, OptionalData, PrincipalData, - QualifiedContractIdentifier, ResponseData, SequenceData, SequenceSubtype, - StandardPrincipalData, TupleData, TypeSignature, Value, + ASCIIData, BuffData, CharType, OptionalData, PrincipalData, QualifiedContractIdentifier, + ResponseData, SequenceData, StandardPrincipalData, TupleData, TypeSignature, Value, }; use crate::vm::{eval, ContractName, Environment, LocalContext}; diff --git a/clarity/src/vm/functions/sequences.rs b/clarity/src/vm/functions/sequences.rs index 60445f9632..8bc89e7373 100644 --- a/clarity/src/vm/functions/sequences.rs +++ b/clarity/src/vm/functions/sequences.rs @@ -19,16 +19,16 @@ use std::cmp; use stacks_common::types::StacksEpochId; use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost, CostOverflowingMath}; +use crate::vm::costs::{runtime_cost, CostOverflowingMath}; use crate::vm::errors::{ check_argument_count, check_arguments_at_least, CheckErrors, InterpreterResult as Result, RuntimeErrorType, }; -use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; +use crate::vm::representations::SymbolicExpression; use crate::vm::types::signatures::ListTypeData; use crate::vm::types::TypeSignature::BoolType; -use crate::vm::types::{CharType, ListData, SequenceData, TypeSignature, Value}; -use crate::vm::{apply, eval, lookup_function, CallableType, Environment, LocalContext}; +use crate::vm::types::{ListData, SequenceData, TypeSignature, Value}; +use crate::vm::{apply, eval, lookup_function, Environment, LocalContext}; pub fn list_cons( args: &[SymbolicExpression], diff --git a/clarity/src/vm/functions/tuples.rs b/clarity/src/vm/functions/tuples.rs index 9a509ccfbe..44519f1320 100644 --- a/clarity/src/vm/functions/tuples.rs +++ b/clarity/src/vm/functions/tuples.rs @@ -14,13 +14,12 @@ // along with this program. If not, see . use crate::vm::costs::cost_functions::ClarityCostFunction; -use crate::vm::costs::{cost_functions, runtime_cost}; +use crate::vm::costs::runtime_cost; use crate::vm::errors::{ check_argument_count, check_arguments_at_least, CheckErrors, InterpreterError, InterpreterResult as Result, }; -use crate::vm::representations::SymbolicExpressionType::List; -use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType}; +use crate::vm::representations::SymbolicExpression; use crate::vm::types::{TupleData, TypeSignature, Value}; use crate::vm::{eval, Environment, LocalContext}; diff --git a/clarity/src/vm/mod.rs b/clarity/src/vm/mod.rs index 8680c06224..82c9b5a4db 100644 --- a/clarity/src/vm/mod.rs +++ b/clarity/src/vm/mod.rs @@ -59,7 +59,7 @@ use serde_json; use stacks_common::types::StacksEpochId; use self::analysis::ContractAnalysis; -use self::ast::{ASTRules, ContractAST}; +use self::ast::ContractAST; use self::costs::ExecutionCost; use self::diagnostic::Diagnostic; use crate::vm::callables::CallableType; @@ -69,8 +69,7 @@ pub use crate::vm::contexts::{ }; use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::costs::{ - cost_functions, runtime_cost, CostOverflowingMath, CostTracker, LimitedCostTracker, - MemoryConsumer, + runtime_cost, CostOverflowingMath, CostTracker, LimitedCostTracker, MemoryConsumer, }; // publish the non-generic StacksEpoch form for use throughout module pub use crate::vm::database::clarity_db::StacksEpoch; @@ -83,9 +82,7 @@ pub use crate::vm::representations::{ ClarityName, ContractName, SymbolicExpression, SymbolicExpressionType, }; pub use crate::vm::types::Value; -use crate::vm::types::{ - PrincipalData, QualifiedContractIdentifier, TraitIdentifier, TypeSignature, -}; +use crate::vm::types::{PrincipalData, TypeSignature}; pub use crate::vm::version::ClarityVersion; pub const MAX_CALL_STACK_DEPTH: usize = 64; @@ -514,6 +511,7 @@ pub fn execute_with_parameters( ) -> Result> { use crate::vm::database::MemoryBackingStore; use crate::vm::tests::test_only_mainnet_to_chain_id; + use crate::vm::types::QualifiedContractIdentifier; let contract_id = QualifiedContractIdentifier::transient(); let mut contract_context = ContractContext::new(contract_id.clone(), clarity_version); @@ -572,14 +570,13 @@ pub fn execute_v2(program: &str) -> Result> { program, ClarityVersion::Clarity2, StacksEpochId::Epoch21, - ASTRules::PrecheckSize, + ast::ASTRules::PrecheckSize, false, ) } #[cfg(test)] mod test { - use hashbrown::HashMap; use stacks_common::consts::CHAIN_ID_TESTNET; use stacks_common::types::StacksEpochId; @@ -587,10 +584,9 @@ mod test { use crate::vm::callables::{DefineType, DefinedFunction}; use crate::vm::costs::LimitedCostTracker; use crate::vm::database::MemoryBackingStore; - use crate::vm::errors::RuntimeErrorType; use crate::vm::types::{QualifiedContractIdentifier, TypeSignature}; use crate::vm::{ - eval, execute, CallStack, ContractContext, Environment, GlobalContext, LocalContext, + eval, CallStack, ContractContext, Environment, GlobalContext, LocalContext, SymbolicExpression, Value, }; diff --git a/clarity/src/vm/representations.rs b/clarity/src/vm/representations.rs index 7e5423b850..ce97d913b4 100644 --- a/clarity/src/vm/representations.rs +++ b/clarity/src/vm/representations.rs @@ -15,19 +15,16 @@ // along with this program. If not, see . use std::borrow::Borrow; -use std::cmp::Ordering; use std::fmt; use std::io::{Read, Write}; use std::ops::Deref; use lazy_static::lazy_static; use regex::Regex; -use stacks_common::codec::{ - read_next, read_next_at_most, write_next, Error as codec_error, StacksMessageCodec, -}; +use stacks_common::codec::{read_next, write_next, Error as codec_error, StacksMessageCodec}; use crate::vm::errors::RuntimeErrorType; -use crate::vm::types::{QualifiedContractIdentifier, TraitIdentifier, Value}; +use crate::vm::types::{TraitIdentifier, Value}; pub const CONTRACT_MIN_NAME_LENGTH: usize = 1; pub const CONTRACT_MAX_NAME_LENGTH: usize = 40; diff --git a/clarity/src/vm/test_util/mod.rs b/clarity/src/vm/test_util/mod.rs index 861c88ad0a..37a40182eb 100644 --- a/clarity/src/vm/test_util/mod.rs +++ b/clarity/src/vm/test_util/mod.rs @@ -14,7 +14,7 @@ use crate::vm::ast::ASTRules; use crate::vm::costs::ExecutionCost; use crate::vm::database::{BurnStateDB, HeadersDB}; use crate::vm::representations::SymbolicExpression; -use crate::vm::types::{PrincipalData, ResponseData, StandardPrincipalData, TupleData, Value}; +use crate::vm::types::{PrincipalData, StandardPrincipalData, TupleData, Value}; use crate::vm::{execute as vm_execute, execute_on_network as vm_execute_on_network, StacksEpoch}; pub struct UnitTestBurnStateDB { diff --git a/clarity/src/vm/tests/mod.rs b/clarity/src/vm/tests/mod.rs index cada7e973b..25d4713a35 100644 --- a/clarity/src/vm/tests/mod.rs +++ b/clarity/src/vm/tests/mod.rs @@ -13,6 +13,9 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see . + +#![allow(unused_imports)] + use stacks_common::consts::{CHAIN_ID_MAINNET, CHAIN_ID_TESTNET}; use stacks_common::types::StacksEpochId; diff --git a/clarity/src/vm/tooling/mod.rs b/clarity/src/vm/tooling/mod.rs index 5b89145588..0713d4576f 100644 --- a/clarity/src/vm/tooling/mod.rs +++ b/clarity/src/vm/tooling/mod.rs @@ -1,13 +1,8 @@ -use std::collections::{BTreeMap, HashMap, HashSet}; - -use stacks_common::consts::CHAIN_ID_TESTNET; use stacks_common::types::StacksEpochId; use super::analysis::ContractAnalysis; -use super::contexts::GlobalContext; -use super::docs::contracts::ContractRef; use super::types::TypeSignature; -use super::{eval_all, ClarityVersion, ContractContext, Error as VmError, Value}; +use super::ClarityVersion; use crate::vm::analysis::{run_analysis, CheckResult}; use crate::vm::ast::{build_ast_with_rules, ASTRules}; use crate::vm::costs::LimitedCostTracker; diff --git a/clarity/src/vm/types/mod.rs b/clarity/src/vm/types/mod.rs index ef4b565834..e789676f5c 100644 --- a/clarity/src/vm/types/mod.rs +++ b/clarity/src/vm/types/mod.rs @@ -19,9 +19,8 @@ pub mod signatures; use std::collections::btree_map::Entry; use std::collections::BTreeMap; -use std::{char, cmp, fmt, str}; +use std::{char, fmt, str}; -use hashbrown::hash_map::OccupiedEntry; use regex::Regex; use stacks_common::address::c32; use stacks_common::types::chainstate::StacksAddress; @@ -29,11 +28,9 @@ use stacks_common::types::StacksEpochId; use stacks_common::util::hash; use crate::vm::errors::{ - CheckErrors, IncomparableError, InterpreterError, InterpreterResult as Result, RuntimeErrorType, -}; -use crate::vm::representations::{ - ClarityName, ContractName, SymbolicExpression, SymbolicExpressionType, + CheckErrors, InterpreterError, InterpreterResult as Result, RuntimeErrorType, }; +use crate::vm::representations::{ClarityName, ContractName, SymbolicExpression}; pub use crate::vm::types::signatures::{ parse_name_type_pairs, AssetIdentifier, BufferLength, FixedFunction, FunctionArg, FunctionSignature, FunctionType, ListTypeData, SequenceSubtype, StringSubtype, diff --git a/clarity/src/vm/types/serialization.rs b/clarity/src/vm/types/serialization.rs index 48030519c8..57bce8bb6c 100644 --- a/clarity/src/vm/types/serialization.rs +++ b/clarity/src/vm/types/serialization.rs @@ -15,11 +15,9 @@ // along with this program. If not, see . use std::io::{Read, Write}; -use std::{cmp, error, fmt, str}; +use std::{cmp, error, str}; -use hashbrown::HashMap; use lazy_static::lazy_static; -use serde_json::Value as JSONValue; use stacks_common::codec::{Error as codec_error, StacksMessageCodec}; use stacks_common::types::StacksEpochId; use stacks_common::util::hash::{hex_bytes, to_hex}; @@ -27,17 +25,12 @@ use stacks_common::util::retry::BoundReader; use super::{ListTypeData, TupleTypeSignature}; use crate::vm::database::{ClarityDeserializable, ClaritySerializable}; -use crate::vm::errors::{ - CheckErrors, Error as ClarityError, IncomparableError, InterpreterError, InterpreterResult, - RuntimeErrorType, -}; +use crate::vm::errors::{CheckErrors, Error as ClarityError, IncomparableError, InterpreterError}; use crate::vm::representations::{ClarityName, ContractName, MAX_STRING_LEN}; -use crate::vm::types::signatures::CallableSubtype; use crate::vm::types::{ - byte_len_of_serialization, BufferLength, CallableData, CharType, OptionalData, PrincipalData, - QualifiedContractIdentifier, ResponseData, SequenceData, SequenceSubtype, - StandardPrincipalData, StringSubtype, StringUTF8Length, TupleData, TypeSignature, Value, - BOUND_VALUE_SERIALIZATION_BYTES, MAX_TYPE_DEPTH, MAX_VALUE_SIZE, + BufferLength, CallableData, CharType, OptionalData, PrincipalData, QualifiedContractIdentifier, + SequenceData, SequenceSubtype, StandardPrincipalData, StringSubtype, TupleData, TypeSignature, + Value, BOUND_VALUE_SERIALIZATION_BYTES, MAX_TYPE_DEPTH, MAX_VALUE_SIZE, }; /// Errors that may occur in serialization or deserialization @@ -578,7 +571,6 @@ impl Value { top_expected_type: Option<&TypeSignature>, sanitize: bool, ) -> Result { - use super::PrincipalData::*; use super::Value::*; let mut stack = vec![DeserializeStackItem::TopLevel { @@ -1381,9 +1373,7 @@ pub mod tests { use super::super::*; use super::SerializationError; use crate::vm::database::{ClarityDeserializable, ClaritySerializable, RollbackWrapper}; - use crate::vm::errors::Error; use crate::vm::tests::test_clarity_versions; - use crate::vm::types::TypeSignature::{BoolType, IntType}; use crate::vm::ClarityVersion; fn buff_type(size: u32) -> TypeSignature { diff --git a/clarity/src/vm/types/signatures.rs b/clarity/src/vm/types/signatures.rs index a85c56ff3e..e76c7e034d 100644 --- a/clarity/src/vm/types/signatures.rs +++ b/clarity/src/vm/types/signatures.rs @@ -15,21 +15,18 @@ // along with this program. If not, see . use std::collections::btree_map::Entry; -use std::collections::{hash_map, BTreeMap}; -use std::hash::{Hash, Hasher}; -use std::ops::Deref; +use std::collections::BTreeMap; +use std::hash::Hash; use std::sync::Arc; use std::{cmp, fmt}; // TypeSignatures use hashbrown::HashSet; use lazy_static::lazy_static; -use stacks_common::address::c32; use stacks_common::types::StacksEpochId; -use stacks_common::util::hash; -use crate::vm::costs::{cost_functions, runtime_cost, CostOverflowingMath}; -use crate::vm::errors::{CheckErrors, Error as VMError, IncomparableError, RuntimeErrorType}; +use crate::vm::costs::{runtime_cost, CostOverflowingMath}; +use crate::vm::errors::CheckErrors; use crate::vm::representations::{ ClarityName, ContractName, SymbolicExpression, SymbolicExpressionType, TraitDefinition, CONTRACT_MAX_NAME_LENGTH, @@ -1933,7 +1930,7 @@ pub fn parse_name_type_pairs( // the form: // ((name1 type1) (name2 type2) (name3 type3) ...) // which is a list of 2-length lists of atoms. - use crate::vm::representations::SymbolicExpressionType::{Atom, List}; + use crate::vm::representations::SymbolicExpressionType::List; // step 1: parse it into a vec of symbolicexpression pairs. let as_pairs: Result> = name_type_pairs diff --git a/clarity/src/vm/variables.rs b/clarity/src/vm/variables.rs index a5947d00cd..0846e14140 100644 --- a/clarity/src/vm/variables.rs +++ b/clarity/src/vm/variables.rs @@ -21,7 +21,7 @@ use crate::vm::contexts::{Environment, LocalContext}; use crate::vm::costs::cost_functions::ClarityCostFunction; use crate::vm::costs::runtime_cost; use crate::vm::errors::{InterpreterResult as Result, RuntimeErrorType}; -use crate::vm::types::{BuffData, Value}; +use crate::vm::types::Value; use crate::vm::ClarityVersion; define_versioned_named_enum_with_max!(NativeVariables(ClarityVersion) {