@@ -26,6 +26,7 @@ pub use config::{ForesterConfig, ForesterEpochInfo};
26
26
use forester_utils:: {
27
27
forester_epoch:: TreeAccounts , rate_limiter:: RateLimiter , rpc_pool:: SolanaRpcPoolBuilder ,
28
28
} ;
29
+ use itertools:: Itertools ;
29
30
use light_client:: rpc:: { LightClient , LightClientConfig , Rpc } ;
30
31
use light_compressed_account:: TreeType ;
31
32
use solana_sdk:: commitment_config:: CommitmentConfig ;
@@ -37,15 +38,16 @@ use crate::{
37
38
metrics:: QUEUE_LENGTH ,
38
39
processor:: tx_cache:: ProcessedHashCache ,
39
40
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,
41
43
} ,
42
44
slot_tracker:: SlotTracker ,
43
45
utils:: get_protocol_config,
44
46
} ;
45
47
46
48
pub async fn run_queue_info (
47
49
config : Arc < ForesterConfig > ,
48
- trees : Vec < TreeAccounts > ,
50
+ trees : & [ TreeAccounts ] ,
49
51
queue_type : TreeType ,
50
52
) -> Result < ( ) > {
51
53
let mut rpc = LightClient :: new ( LightClientConfig {
@@ -60,49 +62,87 @@ pub async fn run_queue_info(
60
62
let trees: Vec < _ > = trees
61
63
. iter ( )
62
64
. filter ( |t| t. tree_type == queue_type)
65
+ . sorted_by_key ( |t| t. merkle_tree . to_string ( ) )
63
66
. cloned ( )
64
67
. collect ( ) ;
65
68
66
69
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
+ ) ;
89
92
}
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) ;
91
117
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 ? ;
95
121
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 " ) ;
101
127
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
+ } ;
106
146
}
107
147
Ok ( ( ) )
108
148
}
0 commit comments