Skip to content

Commit

Permalink
make it work full tesetnet
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhatt-jumptrading committed Nov 18, 2024
1 parent d49a6dc commit 832f8fb
Show file tree
Hide file tree
Showing 15 changed files with 310 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/app/fdctl/run/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ fdctl_obj_new( fd_topo_t const * topo,
fd_funk_new( laddr, VAL("wksp_tag"), VAL("seed"), VAL("txn_max"), VAL("rec_max") );
} else if( FD_UNLIKELY( !strcmp( obj->name, "txncache" ) ) ) {
fd_txncache_new( laddr, VAL("max_rooted_slots"), VAL("max_live_slots"), VAL("max_txn_per_slot"), 0UL );
FD_TEST( fd_funk_new( laddr, VAL("wksp_tag"), VAL("seed"), VAL("txn_max"), VAL("rec_max") ) );
} else {
FD_LOG_ERR(( "unknown object `%s`", obj->name ));
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/fdctl/run/tiles/fd_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,15 @@ funk_publish( fd_replay_tile_ctx_t * ctx, ulong smr ) {

if( FD_LIKELY( !is_constipated ) ) {

FD_LOG_WARNING(("PUBLISHING SLOT %lu", smr));

ulong rc = fd_funk_txn_publish( ctx->funk, root_txn, 1 );
if( FD_UNLIKELY( !rc ) ) {
FD_LOG_ERR(( "failed to funk publish slot %lu", smr ));
}

} else {
FD_LOG_WARNING(("CONSTIPATED PUBLISHING SLOT %lu", smr));
/* If the parent of the current transaction is not NULL, then we will
publish into the parent. Otherwise we know that this transaction is
the new constipated root. */
Expand Down
1 change: 0 additions & 1 deletion src/app/fdctl/run/topos/fd_firedancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ fd_topo_initialize( config_t * config ) {
/**/ fd_topob_link( topo, "poh_shred", "poh_shred", 0, 16384UL, USHORT_MAX, 1UL );
/**/ fd_topob_link( topo, "pack_replay", "pack_replay", 0, 65536UL, USHORT_MAX, 1UL );
/**/ fd_topob_link( topo, "poh_pack", "replay_poh", 0, 128UL, sizeof(fd_became_leader_t) , 1UL );
/**/ fd_topob_link( topo, "poh_replay", "poh_replay", 0, 128UL, USHORT_MAX, 1UL ); /* TODO: not properly sized yet */

/**/ fd_topob_link( topo, "replay_voter", "replay_voter", 0, 128UL, FD_TPU_DCACHE_MTU, 1UL );
/**/ fd_topob_link( topo, "voter_gossip", "voter_gossip", 0, 128UL, FD_TXN_MTU, 1UL );
Expand Down
2 changes: 0 additions & 2 deletions src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ fd_create_snapshot_task( void FD_PARAM_UNUSED *tpool,
FD_LOG_ERR(( "failed to create snapshot" ));
}
FD_LOG_NOTICE(("Successfully produced a snapshot at directory=%s", ledger_args->snapshot_dir ));
//return 0;

ledger_args->slot_ctx->epoch_ctx->constipate_root = 0;
fd_txncache_flush_constipated_slots( ledger_args->slot_ctx->status_cache );

}

Expand Down
15 changes: 15 additions & 0 deletions src/flamenco/runtime/context/fd_exec_slot_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ fd_exec_slot_ctx_recover_( fd_exec_slot_ctx_t * slot_ctx,

recover_clock( slot_ctx );

/* Pass in the hard forks */

FD_LOG_WARNING(("HARD FORKS LENGTH %lu", oldbank->hard_forks.hard_forks_len));

/* The hard forks should be deep copied over.
TODO:This should be in the epoch bank and not the slot bank. */
slot_bank->hard_forks = oldbank->hard_forks;
slot_bank->hard_forks.hard_forks_len = oldbank->hard_forks.hard_forks_len;
slot_bank->hard_forks.hard_forks = fd_valloc_malloc( slot_valloc,
FD_SLOT_PAIR_ALIGN,
oldbank->hard_forks.hard_forks_len * FD_SLOT_PAIR_FOOTPRINT );
for( ulong i=0UL; i < oldbank->hard_forks.hard_forks_len; i++ ) {
slot_bank->hard_forks.hard_forks[i] = oldbank->hard_forks.hard_forks[i];
}

/* Update last restart slot
https://github.com/solana-labs/solana/blob/30531d7a5b74f914dde53bfbb0bc2144f2ac92bb/runtime/src/bank.rs#L2152
Expand Down
4 changes: 4 additions & 0 deletions src/flamenco/runtime/fd_acc_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ fd_acc_mgr_save_many_tpool( fd_acc_mgr_t * acc_mgr,
for( ulong i = 0; i < accounts_cnt; i++ ) {
fd_borrowed_account_t * account = accounts[i];

if( !memcmp(account->pubkey, &fd_sysvar_last_restart_slot_id, sizeof(fd_pubkey_t)) ) {
FD_LOG_WARNING(("PURR"));
}

ulong batch_idx = i & batch_mask;
fd_acc_mgr_save_task_info_t * task_info = &task_infos[batch_idx];
task_info->accounts[task_info->accounts_cnt++] = account;
Expand Down
7 changes: 7 additions & 0 deletions src/flamenco/runtime/fd_hashes.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ fd_hash_bank( fd_exec_slot_ctx_t * slot_ctx,

sort_pubkey_hash_pair_inplace( dirty_keys, dirty_key_cnt );
fd_pubkey_hash_pair_list_t list1 = { .pairs = dirty_keys, .pairs_len = dirty_key_cnt };

for( ulong i = 0; i < dirty_key_cnt; ++i ) {
if( !memcmp(list1.pairs[i].rec->pair.key, &fd_sysvar_last_restart_slot_id, sizeof(fd_pubkey_t)) ) {
FD_LOG_WARNING(("PURR"));
}
}

fd_hash_account_deltas(&list1, 1, &slot_ctx->account_delta_hash );

fd_sha256_t sha;
Expand Down
14 changes: 13 additions & 1 deletion src/flamenco/runtime/fd_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,8 @@ int fd_runtime_block_execute_finalize(fd_exec_slot_ctx_t *slot_ctx,
// return result;
// }

FD_LOG_WARNING(("HARD FORKS LENGTH %lu", slot_ctx->slot_bank.hard_forks.hard_forks_len));

result = fd_runtime_save_slot_bank(slot_ctx);
if( result != FD_RUNTIME_EXECUTE_SUCCESS ) {
FD_LOG_WARNING(("failed to save slot bank"));
Expand Down Expand Up @@ -2367,6 +2369,8 @@ fd_runtime_block_execute_finalize_tpool( fd_exec_slot_ctx_t * slot_ctx,
// return result;
// }

FD_LOG_WARNING(("HARD FORKS LENGTH %lu", slot_ctx->slot_bank.hard_forks.hard_forks_len));

result = fd_runtime_save_slot_bank(slot_ctx);
if( result != FD_RUNTIME_EXECUTE_SUCCESS ) {
FD_LOG_WARNING(("failed to save slot bank"));
Expand Down Expand Up @@ -2853,7 +2857,7 @@ fd_runtime_publish_old_txns( fd_exec_slot_ctx_t * slot_ctx,
if( ++depth == (FD_RUNTIME_NUM_ROOT_BLOCKS - 1 ) ) {
FD_LOG_DEBUG(("publishing %s (slot %lu)", FD_BASE58_ENC_32_ALLOCA( &txn->xid ), txn->xid.ul[0]));

if( slot_ctx->status_cache && slot_ctx->epoch_ctx->constipate_root==0 ) {
if( slot_ctx->status_cache && !fd_txncache_get_is_constipated( slot_ctx->status_cache ) ) {
FD_LOG_WARNING(("REGISTERING ROOT %lu", txn->xid.ul[0] ));
fd_txncache_register_root_slot( slot_ctx->status_cache, txn->xid.ul[0] );
} else if( slot_ctx->status_cache ) {
Expand All @@ -2868,6 +2872,7 @@ fd_runtime_publish_old_txns( fd_exec_slot_ctx_t * slot_ctx,
fd_funk_txn_t *p = fd_funk_txn_parent( txn, txnmap );
if( p != NULL ) {
slot_ctx->root_slot = txn->xid.ul[0];
FD_LOG_WARNING(("CONSTIPATED PUBLISH"));
if( fd_funk_txn_publish_into_parent(funk, txn, 1) == FD_FUNK_SUCCESS ) {
publish_err = 1;
}
Expand All @@ -2880,6 +2885,7 @@ fd_runtime_publish_old_txns( fd_exec_slot_ctx_t * slot_ctx,
if( slot_ctx->root_slot == slot_ctx->snapshot_slot ) {
FD_LOG_WARNING(("CONSTIPATING"));
slot_ctx->epoch_ctx->constipate_root = 1;
fd_txncache_set_is_constipated( slot_ctx->status_cache, 1 );
}
FD_LOG_WARNING(("PUBLISH for slot %lu", txn->xid.ul[0]));;
}
Expand Down Expand Up @@ -2984,6 +2990,8 @@ fd_runtime_block_eval_tpool( fd_exec_slot_ctx_t * slot_ctx,
/* progress to next slot next time */
slot_ctx->blockstore->smr++;

FD_LOG_WARNING(("HARD FORKS LENGTH %lu", slot_ctx->slot_bank.hard_forks.hard_forks_len));

fd_funk_start_write( slot_ctx->acc_mgr->funk );
fd_runtime_save_slot_bank( slot_ctx );
fd_funk_end_write( slot_ctx->acc_mgr->funk );
Expand Down Expand Up @@ -3359,6 +3367,10 @@ fd_runtime_collect_rent_from_account( fd_exec_slot_ctx_t const * slot_ctx,
fd_pubkey_t const * key,
ulong epoch ) {

if( !memcmp(key, &fd_sysvar_last_restart_slot_id, sizeof(fd_pubkey_t)) ) {
FD_LOG_WARNING(("PURR"));
}

if( !FD_FEATURE_ACTIVE( slot_ctx, disable_rent_fees_collection ) ) {
return fd_runtime_collect_from_existing_account( slot_ctx, acc, key, epoch );
} else {
Expand Down
27 changes: 27 additions & 0 deletions src/flamenco/runtime/fd_txncache.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ struct __attribute__((aligned(FD_TXNCACHE_ALIGN))) fd_txncache_private {
array, assuming that the latest slots were constipated
and not flushed. */

int is_constipated; /* Is the status cache in a constipated*/
ulong is_constipated_off;

ulong magic; /* ==FD_TXNCACHE_MAGIC */
};

Expand Down Expand Up @@ -597,7 +600,9 @@ fd_txncache_flush_constipated_slots( fd_txncache_t * tc ) {
for( ulong i=0UL; i<tc->constipated_slots_cnt; i++ ) {
fd_txncache_register_root_slot_private( tc, constipated_slots[ i ] );
}
tc->constipated_slots_cnt = 0UL;

tc->is_constipated = 0;

fd_rwlock_unwrite( tc->lock );

Expand Down Expand Up @@ -1130,3 +1135,25 @@ fd_txncache_get_entries( fd_txncache_t * tc,
return 0;

}

int
fd_txncache_get_is_constipated( fd_txncache_t * tc ) {
fd_rwlock_read( tc->lock );

int is_constipated = tc->is_constipated;

fd_rwlock_unread( tc->lock );

return is_constipated;
}

int
fd_txncache_set_is_constipated( fd_txncache_t * tc, int is_constipated ) {
fd_rwlock_read( tc->lock );

tc->is_constipated = is_constipated;

fd_rwlock_unread( tc->lock );

return 0;
}
12 changes: 11 additions & 1 deletion src/flamenco/runtime/fd_txncache.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@
when we root a slot to when the status cache is done getting serialized into
the snapshot format. This SHOULD be enough time because serializing the
status cache into a Solana snapshot is done on the order of seconds and is
one of the first things that is done during snapshot creation. */
one of the first things that is done during snapshot creation.
TODO:FIXME: flush right after we are done with the stuff here. */

#define FD_TXNCACHE_DEFAULT_MAX_CONSTIPATED_SLOTS (1024UL)

Expand Down Expand Up @@ -436,6 +437,15 @@ int
fd_txncache_get_entries( fd_txncache_t * tc,
fd_bank_slot_deltas_t * bank_slot_deltas );

/* fd_txncache_{is,set}_constipated is used to set and determine if the
status cache is currently in a constipated state. */

int
fd_txncache_get_is_constipated( fd_txncache_t * tc );

int
fd_txncache_set_is_constipated( fd_txncache_t * tc, int is_constipated );

FD_PROTOTYPES_END

#endif /* HEADER_fd_src_flamenco_runtime_txncache_h */
3 changes: 3 additions & 0 deletions src/flamenco/runtime/sysvar/fd_sysvar_last_restart_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ fd_sysvar_last_restart_slot_read( fd_sol_sysvar_last_restart_slot_t * result,
void
fd_sysvar_last_restart_slot_update( fd_exec_slot_ctx_t * slot_ctx ) {

FD_LOG_WARNING(("LAST RESTART SLOT UPDATE"));

/* https://github.com/solana-labs/solana/blob/v1.18.18/runtime/src/bank.rs#L2093-L2095 */
if( !FD_FEATURE_ACTIVE( slot_ctx, last_restart_slot_sysvar ) ) return;

Expand All @@ -82,6 +84,7 @@ fd_sysvar_last_restart_slot_update( fd_exec_slot_ctx_t * slot_ctx ) {

/* https://github.com/solana-labs/solana/blob/v1.18.18/runtime/src/bank.rs#L2122-L2130 */
if( !has_current_last_restart_slot || current_last_restart_slot != last_restart_slot ) {
FD_LOG_WARNING(("SETTING SYSVAR %lu %lu %d", current_last_restart_slot, last_restart_slot, has_current_last_restart_slot));
fd_sysvar_set(
slot_ctx, fd_sysvar_owner_id.key,
&fd_sysvar_last_restart_slot_id,
Expand Down
12 changes: 7 additions & 5 deletions src/flamenco/snapshot/fd_snapshot_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,7 @@ fd_snapshot_create_populate_bank( fd_snapshot_ctx_t * snapshot_ct

bank->parent_slot = snapshot_ctx->slot - 1UL;

/* Hard forks can be omitted as it is not needed to boot off of both clients */

bank->hard_forks.hard_forks = NULL;
bank->hard_forks.hard_forks_len = 0UL;

bank->hard_forks = slot_bank->hard_forks;
bank->transaction_count = slot_bank->transaction_count;
bank->signature_count = slot_bank->parent_signature_cnt;
bank->capitalization = slot_bank->capitalization;
Expand Down Expand Up @@ -727,6 +723,8 @@ fd_snapshot_create_write_status_cache( fd_snapshot_ctx_t * snapshot_ctx ) {
return -1;
}

fd_txncache_flush_constipated_slots( snapshot_ctx->status_cache );

return 0;

} FD_SCRATCH_SCOPE_END;
Expand Down Expand Up @@ -938,6 +936,8 @@ fd_snapshot_create_new_snapshot( fd_snapshot_ctx_t * snapshot_ctx ) {

int err = 0;

FD_LOG_WARNING(("ENTERING SNAPSHOT CREATION"));

/* Validate that the snapshot_ctx is setup correctly */

err = fd_snapshot_create_setup_and_validate_ctx( snapshot_ctx );
Expand Down Expand Up @@ -966,6 +966,8 @@ fd_snapshot_create_new_snapshot( fd_snapshot_ctx_t * snapshot_ctx ) {
return err;
}

FD_LOG_WARNING(("DONE WRITING THE STATUS CACHE"));

/* Populate and write out the manifest and append vecs. */

err = fd_snapshot_create_write_manifest_and_acc_vecs( snapshot_ctx );
Expand Down
Loading

0 comments on commit 832f8fb

Please sign in to comment.