Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move abi utils to snapi #2105

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ semver.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["arbitrary_precision"] }
sha2.workspace = true
sha3.workspace = true
starknet-types-core.workspace = true
starknet_api.workspace = true
strum.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod abi_utils;
pub mod constants;
pub mod sierra_types;
5 changes: 0 additions & 5 deletions crates/blockifier/src/abi/constants.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use starknet_api::transaction::TransactionVersion;
use starknet_types_core::felt::Felt;

pub const CONSTRUCTOR_ENTRY_POINT_NAME: &str = "constructor";
pub const DEFAULT_ENTRY_POINT_NAME: &str = "__default__";
pub const DEFAULT_ENTRY_POINT_SELECTOR: u64 = 0;
pub const DEFAULT_L1_ENTRY_POINT_NAME: &str = "__l1_default__";

// The version is considered 0 for L1-Handler transaction hash calculation purposes.
pub const L1_HANDLER_VERSION: TransactionVersion = TransactionVersion(Felt::ZERO);

Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/concurrency/versioned_state_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::thread;

use assert_matches::assert_matches;
use rstest::{fixture, rstest};
use starknet_api::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address};
use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress};
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::fields::{ContractAddressSalt, ValidResourceBounds};
Expand All @@ -18,7 +19,6 @@ use starknet_api::{
storage_key,
};

use crate::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address};
use crate::concurrency::test_utils::{
class_hash,
contract_address,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/concurrency/worker_logic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::sync::Mutex;

use rstest::rstest;
use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::core::{ContractAddress, Nonce};
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME;
Expand All @@ -11,7 +12,6 @@ use starknet_api::{contract_address, declare_tx_args, felt, invoke_tx_args, nonc
use starknet_types_core::felt::Felt;

use super::WorkerExecutor;
use crate::abi::abi_utils::get_fee_token_var_address;
use crate::bouncer::Bouncer;
use crate::concurrency::fee_utils::STORAGE_READ_SEQUENCER_BALANCE_INDICES;
use crate::concurrency::scheduler::{Task, TransactionStatus};
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/contract_address_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use rstest::rstest;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress};
use starknet_api::transaction::fields::{Calldata, ContractAddressSalt};
use starknet_api::{calldata, felt};

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use cairo_vm::types::layout_name::LayoutName;
use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable};
use cairo_vm::vm::errors::vm_errors::VirtualMachineError;
use cairo_vm::vm::runners::cairo_runner::{CairoArg, CairoRunner, ExecutionResources};
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::abi::constants::{CONSTRUCTOR_ENTRY_POINT_NAME, DEFAULT_ENTRY_POINT_SELECTOR};
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::EntryPointSelector;
use starknet_api::hash::StarkHash;

use super::execution_utils::SEGMENT_ARENA_BUILTIN_SIZE;
use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants::{CONSTRUCTOR_ENTRY_POINT_NAME, DEFAULT_ENTRY_POINT_SELECTOR};
use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources};
use crate::execution::contract_class::{ContractClassV0, TrackedResource};
use crate::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallHintProcessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use num_traits::Pow;
use pretty_assertions::assert_eq;
use rstest::rstest;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::{calculate_contract_address, ChainId};
use starknet_api::state::StorageKey;
use starknet_api::transaction::fields::{Calldata, ContractAddressSalt, Fee};
Expand All @@ -20,7 +21,6 @@ use starknet_api::{calldata, felt, nonce, storage_key};
use starknet_types_core::felt::Felt;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources, OrderedEvent};
use crate::execution::common_hints::ExecutionMode;
Expand Down
7 changes: 3 additions & 4 deletions crates/blockifier/src/execution/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::sync::Arc;
use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources};
use num_traits::{Inv, Zero};
use serde::Serialize;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME;
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector};
use starknet_api::state::StorageKey;
Expand All @@ -18,9 +20,6 @@ use starknet_api::transaction::fields::{
use starknet_api::transaction::TransactionVersion;
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants;
use crate::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME;
use crate::context::{BlockContext, TransactionContext};
use crate::execution::call_info::CallInfo;
use crate::execution::common_hints::ExecutionMode;
Expand Down Expand Up @@ -468,7 +467,7 @@ pub fn handle_empty_constructor(
class_hash: Some(ctor_context.class_hash),
code_address: ctor_context.code_address,
entry_point_type: EntryPointType::Constructor,
entry_point_selector: selector_from_name(constants::CONSTRUCTOR_ENTRY_POINT_NAME),
entry_point_selector: selector_from_name(CONSTRUCTOR_ENTRY_POINT_NAME),
calldata: Calldata::default(),
storage_address: ctor_context.storage_address,
caller_address: ctor_context.caller_address,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/entry_point_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::collections::HashSet;
use cairo_vm::types::builtin_name::BuiltinName;
use num_bigint::BigInt;
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::{get_storage_var_address, selector_from_name};
use starknet_api::core::EntryPointSelector;
use starknet_api::execution_utils::format_panic_data;
use starknet_api::transaction::fields::{Calldata, Fee};
use starknet_api::{calldata, felt, storage_key};

use crate::abi::abi_utils::{get_storage_var_address, selector_from_name};
use crate::context::ChainInfo;
use crate::execution::call_info::{CallExecution, CallInfo};
use crate::execution::entry_point::CallEntryPoint;
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/execution/stack_trace_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use assert_matches::assert_matches;
use pretty_assertions::assert_eq;
use regex::Regex;
use rstest::rstest;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME;
use starknet_api::core::{
calculate_contract_address,
ClassHash,
Expand All @@ -28,8 +30,6 @@ use starknet_api::transaction::TransactionVersion;
use starknet_api::{calldata, felt, invoke_tx_args};
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME;
use crate::context::{BlockContext, ChainInfo};
use crate::execution::call_info::{CallExecution, CallInfo, Retdata};
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use std::sync::Arc;
use itertools::Itertools;
use pretty_assertions::assert_eq;
use rstest::rstest;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::execution_utils::format_panic_data;
use starknet_api::felt;
use starknet_api::transaction::fields::Calldata;
use test_case::test_case;

use super::constants::REQUIRED_GAS_CALL_CONTRACT_TEST;
use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::contract_class::TrackedResource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::calculate_contract_address;
use starknet_api::transaction::fields::{Calldata, ContractAddressSalt, Fee};
use starknet_api::{calldata, felt};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use itertools::concat;
#[cfg(feature = "cairo_native")]
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::felt;
use starknet_api::transaction::fields::Calldata;
use starknet_api::transaction::{EventContent, EventData, EventKey};
use starknet_types_core::felt::Felt;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::{CallExecution, CallInfo, OrderedEvent};
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::ContractAddress;
use starknet_api::execution_utils::format_panic_data;
use starknet_api::state::StorageKey;
use starknet_api::{calldata, felt};
use starknet_types_core::felt::Felt;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::abi::constants;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::{calldata, class_hash, contract_address, felt};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cairo_vm::Felt252;
use num_traits::Pow;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::block::GasPrice;
use starknet_api::core::ChainId;
use starknet_api::data_availability::DataAvailabilityMode;
Expand All @@ -19,7 +20,6 @@ use starknet_api::{felt, nonce};
use starknet_types_core::felt::Felt;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::common_hints::ExecutionMode;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::transaction::fields::Calldata;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::collections::{HashMap, HashSet};
use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::execution_resources::GasAmount;
use starknet_api::execution_utils::format_panic_data;
use starknet_api::transaction::fields::GasVectorComputationMode;
use starknet_api::{calldata, felt, storage_key};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources};
use crate::execution::entry_point::{CallEntryPoint, CallType};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::execution_utils::format_panic_data;
use starknet_api::{calldata, felt};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::entry_point::CallEntryPoint;
use crate::execution::syscalls::syscall_tests::constants::REQUIRED_GAS_STORAGE_READ_WRITE_TEST;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use pretty_assertions::assert_eq;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::{calldata, felt};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::transaction::fields::Calldata;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use itertools::concat;
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::EthAddress;
use starknet_api::felt;
use starknet_api::transaction::fields::Calldata;
use starknet_api::transaction::L2ToL1Payload;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::{CallExecution, MessageToL1, OrderedL2ToL1Message};
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::transaction::fields::Calldata;
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::state::StorageKey;
use starknet_api::{calldata, felt};
use test_case::test_case;

use crate::abi::abi_utils::selector_from_name;
use crate::context::ChainInfo;
use crate::execution::call_info::CallExecution;
use crate::execution::entry_point::CallEntryPoint;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/fee/fee_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::collections::HashSet;
use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use num_bigint::BigUint;
use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::core::ContractAddress;
use starknet_api::execution_resources::GasVector;
use starknet_api::state::StorageKey;
use starknet_api::transaction::fields::ValidResourceBounds::{AllResources, L1Gas};
use starknet_api::transaction::fields::{Fee, GasVectorComputationMode, Resource};
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::get_fee_token_var_address;
use crate::blockifier::block::BlockInfo;
use crate::context::{BlockContext, TransactionContext};
use crate::fee::resources::TransactionFeeResult;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/state/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::cell::RefCell;
use std::collections::{HashMap, HashSet};

use indexmap::IndexMap;
use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::state::StorageKey;
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::get_fee_token_var_address;
use crate::context::TransactionContext;
use crate::execution::contract_class::RunnableContractClass;
use crate::state::errors::StateError;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/state/state_api.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::collections::{HashMap, HashSet};

use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::state::StorageKey;
use starknet_types_core::felt::Felt;

use super::cached_state::{ContractClassMapping, StateMaps};
use crate::abi::abi_utils::get_fee_token_var_address;
use crate::execution::contract_class::RunnableContractClass;
use crate::state::errors::StateError;

Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::PathBuf;

use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::abi::abi_utils::{get_fee_token_var_address, selector_from_name};
use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber, GasPrice, NonzeroGasPrice};
use starknet_api::core::{ClassHash, ContractAddress};
use starknet_api::execution_resources::{GasAmount, GasVector};
Expand All @@ -31,7 +32,6 @@ use starknet_api::transaction::TransactionVersion;
use starknet_api::{contract_address, felt};
use starknet_types_core::felt::Felt;

use crate::abi::abi_utils::{get_fee_token_var_address, selector_from_name};
use crate::abi::constants;
use crate::execution::call_info::ExecutionSummary;
use crate::execution::contract_class::TrackedResource;
Expand Down
Loading
Loading