Define epoch-rewards partition data program id (#34862)

* Create new program id for epoch-rewards partition data PDAs

* Remove misleading repr attribute

* Remove storage of HasherKind

* Split up seeds
This commit is contained in:
Tyera 2024-01-22 19:14:29 -07:00 committed by GitHub
parent 9122193e17
commit 8aa726bfdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -140,7 +140,7 @@ use {
},
epoch_info::EpochInfo,
epoch_rewards_partition_data::{
get_epoch_rewards_partition_data_address, EpochRewardsPartitionDataVersion, HasherKind,
get_epoch_rewards_partition_data_address, EpochRewardsPartitionDataVersion,
PartitionData,
},
epoch_schedule::EpochSchedule,
@ -3603,7 +3603,6 @@ impl Bank {
let epoch_rewards_partition_data = EpochRewardsPartitionDataVersion::V0(PartitionData {
num_partitions,
parent_blockhash,
hasher_kind: HasherKind::Sip13,
});
let address = get_epoch_rewards_partition_data_address(self.epoch());

View File

@ -8,7 +8,14 @@ pub enum EpochRewardsPartitionDataVersion {
V0(PartitionData),
}
#[repr(u8)]
impl EpochRewardsPartitionDataVersion {
pub fn get_hasher_kind(&self) -> HasherKind {
match self {
EpochRewardsPartitionDataVersion::V0(_) => HasherKind::Sip13,
}
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub enum HasherKind {
Sip13,
@ -21,14 +28,12 @@ pub struct PartitionData {
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(),
&[b"EpochRewards", b"PartitionData", &epoch.to_le_bytes()],
&crate::sysvar::id(),
);
address
}