Bump solana_rbpf to version 0.2.13 (#18068)
* Moves syscall_registry into the rbpf Executable constructor. * Adds the reject_unresolved_syscalls flag which is only set when deploying programs via the CLI.
This commit is contained in:
committed by
GitHub
parent
04787be8b1
commit
8d5c04e257
@ -23,7 +23,7 @@ sha3 = "0.9.1"
|
||||
solana-measure = { path = "../../measure", version = "=1.8.0" }
|
||||
solana-runtime = { path = "../../runtime", version = "=1.8.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.8.0" }
|
||||
solana_rbpf = "=0.2.12"
|
||||
solana_rbpf = "=0.2.13"
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -82,15 +82,20 @@ pub fn create_executor(
|
||||
let config = Config {
|
||||
max_call_depth: bpf_compute_budget.max_call_depth,
|
||||
stack_frame_size: bpf_compute_budget.stack_frame_size,
|
||||
enable_instruction_meter: true,
|
||||
enable_instruction_tracing: log_enabled!(Trace),
|
||||
..Config::default()
|
||||
};
|
||||
let mut executable = {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
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)
|
||||
<dyn Executable<BpfError, ThisInstructionMeter>>::from_elf(
|
||||
data,
|
||||
None,
|
||||
config,
|
||||
syscall_registry,
|
||||
)
|
||||
}
|
||||
.map_err(|e| map_ebpf_error(invoke_context, e))?;
|
||||
let (_, elf_bytes) = executable
|
||||
@ -98,7 +103,6 @@ pub fn create_executor(
|
||||
.map_err(|e| map_ebpf_error(invoke_context, e))?;
|
||||
verifier::check(elf_bytes)
|
||||
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e.into())))?;
|
||||
executable.set_syscall_registry(syscall_registry);
|
||||
if use_jit {
|
||||
if let Err(err) = executable.jit_compile() {
|
||||
ic_msg!(invoke_context, "Failed to compile program {:?}", err);
|
||||
@ -853,6 +857,7 @@ impl Executor for BpfExecutor {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rand::Rng;
|
||||
use solana_rbpf::vm::SyscallRegistry;
|
||||
use solana_runtime::{bank::Bank, bank_client::BankClient};
|
||||
use solana_sdk::{
|
||||
account::{
|
||||
@ -905,9 +910,10 @@ mod tests {
|
||||
solana_rbpf::elf::register_bpf_function(&mut bpf_functions, 0, "entrypoint").unwrap();
|
||||
let program = <dyn Executable<BpfError, TestInstructionMeter>>::from_text_bytes(
|
||||
program,
|
||||
bpf_functions,
|
||||
None,
|
||||
Config::default(),
|
||||
SyscallRegistry::default(),
|
||||
bpf_functions,
|
||||
)
|
||||
.unwrap();
|
||||
let mut vm =
|
||||
|
@ -2375,13 +2375,6 @@ mod tests {
|
||||
};
|
||||
use std::str::FromStr;
|
||||
|
||||
const DEFAULT_CONFIG: Config = Config {
|
||||
max_call_depth: 20,
|
||||
stack_frame_size: 4_096,
|
||||
enable_instruction_meter: true,
|
||||
enable_instruction_tracing: false,
|
||||
};
|
||||
|
||||
macro_rules! assert_access_violation {
|
||||
($result:expr, $va:expr, $len:expr) => {
|
||||
match $result {
|
||||
@ -2397,9 +2390,10 @@ mod tests {
|
||||
const LENGTH: u64 = 1000;
|
||||
let data = vec![0u8; LENGTH as usize];
|
||||
let addr = data.as_ptr() as u64;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion::new_from_slice(&data, START, 0, false)],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2436,6 +2430,7 @@ mod tests {
|
||||
// Pubkey
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let addr = &pubkey as *const _ as u64;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2444,7 +2439,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_pubkey =
|
||||
@ -2466,7 +2461,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_instruction =
|
||||
@ -2485,6 +2480,7 @@ mod tests {
|
||||
let data: Vec<u8> = vec![];
|
||||
assert_eq!(0x1 as *const u8, data.as_ptr());
|
||||
let addr = good_data.as_ptr() as *const _ as u64;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2493,7 +2489,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_data = translate_slice::<u8>(
|
||||
@ -2518,7 +2514,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_data = translate_slice::<u8>(
|
||||
@ -2561,7 +2557,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_data = translate_slice::<u64>(
|
||||
@ -2591,7 +2587,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let translated_data = translate_slice::<Pubkey>(
|
||||
@ -2611,6 +2607,7 @@ mod tests {
|
||||
fn test_translate_string_and_do() {
|
||||
let string = "Gaggablaghblagh!";
|
||||
let addr = string.as_ptr() as *const _ as u64;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2619,7 +2616,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
@ -2642,9 +2639,9 @@ mod tests {
|
||||
#[test]
|
||||
#[should_panic(expected = "UserError(SyscallError(Abort))")]
|
||||
fn test_syscall_abort() {
|
||||
let config = Config::default();
|
||||
let memory_mapping =
|
||||
MemoryMapping::new::<UserError>(vec![MemoryRegion::default()], &DEFAULT_CONFIG)
|
||||
.unwrap();
|
||||
MemoryMapping::new::<UserError>(vec![MemoryRegion::default()], &config).unwrap();
|
||||
let mut result: Result<u64, EbpfError<BpfError>> = Ok(0);
|
||||
SyscallAbort::call(
|
||||
&mut SyscallAbort {},
|
||||
@ -2664,6 +2661,7 @@ mod tests {
|
||||
fn test_syscall_sol_panic() {
|
||||
let string = "Gaggablaghblagh!";
|
||||
let addr = string.as_ptr() as *const _ as u64;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2672,7 +2670,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2740,6 +2738,7 @@ mod tests {
|
||||
loader_id: &bpf_loader::id(),
|
||||
enforce_aligned_host_addrs: true,
|
||||
};
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2748,7 +2747,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2853,7 +2852,8 @@ mod tests {
|
||||
compute_meter,
|
||||
logger,
|
||||
};
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(vec![], &DEFAULT_CONFIG).unwrap();
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(vec![], &config).unwrap();
|
||||
|
||||
let mut result: Result<u64, EbpfError<BpfError>> = Ok(0);
|
||||
syscall_sol_log_u64.call(1, 2, 3, 4, 5, &memory_mapping, &mut result);
|
||||
@ -2880,6 +2880,7 @@ mod tests {
|
||||
loader_id: &bpf_loader::id(),
|
||||
enforce_aligned_host_addrs: true,
|
||||
};
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion {
|
||||
host_addr: addr,
|
||||
@ -2888,7 +2889,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: false,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2923,6 +2924,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_syscall_sol_alloc_free() {
|
||||
let config = Config::default();
|
||||
// large alloc
|
||||
{
|
||||
let heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
|
||||
@ -2933,7 +2935,7 @@ mod tests {
|
||||
0,
|
||||
true,
|
||||
)],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let mut syscall = SyscallAllocFree {
|
||||
@ -2960,7 +2962,7 @@ mod tests {
|
||||
0,
|
||||
true,
|
||||
)],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let mut syscall = SyscallAllocFree {
|
||||
@ -2986,7 +2988,7 @@ mod tests {
|
||||
0,
|
||||
true,
|
||||
)],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let mut syscall = SyscallAllocFree {
|
||||
@ -3006,6 +3008,7 @@ mod tests {
|
||||
|
||||
fn check_alignment<T>() {
|
||||
let heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![MemoryRegion::new_from_slice(
|
||||
heap.as_slice(),
|
||||
@ -3013,7 +3016,7 @@ mod tests {
|
||||
0,
|
||||
true,
|
||||
)],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let mut syscall = SyscallAllocFree {
|
||||
@ -3064,6 +3067,7 @@ mod tests {
|
||||
let ro_len = bytes_to_hash.len() as u64;
|
||||
let ro_va = 96;
|
||||
let rw_va = 192;
|
||||
let config = Config::default();
|
||||
let memory_mapping = MemoryMapping::new::<UserError>(
|
||||
vec![
|
||||
MemoryRegion {
|
||||
@ -3095,7 +3099,7 @@ mod tests {
|
||||
is_writable: true,
|
||||
},
|
||||
],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
let compute_meter: Rc<RefCell<dyn ComputeMeter>> =
|
||||
@ -3161,6 +3165,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_syscall_get_sysvar() {
|
||||
let config = Config::default();
|
||||
// Test clock sysvar
|
||||
{
|
||||
let got_clock = Clock::default();
|
||||
@ -3174,7 +3179,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: true,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -3216,7 +3221,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: true,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -3266,7 +3271,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: true,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -3306,7 +3311,7 @@ mod tests {
|
||||
vm_gap_shift: 63,
|
||||
is_writable: true,
|
||||
}],
|
||||
&DEFAULT_CONFIG,
|
||||
&config,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user