Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion compute-budget-instruction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ solana-builtins-default-costs = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-interface = { workspace = true, features = ["borsh"] }
solana-instruction = { workspace = true }
solana-packet = { workspace = true }
solana-perf = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-svm-transaction = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions compute-budget-instruction/src/builtin_programs_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use {
solana_builtins_default_costs::{
get_builtin_migration_feature_index, BuiltinMigrationFeatureIndex, MAYBE_BUILTIN_KEY,
},
solana_packet::PACKET_DATA_SIZE,
solana_perf::packet::QUIC_MAX_STREAM_SIZE,
solana_pubkey::Pubkey,
};

// The maximum number of pubkeys that a packet can contain.
pub(crate) const FILTER_SIZE: u8 = (PACKET_DATA_SIZE / core::mem::size_of::<Pubkey>()) as u8;
pub(crate) const FILTER_SIZE: u8 = (QUIC_MAX_STREAM_SIZE / core::mem::size_of::<Pubkey>()) as u8;

#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) enum ProgramKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,17 @@ mod tests {
use {
super::*,
crate::banking_stage::tests::create_slow_genesis_config,
bytes::BytesMut,
crossbeam_channel::{unbounded, Receiver},
solana_hash::Hash,
solana_keypair::Keypair,
solana_ledger::genesis_utils::GenesisConfigInfo,
solana_message::{
v0, AccountMeta, AddressLookupTableAccount, Instruction, VersionedMessage,
solana_message::{v0, AddressLookupTableAccount, Instruction, VersionedMessage},
solana_packet::Meta,
solana_perf::packet::{
to_packet_batches, BytesPacket, BytesPacketBatch, PacketBatch, RecycledPacketBatch,
QUIC_MAX_STREAM_SIZE,
},
solana_packet::{Meta, PACKET_DATA_SIZE},
solana_perf::packet::{to_packet_batches, Packet, PacketBatch, RecycledPacketBatch},
solana_pubkey::Pubkey,
solana_signer::Signer,
solana_system_interface::instruction as system_instruction,
Expand Down Expand Up @@ -786,7 +788,7 @@ mod tests {
setup_transaction_view_receive_and_buffer(receiver, bank_forks.clone());

let packet_batches = Arc::new(vec![PacketBatch::from(RecycledPacketBatch::new(vec![
Packet::new([1u8; PACKET_DATA_SIZE], Meta::default()),
Packet::new([1u8; QUIC_MAX_STREAM_SIZE], Meta::default()),
]))]);
sender.send(packet_batches).unwrap();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#[cfg(feature = "dev-context-only-utils")]
use qualifier_attr::qualifiers;
use solana_perf::packet::QUIC_MAX_STREAM_SIZE;
use {
super::{transaction_priority_id::TransactionPriorityId, transaction_state::TransactionState},
crate::banking_stage::scheduler_messages::TransactionId,
agave_transaction_view::resolved_transaction_view::ResolvedTransactionView,
itertools::MinMaxResult,
min_max_heap::MinMaxHeap,
slab::{Slab, VacantEntry},
solana_packet::PACKET_DATA_SIZE,
solana_runtime_transaction::{
runtime_transaction::RuntimeTransaction, transaction_with_meta::TransactionWithMeta,
},
Expand Down Expand Up @@ -300,7 +300,7 @@ impl StateContainer<RuntimeTransactionView> for TransactionViewStateContainer {
fn with_capacity(capacity: usize) -> Self {
let inner = TransactionStateContainer::with_capacity(capacity);
let bytes_buffer = (0..inner.id_to_transaction_state.capacity())
.map(|_| Arc::new(Vec::with_capacity(PACKET_DATA_SIZE)))
.map(|_| Arc::new(Vec::with_capacity(QUIC_MAX_STREAM_SIZE)))
.collect::<Vec<_>>()
.into_boxed_slice();
Self {
Expand Down
5 changes: 3 additions & 2 deletions core/src/repair/ancestor_hashes_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use {
solana_gossip::{cluster_info::ClusterInfo, contact_info::Protocol, ping_pong::Pong},
solana_keypair::{signable::Signable, Keypair, Signer},
solana_ledger::blockstore::Blockstore,
solana_packet::PACKET_DATA_SIZE,
solana_perf::{
packet::{deserialize_from_with_limit, PacketBatch, PacketFlags, PacketRef},
recycler::Recycler,
Expand Down Expand Up @@ -388,15 +389,15 @@ impl AncestorHashesService {
return None;
};
let mut cursor = Cursor::new(packet_data);
let Ok(response) = deserialize_from_with_limit(&mut cursor) else {
let Ok(response) = deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE) else {
stats.invalid_packets += 1;
return None;
};

match response {
AncestorHashesResponse::Hashes(ref hashes) => {
// deserialize trailing nonce
let Ok(nonce) = deserialize_from_with_limit(&mut cursor) else {
let Ok(nonce) = deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE) else {
stats.invalid_packets += 1;
return None;
};
Expand Down
8 changes: 4 additions & 4 deletions core/src/repair/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ mod tests {

let mut cursor = Cursor::new(&rsp[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE).unwrap();
assert_eq!(cursor.position(), rsp.len() as u64);
if let RepairProtocol::Orphan { header, slot } = deserialized_request {
assert_eq!(slot, 123);
Expand Down Expand Up @@ -1548,7 +1548,7 @@ mod tests {
.unwrap();
let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE).unwrap();
assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::AncestorHashes {
header,
Expand Down Expand Up @@ -1599,7 +1599,7 @@ mod tests {

let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE).unwrap();
assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::WindowIndex {
header,
Expand Down Expand Up @@ -1633,7 +1633,7 @@ mod tests {

let mut cursor = Cursor::new(&request_bytes[..]);
let deserialized_request: RepairProtocol =
deserialize_from_with_limit(&mut cursor).unwrap();
deserialize_from_with_limit(&mut cursor, PACKET_DATA_SIZE).unwrap();
assert_eq!(cursor.position(), request_bytes.len() as u64);
if let RepairProtocol::HighestWindowIndex {
header,
Expand Down
1 change: 1 addition & 0 deletions core/src/sigverify_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ impl SigVerifyStage {
let mut last_print = Instant::now();
const MAX_DEDUPER_AGE: Duration = Duration::from_secs(2);
const DEDUPER_FALSE_POSITIVE_RATE: f64 = 0.001;
// TODO(klykov): don't we need to increase this constant when we increase the max tx size?
const DEDUPER_NUM_BITS: u64 = 63_999_979;
Builder::new()
.name(thread_name.to_string())
Expand Down
1 change: 1 addition & 0 deletions cost-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ solana-hash = { workspace = true, optional = true }
solana-message = { workspace = true, optional = true }
solana-metrics = { workspace = true }
solana-packet = { workspace = true }
solana-perf = { workspace = true }
solana-pubkey = { workspace = true }
solana-runtime-transaction = { workspace = true }
solana-sdk-ids = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
solana_bincode::limited_deserialize,
solana_compute_budget::compute_budget_limits::DEFAULT_HEAP_COST,
solana_fee_structure::FeeStructure,
solana_perf::packet::QUIC_MAX_STREAM_SIZE,
solana_pubkey::Pubkey,
solana_runtime_transaction::transaction_meta::StaticMeta,
solana_sdk_ids::system_program,
Expand Down Expand Up @@ -241,7 +242,7 @@ impl CostModel {
) -> SystemProgramAccountAllocation {
if program_id == &system_program::id() {
if let Ok(instruction) =
limited_deserialize(instruction.data, solana_packet::PACKET_DATA_SIZE as u64)
limited_deserialize(instruction.data, QUIC_MAX_STREAM_SIZE as u64)
{
Self::calculate_account_data_size_on_deserialized_system_instruction(instruction)
} else {
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
bincode::serialize,
serde::{Deserialize, Serialize},
solana_keypair::signable::Signable,
solana_perf::packet::PACKET_DATA_SIZE,
solana_packet::PACKET_DATA_SIZE,
solana_pubkey::Pubkey,
solana_sanitize::{Sanitize, SanitizeError},
solana_signature::Signature,
Expand Down
4 changes: 3 additions & 1 deletion gossip/src/wire_format_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ mod tests {
crate::protocol::Protocol,
serde::Serialize,
solana_net_utils::tooling_for_tests::{hexdump, validate_packet_format},
solana_packet::PACKET_DATA_SIZE,
solana_sanitize::Sanitize,
std::path::PathBuf,
};

fn parse_gossip(bytes: &[u8]) -> anyhow::Result<Protocol> {
let pkt: Protocol = solana_perf::packet::deserialize_from_with_limit(bytes)?;
let pkt: Protocol =
solana_perf::packet::deserialize_from_with_limit(bytes, PACKET_DATA_SIZE)?;
pkt.sanitize()?;
Ok(pkt)
}
Expand Down
8 changes: 4 additions & 4 deletions ledger/src/shred/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ macro_rules! impl_merkle_shred {
};
}

use impl_merkle_shred;
use {impl_merkle_shred, solana_packet::PACKET_DATA_SIZE};

impl<'a> ShredTrait<'a> for ShredData {
type SignedData = Hash;
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<'a> ShredTrait<'a> for ShredData {
}
payload.truncate(Self::SIZE_OF_PAYLOAD);
let (common_header, data_header): (ShredCommonHeader, _) =
deserialize_from_with_limit(&payload[..])?;
deserialize_from_with_limit(&payload[..], PACKET_DATA_SIZE)?;
if !matches!(common_header.shred_variant, ShredVariant::MerkleData { .. }) {
return Err(Error::InvalidShredVariant);
}
Expand Down Expand Up @@ -533,7 +533,7 @@ impl<'a> ShredTrait<'a> for ShredCode {
{
let mut payload = Payload::from(payload);
let (common_header, coding_header): (ShredCommonHeader, _) =
deserialize_from_with_limit(&payload[..])?;
deserialize_from_with_limit(&payload[..], PACKET_DATA_SIZE)?;
if !matches!(common_header.shred_variant, ShredVariant::MerkleCode { .. }) {
return Err(Error::InvalidShredVariant);
}
Expand Down Expand Up @@ -776,7 +776,7 @@ pub(super) fn recover(
return Err(Error::InvalidRecoveredShred);
};
let (common_header, data_header) =
deserialize_from_with_limit(&shred.payload[..])?;
deserialize_from_with_limit(&shred.payload[..], PACKET_DATA_SIZE)?;
if shred.common_header != common_header {
return Err(Error::InvalidRecoveredShred);
}
Expand Down
1 change: 1 addition & 0 deletions perf/src/deduper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ mod tests {
},
rand::SeedableRng,
rand_chacha::ChaChaRng,
//TODO(klykov): deduper is used for shreds as well, so use here PACKET_DATA_SIZE for now.
solana_packet::{Meta, PACKET_DATA_SIZE},
test_case::test_case,
};
Expand Down
13 changes: 9 additions & 4 deletions perf/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ use {
};
pub use {
bytes,
solana_packet::{self, Meta, Packet, PacketFlags, PACKET_DATA_SIZE},
solana_packet::{self, Meta, Packet, PacketFlags},
};

pub const QUIC_MAX_STREAM_SIZE: usize = 4096;

pub const NUM_PACKETS: usize = 1024 * 8;

pub const PACKETS_PER_BATCH: usize = 64;
Expand Down Expand Up @@ -68,7 +70,7 @@ impl BytesPacket {
where
T: solana_packet::Encode,
{
let buffer = BytesMut::with_capacity(PACKET_DATA_SIZE);
let buffer = BytesMut::with_capacity(QUIC_MAX_STREAM_SIZE);
let mut writer = buffer.writer();
data.encode(&mut writer)?;
let buffer = writer.into_inner();
Expand Down Expand Up @@ -887,15 +889,18 @@ impl<'a> IntoParallelIterator for &'a mut BytesPacketBatch {
}
}

pub fn deserialize_from_with_limit<R, T>(reader: R) -> bincode::Result<T>
pub fn deserialize_from_with_limit<R, T>(
reader: R,
max_packet_data_size: usize,
) -> bincode::Result<T>
where
R: Read,
T: DeserializeOwned,
{
// with_limit causes pre-allocation size to be limited
// to prevent against memory exhaustion attacks.
bincode::options()
.with_limit(PACKET_DATA_SIZE as u64)
.with_limit(max_packet_data_size as u64)
.with_fixint_encoding()
.allow_trailing_bytes()
.deserialize_from(reader)
Expand Down
Loading