Remove bpf_loader.rs
This commit is contained in:
parent
d010cac8a5
commit
ae0be1e857
|
@ -14,8 +14,9 @@ use bincode::deserialize;
|
|||
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
|
||||
use libc::c_char;
|
||||
use solana_rbpf::EbpfVmRaw;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::account::{Account, KeyedAccount};
|
||||
use solana_sdk::loader_instruction::LoaderInstruction;
|
||||
use solana_sdk::native_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::ffi::CStr;
|
||||
use std::io::prelude::*;
|
||||
|
@ -23,6 +24,26 @@ use std::io::{Error, ErrorKind};
|
|||
use std::mem;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
const BPF_LOADER_NAME: &str = "solana_bpf_loader";
|
||||
const BPF_LOADER_PROGRAM_ID: [u8; 32] = [
|
||||
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
];
|
||||
|
||||
pub fn id() -> Pubkey {
|
||||
Pubkey::new(&BPF_LOADER_PROGRAM_ID)
|
||||
}
|
||||
|
||||
pub fn account() -> Account {
|
||||
Account {
|
||||
tokens: 1,
|
||||
owner: id(),
|
||||
userdata: BPF_LOADER_NAME.as_bytes().to_vec(),
|
||||
executable: true,
|
||||
loader: native_loader::id(),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO use rbpf's disassemble
|
||||
#[allow(dead_code)]
|
||||
fn dump_program(key: &Pubkey, prog: &[u8]) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
use bincode::deserialize;
|
||||
use bincode::serialize;
|
||||
use bpf_loader;
|
||||
use budget_program;
|
||||
use counter::Counter;
|
||||
use entry::Entry;
|
||||
|
@ -402,7 +401,7 @@ impl Bank {
|
|||
let mut accounts = self.accounts.write().unwrap();
|
||||
|
||||
// Preload Bpf Loader account
|
||||
accounts.store(&bpf_loader::id(), &bpf_loader::account());
|
||||
accounts.store(&solana_bpf_loader::id(), &solana_bpf_loader::account());
|
||||
|
||||
// Preload Erc20 token program
|
||||
accounts.store(&solana_erc20::id(), &solana_erc20::account());
|
||||
|
@ -2139,7 +2138,7 @@ mod tests {
|
|||
|
||||
assert_eq!(system_program::id(), system);
|
||||
assert_eq!(native_loader::id(), native);
|
||||
assert_eq!(bpf_loader::id(), bpf);
|
||||
assert_eq!(solana_bpf_loader::id(), bpf);
|
||||
assert_eq!(budget_program::id(), budget);
|
||||
assert_eq!(storage_program::id(), storage);
|
||||
assert_eq!(solana_erc20::id(), token);
|
||||
|
@ -2152,7 +2151,7 @@ mod tests {
|
|||
let ids = vec![
|
||||
system_program::id(),
|
||||
native_loader::id(),
|
||||
bpf_loader::id(),
|
||||
solana_bpf_loader::id(),
|
||||
budget_program::id(),
|
||||
storage_program::id(),
|
||||
solana_erc20::id(),
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
//! BPF loader
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::native_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
const BPF_LOADER_NAME: &str = "solana_bpf_loader";
|
||||
const BPF_LOADER_PROGRAM_ID: [u8; 32] = [
|
||||
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
];
|
||||
|
||||
pub fn id() -> Pubkey {
|
||||
Pubkey::new(&BPF_LOADER_PROGRAM_ID)
|
||||
}
|
||||
|
||||
pub fn account() -> Account {
|
||||
Account {
|
||||
tokens: 1,
|
||||
owner: id(),
|
||||
userdata: BPF_LOADER_NAME.as_bytes().to_vec(),
|
||||
executable: true,
|
||||
loader: native_loader::id(),
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ pub mod bank;
|
|||
pub mod banking_stage;
|
||||
pub mod blob_fetch_stage;
|
||||
pub mod bloom;
|
||||
pub mod bpf_loader;
|
||||
pub mod broadcast_stage;
|
||||
pub mod budget_expr;
|
||||
pub mod budget_instruction;
|
||||
|
@ -126,6 +125,7 @@ extern crate solana_jsonrpc_core as jsonrpc_core;
|
|||
extern crate solana_jsonrpc_http_server as jsonrpc_http_server;
|
||||
#[macro_use]
|
||||
extern crate solana_jsonrpc_macros as jsonrpc_macros;
|
||||
extern crate solana_bpf_loader;
|
||||
extern crate solana_erc20;
|
||||
extern crate solana_jsonrpc_pubsub as jsonrpc_pubsub;
|
||||
extern crate solana_jsonrpc_ws_server as jsonrpc_ws_server;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use bincode::serialize;
|
||||
use bpf_loader;
|
||||
use bs58;
|
||||
use budget_program;
|
||||
use budget_transaction::BudgetTransaction;
|
||||
|
@ -13,6 +12,7 @@ use ring::signature::Ed25519KeyPair;
|
|||
use rpc::RpcSignatureStatus;
|
||||
use rpc_request::{get_rpc_request_str, RpcClient, RpcRequest};
|
||||
use serde_json;
|
||||
use solana_bpf_loader;
|
||||
use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
@ -431,7 +431,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
|||
last_id,
|
||||
1,
|
||||
program_userdata.len() as u64,
|
||||
bpf_loader::id(),
|
||||
solana_bpf_loader::id(),
|
||||
0,
|
||||
);
|
||||
send_and_confirm_tx(&rpc_client, &tx).map_err(|_| {
|
||||
|
@ -442,7 +442,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
|||
for chunk in program_userdata.chunks(USERDATA_CHUNK_SIZE) {
|
||||
let tx = Transaction::loader_write(
|
||||
&program,
|
||||
bpf_loader::id(),
|
||||
solana_bpf_loader::id(),
|
||||
offset,
|
||||
chunk.to_vec(),
|
||||
last_id,
|
||||
|
@ -457,9 +457,9 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
|||
offset += USERDATA_CHUNK_SIZE as u32;
|
||||
}
|
||||
|
||||
let last_id = get_last_id(&rpc_client)?;
|
||||
let last_id = get_last_id(&rpc_client, &rpc_addr)?;
|
||||
let tx = Transaction::loader_finalize(&program, bpf_loader::id(), last_id, 0);
|
||||
send_and_confirm_tx(&rpc_client, &tx).map_err(|_| {
|
||||
send_and_confirm_tx(&rpc_client, &rpc_addr, &tx).map_err(|_| {
|
||||
WalletError::DynamicProgramError("Program finalize transaction failed".to_string())
|
||||
})?;
|
||||
|
||||
|
@ -826,7 +826,7 @@ mod tests {
|
|||
.takes_value(true)
|
||||
.required(true)
|
||||
.help("/path/to/program.o"),
|
||||
), // TODO: Add "loader" argument; current default is bpf_loader
|
||||
), // TODO: Add "loader" argument; current default is solana_bpf_loader
|
||||
).subcommand(
|
||||
SubCommand::with_name("get-transaction-count")
|
||||
.about("Get current transaction count"),
|
||||
|
|
|
@ -2,16 +2,18 @@ extern crate bincode;
|
|||
extern crate elf;
|
||||
extern crate serde_derive;
|
||||
extern crate solana;
|
||||
#[cfg(feature = "bpf_c")]
|
||||
extern crate solana_bpf_loader;
|
||||
extern crate solana_sdk;
|
||||
|
||||
use solana::bank::Bank;
|
||||
#[cfg(feature = "bpf_c")]
|
||||
use solana::bpf_loader;
|
||||
use solana::loader_transaction::LoaderTransaction;
|
||||
use solana::logger;
|
||||
use solana::mint::Mint;
|
||||
use solana::native_loader;
|
||||
use solana::system_transaction::SystemTransaction;
|
||||
#[cfg(feature = "bpf_c")]
|
||||
use solana_bpf_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
|
@ -110,7 +112,7 @@ impl Loader {
|
|||
pub fn new_bpf() -> Self {
|
||||
let mint = Mint::new(50);
|
||||
let bank = Bank::new(&mint);
|
||||
let loader = bpf_loader::id();
|
||||
let loader = solana_bpf_loader::id();
|
||||
|
||||
Loader { mint, bank, loader }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue