Rust BPF programs depend on Solana SDK (#5819)
This commit is contained in:
@ -8,25 +8,49 @@ homepage = "https://solana.com/"
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
# On-chain program specific dependencies
|
||||
program = []
|
||||
# Kitchen sink specific dependencies
|
||||
kitchen_sink = [
|
||||
"assert_matches",
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"generic-array",
|
||||
"itertools",
|
||||
"log",
|
||||
"memmap",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rayon",
|
||||
"serde_json",
|
||||
"solana-ed25519-dalek",
|
||||
"solana-logger",
|
||||
"untrusted",
|
||||
]
|
||||
default = ["kitchen_sink"]
|
||||
|
||||
[dependencies]
|
||||
assert_matches = "1.3.0"
|
||||
assert_matches = { version = "1.3.0", optional = true }
|
||||
bincode = "1.1.4"
|
||||
bs58 = "0.2.5"
|
||||
byteorder = "1.3.2"
|
||||
chrono = { version = "0.4.8", features = ["serde"] }
|
||||
generic-array = { version = "0.13.2", default-features = false, features = ["serde", "more_lengths"] }
|
||||
byteorder = { version = "1.3.2", optional = true }
|
||||
cfg-if = "0.1.9"
|
||||
chrono = { version = "0.4.8", features = ["serde"], optional = true }
|
||||
generic-array = { version = "0.13.2", default-features = false, features = ["serde", "more_lengths"], optional = true }
|
||||
hex = "0.3.2"
|
||||
itertools = "0.8.0"
|
||||
log = "0.4.8"
|
||||
memmap = "0.6.2"
|
||||
num-derive = "0.2"
|
||||
num-traits = "0.2"
|
||||
rand = "0.6.5"
|
||||
rayon = "1.2.0"
|
||||
itertools = { version = "0.8.0", optional = true }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
memmap = { version = "0.6.2", optional = true }
|
||||
num-derive = { version = "0.2", optional = true }
|
||||
num-traits = { version = "0.2", optional = true }
|
||||
rand = { version = "0.6.5", optional = true }
|
||||
rayon = { version = "1.2.0", optional = true }
|
||||
serde = "1.0.99"
|
||||
serde_derive = "1.0.99"
|
||||
serde_json = "1.0.40"
|
||||
serde_json = { version = "1.0.40", optional = true }
|
||||
sha2 = "0.8.0"
|
||||
solana-ed25519-dalek = "0.2.0"
|
||||
solana-logger = { path = "../logger", version = "0.19.0-pre0" }
|
||||
untrusted = "0.7.0"
|
||||
solana-ed25519-dalek = { version = "0.2.0", optional = true }
|
||||
solana-logger = { path = "../logger", version = "0.19.0-pre0", optional = true }
|
||||
untrusted = { version = "0.7.0", optional = true }
|
4
sdk/bpf/rust/rust-test/.gitignore
vendored
4
sdk/bpf/rust/rust-test/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
/target/
|
||||
|
||||
Cargo.lock
|
||||
/farf/
|
@ -1,13 +0,0 @@
|
||||
|
||||
[package]
|
||||
name = "solana-sdk-bpf-test"
|
||||
version = "0.19.0-pre0"
|
||||
description = "Solana BPF SDK Rust Cargo test utilities"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = []
|
4
sdk/bpf/rust/rust-utils/.gitignore
vendored
4
sdk/bpf/rust/rust-utils/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
/target/
|
||||
|
||||
Cargo.lock
|
||||
/farf/
|
@ -1,13 +0,0 @@
|
||||
|
||||
[package]
|
||||
name = "solana-sdk-bpf-utils"
|
||||
version = "0.19.0-pre0"
|
||||
description = "Solana BPF SDK Rust Utils"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = []
|
@ -1,4 +0,0 @@
|
||||
//! @brief Solana Rust-based BPF program utility functions and types
|
||||
|
||||
pub mod entrypoint;
|
||||
pub mod log;
|
@ -1,30 +1,48 @@
|
||||
pub mod account;
|
||||
pub mod account_utils;
|
||||
pub mod bpf_loader;
|
||||
pub mod client;
|
||||
pub mod fee_calculator;
|
||||
pub mod genesis_block;
|
||||
pub mod hash;
|
||||
pub mod inflation;
|
||||
pub mod instruction;
|
||||
pub mod instruction_processor_utils;
|
||||
pub mod loader_instruction;
|
||||
pub mod message;
|
||||
pub mod native_loader;
|
||||
pub mod packet;
|
||||
pub mod poh_config;
|
||||
#[macro_use]
|
||||
extern crate cfg_if;
|
||||
|
||||
pub mod pubkey;
|
||||
pub mod rent;
|
||||
pub mod rpc_port;
|
||||
pub mod short_vec;
|
||||
pub mod signature;
|
||||
pub mod system_instruction;
|
||||
pub mod system_program;
|
||||
pub mod system_transaction;
|
||||
pub mod sysvar;
|
||||
pub mod timing;
|
||||
pub mod transaction;
|
||||
pub mod transport;
|
||||
|
||||
// On-chain program modules
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "program")] {
|
||||
pub mod entrypoint;
|
||||
pub mod log;
|
||||
pub mod program_test;
|
||||
}
|
||||
}
|
||||
|
||||
// Kitchen sink modules
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "kitchen_sink")] {
|
||||
pub mod account;
|
||||
pub mod account_utils;
|
||||
pub mod bpf_loader;
|
||||
pub mod client;
|
||||
pub mod fee_calculator;
|
||||
pub mod genesis_block;
|
||||
pub mod hash;
|
||||
pub mod inflation;
|
||||
pub mod instruction;
|
||||
pub mod instruction_processor_utils;
|
||||
pub mod loader_instruction;
|
||||
pub mod message;
|
||||
pub mod native_loader;
|
||||
pub mod packet;
|
||||
pub mod poh_config;
|
||||
pub mod rent;
|
||||
pub mod rpc_port;
|
||||
pub mod short_vec;
|
||||
pub mod signature;
|
||||
pub mod system_instruction;
|
||||
pub mod system_program;
|
||||
pub mod system_transaction;
|
||||
pub mod sysvar;
|
||||
pub mod timing;
|
||||
pub mod transaction;
|
||||
pub mod transport;
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
@ -1,10 +1,7 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::mem;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub use bs58;
|
||||
@ -50,6 +47,7 @@ impl Pubkey {
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "program"))]
|
||||
pub fn new_rand() -> Self {
|
||||
Self::new(&rand::random::<[u8; 32]>())
|
||||
}
|
||||
@ -73,21 +71,25 @@ impl fmt::Display for Pubkey {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "program"))]
|
||||
pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> {
|
||||
use std::io::Write;
|
||||
|
||||
let printable = format!("{}", pubkey);
|
||||
let serialized = serde_json::to_string(&printable)?;
|
||||
|
||||
if let Some(outdir) = Path::new(&outfile).parent() {
|
||||
fs::create_dir_all(outdir)?;
|
||||
if let Some(outdir) = std::path::Path::new(&outfile).parent() {
|
||||
std::fs::create_dir_all(outdir)?;
|
||||
}
|
||||
let mut f = File::create(outfile)?;
|
||||
let mut f = std::fs::File::create(outfile)?;
|
||||
f.write_all(&serialized.clone().into_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "program"))]
|
||||
pub fn read_pubkey(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||
let f = File::open(infile.to_string())?;
|
||||
let f = std::fs::File::open(infile.to_string())?;
|
||||
let printable: String = serde_json::from_reader(f)?;
|
||||
Ok(Pubkey::from_str(&printable)?)
|
||||
}
|
||||
|
Reference in New Issue
Block a user