Skip to content

Commit

Permalink
SVM: Move RewardInfo from accounts-db to Solana SDK (solana-labs#35120)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov authored Feb 7, 2024
1 parent 7a95e4f commit 2c0001b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions accounts-db/src/rent_debits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {
crate::stake_rewards::RewardInfo,
solana_sdk::{pubkey::Pubkey, reward_type::RewardType},
solana_sdk::{pubkey::Pubkey, reward_info::RewardInfo, reward_type::RewardType},
std::collections::HashMap,
};

Expand Down
15 changes: 2 additions & 13 deletions accounts-db/src/stake_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
use {
crate::storable_accounts::StorableAccounts,
solana_sdk::{
account::AccountSharedData, clock::Slot, pubkey::Pubkey, reward_type::RewardType,
account::AccountSharedData, clock::Slot, pubkey::Pubkey, reward_info::RewardInfo,
},
};

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, AbiExample, Clone, Copy)]
pub struct RewardInfo {
pub reward_type: RewardType,
/// Reward amount
pub lamports: i64,
/// Account balance in lamports after `lamports` was applied
pub post_balance: u64,
/// Vote account commission when the reward was credited, only present for voting and staking rewards
pub commission: Option<u8>,
}

#[derive(AbiExample, Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct StakeReward {
pub stake_pubkey: Pubkey,
Expand Down Expand Up @@ -94,7 +83,7 @@ impl StakeReward {
Self {
stake_pubkey: Pubkey::new_unique(),
stake_reward_info: RewardInfo {
reward_type: RewardType::Staking,
reward_type: solana_sdk::reward_type::RewardType::Staking,
lamports: rng.gen_range(1..200),
post_balance: 0, /* unused atm */
commission: None, /* unused atm */
Expand Down
3 changes: 1 addition & 2 deletions core/src/rewards_recorder_service.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use {
crossbeam_channel::{Receiver, RecvTimeoutError, Sender},
solana_accounts_db::stake_rewards::RewardInfo,
solana_ledger::blockstore::Blockstore,
solana_sdk::{clock::Slot, pubkey::Pubkey},
solana_sdk::{clock::Slot, pubkey::Pubkey, reward_info::RewardInfo},
solana_transaction_status::Reward,
std::{
sync::{
Expand Down
3 changes: 1 addition & 2 deletions geyser-plugin-manager/src/block_metadata_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ use {
geyser_plugin_manager::GeyserPluginManager,
},
log::*,
solana_accounts_db::stake_rewards::RewardInfo,
solana_geyser_plugin_interface::geyser_plugin_interface::{
ReplicaBlockInfoV3, ReplicaBlockInfoVersions,
},
solana_measure::measure::Measure,
solana_metrics::*,
solana_sdk::{clock::UnixTimestamp, pubkey::Pubkey},
solana_sdk::{clock::UnixTimestamp, pubkey::Pubkey, reward_info::RewardInfo},
solana_transaction_status::{Reward, Rewards},
std::sync::{Arc, RwLock},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {
solana_accounts_db::stake_rewards::RewardInfo,
solana_sdk::{clock::UnixTimestamp, pubkey::Pubkey},
solana_sdk::{clock::UnixTimestamp, pubkey::Pubkey, reward_info::RewardInfo},
std::sync::{Arc, RwLock},
};

Expand Down
3 changes: 2 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ use {
rent_collector::{CollectedInfo, RentCollector, RENT_EXEMPT_RENT_EPOCH},
rent_debits::RentDebits,
sorted_storages::SortedStorages,
stake_rewards::{RewardInfo, StakeReward},
stake_rewards::StakeReward,
storable_accounts::StorableAccounts,
transaction_results::{
TransactionCheckResult, TransactionExecutionDetails, TransactionExecutionResult,
Expand Down Expand Up @@ -143,6 +143,7 @@ use {
precompiles::get_precompiles,
pubkey::Pubkey,
rent::RentDue,
reward_info::RewardInfo,
saturating_add_assign,
signature::{Keypair, Signature},
slot_hashes::SlotHashes,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank/fee_distribution.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {
super::Bank,
log::{debug, warn},
solana_accounts_db::stake_rewards::RewardInfo,
solana_sdk::{
account::{ReadableAccount, WritableAccount},
pubkey::Pubkey,
reward_info::RewardInfo,
reward_type::RewardType,
system_program,
},
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ mod tests {

// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "12WNiuA7qeLU8JFweQszX5sCnCj1fYnYV4i9DeACqhQD")]
#[frozen_abi(digest = "77zuTwvAGH5Rf28XHUNkRWsrcJ8uMyARMCZZMg9BBu5S")]
#[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperNewer {
#[serde(serialize_with = "wrapper_newer")]
Expand Down
1 change: 1 addition & 0 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub mod program_utils;
pub mod pubkey;
pub mod quic;
pub mod recent_blockhashes_account;
pub mod reward_info;
pub mod reward_type;
pub mod rpc_port;
pub mod secp256k1_instruction;
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/reward_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::reward_type::RewardType;

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, AbiExample, Clone, Copy)]
pub struct RewardInfo {
pub reward_type: RewardType,
/// Reward amount
pub lamports: i64,
/// Account balance in lamports after `lamports` was applied
pub post_balance: u64,
/// Vote account commission when the reward was credited, only present for voting and staking rewards
pub commission: Option<u8>,
}

0 comments on commit 2c0001b

Please sign in to comment.