Skip to content

Commit

Permalink
do not derive Copy for Rent
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Oct 19, 2023
1 parent 0dfaf6f commit e1a6228
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9165,7 +9165,7 @@ impl AccountsDb {
schedule.get_epoch(max_slot),
schedule.clone(),
genesis_config.slots_per_year(),
genesis_config.rent,
genesis_config.rent.clone(),
);
let accounts_data_len = AtomicU64::new(0);

Expand Down
4 changes: 2 additions & 2 deletions genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
identity_pubkey,
identity_pubkey,
commission,
VoteState::get_rent_exempt_reserve(&rent).max(1),
VoteState::get_rent_exempt_reserve(&genesis_config.rent).max(1),
);

genesis_config.add_account(
Expand All @@ -558,7 +558,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.unwrap_or(identity_pubkey),
vote_pubkey,
&vote_account,
&rent,
&genesis_config.rent,
bootstrap_validator_stake_lamports,
),
);
Expand Down
8 changes: 4 additions & 4 deletions genesis/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
let total_lamports = staker_reserve + reserve * 2 + 1;
create_and_check_stakes(
&mut GenesisConfig {
rent,
rent: rent.clone(),
..GenesisConfig::default()
},
&StakerInfo {
Expand All @@ -272,7 +272,7 @@ mod tests {
let total_lamports = staker_reserve + reserve * 2 + 1;
create_and_check_stakes(
&mut GenesisConfig {
rent,
rent: rent.clone(),
..GenesisConfig::default()
},
&StakerInfo {
Expand All @@ -298,7 +298,7 @@ mod tests {
let total_lamports = staker_reserve + (granularity + reserve) * 2;
create_and_check_stakes(
&mut GenesisConfig {
rent,
rent: rent.clone(),
..GenesisConfig::default()
},
&StakerInfo {
Expand All @@ -323,7 +323,7 @@ mod tests {
let total_lamports = staker_reserve + (granularity + reserve + 1) * 2;
create_and_check_stakes(
&mut GenesisConfig {
rent,
rent: rent.clone(),
..GenesisConfig::default()
},
&StakerInfo {
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3442,7 +3442,7 @@ mod tests {
sysvar_cache.set_clock(src_clock.clone());
sysvar_cache.set_epoch_schedule(src_epochschedule.clone());
sysvar_cache.set_fees(src_fees.clone());
sysvar_cache.set_rent(src_rent);
sysvar_cache.set_rent(src_rent.clone());
sysvar_cache.set_epoch_rewards(src_rewards);

let transaction_accounts = vec![
Expand Down
2 changes: 1 addition & 1 deletion programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ mod tests {
let processor_account = AccountSharedData::new(0, 0, &solana_sdk::native_loader::id());
let transaction_context = TransactionContext::new(
vec![(id(), processor_account), (node_pubkey, vote_account)],
rent,
rent.clone(),
0,
0,
);
Expand Down
10 changes: 5 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3896,7 +3896,7 @@ impl Bank {
self.epoch,
self.epoch_schedule().clone(),
self.slots_per_year,
genesis_config.rent,
genesis_config.rent.clone(),
);

// Add additional builtin programs specified in the genesis config
Expand Down Expand Up @@ -4853,7 +4853,7 @@ impl Bank {

let mut transaction_context = TransactionContext::new(
transaction_accounts,
self.rent_collector.rent,
self.rent_collector.rent.clone(),
compute_budget.max_invoke_stack_height,
if self
.feature_set
Expand Down Expand Up @@ -5768,10 +5768,10 @@ impl Bank {
let mut account = self
.get_account_with_fixed_root(&pubkey)
.unwrap_or_default();
let rent = self.rent_collector().rent;
let recipient_pre_rent_state = RentState::from_account(&account, &rent);
let rent = &self.rent_collector().rent;
let recipient_pre_rent_state = RentState::from_account(&account, rent);
let distribution = account.checked_add_lamports(rent_to_be_paid);
let recipient_post_rent_state = RentState::from_account(&account, &rent);
let recipient_post_rent_state = RentState::from_account(&account, rent);
let rent_state_transition_allowed = recipient_post_rent_state
.transition_allowed_from(&recipient_pre_rent_state);
if !rent_state_transition_allowed {
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ fn test_distribute_rent_to_validators_rent_paying() {
.unwrap();
}
let bank = Bank::new_for_tests(&genesis_config);
let rent = bank.rent_collector().rent;
let rent = &bank.rent_collector().rent;
let rent_exempt_minimum = rent.minimum_balance(0);

// Make one validator have an empty identity account
Expand Down Expand Up @@ -1093,7 +1093,7 @@ fn test_distribute_rent_to_validators_rent_paying() {
let account = bank
.get_account_with_fixed_root(address)
.unwrap_or_default();
RentState::from_account(&account, &rent)
RentState::from_account(&account, rent)
};

// Assert starting RentStates
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/rent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {crate::clock::DEFAULT_SLOTS_PER_EPOCH, solana_sdk_macro::CloneZeroed};

/// Configuration of network rent.
#[repr(C)]
#[derive(Serialize, Deserialize, PartialEq, CloneZeroed, Copy, Debug, AbiExample)]
#[derive(Serialize, Deserialize, PartialEq, CloneZeroed, Debug, AbiExample)]
pub struct Rent {
/// Rental rate in lamports/byte-year.
pub lamports_per_byte_year: u64,
Expand Down
2 changes: 1 addition & 1 deletion test-validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ impl TestValidator {
validator_stake_lamports,
validator_identity_lamports,
config.fee_rate_governor.clone(),
config.rent,
config.rent.clone(),
solana_sdk::genesis_config::ClusterType::Development,
accounts.into_iter().collect(),
);
Expand Down

0 comments on commit e1a6228

Please sign in to comment.