Skip to content

Commit faefd71

Browse files
committed
admin: address sentinel PR review feedback
Switch RpcDzLedgerReader to use the nonblocking Solana RPC client so tokio::try_join! actually runs fetches concurrently. Add solana tenant filtering to the create command to match the find command.
1 parent 5e28c25 commit faefd71

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

controlplane/doublezero-admin/src/cli/sentinel.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use doublezero_sentinel::{
1414
};
1515
use doublezero_serviceability::pda::get_tenant_pda;
1616
use serde::Serialize;
17-
use solana_client::rpc_client::RpcClient;
17+
use solana_client::{
18+
nonblocking::rpc_client::RpcClient as NonblockingRpcClient, rpc_client::RpcClient,
19+
};
1820
use solana_sdk::{
1921
commitment_config::CommitmentConfig,
2022
instruction::Instruction,
@@ -132,7 +134,7 @@ impl FindValidatorMulticastPublishersCommand {
132134
api_url: self.validator_metadata_url.clone(),
133135
};
134136
let dz_ledger = RpcDzLedgerReader::new(
135-
RpcClient::new_with_commitment(
137+
NonblockingRpcClient::new_with_commitment(
136138
dzclient.get_rpc().clone(),
137139
CommitmentConfig::confirmed(),
138140
),
@@ -428,7 +430,7 @@ impl CreateValidatorMulticastPublishersCommand {
428430
api_url: self.validator_metadata_url.clone(),
429431
};
430432
let dz_ledger = RpcDzLedgerReader::new(
431-
RpcClient::new_with_commitment(
433+
NonblockingRpcClient::new_with_commitment(
432434
dzclient.get_rpc().clone(),
433435
CommitmentConfig::confirmed(),
434436
),
@@ -445,9 +447,13 @@ impl CreateValidatorMulticastPublishersCommand {
445447
multicast_group_pk, self.multicast_group
446448
);
447449

450+
// Derive the solana tenant PDA to scope user queries.
451+
let (solana_tenant_pk, _) = get_tenant_pda(&program_id, "solana");
452+
let default_tenant_pk = Pubkey::default();
453+
448454
// Fetch users and validator data.
449455
eprintln!("Fetching DZ Ledger users and validator metadata...");
450-
let (all_users, validators) = tokio::try_join!(
456+
let (all_users_unfiltered, validators) = tokio::try_join!(
451457
async {
452458
dz_ledger
453459
.fetch_all_dz_users()
@@ -462,6 +468,12 @@ impl CreateValidatorMulticastPublishersCommand {
462468
},
463469
)?;
464470

471+
// Scope to solana tenant (or default/unset tenant).
472+
let all_users: Vec<_> = all_users_unfiltered
473+
.into_iter()
474+
.filter(|u| u.tenant_pk == solana_tenant_pk || u.tenant_pk == default_tenant_pk)
475+
.collect();
476+
465477
let device_labels: HashMap<Pubkey, String> = codes
466478
.as_ref()
467479
.map(|c| c.device_codes.clone())

crates/sentinel/src/dz_ledger_reader.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use doublezero_sdk::{
66
};
77
use solana_account_decoder::UiAccountEncoding;
88
use solana_client::{
9+
nonblocking::rpc_client::RpcClient as NonblockingRpcClient,
910
rpc_client::RpcClient,
1011
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
1112
rpc_filter::{Memcmp, RpcFilterType},
@@ -52,12 +53,12 @@ pub trait DzLedgerReader: Send + Sync {
5253
// ---------------------------------------------------------------------------
5354

5455
pub struct RpcDzLedgerReader {
55-
client: RpcClient,
56+
client: NonblockingRpcClient,
5657
program_id: Pubkey,
5758
}
5859

5960
impl RpcDzLedgerReader {
60-
pub fn new(client: RpcClient, program_id: Pubkey) -> Self {
61+
pub fn new(client: NonblockingRpcClient, program_id: Pubkey) -> Self {
6162
Self { client, program_id }
6263
}
6364
}
@@ -82,6 +83,7 @@ impl DzLedgerReader for RpcDzLedgerReader {
8283
..Default::default()
8384
},
8485
)
86+
.await
8587
.context("failed to fetch User accounts from DZ Ledger")?;
8688

8789
let mut users = Vec::new();
@@ -126,6 +128,7 @@ impl DzLedgerReader for RpcDzLedgerReader {
126128
..Default::default()
127129
},
128130
)
131+
.await
129132
.context("failed to fetch MulticastGroup accounts from DZ Ledger")?;
130133

131134
for (pk, account) in accounts {

0 commit comments

Comments
 (0)