forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add in method for building a TpuClient
for LocalCluster
tests
#258
Merged
gregcusack
merged 2 commits into
anza-xyz:master
from
gregcusack:tpu-client-from-entrypoint
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,12 @@ use { | |
itertools::izip, | ||
log::*, | ||
solana_accounts_db::utils::create_accounts_run_and_snapshot_dirs, | ||
solana_client::{connection_cache::ConnectionCache, thin_client::ThinClient}, | ||
solana_client::{ | ||
connection_cache::ConnectionCache, | ||
rpc_client::RpcClient, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this dependency on |
||
thin_client::ThinClient, | ||
tpu_client::{QuicTpuClient, TpuClient, TpuClientConfig}, | ||
}, | ||
solana_core::{ | ||
consensus::tower_storage::FileTowerStorage, | ||
validator::{Validator, ValidatorConfig, ValidatorStartProgress}, | ||
|
@@ -802,6 +807,34 @@ impl LocalCluster { | |
..SnapshotConfig::new_load_only() | ||
} | ||
} | ||
|
||
fn build_tpu_client<F>(&self, rpc_client_builder: F) -> Result<QuicTpuClient> | ||
where | ||
F: FnOnce(String) -> Arc<RpcClient>, | ||
{ | ||
let rpc_pubsub_url = format!("ws://{}/", self.entry_point_info.rpc_pubsub().unwrap()); | ||
let rpc_url = format!("http://{}", self.entry_point_info.rpc().unwrap()); | ||
|
||
let cache = match &*self.connection_cache { | ||
ConnectionCache::Quic(cache) => cache, | ||
ConnectionCache::Udp(_) => { | ||
return Err(Error::new( | ||
ErrorKind::Other, | ||
"Expected a Quic ConnectionCache. Got UDP", | ||
)) | ||
} | ||
}; | ||
|
||
let tpu_client = TpuClient::new_with_connection_cache( | ||
rpc_client_builder(rpc_url), | ||
rpc_pubsub_url.as_str(), | ||
TpuClientConfig::default(), | ||
cache.clone(), | ||
) | ||
.map_err(|err| Error::new(ErrorKind::Other, format!("TpuSenderError: {}", err)))?; | ||
|
||
Ok(tpu_client) | ||
} | ||
} | ||
|
||
impl Cluster for LocalCluster { | ||
|
@@ -820,6 +853,19 @@ impl Cluster for LocalCluster { | |
}) | ||
} | ||
|
||
fn build_tpu_quic_client(&self) -> Result<QuicTpuClient> { | ||
self.build_tpu_client(|rpc_url| Arc::new(RpcClient::new(rpc_url))) | ||
} | ||
|
||
fn build_tpu_quic_client_with_commitment( | ||
&self, | ||
commitment_config: CommitmentConfig, | ||
) -> Result<QuicTpuClient> { | ||
self.build_tpu_client(|rpc_url| { | ||
Arc::new(RpcClient::new_with_commitment(rpc_url, commitment_config)) | ||
}) | ||
} | ||
|
||
fn exit_node(&mut self, pubkey: &Pubkey) -> ClusterValidatorInfo { | ||
let mut node = self.validators.remove(pubkey).unwrap(); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's import
solana_tpu_client
directly, since the dependency onConnectionCache
is going away. We may be able to removesolana_client
entirely, eventually.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh this is good to know. i was actually going to ask about this, since
solana_client
seems to be just a wrapper aroundsolana_tpu_client
. sounds good!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this needs to be separate PRs. Add in with dependency on
solana_client
and then another PR that switches over the dependencies tosolana_tpu_client
. A lot of the code includingbench-tps
relies onsolana_client
. For example,bench-tps
implementsBenchTpsClient
forsolana_client/tpu_client
notsolana_tpu_client/tpu_client
. so switching this up in this PR as well may be large.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to do dependency updates in a separate PR, that's fine with me. I can definitely see the argument for that. Just let me know whether you think it makes more sense to do it before or after this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to do it after this PR. This code will be following same usage as previous code (aka using
solana_client::tpu_client
. I have another PR in drafts that will then switch over to usingsolana-tpu-client
. Then I will make another PR that finally switches overThinClient
inLocalCluster
tosolana-tpu-client
.