mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-22 13:28:08 +00:00
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
This commit is contained in:
+20
-18
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-streamer-sdk"
|
name = "solana-streamer-sdk"
|
||||||
version = "0.4.13"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||||
repository = "https://github.com/0xfnzero/solana-streamer"
|
repository = "https://github.com/0xfnzero/solana-streamer"
|
||||||
@@ -13,18 +13,18 @@ readme = "README.md"
|
|||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
solana-sdk = "2.3.0"
|
solana-sdk = "3.0.0"
|
||||||
solana-client = "2.3.6"
|
solana-client = "3.0.0"
|
||||||
solana-program = "2.3.0"
|
solana-program = "3.0.0"
|
||||||
solana-rpc-client = "2.3.6"
|
solana-rpc-client = "3.0.0"
|
||||||
solana-rpc-client-api = "2.3.6"
|
solana-rpc-client-api = "3.0.0"
|
||||||
solana-transaction-status = "2.3.6"
|
solana-transaction-status = "3.0.0"
|
||||||
solana-account-decoder = "2.3.6"
|
solana-account-decoder = "3.0.0"
|
||||||
solana-hash = "2.3.0"
|
solana-hash = "3.0.0"
|
||||||
solana-entry = "2.3.6"
|
solana-entry = "3.0.0"
|
||||||
solana-rpc-client-nonce-utils = "2.3.6"
|
solana-rpc-client-nonce-utils = "3.0.0"
|
||||||
solana-perf = "2.3.6"
|
solana-perf = "3.0.0"
|
||||||
solana-metrics = "2.3.6"
|
solana-metrics = "3.0.0"
|
||||||
spl-associated-token-account = "7.0.0"
|
spl-associated-token-account = "7.0.0"
|
||||||
borsh = { version = "1.5.3", features = ["derive"] }
|
borsh = { version = "1.5.3", features = ["derive"] }
|
||||||
serde = { version = "1.0.215", features = ["derive"] }
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
@@ -36,10 +36,10 @@ base64 = "0.22.1"
|
|||||||
rand = "0.9.0"
|
rand = "0.9.0"
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
anyhow = "1.0.90"
|
anyhow = "1.0.90"
|
||||||
yellowstone-grpc-client = { version = "8.0.0" }
|
yellowstone-grpc-client = { version = "9.0.0" }
|
||||||
yellowstone-grpc-proto = { version = "8.0.0" }
|
yellowstone-grpc-proto = { version = "9.0.0" }
|
||||||
tokio = { version = "1.42.0", features = ["full", "rt-multi-thread"]}
|
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 = { version = "0.23.23", features = ["ring"], default-features = false }
|
||||||
rustls-native-certs = "0.8.1"
|
rustls-native-certs = "0.8.1"
|
||||||
tokio-rustls = "0.26.1"
|
tokio-rustls = "0.26.1"
|
||||||
@@ -52,8 +52,8 @@ async-trait = "0.1.86"
|
|||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
once_cell = "1.20.3"
|
once_cell = "1.20.3"
|
||||||
dashmap = "6.0.1"
|
dashmap = "6.0.1"
|
||||||
prost = "0.13.5"
|
prost = "0.14.1"
|
||||||
prost-types = "0.13.5"
|
prost-types = "0.14.1"
|
||||||
num_enum = "0.7.3"
|
num_enum = "0.7.3"
|
||||||
num-derive = "0.4.2"
|
num-derive = "0.4.2"
|
||||||
num-traits = "0.2.19"
|
num-traits = "0.2.19"
|
||||||
@@ -70,6 +70,8 @@ parking_lot = "0.12.1"
|
|||||||
wide = "0.7"
|
wide = "0.7"
|
||||||
spl-token = "8.0.0"
|
spl-token = "8.0.0"
|
||||||
spl-token-2022 = "9.0.0"
|
spl-token-2022 = "9.0.0"
|
||||||
|
solana-commitment-config = { version = "3.0.0", features = ["serde"] }
|
||||||
|
tonic-prost = "0.14.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = { version = "0.5", features = ["html_reports"] }
|
criterion = { version = "0.5", features = ["html_reports"] }
|
||||||
@@ -108,14 +108,14 @@ Add the dependency to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.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
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = "0.4.13"
|
solana-streamer-sdk = "0.5.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## ⚙️ Configuration System
|
## ⚙️ Configuration System
|
||||||
|
|||||||
+2
-2
@@ -107,14 +107,14 @@ git clone https://github.com/0xfnzero/solana-streamer
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.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
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = "0.4.13"
|
solana-streamer-sdk = "0.5.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## ⚙️ 配置系统
|
## ⚙️ 配置系统
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
use anyhow::Result;
|
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::core::event_parser::EventParser;
|
||||||
use solana_streamer_sdk::streaming::event_parser::Protocol;
|
use solana_streamer_sdk::streaming::event_parser::Protocol;
|
||||||
use solana_streamer_sdk::streaming::event_parser::UnifiedEvent;
|
use solana_streamer_sdk::streaming::event_parser::UnifiedEvent;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Get transaction data based on transaction signature
|
/// Get transaction data based on transaction signature
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|||||||
Executable → Regular
+3
-3
@@ -1,15 +1,15 @@
|
|||||||
// This file is @generated by prost-build.
|
// This file is @generated by prost-build.
|
||||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
#[prost(message, optional, tag = "1")]
|
#[prost(message, optional, tag = "1")]
|
||||||
pub ts: ::core::option::Option<::prost_types::Timestamp>,
|
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 {
|
pub struct Heartbeat {
|
||||||
#[prost(uint64, tag = "1")]
|
#[prost(uint64, tag = "1")]
|
||||||
pub count: u64,
|
pub count: u64,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct Socket {
|
pub struct Socket {
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub ip: ::prost::alloc::string::String,
|
pub ip: ::prost::alloc::string::String,
|
||||||
|
|||||||
Executable → Regular
+387
-15
@@ -1,5 +1,5 @@
|
|||||||
// This file is @generated by prost-build.
|
// This file is @generated by prost-build.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct Heartbeat {
|
pub struct Heartbeat {
|
||||||
/// don't trust IP:PORT from tcp header since it can be tampered over the wire
|
/// 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
|
/// `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")]
|
#[prost(string, repeated, tag = "2")]
|
||||||
pub regions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
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 {
|
pub struct HeartbeatResponse {
|
||||||
/// client must respond within `ttl_ms` to keep stream alive
|
/// client must respond within `ttl_ms` to keep stream alive
|
||||||
#[prost(uint32, tag = "1")]
|
#[prost(uint32, tag = "1")]
|
||||||
pub ttl_ms: u32,
|
pub ttl_ms: u32,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct TraceShred {
|
pub struct TraceShred {
|
||||||
/// source region, one of: <https://docs.jito.wtf/lowlatencytxnsend/#api>
|
/// source region, one of: <https://docs.jito.wtf/lowlatencytxnsend/#api>
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
@@ -29,9 +29,9 @@ pub struct TraceShred {
|
|||||||
pub seq_num: u32,
|
pub seq_num: u32,
|
||||||
}
|
}
|
||||||
/// tbd: we may want to add filters here
|
/// 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 {}
|
pub struct SubscribeEntriesRequest {}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
/// the slot that the entry is from
|
/// the slot that the entry is from
|
||||||
#[prost(uint64, tag = "1")]
|
#[prost(uint64, tag = "1")]
|
||||||
@@ -68,7 +68,7 @@ pub mod shredstream_client {
|
|||||||
}
|
}
|
||||||
impl<T> ShredstreamClient<T>
|
impl<T> ShredstreamClient<T>
|
||||||
where
|
where
|
||||||
T: tonic::client::GrpcService<tonic::body::BoxBody>,
|
T: tonic::client::GrpcService<tonic::body::Body>,
|
||||||
T::Error: Into<StdError>,
|
T::Error: Into<StdError>,
|
||||||
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
||||||
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
||||||
@@ -89,13 +89,13 @@ pub mod shredstream_client {
|
|||||||
F: tonic::service::Interceptor,
|
F: tonic::service::Interceptor,
|
||||||
T::ResponseBody: Default,
|
T::ResponseBody: Default,
|
||||||
T: tonic::codegen::Service<
|
T: tonic::codegen::Service<
|
||||||
http::Request<tonic::body::BoxBody>,
|
http::Request<tonic::body::Body>,
|
||||||
Response = http::Response<
|
Response = http::Response<
|
||||||
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
|
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
<T as tonic::codegen::Service<
|
<T as tonic::codegen::Service<
|
||||||
http::Request<tonic::body::BoxBody>,
|
http::Request<tonic::body::Body>,
|
||||||
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||||
{
|
{
|
||||||
ShredstreamClient::new(InterceptedService::new(inner, interceptor))
|
ShredstreamClient::new(InterceptedService::new(inner, interceptor))
|
||||||
@@ -147,7 +147,7 @@ pub mod shredstream_client {
|
|||||||
format!("Service was not ready: {}", e.into()),
|
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(
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
"/shredstream.Shredstream/SendHeartbeat",
|
"/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<super::Heartbeat>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::HeartbeatResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ShredstreamServer<T> {
|
||||||
|
inner: Arc<T>,
|
||||||
|
accept_compression_encodings: EnabledCompressionEncodings,
|
||||||
|
send_compression_encodings: EnabledCompressionEncodings,
|
||||||
|
max_decoding_message_size: Option<usize>,
|
||||||
|
max_encoding_message_size: Option<usize>,
|
||||||
|
}
|
||||||
|
impl<T> ShredstreamServer<T> {
|
||||||
|
pub fn new(inner: T) -> Self {
|
||||||
|
Self::from_arc(Arc::new(inner))
|
||||||
|
}
|
||||||
|
pub fn from_arc(inner: Arc<T>) -> 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<F>(
|
||||||
|
inner: T,
|
||||||
|
interceptor: F,
|
||||||
|
) -> InterceptedService<Self, F>
|
||||||
|
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<T, B> tonic::codegen::Service<http::Request<B>> for ShredstreamServer<T>
|
||||||
|
where
|
||||||
|
T: Shredstream,
|
||||||
|
B: Body + std::marker::Send + 'static,
|
||||||
|
B::Error: Into<StdError> + std::marker::Send + 'static,
|
||||||
|
{
|
||||||
|
type Response = http::Response<tonic::body::Body>;
|
||||||
|
type Error = std::convert::Infallible;
|
||||||
|
type Future = BoxFuture<Self::Response, Self::Error>;
|
||||||
|
fn poll_ready(
|
||||||
|
&mut self,
|
||||||
|
_cx: &mut Context<'_>,
|
||||||
|
) -> Poll<std::result::Result<(), Self::Error>> {
|
||||||
|
Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||||
|
match req.uri().path() {
|
||||||
|
"/shredstream.Shredstream/SendHeartbeat" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct SendHeartbeatSvc<T: Shredstream>(pub Arc<T>);
|
||||||
|
impl<T: Shredstream> tonic::server::UnaryService<super::Heartbeat>
|
||||||
|
for SendHeartbeatSvc<T> {
|
||||||
|
type Response = super::HeartbeatResponse;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::Response>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<super::Heartbeat>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as Shredstream>::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<T> Clone for ShredstreamServer<T> {
|
||||||
|
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<T> tonic::server::NamedService for ShredstreamServer<T> {
|
||||||
|
const NAME: &'static str = SERVICE_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// Generated client implementations.
|
/// Generated client implementations.
|
||||||
pub mod shredstream_proxy_client {
|
pub mod shredstream_proxy_client {
|
||||||
#![allow(
|
#![allow(
|
||||||
@@ -186,7 +367,7 @@ pub mod shredstream_proxy_client {
|
|||||||
}
|
}
|
||||||
impl<T> ShredstreamProxyClient<T>
|
impl<T> ShredstreamProxyClient<T>
|
||||||
where
|
where
|
||||||
T: tonic::client::GrpcService<tonic::body::BoxBody>,
|
T: tonic::client::GrpcService<tonic::body::Body>,
|
||||||
T::Error: Into<StdError>,
|
T::Error: Into<StdError>,
|
||||||
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
||||||
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
||||||
@@ -207,13 +388,13 @@ pub mod shredstream_proxy_client {
|
|||||||
F: tonic::service::Interceptor,
|
F: tonic::service::Interceptor,
|
||||||
T::ResponseBody: Default,
|
T::ResponseBody: Default,
|
||||||
T: tonic::codegen::Service<
|
T: tonic::codegen::Service<
|
||||||
http::Request<tonic::body::BoxBody>,
|
http::Request<tonic::body::Body>,
|
||||||
Response = http::Response<
|
Response = http::Response<
|
||||||
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
|
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
<T as tonic::codegen::Service<
|
<T as tonic::codegen::Service<
|
||||||
http::Request<tonic::body::BoxBody>,
|
http::Request<tonic::body::Body>,
|
||||||
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||||
{
|
{
|
||||||
ShredstreamProxyClient::new(InterceptedService::new(inner, interceptor))
|
ShredstreamProxyClient::new(InterceptedService::new(inner, interceptor))
|
||||||
@@ -264,7 +445,7 @@ pub mod shredstream_proxy_client {
|
|||||||
format!("Service was not ready: {}", e.into()),
|
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(
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
"/shredstream.ShredstreamProxy/SubscribeEntries",
|
"/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<super::Entry, tonic::Status>,
|
||||||
|
>
|
||||||
|
+ std::marker::Send
|
||||||
|
+ 'static;
|
||||||
|
async fn subscribe_entries(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<super::SubscribeEntriesRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<Self::SubscribeEntriesStream>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ShredstreamProxyServer<T> {
|
||||||
|
inner: Arc<T>,
|
||||||
|
accept_compression_encodings: EnabledCompressionEncodings,
|
||||||
|
send_compression_encodings: EnabledCompressionEncodings,
|
||||||
|
max_decoding_message_size: Option<usize>,
|
||||||
|
max_encoding_message_size: Option<usize>,
|
||||||
|
}
|
||||||
|
impl<T> ShredstreamProxyServer<T> {
|
||||||
|
pub fn new(inner: T) -> Self {
|
||||||
|
Self::from_arc(Arc::new(inner))
|
||||||
|
}
|
||||||
|
pub fn from_arc(inner: Arc<T>) -> 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<F>(
|
||||||
|
inner: T,
|
||||||
|
interceptor: F,
|
||||||
|
) -> InterceptedService<Self, F>
|
||||||
|
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<T, B> tonic::codegen::Service<http::Request<B>> for ShredstreamProxyServer<T>
|
||||||
|
where
|
||||||
|
T: ShredstreamProxy,
|
||||||
|
B: Body + std::marker::Send + 'static,
|
||||||
|
B::Error: Into<StdError> + std::marker::Send + 'static,
|
||||||
|
{
|
||||||
|
type Response = http::Response<tonic::body::Body>;
|
||||||
|
type Error = std::convert::Infallible;
|
||||||
|
type Future = BoxFuture<Self::Response, Self::Error>;
|
||||||
|
fn poll_ready(
|
||||||
|
&mut self,
|
||||||
|
_cx: &mut Context<'_>,
|
||||||
|
) -> Poll<std::result::Result<(), Self::Error>> {
|
||||||
|
Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||||
|
match req.uri().path() {
|
||||||
|
"/shredstream.ShredstreamProxy/SubscribeEntries" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct SubscribeEntriesSvc<T: ShredstreamProxy>(pub Arc<T>);
|
||||||
|
impl<
|
||||||
|
T: ShredstreamProxy,
|
||||||
|
> tonic::server::ServerStreamingService<
|
||||||
|
super::SubscribeEntriesRequest,
|
||||||
|
> for SubscribeEntriesSvc<T> {
|
||||||
|
type Response = super::Entry;
|
||||||
|
type ResponseStream = T::SubscribeEntriesStream;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::ResponseStream>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<super::SubscribeEntriesRequest>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as ShredstreamProxy>::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<T> Clone for ShredstreamProxyServer<T> {
|
||||||
|
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<T> tonic::server::NamedService for ShredstreamProxyServer<T> {
|
||||||
|
const NAME: &'static str = SERVICE_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ use crate::streaming::event_parser::Protocol;
|
|||||||
use crate::streaming::grpc::AccountPretty;
|
use crate::streaming::grpc::AccountPretty;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_account_decoder::parse_nonce::parse_nonce;
|
use solana_account_decoder::parse_nonce::parse_nonce;
|
||||||
use solana_sdk::program_pack::Pack;
|
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
use spl_token::solana_program::program_pack::Pack;
|
||||||
use spl_token::state::{Account, Mint};
|
use spl_token::state::{Account, Mint};
|
||||||
use spl_token_2022::{
|
use spl_token_2022::{
|
||||||
extension::StateWithExtensions,
|
extension::StateWithExtensions,
|
||||||
@@ -332,7 +332,7 @@ impl AccountEventParser {
|
|||||||
return Some(Box::new(event));
|
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::<Account2022>::unpack(&account.data)
|
StateWithExtensions::<Account2022>::unpack(&account.data)
|
||||||
.ok()
|
.ok()
|
||||||
.map(|info| info.base.amount)
|
.map(|info| info.base.amount)
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ use crate::streaming::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use prost_types::Timestamp;
|
use prost_types::Timestamp;
|
||||||
use solana_sdk::{
|
use solana_sdk::{bs58, message::compiled_instruction::CompiledInstruction, pubkey::Pubkey, signature::Signature, transaction::VersionedTransaction};
|
||||||
bs58, instruction::CompiledInstruction, pubkey::Pubkey, signature::Signature,
|
|
||||||
transaction::VersionedTransaction,
|
|
||||||
};
|
|
||||||
use solana_transaction_status::{
|
use solana_transaction_status::{
|
||||||
EncodedConfirmedTransactionWithStatusMeta, InnerInstruction, InnerInstructions, UiInstruction,
|
EncodedConfirmedTransactionWithStatusMeta, InnerInstruction, InnerInstructions, UiInstruction,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use solana_sdk::{pubkey::Pubkey, signature::Signature};
|
use solana_sdk::{pubkey::Pubkey, signature::Signature};
|
||||||
use solana_transaction_status::{TransactionWithStatusMeta, VersionedTransactionWithStatusMeta};
|
|
||||||
use std::{collections::HashMap, fmt};
|
use std::{collections::HashMap, fmt};
|
||||||
use yellowstone_grpc_proto::{
|
use yellowstone_grpc_proto::{
|
||||||
geyser::{
|
geyser::{
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ use crate::{
|
|||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use log::error;
|
use log::error;
|
||||||
use solana_program::pubkey;
|
use solana_program::pubkey;
|
||||||
use solana_sdk::{pubkey::Pubkey, transaction::VersionedTransaction};
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_transaction_status::TransactionWithStatusMeta;
|
use yellowstone_grpc_proto::geyser::SubscribeUpdateTransactionInfo;
|
||||||
use yellowstone_grpc_proto::geyser::{
|
use yellowstone_grpc_proto::geyser::{
|
||||||
subscribe_update::UpdateOneof, SubscribeRequest, SubscribeRequestPing,
|
subscribe_update::UpdateOneof, SubscribeRequest, SubscribeRequestPing,
|
||||||
};
|
};
|
||||||
@@ -26,7 +26,7 @@ pub enum SystemEvent {
|
|||||||
pub struct TransferInfo {
|
pub struct TransferInfo {
|
||||||
pub slot: u64,
|
pub slot: u64,
|
||||||
pub signature: String,
|
pub signature: String,
|
||||||
pub tx: Option<VersionedTransaction>,
|
pub tx: Option<SubscribeUpdateTransactionInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl YellowstoneGrpc {
|
impl YellowstoneGrpc {
|
||||||
@@ -100,22 +100,11 @@ impl YellowstoneGrpc {
|
|||||||
{
|
{
|
||||||
match event_pretty {
|
match event_pretty {
|
||||||
EventPretty::Transaction(transaction_pretty) => {
|
EventPretty::Transaction(transaction_pretty) => {
|
||||||
let tx = yellowstone_grpc_proto::convert_from::create_tx_with_meta(
|
callback(SystemEvent::NewTransfer(TransferInfo {
|
||||||
transaction_pretty.grpc_tx,
|
slot: transaction_pretty.slot,
|
||||||
);
|
signature: transaction_pretty.signature.to_string(),
|
||||||
if let Ok(tx) = tx {
|
tx: Some(transaction_pretty.grpc_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),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user