Skip to content

Commit 65bfa75

Browse files
committed
runtime: work around fixtures with dup blockhash
1 parent 90617bb commit 65bfa75

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

src/flamenco/runtime/sysvar/fd_sysvar_epoch_schedule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ void
3434
fd_sysvar_epoch_schedule_write( fd_exec_slot_ctx_t * slot_ctx,
3535
fd_epoch_schedule_t const * epoch_schedule ) {
3636
ulong sz = fd_epoch_schedule_size( epoch_schedule );
37-
FD_LOG_INFO(("Writing epoch schedule size %lu", sz));
3837
/* TODO remove alloca */
3938
uchar enc[ sz ];
4039
memset( enc, 0, sz );

src/flamenco/runtime/sysvar/fd_sysvar_last_restart_slot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ void
88
fd_sysvar_last_restart_slot_init( fd_exec_slot_ctx_t * slot_ctx ) {
99

1010
if( !FD_FEATURE_ACTIVE_BANK( slot_ctx->bank, last_restart_slot_sysvar ) ) {
11-
FD_LOG_INFO(( "sysvar LastRestartSlot not supported by this ledger version!" ));
1211
return;
1312
}
1413

src/flamenco/runtime/tests/harness/fd_exec_sol_compat.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,14 @@ sol_compat_txn_fixture( fd_runtime_fuzz_runner_t * runner,
492492

493493
int ok = 0;
494494
FD_SPAD_FRAME_BEGIN( runner->spad ) {
495-
// Execute
496-
void * output = NULL;
497-
sol_compat_execute_wrapper( runner, &fixture->input, &output, fd_runtime_fuzz_txn_run );
498-
499-
// Compare effects
500-
fd_exec_test_txn_result_t * effects = (fd_exec_test_txn_result_t *) output;
501-
ok = sol_compat_cmp_txn( &fixture->output, effects );
495+
// Execute
496+
void * output = NULL;
497+
sol_compat_execute_wrapper( runner, &fixture->input, &output, fd_runtime_fuzz_txn_run );
498+
if( FD_LIKELY( output ) ) {
499+
// Compare effects
500+
fd_exec_test_txn_result_t * effects = output;
501+
ok = sol_compat_cmp_txn( &fixture->output, effects );
502+
}
502503
} FD_SPAD_FRAME_END;
503504

504505
// Cleanup

src/flamenco/runtime/tests/harness/fd_txn_harness.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ fd_runtime_fuzz_txn_ctx_create( fd_runtime_fuzz_runner_t * runner,
8888

8989
/* Set epoch bank variables if not present (defaults obtained from GenesisConfig::default() in Agave) */
9090
fd_epoch_schedule_t default_epoch_schedule = {
91-
.slots_per_epoch = 432000,
92-
.leader_schedule_slot_offset = 432000,
93-
.warmup = 1,
94-
.first_normal_epoch = 14,
95-
.first_normal_slot = 524256
96-
};
97-
fd_rent_t default_rent = {
98-
.lamports_per_uint8_year = 3480,
99-
.exemption_threshold = 2.0,
100-
.burn_percent = 50
101-
};
91+
.slots_per_epoch = 432000,
92+
.leader_schedule_slot_offset = 432000,
93+
.warmup = 1,
94+
.first_normal_epoch = 14,
95+
.first_normal_slot = 524256
96+
};
97+
fd_rent_t default_rent = {
98+
.lamports_per_uint8_year = 3480,
99+
.exemption_threshold = 2.0,
100+
.burn_percent = 50
101+
};
102102
fd_bank_epoch_schedule_set( slot_ctx->bank, default_epoch_schedule );
103103

104104
fd_bank_rent_set( slot_ctx->bank, default_rent );
@@ -195,7 +195,7 @@ fd_runtime_fuzz_txn_ctx_create( fd_runtime_fuzz_runner_t * runner,
195195

196196
/* Blockhash queue init */
197197
ulong blockhash_seed; FD_TEST( fd_rng_secure( &blockhash_seed, sizeof(ulong) ) );
198-
fd_blockhashes_init( fd_bank_block_hash_queue_modify( slot_ctx->bank ), blockhash_seed );
198+
fd_blockhashes_t * blockhashes = fd_blockhashes_init( fd_bank_block_hash_queue_modify( slot_ctx->bank ), blockhash_seed );
199199

200200
// Save lamports per signature for most recent blockhash, if sysvar cache contains recent block hashes
201201
fd_recent_block_hashes_t const * rbh_sysvar = fd_sysvar_recent_hashes_read( funk, funk_txn, runner->spad );
@@ -219,10 +219,14 @@ fd_runtime_fuzz_txn_ctx_create( fd_runtime_fuzz_runner_t * runner,
219219
memcpy( genesis_hash->hash, test_ctx->blockhash_queue[0]->bytes, sizeof(fd_hash_t) );
220220

221221
for( ulong i = 0; i < num_blockhashes; ++i ) {
222+
fd_hash_t blockhash = FD_LOAD( fd_hash_t, test_ctx->blockhash_queue[i]->bytes );
223+
/* Drop duplicate blockhashes */
224+
if( FD_UNLIKELY( fd_blockhash_map_idx_remove( blockhashes->map, &blockhash, ULONG_MAX, blockhashes->d.deque )!=ULONG_MAX ) ) {
225+
FD_LOG_WARNING(( "Fuzz input has a duplicate blockhash %s at index %lu",
226+
FD_BASE58_ENC_32_ALLOCA( blockhash.hash ), i ));
227+
}
222228
// Recent block hashes cap is 150 (actually 151), while blockhash queue capacity is 300 (actually 301)
223-
fd_block_block_hash_entry_t blockhash_entry;
224-
memcpy( &blockhash_entry.blockhash, test_ctx->blockhash_queue[i]->bytes, sizeof(fd_hash_t) );
225-
fd_bank_poh_set( slot_ctx->bank, blockhash_entry.blockhash );
229+
fd_bank_poh_set( slot_ctx->bank, blockhash );
226230
fd_sysvar_recent_hashes_update( slot_ctx, runner->spad );
227231
}
228232
} else {

0 commit comments

Comments
 (0)