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

refactor: move state reader modules to a new crate #486

Open
wants to merge 1 commit into
base: pr/Itay-Tsabary-Starkware/tsabary/state_reader_client/8a8b91d3
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions crates/gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ testing = []
[dependencies]
async-trait.workspace = true
axum.workspace = true
blockifier= { workspace = true, features = ["testing"] }
blockifier = { workspace = true, features = ["testing"] }
cairo-lang-starknet-classes.workspace = true
cairo-vm.workspace = true
hyper.workspace = true
mempool_test_utils = { path = "../mempool_test_utils", version = "0.0" }
num-traits.workspace = true
papyrus_config.workspace = true
papyrus_rpc.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
starknet-types-core.workspace = true
starknet_api.workspace = true
starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" }
starknet_mempool_types = { path = "../mempool_types", version = "0.0" }
starknet_sierra_compile = { path = "../starknet_sierra_compile", version = "0.0" }
starknet-types-core.workspace = true
mempool_test_utils = { path = "../mempool_test_utils", version = "0.0"}
starknet_state_reader = { path = "../state_reader", version = "0.0", features = ["testing"] }
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/gateway/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use starknet_api::transaction::TransactionHash;
use starknet_mempool_infra::component_runner::{ComponentStartError, ComponentStarter};
use starknet_mempool_types::communication::SharedMempoolClient;
use starknet_mempool_types::mempool_types::{Account, MempoolInput};
use starknet_state_reader::state_reader::StateReaderFactory;
use tracing::{info, instrument};

use crate::compilation::GatewayCompiler;
use crate::config::{GatewayConfig, GatewayNetworkConfig, RpcStateReaderConfig};
use crate::errors::{GatewayError, GatewayResult, GatewayRunError};
use crate::rpc_state_reader::RpcStateReaderFactory;
use crate::state_reader::StateReaderFactory;
use crate::stateful_transaction_validator::StatefulTransactionValidator;
use crate::stateless_transaction_validator::StatelessTransactionValidator;
use crate::utils::{external_tx_to_thin_tx, get_sender_address};
Expand Down
4 changes: 3 additions & 1 deletion crates/gateway/src/gateway_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ use starknet_api::rpc_transaction::RPCTransaction;
use starknet_api::transaction::TransactionHash;
use starknet_mempool_types::communication::MockMempoolClient;
use starknet_mempool_types::mempool_types::{Account, AccountState, MempoolInput, ThinTransaction};
use starknet_state_reader::state_reader_test_utils::{
local_test_state_reader_factory, TestStateReaderFactory,
};

use crate::compilation::GatewayCompiler;
use crate::config::{
GatewayCompilerConfig, StatefulTransactionValidatorConfig, StatelessTransactionValidatorConfig,
};
use crate::gateway::{add_tx, AppState, SharedMempoolClient};
use crate::state_reader_test_utils::{local_test_state_reader_factory, TestStateReaderFactory};
use crate::stateful_transaction_validator::StatefulTransactionValidator;
use crate::stateless_transaction_validator::StatelessTransactionValidator;
use crate::utils::{external_tx_to_account_tx, get_tx_hash};
Expand Down
4 changes: 1 addition & 3 deletions crates/gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ mod rpc_objects;
mod rpc_state_reader;
#[cfg(test)]
mod rpc_state_reader_test;
mod state_reader;
#[cfg(test)]
mod state_reader_test_utils;

mod stateful_transaction_validator;
mod stateless_transaction_validator;
#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/gateway/src/rpc_state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde_json::{json, Value};
use starknet_api::block::BlockNumber;
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::state::StorageKey;
use starknet_state_reader::state_reader::{MempoolStateReader, StateReaderFactory};
use starknet_types_core::felt::Felt;

use crate::config::RpcStateReaderConfig;
Expand All @@ -18,7 +19,6 @@ use crate::rpc_objects::{
GetCompiledContractClassParams, GetNonceParams, GetStorageAtParams, RpcResponse,
RPC_CLASS_HASH_NOT_FOUND, RPC_ERROR_BLOCK_NOT_FOUND, RPC_ERROR_CONTRACT_ADDRESS_NOT_FOUND,
};
use crate::state_reader::{MempoolStateReader, StateReaderFactory};

pub struct RpcStateReader {
pub config: RpcStateReaderConfig,
Expand Down
2 changes: 1 addition & 1 deletion crates/gateway/src/rpc_state_reader_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde_json::json;
use starknet_api::block::{BlockNumber, GasPrice};
use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey};
use starknet_api::{class_hash, contract_address, felt, patricia_key};
use starknet_state_reader::state_reader::MempoolStateReader;

use crate::config::RpcStateReaderConfig;
use crate::rpc_objects::{
Expand All @@ -15,7 +16,6 @@ use crate::rpc_objects::{
RpcSuccessResponse,
};
use crate::rpc_state_reader::RpcStateReader;
use crate::state_reader::MempoolStateReader;

async fn run_rpc_server() -> mockito::ServerGuard {
mockito::Server::new_async().await
Expand Down
2 changes: 1 addition & 1 deletion crates/gateway/src/stateful_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use blockifier::versioned_constants::VersionedConstants;
use starknet_api::core::Nonce;
use starknet_api::rpc_transaction::{RPCInvokeTransaction, RPCTransaction};
use starknet_api::transaction::TransactionHash;
use starknet_state_reader::state_reader::{MempoolStateReader, StateReaderFactory};
use starknet_types_core::felt::Felt;

use crate::config::StatefulTransactionValidatorConfig;
use crate::errors::{StatefulTransactionValidatorError, StatefulTransactionValidatorResult};
use crate::state_reader::{MempoolStateReader, StateReaderFactory};
use crate::utils::{external_tx_to_account_tx, get_sender_address, get_tx_hash};

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions crates/gateway/src/stateful_transaction_validator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use starknet_api::core::{ContractAddress, Nonce};
use starknet_api::felt;
use starknet_api::rpc_transaction::RPCTransaction;
use starknet_api::transaction::TransactionHash;
use starknet_state_reader::state_reader_test_utils::{
local_test_state_reader_factory, local_test_state_reader_factory_for_deploy_account,
TestStateReader, TestStateReaderFactory,
};
use starknet_types_core::felt::Felt;

use crate::compilation::GatewayCompiler;
use crate::config::{GatewayCompilerConfig, StatefulTransactionValidatorConfig};
use crate::errors::{StatefulTransactionValidatorError, StatefulTransactionValidatorResult};
use crate::state_reader_test_utils::{
local_test_state_reader_factory, local_test_state_reader_factory_for_deploy_account,
TestStateReader, TestStateReaderFactory,
};
use crate::stateful_transaction_validator::StatefulTransactionValidator;

#[fixture]
Expand Down
13 changes: 10 additions & 3 deletions crates/state_reader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
[package]
name = "state_reader"
name = "starknet_state_reader"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]

[lints]
workspace = true

[features]
testing = []

[dependencies]
blockifier = { workspace = true, features = ["testing"] }
mempool_test_utils = { path = "../mempool_test_utils", version = "0.0" }
starknet-types-core.workspace = true
starknet_api.workspace = true
3 changes: 3 additions & 0 deletions crates/state_reader/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pub mod state_reader;

#[cfg(any(feature = "testing", test))]
pub mod state_reader_test_utils;
Loading