Skip to content

Commit

Permalink
Bumps solana_rbpf to v0.2.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jul 23, 2021
1 parent 63aec97 commit 4075902
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 27 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 @@ -39,7 +39,7 @@ solana-config-program = { path = "../programs/config", version = "=1.8.0" }
solana-faucet = { path = "../faucet", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-net-utils = { path = "../net-utils", version = "=1.8.0" }
solana_rbpf = "=0.2.13"
solana_rbpf = "=0.2.14"
solana-remote-wallet = { path = "../remote-wallet", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.8.0" }
Expand Down
3 changes: 2 additions & 1 deletion cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,10 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
// Verify the program
<dyn Executable<BpfError, ThisInstructionMeter>>::from_elf(
&program_data,
Some(|x| verifier::check(x)),
Some(verifier::check),
Config {
reject_unresolved_syscalls: true,
verify_mul64_imm_nonzero: true, // TODO: Remove me after feature gate
..Config::default()
},
register_syscalls(&mut invoke_context).unwrap(),
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 @@ -30,7 +30,7 @@ solana-bpf-loader-program = { path = "../bpf_loader", version = "=1.8.0" }
solana-cli-output = { path = "../../cli-output", version = "=1.8.0" }
solana-logger = { path = "../../logger", version = "=1.8.0" }
solana-measure = { path = "../../measure", version = "=1.8.0" }
solana_rbpf = "=0.2.13"
solana_rbpf = "=0.2.14"
solana-runtime = { path = "../../runtime", version = "=1.8.0" }
solana-sdk = { path = "../../sdk", version = "=1.8.0" }
solana-transaction-status = { path = "../../transaction-status", version = "=1.8.0" }
Expand Down
7 changes: 2 additions & 5 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,11 +1258,8 @@ fn test_program_bpf_call_depth() {
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
assert!(result.is_ok());

let instruction = Instruction::new_with_bincode(
program_id,
&ComputeBudget::default().max_call_depth,
vec![],
);
let instruction =
Instruction::new_with_bincode(program_id, &ComputeBudget::default().max_call_depth, vec![]);
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
assert!(result.is_err());
}
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 @@ -24,7 +24,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.13"
solana_rbpf = "=0.2.14"
thiserror = "1.0"

[dev-dependencies]
Expand Down
20 changes: 9 additions & 11 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ use log::{log_enabled, trace, Level::Trace};
use solana_measure::measure::Measure;
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::{HOST_ALIGN, MM_HEAP_START},
ebpf::HOST_ALIGN,
error::{EbpfError, UserDefinedError},
memory_region::MemoryRegion,
static_analysis::Analysis,
verifier::{self, VerifierError},
vm::{Config, EbpfVm, Executable, InstructionMeter},
Expand Down Expand Up @@ -83,6 +82,7 @@ pub fn create_executor(
max_call_depth: compute_budget.max_call_depth,
stack_frame_size: compute_budget.stack_frame_size,
enable_instruction_tracing: log_enabled!(Trace),
verify_mul64_imm_nonzero: true, // TODO: Feature gate and then remove me
..Config::default()
};
let mut executable = {
Expand All @@ -98,10 +98,8 @@ pub fn create_executor(
)
}
.map_err(|e| map_ebpf_error(invoke_context, e))?;
let (_, elf_bytes) = executable
.get_text_bytes()
.map_err(|e| map_ebpf_error(invoke_context, e))?;
verifier::check(elf_bytes)
let text_bytes = executable.get_text_bytes().1;
verifier::check(text_bytes, &config)
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e.into())))?;
if use_jit {
if let Err(err) = executable.jit_compile() {
Expand Down Expand Up @@ -150,10 +148,9 @@ pub fn create_vm<'a>(
invoke_context: &'a mut dyn InvokeContext,
) -> Result<EbpfVm<'a, BpfError, ThisInstructionMeter>, EbpfError<BpfError>> {
let compute_budget = invoke_context.get_compute_budget();
let heap =
let mut heap =
AlignedMemory::new_with_size(compute_budget.heap_size.unwrap_or(HEAP_LENGTH), HOST_ALIGN);
let heap_region = MemoryRegion::new_from_slice(heap.as_slice(), MM_HEAP_START, 0, true);
let mut vm = EbpfVm::new(program, parameter_bytes, &[heap_region])?;
let mut vm = EbpfVm::new(program, heap.as_slice_mut(), parameter_bytes)?;
syscalls::bind_syscall_context_objects(loader_id, &mut vm, invoke_context, heap)?;
Ok(vm)
}
Expand Down Expand Up @@ -915,7 +912,8 @@ mod tests {
)
.unwrap();
let mut vm =
EbpfVm::<BpfError, TestInstructionMeter>::new(program.as_ref(), 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();
Expand All @@ -927,7 +925,7 @@ mod tests {
let prog = &[
0x18, 0x00, 0x00, 0x00, 0x88, 0x77, 0x66, 0x55, // first half of lddw
];
verifier::check(prog).unwrap();
verifier::check(prog, &Config::default()).unwrap();
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion rbpf-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ serde_json = "1.0.64"
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana_rbpf = "=0.2.13"
solana_rbpf = "=0.2.14"
time = "0.2.25"
4 changes: 2 additions & 2 deletions rbpf-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ native machine code before execting it in the virtual machine.",
.unwrap();

if matches.is_present("verify") {
let (_, elf_bytes) = executable.get_text_bytes().unwrap();
check(elf_bytes).unwrap();
let text_bytes = executable.get_text_bytes().1;
check(text_bytes, &config).unwrap();
}
executable.jit_compile().unwrap();
let analysis = Analysis::from_executable(executable.as_ref());
Expand Down

0 comments on commit 4075902

Please sign in to comment.