From 66f2a0cea13195c7a4ad6d0c6e07038044324c77 Mon Sep 17 00:00:00 2001 From: xternet Date: Thu, 13 Aug 2026 21:34:49 +0200 Subject: [PATCH] fix(core): honor commitment for remote account batches --- crates/core/src/surfnet/remote.rs | 63 ++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/crates/core/src/surfnet/remote.rs b/crates/core/src/surfnet/remote.rs index 3b50bd9c3..64bc57804 100644 --- a/crates/core/src/surfnet/remote.rs +++ b/crates/core/src/surfnet/remote.rs @@ -261,9 +261,10 @@ impl SurfnetRemoteClient { let remote_accounts = self .client - .get_multiple_accounts(pubkeys) + .get_multiple_accounts_with_commitment(pubkeys, commitment_config) .await - .map_err(SurfpoolError::get_multiple_accounts)?; + .map_err(SurfpoolError::get_multiple_accounts)? + .value; debug!("Fetched {:?} accounts from remote", pubkeys); debug!( "Found accounts for pubkeys: {:#?}", @@ -571,8 +572,66 @@ where #[cfg(test)] mod tests { + use std::sync::{Arc, Mutex}; + use super::*; + struct RecordsRequests { + requests: Arc>>, + } + + #[async_trait] + impl RpcSender for RecordsRequests { + async fn send( + &self, + request: RpcRequest, + params: serde_json::Value, + ) -> ClientResult { + self.requests + .lock() + .expect("request recorder mutex should not be poisoned") + .push((request, params)); + Ok(json!({ + "context": { "slot": 1 }, + "value": [null], + })) + } + + fn get_transport_stats(&self) -> RpcTransportStats { + RpcTransportStats::default() + } + + fn url(&self) -> String { + "http://records.example".to_string() + } + } + + #[tokio::test] + async fn multiple_account_fetch_uses_the_requested_commitment() { + let requests = Arc::new(Mutex::new(Vec::new())); + let client = SurfnetRemoteClient { + client: RpcClient::new_sender( + RecordsRequests { + requests: Arc::clone(&requests), + }, + RpcClientConfig::default(), + ), + }; + + let pubkey = Pubkey::new_unique(); + client + .get_multiple_accounts(&[pubkey], CommitmentConfig::confirmed()) + .await + .expect("remote account fetch should succeed"); + + let requests = requests + .lock() + .expect("request recorder mutex should not be poisoned"); + assert_eq!(requests.len(), 1); + assert_eq!(requests[0].0, RpcRequest::GetMultipleAccounts); + assert_eq!(requests[0].1[1]["commitment"], "confirmed"); + } + /// A call that never completes, whether because the endpoint went quiet /// or because its retry policy never gave control back. The deadline does /// not need to know which.