Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Bumps solana_rbpf to v0.2.32 (#27059)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso authored Aug 15, 2022
1 parent b28657f commit f76f8d5
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ solana-sdk = { path = "../sdk", version = "=1.12.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" }
solana-version = { path = "../version", version = "=1.12.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.12.0" }
solana_rbpf = "=0.2.31"
solana_rbpf = "=0.2.32"
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
thiserror = "1.0.31"
tiny-bip39 = "0.8.2"
Expand Down
4 changes: 2 additions & 2 deletions programs/bpf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion programs/bpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ solana-program-runtime = { path = "../../program-runtime", version = "=1.12.0" }
solana-runtime = { path = "../../runtime", version = "=1.12.0" }
solana-sdk = { path = "../../sdk", version = "=1.12.0" }
solana-transaction-status = { path = "../../transaction-status", version = "=1.12.0" }
solana_rbpf = "=0.2.31"
solana_rbpf = "=0.2.32"

[dev-dependencies]
solana-ledger = { path = "../../ledger", version = "=1.12.0" }
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ solana-metrics = { path = "../../metrics", version = "=1.12.0" }
solana-program-runtime = { path = "../../program-runtime", version = "=1.12.0" }
solana-sdk = { path = "../../sdk", version = "=1.12.0" }
solana-zk-token-sdk = { path = "../../zk-token-sdk", version = "=1.12.0" }
solana_rbpf = "=0.2.31"
solana_rbpf = "=0.2.32"
thiserror = "1.0"

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions programs/bpf_loader/src/allocator_bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

use {
solana_program_runtime::invoke_context::{Alloc, AllocErr},
solana_rbpf::aligned_memory::AlignedMemory,
solana_rbpf::{aligned_memory::AlignedMemory, ebpf::HOST_ALIGN},
std::alloc::Layout,
};

#[derive(Debug)]
pub struct BpfAllocator {
#[allow(dead_code)]
heap: AlignedMemory,
heap: AlignedMemory<HOST_ALIGN>,
start: u64,
len: u64,
pos: u64,
}

impl BpfAllocator {
pub fn new(heap: AlignedMemory, virtual_address: u64) -> Self {
pub fn new(heap: AlignedMemory<HOST_ALIGN>, virtual_address: u64) -> Self {
let len = heap.len() as u64;
Self {
heap,
Expand Down
12 changes: 3 additions & 9 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use {
entrypoint::{HEAP_LENGTH, SUCCESS},
feature_set::{
cap_accounts_data_len, cap_bpf_program_instruction_accounts,
disable_bpf_deprecated_load_instructions, disable_bpf_unresolved_symbols_at_runtime,
disable_deploy_of_alloc_free_syscall, disable_deprecated_loader,
enable_bpf_loader_extend_program_data_ix,
error_on_syscall_bpf_function_hash_collisions, reject_callx_r10,
Expand Down Expand Up @@ -167,17 +166,10 @@ pub fn create_executor(
enable_instruction_meter: true,
enable_instruction_tracing: log_enabled!(Trace),
enable_symbol_and_section_labels: false,
disable_unresolved_symbols_at_runtime: invoke_context
.feature_set
.is_active(&disable_bpf_unresolved_symbols_at_runtime::id()),
reject_broken_elfs: reject_deployment_of_broken_elfs,
noop_instruction_rate: 256,
sanitize_user_provided_values: true,
encrypt_environment_registers: true,
disable_deprecated_load_instructions: reject_deployment_of_broken_elfs
&& invoke_context
.feature_set
.is_active(&disable_bpf_deprecated_load_instructions::id()),
syscall_bpf_function_hash_collision: invoke_context
.feature_set
.is_active(&error_on_syscall_bpf_function_hash_collisions::id()),
Expand All @@ -189,6 +181,8 @@ pub fn create_executor(
optimize_rodata: false,
static_syscalls: false,
enable_elf_vaddr: false,
reject_rodata_stack_overlap: false,
new_elf_parser: false,
// Warning, do not use `Config::default()` so that configuration here is explicit.
};
let mut create_executor_metrics = executor_metrics::CreateMetrics::default();
Expand Down Expand Up @@ -303,7 +297,7 @@ pub fn create_vm<'a, 'b>(
.saturating_mul(compute_budget.heap_cost),
);
let mut heap =
AlignedMemory::new_with_size(compute_budget.heap_size.unwrap_or(HEAP_LENGTH), HOST_ALIGN);
AlignedMemory::<HOST_ALIGN>::zero_filled(compute_budget.heap_size.unwrap_or(HEAP_LENGTH));
let parameter_region = MemoryRegion::new_writable(parameter_bytes, MM_INPUT_START);
let mut vm = EbpfVm::new(program, heap.as_slice_mut(), vec![parameter_region])?;
syscalls::bind_syscall_context_objects(&mut vm, invoke_context, heap, orig_account_lengths)?;
Expand Down
12 changes: 6 additions & 6 deletions programs/bpf_loader/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn serialize_parameters(
transaction_context: &TransactionContext,
instruction_context: &InstructionContext,
should_cap_ix_accounts: bool,
) -> Result<(AlignedMemory, Vec<usize>), InstructionError> {
) -> Result<(AlignedMemory<HOST_ALIGN>, Vec<usize>), InstructionError> {
let num_ix_accounts = instruction_context.get_number_of_instruction_accounts();
if should_cap_ix_accounts && num_ix_accounts > usize::from(MAX_INSTRUCTION_ACCOUNTS) {
return Err(InstructionError::MaxAccountsExceeded);
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn deserialize_parameters(
pub fn serialize_parameters_unaligned(
transaction_context: &TransactionContext,
instruction_context: &InstructionContext,
) -> Result<AlignedMemory, InstructionError> {
) -> Result<AlignedMemory<HOST_ALIGN>, InstructionError> {
// Calculate size in order to alloc once
let mut size = size_of::<u64>();
for instruction_account_index in 0..instruction_context.get_number_of_instruction_accounts() {
Expand All @@ -106,7 +106,7 @@ pub fn serialize_parameters_unaligned(
size += size_of::<u64>() // instruction data len
+ instruction_context.get_instruction_data().len() // instruction data
+ size_of::<Pubkey>(); // program id
let mut v = AlignedMemory::new(size, HOST_ALIGN);
let mut v = AlignedMemory::<HOST_ALIGN>::with_capacity(size);

v.write_u64::<LittleEndian>(instruction_context.get_number_of_instruction_accounts() as u64)
.map_err(|_| InstructionError::InvalidArgument)?;
Expand Down Expand Up @@ -208,7 +208,7 @@ pub fn deserialize_parameters_unaligned(
pub fn serialize_parameters_aligned(
transaction_context: &TransactionContext,
instruction_context: &InstructionContext,
) -> Result<AlignedMemory, InstructionError> {
) -> Result<AlignedMemory<HOST_ALIGN>, InstructionError> {
// Calculate size in order to alloc once
let mut size = size_of::<u64>();
for instruction_account_index in 0..instruction_context.get_number_of_instruction_accounts() {
Expand Down Expand Up @@ -239,7 +239,7 @@ pub fn serialize_parameters_aligned(
size += size_of::<u64>() // data len
+ instruction_context.get_instruction_data().len()
+ size_of::<Pubkey>(); // program id;
let mut v = AlignedMemory::new(size, HOST_ALIGN);
let mut v = AlignedMemory::<HOST_ALIGN>::with_capacity(size);

// Serialize into the buffer
v.write_u64::<LittleEndian>(instruction_context.get_number_of_instruction_accounts() as u64)
Expand Down Expand Up @@ -275,7 +275,7 @@ pub fn serialize_parameters_aligned(
.map_err(|_| InstructionError::InvalidArgument)?;
v.write_all(borrowed_account.get_data())
.map_err(|_| InstructionError::InvalidArgument)?;
v.resize(
v.fill_write(
MAX_PERMITTED_DATA_INCREASE
+ (v.write_index() as *const u8).align_offset(BPF_ALIGN_OF_U128),
0,
Expand Down
12 changes: 6 additions & 6 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use {
},
solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf,
ebpf::{self, HOST_ALIGN},
error::EbpfError,
memory_region::{AccessType, MemoryMapping},
question_mark,
Expand Down Expand Up @@ -362,7 +362,7 @@ pub fn register_syscalls(
pub fn bind_syscall_context_objects<'a, 'b>(
vm: &mut EbpfVm<'a, RequisiteVerifier, BpfError, crate::ThisInstructionMeter>,
invoke_context: &'a mut InvokeContext<'b>,
heap: AlignedMemory,
heap: AlignedMemory<HOST_ALIGN>,
orig_account_lengths: Vec<usize>,
) -> Result<(), EbpfError<BpfError>> {
let check_aligned = bpf_loader_deprecated::id()
Expand Down Expand Up @@ -2488,7 +2488,7 @@ mod tests {
program_id,
bpf_loader::id(),
);
let mut heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
let mut heap = AlignedMemory::<HOST_ALIGN>::zero_filled(100);
let mut memory_mapping = MemoryMapping::new::<UserError>(
vec![
MemoryRegion::default(),
Expand Down Expand Up @@ -2530,7 +2530,7 @@ mod tests {
program_id,
bpf_loader::id(),
);
let mut heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
let mut heap = AlignedMemory::<HOST_ALIGN>::zero_filled(100);
let mut memory_mapping = MemoryMapping::new::<UserError>(
vec![
MemoryRegion::default(),
Expand Down Expand Up @@ -2571,7 +2571,7 @@ mod tests {
program_id,
bpf_loader::id(),
);
let mut heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
let mut heap = AlignedMemory::<HOST_ALIGN>::zero_filled(100);
let mut memory_mapping = MemoryMapping::new::<UserError>(
vec![
MemoryRegion::default(),
Expand Down Expand Up @@ -2613,7 +2613,7 @@ mod tests {
program_id,
bpf_loader::id(),
);
let mut heap = AlignedMemory::new_with_size(100, HOST_ALIGN);
let mut heap = AlignedMemory::<HOST_ALIGN>::zero_filled(100);
let config = Config::default();
let mut memory_mapping = MemoryMapping::new::<UserError>(
vec![
Expand Down
2 changes: 1 addition & 1 deletion rbpf-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.12.
solana-logger = { path = "../logger", version = "=1.12.0" }
solana-program-runtime = { path = "../program-runtime", version = "=1.12.0" }
solana-sdk = { path = "../sdk", version = "=1.12.0" }
solana_rbpf = "=0.2.31"
solana_rbpf = "=0.2.32"

0 comments on commit f76f8d5

Please sign in to comment.