From 36ccc712207eb13d413991bba75ee0b6f5b7ed70 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 7 Jun 2023 14:35:28 -0500 Subject: [PATCH] move StakeReward to stake_rewards.rs (#32014) --- runtime/src/bank.rs | 14 +------------- runtime/src/lib.rs | 1 + runtime/src/serde_snapshot/tests.rs | 2 +- runtime/src/stake_rewards.rs | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 runtime/src/stake_rewards.rs diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index ce848d3e0f..d37603ad51 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -70,6 +70,7 @@ use { sorted_storages::SortedStorages, stake_account::{self, StakeAccount}, stake_history::StakeHistory, + stake_rewards::StakeReward, stake_weighted_timestamp::{ calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW_V2, @@ -1129,19 +1130,6 @@ pub struct CommitTransactionCounts { pub signature_count: u64, } -#[derive(AbiExample, Debug, Serialize, Deserialize, Clone, PartialEq)] -pub(crate) struct StakeReward { - stake_pubkey: Pubkey, - stake_reward_info: RewardInfo, - stake_account: AccountSharedData, -} - -impl StakeReward { - fn get_stake_reward(&self) -> i64 { - self.stake_reward_info.lamports - } -} - /// allow [StakeReward] to be passed to `StoreAccounts` directly without copies or vec construction impl<'a> StorableAccounts<'a, AccountSharedData> for (Slot, &'a [StakeReward], IncludeSlotInHash) { fn pubkey(&self, index: usize) -> &Pubkey { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index aacedd91b8..a58b4846f3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -71,6 +71,7 @@ pub mod snapshot_utils; pub mod sorted_storages; mod stake_account; pub mod stake_history; +mod stake_rewards; pub mod stake_weighted_timestamp; pub mod stakes; pub mod static_ids; diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index c15d3a92d5..9c37677d3a 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -719,7 +719,7 @@ mod test_bank_serialize { // This some what long test harness is required to freeze the ABI of // Bank's serialization due to versioned nature - #[frozen_abi(digest = "9BucA5MtPMNNUjADyV27vNgzvDy1RqCLH2gRq5NEuDEF")] + #[frozen_abi(digest = "8LhKH71kTwmagxUGJA6Es58p8fejJsSAdgEmtL3xZdoY")] #[derive(Serialize, AbiExample)] pub struct BankAbiTestWrapperNewer { #[serde(serialize_with = "wrapper_newer")] diff --git a/runtime/src/stake_rewards.rs b/runtime/src/stake_rewards.rs new file mode 100644 index 0000000000..55ab5844dc --- /dev/null +++ b/runtime/src/stake_rewards.rs @@ -0,0 +1,19 @@ +//! Code for stake and vote rewards + +use { + crate::bank::RewardInfo, + solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, +}; + +#[derive(AbiExample, Debug, Serialize, Deserialize, Clone, PartialEq)] +pub(crate) struct StakeReward { + pub(crate) stake_pubkey: Pubkey, + pub(crate) stake_reward_info: RewardInfo, + pub(crate) stake_account: AccountSharedData, +} + +impl StakeReward { + pub(crate) fn get_stake_reward(&self) -> i64 { + self.stake_reward_info.lamports + } +}