* Forward transactions to the expected leader instead of your own TPU port (#12004)
* Use PoHRecorder to send to the right leader
* cleanup
* fmt
* clippy
* Cleanup, fix bug
Co-authored-by: Carl <carl@solana.com>
(cherry picked from commit c67f8bd821
)
# Conflicts:
# banks-server/Cargo.toml
* Update Cargo.toml
Co-authored-by: anatoly yakovenko <anatoly@solana.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
//! The `rpc_service` module implements the Solana JSON RPC service.
|
||||
|
||||
use crate::{
|
||||
bigtable_upload_service::BigTableUploadService, cluster_info::ClusterInfo, rpc::*,
|
||||
rpc_health::*, validator::ValidatorExit,
|
||||
bigtable_upload_service::BigTableUploadService,
|
||||
cluster_info::ClusterInfo,
|
||||
poh_recorder::PohRecorder,
|
||||
rpc::*,
|
||||
rpc_health::*,
|
||||
send_transaction_service::{LeaderInfo, SendTransactionService},
|
||||
validator::ValidatorExit,
|
||||
};
|
||||
use jsonrpc_core::MetaIoHandler;
|
||||
use jsonrpc_http_server::{
|
||||
@@ -14,7 +19,6 @@ use solana_ledger::blockstore::Blockstore;
|
||||
use solana_runtime::{
|
||||
bank_forks::{BankForks, SnapshotConfig},
|
||||
commitment::BlockCommitmentCache,
|
||||
send_transaction_service::SendTransactionService,
|
||||
snapshot_utils,
|
||||
};
|
||||
use solana_sdk::{hash::Hash, native_token::lamports_to_sol, pubkey::Pubkey};
|
||||
@@ -23,7 +27,7 @@ use std::{
|
||||
net::SocketAddr,
|
||||
path::{Path, PathBuf},
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
sync::{mpsc::channel, Arc, RwLock},
|
||||
sync::{mpsc::channel, Arc, Mutex, RwLock},
|
||||
thread::{self, Builder, JoinHandle},
|
||||
};
|
||||
use tokio::runtime;
|
||||
@@ -239,6 +243,7 @@ impl JsonRpcService {
|
||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
||||
blockstore: Arc<Blockstore>,
|
||||
cluster_info: Arc<ClusterInfo>,
|
||||
poh_recorder: Option<Arc<Mutex<PohRecorder>>>,
|
||||
genesis_hash: Hash,
|
||||
ledger_path: &Path,
|
||||
validator_exit: Arc<RwLock<Option<ValidatorExit>>>,
|
||||
@@ -302,16 +307,19 @@ impl JsonRpcService {
|
||||
blockstore,
|
||||
validator_exit.clone(),
|
||||
health.clone(),
|
||||
cluster_info,
|
||||
cluster_info.clone(),
|
||||
genesis_hash,
|
||||
&runtime,
|
||||
bigtable_ledger_storage,
|
||||
);
|
||||
|
||||
let exit_send_transaction_service = Arc::new(AtomicBool::new(false));
|
||||
let leader_info =
|
||||
poh_recorder.map(|recorder| LeaderInfo::new(cluster_info.clone(), recorder));
|
||||
let _send_transaction_service = Arc::new(SendTransactionService::new(
|
||||
tpu_address,
|
||||
&bank_forks,
|
||||
leader_info,
|
||||
&exit_send_transaction_service,
|
||||
receiver,
|
||||
));
|
||||
@@ -438,6 +446,7 @@ mod tests {
|
||||
block_commitment_cache,
|
||||
blockstore,
|
||||
cluster_info,
|
||||
None,
|
||||
Hash::default(),
|
||||
&PathBuf::from("farf"),
|
||||
validator_exit,
|
||||
|
Reference in New Issue
Block a user