Bumps solana_rbpf to v0.2.16 (#21492)

This commit is contained in:
Alexander Meißner
2021-12-13 22:10:03 +01:00
committed by Michael Vines
parent b00087e1ca
commit 558a52d5cb
10 changed files with 40 additions and 47 deletions

View File

@@ -22,7 +22,7 @@ sha3 = "0.9.1"
solana-measure = { path = "../../measure", version = "=1.8.11" }
solana-runtime = { path = "../../runtime", version = "=1.8.11" }
solana-sdk = { path = "../../sdk", version = "=1.8.11" }
solana_rbpf = "=0.2.15"
solana_rbpf = "=0.2.16"
thiserror = "1.0"
[dev-dependencies]

View File

@@ -17,10 +17,11 @@ use solana_measure::measure::Measure;
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},
};
use solana_runtime::message_processor::MessageProcessor;
use solana_sdk::{
@@ -98,12 +99,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;
@@ -151,7 +147,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>> {
@@ -873,7 +869,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...
@@ -910,7 +906,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,
) {
@@ -941,7 +937,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);
@@ -1052,8 +1048,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(),
@@ -1062,8 +1059,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();