Fixes for storage program and rework storage stage (#4654)

automerge
This commit is contained in:
Sagar Dhawan
2019-06-11 18:27:47 -07:00
committed by Grimes
parent 575a897ffc
commit 8019bff391
11 changed files with 394 additions and 311 deletions

View File

@@ -5,7 +5,7 @@ use solana_sdk::hash::Hash;
use solana_sdk::instruction::{AccountMeta, Instruction};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Signature;
use solana_sdk::syscall::tick_height;
use solana_sdk::syscall::current;
use solana_sdk::system_instruction;
use std::collections::HashMap;
@@ -25,7 +25,7 @@ pub enum StorageInstruction {
SubmitMiningProof {
sha_state: Hash,
slot: u64,
segment_index: usize,
signature: Signature,
},
AdvertiseStorageRecentBlockhash {
@@ -37,9 +37,7 @@ pub enum StorageInstruction {
/// Expects 1 Account:
/// 0 - Storage account with credits to redeem
/// 1 - MiningPool account to redeem credits from
ClaimStorageReward {
slot: u64,
},
ClaimStorageReward,
ProofValidation {
segment: u64,
proofs: Vec<(Pubkey, Vec<CheckedProof>)>,
@@ -118,17 +116,17 @@ pub fn create_mining_pool_account(
pub fn mining_proof(
storage_pubkey: &Pubkey,
sha_state: Hash,
slot: u64,
segment_index: usize,
signature: Signature,
) -> Instruction {
let storage_instruction = StorageInstruction::SubmitMiningProof {
sha_state,
slot,
segment_index,
signature,
};
let account_metas = vec![
AccountMeta::new(*storage_pubkey, true),
AccountMeta::new(tick_height::id(), false),
AccountMeta::new(current::id(), false),
];
Instruction::new(id(), &storage_instruction, account_metas)
}
@@ -144,7 +142,7 @@ pub fn advertise_recent_blockhash(
};
let account_metas = vec![
AccountMeta::new(*storage_pubkey, true),
AccountMeta::new(tick_height::id(), false),
AccountMeta::new(current::id(), false),
];
Instruction::new(id(), &storage_instruction, account_metas)
}
@@ -164,16 +162,11 @@ pub fn proof_validation<S: std::hash::BuildHasher>(
Instruction::new(id(), &storage_instruction, account_metas)
}
pub fn claim_reward(
storage_pubkey: &Pubkey,
mining_pool_pubkey: &Pubkey,
slot: u64,
) -> Instruction {
let storage_instruction = StorageInstruction::ClaimStorageReward { slot };
pub fn claim_reward(storage_pubkey: &Pubkey, mining_pool_pubkey: &Pubkey) -> Instruction {
let storage_instruction = StorageInstruction::ClaimStorageReward;
let account_metas = vec![
AccountMeta::new(*storage_pubkey, false),
AccountMeta::new(*mining_pool_pubkey, false),
AccountMeta::new(tick_height::id(), false),
];
Instruction::new(id(), &storage_instruction, account_metas)
}