local-cluster: fix flaky test_rpc_block_subscribe (#34421)
* local-cluster: fix flaky test_rpc_block_subscribe * reenable test * pr feedback: add comment linking pr
This commit is contained in:
parent
c7a57672d7
commit
4f1116164c
|
@ -2562,35 +2562,41 @@ fn run_test_load_program_accounts_partition(scan_commitment: CommitmentConfig) {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial]
|
#[serial]
|
||||||
#[ignore]
|
|
||||||
fn test_rpc_block_subscribe() {
|
fn test_rpc_block_subscribe() {
|
||||||
let total_stake = 100 * DEFAULT_NODE_STAKE;
|
let leader_stake = 100 * DEFAULT_NODE_STAKE;
|
||||||
let leader_stake = total_stake;
|
let rpc_stake = DEFAULT_NODE_STAKE;
|
||||||
let node_stakes = vec![leader_stake];
|
let total_stake = leader_stake + rpc_stake;
|
||||||
|
let node_stakes = vec![leader_stake, rpc_stake];
|
||||||
let mut validator_config = ValidatorConfig::default_for_test();
|
let mut validator_config = ValidatorConfig::default_for_test();
|
||||||
validator_config.enable_default_rpc_block_subscribe();
|
validator_config.enable_default_rpc_block_subscribe();
|
||||||
|
|
||||||
let validator_keys = [
|
let validator_keys = [
|
||||||
"28bN3xyvrP4E8LwEgtLjhnkb7cY4amQb6DrYAbAYjgRV4GAGgkVM2K7wnxnAS7WDneuavza7x21MiafLu1HkwQt4",
|
"28bN3xyvrP4E8LwEgtLjhnkb7cY4amQb6DrYAbAYjgRV4GAGgkVM2K7wnxnAS7WDneuavza7x21MiafLu1HkwQt4",
|
||||||
|
"2saHBBoTkLMmttmPQP8KfBkcCw45S5cwtV3wTdGCscRC8uxdgvHxpHiWXKx4LvJjNJtnNcbSv5NdheokFFqnNDt8",
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| (Arc::new(Keypair::from_base58_string(s)), true))
|
.map(|s| (Arc::new(Keypair::from_base58_string(s)), true))
|
||||||
.take(node_stakes.len())
|
.take(node_stakes.len())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
let rpc_node_pubkey = &validator_keys[1].0.pubkey();
|
||||||
|
|
||||||
let mut config = ClusterConfig {
|
let mut config = ClusterConfig {
|
||||||
cluster_lamports: total_stake,
|
cluster_lamports: total_stake,
|
||||||
node_stakes,
|
node_stakes,
|
||||||
validator_configs: vec![validator_config],
|
validator_configs: make_identical_validator_configs(&validator_config, 2),
|
||||||
validator_keys: Some(validator_keys),
|
validator_keys: Some(validator_keys),
|
||||||
skip_warmup_slots: true,
|
skip_warmup_slots: true,
|
||||||
..ClusterConfig::default()
|
..ClusterConfig::default()
|
||||||
};
|
};
|
||||||
let cluster = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified);
|
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(
|
let (mut block_subscribe_client, receiver) = PubsubClient::block_subscribe(
|
||||||
&format!(
|
&format!(
|
||||||
"ws://{}",
|
"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,
|
RpcBlockSubscribeFilter::All,
|
||||||
Some(RpcBlockSubscribeConfig {
|
Some(RpcBlockSubscribeConfig {
|
||||||
|
|
Loading…
Reference in New Issue