Bumps solana_rbpf to v0.2.16 (#21492)

This commit is contained in:
Alexander Meißner
2021-12-03 23:44:31 +01:00
committed by Trent Nelson
parent e52b3fd1d8
commit f04e06e0c2
10 changed files with 40 additions and 47 deletions

View File

@@ -18,10 +18,11 @@ use {
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::HOST_ALIGN,
elf::Executable,
error::{EbpfError, UserDefinedError},
static_analysis::Analysis,
verifier::{self, VerifierError},
vm::{Config, EbpfVm, Executable, InstructionMeter},
vm::{Config, EbpfVm, InstructionMeter},
},
solana_runtime::message_processor::MessageProcessor,
solana_sdk::{
@@ -101,12 +102,7 @@ pub fn create_executor(
let program = keyed_account_at_index(keyed_accounts, program_account_index)?;
let account = program.try_account_ref()?;
let data = &account.data()[program_data_offset..];
<dyn Executable<BpfError, ThisInstructionMeter>>::from_elf(
data,
None,
config,
syscall_registry,
)
Executable::<BpfError, ThisInstructionMeter>::from_elf(data, None, config, syscall_registry)
}
.map_err(|e| map_ebpf_error(invoke_context, e))?;
let text_bytes = executable.get_text_bytes().1;
@@ -154,7 +150,7 @@ fn check_loader_id(id: &Pubkey) -> bool {
/// Create the BPF virtual machine
pub fn create_vm<'a>(
loader_id: &'a Pubkey,
program: &'a dyn Executable<BpfError, ThisInstructionMeter>,
program: &'a Executable<BpfError, ThisInstructionMeter>,
parameter_bytes: &mut [u8],
invoke_context: &'a mut dyn InvokeContext,
) -> Result<EbpfVm<'a, BpfError, ThisInstructionMeter>, EbpfError<BpfError>> {
@@ -876,7 +872,7 @@ impl InstructionMeter for ThisInstructionMeter {
/// BPF Loader's Executor implementation
pub struct BpfExecutor {
executable: Box<dyn Executable<BpfError, ThisInstructionMeter>>,
executable: Executable<BpfError, ThisInstructionMeter>,
}
// Well, implement Debug for solana_rbpf::vm::Executable in solana-rbpf...
@@ -913,7 +909,7 @@ impl Executor for BpfExecutor {
let compute_meter = invoke_context.get_compute_meter();
let mut vm = match create_vm(
loader_id,
self.executable.as_ref(),
&self.executable,
parameter_bytes.as_slice_mut(),
invoke_context,
) {
@@ -944,7 +940,7 @@ impl Executor for BpfExecutor {
);
if log_enabled!(Trace) {
let mut trace_buffer = Vec::<u8>::new();
let analysis = Analysis::from_executable(self.executable.as_ref());
let analysis = Analysis::from_executable(&self.executable);
vm.get_tracer().write(&mut trace_buffer, &analysis).unwrap();
let trace_string = String::from_utf8(trace_buffer).unwrap();
trace!("BPF Program Instruction Trace:\n{}", trace_string);
@@ -1056,8 +1052,9 @@ mod tests {
];
let input = &mut [0x00];
let mut bpf_functions = std::collections::BTreeMap::<u32, (usize, String)>::new();
solana_rbpf::elf::register_bpf_function(&mut bpf_functions, 0, "entrypoint").unwrap();
let program = <dyn Executable<BpfError, TestInstructionMeter>>::from_text_bytes(
solana_rbpf::elf::register_bpf_function(&mut bpf_functions, 0, "entrypoint", false)
.unwrap();
let program = Executable::<BpfError, TestInstructionMeter>::from_text_bytes(
program,
None,
Config::default(),
@@ -1066,8 +1063,7 @@ mod tests {
)
.unwrap();
let mut vm =
EbpfVm::<BpfError, TestInstructionMeter>::new(program.as_ref(), &mut [], input)
.unwrap();
EbpfVm::<BpfError, TestInstructionMeter>::new(&program, &mut [], input).unwrap();
let mut instruction_meter = TestInstructionMeter { remaining: 10 };
vm.execute_program_interpreted(&mut instruction_meter)
.unwrap();