Demote write locks on transaction program ids (#19593)
* Add feature * Demote write lock on program ids * Fixup bpf tests * Update MappedMessage::is_writable * Comma nit * Review comments
This commit is contained in:
@ -10,7 +10,8 @@ use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
compute_budget::ComputeBudget,
|
||||
feature_set::{
|
||||
neon_evm_compute_budget, tx_wide_compute_cap, updated_verify_policy, FeatureSet,
|
||||
demote_program_write_locks, neon_evm_compute_budget, tx_wide_compute_cap,
|
||||
updated_verify_policy, FeatureSet,
|
||||
},
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::Hash,
|
||||
@ -94,6 +95,7 @@ impl<'a> ThisInvokeContext<'a> {
|
||||
instruction,
|
||||
executable_accounts,
|
||||
accounts,
|
||||
feature_set.is_active(&demote_program_write_locks::id()),
|
||||
);
|
||||
let compute_meter = if feature_set.is_active(&tx_wide_compute_cap::id()) {
|
||||
compute_meter
|
||||
@ -389,6 +391,7 @@ impl MessageProcessor {
|
||||
}
|
||||
|
||||
/// Verify the results of an instruction
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn verify(
|
||||
message: &Message,
|
||||
instruction: &CompiledInstruction,
|
||||
@ -399,6 +402,7 @@ impl MessageProcessor {
|
||||
timings: &mut ExecuteDetailsTimings,
|
||||
logger: Rc<RefCell<dyn Logger>>,
|
||||
updated_verify_policy: bool,
|
||||
demote_program_write_locks: bool,
|
||||
) -> Result<(), InstructionError> {
|
||||
// Verify all executable accounts have zero outstanding refs
|
||||
Self::verify_account_references(executable_accounts)?;
|
||||
@ -419,7 +423,7 @@ impl MessageProcessor {
|
||||
pre_accounts[unique_index]
|
||||
.verify(
|
||||
program_id,
|
||||
message.is_writable(account_index),
|
||||
message.is_writable(account_index, demote_program_write_locks),
|
||||
rent,
|
||||
&account,
|
||||
timings,
|
||||
@ -534,6 +538,7 @@ impl MessageProcessor {
|
||||
timings,
|
||||
invoke_context.get_logger(),
|
||||
invoke_context.is_feature_active(&updated_verify_policy::id()),
|
||||
invoke_context.is_feature_active(&demote_program_write_locks::id()),
|
||||
)?;
|
||||
|
||||
timings.accumulate(&invoke_context.timings);
|
||||
@ -713,7 +718,7 @@ mod tests {
|
||||
))),
|
||||
));
|
||||
let write_privileges: Vec<bool> = (0..message.account_keys.len())
|
||||
.map(|i| message.is_writable(i))
|
||||
.map(|i| message.is_writable(i, /*demote_program_write_locks=*/ true))
|
||||
.collect();
|
||||
invoke_context
|
||||
.verify_and_update(&message.instructions[0], &these_accounts, &write_privileges)
|
||||
@ -1193,6 +1198,8 @@ mod tests {
|
||||
metas.clone(),
|
||||
);
|
||||
let message = Message::new(&[instruction], None);
|
||||
let feature_set = FeatureSet::all_enabled();
|
||||
let demote_program_write_locks = feature_set.is_active(&demote_program_write_locks::id());
|
||||
|
||||
let ancestors = Ancestors::default();
|
||||
let blockhash = Hash::default();
|
||||
@ -1210,7 +1217,7 @@ mod tests {
|
||||
Rc::new(RefCell::new(MockComputeMeter::default())),
|
||||
Rc::new(RefCell::new(Executors::default())),
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
Arc::new(feature_set),
|
||||
Arc::new(Accounts::default_for_tests()),
|
||||
&ancestors,
|
||||
&blockhash,
|
||||
@ -1222,7 +1229,7 @@ mod tests {
|
||||
.account_keys
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, _)| message.is_writable(i))
|
||||
.map(|(i, _)| message.is_writable(i, demote_program_write_locks))
|
||||
.collect::<Vec<bool>>();
|
||||
accounts[0].1.borrow_mut().data_as_mut_slice()[0] = 1;
|
||||
assert_eq!(
|
||||
@ -1282,7 +1289,7 @@ mod tests {
|
||||
.account_keys
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, _)| message.is_writable(i))
|
||||
.map(|(i, _)| message.is_writable(i, demote_program_write_locks))
|
||||
.collect::<Vec<bool>>();
|
||||
assert_eq!(
|
||||
InstructionProcessor::process_cross_program_instruction(
|
||||
|
Reference in New Issue
Block a user