owner -> owner() (#16783)
This commit is contained in:
parent
aeff911c93
commit
f2ab0384e4
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -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
|
||||
})
|
||||
},
|
||||
)
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
|
|
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
@ -146,7 +146,7 @@ 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);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl PreAccount {
|
|||
// 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()
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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()?
|
||||
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>()
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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| {
|
||||
(
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
account::AccountSharedData,
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account_utils::StateMut,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::Hash,
|
||||
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue