2019-03-22 06:47:05 -06:00
|
|
|
//! storage program
|
|
|
|
//! Receive mining proofs from miners, validate the answers
|
|
|
|
//! and give reward for good proofs.
|
|
|
|
|
2019-04-04 12:01:09 -07:00
|
|
|
use crate::storage_contract::StorageAccount;
|
2019-03-22 14:30:18 -06:00
|
|
|
use crate::storage_instruction::StorageInstruction;
|
2019-03-22 06:47:05 -06:00
|
|
|
use log::*;
|
2019-04-04 12:01:09 -07:00
|
|
|
use solana_sdk::account::KeyedAccount;
|
2019-03-23 21:12:27 -06:00
|
|
|
use solana_sdk::instruction::InstructionError;
|
2019-03-22 06:47:05 -06:00
|
|
|
use solana_sdk::pubkey::Pubkey;
|
2019-04-02 13:08:55 -07:00
|
|
|
|
2019-03-22 06:47:05 -06:00
|
|
|
pub fn process_instruction(
|
|
|
|
_program_id: &Pubkey,
|
|
|
|
keyed_accounts: &mut [KeyedAccount],
|
|
|
|
data: &[u8],
|
2019-04-02 13:08:55 -07:00
|
|
|
tick_height: u64,
|
2019-03-22 06:47:05 -06:00
|
|
|
) -> Result<(), InstructionError> {
|
|
|
|
solana_logger::setup();
|
|
|
|
|
2019-04-04 12:01:09 -07:00
|
|
|
let num_keyed_accounts = keyed_accounts.len();
|
|
|
|
let (me, rest) = keyed_accounts.split_at_mut(1);
|
|
|
|
|
2019-03-22 06:47:05 -06:00
|
|
|
// accounts_keys[0] must be signed
|
2019-04-04 12:01:09 -07:00
|
|
|
let storage_account_pubkey = me[0].signer_key();
|
|
|
|
if storage_account_pubkey.is_none() {
|
2019-03-22 06:47:05 -06:00
|
|
|
info!("account[0] is unsigned");
|
2019-04-04 12:01:09 -07:00
|
|
|
Err(InstructionError::MissingRequiredSignature)?;
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
2019-04-04 12:01:09 -07:00
|
|
|
let storage_account_pubkey = *storage_account_pubkey.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-04 12:01:09 -07:00
|
|
|
let mut storage_account = StorageAccount::new(&mut me[0].account);
|
|
|
|
let mut rest: Vec<_> = rest
|
|
|
|
.iter_mut()
|
|
|
|
.map(|keyed_account| StorageAccount::new(&mut keyed_account.account))
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
match bincode::deserialize(data).map_err(|_| InstructionError::InvalidInstructionData)? {
|
|
|
|
StorageInstruction::SubmitMiningProof {
|
|
|
|
sha_state,
|
|
|
|
entry_height,
|
|
|
|
signature,
|
|
|
|
} => {
|
|
|
|
if num_keyed_accounts != 1 {
|
|
|
|
Err(InstructionError::InvalidArgument)?;
|
|
|
|
}
|
|
|
|
storage_account.submit_mining_proof(
|
|
|
|
storage_account_pubkey,
|
2019-03-22 06:47:05 -06:00
|
|
|
sha_state,
|
|
|
|
entry_height,
|
|
|
|
signature,
|
2019-04-04 12:01:09 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
StorageInstruction::AdvertiseStorageRecentBlockhash { hash, entry_height } => {
|
|
|
|
if num_keyed_accounts != 1 {
|
|
|
|
// keyed_accounts[0] should be the main storage key
|
|
|
|
// to access its data
|
|
|
|
Err(InstructionError::InvalidArgument)?;
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
2019-04-04 12:01:09 -07:00
|
|
|
storage_account.advertise_storage_recent_blockhash(hash, entry_height)
|
|
|
|
}
|
|
|
|
StorageInstruction::ClaimStorageReward { entry_height } => {
|
|
|
|
if num_keyed_accounts != 1 {
|
|
|
|
// keyed_accounts[0] should be the main storage key
|
|
|
|
// to access its data
|
|
|
|
Err(InstructionError::InvalidArgument)?;
|
2019-04-02 13:08:55 -07:00
|
|
|
}
|
2019-04-04 12:01:09 -07:00
|
|
|
storage_account.claim_storage_reward(entry_height, tick_height)
|
|
|
|
}
|
|
|
|
StorageInstruction::ProofValidation {
|
|
|
|
entry_height,
|
|
|
|
proofs,
|
|
|
|
} => {
|
|
|
|
if num_keyed_accounts == 1 {
|
|
|
|
// have to have at least 1 replicator to do any verification
|
|
|
|
Err(InstructionError::InvalidArgument)?;
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
2019-04-04 12:01:09 -07:00
|
|
|
storage_account.proof_validation(entry_height, proofs, &mut rest)
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2019-03-22 14:30:18 -06:00
|
|
|
use crate::id;
|
2019-04-04 12:01:09 -07:00
|
|
|
use crate::storage_contract::{CheckedProof, Proof, ProofStatus, StorageContract};
|
2019-04-03 09:45:57 -06:00
|
|
|
use crate::storage_instruction;
|
2019-03-22 14:30:18 -06:00
|
|
|
use crate::ENTRIES_PER_SEGMENT;
|
2019-03-22 06:47:05 -06:00
|
|
|
use bincode::deserialize;
|
|
|
|
use solana_runtime::bank::Bank;
|
2019-03-22 22:02:00 -06:00
|
|
|
use solana_runtime::bank_client::BankClient;
|
2019-03-22 06:47:05 -06:00
|
|
|
use solana_sdk::account::{create_keyed_accounts, Account};
|
2019-04-11 00:25:14 -07:00
|
|
|
use solana_sdk::client::SyncClient;
|
2019-03-22 06:47:05 -06:00
|
|
|
use solana_sdk::genesis_block::GenesisBlock;
|
|
|
|
use solana_sdk::hash::{hash, Hash};
|
2019-03-22 22:02:00 -06:00
|
|
|
use solana_sdk::instruction::Instruction;
|
2019-03-22 06:47:05 -06:00
|
|
|
use solana_sdk::pubkey::Pubkey;
|
|
|
|
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
|
2019-04-03 09:45:57 -06:00
|
|
|
use solana_sdk::system_instruction;
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
fn test_instruction(
|
|
|
|
ix: &Instruction,
|
2019-03-22 06:47:05 -06:00
|
|
|
program_accounts: &mut [Account],
|
|
|
|
) -> Result<(), InstructionError> {
|
2019-03-22 22:02:00 -06:00
|
|
|
let mut keyed_accounts: Vec<_> = ix
|
|
|
|
.accounts
|
2019-03-22 06:47:05 -06:00
|
|
|
.iter()
|
|
|
|
.zip(program_accounts.iter_mut())
|
2019-03-22 22:02:00 -06:00
|
|
|
.map(|(account_meta, account)| {
|
|
|
|
KeyedAccount::new(&account_meta.pubkey, account_meta.is_signer, account)
|
|
|
|
})
|
2019-03-22 06:47:05 -06:00
|
|
|
.collect();
|
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
let ret = process_instruction(&id(), &mut keyed_accounts, &ix.data, 42);
|
2019-03-22 06:47:05 -06:00
|
|
|
info!("ret: {:?}", ret);
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_storage_tx() {
|
2019-03-30 21:37:33 -06:00
|
|
|
let pubkey = Pubkey::new_rand();
|
2019-03-22 22:02:00 -06:00
|
|
|
let mut accounts = [(pubkey, Account::default())];
|
2019-03-22 06:47:05 -06:00
|
|
|
let mut keyed_accounts = create_keyed_accounts(&mut accounts);
|
|
|
|
assert!(process_instruction(&id(), &mut keyed_accounts, &[], 42).is_err());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_serialize_overflow() {
|
2019-03-30 21:37:33 -06:00
|
|
|
let pubkey = Pubkey::new_rand();
|
2019-03-22 06:47:05 -06:00
|
|
|
let mut keyed_accounts = Vec::new();
|
|
|
|
let mut user_account = Account::default();
|
|
|
|
keyed_accounts.push(KeyedAccount::new(&pubkey, true, &mut user_account));
|
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::advertise_recent_blockhash(
|
2019-03-22 22:02:00 -06:00
|
|
|
&pubkey,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
ENTRIES_PER_SEGMENT,
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
2019-03-22 22:02:00 -06:00
|
|
|
process_instruction(&id(), &mut keyed_accounts, &ix.data, 42),
|
2019-04-02 13:08:55 -07:00
|
|
|
Err(InstructionError::InvalidAccountData)
|
2019-03-22 06:47:05 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_accounts_len() {
|
2019-03-30 21:37:33 -06:00
|
|
|
let pubkey = Pubkey::new_rand();
|
2019-03-22 06:47:05 -06:00
|
|
|
let mut accounts = [Account::default()];
|
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
let ix =
|
2019-04-03 09:45:57 -06:00
|
|
|
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
2019-03-22 22:02:00 -06:00
|
|
|
assert!(test_instruction(&ix, &mut accounts).is_err());
|
2019-03-22 06:47:05 -06:00
|
|
|
|
|
|
|
let mut accounts = [Account::default(), Account::default(), Account::default()];
|
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
assert!(test_instruction(&ix, &mut accounts).is_err());
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_submit_mining_invalid_entry_height() {
|
|
|
|
solana_logger::setup();
|
2019-03-30 21:37:33 -06:00
|
|
|
let pubkey = Pubkey::new_rand();
|
2019-03-22 06:47:05 -06:00
|
|
|
let mut accounts = [Account::default(), Account::default()];
|
|
|
|
accounts[1].data.resize(16 * 1024, 0);
|
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
let ix =
|
2019-04-03 09:45:57 -06:00
|
|
|
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
2019-03-22 06:47:05 -06:00
|
|
|
|
|
|
|
// Haven't seen a transaction to roll over the epoch, so this should fail
|
2019-03-22 22:02:00 -06:00
|
|
|
assert!(test_instruction(&ix, &mut accounts).is_err());
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_submit_mining_ok() {
|
|
|
|
solana_logger::setup();
|
2019-03-30 21:37:33 -06:00
|
|
|
let pubkey = Pubkey::new_rand();
|
2019-03-22 06:47:05 -06:00
|
|
|
let mut accounts = [Account::default(), Account::default()];
|
|
|
|
accounts[0].data.resize(16 * 1024, 0);
|
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
let ix =
|
2019-04-03 09:45:57 -06:00
|
|
|
storage_instruction::mining_proof(&pubkey, Hash::default(), 0, Signature::default());
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-03-22 22:02:00 -06:00
|
|
|
test_instruction(&ix, &mut accounts).unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_validate_mining() {
|
|
|
|
solana_logger::setup();
|
2019-04-02 13:08:55 -07:00
|
|
|
let (genesis_block, mint_keypair) = GenesisBlock::new(1000);
|
|
|
|
let mint_pubkey = mint_keypair.pubkey();
|
|
|
|
let replicator_keypair = Keypair::new();
|
|
|
|
let replicator = replicator_keypair.pubkey();
|
|
|
|
let validator_keypair = Keypair::new();
|
|
|
|
let validator = validator_keypair.pubkey();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
let mut bank = Bank::new(&genesis_block);
|
|
|
|
bank.add_instruction_processor(id(), process_instruction);
|
2019-03-22 06:47:05 -06:00
|
|
|
let entry_height = 0;
|
2019-04-02 13:08:55 -07:00
|
|
|
let bank_client = BankClient::new(&bank);
|
|
|
|
|
2019-04-03 15:51:05 -07:00
|
|
|
let ix = system_instruction::create_account(&mint_pubkey, &validator, 10, 4 * 1042, &id());
|
2019-04-03 15:11:08 -06:00
|
|
|
bank_client.send_instruction(&mint_keypair, ix).unwrap();
|
2019-04-02 13:08:55 -07:00
|
|
|
|
2019-04-03 15:51:05 -07:00
|
|
|
let ix = system_instruction::create_account(&mint_pubkey, &replicator, 10, 4 * 1042, &id());
|
2019-04-03 15:11:08 -06:00
|
|
|
bank_client.send_instruction(&mint_keypair, ix).unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::advertise_recent_blockhash(
|
2019-04-02 13:08:55 -07:00
|
|
|
&validator,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
ENTRIES_PER_SEGMENT,
|
|
|
|
);
|
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::mining_proof(
|
2019-04-02 13:08:55 -07:00
|
|
|
&replicator,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
entry_height,
|
|
|
|
Signature::default(),
|
|
|
|
);
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&replicator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::advertise_recent_blockhash(
|
2019-04-02 13:08:55 -07:00
|
|
|
&validator,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
ENTRIES_PER_SEGMENT * 2,
|
|
|
|
);
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
let ix = storage_instruction::proof_validation(
|
|
|
|
&validator,
|
|
|
|
entry_height,
|
2019-04-03 15:51:05 -07:00
|
|
|
vec![CheckedProof {
|
|
|
|
proof: Proof {
|
|
|
|
id: replicator,
|
|
|
|
signature: Signature::default(),
|
|
|
|
sha_state: Hash::default(),
|
|
|
|
},
|
2019-04-02 13:08:55 -07:00
|
|
|
status: ProofStatus::Valid,
|
|
|
|
}],
|
|
|
|
);
|
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::advertise_recent_blockhash(
|
2019-04-02 13:08:55 -07:00
|
|
|
&validator,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
ENTRIES_PER_SEGMENT * 3,
|
|
|
|
);
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
let ix = storage_instruction::reward_claim(&validator, entry_height);
|
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// TODO enable when rewards are working
|
|
|
|
// assert_eq!(bank.get_balance(&validator), TOTAL_VALIDATOR_REWARDS);
|
|
|
|
|
|
|
|
// tick the bank into the next storage epoch so that rewards can be claimed
|
|
|
|
for _ in 0..=ENTRIES_PER_SEGMENT {
|
|
|
|
bank.register_tick(&bank.last_blockhash());
|
|
|
|
}
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 15:51:05 -07:00
|
|
|
let ix = storage_instruction::reward_claim(&replicator, entry_height);
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&replicator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// TODO enable when rewards are working
|
|
|
|
// assert_eq!(bank.get_balance(&replicator), TOTAL_REPLICATOR_REWARDS);
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
|
2019-04-03 16:36:10 -06:00
|
|
|
fn get_storage_entry_height<C: SyncClient>(client: &C, account: &Pubkey) -> u64 {
|
2019-04-03 21:40:29 -06:00
|
|
|
match client.get_account_data(&account).unwrap() {
|
2019-04-03 16:36:10 -06:00
|
|
|
Some(storage_system_account_data) => {
|
|
|
|
let contract = deserialize(&storage_system_account_data);
|
2019-03-22 20:16:44 -06:00
|
|
|
if let Ok(contract) = contract {
|
2019-04-02 13:08:55 -07:00
|
|
|
match contract {
|
|
|
|
StorageContract::ValidatorStorage { entry_height, .. } => {
|
|
|
|
return entry_height;
|
|
|
|
}
|
|
|
|
_ => info!("error in reading entry_height"),
|
|
|
|
}
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
None => {
|
|
|
|
info!("error in reading entry_height");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:36:10 -06:00
|
|
|
fn get_storage_blockhash<C: SyncClient>(client: &C, account: &Pubkey) -> Hash {
|
2019-04-03 21:40:29 -06:00
|
|
|
if let Some(storage_system_account_data) = client.get_account_data(&account).unwrap() {
|
2019-04-03 16:36:10 -06:00
|
|
|
let contract = deserialize(&storage_system_account_data);
|
2019-03-22 20:16:44 -06:00
|
|
|
if let Ok(contract) = contract {
|
2019-04-02 13:08:55 -07:00
|
|
|
match contract {
|
|
|
|
StorageContract::ValidatorStorage { hash, .. } => {
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Hash::default()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_bank_storage() {
|
2019-04-02 13:08:55 -07:00
|
|
|
let (genesis_block, mint_keypair) = GenesisBlock::new(1000);
|
|
|
|
let mint_pubkey = mint_keypair.pubkey();
|
|
|
|
let replicator_keypair = Keypair::new();
|
|
|
|
let replicator_pubkey = replicator_keypair.pubkey();
|
|
|
|
let validator_keypair = Keypair::new();
|
|
|
|
let validator_pubkey = validator_keypair.pubkey();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-03-27 09:15:37 -06:00
|
|
|
let mut bank = Bank::new(&genesis_block);
|
|
|
|
bank.add_instruction_processor(id(), process_instruction);
|
2019-03-27 07:34:01 -06:00
|
|
|
let bank_client = BankClient::new(&bank);
|
|
|
|
|
2019-03-22 06:47:05 -06:00
|
|
|
let x = 42;
|
|
|
|
let blockhash = genesis_block.hash();
|
|
|
|
let x2 = x * 2;
|
|
|
|
let storage_blockhash = hash(&[x2]);
|
|
|
|
|
|
|
|
bank.register_tick(&blockhash);
|
|
|
|
|
2019-03-27 07:34:01 -06:00
|
|
|
bank_client
|
2019-04-02 13:08:55 -07:00
|
|
|
.transfer(10, &mint_keypair, &replicator_pubkey)
|
2019-03-27 07:34:01 -06:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
let ix = system_instruction::create_account(
|
|
|
|
&mint_pubkey,
|
|
|
|
&replicator_pubkey,
|
|
|
|
1,
|
|
|
|
4 * 1024,
|
|
|
|
&id(),
|
|
|
|
);
|
|
|
|
|
2019-04-03 15:11:08 -06:00
|
|
|
bank_client.send_instruction(&mint_keypair, ix).unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
2019-04-03 15:51:05 -07:00
|
|
|
let ix =
|
|
|
|
system_instruction::create_account(&mint_pubkey, &validator_pubkey, 1, 4 * 1024, &id());
|
2019-04-02 13:08:55 -07:00
|
|
|
|
2019-04-03 15:11:08 -06:00
|
|
|
bank_client.send_instruction(&mint_keypair, ix).unwrap();
|
2019-03-22 22:02:00 -06:00
|
|
|
|
2019-04-03 09:45:57 -06:00
|
|
|
let ix = storage_instruction::advertise_recent_blockhash(
|
2019-04-02 13:08:55 -07:00
|
|
|
&validator_pubkey,
|
2019-03-22 06:47:05 -06:00
|
|
|
storage_blockhash,
|
|
|
|
ENTRIES_PER_SEGMENT,
|
|
|
|
);
|
|
|
|
|
2019-04-02 13:08:55 -07:00
|
|
|
bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&validator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
|
|
|
let entry_height = 0;
|
2019-04-03 15:51:05 -07:00
|
|
|
let ix = storage_instruction::mining_proof(
|
2019-04-02 13:08:55 -07:00
|
|
|
&replicator_pubkey,
|
2019-03-22 06:47:05 -06:00
|
|
|
Hash::default(),
|
|
|
|
entry_height,
|
|
|
|
Signature::default(),
|
|
|
|
);
|
2019-04-02 13:08:55 -07:00
|
|
|
let _result = bank_client
|
2019-04-03 15:11:08 -06:00
|
|
|
.send_instruction(&replicator_keypair, ix)
|
2019-04-02 13:08:55 -07:00
|
|
|
.unwrap();
|
2019-03-22 06:47:05 -06:00
|
|
|
|
|
|
|
assert_eq!(
|
2019-04-03 16:36:10 -06:00
|
|
|
get_storage_entry_height(&bank_client, &validator_pubkey),
|
2019-03-22 06:47:05 -06:00
|
|
|
ENTRIES_PER_SEGMENT
|
|
|
|
);
|
2019-04-02 13:08:55 -07:00
|
|
|
assert_eq!(
|
2019-04-03 16:36:10 -06:00
|
|
|
get_storage_blockhash(&bank_client, &validator_pubkey),
|
2019-04-02 13:08:55 -07:00
|
|
|
storage_blockhash
|
|
|
|
);
|
|
|
|
}
|
2019-03-22 06:47:05 -06:00
|
|
|
}
|