Skip to content

Commit cb50f64

Browse files
committed
upgrade to 2.0
1 parent b910bbe commit cb50f64

File tree

11 files changed

+474
-569
lines changed

11 files changed

+474
-569
lines changed

Cargo.lock

Lines changed: 342 additions & 541 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ members = [
1010
resolver = "2"
1111

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

2020
[workspace.dependencies]
21+
agave-geyser-plugin-interface = "=2.0.5"
2122
bincode = "1.3.3"
2223
bs58 = "0.5.0"
2324
clap = { version = "4.4.6", features = ["derive", "env"] }
2425
crossbeam-channel = "0.5.8"
2526
enum-iterator = "1.4.1"
2627
futures-util = "0.3.28"
27-
geyser-grpc-plugin-client = { path = "client", version = "=1.18.1" }
28-
jito-geyser-protos = { path = "proto", version = "=1.18.1" }
28+
geyser-grpc-plugin-client = { path = "client", version = "=2.0.5" }
29+
jito-geyser-protos = { path = "proto", version = "=2.0.5" }
2930
log = "0.4.17"
3031
lru = "0.12.0"
3132
once_cell = "1.17.1"
@@ -36,14 +37,13 @@ rand = "0.8"
3637
serde = "1.0.160"
3738
serde_derive = "1.0.160"
3839
serde_json = "1.0.96"
39-
solana-account-decoder = "=1.18.1"
40-
solana-geyser-plugin-interface = "=1.18.1"
41-
solana-logger = "=1.18.1"
42-
solana-metrics = "=1.18.1"
43-
solana-program = "=1.18.1"
44-
solana-sdk = "=1.18.1"
45-
solana-transaction-status = "=1.18.1"
46-
solana-vote-program = "=1.18.1"
40+
solana-account-decoder = "=2.0.5"
41+
solana-logger = "=2.0.5"
42+
solana-metrics = "=2.0.5"
43+
solana-program = "=2.0.5"
44+
solana-sdk = "=2.0.5"
45+
solana-transaction-status = "=2.0.5"
46+
solana-vote-program = "=2.0.5"
4747
thiserror = "1.0.40"
4848
tokio = { version = "1", features = ["rt-multi-thread"] }
4949
tokio-stream = "0.1"

proto/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ fn main() {
1818
)
1919
.compile(
2020
&[
21-
"proto/geyser.proto",
2221
"proto/confirmed_block.proto",
22+
"proto/entries.proto",
23+
"proto/geyser.proto",
2324
"proto/transaction_by_addr.proto",
2425
],
2526
&["proto"],

proto/proto/confirmed_block.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ message ConfirmedBlock {
1010
repeated Reward rewards = 5;
1111
UnixTimestamp block_time = 6;
1212
BlockHeight block_height = 7;
13+
NumPartitions num_partitions = 8;
1314
}
1415

1516
message ConfirmedTransaction {
@@ -130,6 +131,7 @@ message Reward {
130131

131132
message Rewards {
132133
repeated Reward rewards = 1;
134+
NumPartitions num_partitions = 2;
133135
}
134136

135137
message UnixTimestamp {
@@ -139,3 +141,7 @@ message UnixTimestamp {
139141
message BlockHeight {
140142
uint64 block_height = 1;
141143
}
144+
145+
message NumPartitions {
146+
uint64 num_partitions = 1;
147+
}

proto/proto/entries.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package solana.storage.Entries;
4+
5+
message Entries {
6+
repeated Entry entries = 1;
7+
}
8+
9+
message Entry {
10+
uint32 index = 1;
11+
uint64 num_hashes = 2;
12+
bytes hash = 3;
13+
uint64 num_transactions = 4;
14+
uint32 starting_transaction_index = 5;
15+
}

proto/proto/transaction_by_addr.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum TransactionErrorType {
6262
RESANITIZATION_NEEDED = 34;
6363
PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 35;
6464
UNBALANCED_TRANSACTION = 36;
65+
PROGRAM_CACHE_HIT_MAX_LIMIT = 37;
6566
}
6667

6768
message InstructionError {

proto/src/convert.rs

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//! Note: most of this copied from solana labs storage-proto files, with the addition of the module definitions below
21
use std::{
32
convert::{TryFrom, TryInto},
43
str::FromStr,
@@ -19,21 +18,28 @@ use solana_sdk::{
1918
transaction_context::TransactionReturnData,
2019
};
2120
use solana_transaction_status::{
22-
ConfirmedBlock, InnerInstruction, InnerInstructions, Reward, RewardType, TransactionByAddrInfo,
23-
TransactionStatusMeta, TransactionTokenBalance, TransactionWithStatusMeta,
24-
VersionedConfirmedBlock, VersionedTransactionWithStatusMeta,
21+
ConfirmedBlock, EntrySummary, InnerInstruction, InnerInstructions, Reward, RewardType,
22+
RewardsAndNumPartitions, TransactionByAddrInfo, TransactionStatusMeta, TransactionTokenBalance,
23+
TransactionWithStatusMeta, VersionedConfirmedBlock, VersionedTransactionWithStatusMeta,
2524
};
2625

26+
use crate::solana::{entries, tx_by_addr};
2727
use crate::{solana::storage::confirmed_block, StoredExtendedRewards, StoredTransactionStatusMeta};
2828

29-
pub mod tx_by_addr {
30-
tonic::include_proto!("solana.storage.transaction_by_addr");
31-
}
32-
3329
impl From<Vec<Reward>> for confirmed_block::Rewards {
3430
fn from(rewards: Vec<Reward>) -> Self {
3531
Self {
3632
rewards: rewards.into_iter().map(|r| r.into()).collect(),
33+
num_partitions: None,
34+
}
35+
}
36+
}
37+
38+
impl From<RewardsAndNumPartitions> for confirmed_block::Rewards {
39+
fn from(input: RewardsAndNumPartitions) -> Self {
40+
Self {
41+
rewards: input.rewards.into_iter().map(|r| r.into()).collect(),
42+
num_partitions: input.num_partitions.map(|n| n.into()),
3743
}
3844
}
3945
}
@@ -44,6 +50,17 @@ impl From<confirmed_block::Rewards> for Vec<Reward> {
4450
}
4551
}
4652

53+
impl From<confirmed_block::Rewards> for (Vec<Reward>, Option<u64>) {
54+
fn from(rewards: confirmed_block::Rewards) -> Self {
55+
(
56+
rewards.rewards.into_iter().map(|r| r.into()).collect(),
57+
rewards
58+
.num_partitions
59+
.map(|confirmed_block::NumPartitions { num_partitions }| num_partitions),
60+
)
61+
}
62+
}
63+
4764
impl From<StoredExtendedRewards> for confirmed_block::Rewards {
4865
fn from(rewards: StoredExtendedRewards) -> Self {
4966
Self {
@@ -54,6 +71,7 @@ impl From<StoredExtendedRewards> for confirmed_block::Rewards {
5471
r.into()
5572
})
5673
.collect(),
74+
num_partitions: None,
5775
}
5876
}
5977
}
@@ -108,6 +126,12 @@ impl From<confirmed_block::Reward> for Reward {
108126
}
109127
}
110128

129+
impl From<u64> for confirmed_block::NumPartitions {
130+
fn from(num_partitions: u64) -> Self {
131+
Self { num_partitions }
132+
}
133+
}
134+
111135
impl From<VersionedConfirmedBlock> for confirmed_block::ConfirmedBlock {
112136
fn from(confirmed_block: VersionedConfirmedBlock) -> Self {
113137
let VersionedConfirmedBlock {
@@ -116,6 +140,7 @@ impl From<VersionedConfirmedBlock> for confirmed_block::ConfirmedBlock {
116140
parent_slot,
117141
transactions,
118142
rewards,
143+
num_partitions,
119144
block_time,
120145
block_height,
121146
} = confirmed_block;
@@ -126,6 +151,7 @@ impl From<VersionedConfirmedBlock> for confirmed_block::ConfirmedBlock {
126151
parent_slot,
127152
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
128153
rewards: rewards.into_iter().map(|r| r.into()).collect(),
154+
num_partitions: num_partitions.map(Into::into),
129155
block_time: block_time.map(|timestamp| confirmed_block::UnixTimestamp { timestamp }),
130156
block_height: block_height
131157
.map(|block_height| confirmed_block::BlockHeight { block_height }),
@@ -144,6 +170,7 @@ impl TryFrom<confirmed_block::ConfirmedBlock> for ConfirmedBlock {
144170
parent_slot,
145171
transactions,
146172
rewards,
173+
num_partitions,
147174
block_time,
148175
block_height,
149176
} = confirmed_block;
@@ -157,6 +184,8 @@ impl TryFrom<confirmed_block::ConfirmedBlock> for ConfirmedBlock {
157184
.map(|tx| tx.try_into())
158185
.collect::<std::result::Result<Vec<_>, Self::Error>>()?,
159186
rewards: rewards.into_iter().map(|r| r.into()).collect(),
187+
num_partitions: num_partitions
188+
.map(|confirmed_block::NumPartitions { num_partitions }| num_partitions),
160189
block_time: block_time.map(|confirmed_block::UnixTimestamp { timestamp }| timestamp),
161190
block_height: block_height
162191
.map(|confirmed_block::BlockHeight { block_height }| block_height),
@@ -808,6 +837,7 @@ impl TryFrom<tx_by_addr::TransactionError> for TransactionError {
808837
33 => TransactionError::InvalidLoadedAccountsDataSizeLimit,
809838
34 => TransactionError::ResanitizationNeeded,
810839
36 => TransactionError::UnbalancedTransaction,
840+
37 => TransactionError::ProgramCacheHitMaxLimit,
811841
_ => return Err("Invalid TransactionError"),
812842
})
813843
}
@@ -926,6 +956,9 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
926956
TransactionError::UnbalancedTransaction => {
927957
tx_by_addr::TransactionErrorType::UnbalancedTransaction
928958
}
959+
TransactionError::ProgramCacheHitMaxLimit => {
960+
tx_by_addr::TransactionErrorType::ProgramCacheHitMaxLimit
961+
}
929962
} as i32,
930963
instruction_error: match transaction_error {
931964
TransactionError::InstructionError(index, ref instruction_error) => {
@@ -1184,6 +1217,29 @@ impl TryFrom<tx_by_addr::TransactionByAddr> for Vec<TransactionByAddrInfo> {
11841217
}
11851218
}
11861219

1220+
impl From<(usize, EntrySummary)> for entries::Entry {
1221+
fn from((index, entry_summary): (usize, EntrySummary)) -> Self {
1222+
entries::Entry {
1223+
index: index as u32,
1224+
num_hashes: entry_summary.num_hashes,
1225+
hash: entry_summary.hash.as_ref().into(),
1226+
num_transactions: entry_summary.num_transactions,
1227+
starting_transaction_index: entry_summary.starting_transaction_index as u32,
1228+
}
1229+
}
1230+
}
1231+
1232+
impl From<entries::Entry> for EntrySummary {
1233+
fn from(entry: entries::Entry) -> Self {
1234+
EntrySummary {
1235+
num_hashes: entry.num_hashes,
1236+
hash: Hash::new(&entry.hash),
1237+
num_transactions: entry.num_transactions,
1238+
starting_transaction_index: entry.starting_transaction_index as usize,
1239+
}
1240+
}
1241+
}
1242+
11871243
#[cfg(test)]
11881244
mod test {
11891245
use enum_iterator::all;

proto/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use solana_transaction_status::{
1616

1717
pub mod convert;
1818

19-
// NOTE: Jito Labs added
2019
pub mod solana {
2120
pub mod geyser {
2221
tonic::include_proto!("solana.geyser");
@@ -26,6 +25,12 @@ pub mod solana {
2625
tonic::include_proto!("solana.storage.confirmed_block");
2726
}
2827
}
28+
pub mod tx_by_addr {
29+
tonic::include_proto!("solana.storage.transaction_by_addr");
30+
}
31+
pub mod entries {
32+
tonic::include_proto!("solana.storage.entries");
33+
}
2934
}
3035

3136
pub type StoredExtendedRewards = Vec<StoredExtendedReward>;

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = { workspace = true }
99
crate-type = ["cdylib", "rlib"]
1010

1111
[dependencies]
12+
agave-geyser-plugin-interface = { workspace = true }
1213
bs58 = { workspace = true }
1314
crossbeam-channel = { workspace = true }
1415
futures-util = { workspace = true }
@@ -20,7 +21,6 @@ prost-types = { workspace = true }
2021
serde = { workspace = true }
2122
serde_derive = { workspace = true }
2223
serde_json = { workspace = true }
23-
solana-geyser-plugin-interface = { workspace = true }
2424
solana-logger = { workspace = true }
2525
solana-metrics = { workspace = true }
2626
solana-program = { workspace = true }

server/src/geyser_grpc_plugin.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ use std::{
1111
time::SystemTime,
1212
};
1313

14+
use agave_geyser_plugin_interface::geyser_plugin_interface::{
15+
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoVersions, ReplicaBlockInfoVersions,
16+
ReplicaTransactionInfoVersions, Result as PluginResult, SlotStatus,
17+
};
1418
use bs58;
1519
use crossbeam_channel::{bounded, Sender, TrySendError};
1620
use jito_geyser_protos::solana::{
@@ -24,10 +28,6 @@ use jito_geyser_protos::solana::{
2428
use log::*;
2529
use serde_derive::Deserialize;
2630
use serde_json;
27-
use solana_geyser_plugin_interface::geyser_plugin_interface::{
28-
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoVersions, ReplicaBlockInfoVersions,
29-
ReplicaTransactionInfoVersions, Result as PluginResult, SlotStatus,
30-
};
3131
use tokio::{runtime::Runtime, sync::oneshot};
3232
use tonic::{
3333
service::{interceptor::InterceptedService, Interceptor},
@@ -445,6 +445,26 @@ impl GeyserPlugin for GeyserGrpcPlugin {
445445
entry_count: Some(block.entry_count),
446446
}),
447447
},
448+
ReplicaBlockInfoVersions::V0_0_4(block) => TimestampedBlockUpdate {
449+
ts: Some(prost_types::Timestamp::from(SystemTime::now())),
450+
block_update: Some(BlockUpdate {
451+
slot: block.slot,
452+
blockhash: block.blockhash.to_string(),
453+
rewards: block
454+
.rewards
455+
.rewards
456+
.iter()
457+
.map(|r| (*r).clone().into())
458+
.collect(),
459+
block_time: block.block_time.map(|t| prost_types::Timestamp {
460+
seconds: t,
461+
nanos: 0,
462+
}),
463+
block_height: block.block_height,
464+
executed_transaction_count: Some(block.executed_transaction_count),
465+
entry_count: Some(block.entry_count),
466+
}),
467+
},
448468
};
449469
match data.block_update_sender.try_send(block) {
450470
Ok(_) => Ok(()),

0 commit comments

Comments
 (0)