rename to stake_rewards_by_partition for clarity (#32165)
This commit is contained in:
parent
f720ca3339
commit
174ceba82b
|
@ -884,7 +884,7 @@ pub(crate) struct StartBlockHeightAndRewards {
|
||||||
/// the block height of the slot at which rewards distribution began
|
/// the block height of the slot at which rewards distribution began
|
||||||
pub(crate) start_block_height: u64,
|
pub(crate) start_block_height: u64,
|
||||||
/// calculated epoch rewards pending distribution, outer Vec is by partition (one partition per block)
|
/// calculated epoch rewards pending distribution, outer Vec is by partition (one partition per block)
|
||||||
pub(crate) calculated_epoch_stake_rewards: Arc<Vec<StakeRewards>>,
|
pub(crate) stake_rewards_by_partition: Arc<Vec<StakeRewards>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represent whether bank is in the reward phase or not.
|
/// Represent whether bank is in the reward phase or not.
|
||||||
|
@ -1496,10 +1496,13 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) fn set_epoch_reward_status_active(&mut self, stake_rewards: Vec<StakeRewards>) {
|
pub(crate) fn set_epoch_reward_status_active(
|
||||||
|
&mut self,
|
||||||
|
stake_rewards_by_partition: Vec<StakeRewards>,
|
||||||
|
) {
|
||||||
self.epoch_reward_status = EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
self.epoch_reward_status = EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
||||||
start_block_height: self.block_height,
|
start_block_height: self.block_height,
|
||||||
calculated_epoch_stake_rewards: Arc::new(stake_rewards),
|
stake_rewards_by_partition: Arc::new(stake_rewards_by_partition),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1937,8 +1940,7 @@ impl Bank {
|
||||||
let height = self.block_height();
|
let height = self.block_height();
|
||||||
let start_block_height = status.start_block_height;
|
let start_block_height = status.start_block_height;
|
||||||
let credit_start = start_block_height + self.get_reward_calculation_num_blocks();
|
let credit_start = start_block_height + self.get_reward_calculation_num_blocks();
|
||||||
let credit_end_exclusive =
|
let credit_end_exclusive = credit_start + status.stake_rewards_by_partition.len() as u64;
|
||||||
credit_start + status.calculated_epoch_stake_rewards.len() as u64;
|
|
||||||
assert!(
|
assert!(
|
||||||
self.epoch_schedule.get_slots_in_epoch(self.epoch)
|
self.epoch_schedule.get_slots_in_epoch(self.epoch)
|
||||||
> credit_end_exclusive.saturating_sub(credit_start)
|
> credit_end_exclusive.saturating_sub(credit_start)
|
||||||
|
@ -1947,7 +1949,7 @@ impl Bank {
|
||||||
if height >= credit_start && height < credit_end_exclusive {
|
if height >= credit_start && height < credit_end_exclusive {
|
||||||
let partition_index = height - credit_start;
|
let partition_index = height - credit_start;
|
||||||
self.distribute_epoch_rewards_in_partition(
|
self.distribute_epoch_rewards_in_partition(
|
||||||
&status.calculated_epoch_stake_rewards,
|
&status.stake_rewards_by_partition,
|
||||||
partition_index,
|
partition_index,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,11 +606,11 @@ fn test_extra_fields_eof() {
|
||||||
assert!(matches!(epoch_reward_status, EpochRewardStatus::Active(_)));
|
assert!(matches!(epoch_reward_status, EpochRewardStatus::Active(_)));
|
||||||
if let EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
if let EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
||||||
start_block_height,
|
start_block_height,
|
||||||
calculated_epoch_stake_rewards: ref stake_rewards,
|
ref stake_rewards_by_partition,
|
||||||
}) = epoch_reward_status
|
}) = epoch_reward_status
|
||||||
{
|
{
|
||||||
assert_eq!(*start_block_height, 1);
|
assert_eq!(*start_block_height, 1);
|
||||||
assert_eq!(&rewards[..], &stake_rewards[..]);
|
assert_eq!(&rewards[..], &stake_rewards_by_partition[..]);
|
||||||
} else {
|
} else {
|
||||||
unreachable!("Epoch reward status should NOT be inactive.");
|
unreachable!("Epoch reward status should NOT be inactive.");
|
||||||
}
|
}
|
||||||
|
@ -698,11 +698,11 @@ fn test_extra_fields_full_snapshot_archive() {
|
||||||
assert!(matches!(epoch_reward_status, EpochRewardStatus::Active(_)));
|
assert!(matches!(epoch_reward_status, EpochRewardStatus::Active(_)));
|
||||||
if let EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
if let EpochRewardStatus::Active(StartBlockHeightAndRewards {
|
||||||
start_block_height,
|
start_block_height,
|
||||||
calculated_epoch_stake_rewards: ref stake_rewards,
|
ref stake_rewards_by_partition,
|
||||||
}) = epoch_reward_status
|
}) = epoch_reward_status
|
||||||
{
|
{
|
||||||
assert_eq!(*start_block_height, 1);
|
assert_eq!(*start_block_height, 1);
|
||||||
assert_eq!(&rewards[..], &stake_rewards[..]);
|
assert_eq!(&rewards[..], &stake_rewards_by_partition[..]);
|
||||||
} else {
|
} else {
|
||||||
unreachable!("Epoch reward status should NOT be inactive.");
|
unreachable!("Epoch reward status should NOT be inactive.");
|
||||||
}
|
}
|
||||||
|
@ -795,7 +795,7 @@ mod test_bank_serialize {
|
||||||
|
|
||||||
// This some what long test harness is required to freeze the ABI of
|
// This some what long test harness is required to freeze the ABI of
|
||||||
// Bank's serialization due to versioned nature
|
// Bank's serialization due to versioned nature
|
||||||
#[frozen_abi(digest = "E783LfT75MPc1A9bqVtq3HsSkv3MP8kbssyJVYHA3erG")]
|
#[frozen_abi(digest = "A99zFXvqYm88n6EbtEFbroDbuFNnhw4K7AmqMh2wjJmh")]
|
||||||
#[derive(Serialize, AbiExample)]
|
#[derive(Serialize, AbiExample)]
|
||||||
pub struct BankAbiTestWrapperNewer {
|
pub struct BankAbiTestWrapperNewer {
|
||||||
#[serde(serialize_with = "wrapper_newer")]
|
#[serde(serialize_with = "wrapper_newer")]
|
||||||
|
|
Loading…
Reference in New Issue