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

Extract rpc-filter crate #2097

Closed
wants to merge 5 commits into from
Closed
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
23 changes: 19 additions & 4 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ members = [
"rpc-client",
"rpc-client-api",
"rpc-client-nonce-utils",
"rpc-filter",
"rpc-test",
"runtime",
"runtime-transaction",
Expand Down Expand Up @@ -403,6 +404,7 @@ solana-rpc = { path = "rpc", version = "=2.1.0" }
solana-rpc-client = { path = "rpc-client", version = "=2.1.0", default-features = false }
solana-rpc-client-api = { path = "rpc-client-api", version = "=2.1.0" }
solana-rpc-client-nonce-utils = { path = "rpc-client-nonce-utils", version = "=2.1.0" }
solana-rpc-filter = { path = "rpc-filter", version = "=2.1.0" }
solana-runtime = { path = "runtime", version = "=2.1.0" }
solana-runtime-transaction = { path = "runtime-transaction", version = "=2.1.0" }
solana-sdk = { path = "sdk", version = "=2.1.0" }
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ solana-remote-wallet = { workspace = true, features = ["default"] }
solana-rpc-client = { workspace = true, features = ["default"] }
solana-rpc-client-api = { workspace = true }
solana-rpc-client-nonce-utils = { workspace = true, features = ["clap"] }
solana-rpc-filter = { workspace = true }
solana-sdk = { workspace = true }
solana-streamer = { workspace = true }
solana-tps-client = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ use {
RpcLargestAccountsConfig, RpcLargestAccountsFilter, RpcProgramAccountsConfig,
RpcTransactionConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter,
},
filter::{Memcmp, RpcFilterType},
request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
response::{RpcPerfSample, RpcPrioritizationFee, SlotInfo},
},
solana_rpc_filter::{Memcmp, RpcFilterType},
solana_sdk::{
account::from_account,
account_utils::StateMut,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ use {
solana_rpc_client_api::{
client_error::ErrorKind as ClientErrorKind,
config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig},
filter::{Memcmp, RpcFilterType},
request::MAX_MULTIPLE_ACCOUNTS,
},
solana_rpc_client_nonce_utils::blockhash_query::BlockhashQuery,
solana_rpc_filter::{Memcmp, RpcFilterType},
solana_sdk::{
account::Account,
account_utils::StateMut,
Expand Down
6 changes: 3 additions & 3 deletions cli/src/program_v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ use {
solana_rbpf::{elf::Executable, verifier::RequisiteVerifier},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client::rpc_client::RpcClient,
solana_rpc_client_api::{
config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig},
filter::{Memcmp, RpcFilterType},
solana_rpc_client_api::config::{
RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig,
},
solana_rpc_filter::{Memcmp, RpcFilterType},
solana_sdk::{
account::Account,
commitment_config::CommitmentConfig,
Expand Down
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ solana-quic-client = { workspace = true }
solana-rpc-client = { workspace = true, features = ["default"] }
solana-rpc-client-api = { workspace = true }
solana-rpc-client-nonce-utils = { workspace = true }
solana-rpc-filter = { workspace = true }
solana-sdk = { workspace = true }
solana-streamer = { workspace = true }
solana-thin-client = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub mod rpc_custom_error {
pub use solana_rpc_client_api::custom_error::*;
}
pub mod rpc_filter {
pub use solana_rpc_client_api::filter::*;
pub use solana_rpc_filter::*;
}
pub mod rpc_request {
pub use solana_rpc_client_api::request::*;
Expand Down
19 changes: 16 additions & 3 deletions programs/sbf/Cargo.lock

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

7 changes: 1 addition & 6 deletions rpc-client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ edition = { workspace = true }

[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
bs58 = { workspace = true }
jsonrpc-core = { workspace = true }
reqwest = { workspace = true, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] }
reqwest-middleware = { workspace = true }
Expand All @@ -21,14 +19,11 @@ serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
solana-account-decoder = { workspace = true }
solana-inline-spl = { workspace = true }
solana-rpc-filter = { workspace = true }
solana-sdk = { workspace = true }
solana-transaction-status = { workspace = true }
solana-version = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
const_format = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
2 changes: 1 addition & 1 deletion rpc-client-api/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::filter::RpcFilterType,
solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig},
solana_rpc_filter::RpcFilterType,
solana_sdk::{
clock::{Epoch, Slot},
commitment_config::{CommitmentConfig, CommitmentLevel},
Expand Down
5 changes: 2 additions & 3 deletions rpc-client-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![allow(clippy::arithmetic_side_effects)]

pub mod client_error;
pub mod config;
pub mod custom_error;
pub mod error_object;
pub mod filter;
#[deprecated(since = "2.1.0", note = "Use `solana-rpc-filter` crate instead")]
pub use solana_rpc_filter as filter;
pub mod request;
pub mod response;

Expand Down
26 changes: 26 additions & 0 deletions rpc-filter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "solana-rpc-filter"
description = "Solana RPC filter type"
documentation = "https://docs.rs/solana-rpc-filter"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
base64 = { workspace = true }
bs58 = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
solana-inline-spl = { workspace = true }
solana-sdk = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
const_format = { workspace = true }
serde_json = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
5 changes: 3 additions & 2 deletions rpc-client-api/src/filter.rs → rpc-filter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
base64::{prelude::BASE64_STANDARD, Engine},
serde::Deserialize,
serde_derive::{Deserialize, Serialize},
solana_inline_spl::{token::GenericTokenAccount, token_2022::Account},
solana_sdk::account::{AccountSharedData, ReadableAccount},
std::borrow::Cow,
Expand Down Expand Up @@ -91,7 +91,7 @@ pub enum MemcmpEncodedBytes {
Bytes(Vec<u8>),
}

impl<'de> Deserialize<'de> for MemcmpEncodedBytes {
impl<'de> serde::Deserialize<'de> for MemcmpEncodedBytes {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down Expand Up @@ -194,6 +194,7 @@ impl Memcmp {
}
}

#[allow(clippy::arithmetic_side_effects)]
pub fn bytes_match(&self, data: &[u8]) -> bool {
match self.bytes() {
Some(bytes) => {
Expand Down
1 change: 1 addition & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ solana-perf = { workspace = true }
solana-poh = { workspace = true }
solana-rayon-threadlimit = { workspace = true }
solana-rpc-client-api = { workspace = true }
solana-rpc-filter = { workspace = true }
solana-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana-send-transaction-service = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
solana_inline_spl::{token::GenericTokenAccount, token_2022::Account},
solana_rpc_client_api::filter::RpcFilterType,
solana_rpc_filter::RpcFilterType,
solana_sdk::account::{AccountSharedData, ReadableAccount},
};

Expand Down
14 changes: 6 additions & 8 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use {
solana_rpc_client_api::{
config::*,
custom_error::RpcCustomError,
filter::{Memcmp, RpcFilterType},
request::{
TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE,
MAX_GET_CONFIRMED_BLOCKS_RANGE, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT,
Expand All @@ -49,6 +48,7 @@ use {
},
response::{Response as RpcResponse, *},
},
solana_rpc_filter::{Memcmp, RpcFilterType},
solana_runtime::{
bank::{Bank, TransactionSimulationResult},
bank_forks::BankForks,
Expand Down Expand Up @@ -4324,14 +4324,12 @@ pub mod tests {
blockstore_processor::fill_blockstore_slot_with_ticks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
},
solana_rpc_client_api::{
custom_error::{
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE,
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE,
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION,
},
filter::MemcmpEncodedBytes,
solana_rpc_client_api::custom_error::{
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE,
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE,
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION,
},
solana_rpc_filter::MemcmpEncodedBytes,
solana_runtime::{
accounts_background_service::AbsRequestSender, bank::BankTestConfig,
commitment::BlockCommitment, non_circulating_supply::non_circulating_accounts,
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc_subscription_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
dashmap::{mapref::entry::Entry as DashEntry, DashMap},
solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig},
solana_metrics::{CounterToken, TokenCounter},
solana_rpc_client_api::filter::RpcFilterType,
solana_rpc_filter::RpcFilterType,
solana_runtime::{
bank::{TransactionLogCollectorConfig, TransactionLogCollectorFilter},
bank_forks::BankForks,
Expand Down
Loading