Skip to content

Commit

Permalink
Set genesis epoch schedule from sysvar
Browse files Browse the repository at this point in the history
  • Loading branch information
mjain-jump committed Sep 9, 2024
1 parent 05435cd commit 7a65271
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/txn_fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use solana_runtime::bank::{Bank, LoadAndExecuteTransactionsOutput};
use solana_runtime::bank_forks::BankForks;
use solana_runtime::transaction_batch::TransactionBatch;
use solana_sdk::account::{AccountSharedData, ReadableAccount};
use solana_sdk::epoch_schedule::EpochSchedule;
use solana_sdk::feature_set::FeatureSet;
use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::instruction::InstructionError;
Expand Down Expand Up @@ -364,22 +365,36 @@ pub fn execute_transaction(context: TxnContext) -> Option<TxnResult> {
let fee_collector = Pubkey::new_unique();
let slot = context.slot_ctx.as_ref().map(|ctx| ctx.slot).unwrap_or(10); // Arbitrary default > 0

/* HACK: Set the genesis config rent from the "to-be" sysvar rent, if present */
/* HACK: Set the genesis config rent and epoch schedule from the "to-be" sysvars, if present */
let rent: Rent = context
.tx
.as_ref()?
.message
.as_ref()?
.account_shared_data
.iter()
.find(|item| item.address.as_slice() == sysvar::rent::id().as_ref())
.find(|item| item.address.as_slice() == sysvar::rent::id().as_ref() && item.lamports > 0)
.map(|account| bincode::deserialize(&account.data).ok())
.unwrap_or_default()
.unwrap_or_default();
let epoch_schedule: EpochSchedule = context
.tx
.as_ref()?
.message
.as_ref()?
.account_shared_data
.iter()
.find(|item| {
item.address.as_slice() == sysvar::epoch_schedule::id().as_ref() && item.lamports > 0
})
.map(|account| bincode::deserialize(&account.data).ok())
.unwrap_or_default()
.unwrap_or_default();

let genesis_config = GenesisConfig {
creation_time: 0,
rent,
epoch_schedule,
..GenesisConfig::default()
};

Expand Down

0 comments on commit 7a65271

Please sign in to comment.