-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate partitioned-rewards PDA during calculation (#34624)
* Add epoch_rewards_partition_data module * Rename variable * Pass hasher's parent_blockhash up to begin_partitioned_rewards * Populate epoch rewards partition data account in begin_partitioned_rewards * Fix method name
- Loading branch information
Tyera
authored
Jan 12, 2024
1 parent
22fcffe
commit 4385ed1
Showing
5 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use { | ||
crate::{hash::Hash, pubkey::Pubkey}, | ||
serde_derive::{Deserialize, Serialize}, | ||
}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] | ||
pub enum EpochRewardsPartitionDataVersion { | ||
V0(PartitionData), | ||
} | ||
|
||
#[repr(u8)] | ||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] | ||
pub enum HasherKind { | ||
Sip13, | ||
} | ||
|
||
/// Data about a rewards partitions for an epoch | ||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] | ||
pub struct PartitionData { | ||
/// Number of partitions used for epoch rewards this epoch | ||
pub num_partitions: usize, | ||
/// Blockhash of the last block of the previous epoch, used to create EpochRewardsHasher | ||
pub parent_blockhash: Hash, | ||
/// Kind of hasher used to generate partitions | ||
pub hasher_kind: HasherKind, | ||
} | ||
|
||
pub fn get_epoch_rewards_partition_data_address(epoch: u64) -> Pubkey { | ||
let (address, _bump_seed) = Pubkey::find_program_address( | ||
&[b"EpochRewardsPartitionData", &epoch.to_le_bytes()], | ||
&crate::stake::program::id(), | ||
); | ||
address | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters