@@ -26,6 +26,7 @@ pub use config::{ForesterConfig, ForesterEpochInfo};
2626use forester_utils:: {
2727 forester_epoch:: TreeAccounts , rate_limiter:: RateLimiter , rpc_pool:: SolanaRpcPoolBuilder ,
2828} ;
29+ use itertools:: Itertools ;
2930use light_client:: rpc:: { LightClient , LightClientConfig , Rpc } ;
3031use light_compressed_account:: TreeType ;
3132use solana_sdk:: commitment_config:: CommitmentConfig ;
@@ -37,15 +38,16 @@ use crate::{
3738 metrics:: QUEUE_LENGTH ,
3839 processor:: tx_cache:: ProcessedHashCache ,
3940 queue_helpers:: {
40- fetch_address_v2_queue_length, fetch_queue_item_data, fetch_state_v2_queue_length,
41+ fetch_queue_item_data, print_address_v2_queue_info, print_state_v2_input_queue_info,
42+ print_state_v2_output_queue_info,
4143 } ,
4244 slot_tracker:: SlotTracker ,
4345 utils:: get_protocol_config,
4446} ;
4547
4648pub async fn run_queue_info (
4749 config : Arc < ForesterConfig > ,
48- trees : Vec < TreeAccounts > ,
50+ trees : & [ TreeAccounts ] ,
4951 queue_type : TreeType ,
5052) -> Result < ( ) > {
5153 let mut rpc = LightClient :: new ( LightClientConfig {
@@ -60,49 +62,87 @@ pub async fn run_queue_info(
6062 let trees: Vec < _ > = trees
6163 . iter ( )
6264 . filter ( |t| t. tree_type == queue_type)
65+ . sorted_by_key ( |t| t. merkle_tree . to_string ( ) )
6366 . cloned ( )
6467 . collect ( ) ;
6568
6669 for tree_data in trees {
67- let queue_length = match tree_data. tree_type {
68- TreeType :: StateV1 => fetch_queue_item_data (
69- & mut rpc ,
70- & tree_data . queue ,
71- 0 ,
72- STATE_NULLIFIER_QUEUE_VALUES ,
73- STATE_NULLIFIER_QUEUE_VALUES ,
74- )
75- . await ?
76- . len ( ) ,
77- TreeType :: AddressV1 => fetch_queue_item_data (
78- & mut rpc ,
79- & tree_data . queue ,
80- 0 ,
81- ADDRESS_QUEUE_VALUES ,
82- ADDRESS_QUEUE_VALUES ,
83- )
84- . await ?
85- . len ( ) ,
86- TreeType :: StateV2 => fetch_state_v2_queue_length ( & mut rpc , & tree_data . queue ) . await ? ,
87- TreeType :: AddressV2 => {
88- fetch_address_v2_queue_length ( & mut rpc , & tree_data . merkle_tree ) . await ?
70+ match tree_data. tree_type {
71+ TreeType :: StateV1 => {
72+ let queue_length = fetch_queue_item_data (
73+ & mut rpc ,
74+ & tree_data . queue ,
75+ 0 ,
76+ STATE_NULLIFIER_QUEUE_VALUES ,
77+ STATE_NULLIFIER_QUEUE_VALUES ,
78+ )
79+ . await ?
80+ . len ( ) ;
81+ QUEUE_LENGTH
82+ . with_label_values ( & [
83+ & * queue_type . to_string ( ) ,
84+ & tree_data . merkle_tree . to_string ( ) ,
85+ ] )
86+ . set ( queue_length as i64 ) ;
87+
88+ println ! (
89+ "{:?} queue {} length: {}" ,
90+ queue_type , tree_data . queue , queue_length
91+ ) ;
8992 }
90- } ;
93+ TreeType :: AddressV1 => {
94+ let queue_length = fetch_queue_item_data (
95+ & mut rpc,
96+ & tree_data. queue ,
97+ 0 ,
98+ ADDRESS_QUEUE_VALUES ,
99+ ADDRESS_QUEUE_VALUES ,
100+ )
101+ . await ?
102+ . len ( ) ;
103+ QUEUE_LENGTH
104+ . with_label_values ( & [
105+ & * queue_type. to_string ( ) ,
106+ & tree_data. merkle_tree . to_string ( ) ,
107+ ] )
108+ . set ( queue_length as i64 ) ;
109+
110+ println ! (
111+ "{:?} queue {} length: {}" ,
112+ queue_type, tree_data. queue, queue_length
113+ ) ;
114+ }
115+ TreeType :: StateV2 => {
116+ println ! ( "\n === StateV2 {} ===" , tree_data. merkle_tree) ;
91117
92- QUEUE_LENGTH
93- . with_label_values ( & [ & * queue_type . to_string ( ) , & tree_data . merkle_tree . to_string ( ) ] )
94- . set ( queue_length as i64 ) ;
118+ println ! ( " \n 1. APPEND OPERATIONS:" ) ;
119+ let append_unprocessed =
120+ print_state_v2_output_queue_info ( & mut rpc , & tree_data . queue ) . await ? ;
95121
96- let queue_identifier = if tree_data . tree_type == TreeType :: AddressV2 {
97- tree_data . merkle_tree . to_string ( )
98- } else {
99- tree_data . queue . to_string ( )
100- } ;
122+ println ! ( " \n 2. NULLIFY OPERATIONS:" ) ;
123+ let nullify_unprocessed =
124+ print_state_v2_input_queue_info ( & mut rpc , & tree_data . merkle_tree ) . await ? ;
125+
126+ println ! ( "=========================================== \n " ) ;
101127
102- println ! (
103- "{:?} queue {} length: {}" ,
104- queue_type, queue_identifier, queue_length
105- ) ;
128+ QUEUE_LENGTH
129+ . with_label_values ( & [ "StateV2.Append" , & tree_data. queue . to_string ( ) ] )
130+ . set ( append_unprocessed as i64 ) ;
131+
132+ QUEUE_LENGTH
133+ . with_label_values ( & [ "StateV2.Nullify" , & tree_data. merkle_tree . to_string ( ) ] )
134+ . set ( nullify_unprocessed as i64 ) ;
135+ }
136+ TreeType :: AddressV2 => {
137+ println ! ( "\n === AddressV2 {} ===" , tree_data. merkle_tree) ;
138+ let queue_length =
139+ print_address_v2_queue_info ( & mut rpc, & tree_data. merkle_tree ) . await ?;
140+ println ! ( "===========================================\n " ) ;
141+ QUEUE_LENGTH
142+ . with_label_values ( & [ "AddressV2" , & tree_data. merkle_tree . to_string ( ) ] )
143+ . set ( queue_length as i64 ) ;
144+ }
145+ } ;
106146 }
107147 Ok ( ( ) )
108148}
0 commit comments