featurize_policy_update (#18492)
This commit is contained in:
parent
1f288ce527
commit
ccdf93e2b8
|
@ -26,6 +26,7 @@ fn bench_verify_account_changes_data(bencher: &mut Bencher) {
|
||||||
&post,
|
&post,
|
||||||
&mut ExecuteDetailsTimings::default(),
|
&mut ExecuteDetailsTimings::default(),
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
),
|
),
|
||||||
Ok(())
|
Ok(())
|
||||||
);
|
);
|
||||||
|
@ -39,6 +40,7 @@ fn bench_verify_account_changes_data(bencher: &mut Bencher) {
|
||||||
&post,
|
&post,
|
||||||
&mut ExecuteDetailsTimings::default(),
|
&mut ExecuteDetailsTimings::default(),
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
@ -63,6 +65,7 @@ fn bench_verify_account_changes_data(bencher: &mut Bencher) {
|
||||||
&post,
|
&post,
|
||||||
&mut ExecuteDetailsTimings::default(),
|
&mut ExecuteDetailsTimings::default(),
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ use solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||||
feature_set::{instructions_sysvar_enabled, FeatureSet},
|
feature_set::{instructions_sysvar_enabled, updated_verify_policy, FeatureSet},
|
||||||
ic_logger_msg, ic_msg,
|
ic_logger_msg, ic_msg,
|
||||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||||
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
||||||
|
@ -110,6 +110,7 @@ impl PreAccount {
|
||||||
post: &AccountSharedData,
|
post: &AccountSharedData,
|
||||||
timings: &mut ExecuteDetailsTimings,
|
timings: &mut ExecuteDetailsTimings,
|
||||||
outermost_call: bool,
|
outermost_call: bool,
|
||||||
|
updated_verify_policy: bool,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
let pre = self.account.borrow();
|
let pre = self.account.borrow();
|
||||||
|
|
||||||
|
@ -178,9 +179,14 @@ impl PreAccount {
|
||||||
if !rent.is_exempt(post.lamports(), post.data().len()) {
|
if !rent.is_exempt(post.lamports(), post.data().len()) {
|
||||||
return Err(InstructionError::ExecutableAccountNotRentExempt);
|
return Err(InstructionError::ExecutableAccountNotRentExempt);
|
||||||
}
|
}
|
||||||
|
let owner = if updated_verify_policy {
|
||||||
|
post.owner()
|
||||||
|
} else {
|
||||||
|
pre.owner()
|
||||||
|
};
|
||||||
if !is_writable // line coverage used to get branch coverage
|
if !is_writable // line coverage used to get branch coverage
|
||||||
|| pre.executable()
|
|| pre.executable()
|
||||||
|| program_id != post.owner()
|
|| program_id != owner
|
||||||
{
|
{
|
||||||
return Err(InstructionError::ExecutableModified);
|
return Err(InstructionError::ExecutableModified);
|
||||||
}
|
}
|
||||||
|
@ -408,6 +414,7 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
||||||
write_privileges,
|
write_privileges,
|
||||||
&mut self.timings,
|
&mut self.timings,
|
||||||
logger,
|
logger,
|
||||||
|
self.feature_set.is_active(&updated_verify_policy::id()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
|
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
|
||||||
|
@ -991,6 +998,7 @@ impl MessageProcessor {
|
||||||
rent: &Rent,
|
rent: &Rent,
|
||||||
timings: &mut ExecuteDetailsTimings,
|
timings: &mut ExecuteDetailsTimings,
|
||||||
logger: Rc<RefCell<dyn Logger>>,
|
logger: Rc<RefCell<dyn Logger>>,
|
||||||
|
updated_verify_policy: bool,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
// Verify all executable accounts have zero outstanding refs
|
// Verify all executable accounts have zero outstanding refs
|
||||||
Self::verify_account_references(executable_accounts)?;
|
Self::verify_account_references(executable_accounts)?;
|
||||||
|
@ -1016,6 +1024,7 @@ impl MessageProcessor {
|
||||||
&account,
|
&account,
|
||||||
timings,
|
timings,
|
||||||
true,
|
true,
|
||||||
|
updated_verify_policy,
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
ic_logger_msg!(
|
ic_logger_msg!(
|
||||||
|
@ -1051,6 +1060,7 @@ impl MessageProcessor {
|
||||||
write_privileges: &[bool],
|
write_privileges: &[bool],
|
||||||
timings: &mut ExecuteDetailsTimings,
|
timings: &mut ExecuteDetailsTimings,
|
||||||
logger: Rc<RefCell<dyn Logger>>,
|
logger: Rc<RefCell<dyn Logger>>,
|
||||||
|
updated_verify_policy: bool,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
// Verify the per-account instruction results
|
// Verify the per-account instruction results
|
||||||
let (mut pre_sum, mut post_sum) = (0_u128, 0_u128);
|
let (mut pre_sum, mut post_sum) = (0_u128, 0_u128);
|
||||||
|
@ -1069,7 +1079,15 @@ impl MessageProcessor {
|
||||||
}
|
}
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
pre_account
|
pre_account
|
||||||
.verify(program_id, is_writable, rent, &account, timings, false)
|
.verify(
|
||||||
|
program_id,
|
||||||
|
is_writable,
|
||||||
|
rent,
|
||||||
|
&account,
|
||||||
|
timings,
|
||||||
|
false,
|
||||||
|
updated_verify_policy,
|
||||||
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
ic_logger_msg!(logger, "failed to verify account {}: {}", key, err);
|
ic_logger_msg!(logger, "failed to verify account {}: {}", key, err);
|
||||||
err
|
err
|
||||||
|
@ -1159,6 +1177,7 @@ impl MessageProcessor {
|
||||||
&rent_collector.rent,
|
&rent_collector.rent,
|
||||||
timings,
|
timings,
|
||||||
invoke_context.get_logger(),
|
invoke_context.get_logger(),
|
||||||
|
invoke_context.is_feature_active(&updated_verify_policy::id()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
timings.accumulate(&invoke_context.timings);
|
timings.accumulate(&invoke_context.timings);
|
||||||
|
@ -1465,6 +1484,7 @@ mod tests {
|
||||||
&self.post,
|
&self.post,
|
||||||
&mut ExecuteDetailsTimings::default(),
|
&mut ExecuteDetailsTimings::default(),
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,10 @@ pub mod vote_stake_checked_instructions {
|
||||||
solana_sdk::declare_id!("BcWknVcgvonN8sL4HE4XFuEVgfcee5MwxWPAgP6ZV89X");
|
solana_sdk::declare_id!("BcWknVcgvonN8sL4HE4XFuEVgfcee5MwxWPAgP6ZV89X");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod updated_verify_policy {
|
||||||
|
solana_sdk::declare_id!("k15tVxtkgsmo7dy6iJ56N5hBCxuQAtqRgYwoTDuwbia");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
|
@ -198,6 +202,7 @@ lazy_static! {
|
||||||
(dedupe_config_program_signers::id(), "dedupe config program signers"),
|
(dedupe_config_program_signers::id(), "dedupe config program signers"),
|
||||||
(deterministic_shred_seed_enabled::id(), "deterministic shred seed"),
|
(deterministic_shred_seed_enabled::id(), "deterministic shred seed"),
|
||||||
(vote_stake_checked_instructions::id(), "vote/state program checked instructions #18345"),
|
(vote_stake_checked_instructions::id(), "vote/state program checked instructions #18345"),
|
||||||
|
(updated_verify_policy::id(), "Update verify policy"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in New Issue