parent
cea8067219
commit
a5f2444ad2
|
@ -31,7 +31,7 @@ name = "ar"
|
|||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -97,7 +97,7 @@ name = "base64"
|
|||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -110,7 +110,7 @@ name = "bincode"
|
|||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -145,7 +145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -201,7 +201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.3.2"
|
||||
version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -209,7 +209,7 @@ name = "bytes"
|
|||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -308,7 +308,7 @@ version = "2.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -386,7 +386,7 @@ name = "curve25519-dalek"
|
|||
version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -449,7 +449,7 @@ dependencies = [
|
|||
"bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bloom 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"enum-primitive-derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -690,7 +690,7 @@ name = "hash32"
|
|||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1147,7 +1147,7 @@ name = "pbkdf2"
|
|||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1709,7 +1709,7 @@ name = "solana-bpf-loader-program"
|
|||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1725,7 +1725,7 @@ name = "solana-bpf-programs"
|
|||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"elf 0.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-bpf-loader-program 1.1.0",
|
||||
"solana-logger 1.1.0",
|
||||
|
@ -1764,7 +1764,7 @@ dependencies = [
|
|||
name = "solana-bpf-rust-dep-crate"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk 1.1.0",
|
||||
"solana-sdk-bpf-test 1.1.0",
|
||||
]
|
||||
|
@ -1944,7 +1944,7 @@ version = "1.1.0"
|
|||
dependencies = [
|
||||
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bv 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1980,7 +1980,7 @@ dependencies = [
|
|||
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bv 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2073,7 +2073,7 @@ name = "solana_rbpf"
|
|||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"combine 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"elfkit 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2775,7 +2775,7 @@ dependencies = [
|
|||
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
|
||||
"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
|
||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
||||
"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
|
||||
"checksum bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38"
|
||||
"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101"
|
||||
|
|
|
@ -6,7 +6,8 @@ mod bpf {
|
|||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
loader_utils::load_program,
|
||||
};
|
||||
use std::{env, fs::File, path::PathBuf};
|
||||
use solana_sdk::{bpf_loader, pubkey::Pubkey, signature::Keypair};
|
||||
use std::{env, fs::File, io::Read, path::PathBuf};
|
||||
|
||||
/// BPF program file extension
|
||||
const PLATFORM_FILE_EXTENSION_BPF: &str = "so";
|
||||
|
@ -23,20 +24,28 @@ mod bpf {
|
|||
pathbuf
|
||||
}
|
||||
|
||||
fn load_bpf_program(bank_client: &BankClient, payer_keypair: &Keypair, name: &str) -> Pubkey {
|
||||
let path = create_bpf_path(name);
|
||||
println!("path {:?}", path);
|
||||
let mut file = File::open(path).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
load_program(bank_client, payer_keypair, &bpf_loader::id(), elf)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bpf_c")]
|
||||
mod bpf_c {
|
||||
use super::*;
|
||||
use solana_runtime::loader_utils::create_invoke_instruction;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
bpf_loader,
|
||||
client::SyncClient,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
pubkey::Pubkey,
|
||||
signature::Signer,
|
||||
transaction::TransactionError,
|
||||
};
|
||||
use std::{io::Read, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn test_program_bpf_c() {
|
||||
|
@ -54,9 +63,6 @@ mod bpf {
|
|||
];
|
||||
for program in programs.iter() {
|
||||
println!("Test program: {:?}", program.0);
|
||||
let mut file = File::open(create_bpf_path(program.0)).expect("file open failed");
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
|
@ -67,7 +73,7 @@ mod bpf {
|
|||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let program_id = load_bpf_program(&bank_client, &mint_keypair, program.0);
|
||||
let instruction =
|
||||
create_invoke_instruction(mint_keypair.pubkey(), program_id, &1u8);
|
||||
let result = bank_client.send_instruction(&mint_keypair, instruction);
|
||||
|
@ -83,11 +89,6 @@ mod bpf {
|
|||
fn test_program_bpf_c_duplicate_accounts() {
|
||||
solana_logger::setup();
|
||||
|
||||
let filename = create_bpf_path("dup_accounts");
|
||||
let mut file = File::open(filename).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
|
@ -96,8 +97,7 @@ mod bpf {
|
|||
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
|
||||
let program_id = load_bpf_program(&bank_client, &mint_keypair, "dup_accounts");
|
||||
let payee_account = Account::new(10, 1, &program_id);
|
||||
let payee_pubkey = Pubkey::new_rand();
|
||||
bank.store_account(&payee_pubkey, &payee_account);
|
||||
|
@ -158,11 +158,6 @@ mod bpf {
|
|||
fn test_program_bpf_c_error_handling() {
|
||||
solana_logger::setup();
|
||||
|
||||
let filename = create_bpf_path("error_handling");
|
||||
let mut file = File::open(filename).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
|
@ -171,7 +166,7 @@ mod bpf {
|
|||
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let program_id = load_bpf_program(&bank_client, &mint_keypair, "error_handling");
|
||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||
|
||||
let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
|
||||
|
@ -220,7 +215,6 @@ mod bpf {
|
|||
use super::*;
|
||||
use solana_sdk::{
|
||||
account::Account,
|
||||
bpf_loader,
|
||||
client::SyncClient,
|
||||
clock::DEFAULT_SLOTS_PER_EPOCH,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
|
@ -229,7 +223,6 @@ mod bpf {
|
|||
sysvar::{clock, fees, rent, rewards, slot_hashes, stake_history},
|
||||
transaction::TransactionError,
|
||||
};
|
||||
use std::io::Read;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
|
@ -249,11 +242,7 @@ mod bpf {
|
|||
("solana_bpf_rust_sysval", true),
|
||||
];
|
||||
for program in programs.iter() {
|
||||
let filename = create_bpf_path(program.0);
|
||||
println!("Test program: {:?} from {:?}", program.0, filename);
|
||||
let mut file = File::open(filename).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
println!("Test program: {:?}", program.0);
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
|
@ -267,7 +256,7 @@ mod bpf {
|
|||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let program_id = load_bpf_program(&bank_client, &mint_keypair, program.0);
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
AccountMeta::new(Keypair::new().pubkey(), false),
|
||||
|
@ -292,21 +281,15 @@ mod bpf {
|
|||
fn test_program_bpf_rust_duplicate_accounts() {
|
||||
solana_logger::setup();
|
||||
|
||||
let filename = create_bpf_path("solana_bpf_rust_dup_accounts");
|
||||
let mut file = File::open(filename).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(50);
|
||||
|
||||
let bank = Arc::new(Bank::new(&genesis_config));
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
|
||||
let program_id =
|
||||
load_bpf_program(&bank_client, &mint_keypair, "solana_bpf_rust_dup_accounts");
|
||||
let payee_account = Account::new(10, 1, &program_id);
|
||||
let payee_pubkey = Pubkey::new_rand();
|
||||
bank.store_account(&payee_pubkey, &payee_account);
|
||||
|
@ -367,20 +350,18 @@ mod bpf {
|
|||
fn test_program_bpf_rust_error_handling() {
|
||||
solana_logger::setup();
|
||||
|
||||
let filename = create_bpf_path("solana_bpf_rust_error_handling");
|
||||
let mut file = File::open(filename).unwrap();
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(50);
|
||||
|
||||
let bank = Bank::new(&genesis_config);
|
||||
let bank_client = BankClient::new(bank);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let program_id = load_bpf_program(
|
||||
&bank_client,
|
||||
&mint_keypair,
|
||||
"solana_bpf_rust_error_handling",
|
||||
);
|
||||
let account_metas = vec![AccountMeta::new(mint_keypair.pubkey(), true)];
|
||||
|
||||
let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
|
||||
|
|
|
@ -18,7 +18,6 @@ num-traits = { version = "0.2" }
|
|||
solana-logger = { path = "../../logger", version = "1.1.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "1.1.0" }
|
||||
solana_rbpf = "=0.1.23"
|
||||
|
||||
thiserror = "1.0"
|
||||
|
||||
[lib]
|
||||
|
|
Loading…
Reference in New Issue