Rename padding -> reserved and increase its size
This commit is contained in:
parent
bb9738b12f
commit
16d22648f7
|
@ -104,7 +104,8 @@ pub fn configure_voting_mint(
|
|||
lockup_scaled_factor,
|
||||
lockup_saturation_secs,
|
||||
grant_authority: grant_authority.unwrap_or_default(),
|
||||
padding: [0; 31],
|
||||
reserved1: [0; 7],
|
||||
reserved2: [0; 7],
|
||||
};
|
||||
|
||||
// Check for overflow in vote weight
|
||||
|
|
|
@ -38,9 +38,10 @@ pub struct DepositEntry {
|
|||
// Points to the VotingMintConfig this deposit uses.
|
||||
pub voting_mint_config_idx: u8,
|
||||
|
||||
pub padding: [u8; 13],
|
||||
pub reserved: [u8; 29],
|
||||
}
|
||||
const_assert!(std::mem::size_of::<DepositEntry>() == 32 + 2 * 8 + 3 + 13);
|
||||
const_assert!(std::mem::size_of::<DepositEntry>() == 32 + 2 * 8 + 3 + 29);
|
||||
const_assert!(std::mem::size_of::<DepositEntry>() % 8 == 0);
|
||||
|
||||
impl DepositEntry {
|
||||
/// # Voting Power Caclulation
|
||||
|
@ -367,7 +368,7 @@ mod tests {
|
|||
is_used: true,
|
||||
allow_clawback: false,
|
||||
voting_mint_config_idx: 0,
|
||||
padding: [0; 13],
|
||||
reserved: [0; 29],
|
||||
};
|
||||
let initial_deposit = deposit.clone();
|
||||
let month = deposit.lockup.kind.period_secs() as i64;
|
||||
|
@ -436,12 +437,12 @@ mod tests {
|
|||
start_ts: lockup_start,
|
||||
end_ts: lockup_start + 2 * day,
|
||||
kind: Daily,
|
||||
padding: [0; 15],
|
||||
reserved: [0; 15],
|
||||
},
|
||||
is_used: true,
|
||||
allow_clawback: false,
|
||||
voting_mint_config_idx: 0,
|
||||
padding: [0; 13],
|
||||
reserved: [0; 29],
|
||||
};
|
||||
let voting_mint_config = VotingMintConfig {
|
||||
mint: Pubkey::default(),
|
||||
|
@ -450,7 +451,8 @@ mod tests {
|
|||
lockup_scaled_factor: 1_000_000_000, // 1x
|
||||
lockup_saturation_secs: saturation as u64,
|
||||
digit_shift: 0,
|
||||
padding: [0; 31],
|
||||
reserved1: [0; 7],
|
||||
reserved2: [0; 7],
|
||||
};
|
||||
|
||||
let unlocked_vote_weight =
|
||||
|
|
|
@ -44,9 +44,10 @@ pub struct Lockup {
|
|||
pub kind: LockupKind,
|
||||
|
||||
// Empty bytes for future upgrades.
|
||||
pub padding: [u8; 15],
|
||||
pub reserved: [u8; 15],
|
||||
}
|
||||
const_assert!(std::mem::size_of::<Lockup>() == 2 * 8 + 1 + 15);
|
||||
const_assert!(std::mem::size_of::<Lockup>() % 8 == 0);
|
||||
|
||||
impl Default for Lockup {
|
||||
fn default() -> Self {
|
||||
|
@ -54,7 +55,7 @@ impl Default for Lockup {
|
|||
kind: LockupKind::None,
|
||||
start_ts: 0,
|
||||
end_ts: 0,
|
||||
padding: [0; 15],
|
||||
reserved: [0; 15],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ impl Lockup {
|
|||
.unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
padding: [0; 15],
|
||||
reserved: [0; 15],
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -753,7 +754,7 @@ mod tests {
|
|||
kind: LockupKind::Cliff,
|
||||
start_ts,
|
||||
end_ts,
|
||||
padding: [0u8; 15],
|
||||
reserved: [0u8; 15],
|
||||
};
|
||||
let days_left = l.periods_left(curr_ts)?;
|
||||
assert_eq!(days_left, t.expected_days_left);
|
||||
|
@ -768,7 +769,7 @@ mod tests {
|
|||
kind: LockupKind::Monthly,
|
||||
start_ts,
|
||||
end_ts,
|
||||
padding: [0u8; 15],
|
||||
reserved: [0u8; 15],
|
||||
};
|
||||
let months_left = l.periods_left(curr_ts)?;
|
||||
assert_eq!(months_left, t.expected_months_left);
|
||||
|
@ -788,9 +789,9 @@ mod tests {
|
|||
start_ts,
|
||||
end_ts,
|
||||
kind: t.kind,
|
||||
padding: [0u8; 15],
|
||||
reserved: [0u8; 15],
|
||||
},
|
||||
padding: [0; 13],
|
||||
reserved: [0; 29],
|
||||
};
|
||||
let curr_ts = start_ts + days_to_secs(t.curr_day);
|
||||
let power = d.voting_power_locked(curr_ts, t.amount_deposited, MAX_SECS_LOCKED)?;
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct Registrar {
|
|||
pub realm: Pubkey,
|
||||
pub realm_governing_token_mint: Pubkey,
|
||||
pub realm_authority: Pubkey,
|
||||
pub padding1: [u8; 32],
|
||||
pub reserved1: [u8; 32],
|
||||
|
||||
/// Storage for voting mints and their configuration.
|
||||
/// The length should be adjusted for one's use case.
|
||||
|
@ -20,9 +20,11 @@ pub struct Registrar {
|
|||
/// Debug only: time offset, to allow tests to move forward in time.
|
||||
pub time_offset: i64,
|
||||
pub bump: u8,
|
||||
pub padding2: [u8; 31],
|
||||
pub reserved2: [u8; 7],
|
||||
pub reserved3: [u64; 11], // split because `Default` does not support [u8; 95]
|
||||
}
|
||||
const_assert!(std::mem::size_of::<Registrar>() == 5 * 32 + 4 * 120 + 8 + 1 + 31);
|
||||
const_assert!(std::mem::size_of::<Registrar>() == 5 * 32 + 4 * 152 + 8 + 1 + 95);
|
||||
const_assert!(std::mem::size_of::<Registrar>() % 8 == 0);
|
||||
|
||||
impl Registrar {
|
||||
pub fn clock_unix_timestamp(&self) -> i64 {
|
||||
|
|
|
@ -12,9 +12,10 @@ pub struct Voter {
|
|||
pub deposits: [DepositEntry; 32],
|
||||
pub voter_bump: u8,
|
||||
pub voter_weight_record_bump: u8,
|
||||
pub padding: [u8; 30],
|
||||
pub reserved: [u8; 94],
|
||||
}
|
||||
const_assert!(std::mem::size_of::<Voter>() == 2 * 32 + 32 * 64 + 2 + 30);
|
||||
const_assert!(std::mem::size_of::<Voter>() == 2 * 32 + 32 * 80 + 2 + 94);
|
||||
const_assert!(std::mem::size_of::<Voter>() % 8 == 0);
|
||||
|
||||
impl Voter {
|
||||
pub fn weight(&self, registrar: &Registrar) -> Result<u64> {
|
||||
|
|
|
@ -31,9 +31,11 @@ pub struct VotingMintConfig {
|
|||
pub digit_shift: i8,
|
||||
|
||||
// Empty bytes for future upgrades.
|
||||
pub padding: [u8; 31],
|
||||
pub reserved1: [u8; 7],
|
||||
pub reserved2: [u64; 7], // split because `Default` does not support [u8; 63]
|
||||
}
|
||||
const_assert!(std::mem::size_of::<VotingMintConfig>() == 2 * 32 + 3 * 8 + 1 + 31);
|
||||
const_assert!(std::mem::size_of::<VotingMintConfig>() == 2 * 32 + 3 * 8 + 1 + 63);
|
||||
const_assert!(std::mem::size_of::<VotingMintConfig>() % 8 == 0);
|
||||
|
||||
impl VotingMintConfig {
|
||||
/// Converts an amount in this voting mints's native currency
|
||||
|
|
Loading…
Reference in New Issue