Revert "Bumps solana_rbpf to v0.2.16 (#21492)"
This reverts commit f04e06e0c2
.
This commit is contained in:
@@ -18,11 +18,10 @@ use {
|
||||
solana_rbpf::{
|
||||
aligned_memory::AlignedMemory,
|
||||
ebpf::HOST_ALIGN,
|
||||
elf::Executable,
|
||||
error::{EbpfError, UserDefinedError},
|
||||
static_analysis::Analysis,
|
||||
verifier::{self, VerifierError},
|
||||
vm::{Config, EbpfVm, InstructionMeter},
|
||||
vm::{Config, EbpfVm, Executable, InstructionMeter},
|
||||
},
|
||||
solana_runtime::message_processor::MessageProcessor,
|
||||
solana_sdk::{
|
||||
@@ -102,7 +101,12 @@ 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..];
|
||||
Executable::<BpfError, ThisInstructionMeter>::from_elf(data, None, config, syscall_registry)
|
||||
<dyn 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;
|
||||
@@ -150,7 +154,7 @@ fn check_loader_id(id: &Pubkey) -> bool {
|
||||
/// Create the BPF virtual machine
|
||||
pub fn create_vm<'a>(
|
||||
loader_id: &'a Pubkey,
|
||||
program: &'a Executable<BpfError, ThisInstructionMeter>,
|
||||
program: &'a dyn Executable<BpfError, ThisInstructionMeter>,
|
||||
parameter_bytes: &mut [u8],
|
||||
invoke_context: &'a mut dyn InvokeContext,
|
||||
) -> Result<EbpfVm<'a, BpfError, ThisInstructionMeter>, EbpfError<BpfError>> {
|
||||
@@ -872,7 +876,7 @@ impl InstructionMeter for ThisInstructionMeter {
|
||||
|
||||
/// BPF Loader's Executor implementation
|
||||
pub struct BpfExecutor {
|
||||
executable: Executable<BpfError, ThisInstructionMeter>,
|
||||
executable: Box<dyn Executable<BpfError, ThisInstructionMeter>>,
|
||||
}
|
||||
|
||||
// Well, implement Debug for solana_rbpf::vm::Executable in solana-rbpf...
|
||||
@@ -909,7 +913,7 @@ impl Executor for BpfExecutor {
|
||||
let compute_meter = invoke_context.get_compute_meter();
|
||||
let mut vm = match create_vm(
|
||||
loader_id,
|
||||
&self.executable,
|
||||
self.executable.as_ref(),
|
||||
parameter_bytes.as_slice_mut(),
|
||||
invoke_context,
|
||||
) {
|
||||
@@ -940,7 +944,7 @@ impl Executor for BpfExecutor {
|
||||
);
|
||||
if log_enabled!(Trace) {
|
||||
let mut trace_buffer = Vec::<u8>::new();
|
||||
let analysis = Analysis::from_executable(&self.executable);
|
||||
let analysis = Analysis::from_executable(self.executable.as_ref());
|
||||
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);
|
||||
@@ -1052,9 +1056,8 @@ 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", false)
|
||||
.unwrap();
|
||||
let program = Executable::<BpfError, TestInstructionMeter>::from_text_bytes(
|
||||
solana_rbpf::elf::register_bpf_function(&mut bpf_functions, 0, "entrypoint").unwrap();
|
||||
let program = <dyn Executable<BpfError, TestInstructionMeter>>::from_text_bytes(
|
||||
program,
|
||||
None,
|
||||
Config::default(),
|
||||
@@ -1063,7 +1066,8 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let mut vm =
|
||||
EbpfVm::<BpfError, TestInstructionMeter>::new(&program, &mut [], input).unwrap();
|
||||
EbpfVm::<BpfError, TestInstructionMeter>::new(program.as_ref(), &mut [], input)
|
||||
.unwrap();
|
||||
let mut instruction_meter = TestInstructionMeter { remaining: 10 };
|
||||
vm.execute_program_interpreted(&mut instruction_meter)
|
||||
.unwrap();
|
||||
|
Reference in New Issue
Block a user