Skip to content

Commit f98c74a

Browse files
authored
chore: light client sdk cleanup (#1799)
* test: add missing error to error codes test * chore: rename RpcConfig -> LightClientConfig * chore: format, fix: light-program-test remove env variable modification during program setup * feat: light program test skip startup logs * fix: logging consistency
1 parent b2a2364 commit f98c74a

29 files changed

+104
-102
lines changed

forester-utils/src/rpc_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{cmp::min, time::Duration};
22

33
use async_trait::async_trait;
44
use bb8::{Pool, PooledConnection};
5-
use light_client::rpc::{Rpc, RpcConfig, RpcError};
5+
use light_client::rpc::{LightClientConfig, Rpc, RpcError};
66
use solana_sdk::commitment_config::CommitmentConfig;
77
use thiserror::Error;
88
use tokio::time::sleep;
@@ -56,7 +56,7 @@ impl<R: Rpc + 'static> bb8::ManageConnection for SolanaConnectionManager<R> {
5656
type Error = PoolError;
5757

5858
async fn connect(&self) -> Result<Self::Connection, Self::Error> {
59-
let config = RpcConfig {
59+
let config = LightClientConfig {
6060
url: self.url.to_string(),
6161
commitment_config: Some(self.commitment),
6262
with_indexer: false,

forester/src/epoch_manager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use forester_utils::{
1616
use futures::future::join_all;
1717
use light_client::{
1818
indexer::{Indexer, MerkleProof, NewAddressProofWithContext},
19-
rpc::{LightClient, RetryConfig, Rpc, RpcConfig, RpcError},
19+
rpc::{LightClient, LightClientConfig, RetryConfig, Rpc, RpcError},
2020
};
2121
use light_compressed_account::TreeType;
2222
use light_registry::{
@@ -473,7 +473,7 @@ impl<R: Rpc, I: Indexer + IndexerType<R> + 'static> EpochManager<R, I> {
473473
max_retries: u32,
474474
retry_delay: Duration,
475475
) -> Result<ForesterEpochInfo> {
476-
let rpc = LightClient::new(RpcConfig {
476+
let rpc = LightClient::new(LightClientConfig {
477477
url: self.config.external_services.rpc_url.to_string(),
478478
commitment_config: None,
479479
fetch_active_tree: false,
@@ -543,7 +543,7 @@ impl<R: Rpc, I: Indexer + IndexerType<R> + 'static> EpochManager<R, I> {
543543
))]
544544
async fn register_for_epoch(&self, epoch: u64) -> Result<ForesterEpochInfo> {
545545
info!("Registering for epoch: {}", epoch);
546-
let mut rpc = LightClient::new(RpcConfig {
546+
let mut rpc = LightClient::new(LightClientConfig {
547547
url: self.config.external_services.rpc_url.to_string(),
548548
commitment_config: None,
549549
fetch_active_tree: false,
@@ -1196,7 +1196,7 @@ impl<R: Rpc, I: Indexer + IndexerType<R> + 'static> EpochManager<R, I> {
11961196
))]
11971197
async fn report_work(&self, epoch_info: &ForesterEpochInfo) -> Result<()> {
11981198
info!("Reporting work");
1199-
let mut rpc = LightClient::new(RpcConfig {
1199+
let mut rpc = LightClient::new(LightClientConfig {
12001200
url: self.config.external_services.rpc_url.to_string(),
12011201
commitment_config: None,
12021202
fetch_active_tree: false,

forester/src/forester_status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use anchor_lang::{AccountDeserialize, Discriminator};
44
use forester_utils::forester_epoch::{get_epoch_phases, TreeAccounts};
55
use itertools::Itertools;
6-
use light_client::rpc::{LightClient, Rpc, RpcConfig};
6+
use light_client::rpc::{LightClient, LightClientConfig, Rpc};
77
use light_compressed_account::TreeType;
88
use light_registry::{protocol_config::state::ProtocolConfigPda, EpochPda, ForesterEpochPda};
99
use solana_program::{clock::Slot, pubkey::Pubkey};
@@ -173,7 +173,7 @@ pub async fn fetch_forester_status(args: &StatusArgs) {
173173

174174
debug!("Fetching trees...");
175175
debug!("RPC URL: {}", config.external_services.rpc_url);
176-
let mut rpc = LightClient::new(RpcConfig {
176+
let mut rpc = LightClient::new(LightClientConfig {
177177
url: config.external_services.rpc_url.to_string(),
178178
commitment_config: None,
179179
fetch_active_tree: false,

forester/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use forester_utils::{
2929
};
3030
use light_client::{
3131
indexer::Indexer,
32-
rpc::{LightClient, Rpc, RpcConfig},
32+
rpc::{LightClient, LightClientConfig, Rpc},
3333
};
3434
use light_compressed_account::TreeType;
3535
use solana_sdk::commitment_config::CommitmentConfig;
@@ -51,7 +51,7 @@ pub async fn run_queue_info(
5151
trees: Vec<TreeAccounts>,
5252
queue_type: TreeType,
5353
) {
54-
let mut rpc = LightClient::new(RpcConfig {
54+
let mut rpc = LightClient::new(LightClientConfig {
5555
url: config.external_services.rpc_url.to_string(),
5656
commitment_config: None,
5757
fetch_active_tree: false,

forester/tests/address_v2_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use light_batched_merkle_tree::{
1010
use light_client::{
1111
indexer::{photon_indexer::PhotonIndexer, AddressWithTree},
1212
local_test_validator::{LightValidatorConfig, ProverConfig},
13-
rpc::{client::RpcUrl, merkle_tree::MerkleTreeExt, LightClient, Rpc, RpcConfig},
13+
rpc::{client::RpcUrl, merkle_tree::MerkleTreeExt, LightClient, LightClientConfig, Rpc},
1414
};
1515
use light_compressed_account::{
1616
address::derive_address,
@@ -70,7 +70,7 @@ async fn test_create_v2_address() {
7070
config.derivation_pubkey = env.protocol.forester.pubkey();
7171
config.general_config = GeneralConfig::test_address_v2();
7272

73-
let mut rpc = LightClient::new(RpcConfig {
73+
let mut rpc = LightClient::new(LightClientConfig {
7474
url: RpcUrl::Localnet.to_string(),
7575
commitment_config: Some(CommitmentConfig::processed()),
7676
fetch_active_tree: false,

forester/tests/batched_address_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use light_batched_merkle_tree::{
1212
use light_client::{
1313
indexer::{photon_indexer::PhotonIndexer, AddressMerkleTreeAccounts, Indexer},
1414
local_test_validator::{LightValidatorConfig, ProverConfig},
15-
rpc::{client::RpcUrl, LightClient, Rpc, RpcConfig},
15+
rpc::{client::RpcUrl, LightClient, LightClientConfig, Rpc},
1616
};
1717
use light_program_test::{accounts::test_accounts::TestAccounts, indexer::TestIndexer};
1818
use light_test_utils::{
@@ -63,7 +63,7 @@ async fn test_address_batched() {
6363
.unwrap();
6464

6565
let commitment_config = CommitmentConfig::confirmed();
66-
let mut rpc = LightClient::new(RpcConfig {
66+
let mut rpc = LightClient::new(LightClientConfig {
6767
url: RpcUrl::Localnet.to_string(),
6868
commitment_config: Some(commitment_config),
6969
fetch_active_tree: false,

forester/tests/batched_state_async_indexer_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use light_client::{
1212
GetCompressedTokenAccountsByOwnerOrDelegateOptions, Indexer,
1313
},
1414
local_test_validator::{LightValidatorConfig, ProverConfig},
15-
rpc::{client::RpcUrl, LightClient, Rpc, RpcConfig},
15+
rpc::{client::RpcUrl, LightClient, LightClientConfig, Rpc},
1616
};
1717
use light_compressed_account::{
1818
address::derive_address_legacy,
@@ -222,7 +222,7 @@ async fn test_state_indexer_async_batched() {
222222
// ─────────────────────────────────────────────────────────────────────────────
223223

224224
async fn setup_rpc_connection(forester: &Keypair) -> LightClient {
225-
let mut rpc = LightClient::new(RpcConfig {
225+
let mut rpc = LightClient::new(LightClientConfig {
226226
url: RpcUrl::Localnet.to_string(),
227227
commitment_config: Some(CommitmentConfig::processed()),
228228
fetch_active_tree: false,

forester/tests/batched_state_indexer_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use light_batched_merkle_tree::{
1212
use light_client::{
1313
indexer::{photon_indexer::PhotonIndexer, Indexer, IndexerRpcConfig, RetryConfig},
1414
local_test_validator::{LightValidatorConfig, ProverConfig},
15-
rpc::{client::RpcUrl, LightClient, Rpc, RpcConfig},
15+
rpc::{client::RpcUrl, LightClient, LightClientConfig, Rpc},
1616
};
1717
use light_compressed_account::TreeType;
1818
use light_program_test::{accounts::test_accounts::TestAccounts, indexer::TestIndexer};
@@ -62,7 +62,7 @@ async fn test_state_indexer_batched() {
6262
.unwrap();
6363

6464
let commitment_config = CommitmentConfig::confirmed();
65-
let mut rpc = LightClient::new(RpcConfig {
65+
let mut rpc = LightClient::new(LightClientConfig {
6666
url: RpcUrl::Localnet.to_string(),
6767
fetch_active_tree: false,
6868
commitment_config: Some(commitment_config),

forester/tests/batched_state_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use light_batched_merkle_tree::{
1111
};
1212
use light_client::{
1313
local_test_validator::{LightValidatorConfig, ProverConfig},
14-
rpc::{client::RpcUrl, LightClient, Rpc, RpcConfig},
14+
rpc::{client::RpcUrl, LightClient, LightClientConfig, Rpc},
1515
};
1616
use light_compressed_account::TreeType;
1717
use light_program_test::{accounts::test_accounts::TestAccounts, indexer::TestIndexer};
@@ -67,7 +67,7 @@ async fn test_state_batched() {
6767
.unwrap();
6868

6969
let commitment_config = CommitmentConfig::confirmed();
70-
let mut rpc = LightClient::new(RpcConfig {
70+
let mut rpc = LightClient::new(LightClientConfig {
7171
url: RpcUrl::Localnet.to_string(),
7272
commitment_config: Some(commitment_config),
7373
fetch_active_tree: false,

forester/tests/e2e_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use forester_utils::{
1212
use light_client::{
1313
indexer::{AddressMerkleTreeAccounts, StateMerkleTreeAccounts},
1414
local_test_validator::{LightValidatorConfig, ProverConfig},
15-
rpc::{client::RpcUrl, LightClient, Rpc, RpcConfig, RpcError},
15+
rpc::{client::RpcUrl, LightClient, LightClientConfig, Rpc, RpcError},
1616
};
1717
use light_program_test::{accounts::test_accounts::TestAccounts, indexer::TestIndexer};
1818
use light_registry::{utils::get_forester_epoch_pda_from_authority, ForesterEpochPda};
@@ -60,7 +60,7 @@ async fn test_epoch_monitor_with_2_foresters() {
6060
.await
6161
.unwrap();
6262

63-
let mut rpc = LightClient::new(RpcConfig {
63+
let mut rpc = LightClient::new(LightClientConfig {
6464
url: RpcUrl::Localnet.to_string(),
6565
commitment_config: Some(CommitmentConfig::confirmed()),
6666
fetch_active_tree: false,
@@ -408,7 +408,7 @@ async fn test_epoch_double_registration() {
408408
.await
409409
.unwrap();
410410

411-
let mut rpc = LightClient::new(RpcConfig {
411+
let mut rpc = LightClient::new(LightClientConfig {
412412
url: RpcUrl::Localnet.to_string(),
413413
commitment_config: Some(CommitmentConfig::confirmed()),
414414
fetch_active_tree: false,

0 commit comments

Comments
 (0)