Skip to content

Commit fd5559d

Browse files
debug
1 parent 539ab6a commit fd5559d

File tree

1 file changed

+62
-29
lines changed

1 file changed

+62
-29
lines changed

src/discof/restore/fd_snapin_tile.c

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
112143
static void
113144
manifest_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

@@ -290,13 +321,14 @@ handle_control_frag( fd_snapin_tile_t * ctx,
290321
break;
291322
}
292323

293-
if( FD_UNLIKELY( memcmp( ctx->lthash_info.full.lthash.bytes, ctx->lthash_info.full.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ) ) {
294-
FD_LOG_WARNING(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
295-
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.lthash ),
296-
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.manifest_lthash ) ));
297-
transition_malformed( ctx, stem );
298-
break;
299-
}
324+
calculate_lthash( ctx );
325+
// if( FD_UNLIKELY( memcmp( ctx->lthash_info.full.lthash.bytes, ctx->lthash_info.full.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ) ) {
326+
// FD_LOG_WARNING(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
327+
// FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.lthash ),
328+
// FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.manifest_lthash ) ));
329+
// transition_malformed( ctx, stem );
330+
// break;
331+
// }
300332

301333
fd_snapshot_parser_reset( ctx->ssparse, fd_chunk_to_laddr( ctx->manifest_out.wksp, ctx->manifest_out.chunk ), ctx->manifest_out.mtu );
302334

@@ -312,14 +344,15 @@ handle_control_frag( fd_snapin_tile_t * ctx,
312344
break;
313345
}
314346

315-
if( FD_UNLIKELY( memcmp( ctx->lthash_info.full.lthash.bytes, ctx->lthash_info.full.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ||
316-
memcmp( ctx->lthash_info.incremental.lthash.bytes, ctx->lthash_info.incremental.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ) ) {
317-
FD_LOG_WARNING(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
318-
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.lthash ),
319-
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.manifest_lthash ) ));
320-
transition_malformed( ctx, stem );
321-
break;
322-
}
347+
calculate_lthash( ctx );
348+
// if( FD_UNLIKELY( memcmp( ctx->lthash_info.full.lthash.bytes, ctx->lthash_info.full.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ||
349+
// memcmp( ctx->lthash_info.incremental.lthash.bytes, ctx->lthash_info.incremental.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ) ) {
350+
// FD_LOG_WARNING(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
351+
// FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.lthash ),
352+
// FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.manifest_lthash ) ));
353+
// transition_malformed( ctx, stem );
354+
// break;
355+
// }
323356

324357
if( FD_LIKELY( ctx->funk_txn ) ) fd_funk_txn_publish_into_parent( ctx->funk, ctx->funk_txn, 0 );
325358
fd_stem_publish( stem, 0UL, fd_ssmsg_sig( FD_SSMSG_DONE, 0UL ), 0UL, 0UL, 0UL, 0UL, 0UL );

0 commit comments

Comments
 (0)