From 392ffe3103b716b1e5d570c38028696fa82e2a56 Mon Sep 17 00:00:00 2001 From: galactus <96341601+godmodegalactus@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:05:07 +0100 Subject: [PATCH] merging main with production (#290) * remove block_debug_listen (#286) * remove block_debug_listen caused a panic - need more time to investigate 2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] thread 'tokio-runtime-worker' panicked at cluster-endpoints/src/grpc_inspect.rs:59:21: 2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] Error receiving block: Closed 2024-01-17T20:31:42.922 app[683d392fd45368] ams [info] 2024-01-17T20:31:42.912597Z ERROR lite_rpc: Services quit unexpectedly Err(cluster endpoint failure (Err(JoinError::Panic(Id(20), ...)), 1, [JoinHandle { id: Id(19) }, JoinHandle { id: Id(23) }]) * clippy * Fixing message too long and overflow panics (#288) * Update geyser grpc connector commit (#289) --------- Co-authored-by: Groovie | Mango <95291500+grooviegermanikus@users.noreply.github.com> --- Cargo.lock | 2 +- core/src/stores/tx_store.rs | 5 ++++- lite-rpc/src/bridge.rs | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4de2f389..f0878583 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1767,7 +1767,7 @@ dependencies = [ [[package]] name = "geyser-grpc-connector" version = "0.7.1+yellowstone.1.11" -source = "git+https://github.com/blockworks-foundation/geyser-grpc-connector.git?tag=v1.17.15#a3e8e89af71632f31895a688e82c1ab091b11c2f" +source = "git+https://github.com/blockworks-foundation/geyser-grpc-connector.git?tag=v1.17.15#4d737e7c2e8a7bb85b1580da094370dafba3eb8e" dependencies = [ "anyhow", "async-stream", diff --git a/core/src/stores/tx_store.rs b/core/src/stores/tx_store.rs index 5781ef93..745dd37a 100644 --- a/core/src/stores/tx_store.rs +++ b/core/src/stores/tx_store.rs @@ -63,7 +63,10 @@ impl TxStore { let length_before = self.store.len(); self.store .retain(|_k, v| v.last_valid_blockheight >= current_finalized_blockheight); - log::info!("Cleaned {} transactions", length_before - self.store.len()); + log::info!( + "Cleaned {} transactions", + length_before.saturating_sub(self.store.len()) + ); } pub fn is_transaction_confirmed(&self, signature: &String) -> bool { diff --git a/lite-rpc/src/bridge.rs b/lite-rpc/src/bridge.rs index e301feb6..b7ec84a7 100644 --- a/lite-rpc/src/bridge.rs +++ b/lite-rpc/src/bridge.rs @@ -14,6 +14,7 @@ use anyhow::Context; use jsonrpsee::{core::SubscriptionResult, server::ServerBuilder, PendingSubscriptionSink}; use prometheus::{opts, register_int_counter, IntCounter}; use solana_lite_rpc_core::{ + encoding, stores::{block_information_store::BlockInformation, data_cache::DataCache, tx_store::TxProps}, AnyhowJoinHandle, }; @@ -314,11 +315,27 @@ impl LiteRpcServer for LiteBridge { ) -> crate::rpc::Result { RPC_SEND_TX.inc(); + // Copied these constants from solana labs code + const MAX_BASE58_SIZE: usize = 1683; + const MAX_BASE64_SIZE: usize = 1644; + let SendTransactionConfig { encoding, max_retries, } = send_transaction_config.unwrap_or_default(); + let expected_size = match encoding { + encoding::BinaryEncoding::Base58 => MAX_BASE58_SIZE, + encoding::BinaryEncoding::Base64 => MAX_BASE64_SIZE, + }; + if tx.len() > expected_size { + return Err(jsonrpsee::core::Error::Custom(format!( + "Transaction too large, expected : {} transaction len {}", + expected_size, + tx.len() + ))); + } + let raw_tx = match encoding.decode(tx) { Ok(raw_tx) => raw_tx, Err(err) => {