Skip to content

Commit

Permalink
upgrade to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
segfaultdoc committed Aug 20, 2024
1 parent b910bbe commit 341f4ca
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 563 deletions.
883 changes: 342 additions & 541 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ members = [
resolver = "2"

[workspace.package]
version = "1.18.1"
version = "2.0.5"
license = "Apache-2.0"
authors = ["Jito Foundation <[email protected]>"]
edition = "2021"
repository = "https://github.com/jito-foundation/geyser-grpc-plugin"
homepage = "https://jito.network/"

[workspace.dependencies]
agave-geyser-plugin-interface = "=2.0.5"
bincode = "1.3.3"
bs58 = "0.5.0"
clap = { version = "4.4.6", features = ["derive", "env"] }
crossbeam-channel = "0.5.8"
enum-iterator = "1.4.1"
futures-util = "0.3.28"
geyser-grpc-plugin-client = { path = "client", version = "=1.18.1" }
jito-geyser-protos = { path = "proto", version = "=1.18.1" }
geyser-grpc-plugin-client = { path = "client", version = "=2.0.5" }
jito-geyser-protos = { path = "proto", version = "=2.0.5" }
log = "0.4.17"
lru = "0.12.0"
once_cell = "1.17.1"
Expand All @@ -36,14 +37,13 @@ rand = "0.8"
serde = "1.0.160"
serde_derive = "1.0.160"
serde_json = "1.0.96"
solana-account-decoder = "=1.18.1"
solana-geyser-plugin-interface = "=1.18.1"
solana-logger = "=1.18.1"
solana-metrics = "=1.18.1"
solana-program = "=1.18.1"
solana-sdk = "=1.18.1"
solana-transaction-status = "=1.18.1"
solana-vote-program = "=1.18.1"
solana-account-decoder = "=2.0.5"
solana-logger = "=2.0.5"
solana-metrics = "=2.0.5"
solana-program = "=2.0.5"
solana-sdk = "=2.0.5"
solana-transaction-status = "=2.0.5"
solana-vote-program = "=2.0.5"
thiserror = "1.0.40"
tokio = { version = "1", features = ["rt-multi-thread"] }
tokio-stream = "0.1"
Expand Down
6 changes: 6 additions & 0 deletions proto/proto/confirmed_block.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ message ConfirmedBlock {
repeated Reward rewards = 5;
UnixTimestamp block_time = 6;
BlockHeight block_height = 7;
NumPartitions num_partitions = 8;
}

message ConfirmedTransaction {
Expand Down Expand Up @@ -139,3 +140,8 @@ message UnixTimestamp {
message BlockHeight {
uint64 block_height = 1;
}

message NumPartitions {
uint64 num_partitions = 1;
}

1 change: 1 addition & 0 deletions proto/proto/transaction_by_addr.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum TransactionErrorType {
RESANITIZATION_NEEDED = 34;
PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35;
UNBALANCED_TRANSACTION = 36;
PROGRAM_CACHE_HIT_MAX_LIMIT = 37;
}

message InstructionError {
Expand Down
14 changes: 10 additions & 4 deletions proto/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ impl From<VersionedConfirmedBlock> for confirmed_block::ConfirmedBlock {
rewards,
block_time,
block_height,
num_partitions,
} = confirmed_block;

Self {
Expand All @@ -129,15 +130,15 @@ impl From<VersionedConfirmedBlock> for confirmed_block::ConfirmedBlock {
block_time: block_time.map(|timestamp| confirmed_block::UnixTimestamp { timestamp }),
block_height: block_height
.map(|block_height| confirmed_block::BlockHeight { block_height }),
num_partitions: num_partitions
.map(|num_partitions| confirmed_block::NumPartitions { num_partitions }),
}
}
}

impl TryFrom<confirmed_block::ConfirmedBlock> for ConfirmedBlock {
type Error = bincode::Error;
fn try_from(
confirmed_block: confirmed_block::ConfirmedBlock,
) -> std::result::Result<Self, Self::Error> {
fn try_from(confirmed_block: confirmed_block::ConfirmedBlock) -> Result<Self, Self::Error> {
let confirmed_block::ConfirmedBlock {
previous_blockhash,
blockhash,
Expand All @@ -146,6 +147,7 @@ impl TryFrom<confirmed_block::ConfirmedBlock> for ConfirmedBlock {
rewards,
block_time,
block_height,
num_partitions,
} = confirmed_block;

Ok(Self {
Expand All @@ -155,11 +157,12 @@ impl TryFrom<confirmed_block::ConfirmedBlock> for ConfirmedBlock {
transactions: transactions
.into_iter()
.map(|tx| tx.try_into())
.collect::<std::result::Result<Vec<_>, Self::Error>>()?,
.collect::<Result<Vec<_>, Self::Error>>()?,
rewards: rewards.into_iter().map(|r| r.into()).collect(),
block_time: block_time.map(|confirmed_block::UnixTimestamp { timestamp }| timestamp),
block_height: block_height
.map(|confirmed_block::BlockHeight { block_height }| block_height),
num_partitions: num_partitions.map(|num_partitions| num_partitions.num_partitions),
})
}
}
Expand Down Expand Up @@ -926,6 +929,9 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
TransactionError::UnbalancedTransaction => {
tx_by_addr::TransactionErrorType::UnbalancedTransaction
}
TransactionError::ProgramCacheHitMaxLimit => {
tx_by_addr::TransactionErrorType::ProgramCacheHitMaxLimit
}
} as i32,
instruction_error: match transaction_error {
TransactionError::InstructionError(index, ref instruction_error) => {
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = { workspace = true }
crate-type = ["cdylib", "rlib"]

[dependencies]
agave-geyser-plugin-interface = { workspace = true }
bs58 = { workspace = true }
crossbeam-channel = { workspace = true }
futures-util = { workspace = true }
Expand All @@ -20,7 +21,6 @@ prost-types = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
solana-geyser-plugin-interface = { workspace = true }
solana-logger = { workspace = true }
solana-metrics = { workspace = true }
solana-program = { workspace = true }
Expand Down
28 changes: 24 additions & 4 deletions server/src/geyser_grpc_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use std::{
time::SystemTime,
};

use agave_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoVersions, ReplicaBlockInfoVersions,
ReplicaTransactionInfoVersions, Result as PluginResult, SlotStatus,
};
use bs58;
use crossbeam_channel::{bounded, Sender, TrySendError};
use jito_geyser_protos::solana::{
Expand All @@ -24,10 +28,6 @@ use jito_geyser_protos::solana::{
use log::*;
use serde_derive::Deserialize;
use serde_json;
use solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoVersions, ReplicaBlockInfoVersions,
ReplicaTransactionInfoVersions, Result as PluginResult, SlotStatus,
};
use tokio::{runtime::Runtime, sync::oneshot};
use tonic::{
service::{interceptor::InterceptedService, Interceptor},
Expand Down Expand Up @@ -445,6 +445,26 @@ impl GeyserPlugin for GeyserGrpcPlugin {
entry_count: Some(block.entry_count),
}),
},
ReplicaBlockInfoVersions::V0_0_4(block) => TimestampedBlockUpdate {
ts: Some(prost_types::Timestamp::from(SystemTime::now())),
block_update: Some(BlockUpdate {
slot: block.slot,
blockhash: block.blockhash.to_string(),
rewards: block
.rewards
.rewards
.iter()
.map(|r| (*r).clone().into())
.collect(),
block_time: block.block_time.map(|t| prost_types::Timestamp {
seconds: t,
nanos: 0,
}),
block_height: block.block_height,
executed_transaction_count: Some(block.executed_transaction_count),
entry_count: Some(block.entry_count),
}),
},
};
match data.block_update_sender.try_send(block) {
Ok(_) => Ok(()),
Expand Down
4 changes: 2 additions & 2 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod server;
pub(crate) mod subscription_stream;

#[cfg(not(feature = "jito-solana"))]
extern crate solana_geyser_plugin_interface;
extern crate agave_geyser_plugin_interface;
#[cfg(not(feature = "jito-solana"))]
extern crate solana_logger;
#[cfg(not(feature = "jito-solana"))]
Expand All @@ -16,7 +16,7 @@ extern crate solana_sdk;
extern crate solana_vote_program;

#[cfg(feature = "jito-solana")]
extern crate jito_solana_geyser_plugin_interface as solana_geyser_plugin_interface;
extern crate jito_solana_geyser_plugin_interface as agave_geyser_plugin_interface;
#[cfg(feature = "jito-solana")]
extern crate jito_solana_logger as solana_logger;
#[cfg(feature = "jito-solana")]
Expand Down

0 comments on commit 341f4ca

Please sign in to comment.