Compare commits
7 Commits
document-r
...
mergify/bp
Author | SHA1 | Date | |
---|---|---|---|
|
26419d7723 | ||
|
821261a2d1 | ||
|
f0c5962817 | ||
|
1b930a1485 | ||
|
2ed9655958 | ||
|
c63782f833 | ||
|
258f752e5d |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -5786,7 +5786,9 @@ version = "1.10.4"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"log",
|
||||
"solana-client",
|
||||
"solana-logger 1.10.4",
|
||||
"solana-measure",
|
||||
"solana-metrics",
|
||||
"solana-runtime",
|
||||
"solana-sdk",
|
||||
|
@@ -24,7 +24,7 @@ use {
|
||||
transaction::{self, SanitizedTransaction, Transaction},
|
||||
},
|
||||
solana_send_transaction_service::{
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo},
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo, DEFAULT_TPU_USE_QUIC},
|
||||
tpu_info::NullTpuInfo,
|
||||
},
|
||||
std::{
|
||||
@@ -399,6 +399,7 @@ pub async fn start_tcp_server(
|
||||
receiver,
|
||||
5_000,
|
||||
0,
|
||||
DEFAULT_TPU_USE_QUIC,
|
||||
);
|
||||
|
||||
let server = BanksServer::new(
|
||||
|
@@ -1,5 +1,7 @@
|
||||
use {
|
||||
crate::{tpu_connection::TpuConnection, udp_client::UdpTpuConnection},
|
||||
crate::{
|
||||
quic_client::QuicTpuConnection, tpu_connection::TpuConnection, udp_client::UdpTpuConnection,
|
||||
},
|
||||
lazy_static::lazy_static,
|
||||
std::{
|
||||
collections::{hash_map::Entry, BTreeMap, HashMap},
|
||||
@@ -23,6 +25,7 @@ struct ConnMap {
|
||||
// that seems non-"Rust-y" and low bang/buck. This is still pretty terrible though...
|
||||
last_used_times: BTreeMap<u64, SocketAddr>,
|
||||
ticks: u64,
|
||||
use_quic: bool,
|
||||
}
|
||||
|
||||
impl ConnMap {
|
||||
@@ -31,21 +34,31 @@ impl ConnMap {
|
||||
map: HashMap::new(),
|
||||
last_used_times: BTreeMap::new(),
|
||||
ticks: 0,
|
||||
use_quic: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_use_quic(&mut self, use_quic: bool) {
|
||||
self.use_quic = use_quic;
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref CONNECTION_MAP: Mutex<ConnMap> = Mutex::new(ConnMap::new());
|
||||
}
|
||||
|
||||
pub fn set_use_quic(use_quic: bool) {
|
||||
let mut map = (*CONNECTION_MAP).lock().unwrap();
|
||||
map.set_use_quic(use_quic);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
// TODO: see https://github.com/solana-labs/solana/issues/23661
|
||||
// remove lazy_static and optimize and refactor this
|
||||
pub fn get_connection(addr: &SocketAddr) -> Arc<dyn TpuConnection + 'static + Sync + Send> {
|
||||
let mut map = (*CONNECTION_MAP).lock().unwrap();
|
||||
let ticks = map.ticks;
|
||||
|
||||
let use_quic = map.use_quic;
|
||||
let (conn, target_ticks) = match map.map.entry(*addr) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
let mut pair = entry.get_mut();
|
||||
@@ -57,12 +70,15 @@ pub fn get_connection(addr: &SocketAddr) -> Arc<dyn TpuConnection + 'static + Sy
|
||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
// TODO: see https://github.com/solana-labs/solana/issues/23659
|
||||
// make it configurable (e.g. via the command line) whether to use UDP or Quic
|
||||
let conn = Arc::new(UdpTpuConnection::new(send_socket, *addr));
|
||||
|
||||
let conn: Arc<dyn TpuConnection + 'static + Sync + Send> = if use_quic {
|
||||
Arc::new(QuicTpuConnection::new(send_socket, *addr))
|
||||
} else {
|
||||
Arc::new(UdpTpuConnection::new(send_socket, *addr))
|
||||
};
|
||||
|
||||
entry.insert((conn.clone(), ticks));
|
||||
(
|
||||
conn as Arc<dyn TpuConnection + 'static + Sync + Send>,
|
||||
ticks,
|
||||
)
|
||||
(conn, ticks)
|
||||
}
|
||||
};
|
||||
|
||||
|
2
programs/bpf/Cargo.lock
generated
2
programs/bpf/Cargo.lock
generated
@@ -3761,6 +3761,8 @@ version = "1.10.4"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"log",
|
||||
"solana-client",
|
||||
"solana-measure",
|
||||
"solana-metrics",
|
||||
"solana-runtime",
|
||||
"solana-sdk",
|
||||
|
@@ -75,7 +75,7 @@ use {
|
||||
},
|
||||
},
|
||||
solana_send_transaction_service::{
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo},
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo, DEFAULT_TPU_USE_QUIC},
|
||||
tpu_info::NullTpuInfo,
|
||||
},
|
||||
solana_storage_bigtable::Error as StorageError,
|
||||
@@ -323,6 +323,7 @@ impl JsonRpcRequestProcessor {
|
||||
receiver,
|
||||
1000,
|
||||
1,
|
||||
DEFAULT_TPU_USE_QUIC,
|
||||
);
|
||||
|
||||
Self {
|
||||
@@ -6087,6 +6088,7 @@ pub mod tests {
|
||||
receiver,
|
||||
1000,
|
||||
1,
|
||||
DEFAULT_TPU_USE_QUIC,
|
||||
);
|
||||
|
||||
let mut bad_transaction = system_transaction::transfer(
|
||||
@@ -6352,6 +6354,7 @@ pub mod tests {
|
||||
receiver,
|
||||
1000,
|
||||
1,
|
||||
DEFAULT_TPU_USE_QUIC,
|
||||
);
|
||||
assert_eq!(
|
||||
request_processor.get_block_commitment(0),
|
||||
|
@@ -50,6 +50,8 @@ use {
|
||||
tokio_util::codec::{BytesCodec, FramedRead},
|
||||
};
|
||||
|
||||
const FULL_SNAPSHOT_REQUEST_PATH: &str = "/snapshot.tar.bz2";
|
||||
const INCREMENTAL_SNAPSHOT_REQUEST_PATH: &str = "/incremental-snapshot.tar.bz2";
|
||||
const LARGEST_ACCOUNTS_CACHE_DURATION: u64 = 60 * 60 * 2;
|
||||
|
||||
pub struct JsonRpcService {
|
||||
@@ -227,16 +229,37 @@ impl RequestMiddleware for RpcRequestMiddleware {
|
||||
trace!("request uri: {}", request.uri());
|
||||
|
||||
if let Some(ref snapshot_config) = self.snapshot_config {
|
||||
if request.uri().path() == "/snapshot.tar.bz2" {
|
||||
if request.uri().path() == FULL_SNAPSHOT_REQUEST_PATH
|
||||
|| request.uri().path() == INCREMENTAL_SNAPSHOT_REQUEST_PATH
|
||||
{
|
||||
// Convenience redirect to the latest snapshot
|
||||
return if let Some(full_snapshot_archive_info) =
|
||||
let full_snapshot_archive_info =
|
||||
snapshot_utils::get_highest_full_snapshot_archive_info(
|
||||
&snapshot_config.snapshot_archives_dir,
|
||||
) {
|
||||
);
|
||||
let snapshot_archive_info =
|
||||
if let Some(full_snapshot_archive_info) = full_snapshot_archive_info {
|
||||
if request.uri().path() == FULL_SNAPSHOT_REQUEST_PATH {
|
||||
Some(full_snapshot_archive_info.snapshot_archive_info().clone())
|
||||
} else {
|
||||
snapshot_utils::get_highest_incremental_snapshot_archive_info(
|
||||
&snapshot_config.snapshot_archives_dir,
|
||||
full_snapshot_archive_info.slot(),
|
||||
)
|
||||
.map(|incremental_snapshot_archive_info| {
|
||||
incremental_snapshot_archive_info
|
||||
.snapshot_archive_info()
|
||||
.clone()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
return if let Some(snapshot_archive_info) = snapshot_archive_info {
|
||||
RpcRequestMiddleware::redirect(&format!(
|
||||
"/{}",
|
||||
full_snapshot_archive_info
|
||||
.path()
|
||||
snapshot_archive_info
|
||||
.path
|
||||
.file_name()
|
||||
.unwrap_or_else(|| std::ffi::OsStr::new(""))
|
||||
.to_str()
|
||||
|
@@ -5136,7 +5136,7 @@ impl AccountsDb {
|
||||
&self,
|
||||
slot: Slot,
|
||||
ancestors: &Ancestors,
|
||||
check_hash: bool,
|
||||
check_hash: bool, // this will not be supported anymore
|
||||
) -> Result<(Hash, u64), BankHashVerificationError> {
|
||||
use BankHashVerificationError::*;
|
||||
let mut collect = Measure::start("collect");
|
||||
@@ -5192,7 +5192,7 @@ impl AccountsDb {
|
||||
|loaded_account| {
|
||||
let loaded_hash = loaded_account.loaded_hash();
|
||||
let balance = loaded_account.lamports();
|
||||
if check_hash && !self.is_filler_account(pubkey) {
|
||||
if check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore
|
||||
let computed_hash =
|
||||
loaded_account.compute_hash(*slot, pubkey);
|
||||
if computed_hash != loaded_hash {
|
||||
@@ -5507,7 +5507,7 @@ impl AccountsDb {
|
||||
use_index: bool,
|
||||
slot: Slot,
|
||||
ancestors: &Ancestors,
|
||||
check_hash: bool,
|
||||
check_hash: bool, // this will not be supported anymore
|
||||
can_cached_slot_be_unflushed: bool,
|
||||
slots_per_epoch: Option<Slot>,
|
||||
is_startup: bool,
|
||||
@@ -5687,6 +5687,7 @@ impl AccountsDb {
|
||||
CalculateHashIntermediate::new(loaded_account.loaded_hash(), balance, *pubkey);
|
||||
|
||||
if check_hash && !Self::is_filler_account_helper(pubkey, filler_account_suffix) {
|
||||
// this will not be supported anymore
|
||||
let computed_hash = loaded_account.compute_hash(slot, pubkey);
|
||||
if computed_hash != source_item.hash {
|
||||
info!(
|
||||
@@ -5825,7 +5826,7 @@ impl AccountsDb {
|
||||
use BankHashVerificationError::*;
|
||||
|
||||
let use_index = false;
|
||||
let check_hash = true;
|
||||
let check_hash = false; // this will not be supported anymore
|
||||
let is_startup = true;
|
||||
let can_cached_slot_be_unflushed = false;
|
||||
let (calculated_hash, calculated_lamports) = self
|
||||
@@ -10136,7 +10137,7 @@ pub mod tests {
|
||||
db.add_root(some_slot);
|
||||
assert_matches!(
|
||||
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 1, true),
|
||||
Err(MismatchedAccountHash)
|
||||
Err(MismatchedBankHash)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -6450,6 +6450,11 @@ impl Bank {
|
||||
self.reconfigure_token2_native_mint();
|
||||
}
|
||||
self.ensure_no_storage_rewards_pool();
|
||||
|
||||
if new_feature_activations.contains(&feature_set::cap_accounts_data_len::id()) {
|
||||
const ACCOUNTS_DATA_LEN: u64 = 50_000_000_000;
|
||||
self.store_accounts_data_len(ACCOUNTS_DATA_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
fn adjust_sysvar_balance_for_rent(&self, account: &mut AccountSharedData) {
|
||||
|
@@ -77,15 +77,17 @@ pub mod solana_sdk {
|
||||
pub fn new() -> Keypair {
|
||||
Keypair
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pubkey(&self) -> Pubkey {
|
||||
impl Signer for Keypair {
|
||||
fn pubkey(&self) -> Pubkey {
|
||||
Pubkey::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Signer for Keypair {}
|
||||
|
||||
pub trait Signer {}
|
||||
pub trait Signer {
|
||||
fn pubkey(&self) -> Pubkey;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod signers {
|
||||
@@ -130,6 +132,16 @@ pub mod solana_sdk {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_signed_with_payer<T: Signers>(
|
||||
instructions: &[Instruction],
|
||||
payer: Option<&Pubkey>,
|
||||
signing_keypairs: &T,
|
||||
recent_blockhash: Hash,
|
||||
) -> Self {
|
||||
let message = Message::new(instructions, payer);
|
||||
Self::new(signing_keypairs, message, recent_blockhash)
|
||||
}
|
||||
|
||||
pub fn sign<T: Signers>(&mut self, _keypairs: &T, _recent_blockhash: Hash) {}
|
||||
}
|
||||
}
|
||||
|
@@ -164,7 +164,7 @@ impl Message {
|
||||
/// instruction::Instruction,
|
||||
/// message::Message,
|
||||
/// pubkey::Pubkey,
|
||||
/// signature::Keypair,
|
||||
/// signature::{Keypair, Signer},
|
||||
/// transaction::Transaction,
|
||||
/// };
|
||||
///
|
||||
@@ -235,7 +235,7 @@ impl Message {
|
||||
/// instruction::Instruction,
|
||||
/// message::Message,
|
||||
/// pubkey::Pubkey,
|
||||
/// signature::Keypair,
|
||||
/// signature::{Keypair, Signer},
|
||||
/// transaction::Transaction,
|
||||
/// };
|
||||
///
|
||||
@@ -333,7 +333,7 @@ impl Message {
|
||||
/// message::Message,
|
||||
/// nonce,
|
||||
/// pubkey::Pubkey,
|
||||
/// signature::Keypair,
|
||||
/// signature::{Keypair, Signer},
|
||||
/// system_instruction,
|
||||
/// transaction::Transaction,
|
||||
/// };
|
||||
|
@@ -346,22 +346,24 @@ impl Pubkey {
|
||||
///
|
||||
/// The client program:
|
||||
///
|
||||
/// ```ignore
|
||||
/// # // NB: This example depends on solana_sdk and solana_client, and adding
|
||||
/// # // those as dev-dependencies would create an unpublishable circular
|
||||
/// # // dependency, hence it is ignored.
|
||||
/// #
|
||||
/// ```
|
||||
/// # use borsh::{BorshSerialize, BorshDeserialize};
|
||||
/// # use solana_program::pubkey::Pubkey;
|
||||
/// # use solana_program::instruction::Instruction;
|
||||
/// # use solana_program::hash::Hash;
|
||||
/// # use solana_program::instruction::AccountMeta;
|
||||
/// # use solana_program::system_program;
|
||||
/// # use solana_sdk::signature::Keypair;
|
||||
/// # use solana_sdk::signature::{Signer, Signature};
|
||||
/// # use solana_sdk::transaction::Transaction;
|
||||
/// # use solana_program::example_mocks::{solana_sdk, solana_client};
|
||||
/// # use solana_program::{
|
||||
/// # pubkey::Pubkey,
|
||||
/// # instruction::Instruction,
|
||||
/// # hash::Hash,
|
||||
/// # instruction::AccountMeta,
|
||||
/// # system_program,
|
||||
/// # };
|
||||
/// # use solana_sdk::{
|
||||
/// # signature::Keypair,
|
||||
/// # signature::{Signer, Signature},
|
||||
/// # transaction::Transaction,
|
||||
/// # };
|
||||
/// # use solana_client::rpc_client::RpcClient;
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use anyhow::Result;
|
||||
/// #
|
||||
/// # #[derive(BorshSerialize, BorshDeserialize, Debug)]
|
||||
/// # struct InstructionData {
|
||||
@@ -370,52 +372,63 @@ impl Pubkey {
|
||||
/// # }
|
||||
/// #
|
||||
/// # pub static VAULT_ACCOUNT_SIZE: u64 = 1024;
|
||||
/// #
|
||||
/// fn create_vault_account(
|
||||
/// client: &RpcClient,
|
||||
/// program_id: Pubkey,
|
||||
/// payer: &Keypair,
|
||||
/// ) -> Result<()> {
|
||||
/// // Derive the PDA from the payer account, a string representing the unique
|
||||
/// // purpose of the account ("vault"), and the address of our on-chain program.
|
||||
/// let (vault_pubkey, vault_bump_seed) = Pubkey::find_program_address(
|
||||
/// &[b"vault", payer.pubkey().as_ref()],
|
||||
/// &program_id
|
||||
/// );
|
||||
///
|
||||
/// // Get the amount of lamports needed to pay for the vault's rent
|
||||
/// let vault_account_size = usize::try_from(VAULT_ACCOUNT_SIZE)?;
|
||||
/// let lamports = client.get_minimum_balance_for_rent_exemption(vault_account_size)?;
|
||||
///
|
||||
/// // The on-chain program's instruction data, imported from that program's crate.
|
||||
/// let instr_data = InstructionData {
|
||||
/// vault_bump_seed,
|
||||
/// lamports,
|
||||
/// };
|
||||
///
|
||||
/// // The accounts required by both our on-chain program and the system program's
|
||||
/// // `create_account` instruction, including the vault's address.
|
||||
/// let accounts = vec![
|
||||
/// AccountMeta::new(payer.pubkey(), true),
|
||||
/// AccountMeta::new(vault_pubkey, false),
|
||||
/// AccountMeta::new(system_program::ID, false),
|
||||
/// ];
|
||||
///
|
||||
/// // Create the instruction by serializing our instruction data via borsh
|
||||
/// let instruction = Instruction::new_with_borsh(
|
||||
/// program_id,
|
||||
/// &instr_data,
|
||||
/// accounts,
|
||||
/// );
|
||||
///
|
||||
/// let blockhash = client.get_latest_blockhash()?;
|
||||
///
|
||||
/// let transaction = Transaction::new_signed_with_payer(
|
||||
/// &[instruction],
|
||||
/// Some(&payer.pubkey()),
|
||||
/// &[payer],
|
||||
/// blockhash,
|
||||
/// );
|
||||
///
|
||||
/// client.send_and_confirm_transaction(&transaction)?;
|
||||
///
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// # let program_id = Pubkey::new_unique();
|
||||
/// # let payer = Keypair::new();
|
||||
/// # let rpc_client = RpcClient::new("no-run".to_string());
|
||||
/// # let client = RpcClient::new(String::new());
|
||||
/// #
|
||||
/// # create_vault_account(&client, program_id, &payer)?;
|
||||
/// #
|
||||
/// // Derive the PDA from the payer account, a string representing the unique
|
||||
/// // purpose of the account ("vault"), and the address of our on-chain program.
|
||||
/// let (vault_pubkey, vault_bump_seed) = Pubkey::find_program_address(
|
||||
/// &[b"vault", payer.pubkey().as_ref()],
|
||||
/// &program_id
|
||||
/// );
|
||||
///
|
||||
/// // Get the amount of lamports needed to pay for the vault's rent
|
||||
/// let vault_account_size = usize::try_from(VAULT_ACCOUNT_SIZE)?;
|
||||
/// let lamports = rpc_client.get_minimum_balance_for_rent_exemption(vault_account_size)?;
|
||||
///
|
||||
/// // The on-chain program's instruction data, imported from that program's crate.
|
||||
/// let instr_data = InstructionData {
|
||||
/// vault_bump_seed,
|
||||
/// lamports,
|
||||
/// };
|
||||
///
|
||||
/// // The accounts required by both our on-chain program and the system program's
|
||||
/// // `create_account` instruction, including the vault's address.
|
||||
/// let accounts = vec![
|
||||
/// AccountMeta::new(payer.pubkey(), true),
|
||||
/// AccountMeta::new(vault_pubkey, false),
|
||||
/// AccountMeta::new(system_program::ID, false),
|
||||
/// ];
|
||||
///
|
||||
/// // Create the instruction by serializing our instruction data via borsh
|
||||
/// let instruction = Instruction::new_with_borsh(
|
||||
/// program_id,
|
||||
/// &instr_data,
|
||||
/// accounts,
|
||||
/// );
|
||||
///
|
||||
/// let blockhash = rpc_client.get_latest_blockhash()?;
|
||||
///
|
||||
/// let transaction = Transaction::new_signed_with_payer(
|
||||
/// &[instruction],
|
||||
/// Some(&payer.pubkey()),
|
||||
/// &[&payer],
|
||||
/// blockhash,
|
||||
/// );
|
||||
///
|
||||
/// rpc_client.send_and_confirm_transaction(&transaction)?;
|
||||
/// # Ok::<(), anyhow::Error>(())
|
||||
/// ```
|
||||
pub fn find_program_address(seeds: &[&[u8]], program_id: &Pubkey) -> (Pubkey, u8) {
|
||||
|
@@ -12,10 +12,13 @@ edition = "2021"
|
||||
[dependencies]
|
||||
crossbeam-channel = "0.5"
|
||||
log = "0.4.14"
|
||||
solana-client = { path = "../client", version = "=1.10.4" }
|
||||
solana-measure = { path = "../measure", version = "=1.10.4" }
|
||||
solana-metrics = { path = "../metrics", version = "=1.10.4" }
|
||||
solana-runtime = { path = "../runtime", version = "=1.10.4" }
|
||||
solana-sdk = { path = "../sdk", version = "=1.10.4" }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
solana-logger = { path = "../logger", version = "=1.10.4" }
|
||||
|
||||
|
@@ -2,12 +2,14 @@ use {
|
||||
crate::tpu_info::TpuInfo,
|
||||
crossbeam_channel::{Receiver, RecvTimeoutError},
|
||||
log::*,
|
||||
solana_client::connection_cache,
|
||||
solana_measure::measure::Measure,
|
||||
solana_metrics::{datapoint_warn, inc_new_counter_info},
|
||||
solana_runtime::{bank::Bank, bank_forks::BankForks},
|
||||
solana_sdk::{hash::Hash, nonce_account, pubkey::Pubkey, signature::Signature},
|
||||
std::{
|
||||
collections::hash_map::{Entry, HashMap},
|
||||
net::{SocketAddr, UdpSocket},
|
||||
net::SocketAddr,
|
||||
sync::{Arc, RwLock},
|
||||
thread::{self, Builder, JoinHandle},
|
||||
time::{Duration, Instant},
|
||||
@@ -65,12 +67,15 @@ struct ProcessTransactionsResult {
|
||||
retained: u64,
|
||||
}
|
||||
|
||||
pub const DEFAULT_TPU_USE_QUIC: bool = false;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Config {
|
||||
pub retry_rate_ms: u64,
|
||||
pub leader_forward_count: u64,
|
||||
pub default_max_retries: Option<usize>,
|
||||
pub service_max_retries: usize,
|
||||
pub use_quic: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -80,6 +85,7 @@ impl Default for Config {
|
||||
leader_forward_count: DEFAULT_LEADER_FORWARD_COUNT,
|
||||
default_max_retries: None,
|
||||
service_max_retries: DEFAULT_SERVICE_MAX_RETRIES,
|
||||
use_quic: DEFAULT_TPU_USE_QUIC,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,10 +98,12 @@ impl SendTransactionService {
|
||||
receiver: Receiver<TransactionInfo>,
|
||||
retry_rate_ms: u64,
|
||||
leader_forward_count: u64,
|
||||
use_quic: bool,
|
||||
) -> Self {
|
||||
let config = Config {
|
||||
retry_rate_ms,
|
||||
leader_forward_count,
|
||||
use_quic,
|
||||
..Config::default()
|
||||
};
|
||||
Self::new_with_config(tpu_address, bank_forks, leader_info, receiver, config)
|
||||
@@ -128,12 +136,11 @@ impl SendTransactionService {
|
||||
let mut last_status_check = Instant::now();
|
||||
let mut last_leader_refresh = Instant::now();
|
||||
let mut transactions = HashMap::new();
|
||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
|
||||
if let Some(leader_info) = leader_info.as_mut() {
|
||||
leader_info.refresh_recent_peers();
|
||||
}
|
||||
|
||||
connection_cache::set_use_quic(config.use_quic);
|
||||
Builder::new()
|
||||
.name("send-tx-sv2".to_string())
|
||||
.spawn(move || loop {
|
||||
@@ -158,11 +165,7 @@ impl SendTransactionService {
|
||||
})
|
||||
.unwrap_or_else(|| vec![&tpu_address]);
|
||||
for address in addresses {
|
||||
Self::send_transaction(
|
||||
&send_socket,
|
||||
address,
|
||||
&transaction_info.wire_transaction,
|
||||
);
|
||||
Self::send_transaction(address, &transaction_info.wire_transaction);
|
||||
}
|
||||
if transactions_len < MAX_TRANSACTION_QUEUE_SIZE {
|
||||
inc_new_counter_info!("send_transaction_service-insert-tx", 1);
|
||||
@@ -193,7 +196,6 @@ impl SendTransactionService {
|
||||
let _result = Self::process_transactions(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&leader_info,
|
||||
@@ -215,7 +217,6 @@ impl SendTransactionService {
|
||||
fn process_transactions<T: TpuInfo>(
|
||||
working_bank: &Arc<Bank>,
|
||||
root_bank: &Arc<Bank>,
|
||||
send_socket: &UdpSocket,
|
||||
tpu_address: &SocketAddr,
|
||||
transactions: &mut HashMap<Signature, TransactionInfo>,
|
||||
leader_info: &Option<T>,
|
||||
@@ -286,11 +287,7 @@ impl SendTransactionService {
|
||||
})
|
||||
.unwrap_or_else(|| vec![tpu_address]);
|
||||
for address in addresses {
|
||||
Self::send_transaction(
|
||||
send_socket,
|
||||
address,
|
||||
&transaction_info.wire_transaction,
|
||||
);
|
||||
Self::send_transaction(address, &transaction_info.wire_transaction);
|
||||
}
|
||||
true
|
||||
}
|
||||
@@ -311,14 +308,20 @@ impl SendTransactionService {
|
||||
result
|
||||
}
|
||||
|
||||
fn send_transaction(
|
||||
send_socket: &UdpSocket,
|
||||
tpu_address: &SocketAddr,
|
||||
wire_transaction: &[u8],
|
||||
) {
|
||||
if let Err(err) = send_socket.send_to(wire_transaction, tpu_address) {
|
||||
fn send_transaction(tpu_address: &SocketAddr, wire_transaction: &[u8]) {
|
||||
let mut measure = Measure::start("send_transaction_service-us");
|
||||
let connection = connection_cache::get_connection(tpu_address);
|
||||
|
||||
if let Err(err) = connection.send_wire_transaction(wire_transaction) {
|
||||
warn!("Failed to send transaction to {}: {:?}", tpu_address, err);
|
||||
}
|
||||
measure.stop();
|
||||
inc_new_counter_info!(
|
||||
"send_transaction_service-us",
|
||||
measure.as_us() as usize,
|
||||
1000,
|
||||
1000
|
||||
);
|
||||
}
|
||||
|
||||
pub fn join(self) -> thread::Result<()> {
|
||||
@@ -352,6 +355,7 @@ mod test {
|
||||
receiver,
|
||||
1000,
|
||||
1,
|
||||
DEFAULT_TPU_USE_QUIC,
|
||||
);
|
||||
|
||||
drop(sender);
|
||||
@@ -365,7 +369,6 @@ mod test {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(4);
|
||||
let bank = Bank::new_for_tests(&genesis_config);
|
||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
|
||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let tpu_address = "127.0.0.1:0".parse().unwrap();
|
||||
let config = Config {
|
||||
leader_forward_count: 1,
|
||||
@@ -412,7 +415,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -441,7 +443,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -470,7 +471,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -499,7 +499,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -529,7 +528,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -569,7 +567,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -587,7 +584,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -610,7 +606,6 @@ mod test {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(4);
|
||||
let bank = Bank::new_for_tests(&genesis_config);
|
||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
|
||||
let send_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let tpu_address = "127.0.0.1:0".parse().unwrap();
|
||||
let config = Config {
|
||||
leader_forward_count: 1,
|
||||
@@ -667,7 +662,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -695,7 +689,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -725,7 +718,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -753,7 +745,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -782,7 +773,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -811,7 +801,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -841,7 +830,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
@@ -866,7 +854,6 @@ mod test {
|
||||
let result = SendTransactionService::process_transactions::<NullTpuInfo>(
|
||||
&working_bank,
|
||||
&root_bank,
|
||||
&send_socket,
|
||||
&tpu_address,
|
||||
&mut transactions,
|
||||
&None,
|
||||
|
@@ -9,6 +9,7 @@ use {
|
||||
console::style,
|
||||
log::*,
|
||||
rand::{seq::SliceRandom, thread_rng},
|
||||
send_transaction_service::DEFAULT_TPU_USE_QUIC,
|
||||
solana_clap_utils::{
|
||||
input_parsers::{keypair_of, keypairs_of, pubkey_of, value_of},
|
||||
input_validators::{
|
||||
@@ -456,6 +457,7 @@ pub fn main() {
|
||||
let default_accounts_shrink_ratio = &DEFAULT_ACCOUNTS_SHRINK_RATIO.to_string();
|
||||
let default_rocksdb_fifo_shred_storage_size =
|
||||
&DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES.to_string();
|
||||
let default_tpu_use_quic = &DEFAULT_TPU_USE_QUIC.to_string();
|
||||
|
||||
let matches = App::new(crate_name!()).about(crate_description!())
|
||||
.version(solana_version::version!())
|
||||
@@ -1144,6 +1146,14 @@ pub fn main() {
|
||||
.validator(is_parsable::<u64>)
|
||||
.help("Milliseconds to wait in the TPU receiver for packet coalescing."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("tpu_use_quic")
|
||||
.long("tpu-use-quic")
|
||||
.takes_value(true)
|
||||
.value_name("BOOLEAN")
|
||||
.default_value(default_tpu_use_quic)
|
||||
.help("When this is set to true, the system will use QUIC to send transactions."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("rocksdb_max_compaction_jitter")
|
||||
.long("rocksdb-max-compaction-jitter-slots")
|
||||
@@ -2095,6 +2105,8 @@ pub fn main() {
|
||||
let restricted_repair_only_mode = matches.is_present("restricted_repair_only_mode");
|
||||
let accounts_shrink_optimize_total_space =
|
||||
value_t_or_exit!(matches, "accounts_shrink_optimize_total_space", bool);
|
||||
let tpu_use_quic = value_t_or_exit!(matches, "tpu_use_quic", bool);
|
||||
|
||||
let shrink_ratio = value_t_or_exit!(matches, "accounts_shrink_ratio", f64);
|
||||
if !(0.0..=1.0).contains(&shrink_ratio) {
|
||||
eprintln!(
|
||||
@@ -2366,6 +2378,7 @@ pub fn main() {
|
||||
"rpc_send_transaction_service_max_retries",
|
||||
usize
|
||||
),
|
||||
use_quic: tpu_use_quic,
|
||||
},
|
||||
no_poh_speed_test: matches.is_present("no_poh_speed_test"),
|
||||
no_os_memory_stats_reporting: matches.is_present("no_os_memory_stats_reporting"),
|
||||
|
Reference in New Issue
Block a user