Remove feature switch for demoting sysvar write locks (#18373)
This commit is contained in:
@ -27,9 +27,7 @@ fn bench_manual_instruction_serialize(b: &mut Bencher) {
|
||||
let instructions = make_instructions();
|
||||
let message = Message::new(&instructions, None);
|
||||
b.iter(|| {
|
||||
test::black_box(message.serialize_instructions(
|
||||
true, // demote_sysvar_write_locks
|
||||
));
|
||||
test::black_box(message.serialize_instructions());
|
||||
});
|
||||
}
|
||||
|
||||
@ -46,9 +44,7 @@ fn bench_bincode_instruction_deserialize(b: &mut Bencher) {
|
||||
fn bench_manual_instruction_deserialize(b: &mut Bencher) {
|
||||
let instructions = make_instructions();
|
||||
let message = Message::new(&instructions, None);
|
||||
let serialized = message.serialize_instructions(
|
||||
true, // demote_sysvar_write_locks
|
||||
);
|
||||
let serialized = message.serialize_instructions();
|
||||
b.iter(|| {
|
||||
for i in 0..instructions.len() {
|
||||
test::black_box(instructions::load_instruction_at(i, &serialized).unwrap());
|
||||
@ -60,9 +56,7 @@ fn bench_manual_instruction_deserialize(b: &mut Bencher) {
|
||||
fn bench_manual_instruction_deserialize_single(b: &mut Bencher) {
|
||||
let instructions = make_instructions();
|
||||
let message = Message::new(&instructions, None);
|
||||
let serialized = message.serialize_instructions(
|
||||
true, // demote_sysvar_write_locks
|
||||
);
|
||||
let serialized = message.serialize_instructions();
|
||||
b.iter(|| {
|
||||
test::black_box(instructions::load_instruction_at(3, &serialized).unwrap());
|
||||
});
|
||||
|
@ -391,7 +391,7 @@ impl Message {
|
||||
self.program_position(i).is_some()
|
||||
}
|
||||
|
||||
pub fn is_writable(&self, i: usize, demote_sysvar_write_locks: bool) -> bool {
|
||||
pub fn is_writable(&self, i: usize) -> bool {
|
||||
(i < (self.header.num_required_signatures - self.header.num_readonly_signed_accounts)
|
||||
as usize
|
||||
|| (i >= self.header.num_required_signatures as usize
|
||||
@ -399,8 +399,7 @@ impl Message {
|
||||
- self.header.num_readonly_unsigned_accounts as usize))
|
||||
&& !{
|
||||
let key = self.account_keys[i];
|
||||
demote_sysvar_write_locks
|
||||
&& (sysvar::is_sysvar_id(&key) || BUILTIN_PROGRAMS_KEYS.contains(&key))
|
||||
sysvar::is_sysvar_id(&key) || BUILTIN_PROGRAMS_KEYS.contains(&key)
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,14 +407,11 @@ impl Message {
|
||||
i < self.header.num_required_signatures as usize
|
||||
}
|
||||
|
||||
pub fn get_account_keys_by_lock_type(
|
||||
&self,
|
||||
demote_sysvar_write_locks: bool,
|
||||
) -> (Vec<&Pubkey>, Vec<&Pubkey>) {
|
||||
pub fn get_account_keys_by_lock_type(&self) -> (Vec<&Pubkey>, Vec<&Pubkey>) {
|
||||
let mut writable_keys = vec![];
|
||||
let mut readonly_keys = vec![];
|
||||
for (i, key) in self.account_keys.iter().enumerate() {
|
||||
if self.is_writable(i, demote_sysvar_write_locks) {
|
||||
if self.is_writable(i) {
|
||||
writable_keys.push(key);
|
||||
} else {
|
||||
readonly_keys.push(key);
|
||||
@ -437,7 +433,7 @@ impl Message {
|
||||
// 35..67 - program_id
|
||||
// 67..69 - data len - u16
|
||||
// 69..data_len - data
|
||||
pub fn serialize_instructions(&self, demote_sysvar_write_locks: bool) -> Vec<u8> {
|
||||
pub fn serialize_instructions(&self) -> Vec<u8> {
|
||||
// 64 bytes is a reasonable guess, calculating exactly is slower in benchmarks
|
||||
let mut data = Vec::with_capacity(self.instructions.len() * (32 * 2));
|
||||
append_u16(&mut data, self.instructions.len() as u16);
|
||||
@ -452,7 +448,7 @@ impl Message {
|
||||
for account_index in &instruction.accounts {
|
||||
let account_index = *account_index as usize;
|
||||
let is_signer = self.is_signer(account_index);
|
||||
let is_writable = self.is_writable(account_index, demote_sysvar_write_locks);
|
||||
let is_writable = self.is_writable(account_index);
|
||||
let mut meta_byte = 0;
|
||||
if is_signer {
|
||||
meta_byte |= 1 << Self::IS_SIGNER_BIT;
|
||||
@ -891,13 +887,12 @@ mod tests {
|
||||
recent_blockhash: Hash::default(),
|
||||
instructions: vec![],
|
||||
};
|
||||
let demote_sysvar_write_locks = true;
|
||||
assert!(message.is_writable(0, demote_sysvar_write_locks));
|
||||
assert!(!message.is_writable(1, demote_sysvar_write_locks));
|
||||
assert!(!message.is_writable(2, demote_sysvar_write_locks));
|
||||
assert!(message.is_writable(3, demote_sysvar_write_locks));
|
||||
assert!(message.is_writable(4, demote_sysvar_write_locks));
|
||||
assert!(!message.is_writable(5, demote_sysvar_write_locks));
|
||||
assert!(message.is_writable(0));
|
||||
assert!(!message.is_writable(1));
|
||||
assert!(!message.is_writable(2));
|
||||
assert!(message.is_writable(3));
|
||||
assert!(message.is_writable(4));
|
||||
assert!(!message.is_writable(5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -925,9 +920,7 @@ mod tests {
|
||||
Some(&id1),
|
||||
);
|
||||
assert_eq!(
|
||||
message.get_account_keys_by_lock_type(
|
||||
true, // demote_sysvar_write_locks
|
||||
),
|
||||
message.get_account_keys_by_lock_type(),
|
||||
(vec![&id1, &id0], vec![&id3, &id2, &program_id])
|
||||
);
|
||||
}
|
||||
@ -957,9 +950,7 @@ mod tests {
|
||||
];
|
||||
|
||||
let message = Message::new(&instructions, Some(&id1));
|
||||
let serialized = message.serialize_instructions(
|
||||
true, // demote_sysvar_write_locks
|
||||
);
|
||||
let serialized = message.serialize_instructions();
|
||||
for (i, instruction) in instructions.iter().enumerate() {
|
||||
assert_eq!(
|
||||
Message::deserialize_instruction(i, &serialized).unwrap(),
|
||||
@ -980,9 +971,7 @@ mod tests {
|
||||
];
|
||||
|
||||
let message = Message::new(&instructions, Some(&id1));
|
||||
let serialized = message.serialize_instructions(
|
||||
true, // demote_sysvar_write_locks
|
||||
);
|
||||
let serialized = message.serialize_instructions();
|
||||
assert_eq!(
|
||||
Message::deserialize_instruction(instructions.len(), &serialized).unwrap_err(),
|
||||
SanitizeError::IndexOutOfBounds,
|
||||
|
@ -103,10 +103,6 @@ pub mod upgradeable_close_instruction {
|
||||
solana_sdk::declare_id!("FsPaByos3gA9bUEhp3EimQpQPCoSvCEigHod496NmABQ");
|
||||
}
|
||||
|
||||
pub mod demote_sysvar_write_locks {
|
||||
solana_sdk::declare_id!("86LJYRuq2zgtHuL3FccR6hqFJQMQkFoun4knAxcPiF1P");
|
||||
}
|
||||
|
||||
pub mod sysvar_via_syscall {
|
||||
solana_sdk::declare_id!("7411E6gFQLDhQkdRjmpXwM1hzHMMoYQUjHicmvGPC1Nf");
|
||||
}
|
||||
@ -177,7 +173,6 @@ lazy_static! {
|
||||
(require_stake_for_gossip::id(), "require stakes for propagating crds values through gossip #15561"),
|
||||
(cpi_data_cost::id(), "charge the compute budget for data passed via CPI"),
|
||||
(upgradeable_close_instruction::id(), "close upgradeable buffer accounts"),
|
||||
(demote_sysvar_write_locks::id(), "demote builtins and sysvar write locks to readonly #15497"),
|
||||
(sysvar_via_syscall::id(), "provide sysvars via syscalls"),
|
||||
(enforce_aligned_host_addrs::id(), "enforce aligned host addresses"),
|
||||
(update_data_on_realloc::id(), "Retain updated data values modified after realloc via CPI"),
|
||||
|
Reference in New Issue
Block a user