Skip to content

Commit

Permalink
owner -> owner() (#16783)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Apr 26, 2021
1 parent aeff911 commit f2ab038
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion programs/config/src/config_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn process_instruction(
let current_data: ConfigKeys = {
let config_account = config_keyed_account.try_account_ref_mut()?;
if invoke_context.is_feature_active(&feature_set::check_program_owner::id())
&& config_account.owner != crate::id()
&& config_account.owner() != &crate::id()
{
return Err(InstructionError::InvalidAccountOwner);
}
Expand Down
10 changes: 5 additions & 5 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Accounts {
})
.unwrap_or_default();

if account.executable && bpf_loader_upgradeable::check_id(&account.owner) {
if account.executable && bpf_loader_upgradeable::check_id(account.owner()) {
// The upgradeable loader requires the derived ProgramData account
if let Ok(UpgradeableLoaderState::Program {
programdata_address,
Expand Down Expand Up @@ -666,7 +666,7 @@ impl Accounts {
ancestors,
|collector: &mut Vec<(Pubkey, AccountSharedData)>, some_account_tuple| {
Self::load_while_filtering(collector, some_account_tuple, |account| {
account.owner == *program_id
account.owner() == program_id
})
},
)
Expand All @@ -682,7 +682,7 @@ impl Accounts {
ancestors,
|collector: &mut Vec<(Pubkey, AccountSharedData)>, some_account_tuple| {
Self::load_while_filtering(collector, some_account_tuple, |account| {
account.owner == *program_id && filter(account)
account.owner() == program_id && filter(account)
})
},
)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ pub fn create_test_accounts(
for t in 0..num {
let pubkey = solana_sdk::pubkey::new_rand();
let account =
AccountSharedData::new((t + 1) as u64, 0, AccountSharedData::default().owner());
AccountSharedData::new((t + 1) as u64, 0, &AccountSharedData::default().owner());
accounts.store_slow_uncached(slot, &pubkey, &account);
pubkeys.push(pubkey);
}
Expand All @@ -1049,7 +1049,7 @@ pub fn create_test_accounts(
pub fn update_accounts_bench(accounts: &Accounts, pubkeys: &[Pubkey], slot: u64) {
for pubkey in pubkeys {
let amount = thread_rng().gen_range(0, 10);
let account = AccountSharedData::new(amount, 0, AccountSharedData::default().owner());
let account = AccountSharedData::new(amount, 0, &AccountSharedData::default().owner());
accounts.store_slow_uncached(slot, &pubkey, &account);
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'a> LoadedAccount<'a> {
pub fn owner(&self) -> &Pubkey {
match self {
LoadedAccount::Stored(stored_account_meta) => &stored_account_meta.account_meta.owner,
LoadedAccount::Cached((_, cached_account)) => &cached_account.account.owner,
LoadedAccount::Cached((_, cached_account)) => &cached_account.account.owner(),
}
}

Expand Down Expand Up @@ -3254,7 +3254,7 @@ impl AccountsDb {
let mut hasher = Hasher::default();

hasher.hash(&account.data());
hasher.hash(&account.owner.as_ref());
hasher.hash(&account.owner().as_ref());

if account.executable {
hasher.hash(&[1u8; 1]);
Expand Down
10 changes: 5 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,15 +1779,15 @@ impl Bank {
stake_pubkey,
&InflationPointCalculationEvent::Delegation(
*delegation,
vote_account.owner,
*vote_account.owner(),
),
));
}
if self
.feature_set
.is_active(&feature_set::filter_stake_delegation_accounts::id())
&& (stake_account.owner != solana_stake_program::id()
|| vote_account.owner != solana_vote_program::id())
&& (stake_account.owner() != &solana_stake_program::id()
|| vote_account.owner() != &solana_vote_program::id())
{
datapoint_warn!(
"bank-stake_delegation_accounts-invalid-account",
Expand Down Expand Up @@ -2203,7 +2203,7 @@ impl Bank {
// it's very unlikely to be squatted at program_id as non-system account because of burden to
// find victim's pubkey/hash. So, when account.owner is indeed native_loader's, it's
// safe to assume it's a genuine program.
if native_loader::check_id(&account.owner) {
if native_loader::check_id(&account.owner()) {
Some(account)
} else {
// malicious account is pre-occupying at program_id
Expand Down Expand Up @@ -4954,7 +4954,7 @@ impl Bank {
let store = if let Some(existing_native_mint_account) =
self.get_account_with_fixed_root(&inline_spl_token_v2_0::native_mint::id())
{
if existing_native_mint_account.owner == solana_sdk::system_program::id() {
if existing_native_mint_account.owner() == &solana_sdk::system_program::id() {
native_mint_account.lamports = existing_native_mint_account.lamports;
true
} else {
Expand Down
16 changes: 8 additions & 8 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ impl PreAccount {
// only if the account is writable and
// only if the account is not executable and
// only if the data is zero-initialized or empty
let owner_changed = pre.owner != post.owner;
let owner_changed = pre.owner() != post.owner();
if owner_changed
&& (!is_writable // line coverage used to get branch coverage
|| pre.executable
|| *program_id != pre.owner
|| program_id != pre.owner()
|| !Self::is_zeroed(&post.data()))
{
return Err(InstructionError::ModifiedProgramId);
}

// An account not assigned to the program cannot have its balance decrease.
if *program_id != pre.owner // line coverage used to get branch coverage
if program_id != pre.owner() // line coverage used to get branch coverage
&& pre.lamports() > post.lamports
{
return Err(InstructionError::ExternalAccountLamportSpend);
Expand All @@ -146,15 +146,15 @@ impl PreAccount {
let data_len_changed = pre.data().len() != post.data().len();
if data_len_changed
&& (!system_program::check_id(program_id) // line coverage used to get branch coverage
|| !system_program::check_id(&pre.owner))
|| !system_program::check_id(pre.owner()))
{
return Err(InstructionError::AccountDataSizeChanged);
}

// Only the owner may change account data
// and if the account is writable
// and if the account is not executable
if !(*program_id == pre.owner
if !(program_id == pre.owner()
&& is_writable // line coverage used to get branch coverage
&& !pre.executable)
&& pre.data() != post.data()
Expand All @@ -176,7 +176,7 @@ impl PreAccount {
}
if !is_writable // line coverage used to get branch coverage
|| pre.executable
|| *program_id != pre.owner
|| program_id != pre.owner()
{
return Err(InstructionError::ExecutableModified);
}
Expand Down Expand Up @@ -840,7 +840,7 @@ impl MessageProcessor {
);
return Err(InstructionError::AccountNotExecutable);
}
let programdata = if program_account.borrow().owner == bpf_loader_upgradeable::id() {
let programdata = if program_account.borrow().owner() == &bpf_loader_upgradeable::id() {
if let UpgradeableLoaderState::Program {
programdata_address,
} = program_account.borrow().state()?
Expand Down Expand Up @@ -918,7 +918,7 @@ impl MessageProcessor {
dst_keyed_account.try_account_ref_mut()?.lamports = src_keyed_account.lamports;
dst_keyed_account
.try_account_ref_mut()?
.set_owner(src_keyed_account.owner);
.set_owner(*src_keyed_account.owner());
dst_keyed_account
.try_account_ref_mut()?
.set_data(src_keyed_account.data().to_vec());
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/rent_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl RentCollector {
) -> u64 {
if account.executable
|| account.rent_epoch > self.epoch
|| sysvar::check_id(&account.owner)
|| sysvar::check_id(account.owner())
|| *address == incinerator::id()
{
0
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ impl Stakes {
}

pub fn is_stake(account: &AccountSharedData) -> bool {
solana_vote_program::check_id(&account.owner)
|| solana_stake_program::check_id(&account.owner)
solana_vote_program::check_id(account.owner())
|| solana_stake_program::check_id(account.owner())
&& account.data().len() >= std::mem::size_of::<StakeState>()
}

Expand All @@ -122,7 +122,7 @@ impl Stakes {
fix_stake_deactivate: bool,
check_vote_init: bool,
) -> Option<ArcVoteAccount> {
if solana_vote_program::check_id(&account.owner) {
if solana_vote_program::check_id(account.owner()) {
// unconditionally remove existing at first; there is no dependent calculated state for
// votes, not like stakes (stake codepath maintains calculated stake value grouped by
// delegated vote pubkey)
Expand All @@ -148,7 +148,7 @@ impl Stakes {
.insert(*pubkey, (stake, ArcVoteAccount::from(account.clone())));
}
old.map(|(_, account)| account)
} else if solana_stake_program::check_id(&account.owner) {
} else if solana_stake_program::check_id(account.owner()) {
// old_stake is stake lamports and voter_pubkey from the pre-store() version
let old_stake = self.stake_delegations.get(pubkey).map(|delegation| {
(
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/system_instruction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn allocate(

// if it looks like the `to` account is already in use, bail
// (note that the id check is also enforced by message_processor)
if !account.data().is_empty() || !system_program::check_id(&account.owner) {
if !account.data().is_empty() || !system_program::check_id(&account.owner()) {
ic_msg!(
invoke_context,
"Allocate: account {:?} already in use",
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/keyed_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a> KeyedAccount<'a> {
}

pub fn owner(&self) -> Result<Pubkey, InstructionError> {
Ok(self.try_borrow()?.owner)
Ok(*self.try_borrow()?.owner())
}

pub fn executable(&self) -> Result<bool, InstructionError> {
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/nonce_account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
account::AccountSharedData,
account::{AccountSharedData, ReadableAccount},
account_utils::StateMut,
fee_calculator::FeeCalculator,
hash::Hash,
Expand All @@ -20,7 +20,7 @@ pub fn create_account(lamports: u64) -> RefCell<AccountSharedData> {
}

pub fn verify_nonce_account(acc: &AccountSharedData, hash: &Hash) -> bool {
if acc.owner != crate::system_program::id() {
if acc.owner() != &crate::system_program::id() {
return false;
}
match StateMut::<Versions>::state(acc).map(|v| v.convert_to_current()) {
Expand Down

0 comments on commit f2ab038

Please sign in to comment.