@@ -109,6 +109,37 @@ metrics_write( fd_snapin_tile_t * ctx ) {
109109 FD_MGAUGE_SET ( SNAPIN , STATE , (ulong )ctx -> state );
110110}
111111
112+ static void
113+ calculate_lthash ( fd_snapin_tile_t * ctx ) {
114+ fd_funk_all_iter_t iter [1 ];
115+ for ( fd_funk_all_iter_new ( ctx -> funk , iter );
116+ !fd_funk_all_iter_done ( iter );
117+ fd_funk_all_iter_next ( iter ) ) {
118+ fd_funk_rec_t const * rec = fd_funk_all_iter_ele_const ( iter );
119+ if ( !fd_funk_key_is_acc ( rec -> pair .key ) || /* not a solana record */
120+ (rec -> flags & FD_FUNK_REC_FLAG_ERASE ) || /* this is a tombstone */
121+ (rec -> pair .xid -> ul [0 ] | rec -> pair .xid -> ul [1 ]) != 0 /* not root xid */ ) {
122+ continue ;
123+ }
124+
125+ fd_account_meta_t const * meta = fd_funk_val ( rec , fd_funk_wksp (ctx -> funk ) );
126+ fd_lthash_value_t new_account_lthash [1 ];
127+ fd_hashes_account_lthash ( fd_type_pun_const (rec -> pair .key -> uc ),
128+ meta ,
129+ fd_account_meta_get_data_const ( meta ),
130+ new_account_lthash );
131+ FD_LOG_WARNING (("calculated account hash %s for %s" ,
132+ FD_LTHASH_ENC_32_ALLOCA ( new_account_lthash ),
133+ FD_BASE58_ENC_32_ALLOCA ( (fd_pubkey_t * )rec -> pair .key -> uc ) ));
134+ fd_lthash_add ( & ctx -> lthash_info .full .lthash , new_account_lthash );
135+ }
136+ if ( FD_UNLIKELY ( memcmp ( ctx -> lthash_info .full .lthash .bytes , ctx -> lthash_info .full .manifest_lthash .bytes , sizeof (fd_lthash_value_t ) ) ) ) {
137+ FD_LOG_ERR (( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest" ,
138+ FD_LTHASH_ENC_32_ALLOCA ( & ctx -> lthash_info .full .lthash ),
139+ FD_LTHASH_ENC_32_ALLOCA ( & ctx -> lthash_info .full .manifest_lthash ) ));
140+ }
141+ }
142+
112143static void
113144manifest_cb ( void * _ctx ,
114145 ulong manifest_sz ) {
@@ -142,13 +173,13 @@ is_duplicate_account( fd_snapin_tile_t * ctx,
142173 /* TODO: Reaching here means the existing value is a duplicate
143174 account. We need to hash the existing account and subtract that
144175 hash from the running lthash. */
145- fd_lthash_value_t old_account_lthash [1 ];
146- fd_lthash_value_t * lthash = ctx -> full ? & ctx -> lthash_info .full .lthash : & ctx -> lthash_info .incremental .lthash ;
147- fd_hashes_account_lthash ( (fd_pubkey_t * )account_pubkey ,
148- rec_meta ,
149- fd_account_meta_get_data_const ( rec_meta ),
150- old_account_lthash );
151- fd_lthash_sub ( lthash , old_account_lthash );
176+ // fd_lthash_value_t old_account_lthash[1];
177+ // fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
178+ // fd_hashes_account_lthash( (fd_pubkey_t*)account_pubkey,
179+ // rec_meta,
180+ // fd_account_meta_get_data_const( rec_meta ),
181+ // old_account_lthash );
182+ // fd_lthash_sub( lthash, old_account_lthash );
152183 }
153184
154185 return 0 ;
@@ -201,13 +232,13 @@ account_data_cb( void * _ctx,
201232 ctx -> acc_data += data_sz ;
202233
203234 if ( ctx -> acc_data == ctx -> acc_data_end ) {
204- fd_lthash_value_t new_account_lthash [1 ];
205- fd_lthash_value_t * lthash = ctx -> full ? & ctx -> lthash_info .full .lthash : & ctx -> lthash_info .incremental .lthash ;
206- fd_hashes_account_lthash ( & ctx -> acc_pubkey ,
207- ctx -> acc_meta ,
208- ctx -> acc_data_start ,
209- new_account_lthash );
210- fd_lthash_add ( lthash , new_account_lthash );
235+ // fd_lthash_value_t new_account_lthash[1];
236+ // fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
237+ // fd_hashes_account_lthash( &ctx->acc_pubkey,
238+ // ctx->acc_meta,
239+ // ctx->acc_data_start,
240+ // new_account_lthash );
241+ // fd_lthash_add( lthash, new_account_lthash );
211242 }
212243}
213244
0 commit comments