@@ -3,7 +3,6 @@ use std::sync::{
33 Arc ,
44} ;
55
6- use borsh:: BorshDeserialize ;
76use forester_utils:: rpc_pool:: SolanaRpcPool ;
87use futures:: StreamExt ;
98use light_client:: {
@@ -81,7 +80,7 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
8180 // Get the compressible config PDA for this program (config_bump = 0)
8281 let ( config_pda, _) = LightConfig :: derive_pda ( program_id, 0 ) ;
8382
84- // Fetch the config to get rent_sponsor and address_space
83+ // Fetch the config account
8584 let rpc = self . rpc_pool . get_connection ( ) . await ?;
8685 let config_account = rpc
8786 . get_account ( config_pda)
@@ -91,38 +90,22 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
9190 anyhow:: anyhow!( "Config account not found for program {}" , program_id)
9291 } ) ?;
9392
94- // Verify account owner matches program_id (mirrors LightConfig::load_checked)
95- if config_account. owner != * program_id {
96- return Err ( anyhow:: anyhow!(
97- "Config account owner mismatch. Expected: {}. Found: {}" ,
98- program_id,
99- config_account. owner
100- ) ) ;
101- }
102-
103- // Deserialize config
104- let config = LightConfig :: try_from_slice ( & config_account. data )
105- . map_err ( |e| anyhow:: anyhow!( "Failed to deserialize config: {:?}" , e) ) ?;
106-
107- // Validate config (checks config_bump == 0 and other constraints)
108- config. validate ( ) . map_err ( |e| {
93+ // Load and validate config using SDK validator
94+ // This checks: owner == program_id, config_bump == 0, PDA derivation, and other constraints
95+ let config = LightConfig :: load_checked_client (
96+ & config_account. data ,
97+ & config_account. owner ,
98+ & config_pda,
99+ program_id,
100+ )
101+ . map_err ( |e| {
109102 anyhow:: anyhow!(
110- "LightConfig validation failed for program {}: {:? }" ,
103+ "LightConfig validation failed for program {}: {}" ,
111104 program_id,
112105 e
113106 )
114107 } ) ?;
115108
116- // Verify PDA derivation matches (mirrors LightConfig::load_checked)
117- let ( expected_pda, _) = LightConfig :: derive_pda ( program_id, config. config_bump ) ;
118- if expected_pda != config_pda {
119- return Err ( anyhow:: anyhow!(
120- "Config PDA derivation mismatch. Expected: {}. Found: {}" ,
121- expected_pda,
122- config_pda
123- ) ) ;
124- }
125-
126109 let rent_sponsor = config. rent_sponsor ;
127110 let compression_authority = config. compression_authority ;
128111 let address_tree = * config
0 commit comments