Skip to content
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

local-cluster: fix flaky test_rpc_block_subscribe #34421

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2562,35 +2562,41 @@ fn run_test_load_program_accounts_partition(scan_commitment: CommitmentConfig) {

#[test]
#[serial]
#[ignore]
fn test_rpc_block_subscribe() {
let total_stake = 100 * DEFAULT_NODE_STAKE;
let leader_stake = total_stake;
let node_stakes = vec![leader_stake];
let leader_stake = 100 * DEFAULT_NODE_STAKE;
let rpc_stake = DEFAULT_NODE_STAKE;
let total_stake = leader_stake + rpc_stake;
let node_stakes = vec![leader_stake, rpc_stake];
let mut validator_config = ValidatorConfig::default_for_test();
validator_config.enable_default_rpc_block_subscribe();

let validator_keys = [
"28bN3xyvrP4E8LwEgtLjhnkb7cY4amQb6DrYAbAYjgRV4GAGgkVM2K7wnxnAS7WDneuavza7x21MiafLu1HkwQt4",
"2saHBBoTkLMmttmPQP8KfBkcCw45S5cwtV3wTdGCscRC8uxdgvHxpHiWXKx4LvJjNJtnNcbSv5NdheokFFqnNDt8",
]
.iter()
.map(|s| (Arc::new(Keypair::from_base58_string(s)), true))
.take(node_stakes.len())
.collect::<Vec<_>>();
let rpc_node_pubkey = &validator_keys[1].0.pubkey();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to document or point to this PR for why we chose this validator key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the comment to the subscribe call


let mut config = ClusterConfig {
cluster_lamports: total_stake,
node_stakes,
validator_configs: vec![validator_config],
validator_configs: make_identical_validator_configs(&validator_config, 2),
validator_keys: Some(validator_keys),
skip_warmup_slots: true,
..ClusterConfig::default()
};
let cluster = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified);
let rpc_node_contact_info = cluster.get_contact_info(rpc_node_pubkey).unwrap();
let (mut block_subscribe_client, receiver) = PubsubClient::block_subscribe(
&format!(
"ws://{}",
&cluster.entry_point_info.rpc_pubsub().unwrap().to_string()
// It is important that we subscribe to a non leader node as there
// is a race condition which can cause leader nodes to not send
// BlockUpdate notifications properly. See https://github.com/solana-labs/solana/pull/34421
&rpc_node_contact_info.rpc_pubsub().unwrap().to_string()
),
RpcBlockSubscribeFilter::All,
Some(RpcBlockSubscribeConfig {
Expand Down