Make BPF Loader static (bp #11516) (#11865)

* Make BPF Loader static (#11516)

(cherry picked from commit 7c736f71fe)

# Conflicts:
#	Cargo.lock
#	core/Cargo.toml
#	core/src/lib.rs
#	core/src/validator.rs
#	genesis/src/main.rs
#	programs/bpf/tests/programs.rs
#	runtime/src/builtin_programs.rs
#	runtime/src/lib.rs

* resolve conflicts

* nudge

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-08-27 01:00:24 +00:00
committed by GitHub
parent 97c3ff8a4f
commit 81db361d77
20 changed files with 779 additions and 515 deletions

View File

@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
use solana_sdk::{
account::{create_keyed_readonly_accounts, Account, KeyedAccount},
clock::Epoch,
entrypoint_native::{InvokeContext, Logger, ProcessInstruction},
entrypoint_native::{InvokeContext, Logger, ProcessInstruction, ProcessInstructionWithContext},
instruction::{CompiledInstruction, InstructionError},
message::Message,
native_loader,
@@ -247,9 +247,6 @@ impl Logger for ThisLogger {
}
}
pub type ProcessInstructionWithContext =
fn(&Pubkey, &[KeyedAccount], &[u8], &mut dyn InvokeContext) -> Result<(), InstructionError>;
#[derive(Deserialize, Serialize)]
pub struct MessageProcessor {
#[serde(skip)]
@@ -343,6 +340,17 @@ impl MessageProcessor {
) -> Result<(), InstructionError> {
if native_loader::check_id(&keyed_accounts[0].owner()?) {
let root_id = keyed_accounts[0].unsigned_key();
for (id, process_instruction) in &self.loaders {
if id == root_id {
// Call the program via a builtin loader
return process_instruction(
&root_id,
&keyed_accounts[1..],
instruction_data,
invoke_context,
);
}
}
for (id, process_instruction) in &self.programs {
if id == root_id {
// Call the builtin program
@@ -357,9 +365,9 @@ impl MessageProcessor {
invoke_context,
);
} else {
let owner_id = keyed_accounts[0].owner()?;
let owner_id = &keyed_accounts[0].owner()?;
for (id, process_instruction) in &self.loaders {
if *id == owner_id {
if id == owner_id {
// Call the program via a builtin loader
return process_instruction(
&owner_id,