From bb927628b2a2eeb73f3eb844678e81f2a95f1245 Mon Sep 17 00:00:00 2001 From: ysq Date: Fri, 26 Sep 2025 23:59:06 +0800 Subject: [PATCH] feat: upgrade to Solana SDK v3.0.0 and modernize dependencies - Upgrade all Solana SDK dependencies from v2.3.x to v3.0.0 - Update yellowstone-grpc dependencies from v8.0.0 to v9.0.0 - Upgrade tonic from v0.12.3 to v0.14.2 with transport features - Update prost and prost-types to v0.14.1 - Add solana-commitment-config and tonic-prost dependencies - Migrate from solana-sdk::instruction to message::compiled_instruction - Update imports for SPL token pack compatibility - Fix type compatibility issues with new gRPC and protobuf versions - Regenerate proto files with updated codegen and server implementations --- Cargo.toml | 38 +- README.md | 4 +- README_CN.md | 4 +- examples/parse_tx_events.rs | 4 +- src/protos/shared.rs | 6 +- src/protos/shredstream.rs | 402 +++++++++++++++++- .../event_parser/core/account_event_parser.rs | 4 +- .../event_parser/core/event_parser.rs | 5 +- src/streaming/grpc/types.rs | 1 - src/streaming/yellowstone_sub_system.rs | 27 +- 10 files changed, 426 insertions(+), 69 deletions(-) mode change 100755 => 100644 src/protos/shared.rs mode change 100755 => 100644 src/protos/shredstream.rs diff --git a/Cargo.toml b/Cargo.toml index 7d03819..652ee02 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-streamer-sdk" -version = "0.4.13" +version = "0.5.0" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/solana-streamer" @@ -13,18 +13,18 @@ readme = "README.md" crate-type = ["cdylib", "rlib"] [dependencies] -solana-sdk = "2.3.0" -solana-client = "2.3.6" -solana-program = "2.3.0" -solana-rpc-client = "2.3.6" -solana-rpc-client-api = "2.3.6" -solana-transaction-status = "2.3.6" -solana-account-decoder = "2.3.6" -solana-hash = "2.3.0" -solana-entry = "2.3.6" -solana-rpc-client-nonce-utils = "2.3.6" -solana-perf = "2.3.6" -solana-metrics = "2.3.6" +solana-sdk = "3.0.0" +solana-client = "3.0.0" +solana-program = "3.0.0" +solana-rpc-client = "3.0.0" +solana-rpc-client-api = "3.0.0" +solana-transaction-status = "3.0.0" +solana-account-decoder = "3.0.0" +solana-hash = "3.0.0" +solana-entry = "3.0.0" +solana-rpc-client-nonce-utils = "3.0.0" +solana-perf = "3.0.0" +solana-metrics = "3.0.0" spl-associated-token-account = "7.0.0" borsh = { version = "1.5.3", features = ["derive"] } serde = { version = "1.0.215", features = ["derive"] } @@ -36,10 +36,10 @@ base64 = "0.22.1" rand = "0.9.0" bincode = "1.3.3" anyhow = "1.0.90" -yellowstone-grpc-client = { version = "8.0.0" } -yellowstone-grpc-proto = { version = "8.0.0" } +yellowstone-grpc-client = { version = "9.0.0" } +yellowstone-grpc-proto = { version = "9.0.0" } tokio = { version = "1.42.0", features = ["full", "rt-multi-thread"]} -tonic = { version = "0.12.3", features = ["tls", "tls-roots", "tls-webpki-roots"] } +tonic = { version = "0.14.2", features = ["transport"] } rustls = { version = "0.23.23", features = ["ring"], default-features = false } rustls-native-certs = "0.8.1" tokio-rustls = "0.26.1" @@ -52,8 +52,8 @@ async-trait = "0.1.86" lazy_static = "1.5.0" once_cell = "1.20.3" dashmap = "6.0.1" -prost = "0.13.5" -prost-types = "0.13.5" +prost = "0.14.1" +prost-types = "0.14.1" num_enum = "0.7.3" num-derive = "0.4.2" num-traits = "0.2.19" @@ -70,6 +70,8 @@ parking_lot = "0.12.1" wide = "0.7" spl-token = "8.0.0" spl-token-2022 = "9.0.0" +solana-commitment-config = { version = "3.0.0", features = ["serde"] } +tonic-prost = "0.14.2" [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] } \ No newline at end of file diff --git a/README.md b/README.md index 6349ba4..d4fb8c6 100755 --- a/README.md +++ b/README.md @@ -108,14 +108,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.13" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.5.0" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -solana-streamer-sdk = "0.4.13" +solana-streamer-sdk = "0.5.0" ``` ## ⚙️ Configuration System diff --git a/README_CN.md b/README_CN.md index 6e48a27..495d104 100644 --- a/README_CN.md +++ b/README_CN.md @@ -107,14 +107,14 @@ git clone https://github.com/0xfnzero/solana-streamer ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.13" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.5.0" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = "0.4.13" +solana-streamer-sdk = "0.5.0" ``` ## ⚙️ 配置系统 diff --git a/examples/parse_tx_events.rs b/examples/parse_tx_events.rs index 0330cb8..61c884b 100644 --- a/examples/parse_tx_events.rs +++ b/examples/parse_tx_events.rs @@ -1,12 +1,10 @@ use anyhow::Result; -use solana_sdk::commitment_config::CommitmentConfig; - +use solana_commitment_config::CommitmentConfig; use solana_streamer_sdk::streaming::event_parser::core::event_parser::EventParser; use solana_streamer_sdk::streaming::event_parser::Protocol; use solana_streamer_sdk::streaming::event_parser::UnifiedEvent; use std::str::FromStr; use std::sync::Arc; - /// Get transaction data based on transaction signature #[tokio::main] async fn main() -> Result<()> { diff --git a/src/protos/shared.rs b/src/protos/shared.rs old mode 100755 new mode 100644 index b2b0680..6cb1cd1 --- a/src/protos/shared.rs +++ b/src/protos/shared.rs @@ -1,15 +1,15 @@ // This file is @generated by prost-build. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct Header { #[prost(message, optional, tag = "1")] pub ts: ::core::option::Option<::prost_types::Timestamp>, } -#[derive(Clone, Copy, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct Heartbeat { #[prost(uint64, tag = "1")] pub count: u64, } -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct Socket { #[prost(string, tag = "1")] pub ip: ::prost::alloc::string::String, diff --git a/src/protos/shredstream.rs b/src/protos/shredstream.rs old mode 100755 new mode 100644 index 95a36f5..876f635 --- a/src/protos/shredstream.rs +++ b/src/protos/shredstream.rs @@ -1,5 +1,5 @@ // This file is @generated by prost-build. -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct Heartbeat { /// don't trust IP:PORT from tcp header since it can be tampered over the wire /// `socket.ip` must match incoming packet's ip. this prevents spamming an unwitting destination @@ -10,13 +10,13 @@ pub struct Heartbeat { #[prost(string, repeated, tag = "2")] pub regions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -#[derive(Clone, Copy, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct HeartbeatResponse { /// client must respond within `ttl_ms` to keep stream alive #[prost(uint32, tag = "1")] pub ttl_ms: u32, } -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct TraceShred { /// source region, one of: #[prost(string, tag = "1")] @@ -29,9 +29,9 @@ pub struct TraceShred { pub seq_num: u32, } /// tbd: we may want to add filters here -#[derive(Clone, Copy, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct SubscribeEntriesRequest {} -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct Entry { /// the slot that the entry is from #[prost(uint64, tag = "1")] @@ -68,7 +68,7 @@ pub mod shredstream_client { } impl ShredstreamClient where - T: tonic::client::GrpcService, + T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + std::marker::Send, @@ -89,13 +89,13 @@ pub mod shredstream_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, + http::Request, Response = http::Response< - >::ResponseBody, + >::ResponseBody, >, >, , + http::Request, >>::Error: Into + std::marker::Send + std::marker::Sync, { ShredstreamClient::new(InterceptedService::new(inner, interceptor)) @@ -147,7 +147,7 @@ pub mod shredstream_client { format!("Service was not ready: {}", e.into()), ) })?; - let codec = tonic::codec::ProstCodec::default(); + let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/shredstream.Shredstream/SendHeartbeat", ); @@ -158,6 +158,187 @@ pub mod shredstream_client { } } } +/// Generated server implementations. +pub mod shredstream_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with ShredstreamServer. + #[async_trait] + pub trait Shredstream: std::marker::Send + std::marker::Sync + 'static { + /// RPC endpoint to send heartbeats to keep shreds flowing + async fn send_heartbeat( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct ShredstreamServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl ShredstreamServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for ShredstreamServer + where + T: Shredstream, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/shredstream.Shredstream/SendHeartbeat" => { + #[allow(non_camel_case_types)] + struct SendHeartbeatSvc(pub Arc); + impl tonic::server::UnaryService + for SendHeartbeatSvc { + type Response = super::HeartbeatResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::send_heartbeat(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SendHeartbeatSvc(inner); + let codec = tonic_prost::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + let mut response = http::Response::new( + tonic::body::Body::default(), + ); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for ShredstreamServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "shredstream.Shredstream"; + impl tonic::server::NamedService for ShredstreamServer { + const NAME: &'static str = SERVICE_NAME; + } +} /// Generated client implementations. pub mod shredstream_proxy_client { #![allow( @@ -186,7 +367,7 @@ pub mod shredstream_proxy_client { } impl ShredstreamProxyClient where - T: tonic::client::GrpcService, + T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + std::marker::Send, @@ -207,13 +388,13 @@ pub mod shredstream_proxy_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, + http::Request, Response = http::Response< - >::ResponseBody, + >::ResponseBody, >, >, , + http::Request, >>::Error: Into + std::marker::Send + std::marker::Sync, { ShredstreamProxyClient::new(InterceptedService::new(inner, interceptor)) @@ -264,7 +445,7 @@ pub mod shredstream_proxy_client { format!("Service was not ready: {}", e.into()), ) })?; - let codec = tonic::codec::ProstCodec::default(); + let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/shredstream.ShredstreamProxy/SubscribeEntries", ); @@ -277,3 +458,194 @@ pub mod shredstream_proxy_client { } } } +/// Generated server implementations. +pub mod shredstream_proxy_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with ShredstreamProxyServer. + #[async_trait] + pub trait ShredstreamProxy: std::marker::Send + std::marker::Sync + 'static { + /// Server streaming response type for the SubscribeEntries method. + type SubscribeEntriesStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + + std::marker::Send + + 'static; + async fn subscribe_entries( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct ShredstreamProxyServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl ShredstreamProxyServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for ShredstreamProxyServer + where + T: ShredstreamProxy, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/shredstream.ShredstreamProxy/SubscribeEntries" => { + #[allow(non_camel_case_types)] + struct SubscribeEntriesSvc(pub Arc); + impl< + T: ShredstreamProxy, + > tonic::server::ServerStreamingService< + super::SubscribeEntriesRequest, + > for SubscribeEntriesSvc { + type Response = super::Entry; + type ResponseStream = T::SubscribeEntriesStream; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::subscribe_entries(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SubscribeEntriesSvc(inner); + let codec = tonic_prost::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.server_streaming(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + let mut response = http::Response::new( + tonic::body::Body::default(), + ); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for ShredstreamProxyServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "shredstream.ShredstreamProxy"; + impl tonic::server::NamedService for ShredstreamProxyServer { + const NAME: &'static str = SERVICE_NAME; + } +} diff --git a/src/streaming/event_parser/core/account_event_parser.rs b/src/streaming/event_parser/core/account_event_parser.rs index d572420..8a9090e 100644 --- a/src/streaming/event_parser/core/account_event_parser.rs +++ b/src/streaming/event_parser/core/account_event_parser.rs @@ -14,8 +14,8 @@ use crate::streaming::event_parser::Protocol; use crate::streaming::grpc::AccountPretty; use serde::{Deserialize, Serialize}; use solana_account_decoder::parse_nonce::parse_nonce; -use solana_sdk::program_pack::Pack; use solana_sdk::pubkey::Pubkey; +use spl_token::solana_program::program_pack::Pack; use spl_token::state::{Account, Mint}; use spl_token_2022::{ extension::StateWithExtensions, @@ -332,7 +332,7 @@ impl AccountEventParser { return Some(Box::new(event)); } } - let amount = if account.owner == spl_token_2022::ID { + let amount = if account.owner.to_bytes() == spl_token_2022::ID.to_bytes() { StateWithExtensions::::unpack(&account.data) .ok() .map(|info| info.base.amount) diff --git a/src/streaming/event_parser/core/event_parser.rs b/src/streaming/event_parser/core/event_parser.rs index c72935a..de133f1 100644 --- a/src/streaming/event_parser/core/event_parser.rs +++ b/src/streaming/event_parser/core/event_parser.rs @@ -23,10 +23,7 @@ use crate::streaming::{ }, }; use prost_types::Timestamp; -use solana_sdk::{ - bs58, instruction::CompiledInstruction, pubkey::Pubkey, signature::Signature, - transaction::VersionedTransaction, -}; +use solana_sdk::{bs58, message::compiled_instruction::CompiledInstruction, pubkey::Pubkey, signature::Signature, transaction::VersionedTransaction}; use solana_transaction_status::{ EncodedConfirmedTransactionWithStatusMeta, InnerInstruction, InnerInstructions, UiInstruction, }; diff --git a/src/streaming/grpc/types.rs b/src/streaming/grpc/types.rs index db7fe1c..6abfca3 100644 --- a/src/streaming/grpc/types.rs +++ b/src/streaming/grpc/types.rs @@ -1,5 +1,4 @@ use solana_sdk::{pubkey::Pubkey, signature::Signature}; -use solana_transaction_status::{TransactionWithStatusMeta, VersionedTransactionWithStatusMeta}; use std::{collections::HashMap, fmt}; use yellowstone_grpc_proto::{ geyser::{ diff --git a/src/streaming/yellowstone_sub_system.rs b/src/streaming/yellowstone_sub_system.rs index 32c2393..74a3696 100755 --- a/src/streaming/yellowstone_sub_system.rs +++ b/src/streaming/yellowstone_sub_system.rs @@ -8,8 +8,8 @@ use crate::{ use futures::{SinkExt, StreamExt}; use log::error; use solana_program::pubkey; -use solana_sdk::{pubkey::Pubkey, transaction::VersionedTransaction}; -use solana_transaction_status::TransactionWithStatusMeta; +use solana_sdk::pubkey::Pubkey; +use yellowstone_grpc_proto::geyser::SubscribeUpdateTransactionInfo; use yellowstone_grpc_proto::geyser::{ subscribe_update::UpdateOneof, SubscribeRequest, SubscribeRequestPing, }; @@ -26,7 +26,7 @@ pub enum SystemEvent { pub struct TransferInfo { pub slot: u64, pub signature: String, - pub tx: Option, + pub tx: Option, } impl YellowstoneGrpc { @@ -100,22 +100,11 @@ impl YellowstoneGrpc { { match event_pretty { EventPretty::Transaction(transaction_pretty) => { - let tx = yellowstone_grpc_proto::convert_from::create_tx_with_meta( - transaction_pretty.grpc_tx, - ); - if let Ok(tx) = tx { - let trade_raw: TransactionWithStatusMeta = tx; - let meta = trade_raw.get_status_meta(); - if meta.is_none() { - return Ok(()); - } - let transaction = trade_raw.get_transaction(); - callback(SystemEvent::NewTransfer(TransferInfo { - slot: transaction_pretty.slot, - signature: transaction_pretty.signature.to_string(), - tx: Some(transaction), - })); - } + callback(SystemEvent::NewTransfer(TransferInfo { + slot: transaction_pretty.slot, + signature: transaction_pretty.signature.to_string(), + tx: Some(transaction_pretty.grpc_tx), + })); } _ => {} }