* Drop write lock on sysvars
* adds env var for demoting sysvar write lock demotion
* moves demote logic to is_writable
* feature gates sysvar write lock demotion
* adds builtins to write lock demotion
* adds system program id to builtins
* adds Feature111...
* adds an abi-freeze test
* mvines set of builtin program keys
Co-authored-by: Michael Vines <mvines@gmail.com>
* update tests
* adds bpf loader keys
* Add test sysvar
* Plumb demote_sysvar to is_writable
* more plumbing of demote_sysvar_write_locks to is_writable
* patches test_program_bpf_instruction_introspection
* hard codes demote_sysvar_write_locks to false for serialization/encoding methods
* Revert "hard codes demote_sysvar_write_locks to false for serialization/encoding methods"
This reverts commit ae3e2d2e777437bddd753933097a210dcbc1b1fc.
* change the hardcoded ones to demote_sysvar_write_locks=true
* Use data_as_mut_slice
Co-authored-by: behzad nouri <behzadnouri@gmail.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
(cherry picked from commit 54c68ea83f
)
Co-authored-by: sakridge <sakridge@gmail.com>
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
#![feature(test)]
|
|
|
|
extern crate test;
|
|
use bincode::{deserialize, serialize};
|
|
use solana_sdk::instruction::{AccountMeta, Instruction};
|
|
use solana_sdk::message::Message;
|
|
use solana_sdk::pubkey;
|
|
use solana_sdk::sysvar::instructions;
|
|
use test::Bencher;
|
|
|
|
fn make_instructions() -> Vec<Instruction> {
|
|
let meta = AccountMeta::new(pubkey::new_rand(), false);
|
|
let inst = Instruction::new_with_bincode(pubkey::new_rand(), &[0; 10], vec![meta; 4]);
|
|
vec![inst; 4]
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_bincode_instruction_serialize(b: &mut Bencher) {
|
|
let instructions = make_instructions();
|
|
b.iter(|| {
|
|
test::black_box(serialize(&instructions).unwrap());
|
|
});
|
|
}
|
|
|
|
#[bench]
|
|
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
|
|
));
|
|
});
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_bincode_instruction_deserialize(b: &mut Bencher) {
|
|
let instructions = make_instructions();
|
|
let serialized = serialize(&instructions).unwrap();
|
|
b.iter(|| {
|
|
test::black_box(deserialize::<Vec<Instruction>>(&serialized).unwrap());
|
|
});
|
|
}
|
|
|
|
#[bench]
|
|
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
|
|
);
|
|
b.iter(|| {
|
|
for i in 0..instructions.len() {
|
|
test::black_box(instructions::load_instruction_at(i, &serialized).unwrap());
|
|
}
|
|
});
|
|
}
|
|
|
|
#[bench]
|
|
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
|
|
);
|
|
b.iter(|| {
|
|
test::black_box(instructions::load_instruction_at(3, &serialized).unwrap());
|
|
});
|
|
}
|