Skip to content

Commit

Permalink
Boot storage program from the SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
garious committed Mar 5, 2019
1 parent 9c8240a commit 2545463
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 20 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ members = [
"programs/rewards",
"programs/rewards_api",
"programs/storage",
"programs/storage_api",
"programs/system",
"programs/vote",
"programs/vote_api",
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ solana-metrics = { path = "../metrics", version = "0.12.0" }
solana-netutil = { path = "../netutil", version = "0.12.0" }
solana-runtime = { path = "../runtime", version = "0.12.0" }
solana-sdk = { path = "../sdk", version = "0.12.0" }
solana-storage-api = { path = "../programs/storage_api", version = "0.12.0" }
solana-vote-api = { path = "../programs/vote_api", version = "0.12.0" }
solana-vote-signer = { path = "../vote-signer", version = "0.12.0" }
sys-info = "0.5.6"
Expand Down
2 changes: 1 addition & 1 deletion core/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::{Hash, Hasher};
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::storage_program::StorageTransaction;
use solana_storage_api::StorageTransaction;
use std::fs::File;
use std::io;
use std::io::BufReader;
Expand Down
4 changes: 2 additions & 2 deletions core/src/storage_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use rand_chacha::ChaChaRng;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, Signature};
use solana_sdk::storage_program::{self, StorageProgram, StorageTransaction};
use solana_sdk::transaction::Transaction;
use solana_storage_api::{self, StorageProgram, StorageTransaction};
use std::collections::HashSet;
use std::io;
use std::mem::size_of;
Expand Down Expand Up @@ -377,7 +377,7 @@ impl StorageStage {
.copy_from_slice(tx.signatures[0].as_ref());
*current_key_idx += size_of::<Signature>();
*current_key_idx %= storage_keys.len();
} else if storage_program::check_id(&program_id) {
} else if solana_storage_api::check_id(&program_id) {
match deserialize(&tx.instructions[i].userdata) {
Ok(StorageProgram::SubmitMiningProof {
entry_height: proof_entry_height,
Expand Down
1 change: 1 addition & 0 deletions programs/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde = "1.0.89"
serde_derive = "1.0.89"
solana-logger = { path = "../../logger", version = "0.12.0" }
solana-sdk = { path = "../../sdk", version = "0.12.0" }
solana-storage-api = { path = "../storage_api", version = "0.12.0" }

[dev-dependencies]
solana-runtime = { path = "../../runtime", version = "0.12.0" }
Expand Down
5 changes: 2 additions & 3 deletions programs/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_sdk::account::KeyedAccount;
use solana_sdk::native_program::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::solana_entrypoint;
use solana_sdk::storage_program::*;
use solana_storage_api::*;

pub const TOTAL_VALIDATOR_REWARDS: u64 = 1000;
pub const TOTAL_REPLICATOR_REWARDS: u64 = 1000;
Expand Down Expand Up @@ -180,9 +180,8 @@ mod test {
use solana_sdk::account::{create_keyed_accounts, Account};
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::storage_program::ProofStatus;
use solana_sdk::storage_program::StorageTransaction;
use solana_sdk::transaction::{Instruction, Transaction};
use solana_storage_api::{ProofStatus, StorageTransaction};

fn test_transaction(
tx: &Transaction,
Expand Down
9 changes: 4 additions & 5 deletions programs/storage/tests/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::storage_program;
use solana_sdk::storage_program::{StorageTransaction, ENTRIES_PER_SEGMENT};
use solana_sdk::system_transaction::SystemTransaction;
use solana_storage_api::{StorageTransaction, ENTRIES_PER_SEGMENT};

fn get_storage_entry_height(bank: &Bank, account: Pubkey) -> u64 {
match bank.get_account(&account) {
Some(storage_system_account) => {
let state = deserialize(&storage_system_account.userdata);
if let Ok(state) = state {
let state: storage_program::StorageProgramState = state;
let state: solana_storage_api::StorageProgramState = state;
return state.entry_height;
}
}
Expand All @@ -29,7 +28,7 @@ fn get_storage_blockhash(bank: &Bank, account: Pubkey) -> Hash {
if let Some(storage_system_account) = bank.get_account(&account) {
let state = deserialize(&storage_system_account.userdata);
if let Ok(state) = state {
let state: storage_program::StorageProgramState = state;
let state: solana_storage_api::StorageProgramState = state;
return state.hash;
}
}
Expand Down Expand Up @@ -63,7 +62,7 @@ fn test_bank_storage() {
blockhash,
1,
4 * 1024,
storage_program::id(),
solana_storage_api::id(),
0,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::hash::Hash;
use crate::pubkey::Pubkey;
use crate::signature::{Keypair, Signature};
use crate::transaction::Transaction;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, Signature};
use solana_sdk::transaction::Transaction;

pub const ENTRIES_PER_SEGMENT: u64 = 16;

Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solana-logger = { path = "../logger", version = "0.12.0" }
solana-metrics = { path = "../metrics", version = "0.12.0" }
solana-sdk = { path = "../sdk", version = "0.12.0" }
solana-system-program = { path = "../programs/system", version = "0.12.0" }
solana-storage-api = { path = "../programs/storage_api", version = "0.12.0" }
solana-token-api = { path = "../programs/token_api", version = "0.12.0" }
solana-vote-api = { path = "../programs/vote_api", version = "0.12.0" }

Expand Down
7 changes: 3 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use solana_sdk::native_loader;
use solana_sdk::native_program::ProgramError;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, Signature};
use solana_sdk::storage_program;
use solana_sdk::system_program;
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::timing::{duration_as_us, MAX_RECENT_BLOCKHASHES, NUM_TICKS_PER_SECOND};
Expand Down Expand Up @@ -293,7 +292,7 @@ impl Bank {
fn add_builtin_programs(&self) {
self.add_native_program("solana_system_program", &system_program::id());
self.add_native_program("solana_vote_program", &solana_vote_api::id());
self.add_native_program("solana_storage_program", &storage_program::id());
self.add_native_program("solana_storage_program", &solana_storage_api::id());
self.add_native_program("solana_bpf_loader", &bpf_loader::id());
self.add_native_program("solana_budget_program", &solana_budget_api::id());
self.add_native_program("solana_token_program", &solana_token_api::id());
Expand Down Expand Up @@ -1271,7 +1270,7 @@ mod tests {
assert_eq!(native_loader::id(), native);
assert_eq!(bpf_loader::id(), bpf);
assert_eq!(solana_budget_api::id(), budget);
assert_eq!(storage_program::id(), storage);
assert_eq!(solana_storage_api::id(), storage);
assert_eq!(solana_token_api::id(), token);
assert_eq!(solana_vote_api::id(), vote);
}
Expand All @@ -1284,7 +1283,7 @@ mod tests {
native_loader::id(),
bpf_loader::id(),
solana_budget_api::id(),
storage_program::id(),
solana_storage_api::id(),
solana_token_api::id(),
solana_vote_api::id(),
];
Expand Down
1 change: 0 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub mod packet;
pub mod pubkey;
pub mod shortvec;
pub mod signature;
pub mod storage_program;
pub mod system_instruction;
pub mod system_program;
pub mod system_transaction;
Expand Down

0 comments on commit 2545463

Please sign in to comment.