Skip to content

Commit

Permalink
invoke context: add epoch stake
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Apr 18, 2024
1 parent d5b979c commit a233266
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub struct InvokeContext<'a> {
pub programs_loaded_for_tx_batch: &'a ProgramCacheForTxBatch,
pub programs_modified_by_tx: &'a mut ProgramCacheForTxBatch,
pub feature_set: Arc<FeatureSet>,
pub get_epoch_stake_callback: &'a dyn Fn(&'a Pubkey) -> u64,
pub timings: ExecuteDetailsTimings,
pub blockhash: Hash,
pub lamports_per_signature: u64,
Expand All @@ -186,6 +187,7 @@ impl<'a> InvokeContext<'a> {
programs_loaded_for_tx_batch: &'a ProgramCacheForTxBatch,
programs_modified_by_tx: &'a mut ProgramCacheForTxBatch,
feature_set: Arc<FeatureSet>,
get_epoch_stake_callback: &'a dyn Fn(&'a Pubkey) -> u64,
blockhash: Hash,
lamports_per_signature: u64,
) -> Self {
Expand All @@ -199,6 +201,7 @@ impl<'a> InvokeContext<'a> {
programs_loaded_for_tx_batch,
programs_modified_by_tx,
feature_set,
get_epoch_stake_callback,
timings: ExecuteDetailsTimings::default(),
blockhash,
lamports_per_signature,
Expand Down Expand Up @@ -685,6 +688,7 @@ macro_rules! with_mock_invoke_context {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down
1 change: 1 addition & 0 deletions runtime/src/bank/builtins/core_bpf_migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl Bank {
&programs_loaded,
&mut programs_modified,
self.feature_set.clone(),
&|_| 0,
Hash::default(),
0,
);
Expand Down
7 changes: 7 additions & 0 deletions svm/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -331,6 +332,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -372,6 +374,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -504,6 +507,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -540,6 +544,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -573,6 +578,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down Expand Up @@ -667,6 +673,7 @@ mod tests {
&programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
Arc::new(FeatureSet::all_enabled()),
&|_| 0,
Hash::default(),
0,
);
Expand Down
2 changes: 2 additions & 0 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
programs_loaded_for_tx_batch.latest_root_epoch,
);
let sysvar_cache = &self.sysvar_cache.read().unwrap();
let epoch_stake_callback = |pubkey| callback.get_epoch_stake(pubkey);

let mut invoke_context = InvokeContext::new(
&mut transaction_context,
Expand All @@ -682,6 +683,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
programs_loaded_for_tx_batch,
&mut programs_modified_by_tx,
callback.get_feature_set(),
&epoch_stake_callback,
blockhash,
lamports_per_signature,
);
Expand Down

0 comments on commit a233266

Please sign in to comment.