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

Commit

Permalink
Bump solana_rbpf to 0.2.34 (#28198)
Browse files Browse the repository at this point in the history
* Bumps solana_rbpf to 0.2.34

* Removes generic UserError from EbpfError.

* Uses ProgramResult for syscalls.
Removes use sites of the question_mark! macro by wrapping the call method of SyscallObjects.

* Uses InvokeContext as syscall context object directly.

* Replaces bind_syscall_context_object() by a parameter in the constructor.

* Inlines bind_syscall_context_objects() at its only call site.
  • Loading branch information
Lichtso authored Oct 6, 2022
1 parent 66cd290 commit 30b0a13
Show file tree
Hide file tree
Showing 16 changed files with 1,337 additions and 1,804 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 @@ -54,7 +54,7 @@ solana-tpu-client = { path = "../tpu-client", version = "=1.15.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.15.0" }
solana-version = { path = "../version", version = "=1.15.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.15.0" }
solana_rbpf = "=0.2.33"
solana_rbpf = "=0.2.34"
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
thiserror = "1.0.31"
tiny-bip39 = "0.8.2"
Expand Down
10 changes: 4 additions & 6 deletions cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
log::*,
solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig},
solana_bpf_loader_program::{syscalls::register_syscalls, BpfError, ThisInstructionMeter},
solana_bpf_loader_program::{syscalls::register_syscalls, ThisInstructionMeter},
solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*},
solana_cli_output::{
CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId,
Expand Down Expand Up @@ -2086,7 +2086,7 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);

// Verify the program
let executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let executable = Executable::<ThisInstructionMeter>::from_elf(
&program_data,
Config {
reject_broken_elfs: true,
Expand All @@ -2097,10 +2097,8 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
.map_err(|err| format!("ELF error: {}", err))?;

let _ =
VerifiedExecutable::<RequisiteVerifier, BpfError, ThisInstructionMeter>::from_executable(
executable,
)
.map_err(|err| format!("ELF error: {}", err))?;
VerifiedExecutable::<RequisiteVerifier, ThisInstructionMeter>::from_executable(executable)
.map_err(|err| format!("ELF error: {}", err))?;

Ok(program_data)
}
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.15.0" }
solana-runtime = { path = "../../runtime", version = "=1.15.0" }
solana-sdk = { path = "../../sdk", version = "=1.15.0" }
solana-transaction-status = { path = "../../transaction-status", version = "=1.15.0" }
solana_rbpf = "=0.2.33"
solana_rbpf = "=0.2.34"

[dev-dependencies]
solana-ledger = { path = "../../ledger", version = "=1.15.0" }
Expand Down
43 changes: 20 additions & 23 deletions programs/bpf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate solana_bpf_loader_program;
use {
byteorder::{ByteOrder, LittleEndian, WriteBytesExt},
solana_bpf_loader_program::{
create_vm, serialization::serialize_parameters, syscalls::register_syscalls, BpfError,
create_vm, serialization::serialize_parameters, syscalls::register_syscalls,
ThisInstructionMeter,
},
solana_measure::measure::Measure,
Expand Down Expand Up @@ -81,7 +81,7 @@ fn bench_program_create_executable(bencher: &mut Bencher) {
let elf = load_elf("bench_alu").unwrap();

bencher.iter(|| {
let _ = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let _ = Executable::<ThisInstructionMeter>::from_elf(
&elf,
Config::default(),
SyscallRegistry::default(),
Expand All @@ -106,19 +106,18 @@ fn bench_program_alu(bencher: &mut Bencher) {
.get_compute_meter()
.borrow_mut()
.mock_set_remaining(std::i64::MAX as u64);
let executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let executable = Executable::<ThisInstructionMeter>::from_elf(
&elf,
Config::default(),
register_syscalls(invoke_context, true).unwrap(),
)
.unwrap();

let mut verified_executable = VerifiedExecutable::<
RequisiteVerifier,
BpfError,
ThisInstructionMeter,
>::from_executable(executable)
.unwrap();
let mut verified_executable =
VerifiedExecutable::<RequisiteVerifier, ThisInstructionMeter>::from_executable(
executable,
)
.unwrap();

verified_executable.jit_compile().unwrap();
let compute_meter = invoke_context.get_compute_meter();
Expand Down Expand Up @@ -235,19 +234,18 @@ fn bench_create_vm(bencher: &mut Bencher) {
)
.unwrap();

let executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let executable = Executable::<ThisInstructionMeter>::from_elf(
&elf,
Config::default(),
register_syscalls(invoke_context, true).unwrap(),
)
.unwrap();

let verified_executable = VerifiedExecutable::<
RequisiteVerifier,
BpfError,
ThisInstructionMeter,
>::from_executable(executable)
.unwrap();
let verified_executable =
VerifiedExecutable::<RequisiteVerifier, ThisInstructionMeter>::from_executable(
executable,
)
.unwrap();

bencher.iter(|| {
let _ = create_vm(
Expand Down Expand Up @@ -283,19 +281,18 @@ fn bench_instruction_count_tuner(_bencher: &mut Bencher) {
)
.unwrap();

let executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let executable = Executable::<ThisInstructionMeter>::from_elf(
&elf,
Config::default(),
register_syscalls(invoke_context, true).unwrap(),
)
.unwrap();

let verified_executable = VerifiedExecutable::<
RequisiteVerifier,
BpfError,
ThisInstructionMeter,
>::from_executable(executable)
.unwrap();
let verified_executable =
VerifiedExecutable::<RequisiteVerifier, ThisInstructionMeter>::from_executable(
executable,
)
.unwrap();

let compute_meter = invoke_context.get_compute_meter();
let mut instruction_meter = ThisInstructionMeter { compute_meter };
Expand Down
25 changes: 14 additions & 11 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use {
create_vm,
serialization::{deserialize_parameters, serialize_parameters},
syscalls::register_syscalls,
BpfError, ThisInstructionMeter,
ThisInstructionMeter,
},
solana_program_runtime::invoke_context::with_mock_invoke_context,
solana_rbpf::{
Expand Down Expand Up @@ -241,20 +241,19 @@ fn run_program(name: &str) -> u64 {
reject_broken_elfs: true,
..Config::default()
};
let executable = Executable::<BpfError, ThisInstructionMeter>::from_elf(
let executable = Executable::<ThisInstructionMeter>::from_elf(
&data,
config,
register_syscalls(invoke_context, true /* no sol_alloc_free */).unwrap(),
)
.unwrap();

#[allow(unused_mut)]
let mut verified_executable = VerifiedExecutable::<
RequisiteVerifier,
BpfError,
ThisInstructionMeter,
>::from_executable(executable)
.unwrap();
let mut verified_executable =
VerifiedExecutable::<RequisiteVerifier, ThisInstructionMeter>::from_executable(
executable,
)
.unwrap();

let run_program_iterations = {
#[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -300,7 +299,10 @@ fn run_program(name: &str) -> u64 {
instruction_count = vm.get_total_instruction_count();
if config.enable_instruction_tracing {
if i == 1 {
if !Tracer::compare(tracer.as_ref().unwrap(), vm.get_tracer()) {
if !Tracer::compare(
tracer.as_ref().unwrap(),
&vm.get_program_environment().tracer,
) {
let analysis =
Analysis::from_executable(verified_executable.get_executable())
.unwrap();
Expand All @@ -312,7 +314,8 @@ fn run_program(name: &str) -> u64 {
.write(&mut stdout.lock(), &analysis)
.unwrap();
println!("TRACE (jit):");
vm.get_tracer()
vm.get_program_environment()
.tracer
.write(&mut stdout.lock(), &analysis)
.unwrap();
assert!(false);
Expand All @@ -330,7 +333,7 @@ fn run_program(name: &str) -> u64 {
trace!("BPF Program Instruction Trace:\n{}", trace_string);
}
}
tracer = Some(vm.get_tracer().clone());
tracer = Some(vm.get_program_environment().tracer.clone());
}
}
assert!(match deserialize_parameters(
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.15.0" }
solana-program-runtime = { path = "../../program-runtime", version = "=1.15.0" }
solana-sdk = { path = "../../sdk", version = "=1.15.0" }
solana-zk-token-sdk = { path = "../../zk-token-sdk", version = "=1.15.0" }
solana_rbpf = "=0.2.33"
solana_rbpf = "=0.2.34"
thiserror = "1.0"

[dev-dependencies]
Expand Down
Loading

0 comments on commit 30b0a13

Please sign in to comment.