From 8f1cc8bdf411b6f495213dfcf371a5c8e23b2f70 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Wed, 1 Nov 2023 16:20:23 +0600 Subject: [PATCH] geyser: remove startup_status (#230) --- CHANGELOG.md | 17 +++- Cargo.lock | 10 +- Cargo.toml | 10 +- examples/rust/Cargo.toml | 2 +- yellowstone-grpc-client-nodejs/package.json | 2 +- yellowstone-grpc-client/Cargo.toml | 4 +- yellowstone-grpc-geyser/Cargo.toml | 2 +- yellowstone-grpc-geyser/src/plugin.rs | 106 ++++++-------------- yellowstone-grpc-proto/Cargo.toml | 2 +- yellowstone-grpc-tools/Cargo.toml | 2 +- 10 files changed, 64 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d4084..7a2150b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,17 +12,30 @@ The minor version will be incremented upon a breaking change and the patch versi ### Fixes +### Features + +### Breaking + +## 2023-11-01 + +- @triton-one/yellowstone-grpc:0.3.0 +- yellowstone-grpc-client-1.12.0+solana.1.17.1 +- yellowstone-grpc-geyser-1.11.0+solana.1.17.1 +- yellowstone-grpc-proto-1.11.0+solana.1.17.1 +- yellowstone-grpc-tools-1.0.0-rc.6+solana.1.17.1 + +### Fixes + - geyser: trigger end of startup when parent slot 0 seen in `update_slot_status` notification because `notify_end_of_startup` is not triggered when cluster started from genesis ([#207](https://github.com/rpcpool/yellowstone-grpc/pull/207)) - tools: correctly handle SIGINT in kafka ([#219](https://github.com/rpcpool/yellowstone-grpc/pull/219)) - geyser: use Ordering::Relaxed instead of SeqCst ([#221](https://github.com/rpcpool/yellowstone-grpc/pull/221)) - proto: add optional field `ping` to `SubscribeRequest` ([#227](https://github.com/rpcpool/yellowstone-grpc/pull/227)) +- geyser: remove startup_status (allow reload plugin) ([#230](https://github.com/rpcpool/yellowstone-grpc/pull/230)) ### Features - proto: add optional field `filter_by_commitment` to Slots filter ([#223](https://github.com/rpcpool/yellowstone-grpc/pull/223)) -### Breaking - ## 2023-10-19 - yellowstone-grpc-tools-1.0.0-rc.5+solana.1.17.1 diff --git a/Cargo.lock b/Cargo.lock index 2ce45c3..f082b3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4948,7 +4948,7 @@ dependencies = [ [[package]] name = "yellowstone-grpc-client" -version = "1.11.1+solana.1.17.1" +version = "1.12.0+solana.1.17.1" dependencies = [ "bytes", "futures", @@ -4962,7 +4962,7 @@ dependencies = [ [[package]] name = "yellowstone-grpc-client-simple" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" dependencies = [ "anyhow", "backoff", @@ -4985,7 +4985,7 @@ dependencies = [ [[package]] name = "yellowstone-grpc-geyser" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" dependencies = [ "anyhow", "base64 0.21.4", @@ -5017,7 +5017,7 @@ dependencies = [ [[package]] name = "yellowstone-grpc-proto" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" dependencies = [ "anyhow", "bincode", @@ -5032,7 +5032,7 @@ dependencies = [ [[package]] name = "yellowstone-grpc-tools" -version = "1.0.0-rc.5+solana.1.17.1" +version = "1.0.0-rc.6+solana.1.17.1" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 5daadd2..9b043ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [workspace] members = [ - "examples/rust", # 1.10.0+solana.1.17.1 - "yellowstone-grpc-client", # 1.11.1+solana.1.17.1 - "yellowstone-grpc-geyser", # 1.10.0+solana.1.17.1 - "yellowstone-grpc-proto", # 1.10.0+solana.1.17.1 - "yellowstone-grpc-tools", # 1.0.0-rc.5+solana.1.17.1 + "examples/rust", # 1.11.0+solana.1.17.1 + "yellowstone-grpc-client", # 1.12.0+solana.1.17.1 + "yellowstone-grpc-geyser", # 1.11.0+solana.1.17.1 + "yellowstone-grpc-proto", # 1.11.0+solana.1.17.1 + "yellowstone-grpc-tools", # 1.0.0-rc.6+solana.1.17.1 ] [profile.release] diff --git a/examples/rust/Cargo.toml b/examples/rust/Cargo.toml index 3d4b9db..c3ee4f6 100644 --- a/examples/rust/Cargo.toml +++ b/examples/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-grpc-client-simple" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" authors = ["Triton One"] edition = "2021" publish = false diff --git a/yellowstone-grpc-client-nodejs/package.json b/yellowstone-grpc-client-nodejs/package.json index b5348a8..20b339e 100644 --- a/yellowstone-grpc-client-nodejs/package.json +++ b/yellowstone-grpc-client-nodejs/package.json @@ -1,6 +1,6 @@ { "name": "@triton-one/yellowstone-grpc", - "version": "0.2.1", + "version": "0.3.0", "license": "Apache-2.0", "author": "Triton One", "description": "Yellowstone gRPC Geyser Node.js Client", diff --git a/yellowstone-grpc-client/Cargo.toml b/yellowstone-grpc-client/Cargo.toml index 9e35274..3cc9674 100644 --- a/yellowstone-grpc-client/Cargo.toml +++ b/yellowstone-grpc-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-grpc-client" -version = "1.11.1+solana.1.17.1" +version = "1.12.0+solana.1.17.1" authors = ["Triton One"] edition = "2021" description = "Yellowstone gRPC Geyser Simple Client" @@ -16,7 +16,7 @@ http = "0.2.8" thiserror = "1.0" tonic = { version = "0.10.2", features = ["gzip", "tls", "tls-roots"] } tonic-health = "0.10.2" -yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto", version = "1.10.0+solana.1.17.1" } +yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto", version = "1.11.0+solana.1.17.1" } [dev-dependencies] tokio = { version = "1.32.0", features = ["macros"] } diff --git a/yellowstone-grpc-geyser/Cargo.toml b/yellowstone-grpc-geyser/Cargo.toml index cc01904..d1b6521 100644 --- a/yellowstone-grpc-geyser/Cargo.toml +++ b/yellowstone-grpc-geyser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-grpc-geyser" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" authors = ["Triton One"] edition = "2021" description = "Yellowstone gRPC Geyser Plugin" diff --git a/yellowstone-grpc-geyser/src/plugin.rs b/yellowstone-grpc-geyser/src/plugin.rs index 68ff6f8..2e3e52d 100644 --- a/yellowstone-grpc-geyser/src/plugin.rs +++ b/yellowstone-grpc-geyser/src/plugin.rs @@ -9,26 +9,16 @@ use { ReplicaEntryInfoVersions, ReplicaTransactionInfoVersions, Result as PluginResult, SlotStatus, }, - std::{ - sync::{ - atomic::{AtomicU8, Ordering}, - Arc, - }, - time::Duration, - }, + std::{sync::Arc, time::Duration}, tokio::{ runtime::Runtime, sync::{mpsc, Notify}, }, }; -const STARTUP_END_OF_RECEIVED: u8 = 1 << 0; -const STARTUP_PROCESSED_RECEIVED: u8 = 1 << 1; - #[derive(Debug)] pub struct PluginInner { runtime: Runtime, - startup_status: AtomicU8, snapshot_channel: Option>>, grpc_channel: mpsc::UnboundedSender, grpc_shutdown: Arc, @@ -53,15 +43,8 @@ impl Plugin { where F: FnOnce(&PluginInner) -> PluginResult<()>, { - // Full block reconstruction will fail before first processed slot received let inner = self.inner.as_ref().expect("initialized"); - if inner.startup_status.load(Ordering::Relaxed) - == STARTUP_END_OF_RECEIVED | STARTUP_PROCESSED_RECEIVED - { - f(inner) - } else { - Ok(()) - } + f(inner) } } @@ -97,7 +80,6 @@ impl GeyserPlugin for Plugin { self.inner = Some(PluginInner { runtime, - startup_status: AtomicU8::new(0), snapshot_channel, grpc_channel, grpc_shutdown, @@ -122,49 +104,43 @@ impl GeyserPlugin for Plugin { slot: u64, is_startup: bool, ) -> PluginResult<()> { - let account = match account { - ReplicaAccountInfoVersions::V0_0_1(_info) => { - unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported") - } - ReplicaAccountInfoVersions::V0_0_2(_info) => { - unreachable!("ReplicaAccountInfoVersions::V0_0_2 is not supported") - } - ReplicaAccountInfoVersions::V0_0_3(info) => info, - }; - let message = Message::Account((account, slot, is_startup).into()); + self.with_inner(|inner| { + let account = match account { + ReplicaAccountInfoVersions::V0_0_1(_info) => { + unreachable!("ReplicaAccountInfoVersions::V0_0_1 is not supported") + } + ReplicaAccountInfoVersions::V0_0_2(_info) => { + unreachable!("ReplicaAccountInfoVersions::V0_0_2 is not supported") + } + ReplicaAccountInfoVersions::V0_0_3(info) => info, + }; - if is_startup { - let inner = self.inner.as_ref().expect("initialized"); + let message = Message::Account((account, slot, is_startup).into()); + if is_startup { + if let Some(channel) = &inner.snapshot_channel { + match channel.send(Some(message)) { + Ok(()) => MESSAGE_QUEUE_SIZE.inc(), + Err(_) => panic!("failed to send message to startup queue: channel closed"), + } + } + } else { + inner.send_message(message); + } + + Ok(()) + }) + } + + fn notify_end_of_startup(&self) -> PluginResult<()> { + self.with_inner(|inner| { if let Some(channel) = &inner.snapshot_channel { - match channel.send(Some(message)) { + match channel.send(None) { Ok(()) => MESSAGE_QUEUE_SIZE.inc(), Err(_) => panic!("failed to send message to startup queue: channel closed"), } } Ok(()) - } else { - self.with_inner(|inner| { - inner.send_message(message); - Ok(()) - }) - } - } - - fn notify_end_of_startup(&self) -> PluginResult<()> { - let inner = self.inner.as_ref().expect("initialized"); - - inner - .startup_status - .fetch_or(STARTUP_END_OF_RECEIVED, Ordering::Relaxed); - - if let Some(channel) = &inner.snapshot_channel { - match channel.send(None) { - Ok(()) => MESSAGE_QUEUE_SIZE.inc(), - Err(_) => panic!("failed to send message to startup queue: channel closed"), - } - } - - Ok(()) + }) } fn update_slot_status( @@ -173,28 +149,10 @@ impl GeyserPlugin for Plugin { parent: Option, status: SlotStatus, ) -> PluginResult<()> { - let inner = self.inner.as_ref().expect("initialized"); - // if plugin run on genesis of network, notify_end_of_startup will not be triggered, and slot 0 will not - // come through this function. - if parent == Some(0) { - inner - .startup_status - .fetch_or(STARTUP_END_OF_RECEIVED, Ordering::Relaxed); - } - if status == SlotStatus::Processed { - let _ = inner.startup_status.compare_exchange( - STARTUP_END_OF_RECEIVED, - STARTUP_END_OF_RECEIVED | STARTUP_PROCESSED_RECEIVED, - Ordering::Relaxed, - Ordering::Relaxed, - ); - } - self.with_inner(|inner| { let message = Message::Slot((slot, parent, status).into()); inner.send_message(message); prom::update_slot_status(status, slot); - Ok(()) }) } diff --git a/yellowstone-grpc-proto/Cargo.toml b/yellowstone-grpc-proto/Cargo.toml index 8fc5b96..b7b0e87 100644 --- a/yellowstone-grpc-proto/Cargo.toml +++ b/yellowstone-grpc-proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-grpc-proto" -version = "1.10.0+solana.1.17.1" +version = "1.11.0+solana.1.17.1" authors = ["Triton One"] edition = "2021" description = "Yellowstone gRPC Geyser Protobuf Definitions" diff --git a/yellowstone-grpc-tools/Cargo.toml b/yellowstone-grpc-tools/Cargo.toml index 0682717..4ee292e 100644 --- a/yellowstone-grpc-tools/Cargo.toml +++ b/yellowstone-grpc-tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yellowstone-grpc-tools" -version = "1.0.0-rc.5+solana.1.17.1" +version = "1.0.0-rc.6+solana.1.17.1" authors = ["Triton One"] edition = "2021" description = "Yellowstone gRPC Tools"