Skip to content

Commit

Permalink
proto: add enum SlotStatus (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Feb 6, 2025
1 parent 9db04a9 commit d36f8ba
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 118 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ The minor version will be incremented upon a breaking change and the patch versi

### Breaking

## 2025-02-06

- @triton-one/yellowstone-grpc@3.0.0
- yellowstone-grpc-client-simple-5.0.0
- yellowstone-grpc-client-5.0.0
- yellowstone-grpc-geyser-5.0.0
- yellowstone-grpc-proto-5.0.0

### Breaking

- proto: add enum `SlotStatus` ([#529](https://github.com/rpcpool/yellowstone-grpc/pull/529))

## 2025-02-05

- yellowstone-grpc-client-simple-4.4.1
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[workspace]
resolver = "2"
members = [
"examples/rust", # 4.4.1
"yellowstone-grpc-client", # 4.2.1
"yellowstone-grpc-geyser", # 4.3.1
"yellowstone-grpc-proto", # 4.2.1
"examples/rust", # 5.0.0
"yellowstone-grpc-client", # 5.0.0
"yellowstone-grpc-geyser", # 5.0.0
"yellowstone-grpc-proto", # 5.0.0
]
exclude = [
"yellowstone-grpc-client-nodejs/solana-encoding-wasm", # 3.0.0
Expand Down Expand Up @@ -69,8 +69,8 @@ tonic = "0.12.1"
tonic-build = "0.12.1"
tonic-health = "0.12.1"
vergen = "9.0.0"
yellowstone-grpc-client = { path = "yellowstone-grpc-client", version = "4.2.1" }
yellowstone-grpc-proto = { path = "yellowstone-grpc-proto", version = "4.2.1", default-features = false }
yellowstone-grpc-client = { path = "yellowstone-grpc-client", version = "5.0.0" }
yellowstone-grpc-proto = { path = "yellowstone-grpc-proto", version = "5.0.0", default-features = false }

[workspace.lints.clippy]
clone_on_ref_ptr = "deny"
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-client-simple"
version = "4.4.1"
version = "5.0.0"
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/package-lock.json

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

2 changes: 1 addition & 1 deletion examples/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yellowstone-grpc-client-example-ts",
"version": "2.1.0",
"version": "3.0.0",
"license": "Apache-2.0",
"author": "Triton One",
"main": "dist/client.js",
Expand Down
4 changes: 2 additions & 2 deletions yellowstone-grpc-client-nodejs/package-lock.json

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

2 changes: 1 addition & 1 deletion yellowstone-grpc-client-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@triton-one/yellowstone-grpc",
"version": "2.1.0",
"version": "3.0.0",
"license": "Apache-2.0",
"author": "Triton One",
"description": "Yellowstone gRPC Geyser Node.js Client",
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ crate-type = ["cdylib"]
serde_json = "1.0.86"
solana-transaction-status = "~2.1.1"
wasm-bindgen = "0.2.95"
yellowstone-grpc-proto = { path = "../../yellowstone-grpc-proto", version = "4.1.1", default-features = false, features = ["convert"] }
yellowstone-grpc-proto = { path = "../../yellowstone-grpc-proto", version = "5.0.0", default-features = false, features = ["convert"] }

[workspace.lints.clippy]
clone_on_ref_ptr = "deny"
Expand Down
2 changes: 1 addition & 1 deletion yellowstone-grpc-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-client"
version = "4.2.1"
version = "5.0.0"
authors = { workspace = true }
edition = { workspace = true }
description = "Yellowstone gRPC Geyser Simple Client"
Expand Down
2 changes: 1 addition & 1 deletion yellowstone-grpc-geyser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-geyser"
version = "4.3.1"
version = "5.0.0"
authors = { workspace = true }
edition = { workspace = true }
description = "Yellowstone gRPC Geyser Plugin"
Expand Down
50 changes: 23 additions & 27 deletions yellowstone-grpc-geyser/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use {
},
message::{
CommitmentLevel, Message, MessageBlock, MessageBlockMeta, MessageEntry,
MessageSlot, MessageTransactionInfo,
MessageSlot, MessageTransactionInfo, SlotStatus,
},
proto::geyser_server::{Geyser, GeyserServer},
},
Expand Down Expand Up @@ -107,13 +107,13 @@ impl BlockMetaStorage {
match message {
Message::Slot(msg) => {
match msg.status {
CommitmentLevel::Processed => {
SlotStatus::Processed => {
storage.processed.replace(msg.slot);
}
CommitmentLevel::Confirmed => {
SlotStatus::Confirmed => {
storage.confirmed.replace(msg.slot);
}
CommitmentLevel::Finalized => {
SlotStatus::Finalized => {
storage.finalized.replace(msg.slot);
}
_ => {}
Expand All @@ -130,20 +130,20 @@ impl BlockMetaStorage {
.or_insert_with(|| BlockhashStatus::new(msg.slot));

match msg.status {
CommitmentLevel::Processed => {
SlotStatus::Processed => {
entry.processed = true;
}
CommitmentLevel::Confirmed => {
SlotStatus::Confirmed => {
entry.confirmed = true;
}
CommitmentLevel::Finalized => {
SlotStatus::Finalized => {
entry.finalized = true;
}
_ => {}
}
}

if msg.status == CommitmentLevel::Finalized {
if msg.status == SlotStatus::Finalized {
if let Some(keep_slot) = msg.slot.checked_sub(KEEP_SLOTS) {
storage.blocks.retain(|slot, _block| *slot >= keep_slot);
}
Expand Down Expand Up @@ -202,7 +202,6 @@ impl BlockMetaStorage {
CommitmentLevel::Processed => storage.processed,
CommitmentLevel::Confirmed => storage.confirmed,
CommitmentLevel::Finalized => storage.finalized,
_ => return Err(Status::internal("unreachable")),
};

match slot.and_then(|slot| storage.blocks.get(&slot)) {
Expand Down Expand Up @@ -231,20 +230,17 @@ impl BlockMetaStorage {
CommitmentLevel::Processed => storage.processed,
CommitmentLevel::Confirmed => storage.confirmed,
CommitmentLevel::Finalized => storage.finalized,
_ => return Err(Status::internal("unreachable")),
}
.ok_or_else(|| Status::internal("startup"))?;

let valid = storage
.blockhashes
.get(blockhash)
.map(|status| match commitment {
CommitmentLevel::Processed => Ok(status.processed),
CommitmentLevel::Confirmed => Ok(status.confirmed),
CommitmentLevel::Finalized => Ok(status.finalized),
_ => Err(Status::internal("unreachable")),
CommitmentLevel::Processed => status.processed,
CommitmentLevel::Confirmed => status.confirmed,
CommitmentLevel::Finalized => status.finalized,
})
.transpose()?
.unwrap_or(false);

Ok(Response::new(IsBlockhashValidResponse { valid, slot }))
Expand Down Expand Up @@ -548,10 +544,10 @@ impl GrpcService {
match &message {
// On startup we can receive multiple Confirmed/Finalized slots without BlockMeta message
// With saved first Processed slot we can ignore errors caused by startup process
Message::Slot(msg) if processed_first_slot.is_none() && msg.status == CommitmentLevel::Processed => {
Message::Slot(msg) if processed_first_slot.is_none() && msg.status == SlotStatus::Processed => {
processed_first_slot = Some(msg.slot);
}
Message::Slot(msg) if msg.status == CommitmentLevel::Finalized => {
Message::Slot(msg) if msg.status == SlotStatus::Finalized => {
// keep extra 10 slots + slots for replay
if let Some(msg_slot) = msg.slot.checked_sub(10 + replay_stored_slots) {
loop {
Expand Down Expand Up @@ -600,13 +596,13 @@ impl GrpcService {
let slot_messages = messages.entry(message.get_slot()).or_default();
if let Message::Slot(msg) = &message {
match msg.status {
CommitmentLevel::Processed => {
SlotStatus::Processed => {
slot_messages.parent_slot = msg.parent;
},
CommitmentLevel::Confirmed => {
SlotStatus::Confirmed => {
slot_messages.confirmed = true;
},
CommitmentLevel::Finalized => {
SlotStatus::Finalized => {
slot_messages.finalized = true;
},
_ => {}
Expand Down Expand Up @@ -685,12 +681,12 @@ impl GrpcService {
.and_then(|entry| entry.parent_slot)
.map(|parent| (parent, messages.get_mut(&parent)))
{
if (status == CommitmentLevel::Confirmed && !entry.confirmed) ||
(status == CommitmentLevel::Finalized && !entry.finalized)
if (status == SlotStatus::Confirmed && !entry.confirmed) ||
(status == SlotStatus::Finalized && !entry.finalized)
{
if status == CommitmentLevel::Confirmed {
if status == SlotStatus::Confirmed {
entry.confirmed = true;
} else if status == CommitmentLevel::Finalized {
} else if status == SlotStatus::Finalized {
entry.finalized = true;
}

Expand All @@ -711,10 +707,10 @@ impl GrpcService {
for message in messages_vec.into_iter().rev() {
if let Message::Slot(slot) = &message.1 {
let (mut confirmed_messages, mut finalized_messages) = match slot.status {
CommitmentLevel::Processed | CommitmentLevel::FirstShredReceived | CommitmentLevel::Completed | CommitmentLevel::CreatedBank | CommitmentLevel::Dead => {
SlotStatus::Processed | SlotStatus::FirstShredReceived | SlotStatus::Completed | SlotStatus::CreatedBank | SlotStatus::Dead => {
(Vec::with_capacity(1), Vec::with_capacity(1))
}
CommitmentLevel::Confirmed => {
SlotStatus::Confirmed => {
if let Some(slot_messages) = messages.get_mut(&slot.slot) {
if !slot_messages.sealed {
slot_messages.confirmed_at = Some(slot_messages.messages.len());
Expand All @@ -727,7 +723,7 @@ impl GrpcService {
.unwrap_or_default();
(vec, Vec::with_capacity(1))
}
CommitmentLevel::Finalized => {
SlotStatus::Finalized => {
if let Some(slot_messages) = messages.get_mut(&slot.slot) {
if !slot_messages.sealed {
slot_messages.finalized_at = Some(slot_messages.messages.len());
Expand Down
10 changes: 5 additions & 5 deletions yellowstone-grpc-geyser/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{config::ConfigPrometheus, version::VERSION as VERSION_INFO},
agave_geyser_plugin_interface::geyser_plugin_interface::SlotStatus,
agave_geyser_plugin_interface::geyser_plugin_interface::SlotStatus as GeyserSlosStatus,
http_body_util::{combinators::BoxBody, BodyExt, Empty as BodyEmpty, Full as BodyFull},
hyper::{
body::{Bytes, Incoming as BodyIncoming},
Expand All @@ -24,7 +24,7 @@ use {
sync::{mpsc, oneshot, Notify},
task::JoinHandle,
},
yellowstone_grpc_proto::plugin::{filter::Filter, message::CommitmentLevel},
yellowstone_grpc_proto::plugin::{filter::Filter, message::SlotStatus},
};

lazy_static::lazy_static! {
Expand Down Expand Up @@ -314,13 +314,13 @@ fn not_found_handler() -> http::Result<Response<BoxBody<Bytes, Infallible>>> {
.body(BodyEmpty::new().boxed())
}

pub fn update_slot_status(status: &SlotStatus, slot: u64) {
pub fn update_slot_status(status: &GeyserSlosStatus, slot: u64) {
SLOT_STATUS
.with_label_values(&[status.as_str()])
.set(slot as i64);
}

pub fn update_slot_plugin_status(status: CommitmentLevel, slot: u64) {
pub fn update_slot_plugin_status(status: SlotStatus, slot: u64) {
SLOT_STATUS_PLUGIN
.with_label_values(&[status.as_str()])
.set(slot as i64);
Expand Down Expand Up @@ -365,7 +365,7 @@ pub fn update_subscriptions(endpoint: &str, old: Option<&Filter>, new: Option<&F
}
}

pub fn missed_status_message_inc(status: CommitmentLevel) {
pub fn missed_status_message_inc(status: SlotStatus) {
MISSED_STATUS_MESSAGE
.with_label_values(&[status.as_str()])
.inc()
Expand Down
2 changes: 1 addition & 1 deletion yellowstone-grpc-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yellowstone-grpc-proto"
version = "4.2.1"
version = "5.0.0"
authors = { workspace = true }
edition = { workspace = true }
description = "Yellowstone gRPC Geyser Protobuf Definitions"
Expand Down
Loading

0 comments on commit d36f8ba

Please sign in to comment.