Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sysvar/src/stake_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#[cfg(feature = "bincode")]
use crate::Sysvar;
#[deprecated(
since = "2.3.0",
note = "Use solana_sdk_ids::sysvar::stake_history instead"
)]
pub use solana_sdk_ids::sysvar::stake_history::{check_id, id, ID};
#[deprecated(
since = "2.2.0",
Expand All @@ -68,12 +72,17 @@ impl Sysvar for StakeHistory {
}

// we do not provide Default because this requires the real current epoch
#[deprecated(
since = "2.3.0",
note = "Use solana_stake_interface::sysvar::stake_history::StakeHistorySysvar in v2 instead"
)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "in v2 instead" mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're inverting which crate implements the sysvar code and trait from solana-sysvar to solana-stake-interface, but since only one crate can implement the trait, we have to do it in a breaking change, ie in solana-stake-interface v2 and solana-sysvar v3.

With normal deprecation warnings, there's typically an alternative that you can use right away, but we don't have the alternative ready in solana-sysvar v2, so I wanted to make clear that you need to use solana-stake-interface v2. Is it clearer if it says this?

Use solana_stake_interface::sysvar::stake_history::StakeHistorySysvar in solana-stake-interface v2 instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! That's a little more clear, thanks!

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct StakeHistorySysvar(pub Epoch);

// precompute so we can statically allocate buffer
const EPOCH_AND_ENTRY_SERIALIZED_SIZE: u64 = 32;

#[allow(deprecated)]
impl StakeHistoryGetEntry for StakeHistorySysvar {
fn get_entry(&self, target_epoch: Epoch) -> Option<StakeHistoryEntry> {
let current_epoch = self.0;
Expand Down Expand Up @@ -127,6 +136,7 @@ impl StakeHistoryGetEntry for StakeHistorySysvar {
}

#[cfg(test)]
#[allow(deprecated)]
mod tests {
use {super::*, crate::tests::mock_get_sysvar_syscall, serial_test::serial};

Expand Down
Loading