-
Notifications
You must be signed in to change notification settings - Fork 1k
Add local cluster utitlity functions #355
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,10 @@ use { | |
| connection_cache::{ConnectionCache, Protocol}, | ||
| thin_client::ThinClient, | ||
| }, | ||
| solana_core::consensus::VOTE_THRESHOLD_DEPTH, | ||
| solana_core::consensus::{ | ||
| tower_storage::{FileTowerStorage, SavedTower, SavedTowerVersions, TowerStorage}, | ||
| VOTE_THRESHOLD_DEPTH, | ||
| }, | ||
| solana_entry::entry::{Entry, EntrySlice}, | ||
| solana_gossip::{ | ||
| cluster_info::{self, ClusterInfo}, | ||
|
|
@@ -43,7 +46,7 @@ use { | |
| borrow::Borrow, | ||
| collections::{HashMap, HashSet, VecDeque}, | ||
| net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener}, | ||
| path::Path, | ||
| path::{Path, PathBuf}, | ||
| sync::{ | ||
| atomic::{AtomicBool, Ordering}, | ||
| Arc, RwLock, | ||
|
|
@@ -334,6 +337,53 @@ pub fn kill_entry_and_spend_and_verify_rest( | |
| } | ||
| } | ||
|
|
||
| pub fn apply_votes_to_tower(node_keypair: &Keypair, votes: Vec<(Slot, Hash)>, tower_path: PathBuf) { | ||
| let tower_storage = FileTowerStorage::new(tower_path); | ||
| let mut tower = tower_storage.load(&node_keypair.pubkey()).unwrap(); | ||
| for (slot, hash) in votes { | ||
| tower.record_vote(slot, hash); | ||
| } | ||
| let saved_tower = SavedTowerVersions::from(SavedTower::new(&tower, node_keypair).unwrap()); | ||
| tower_storage.store(&saved_tower).unwrap(); | ||
| } | ||
|
|
||
| pub fn check_min_slot_is_rooted( | ||
| min_slot: Slot, | ||
|
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. I'm confused: why is this min_slot instead of just slot? (How is min_slot different from a normal slot?)
Author
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. it's not guaranteed that at the time you check that the |
||
| contact_infos: &[ContactInfo], | ||
| connection_cache: &Arc<ConnectionCache>, | ||
|
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. nit: Probably better to describe in function name or comments we are testing the designated slot is root on all given contact_infos?
Author
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. it's not that we are checking that |
||
| test_name: &str, | ||
| ) { | ||
| let mut last_print = Instant::now(); | ||
| let loop_start = Instant::now(); | ||
| let loop_timeout = Duration::from_secs(180); | ||
| for ingress_node in contact_infos.iter() { | ||
| let (rpc, tpu) = LegacyContactInfo::try_from(ingress_node) | ||
| .map(|node| get_client_facing_addr(connection_cache.protocol(), node)) | ||
| .unwrap(); | ||
|
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. Are we sure this unwrap() will always succeed?
Author
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. yup if the contact info is well formed seems like it should always work |
||
| let client = ThinClient::new(rpc, tpu, connection_cache.clone()); | ||
| loop { | ||
| let root_slot = client | ||
| .get_slot_with_commitment(CommitmentConfig::finalized()) | ||
|
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. don't know the context of where you plan to use this yet, but is this more preferable than checking
Author
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. That was the other option, but this was intended as a faster replacement for Directly introspecting the tower has always been more of a hack, since |
||
| .unwrap_or(0); | ||
| if root_slot >= min_slot || last_print.elapsed().as_secs() > 3 { | ||
| info!( | ||
| "{} waiting for node {} to see root >= {}.. observed latest root: {}", | ||
| test_name, | ||
| ingress_node.pubkey(), | ||
| min_slot, | ||
| root_slot | ||
| ); | ||
| last_print = Instant::now(); | ||
| if root_slot >= min_slot { | ||
| break; | ||
| } | ||
| } | ||
| sleep(Duration::from_millis(clock::DEFAULT_MS_PER_SLOT / 2)); | ||
| assert!(loop_start.elapsed() < loop_timeout); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn check_for_new_roots( | ||
| num_new_roots: usize, | ||
| contact_infos: &[ContactInfo], | ||
|
|
||
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.
think you can use the new guy here:
Uh oh!
There was an error while loading. Please reload this page.
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.
didn't even realize this existed, works much wao
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.
huh works locally but is failing CI: https://buildkite.com/anza/agave/builds/1225#018e68a5-2942-41ba-973a-bf89c03c8950
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.
huh strange. I'm fine if you push it without the flag for now
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.
cool, removed