Skip to content

Commit 695b649

Browse files
wip
1 parent 40a602b commit 695b649

File tree

1 file changed

+71
-41
lines changed

1 file changed

+71
-41
lines changed

src/discof/restore/fd_snapin_tile.c

Lines changed: 71 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,34 @@ metrics_write( fd_snapin_tile_t * ctx ) {
105105
FD_MGAUGE_SET( SNAPIN, STATE, (ulong)ctx->state );
106106
}
107107

108+
static void
109+
calculate_lthash( fd_snapin_tile_t * ctx ) {
110+
fd_funk_all_iter_t iter[1];
111+
for( fd_funk_all_iter_new( ctx->funk, iter );
112+
!fd_funk_all_iter_done( iter );
113+
fd_funk_all_iter_next( iter ) ) {
114+
fd_funk_rec_t const * rec = fd_funk_all_iter_ele_const( iter );
115+
if ( !fd_funk_key_is_acc( rec->pair.key ) || /* not a solana record */
116+
(rec->flags & FD_FUNK_REC_FLAG_ERASE) || /* this is a tombstone */
117+
(rec->pair.xid->ul[0] | rec->pair.xid->ul[1]) != 0 /* not root xid */ ) {
118+
continue;
119+
}
120+
121+
fd_account_meta_t const * meta = fd_funk_val( rec, fd_funk_wksp(ctx->funk) );
122+
fd_lthash_value_t new_account_lthash[1];
123+
fd_hashes_account_lthash( fd_type_pun_const(rec->pair.key->uc),
124+
meta,
125+
fd_account_meta_get_data_const( meta ),
126+
new_account_lthash );
127+
fd_lthash_add( &ctx->lthash_info.full.lthash, new_account_lthash );
128+
}
129+
if( FD_UNLIKELY( memcmp( ctx->lthash_info.full.lthash.bytes, ctx->lthash_info.full.manifest_lthash.bytes, sizeof(fd_lthash_value_t) ) ) ) {
130+
FD_LOG_ERR(( "calculated accounts lthash %s does not match accounts lthash %s in snapshot manifest",
131+
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.lthash ),
132+
FD_LTHASH_ENC_32_ALLOCA( &ctx->lthash_info.full.manifest_lthash ) ));
133+
}
134+
}
135+
108136
static void
109137
manifest_cb( void * _ctx,
110138
ulong manifest_sz ) {
@@ -138,19 +166,19 @@ is_duplicate_account( fd_snapin_tile_t * ctx,
138166
/* TODO: Reaching here means the existing value is a duplicate
139167
account. We need to hash the existing account and subtract that
140168
hash from the running lthash. */
141-
fd_lthash_value_t old_account_lthash[1];
142-
fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
143-
fd_hashes_account_lthash( (fd_pubkey_t*)account_pubkey,
144-
rec_meta,
145-
fd_account_meta_get_data_const( rec_meta ),
146-
old_account_lthash );
147-
FD_LOG_WARNING(("subtracting old account hash %s for pubkey %s from lthash %s",
148-
FD_LTHASH_ENC_32_ALLOCA( old_account_lthash ),
149-
FD_BASE58_ENC_32_ALLOCA( (fd_pubkey_t*)account_pubkey ),
150-
FD_LTHASH_ENC_32_ALLOCA( lthash )));
151-
fd_lthash_sub( lthash, old_account_lthash );
152-
FD_LOG_WARNING(("resulting lthash %s",
153-
FD_LTHASH_ENC_32_ALLOCA( lthash )));
169+
// fd_lthash_value_t old_account_lthash[1];
170+
// fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
171+
// fd_hashes_account_lthash( (fd_pubkey_t*)account_pubkey,
172+
// rec_meta,
173+
// fd_account_meta_get_data_const( rec_meta ),
174+
// old_account_lthash );
175+
// FD_LOG_WARNING(("subtracting old account hash %s for pubkey %s from lthash %s",
176+
// FD_LTHASH_ENC_32_ALLOCA( old_account_lthash ),
177+
// FD_BASE58_ENC_32_ALLOCA( (fd_pubkey_t*)account_pubkey ),
178+
// FD_LTHASH_ENC_32_ALLOCA( lthash )));
179+
// fd_lthash_sub( lthash, old_account_lthash );
180+
// FD_LOG_WARNING(("resulting lthash %s",
181+
// FD_LTHASH_ENC_32_ALLOCA( lthash )));
154182
}
155183

156184
return 0;
@@ -186,19 +214,19 @@ account_cb( void * _ctx,
186214
ctx->metrics.accounts_inserted++;
187215
fd_txn_account_mutable_fini( rec, ctx->funk, ctx->funk_txn, &prepare );
188216

189-
fd_lthash_value_t new_account_lthash[1];
190-
fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
191-
fd_hashes_account_lthash( (fd_pubkey_t*)hdr->meta.pubkey,
192-
fd_txn_account_get_meta( rec ),
193-
fd_txn_account_get_data( rec ),
194-
new_account_lthash );
195-
FD_LOG_WARNING(("adding new account hash %s for pubkey %s from lthash %s",
196-
FD_LTHASH_ENC_32_ALLOCA( new_account_lthash ),
197-
FD_BASE58_ENC_32_ALLOCA( (fd_pubkey_t*)hdr->meta.pubkey ),
198-
FD_LTHASH_ENC_32_ALLOCA( lthash )));
199-
fd_lthash_add( lthash, new_account_lthash );
200-
FD_LOG_WARNING(("resulting lthash %s",
201-
FD_LTHASH_ENC_32_ALLOCA( lthash )));
217+
// fd_lthash_value_t new_account_lthash[1];
218+
// fd_lthash_value_t * lthash = ctx->full ? &ctx->lthash_info.full.lthash : &ctx->lthash_info.incremental.lthash;
219+
// fd_hashes_account_lthash( (fd_pubkey_t*)hdr->meta.pubkey,
220+
// fd_txn_account_get_meta( rec ),
221+
// fd_txn_account_get_data( rec ),
222+
// new_account_lthash );
223+
// FD_LOG_WARNING(("adding new account hash %s for pubkey %s from lthash %s",
224+
// FD_LTHASH_ENC_32_ALLOCA( new_account_lthash ),
225+
// FD_BASE58_ENC_32_ALLOCA( (fd_pubkey_t*)hdr->meta.pubkey ),
226+
// FD_LTHASH_ENC_32_ALLOCA( lthash )));
227+
// fd_lthash_add( lthash, new_account_lthash );
228+
// FD_LOG_WARNING(("resulting lthash %s",
229+
// FD_LTHASH_ENC_32_ALLOCA( lthash )));
202230

203231
}
204232

@@ -292,13 +320,14 @@ handle_control_frag( fd_snapin_tile_t * ctx,
292320
break;
293321
}
294322

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

303332
fd_snapshot_parser_reset( ctx->ssparse, fd_chunk_to_laddr( ctx->manifest_out.wksp, ctx->manifest_out.chunk ), ctx->manifest_out.mtu );
304333

@@ -314,14 +343,15 @@ handle_control_frag( fd_snapin_tile_t * ctx,
314343
break;
315344
}
316345

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

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

0 commit comments

Comments
 (0)