block_hash => blockhash

This commit is contained in:
Michael Vines
2019-03-02 10:25:16 -08:00
committed by Greg Fitzgerald
parent 0f1582c196
commit a94880574b
55 changed files with 591 additions and 597 deletions

View File

@ -66,7 +66,7 @@ impl BankingStage {
// Single thread to generate entries from many banks.
// This thread talks to poh_service and broadcasts the entries once they have been recorded.
// Once an entry has been recorded, its block_hash is registered with the bank.
// Once an entry has been recorded, its blockhash is registered with the bank.
let exit = Arc::new(AtomicBool::new(false));
// Single thread to compute confirmation
@ -361,7 +361,7 @@ mod tests {
let exit = Arc::new(AtomicBool::new(false));
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(
bank.tick_height(),
bank.last_block_hash(),
bank.last_blockhash(),
)));
let poh_service = PohService::new(
poh_recorder.clone(),
@ -394,7 +394,7 @@ mod tests {
let (mut genesis_block, _mint_keypair) = GenesisBlock::new(2);
genesis_block.ticks_per_slot = 4;
let bank = Arc::new(Bank::new(&genesis_block));
let start_hash = bank.last_block_hash();
let start_hash = bank.last_blockhash();
let (verified_sender, verified_receiver) = channel();
let (poh_recorder, poh_service) = create_test_recorder(&bank);
let (banking_stage, entry_receiver) = BankingStage::new(
@ -413,7 +413,7 @@ mod tests {
.collect();
assert_eq!(entries.len(), genesis_block.ticks_per_slot as usize - 1);
assert!(entries.verify(&start_hash));
assert_eq!(entries[entries.len() - 1].hash, bank.last_block_hash());
assert_eq!(entries[entries.len() - 1].hash, bank.last_blockhash());
banking_stage.join().unwrap();
poh_service.close().unwrap();
}
@ -422,7 +422,7 @@ mod tests {
fn test_banking_stage_entries_only() {
let (genesis_block, mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let start_hash = bank.last_block_hash();
let start_hash = bank.last_blockhash();
let (verified_sender, verified_receiver) = channel();
let (poh_recorder, poh_service) = create_test_recorder(&bank);
let (banking_stage, entry_receiver) = BankingStage::new(
@ -464,11 +464,11 @@ mod tests {
assert!(entries.len() >= 1);
let mut block_hash = start_hash;
let mut blockhash = start_hash;
entries.iter().for_each(|entries| {
assert_eq!(entries.len(), 1);
assert!(entries.verify(&block_hash));
block_hash = entries.last().unwrap().hash;
assert!(entries.verify(&blockhash));
blockhash = entries.last().unwrap().hash;
});
drop(entry_receiver);
banking_stage.join().unwrap();
@ -636,7 +636,7 @@ mod tests {
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(
bank.tick_height(),
bank.last_block_hash(),
bank.last_blockhash(),
)));
poh_recorder.lock().unwrap().set_working_bank(working_bank);
let pubkey = Keypair::new().pubkey();
@ -691,7 +691,7 @@ mod tests {
};
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(
bank.tick_height(),
bank.last_block_hash(),
bank.last_blockhash(),
)));
poh_recorder.lock().unwrap().set_working_bank(working_bank);

View File

@ -71,7 +71,7 @@ pub trait BlockstreamEvents {
slot: u64,
tick_height: u64,
leader_id: Pubkey,
block_hash: Hash,
blockhash: Hash,
) -> Result<()>;
}
@ -109,7 +109,7 @@ where
slot: u64,
tick_height: u64,
leader_id: Pubkey,
block_hash: Hash,
blockhash: Hash,
) -> Result<()> {
let payload = format!(
r#"{{"dt":"{}","t":"block","s":{},"h":{},"l":"{:?}","id":"{:?}"}}"#,
@ -117,7 +117,7 @@ where
slot,
tick_height,
leader_id,
block_hash,
blockhash,
);
self.output.write(payload)?;
Ok(())
@ -163,7 +163,7 @@ mod test {
let blockstream = MockBlockstream::new("test_stream".to_string());
let ticks_per_slot = 5;
let mut block_hash = Hash::default();
let mut blockhash = Hash::default();
let mut entries = Vec::new();
let mut expected_entries = Vec::new();
@ -175,12 +175,12 @@ mod test {
for tick_height in tick_height_initial..=tick_height_final {
if tick_height == 5 {
blockstream
.emit_block_event(curr_slot, tick_height - 1, leader_id, block_hash)
.emit_block_event(curr_slot, tick_height - 1, leader_id, blockhash)
.unwrap();
curr_slot += 1;
}
let entry = Entry::new(&mut block_hash, 1, vec![]); // just ticks
block_hash = entry.hash;
let entry = Entry::new(&mut blockhash, 1, vec![]); // just ticks
blockhash = entry.hash;
blockstream
.emit_entry_event(curr_slot, tick_height, leader_id, &entry)
.unwrap();

View File

@ -125,7 +125,7 @@ mod test {
let (mut genesis_block, _mint_keypair) = GenesisBlock::new(1000);
genesis_block.ticks_per_slot = ticks_per_slot;
let (ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot).unwrap();
// Set up blockstream
@ -138,12 +138,12 @@ mod test {
let mut entries = create_ticks(4, Hash::default());
let keypair = Keypair::new();
let mut block_hash = entries[3].hash;
let mut blockhash = entries[3].hash;
let tx = SystemTransaction::new_account(&keypair, keypair.pubkey(), 1, Hash::default(), 0);
let entry = Entry::new(&mut block_hash, 1, vec![tx]);
block_hash = entry.hash;
let entry = Entry::new(&mut blockhash, 1, vec![tx]);
blockhash = entry.hash;
entries.push(entry);
let final_tick = create_ticks(1, block_hash);
let final_tick = create_ticks(1, blockhash);
entries.extend_from_slice(&final_tick);
let expected_entries = entries.clone();

View File

@ -689,7 +689,7 @@ impl Blocktree {
db_iterator.seek_to_first();
Ok(EntryIterator {
db_iterator,
block_hash: None,
blockhash: None,
})
}
@ -1250,7 +1250,7 @@ struct EntryIterator {
// TODO: remove me when replay_stage is iterating by block (Blocktree)
// this verification is duplicating that of replay_stage, which
// can do this in parallel
block_hash: Option<Hash>,
blockhash: Option<Hash>,
// https://github.com/rust-rocksdb/rust-rocksdb/issues/234
// rocksdb issue: the _blocktree member must be lower in the struct to prevent a crash
// when the db_iterator member above is dropped.
@ -1267,13 +1267,13 @@ impl Iterator for EntryIterator {
if self.db_iterator.valid() {
if let Some(value) = self.db_iterator.value() {
if let Ok(entry) = deserialize::<Entry>(&value[BLOB_HEADER_SIZE..]) {
if let Some(block_hash) = self.block_hash {
if !entry.verify(&block_hash) {
if let Some(blockhash) = self.blockhash {
if !entry.verify(&blockhash) {
return None;
}
}
self.db_iterator.next();
self.block_hash = Some(entry.hash);
self.blockhash = Some(entry.hash);
return Some(entry);
}
}
@ -1284,7 +1284,7 @@ impl Iterator for EntryIterator {
// Creates a new ledger with slot 0 full of ticks (and only ticks).
//
// Returns the block_hash that can be used to append entries with.
// Returns the blockhash that can be used to append entries with.
pub fn create_new_ledger(ledger_path: &str, genesis_block: &GenesisBlock) -> Result<Hash> {
let ticks_per_slot = genesis_block.ticks_per_slot;
Blocktree::destroy(ledger_path)?;
@ -1362,8 +1362,8 @@ macro_rules! create_new_tmp_ledger {
// ticks)
pub fn create_new_tmp_ledger(name: &str, genesis_block: &GenesisBlock) -> (String, Hash) {
let ledger_path = get_tmp_ledger_path(name);
let block_hash = create_new_ledger(&ledger_path, genesis_block).unwrap();
(ledger_path, block_hash)
let blockhash = create_new_ledger(&ledger_path, genesis_block).unwrap();
(ledger_path, blockhash)
}
#[macro_export]

View File

@ -115,7 +115,7 @@ pub fn process_blocktree(
let slot = 0;
let bank = Arc::new(Bank::new_with_paths(&genesis_block, account_paths));
let entry_height = 0;
let last_entry_hash = bank.last_block_hash();
let last_entry_hash = bank.last_blockhash();
vec![(slot, bank, entry_height, last_entry_hash)]
};
@ -286,7 +286,7 @@ mod tests {
*/
// Create a new ledger with slot 0 full of ticks
let (ledger_path, mut block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, mut blockhash) = create_new_tmp_ledger!(&genesis_block);
debug!("ledger_path: {:?}", ledger_path);
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot)
@ -297,8 +297,8 @@ mod tests {
{
let parent_slot = 0;
let slot = 1;
let mut entries = create_ticks(ticks_per_slot, block_hash);
block_hash = entries.last().unwrap().hash;
let mut entries = create_ticks(ticks_per_slot, blockhash);
blockhash = entries.last().unwrap().hash;
entries.pop();
@ -307,7 +307,7 @@ mod tests {
}
// slot 2, points at slot 1
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, block_hash);
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, blockhash);
let (mut _bank_forks, bank_forks_info) =
process_blocktree(&genesis_block, &blocktree, None).unwrap();
@ -330,9 +330,9 @@ mod tests {
let ticks_per_slot = genesis_block.ticks_per_slot;
// Create a new ledger with slot 0 full of ticks
let (ledger_path, block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, blockhash) = create_new_tmp_ledger!(&genesis_block);
debug!("ledger_path: {:?}", ledger_path);
let mut last_entry_hash = block_hash;
let mut last_entry_hash = blockhash;
/*
Build a blocktree in the ledger with the following fork structure:
@ -443,7 +443,7 @@ mod tests {
// First, ensure the TX is rejected because of the unregistered last ID
assert_eq!(
bank.process_transaction(&tx),
Err(BankError::BlockHashNotFound)
Err(BankError::BlockhashNotFound)
);
// Now ensure the TX is accepted despite pointing to the ID of an empty entry.
@ -460,12 +460,12 @@ mod tests {
debug!("ledger_path: {:?}", ledger_path);
let mut entries = vec![];
let block_hash = genesis_block.hash();
let blockhash = genesis_block.hash();
for _ in 0..3 {
// Transfer one token from the mint to a random account
let keypair = Keypair::new();
let tx =
SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, block_hash, 0);
SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, blockhash, 0);
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
last_entry_hash = entry.hash;
entries.push(entry);
@ -473,7 +473,7 @@ mod tests {
// Add a second Transaction that will produce a
// ProgramError<0, ResultWithNegativeTokens> error when processed
let keypair2 = Keypair::new();
let tx = SystemTransaction::new_account(&keypair, keypair2.pubkey(), 42, block_hash, 0);
let tx = SystemTransaction::new_account(&keypair, keypair2.pubkey(), 42, blockhash, 0);
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
last_entry_hash = entry.hash;
entries.push(entry);
@ -501,14 +501,14 @@ mod tests {
let bank = bank_forks[1].clone();
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 50 - 3);
assert_eq!(bank.tick_height(), 2 * genesis_block.ticks_per_slot - 1);
assert_eq!(bank.last_block_hash(), entries.last().unwrap().hash);
assert_eq!(bank.last_blockhash(), entries.last().unwrap().hash);
}
#[test]
fn test_process_ledger_with_one_tick_per_slot() {
let (mut genesis_block, _mint_keypair) = GenesisBlock::new(123);
genesis_block.ticks_per_slot = 1;
let (ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let blocktree = Blocktree::open(&ledger_path).unwrap();
let (bank_forks, bank_forks_info) =
@ -545,29 +545,29 @@ mod tests {
let keypair1 = Keypair::new();
let keypair2 = Keypair::new();
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
// ensure bank can process 2 entries that have a common account and no tick is registered
let tx = SystemTransaction::new_account(
&mint_keypair,
keypair1.pubkey(),
2,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_1 = next_entry(&block_hash, 1, vec![tx]);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_account(
&mint_keypair,
keypair2.pubkey(),
2,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
assert_eq!(par_process_entries(&bank, &[entry_1, entry_2]), Ok(()));
assert_eq!(bank.get_balance(&keypair1.pubkey()), 2);
assert_eq!(bank.get_balance(&keypair2.pubkey()), 2);
assert_eq!(bank.last_block_hash(), block_hash);
assert_eq!(bank.last_blockhash(), blockhash);
}
#[test]
@ -580,23 +580,23 @@ mod tests {
// fund: put 4 in each of 1 and 2
assert_matches!(
bank.transfer(4, &mint_keypair, keypair1.pubkey(), bank.last_block_hash()),
bank.transfer(4, &mint_keypair, keypair1.pubkey(), bank.last_blockhash()),
Ok(_)
);
assert_matches!(
bank.transfer(4, &mint_keypair, keypair2.pubkey(), bank.last_block_hash()),
bank.transfer(4, &mint_keypair, keypair2.pubkey(), bank.last_blockhash()),
Ok(_)
);
// construct an Entry whose 2nd transaction would cause a lock conflict with previous entry
let entry_1_to_mint = next_entry(
&bank.last_block_hash(),
&bank.last_blockhash(),
1,
vec![SystemTransaction::new_account(
&keypair1,
mint_keypair.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
)],
);
@ -609,14 +609,14 @@ mod tests {
&keypair2,
keypair3.pubkey(),
2,
bank.last_block_hash(),
bank.last_blockhash(),
0,
), // should be fine
SystemTransaction::new_account(
&keypair1,
mint_keypair.pubkey(),
2,
bank.last_block_hash(),
bank.last_blockhash(),
0,
), // will collide
],
@ -646,7 +646,7 @@ mod tests {
&mint_keypair,
keypair1.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
@ -654,33 +654,33 @@ mod tests {
&mint_keypair,
keypair2.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
// ensure bank can process 2 entries that do not have a common account and no tick is registered
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_account(
&keypair1,
keypair3.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_1 = next_entry(&block_hash, 1, vec![tx]);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_account(
&keypair2,
keypair4.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
assert_eq!(par_process_entries(&bank, &[entry_1, entry_2]), Ok(()));
assert_eq!(bank.get_balance(&keypair3.pubkey()), 1);
assert_eq!(bank.get_balance(&keypair4.pubkey()), 1);
assert_eq!(bank.last_block_hash(), block_hash);
assert_eq!(bank.last_blockhash(), blockhash);
}
#[test]
@ -697,7 +697,7 @@ mod tests {
&mint_keypair,
keypair1.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
@ -705,25 +705,25 @@ mod tests {
&mint_keypair,
keypair2.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
let block_hash = bank.last_block_hash();
while block_hash == bank.last_block_hash() {
let blockhash = bank.last_blockhash();
while blockhash == bank.last_blockhash() {
bank.register_tick(&Hash::default());
}
// ensure bank can process 2 entries that do not have a common account and tick is registered
let tx = SystemTransaction::new_account(&keypair2, keypair3.pubkey(), 1, block_hash, 0);
let entry_1 = next_entry(&block_hash, 1, vec![tx]);
let tx = SystemTransaction::new_account(&keypair2, keypair3.pubkey(), 1, blockhash, 0);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tick = next_entry(&entry_1.hash, 1, vec![]);
let tx = SystemTransaction::new_account(
&keypair1,
keypair4.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_2 = next_entry(&tick.hash, 1, vec![tx]);
@ -739,7 +739,7 @@ mod tests {
&keypair2,
keypair3.pubkey(),
1,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]);

View File

@ -27,7 +27,7 @@ pub fn spend_and_verify_all_nodes(
&funding_keypair,
random_keypair.pubkey(),
1,
client.get_recent_block_hash(),
client.get_recent_blockhash(),
0,
);
let sig = client

View File

@ -127,11 +127,11 @@ impl Fullnode {
info!(
"starting PoH... {} {}",
bank.tick_height(),
bank.last_block_hash(),
bank.last_blockhash(),
);
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(
bank.tick_height(),
bank.last_block_hash(),
bank.last_blockhash(),
)));
let poh_service = PohService::new(poh_recorder.clone(), &config.tick_config, exit.clone());
@ -335,12 +335,12 @@ impl Fullnode {
//instead of here
info!(
"reset PoH... {} {}",
rotation_info.tick_height, rotation_info.block_hash
rotation_info.tick_height, rotation_info.blockhash
);
self.poh_recorder
.lock()
.unwrap()
.reset(rotation_info.tick_height, rotation_info.block_hash);
.reset(rotation_info.tick_height, rotation_info.blockhash);
let slot = rotation_info.slot;
self.rotate(rotation_info);
debug!("role transition complete");
@ -441,7 +441,7 @@ pub fn make_active_set_entries(
token_source: &Keypair,
stake: u64,
slot_height_to_vote_on: u64,
block_hash: &Hash,
blockhash: &Hash,
num_ending_ticks: u64,
) -> (Vec<Entry>, VotingKeypair) {
// 1) Assume the active_keypair node has no tokens staked
@ -449,10 +449,10 @@ pub fn make_active_set_entries(
&token_source,
active_keypair.pubkey(),
stake,
*block_hash,
*blockhash,
0,
);
let mut last_entry_hash = *block_hash;
let mut last_entry_hash = *blockhash;
let transfer_entry = next_entry_mut(&mut last_entry_hash, 1, vec![transfer_tx]);
// 2) Create and register a vote account for active_keypair
@ -460,12 +460,11 @@ pub fn make_active_set_entries(
let vote_account_id = voting_keypair.pubkey();
let new_vote_account_tx =
VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *block_hash, 1, 1);
VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *blockhash, 1, 1);
let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]);
// 3) Create vote entry
let vote_tx =
VoteTransaction::new_vote(&voting_keypair, slot_height_to_vote_on, *block_hash, 0);
let vote_tx = VoteTransaction::new_vote(&voting_keypair, slot_height_to_vote_on, *blockhash, 0);
let vote_entry = next_entry_mut(&mut last_entry_hash, 1, vec![vote_tx]);
// 4) Create `num_ending_ticks` empty ticks
@ -496,7 +495,7 @@ mod tests {
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
let (genesis_block, _mint_keypair) =
GenesisBlock::new_with_leader(10_000, leader_keypair.pubkey(), 1000);
let (validator_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (validator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let validator = Fullnode::new(
validator_node,
@ -522,7 +521,7 @@ mod tests {
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
let (genesis_block, _mint_keypair) =
GenesisBlock::new_with_leader(10_000, leader_keypair.pubkey(), 1000);
let (validator_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (validator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
ledger_paths.push(validator_ledger_path.clone());
Fullnode::new(
validator_node,
@ -570,7 +569,7 @@ mod tests {
genesis_block.ticks_per_slot = ticks_per_slot;
genesis_block.slots_per_epoch = slots_per_epoch;
let (bootstrap_leader_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (bootstrap_leader_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
// Start the bootstrap leader
let bootstrap_leader = Fullnode::new(
@ -667,7 +666,7 @@ mod tests {
let leader_keypair = Arc::new(Keypair::new());
let validator_keypair = Arc::new(Keypair::new());
let fullnode_config = FullnodeConfig::default();
let (leader_node, validator_node, validator_ledger_path, ledger_initial_len, block_hash) =
let (leader_node, validator_node, validator_ledger_path, ledger_initial_len, blockhash) =
setup_leader_validator(&leader_keypair, &validator_keypair, ticks_per_slot, 0);
let leader_id = leader_keypair.pubkey();
@ -707,7 +706,7 @@ mod tests {
&leader_id,
blobs_to_send,
ledger_initial_len,
block_hash,
blockhash,
&tvu_address,
)
.into_iter()
@ -757,7 +756,7 @@ mod tests {
GenesisBlock::new_with_leader(10_000, leader_node.info.id, 500);
genesis_block.ticks_per_slot = ticks_per_slot;
let (ledger_path, block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, blockhash) = create_new_tmp_ledger!(&genesis_block);
// Add entries so that the validator is in the active set, then finish up the slot with
// ticks (and maybe add extra slots full of empty ticks)
@ -766,12 +765,12 @@ mod tests {
&mint_keypair,
10,
0,
&block_hash,
&blockhash,
ticks_per_slot * (num_ending_slots + 1),
);
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot).unwrap();
let block_hash = entries.last().unwrap().hash;
let blockhash = entries.last().unwrap().hash;
let entry_height = ticks_per_slot + entries.len() as u64;
blocktree.write_entries(1, 0, 0, entries).unwrap();
@ -780,7 +779,7 @@ mod tests {
validator_node,
ledger_path,
entry_height,
block_hash,
blockhash,
)
}
}

View File

@ -154,7 +154,7 @@ mod tests {
tick_hash = hash(&serialize(&tick_hash).unwrap());
bank.register_tick(&tick_hash);
}
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
// Create a total of 10 vote accounts, each will have a balance of 1 (after giving 1 to
// their vote account), for a total staking pool of 10 tokens.
@ -166,7 +166,7 @@ mod tests {
let voting_pubkey = voting_keypair.pubkey();
// Give the validator some tokens
bank.transfer(2, &mint_keypair, validator_keypair.pubkey(), block_hash)
bank.transfer(2, &mint_keypair, validator_keypair.pubkey(), blockhash)
.unwrap();
new_vote_account(&validator_keypair, &voting_pubkey, &bank, 1);
@ -188,7 +188,7 @@ mod tests {
// Get another validator to vote, so we now have 2/3 consensus
let voting_keypair = &vote_accounts[7].0;
let vote_tx = VoteTransaction::new_vote(voting_keypair, 7, block_hash, 0);
let vote_tx = VoteTransaction::new_vote(voting_keypair, 7, blockhash, 0);
bank.process_transaction(&vote_tx).unwrap();
LeaderConfirmationService::compute_confirmation(

View File

@ -34,7 +34,7 @@ impl LocalCluster {
let leader_node = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
let (genesis_block, mint_keypair) =
GenesisBlock::new_with_leader(cluster_lamports, leader_pubkey, lamports_per_node);
let (genesis_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (genesis_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let leader_ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
let mut ledger_paths = vec![];
ledger_paths.push(genesis_ledger_path.clone());
@ -121,10 +121,10 @@ impl LocalCluster {
dest_pubkey: &Pubkey,
lamports: u64,
) -> u64 {
trace!("getting leader block_hash");
let block_hash = client.get_recent_block_hash();
trace!("getting leader blockhash");
let blockhash = client.get_recent_blockhash();
let mut tx =
SystemTransaction::new_account(&source_keypair, *dest_pubkey, lamports, block_hash, 0);
SystemTransaction::new_account(&source_keypair, *dest_pubkey, lamports, blockhash, 0);
info!(
"executing transfer of {} from {} to {}",
lamports,
@ -148,7 +148,7 @@ impl LocalCluster {
let mut transaction = VoteTransaction::fund_staking_account(
from_account,
vote_account,
client.get_recent_block_hash(),
client.get_recent_blockhash(),
amount,
1,
);

View File

@ -52,14 +52,14 @@ impl PohRecorder {
}
// synchronize PoH with a bank
pub fn reset(&mut self, tick_height: u64, block_hash: Hash) {
pub fn reset(&mut self, tick_height: u64, blockhash: Hash) {
let mut cache = vec![];
info!(
"reset poh from: {},{} to: {},{}",
self.poh.hash, self.poh.tick_height, block_hash, tick_height,
self.poh.hash, self.poh.tick_height, blockhash, tick_height,
);
std::mem::swap(&mut cache, &mut self.tick_cache);
self.poh = Poh::new(block_hash, tick_height);
self.poh = Poh::new(blockhash, tick_height);
}
pub fn set_working_bank(&mut self, working_bank: WorkingBank) {
@ -223,7 +223,7 @@ mod tests {
fn test_poh_recorder_clear() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, _) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -243,7 +243,7 @@ mod tests {
fn test_poh_recorder_tick_sent_after_min() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -274,7 +274,7 @@ mod tests {
fn test_poh_recorder_tick_sent_upto_and_including_max() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -304,7 +304,7 @@ mod tests {
fn test_poh_recorder_record_to_early() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -326,7 +326,7 @@ mod tests {
fn test_poh_recorder_record_at_min_passes() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -357,7 +357,7 @@ mod tests {
fn test_poh_recorder_record_at_max_fails() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);
@ -385,7 +385,7 @@ mod tests {
fn test_poh_cache_on_disconnect() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let mut poh_recorder = PohRecorder::new(0, prev_hash);

View File

@ -124,7 +124,7 @@ mod tests {
fn test_poh_service() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(bank.tick_height(), prev_hash)));
let exit = Arc::new(AtomicBool::new(false));
@ -204,7 +204,7 @@ mod tests {
fn test_poh_service_drops_working_bank() {
let (genesis_block, _mint_keypair) = GenesisBlock::new(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_block_hash();
let prev_hash = bank.last_blockhash();
let (entry_sender, entry_receiver) = channel();
let poh_recorder = Arc::new(Mutex::new(PohRecorder::new(bank.tick_height(), prev_hash)));
let exit = Arc::new(AtomicBool::new(false));

View File

@ -137,7 +137,7 @@ impl ReplayStage {
let vote = VoteTransaction::new_vote(
keypair,
*latest_slot_vote,
parent.last_block_hash(),
parent.last_blockhash(),
0,
);
cluster_info.write().unwrap().push_vote(vote);
@ -152,7 +152,7 @@ impl ReplayStage {
);
to_leader_sender.send(TvuRotationInfo {
tick_height: parent.tick_height(),
block_hash: parent.last_block_hash(),
blockhash: parent.last_blockhash(),
slot: next_slot,
leader_id: next_leader,
})?;
@ -208,7 +208,7 @@ impl ReplayStage {
let bank_id = bank.slot();
let bank_progress = &mut progress
.entry(bank_id)
.or_insert((bank.last_block_hash(), 0));
.or_insert((bank.last_blockhash(), 0));
blocktree.get_slot_entries_with_blob_count(bank_id, bank_progress.1 as u64, None)
}
@ -221,7 +221,7 @@ impl ReplayStage {
) -> result::Result<()> {
let bank_progress = &mut progress
.entry(bank.slot())
.or_insert((bank.last_block_hash(), 0));
.or_insert((bank.last_blockhash(), 0));
let result = Self::verify_and_process_entries(&bank, &entries, &bank_progress.0);
bank_progress.1 += num;
if let Some(last_entry) = entries.last() {
@ -257,7 +257,7 @@ impl ReplayStage {
entries.len(),
bank.tick_height(),
last_entry,
bank.last_block_hash()
bank.last_blockhash()
);
return Err(result::Error::BlobError(BlobError::VerificationFailed));
}
@ -333,7 +333,7 @@ mod test {
let (genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(10_000, leader_id, 500);
let (my_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (my_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
// Set up the cluster info
let cluster_info_me = Arc::new(RwLock::new(ClusterInfo::new(my_node.info.clone())));
@ -362,11 +362,11 @@ mod test {
);
let keypair = voting_keypair.as_ref();
let vote = VoteTransaction::new_vote(keypair, 0, bank.last_block_hash(), 0);
let vote = VoteTransaction::new_vote(keypair, 0, bank.last_blockhash(), 0);
cluster_info_me.write().unwrap().push_vote(vote);
info!("Send ReplayStage an entry, should see it on the ledger writer receiver");
let next_tick = create_ticks(1, bank.last_block_hash());
let next_tick = create_ticks(1, bank.last_blockhash());
blocktree.write_entries(1, 0, 0, next_tick.clone()).unwrap();
let received_tick = ledger_writer_recv
@ -387,10 +387,10 @@ mod test {
let (forward_entry_sender, forward_entry_receiver) = channel();
let genesis_block = GenesisBlock::new(10_000).0;
let bank = Arc::new(Bank::new(&genesis_block));
let mut block_hash = bank.last_block_hash();
let mut blockhash = bank.last_blockhash();
let mut entries = Vec::new();
for _ in 0..5 {
let entry = next_entry_mut(&mut block_hash, 1, vec![]); //just ticks
let entry = next_entry_mut(&mut blockhash, 1, vec![]); //just ticks
entries.push(entry);
}

View File

@ -80,7 +80,7 @@ pub fn sample_file(in_path: &Path, sample_offsets: &[u64]) -> io::Result<Hash> {
Ok(hasher.result())
}
fn get_entry_heights_from_block_hash(
fn get_entry_heights_from_blockhash(
signature: &ring::signature::Signature,
storage_entry_height: u64,
) -> u64 {
@ -158,11 +158,11 @@ impl Replicator {
info!("Got leader: {:?}", leader);
let (storage_block_hash, storage_entry_height) =
Self::poll_for_block_hash_and_entry_height(&cluster_info)?;
let (storage_blockhash, storage_entry_height) =
Self::poll_for_blockhash_and_entry_height(&cluster_info)?;
let signature = keypair.sign(storage_block_hash.as_ref());
let entry_height = get_entry_heights_from_block_hash(&signature, storage_entry_height);
let signature = keypair.sign(storage_blockhash.as_ref());
let entry_height = get_entry_heights_from_blockhash(&signature, storage_entry_height);
info!("replicating entry_height: {}", entry_height);
@ -254,12 +254,12 @@ impl Replicator {
match sample_file(&ledger_data_file_encrypted, &sampling_offsets) {
Ok(hash) => {
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
info!("sampled hash: {}", hash);
let mut tx = StorageTransaction::new_mining_proof(
&keypair,
hash,
block_hash,
blockhash,
entry_height,
Signature::new(signature.as_ref()),
);
@ -326,7 +326,7 @@ impl Replicator {
}
}
fn poll_for_block_hash_and_entry_height(
fn poll_for_blockhash_and_entry_height(
cluster_info: &Arc<RwLock<ClusterInfo>>,
) -> Result<(String, u64)> {
for _ in 0..10 {
@ -338,8 +338,8 @@ impl Replicator {
RpcClient::new_from_socket(rpc_peers[node_idx].rpc)
};
let storage_block_hash = rpc_client
.make_rpc_request(2, RpcRequest::GetStorageBlockHash, None)
let storage_blockhash = rpc_client
.make_rpc_request(2, RpcRequest::GetStorageBlockhash, None)
.expect("rpc request")
.to_string();
let storage_entry_height = rpc_client
@ -348,14 +348,14 @@ impl Replicator {
.as_u64()
.unwrap();
if get_segment_from_entry(storage_entry_height) != 0 {
return Ok((storage_block_hash, storage_entry_height));
return Ok((storage_blockhash, storage_entry_height));
}
info!("max entry_height: {}", storage_entry_height);
sleep(Duration::from_secs(3));
}
Err(Error::new(
ErrorKind::Other,
"Couldn't get block_hash or entry_height",
"Couldn't get blockhash or entry_height",
))?
}
@ -366,12 +366,12 @@ impl Replicator {
let airdrop_amount = 1;
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
match request_airdrop_transaction(
&drone_addr,
&keypair.pubkey(),
airdrop_amount,
block_hash,
blockhash,
) {
Ok(transaction) => {
let signature = client.transfer_signed(&transaction).unwrap();

View File

@ -57,8 +57,8 @@ impl JsonRpcRequestProcessor {
Ok(val)
}
fn get_recent_block_hash(&self) -> Result<String> {
let id = self.bank()?.last_block_hash();
fn get_recent_blockhash(&self) -> Result<String> {
let id = self.bank()?.last_blockhash();
Ok(bs58::encode(id).into_string())
}
@ -72,8 +72,8 @@ impl JsonRpcRequestProcessor {
Ok(self.bank()?.transaction_count() as u64)
}
fn get_storage_block_hash(&self) -> Result<String> {
let hash = self.storage_state.get_storage_block_hash();
fn get_storage_blockhash(&self) -> Result<String> {
let hash = self.storage_state.get_storage_blockhash();
Ok(bs58::encode(hash).into_string())
}
@ -155,8 +155,8 @@ pub trait RpcSol {
#[rpc(meta, name = "getBalance")]
fn get_balance(&self, _: Self::Metadata, _: String) -> Result<u64>;
#[rpc(meta, name = "getRecentBlockHash")]
fn get_recent_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getRecentBlockhash")]
fn get_recent_blockhash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getSignatureStatus")]
fn get_signature_status(&self, _: Self::Metadata, _: String) -> Result<RpcSignatureStatus>;
@ -170,8 +170,8 @@ pub trait RpcSol {
#[rpc(meta, name = "sendTransaction")]
fn send_transaction(&self, _: Self::Metadata, _: Vec<u8>) -> Result<String>;
#[rpc(meta, name = "getStorageBlockHash")]
fn get_storage_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageBlockhash")]
fn get_storage_blockhash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageEntryHeight")]
fn get_storage_entry_height(&self, _: Self::Metadata) -> Result<u64>;
@ -209,12 +209,12 @@ impl RpcSol for RpcSolImpl {
meta.request_processor.read().unwrap().get_balance(pubkey)
}
fn get_recent_block_hash(&self, meta: Self::Metadata) -> Result<String> {
info!("get_recent_block_hash rpc request received");
fn get_recent_blockhash(&self, meta: Self::Metadata) -> Result<String> {
info!("get_recent_blockhash rpc request received");
meta.request_processor
.read()
.unwrap()
.get_recent_block_hash()
.get_recent_blockhash()
}
fn get_signature_status(&self, meta: Self::Metadata, id: String) -> Result<RpcSignatureStatus> {
@ -258,19 +258,17 @@ impl RpcSol for RpcSolImpl {
trace!("request_airdrop id={} tokens={}", id, tokens);
let pubkey = verify_pubkey(id)?;
let block_hash = meta
let blockhash = meta
.request_processor
.read()
.unwrap()
.bank()?
.last_block_hash();
let transaction =
request_airdrop_transaction(&meta.drone_addr, &pubkey, tokens, block_hash).map_err(
|err| {
info!("request_airdrop_transaction failed: {:?}", err);
Error::internal_error()
},
)?;;
.last_blockhash();
let transaction = request_airdrop_transaction(&meta.drone_addr, &pubkey, tokens, blockhash)
.map_err(|err| {
info!("request_airdrop_transaction failed: {:?}", err);
Error::internal_error()
})?;;
let data = serialize(&transaction).map_err(|err| {
info!("request_airdrop: serialize error: {:?}", err);
@ -338,11 +336,11 @@ impl RpcSol for RpcSolImpl {
Ok(signature)
}
fn get_storage_block_hash(&self, meta: Self::Metadata) -> Result<String> {
fn get_storage_blockhash(&self, meta: Self::Metadata) -> Result<String> {
meta.request_processor
.read()
.unwrap()
.get_storage_block_hash()
.get_storage_blockhash()
}
fn get_storage_entry_height(&self, meta: Self::Metadata) -> Result<u64> {
@ -380,8 +378,8 @@ mod tests {
let (genesis_block, alice) = GenesisBlock::new(10_000);
let bank = Arc::new(Bank::new(&genesis_block));
let block_hash = bank.last_block_hash();
let tx = SystemTransaction::new_move(&alice, pubkey, 20, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_move(&alice, pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
@ -405,7 +403,7 @@ mod tests {
drone_addr,
rpc_addr,
};
(io, meta, block_hash, alice)
(io, meta, blockhash, alice)
}
#[test]
@ -416,8 +414,8 @@ mod tests {
let mut request_processor = JsonRpcRequestProcessor::new(StorageState::default());
request_processor.set_bank(&bank);
thread::spawn(move || {
let block_hash = bank.last_block_hash();
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
})
.join()
@ -428,7 +426,7 @@ mod tests {
#[test]
fn test_rpc_get_balance() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["{}"]}}"#,
@ -446,7 +444,7 @@ mod tests {
#[test]
fn test_rpc_get_tx_count() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getTransactionCount"}}"#);
let res = io.handle_request_sync(&req, meta);
@ -461,7 +459,7 @@ mod tests {
#[test]
fn test_rpc_get_account_info() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}"]}}"#,
@ -488,8 +486,8 @@ mod tests {
#[test]
fn test_rpc_confirm_tx() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"confirmTransaction","params":["{}"]}}"#,
@ -507,8 +505,8 @@ mod tests {
#[test]
fn test_rpc_get_signature_status() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
@ -523,7 +521,7 @@ mod tests {
assert_eq!(expected, result);
// Test getSignatureStatus request on unprocessed tx
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 10, block_hash, 0);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 10, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
@ -538,13 +536,13 @@ mod tests {
}
#[test]
fn test_rpc_get_recent_block_hash() {
fn test_rpc_get_recent_blockhash() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getRecentBlockHash"}}"#);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getRecentBlockhash"}}"#);
let res = io.handle_request_sync(&req, meta);
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, block_hash);
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, blockhash);
let expected: Response =
serde_json::from_str(&expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
@ -555,7 +553,7 @@ mod tests {
#[test]
fn test_rpc_fail_request_airdrop() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
// Expect internal error because no leader is running
let req = format!(

View File

@ -64,7 +64,7 @@ impl MockRpcClient {
let n = if self.addr == "airdrop" { 0 } else { 50 };
Value::Number(Number::from(n))
}
RpcRequest::GetRecentBlockHash => Value::String(PUBKEY.to_string()),
RpcRequest::GetRecentBlockhash => Value::String(PUBKEY.to_string()),
RpcRequest::GetSignatureStatus => {
let str = if self.addr == "account_in_use" {
"AccountInUse"
@ -98,14 +98,14 @@ pub fn request_airdrop_transaction(
_drone_addr: &SocketAddr,
_id: &Pubkey,
tokens: u64,
_block_hash: Hash,
_blockhash: Hash,
) -> Result<Transaction, Error> {
if tokens == 0 {
Err(Error::new(ErrorKind::Other, "Airdrop failed"))?
}
let key = Keypair::new();
let to = Keypair::new().pubkey();
let block_hash = Hash::default();
let tx = SystemTransaction::new_account(&key, to, 50, block_hash, 0);
let blockhash = Hash::default();
let tx = SystemTransaction::new_account(&key, to, 50, blockhash, 0);
Ok(tx)
}

View File

@ -203,12 +203,12 @@ mod tests {
let bob_pubkey = bob.pubkey();
let bank = Bank::new(&genesis_block);
let arc_bank = Arc::new(bank);
let block_hash = arc_bank.last_block_hash();
let blockhash = arc_bank.last_blockhash();
let rpc = RpcSolPubSubImpl::default();
// Test signature subscriptions
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let session = create_session();
let (subscriber, _id_receiver, mut receiver) =
@ -232,7 +232,7 @@ mod tests {
let bob_pubkey = Keypair::new().pubkey();
let bank = Bank::new(&genesis_block);
let arc_bank = Arc::new(bank);
let block_hash = arc_bank.last_block_hash();
let blockhash = arc_bank.last_blockhash();
let session = create_session();
@ -240,7 +240,7 @@ mod tests {
let rpc = RpcSolPubSubImpl::default();
io.extend_with(rpc.to_delegate());
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
tx.signatures[0].to_string()
@ -279,7 +279,7 @@ mod tests {
let executable = false; // TODO
let bank = Bank::new(&genesis_block);
let arc_bank = Arc::new(bank);
let block_hash = arc_bank.last_block_hash();
let blockhash = arc_bank.last_blockhash();
let rpc = RpcSolPubSubImpl::default();
let session = create_session();
@ -289,7 +289,7 @@ mod tests {
let tx = SystemTransaction::new_program_account(
&alice,
contract_funds.pubkey(),
block_hash,
blockhash,
50,
0,
budget_program_id,
@ -300,7 +300,7 @@ mod tests {
let tx = SystemTransaction::new_program_account(
&alice,
contract_state.pubkey(),
block_hash,
blockhash,
1,
196,
budget_program_id,
@ -342,7 +342,7 @@ mod tests {
witness.pubkey(),
None,
50,
block_hash,
blockhash,
);
let arc_bank = process_transaction_and_notify(&arc_bank, &tx, &rpc.subscriptions).unwrap();
sleep(Duration::from_millis(200));
@ -371,14 +371,14 @@ mod tests {
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
}
let tx = SystemTransaction::new_account(&alice, witness.pubkey(), 1, block_hash, 0);
let tx = SystemTransaction::new_account(&alice, witness.pubkey(), 1, blockhash, 0);
let arc_bank = process_transaction_and_notify(&arc_bank, &tx, &rpc.subscriptions).unwrap();
sleep(Duration::from_millis(200));
let tx = BudgetTransaction::new_signature(
&witness,
contract_state.pubkey(),
bob_pubkey,
block_hash,
blockhash,
);
let arc_bank = process_transaction_and_notify(&arc_bank, &tx, &rpc.subscriptions).unwrap();
sleep(Duration::from_millis(200));

View File

@ -129,7 +129,7 @@ pub enum RpcRequest {
ConfirmTransaction,
GetAccountInfo,
GetBalance,
GetRecentBlockHash,
GetRecentBlockhash,
GetSignatureStatus,
GetTransactionCount,
RequestAirdrop,
@ -137,7 +137,7 @@ pub enum RpcRequest {
RegisterNode,
SignVote,
DeregisterNode,
GetStorageBlockHash,
GetStorageBlockhash,
GetStorageEntryHeight,
GetStoragePubkeysForEntryHeight,
}
@ -149,7 +149,7 @@ impl RpcRequest {
RpcRequest::ConfirmTransaction => "confirmTransaction",
RpcRequest::GetAccountInfo => "getAccountInfo",
RpcRequest::GetBalance => "getBalance",
RpcRequest::GetRecentBlockHash => "getRecentBlockHash",
RpcRequest::GetRecentBlockhash => "getRecentBlockhash",
RpcRequest::GetSignatureStatus => "getSignatureStatus",
RpcRequest::GetTransactionCount => "getTransactionCount",
RpcRequest::RequestAirdrop => "requestAirdrop",
@ -157,7 +157,7 @@ impl RpcRequest {
RpcRequest::RegisterNode => "registerNode",
RpcRequest::SignVote => "signVote",
RpcRequest::DeregisterNode => "deregisterNode",
RpcRequest::GetStorageBlockHash => "getStorageBlockHash",
RpcRequest::GetStorageBlockhash => "getStorageBlockhash",
RpcRequest::GetStorageEntryHeight => "getStorageEntryHeight",
RpcRequest::GetStoragePubkeysForEntryHeight => "getStoragePubkeysForEntryHeight",
};
@ -217,9 +217,9 @@ mod tests {
let request = test_request.build_request_json(1, Some(addr));
assert_eq!(request["method"], "getBalance");
let test_request = RpcRequest::GetRecentBlockHash;
let test_request = RpcRequest::GetRecentBlockhash;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "getRecentBlockHash");
assert_eq!(request["method"], "getRecentBlockhash");
let test_request = RpcRequest::GetTransactionCount;
let request = test_request.build_request_json(1, None);
@ -244,7 +244,7 @@ mod tests {
Ok(Value::Number(Number::from(50)))
});
// Failed request
io.add_method("getRecentBlockHash", |params: Params| {
io.add_method("getRecentBlockhash", |params: Params| {
if params != Params::None {
Err(Error::invalid_request())
} else {
@ -275,16 +275,16 @@ mod tests {
);
assert_eq!(balance.unwrap().as_u64().unwrap(), 50);
let block_hash = rpc_client.make_rpc_request(2, RpcRequest::GetRecentBlockHash, None);
let blockhash = rpc_client.make_rpc_request(2, RpcRequest::GetRecentBlockhash, None);
assert_eq!(
block_hash.unwrap().as_str().unwrap(),
blockhash.unwrap().as_str().unwrap(),
"deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"
);
// Send erroneous parameter
let block_hash =
rpc_client.make_rpc_request(3, RpcRequest::GetRecentBlockHash, Some(json!("paramter")));
assert_eq!(block_hash.is_err(), true);
let blockhash =
rpc_client.make_rpc_request(3, RpcRequest::GetRecentBlockhash, Some(json!("paramter")));
assert_eq!(blockhash.is_err(), true);
}
#[test]

View File

@ -156,11 +156,11 @@ mod tests {
let (genesis_block, mint_keypair) = GenesisBlock::new(100);
let bank = Bank::new(&genesis_block);
let alice = Keypair::new();
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_program_account(
&mint_keypair,
alice.pubkey(),
block_hash,
blockhash,
1,
16,
budget_program::id(),
@ -201,8 +201,8 @@ mod tests {
let (genesis_block, mint_keypair) = GenesisBlock::new(100);
let bank = Bank::new(&genesis_block);
let alice = Keypair::new();
let block_hash = bank.last_block_hash();
let tx = SystemTransaction::new_move(&mint_keypair, alice.pubkey(), 20, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_move(&mint_keypair, alice.pubkey(), 20, blockhash, 0);
let signature = tx.signatures[0];
bank.process_transaction(&tx).unwrap();

View File

@ -495,7 +495,7 @@ mod tests {
let keypairs = vec![&keypair0, &keypair1];
let tokens = 5;
let fee = 2;
let block_hash = Hash::default();
let blockhash = Hash::default();
let keys = vec![keypair0.pubkey(), keypair1.pubkey()];
@ -508,7 +508,7 @@ mod tests {
let tx = Transaction::new_with_instructions(
&keypairs,
&keys,
block_hash,
blockhash,
fee,
program_ids,
instructions,

View File

@ -39,7 +39,7 @@ pub struct StorageStateInner {
storage_results: StorageResults,
storage_keys: StorageKeys,
replicator_map: ReplicatorMap,
storage_block_hash: Hash,
storage_blockhash: Hash,
entry_height: u64,
}
@ -93,7 +93,7 @@ impl StorageState {
storage_results,
replicator_map,
entry_height: 0,
storage_block_hash: Hash::default(),
storage_blockhash: Hash::default(),
};
StorageState {
@ -111,8 +111,8 @@ impl StorageState {
self.state.read().unwrap().storage_results[idx]
}
pub fn get_storage_block_hash(&self) -> Hash {
self.state.read().unwrap().storage_block_hash
pub fn get_storage_blockhash(&self) -> Hash {
self.state.read().unwrap().storage_blockhash
}
pub fn get_entry_height(&self) -> u64 {
@ -235,10 +235,10 @@ impl StorageStage {
}
}
let mut block_hash = None;
let mut blockhash = None;
for _ in 0..10 {
if let Some(new_block_hash) = client.try_get_recent_block_hash(1) {
block_hash = Some(new_block_hash);
if let Some(new_blockhash) = client.try_get_recent_blockhash(1) {
blockhash = Some(new_blockhash);
break;
}
@ -247,8 +247,8 @@ impl StorageStage {
}
}
if let Some(block_hash) = block_hash {
tx.sign(&[keypair.as_ref()], block_hash);
if let Some(blockhash) = blockhash {
tx.sign(&[keypair.as_ref()], blockhash);
if exit.load(Ordering::Relaxed) {
Err(io::Error::new(io::ErrorKind::Other, "exit signaled"))?;
@ -284,7 +284,7 @@ impl StorageStage {
let mut seed = [0u8; 32];
let signature = keypair.sign(&entry_id.as_ref());
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
keypair,
entry_id,
Hash::default(),
@ -505,7 +505,7 @@ mod tests {
let (genesis_block, _mint_keypair) = GenesisBlock::new(1000);
let ticks_per_slot = genesis_block.ticks_per_slot;
let (ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let entries = make_tiny_test_entries(64);
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot).unwrap();
@ -567,7 +567,7 @@ mod tests {
let (genesis_block, _mint_keypair) = GenesisBlock::new(1000);
let ticks_per_slot = genesis_block.ticks_per_slot;;
let (ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let entries = make_tiny_test_entries(128);
let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot).unwrap();

View File

@ -99,7 +99,7 @@ impl ThinClient {
tries: usize,
) -> io::Result<Signature> {
for x in 0..tries {
transaction.sign(&[keypair], self.get_recent_block_hash());
transaction.sign(&[keypair], self.get_recent_blockhash());
let mut buf = vec![0; transaction.serialized_size().unwrap() as usize];
let mut wr = std::io::Cursor::new(&mut buf[..]);
serialize_into(&mut wr, &transaction)
@ -123,17 +123,17 @@ impl ThinClient {
tokens: u64,
keypair: &Keypair,
to: Pubkey,
block_hash: &Hash,
blockhash: &Hash,
) -> io::Result<Signature> {
debug!(
"transfer: tokens={} from={:?} to={:?} block_hash={:?}",
"transfer: tokens={} from={:?} to={:?} blockhash={:?}",
tokens,
keypair.pubkey(),
to,
block_hash
blockhash
);
let now = Instant::now();
let transaction = SystemTransaction::new_account(keypair, to, tokens, *block_hash, 0);
let transaction = SystemTransaction::new_account(keypair, to, tokens, *blockhash, 0);
let result = self.transfer_signed(&transaction);
solana_metrics::submit(
influxdb::Point::new("thinclient")
@ -216,22 +216,22 @@ impl ThinClient {
}
/// Request the last Entry ID from the server without blocking.
/// Returns the block_hash Hash or None if there was no response from the server.
pub fn try_get_recent_block_hash(&mut self, mut num_retries: u64) -> Option<Hash> {
/// Returns the blockhash Hash or None if there was no response from the server.
pub fn try_get_recent_blockhash(&mut self, mut num_retries: u64) -> Option<Hash> {
loop {
trace!("try_get_recent_block_hash send_to {}", &self.rpc_addr);
trace!("try_get_recent_blockhash send_to {}", &self.rpc_addr);
let response =
self.rpc_client
.make_rpc_request(1, RpcRequest::GetRecentBlockHash, None);
.make_rpc_request(1, RpcRequest::GetRecentBlockhash, None);
match response {
Ok(value) => {
let block_hash_str = value.as_str().unwrap();
let block_hash_vec = bs58::decode(block_hash_str).into_vec().unwrap();
return Some(Hash::new(&block_hash_vec));
let blockhash_str = value.as_str().unwrap();
let blockhash_vec = bs58::decode(blockhash_str).into_vec().unwrap();
return Some(Hash::new(&blockhash_vec));
}
Err(error) => {
debug!("thin_client get_recent_block_hash error: {:?}", error);
debug!("thin_client get_recent_blockhash error: {:?}", error);
num_retries -= 1;
if num_retries == 0 {
return None;
@ -243,10 +243,10 @@ impl ThinClient {
/// Request the last Entry ID from the server. This method blocks
/// until the server sends a response.
pub fn get_recent_block_hash(&mut self) -> Hash {
pub fn get_recent_blockhash(&mut self) -> Hash {
loop {
trace!("get_recent_block_hash send_to {}", &self.rpc_addr);
if let Some(hash) = self.try_get_recent_block_hash(10) {
trace!("get_recent_blockhash send_to {}", &self.rpc_addr);
if let Some(hash) = self.try_get_recent_blockhash(10) {
return hash;
}
}
@ -254,18 +254,18 @@ impl ThinClient {
/// Request a new last Entry ID from the server. This method blocks
/// until the server sends a response.
pub fn get_next_block_hash(&mut self, previous_block_hash: &Hash) -> Hash {
self.get_next_block_hash_ext(previous_block_hash, &|| {
pub fn get_next_blockhash(&mut self, previous_blockhash: &Hash) -> Hash {
self.get_next_blockhash_ext(previous_blockhash, &|| {
sleep(Duration::from_millis(100));
})
}
pub fn get_next_block_hash_ext(&mut self, previous_block_hash: &Hash, func: &Fn()) -> Hash {
pub fn get_next_blockhash_ext(&mut self, previous_blockhash: &Hash, func: &Fn()) -> Hash {
loop {
let block_hash = self.get_recent_block_hash();
if block_hash != *previous_block_hash {
break block_hash;
let blockhash = self.get_recent_blockhash();
if blockhash != *previous_blockhash {
break blockhash;
}
debug!("Got same block_hash ({:?}), will retry...", block_hash);
debug!("Got same blockhash ({:?}), will retry...", blockhash);
func()
}
}
@ -468,7 +468,7 @@ pub fn new_fullnode() -> (Fullnode, NodeInfo, Keypair, String) {
let node_info = node.info.clone();
let (genesis_block, mint_keypair) = GenesisBlock::new_with_leader(10_000, node_info.id, 42);
let (ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let vote_account_keypair = Arc::new(Keypair::new());
let voting_keypair = VotingKeypair::new_local(&vote_account_keypair);
@ -511,11 +511,11 @@ mod tests {
let transaction_count = client.transaction_count();
assert_eq!(transaction_count, 0);
let block_hash = client.get_recent_block_hash();
info!("test_thin_client block_hash: {:?}", block_hash);
let blockhash = client.get_recent_blockhash();
info!("test_thin_client blockhash: {:?}", blockhash);
let signature = client
.transfer(500, &alice, bob_pubkey, &block_hash)
.transfer(500, &alice, bob_pubkey, &blockhash)
.unwrap();
info!("test_thin_client signature: {:?}", signature);
client.poll_for_signature(&signature).unwrap();
@ -543,15 +543,15 @@ mod tests {
let mut client = mk_client(&leader_data);
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
let tx = SystemTransaction::new_account(&alice, bob_pubkey, 500, block_hash, 0);
let tx = SystemTransaction::new_account(&alice, bob_pubkey, 500, blockhash, 0);
let _sig = client.transfer_signed(&tx).unwrap();
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
let mut tr2 = SystemTransaction::new_account(&alice, bob_pubkey, 501, block_hash, 0);
let mut tr2 = SystemTransaction::new_account(&alice, bob_pubkey, 501, blockhash, 0);
let mut instruction2 = deserialize(tr2.userdata(0)).unwrap();
if let SystemInstruction::Move { ref mut tokens } = instruction2 {
*tokens = 502;
@ -580,9 +580,9 @@ mod tests {
// Create the validator account, transfer some tokens to that account
let validator_keypair = Keypair::new();
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
let signature = client
.transfer(500, &alice, validator_keypair.pubkey(), &block_hash)
.transfer(500, &alice, validator_keypair.pubkey(), &blockhash)
.unwrap();
client.poll_for_signature(&signature).unwrap();
@ -590,12 +590,12 @@ mod tests {
// Create and register the vote account
let validator_vote_account_keypair = Keypair::new();
let vote_account_id = validator_vote_account_keypair.pubkey();
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
let transaction = VoteTransaction::fund_staking_account(
&validator_keypair,
vote_account_id,
block_hash,
blockhash,
1,
1,
);
@ -654,15 +654,15 @@ mod tests {
);
let mut client = mk_client(&leader_data);
let block_hash = client.get_recent_block_hash();
info!("test_thin_client block_hash: {:?}", block_hash);
let blockhash = client.get_recent_blockhash();
info!("test_thin_client blockhash: {:?}", blockhash);
let starting_alice_balance = client.poll_get_balance(&alice.pubkey()).unwrap();
info!("Alice has {} tokens", starting_alice_balance);
info!("Give Bob 500 tokens");
let signature = client
.transfer(500, &alice, bob_keypair.pubkey(), &block_hash)
.transfer(500, &alice, bob_keypair.pubkey(), &blockhash)
.unwrap();
client.poll_for_signature(&signature).unwrap();
@ -671,7 +671,7 @@ mod tests {
info!("Take Bob's 500 tokens away");
let signature = client
.transfer(500, &bob_keypair, alice.pubkey(), &block_hash)
.transfer(500, &bob_keypair, alice.pubkey(), &blockhash)
.unwrap();
client.poll_for_signature(&signature).unwrap();
let alice_balance = client.poll_get_balance(&alice.pubkey()).unwrap();

View File

@ -34,7 +34,7 @@ use std::thread;
pub struct TvuRotationInfo {
pub tick_height: u64, // tick height, bank might not exist yet
pub block_hash: Hash, // block_hash that was voted on
pub blockhash: Hash, // blockhash that was voted on
pub slot: u64, // slot height to initiate a rotation
pub leader_id: Pubkey, // leader upon rotation
}

View File

@ -1,4 +1,4 @@
//! The `vote_signer_proxy` votes on the `block_hash` of the bank at a regular cadence
//! The `vote_signer_proxy` votes on the `blockhash` of the bank at a regular cadence
use crate::rpc_request::{RpcClient, RpcRequest};
use jsonrpc_core;
@ -109,11 +109,11 @@ pub mod tests {
bank: &Bank,
num_tokens: u64,
) {
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
let tx = VoteTransaction::fund_staking_account(
from_keypair,
*voting_pubkey,
block_hash,
blockhash,
num_tokens,
0,
);
@ -121,8 +121,8 @@ pub mod tests {
}
pub fn push_vote<T: KeypairUtil>(voting_keypair: &T, bank: &Bank, slot_height: u64) {
let block_hash = bank.last_block_hash();
let tx = VoteTransaction::new_vote(voting_keypair, slot_height, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = VoteTransaction::new_vote(voting_keypair, slot_height, blockhash, 0);
bank.process_transaction(&tx).unwrap();
}