Skip to content

Commit

Permalink
Tweaks for transaction-level fuzzing (#2744)
Browse files Browse the repository at this point in the history
Tweak register blockhash for tests + add optional feature set parameter into bank for fuzzing
  • Loading branch information
mjain-jump authored Aug 26, 2024
1 parent 4a777d1 commit a10cd55
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ pub(crate) fn process_blockstore_for_bank_0(
None,
exit,
None,
None,
);
let bank0_slot = bank0.slot();
let bank_forks = BankForks::new_rw_arc(bank0);
Expand Down
1 change: 1 addition & 0 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ impl ProgramTest {
None,
Arc::default(),
None,
None,
);

// Add commonly-used SPL programs as a convenience to the user
Expand Down
9 changes: 8 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ impl Bank {
#[allow(unused)] collector_id_for_tests: Option<Pubkey>,
exit: Arc<AtomicBool>,
#[allow(unused)] genesis_hash: Option<Hash>,
#[allow(unused)] feature_set: Option<FeatureSet>,
) -> Self {
let accounts_db = AccountsDb::new_with_config(
paths,
Expand All @@ -1005,6 +1006,11 @@ impl Bank {
bank.transaction_debug_keys = debug_keys;
bank.cluster_type = Some(genesis_config.cluster_type);

#[cfg(feature = "dev-context-only-utils")]
{
bank.feature_set = Arc::new(feature_set.unwrap_or_default());
}

#[cfg(not(feature = "dev-context-only-utils"))]
bank.process_genesis_config(genesis_config);
#[cfg(feature = "dev-context-only-utils")]
Expand Down Expand Up @@ -3157,7 +3163,6 @@ impl Bank {
w_blockhash_queue
.register_hash(blockhash, self.fee_rate_governor.lamports_per_signature);
}
self.update_recent_blockhashes_locked(&w_blockhash_queue);
}

/// Tell the bank which Entry IDs exist on the ledger. This function assumes subsequent calls
Expand Down Expand Up @@ -6631,6 +6636,7 @@ impl Bank {
Some(Pubkey::new_unique()),
Arc::default(),
None,
None,
)
}

Expand All @@ -6655,6 +6661,7 @@ impl Bank {
Some(Pubkey::new_unique()),
Arc::default(),
None,
None,
)
}

Expand Down
2 changes: 2 additions & 0 deletions runtime/src/bank/partitioned_epoch_rewards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ mod tests {
Some(Pubkey::new_unique()),
Arc::default(),
None,
None,
);

// Fill bank_forks with banks with votes landing in the next slot
Expand Down Expand Up @@ -488,6 +489,7 @@ mod tests {
Some(Pubkey::new_unique()),
Arc::default(),
None,
None,
);

let stake_account_stores_per_block =
Expand Down
5 changes: 5 additions & 0 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9010,6 +9010,7 @@ fn test_epoch_schedule_from_genesis_config() {
None,
Arc::default(),
None,
None,
));

assert_eq!(bank.epoch_schedule(), &genesis_config.epoch_schedule);
Expand Down Expand Up @@ -9041,6 +9042,7 @@ where
None,
Arc::default(),
None,
None,
));
let vote_and_stake_accounts =
load_vote_and_stake_accounts(&bank).vote_with_stake_delegations_map;
Expand Down Expand Up @@ -12645,6 +12647,7 @@ fn test_rehash_with_skipped_rewrites() {
Some(Pubkey::new_unique()),
Arc::new(AtomicBool::new(false)),
None,
None,
));
// This test is only meaningful while the bank hash contains rewrites.
// Once this feature is enabled, it may be possible to remove this test entirely.
Expand Down Expand Up @@ -12707,6 +12710,7 @@ fn test_rebuild_skipped_rewrites() {
Some(Pubkey::new_unique()),
Arc::new(AtomicBool::new(false)),
None,
None,
));
// This test is only meaningful while the bank hash contains rewrites.
// Once this feature is enabled, it may be possible to remove this test entirely.
Expand Down Expand Up @@ -12818,6 +12822,7 @@ fn test_get_accounts_for_bank_hash_details(skip_rewrites: bool) {
Some(Pubkey::new_unique()),
Arc::new(AtomicBool::new(false)),
None,
None,
));
// This test is only meaningful while the bank hash contains rewrites.
// Once this feature is enabled, it may be possible to remove this test entirely.
Expand Down

0 comments on commit a10cd55

Please sign in to comment.