From fb01ab28ec90c59e54e6e7e1209a46ea5933cc4e Mon Sep 17 00:00:00 2001 From: ripatel-fd Date: Fri, 15 Mar 2024 21:59:41 +0100 Subject: [PATCH] Use static memory layout for all sysvars (#249) Co-authored-by: Richard Patel --- sdk/program/src/epoch_rewards.rs | 2 ++ sdk/program/src/fee_calculator.rs | 1 + sdk/program/src/stake_history.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/sdk/program/src/epoch_rewards.rs b/sdk/program/src/epoch_rewards.rs index 525caf5f1f9c68..e3229486e0e0dc 100644 --- a/sdk/program/src/epoch_rewards.rs +++ b/sdk/program/src/epoch_rewards.rs @@ -7,6 +7,8 @@ //! [`sysvar::epoch_rewards`]: crate::sysvar::epoch_rewards use std::ops::AddAssign; + +#[repr(C)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Default, Clone, Copy, AbiExample)] pub struct EpochRewards { /// total rewards for the current epoch, in lamports diff --git a/sdk/program/src/fee_calculator.rs b/sdk/program/src/fee_calculator.rs index ef29ec2e2beb7d..c4dcb572cf2b61 100644 --- a/sdk/program/src/fee_calculator.rs +++ b/sdk/program/src/fee_calculator.rs @@ -6,6 +6,7 @@ use { log::*, }; +#[repr(C)] #[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, AbiExample)] #[serde(rename_all = "camelCase")] pub struct FeeCalculator { diff --git a/sdk/program/src/stake_history.rs b/sdk/program/src/stake_history.rs index 331803e5f7572e..0441482fd2f38e 100644 --- a/sdk/program/src/stake_history.rs +++ b/sdk/program/src/stake_history.rs @@ -11,6 +11,7 @@ use std::ops::Deref; pub const MAX_ENTRIES: usize = 512; // it should never take as many as 512 epochs to warm up or cool down +#[repr(C)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Default, Clone, AbiExample)] pub struct StakeHistoryEntry { pub effective: u64, // effective stake at this epoch