Skip to content

Commit 6753825

Browse files
committed
cost tracker: general tidyness
1 parent 2dca3a2 commit 6753825

File tree

15 files changed

+243
-328
lines changed

15 files changed

+243
-328
lines changed

src/discof/replay/fd_replay_tile.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,7 @@ replay_block_start( fd_replay_tile_t * ctx,
709709
&is_epoch_boundary );
710710
if( FD_UNLIKELY( is_epoch_boundary ) ) publish_stake_weights( ctx, stem, bank, 1 );
711711

712-
int res = fd_runtime_block_execute_prepare( bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad );
713-
if( FD_UNLIKELY( res!=FD_RUNTIME_EXECUTE_SUCCESS ) ) {
714-
FD_LOG_CRIT(( "block prep execute failed" ));
715-
}
716-
712+
FD_TEST( !fd_runtime_block_execute_prepare( bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad ) );
717713
return bank;
718714
}
719715

@@ -770,9 +766,7 @@ publish_slot_completed( fd_replay_tile_t * ctx,
770766
slot_info->tips = 0UL; /* todo ... tip accounts balance delta */
771767
slot_info->shred_count = fd_bank_shred_cnt_get( bank );
772768

773-
fd_cost_tracker_t const * cost_tracker = fd_bank_cost_tracker_locking_query( bank );
774-
slot_info->max_compute_units = !!cost_tracker ? cost_tracker->block_cost_limit : ULONG_MAX;
775-
fd_bank_cost_tracker_end_locking_query( bank );
769+
slot_info->max_compute_units = fd_cost_tracker_block_cost_limit( bank );
776770

777771
slot_info->first_fec_set_received_nanos = bank->first_fec_set_received_nanos;
778772
slot_info->preparation_begin_nanos = bank->preparation_begin_nanos;
@@ -940,10 +934,7 @@ prepare_leader_bank( fd_replay_tile_t * ctx,
940934
&is_epoch_boundary );
941935
if( FD_UNLIKELY( is_epoch_boundary ) ) publish_stake_weights( ctx, stem, ctx->leader_bank, 1 );
942936

943-
int res = fd_runtime_block_execute_prepare( ctx->leader_bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad );
944-
if( FD_UNLIKELY( res!=FD_RUNTIME_EXECUTE_SUCCESS ) ) {
945-
FD_LOG_CRIT(( "block prep execute failed" ));
946-
}
937+
FD_TEST( !fd_runtime_block_execute_prepare( ctx->leader_bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad ) );
947938

948939
/* Now that a bank has been created for the leader slot, increment the
949940
reference count until we are done with the leader slot. */
@@ -1109,7 +1100,7 @@ init_after_snapshot( fd_replay_tile_t * ctx ) {
11091100
fd_sha256_hash( poh->hash, 32UL, poh->hash );
11101101
}
11111102

1112-
FD_TEST( fd_runtime_block_execute_prepare( bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad ) == 0 );
1103+
FD_TEST( !fd_runtime_block_execute_prepare( bank, ctx->funk, &xid, ctx->capture_ctx, ctx->runtime_spad ) );
11131104
fd_runtime_block_execute_finalize( bank, ctx->funk, &xid, ctx->capture_ctx, 1 );
11141105

11151106
snapshot_slot = 0UL;
@@ -1298,9 +1289,7 @@ boot_genesis( fd_replay_tile_t * ctx,
12981289
fd_genesis_solana_global_t const * genesis = fd_type_pun( (uchar*)fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk )+sizeof(fd_hash_t)+sizeof(fd_lthash_value_t) );
12991290

13001291
fd_bank_t * bank = fd_banks_bank_query( ctx->banks, FD_REPLAY_BOOT_BANK_IDX );
1301-
if( FD_UNLIKELY( !bank ) ) {
1302-
FD_LOG_CRIT(( "invariant violation: bank is NULL for bank index %lu", FD_REPLAY_BOOT_BANK_IDX ));
1303-
}
1292+
FD_TEST( bank );
13041293
fd_funk_txn_xid_t xid = { .ul = { 0UL, 0UL } };
13051294

13061295
fd_runtime_read_genesis( ctx->banks, bank, ctx->funk, &xid, NULL, fd_type_pun_const( genesis_hash ), fd_type_pun_const( lthash ), genesis, ctx->runtime_spad );
@@ -1366,7 +1355,6 @@ boot_genesis( fd_replay_tile_t * ctx,
13661355
publish_slot_completed( ctx, stem, bank, 1 );
13671356
publish_root_advanced( ctx, stem );
13681357
publish_reset( ctx, stem, bank );
1369-
13701358
}
13711359

13721360
static void

src/flamenco/progcache/test_progcache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#include "fd_progcache_admin.h"
55
#include "fd_progcache_user.h"
6-
#include "../runtime/fd_bank.h"
6+
#include "../runtime/fd_system_ids.h"
7+
#include "../runtime/fd_txn_account.h"
8+
#include "../features/fd_features.h"
79

810
/* Load in programdata for tests */
911
FD_IMPORT_BINARY( valid_program_data, "src/ballet/sbpf/fixtures/hello_solana_program.so" );

src/flamenco/runtime/fd_bank.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ fd_banks_new( void * shmem, ulong max_total_banks, ulong max_fork_width ) {
242242
the offset in the banks. */
243243

244244
fd_bank_cost_tracker_t * cost_tracker_pool = fd_bank_cost_tracker_pool_join( fd_bank_cost_tracker_pool_new( cost_tracker_pool_mem, max_fork_width ) );
245-
if( FD_UNLIKELY( !cost_tracker_pool ) ) {
246-
FD_LOG_WARNING(( "Failed to new or join cost tracker pool" ));
247-
return NULL;
248-
}
245+
FD_TEST( cost_tracker_pool );
249246
fd_banks_set_cost_tracker_pool( banks, cost_tracker_pool );
250247

248+
for( ulong i=0UL; i<max_fork_width; i++ ) {
249+
fd_bank_cost_tracker_t * cost_tracker = fd_bank_cost_tracker_pool_ele( cost_tracker_pool, i );
250+
fd_cost_tracker_join( fd_cost_tracker_new( cost_tracker->data, 88888UL /* TODO: REAL SEED */ ) );
251+
}
252+
251253
/* Now, call _new() and _join() for all of the CoW pools. */
252254
#define HAS_COW_1_LIMIT_1(name) \
253255
fd_rwlock_unwrite( &banks->name##_pool_lock ); \

src/flamenco/runtime/fd_bank.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,9 @@ FD_BANKS_ITER(X)
594594
static inline fd_cost_tracker_t *
595595
fd_bank_cost_tracker_locking_modify( fd_bank_t * bank ) {
596596
fd_bank_cost_tracker_t * cost_tracker_pool = fd_bank_get_cost_tracker_pool( bank );
597-
if( FD_UNLIKELY( bank->cost_tracker_pool_idx==fd_bank_cost_tracker_pool_idx_null( cost_tracker_pool ) ) ) {
598-
return NULL;
599-
}
597+
FD_TEST( bank->cost_tracker_pool_idx!=fd_bank_cost_tracker_pool_idx_null( cost_tracker_pool ) );
600598
uchar * cost_tracker_mem = fd_bank_cost_tracker_pool_ele( cost_tracker_pool, bank->cost_tracker_pool_idx )->data;
601-
if( FD_UNLIKELY( !cost_tracker_mem ) ) {
602-
FD_LOG_CRIT(( "invariant violation: cost tracker memory is null" ));
603-
}
599+
FD_TEST( cost_tracker_mem );
604600
fd_rwlock_write( &bank->cost_tracker_lock );
605601
return fd_type_pun( cost_tracker_mem );
606602
}
@@ -613,13 +609,9 @@ fd_bank_cost_tracker_end_locking_modify( fd_bank_t * bank ) {
613609
static inline fd_cost_tracker_t const *
614610
fd_bank_cost_tracker_locking_query( fd_bank_t * bank ) {
615611
fd_bank_cost_tracker_t * cost_tracker_pool = fd_bank_get_cost_tracker_pool( bank );
616-
if( FD_UNLIKELY( bank->cost_tracker_pool_idx==fd_bank_cost_tracker_pool_idx_null( cost_tracker_pool ) ) ) {
617-
return NULL;
618-
}
612+
FD_TEST( bank->cost_tracker_pool_idx!=fd_bank_cost_tracker_pool_idx_null( cost_tracker_pool ) );
619613
uchar * cost_tracker_mem = fd_bank_cost_tracker_pool_ele( cost_tracker_pool, bank->cost_tracker_pool_idx )->data;
620-
if( FD_UNLIKELY( !cost_tracker_mem ) ) {
621-
FD_LOG_CRIT(( "invariant violation: cost tracker memory is null" ));
622-
}
614+
FD_TEST( cost_tracker_mem );
623615
fd_rwlock_read( &bank->cost_tracker_lock );
624616
return fd_type_pun_const( cost_tracker_mem );
625617
}

src/flamenco/runtime/fd_core_bpf_migration.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "program/fd_bpf_loader_program.h"
33
#include "program/fd_builtin_programs.h"
44
#include "fd_pubkey_utils.h"
5+
#include "fd_system_ids.h"
56

67
/* Mimics bank.new_target_program_account(). Assumes out_rec is a
78
modifiable record.

0 commit comments

Comments
 (0)