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>
This commit is contained in:
committed by
GitHub
parent
9eebaa2e59
commit
c67f8bd821
@@ -1,9 +1,13 @@
|
||||
//! The `rpc` module implements the Solana RPC interface.
|
||||
|
||||
use crate::{
|
||||
cluster_info::ClusterInfo, contact_info::ContactInfo,
|
||||
non_circulating_supply::calculate_non_circulating_supply, rpc_error::RpcCustomError,
|
||||
rpc_health::*, validator::ValidatorExit,
|
||||
cluster_info::ClusterInfo,
|
||||
contact_info::ContactInfo,
|
||||
non_circulating_supply::calculate_non_circulating_supply,
|
||||
rpc_error::RpcCustomError,
|
||||
rpc_health::*,
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo},
|
||||
validator::ValidatorExit,
|
||||
};
|
||||
use bincode::{config::Options, serialize};
|
||||
use jsonrpc_core::{types::error, Error, Metadata, Result};
|
||||
@@ -36,7 +40,6 @@ use solana_runtime::{
|
||||
bank::Bank,
|
||||
bank_forks::BankForks,
|
||||
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
|
||||
send_transaction_service::{SendTransactionService, TransactionInfo},
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
@@ -213,7 +216,7 @@ impl JsonRpcRequestProcessor {
|
||||
let cluster_info = Arc::new(ClusterInfo::default());
|
||||
let tpu_address = cluster_info.my_contact_info().tpu;
|
||||
let (sender, receiver) = channel();
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
|
||||
Self {
|
||||
config: JsonRpcConfig::default(),
|
||||
@@ -2692,7 +2695,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
|
||||
cluster_info.insert_info(ContactInfo::new_with_pubkey_socketaddr(
|
||||
&leader_pubkey,
|
||||
@@ -4004,7 +4007,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"sendTransaction","params":["37u9WtQpcm6ULa3Vmu7ySnANv"]}"#;
|
||||
let res = io.handle_request_sync(req, meta);
|
||||
@@ -4045,7 +4048,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
|
||||
let mut bad_transaction =
|
||||
system_transaction::transfer(&mint_keypair, &Pubkey::new_rand(), 42, Hash::default());
|
||||
@@ -4227,7 +4230,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
assert_eq!(request_processor.validator_exit(), false);
|
||||
assert_eq!(exit.load(Ordering::Relaxed), false);
|
||||
}
|
||||
@@ -4256,7 +4259,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
assert_eq!(request_processor.validator_exit(), true);
|
||||
assert_eq!(exit.load(Ordering::Relaxed), true);
|
||||
}
|
||||
@@ -4342,7 +4345,7 @@ pub mod tests {
|
||||
&runtime::Runtime::new().unwrap(),
|
||||
None,
|
||||
);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, &exit, receiver);
|
||||
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
|
||||
assert_eq!(
|
||||
request_processor.get_block_commitment(0),
|
||||
RpcBlockCommitment {
|
||||
|
Reference in New Issue
Block a user