Fixing message too long and overflow panics (#288)
This commit is contained in:
parent
e3bfaac726
commit
4d4019264e
|
@ -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 {
|
||||
|
|
|
@ -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<String> {
|
||||
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) => {
|
||||
|
|
Loading…
Reference in New Issue