AccountSharedData.executable() (#16835)

This commit is contained in:
Jeff Washington (jwash)
2021-04-27 09:12:17 -05:00
committed by GitHub
parent 4e7e675c07
commit 998cba74b5
7 changed files with 19 additions and 18 deletions

View File

@ -228,7 +228,8 @@ 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,
@ -352,7 +353,7 @@ impl Accounts {
return Err(TransactionError::ProgramAccountNotFound);
}
};
if !program.executable {
if !program.executable() {
error_counters.invalid_program_for_execution += 1;
return Err(TransactionError::InvalidProgramForExecution);
}

View File

@ -289,7 +289,7 @@ impl<'a> LoadedAccount<'a> {
LoadedAccount::Stored(stored_account_meta) => {
stored_account_meta.account_meta.executable
}
LoadedAccount::Cached((_, cached_account)) => cached_account.account.executable,
LoadedAccount::Cached((_, cached_account)) => cached_account.account.executable(),
}
}
@ -3256,7 +3256,7 @@ impl AccountsDb {
hasher.hash(&account.data());
hasher.hash(&account.owner().as_ref());
if account.executable {
if account.executable() {
hasher.hash(&[1u8; 1]);
} else {
hasher.hash(&[0u8; 1]);

View File

@ -116,7 +116,7 @@ impl PreAccount {
let owner_changed = pre.owner() != post.owner();
if owner_changed
&& (!is_writable // line coverage used to get branch coverage
|| pre.executable
|| pre.executable()
|| program_id != pre.owner()
|| !Self::is_zeroed(&post.data()))
{
@ -136,7 +136,7 @@ impl PreAccount {
if !is_writable {
return Err(InstructionError::ReadonlyLamportChange);
}
if pre.executable {
if pre.executable() {
return Err(InstructionError::ExecutableLamportChange);
}
}
@ -156,10 +156,10 @@ impl PreAccount {
// and if the account is not executable
if !(program_id == pre.owner()
&& is_writable // line coverage used to get branch coverage
&& !pre.executable)
&& !pre.executable())
&& pre.data() != post.data()
{
if pre.executable {
if pre.executable() {
return Err(InstructionError::ExecutableDataModified);
} else if is_writable {
return Err(InstructionError::ExternalAccountDataModified);
@ -169,13 +169,13 @@ impl PreAccount {
}
// executable is one-way (false->true) and only the account owner may set it.
let executable_changed = pre.executable != post.executable;
let executable_changed = pre.executable() != post.executable();
if executable_changed {
if !rent.is_exempt(post.lamports, post.data().len()) {
return Err(InstructionError::ExecutableAccountNotRentExempt);
}
if !is_writable // line coverage used to get branch coverage
|| pre.executable
|| pre.executable()
|| program_id != pre.owner()
{
return Err(InstructionError::ExecutableModified);
@ -832,7 +832,7 @@ impl MessageProcessor {
ic_msg!(invoke_context, "Unknown program {}", callee_program_id);
InstructionError::MissingAccount
})?;
if !program_account.borrow().executable {
if !program_account.borrow().executable() {
ic_msg!(
invoke_context,
"Account {} is not executable",
@ -902,7 +902,7 @@ impl MessageProcessor {
let dst_keyed_account = &keyed_accounts[dst_keyed_account_index];
let src_keyed_account = account.borrow();
if message.is_writable(src_keyed_account_index, demote_sysvar_write_locks)
&& !src_keyed_account.executable
&& !src_keyed_account.executable()
{
if dst_keyed_account.data_len()? != src_keyed_account.data().len()
&& dst_keyed_account.data_len()? != 0
@ -1108,7 +1108,7 @@ impl MessageProcessor {
)?;
pre_sum += u128::from(pre_account.lamports());
post_sum += u128::from(account.lamports);
if is_writable && !account.executable {
if is_writable && !account.executable() {
pre_account.update(&account);
}
return Ok(());

View File

@ -61,7 +61,7 @@ impl RentCollector {
address: &Pubkey,
account: &mut AccountSharedData,
) -> u64 {
if account.executable
if account.executable()
|| account.rent_epoch > self.epoch
|| sysvar::check_id(account.owner())
|| *address == incinerator::id()