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

Commit

Permalink
Refactor - create_executor() to be usable outside of bpf_loader (#28369)
Browse files Browse the repository at this point in the history
* Moves disable_deploy_of_alloc_free_syscall parameter inside create_executor().

* Lets register_syscalls() take &FeatureSet only instead of the entire InvokeContext.

* Uses ic_logger_msg!() instead of ic_msg!() inside create_executor().
Inlines map_ebpf_error().

* Adds register_syscalls_us to executor_metrics::CreateMetrics.

* Moves timings accumulation into executor_metrics::CreateMetrics::submit_datapoint().

* Moves &invoke_context.feature_set into a variable.

* Lets create_executor() return executor_metrics::CreateMetrics via a mutable parameter.

* Dissolves invoke_context parameter in create_executor().

* Pulls assignment of create_executor_metrics.program_id outside of create_executor().

* Makes create_executor() take a byte slice instead of a BorrowedAccount.

* Adds create_executor_from_account().
  • Loading branch information
Lichtso authored Oct 18, 2022
1 parent d949f4f commit 547f075
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 171 deletions.
4 changes: 2 additions & 2 deletions cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
file.read_to_end(&mut program_data)
.map_err(|err| format!("Unable to read program file: {}", err))?;
let mut transaction_context = TransactionContext::new(Vec::new(), Some(Rent::default()), 1, 1);
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);

// Verify the program
let executable = Executable::<ThisInstructionMeter>::from_elf(
Expand All @@ -2092,7 +2092,7 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
reject_broken_elfs: true,
..Config::default()
},
register_syscalls(&mut invoke_context, true).unwrap(),
register_syscalls(&invoke_context.feature_set, true).unwrap(),
)
.map_err(|err| format!("ELF error: {}", err))?;

Expand Down
Loading

0 comments on commit 547f075

Please sign in to comment.