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

@ -102,7 +102,7 @@ pub fn sample_tx_count(
/// Send loopback payment of 0 tokens and confirm the network processed it
pub fn send_barrier_transaction(
barrier_client: &mut ThinClient,
block_hash: &mut Hash,
blockhash: &mut Hash,
id: &Keypair,
) {
let transfer_start = Instant::now();
@ -116,9 +116,9 @@ pub fn send_barrier_transaction(
);
}
*block_hash = barrier_client.get_recent_block_hash();
*blockhash = barrier_client.get_recent_blockhash();
let signature = barrier_client
.transfer(0, &id, id.pubkey(), block_hash)
.transfer(0, &id, id.pubkey(), blockhash)
.expect("Unable to send barrier transaction");
let confirmatiom = barrier_client.poll_for_signature(&signature);
@ -158,13 +158,13 @@ pub fn send_barrier_transaction(
exit(1);
}
let new_block_hash = barrier_client.get_recent_block_hash();
if new_block_hash == *block_hash {
let new_blockhash = barrier_client.get_recent_blockhash();
if new_blockhash == *blockhash {
if poll_count > 0 && poll_count % 8 == 0 {
println!("block_hash is not advancing, still at {:?}", *block_hash);
println!("blockhash is not advancing, still at {:?}", *blockhash);
}
} else {
*block_hash = new_block_hash;
*blockhash = new_blockhash;
}
poll_count += 1;
@ -180,7 +180,7 @@ pub fn generate_txs(
leader: &NodeInfo,
) {
let mut client = mk_client(leader);
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
let tx_count = source.len();
println!("Signing transactions... {} (reclaim={})", tx_count, reclaim);
let signing_start = Instant::now();
@ -194,7 +194,7 @@ pub fn generate_txs(
.par_iter()
.map(|(id, keypair)| {
(
SystemTransaction::new_account(id, keypair.pubkey(), 1, block_hash, 0),
SystemTransaction::new_account(id, keypair.pubkey(), 1, blockhash, 0),
timestamp(),
)
})
@ -209,7 +209,7 @@ pub fn generate_txs(
bsps * 1_000_000_f64,
nsps / 1_000_f64,
duration_as_ms(&duration),
block_hash,
blockhash,
);
solana_metrics::submit(
influxdb::Point::new("bench-tps")
@ -332,7 +332,7 @@ pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], t
}
}
// try to transfer a "few" at a time with recent block_hash
// try to transfer a "few" at a time with recent blockhash
// assume 4MB network buffers, and 512 byte packets
const FUND_CHUNK_LEN: usize = 4 * 1024 * 1024 / 512;
@ -370,11 +370,11 @@ pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], t
to_fund_txs.len(),
);
let block_hash = client.get_recent_block_hash();
let blockhash = client.get_recent_blockhash();
// re-sign retained to_fund_txes with updated block_hash
// re-sign retained to_fund_txes with updated blockhash
to_fund_txs.par_iter_mut().for_each(|(k, tx)| {
tx.sign(&[*k], block_hash);
tx.sign(&[*k], blockhash);
});
to_fund_txs.iter().for_each(|(_, tx)| {
@ -414,8 +414,8 @@ pub fn airdrop_tokens(
id.pubkey(),
);
let block_hash = client.get_recent_block_hash();
match request_airdrop_transaction(&drone_addr, &id.pubkey(), airdrop_amount, block_hash) {
let blockhash = client.get_recent_blockhash();
match request_airdrop_transaction(&drone_addr, &id.pubkey(), airdrop_amount, blockhash) {
Ok(transaction) => {
let signature = client.transfer_signed(&transaction).unwrap();
client.poll_for_signature(&signature).unwrap();

View File

@ -170,8 +170,8 @@ fn main() {
airdrop_tokens(&mut barrier_client, &drone_addr, &barrier_id, 1);
println!("Get last ID...");
let mut block_hash = client.get_recent_block_hash();
println!("Got last ID {:?}", block_hash);
let mut blockhash = client.get_recent_blockhash();
println!("Got last ID {:?}", blockhash);
let first_tx_count = client.transaction_count();
println!("Initial transaction count {}", first_tx_count);
@ -254,7 +254,7 @@ fn main() {
// It's not feasible (would take too much time) to confirm each of the `tx_count / 2`
// transactions sent by `generate_txs()` so instead send and confirm a single transaction
// to validate the network is still functional.
send_barrier_transaction(&mut barrier_client, &mut block_hash, &barrier_id);
send_barrier_transaction(&mut barrier_client, &mut blockhash, &barrier_id);
i += 1;
if should_switch_directions(num_tokens_per_account, i) {

View File

@ -45,7 +45,7 @@ fn create_test_recorder(bank: &Arc<Bank>) -> (Arc<Mutex<PohRecorder>>, PohServic
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(),

View File

@ -46,7 +46,7 @@ desired cluster.
## Attack vectors
### Invalid recent_block_hash
### Invalid recent_blockhash
The drone may prefer its airdrops only target a particular Solana cluster. To
do that, it listens to the cluster for new entry IDs and ensure any requests
@ -68,8 +68,8 @@ A client may request multiple airdrops before the first has been submitted to
the ledger. The client may do this maliciously or simply because it thinks the
first request was dropped. The drone should not simply query the cluster to
ensure the client has not already received an airdrop. Instead, it should use
`recent_block_hash` to ensure the previous request is expired before signing another.
Note that the Solana cluster will reject any transaction with a `recent_block_hash`
`recent_blockhash` to ensure the previous request is expired before signing another.
Note that the Solana cluster will reject any transaction with a `recent_blockhash`
beyond a certain *age*.
### Denial of Service

View File

@ -24,7 +24,7 @@ Methods
* [confirmTransaction](#confirmtransaction)
* [getAccountInfo](#getaccountinfo)
* [getBalance](#getbalance)
* [getRecentBlockHash](#getrecentblockhash)
* [getRecentBlockhash](#getrecentblockhash)
* [getSignatureStatus](#getsignaturestatus)
* [getTransactionCount](#gettransactioncount)
* [requestAirdrop](#requestairdrop)
@ -137,7 +137,7 @@ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "
---
### getRecentBlockHash
### getRecentBlockhash
Returns a recent block hash from the ledger
##### Parameters:
@ -149,7 +149,7 @@ None
##### Example:
```bash
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getRecentBlockHash"}' http://localhost:8899
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getRecentBlockhash"}' http://localhost:8899
// Result
{"jsonrpc":"2.0","result":"GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC","id":1}

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();
}

View File

@ -50,7 +50,7 @@ pub enum DroneRequest {
GetAirdrop {
tokens: u64,
to: Pubkey,
block_hash: Hash,
blockhash: Hash,
},
}
@ -110,7 +110,7 @@ impl Drone {
DroneRequest::GetAirdrop {
tokens,
to,
block_hash,
blockhash,
} => {
if self.check_request_limit(tokens) {
self.request_current += tokens;
@ -137,11 +137,11 @@ impl Drone {
&[to],
system_program::id(),
&create_instruction,
block_hash,
blockhash,
0, /*fee*/
);
transaction.sign(&[&self.mint_keypair], block_hash);
transaction.sign(&[&self.mint_keypair], blockhash);
Ok(transaction)
} else {
Err(Error::new(ErrorKind::Other, "token limit reached"))
@ -194,18 +194,18 @@ pub fn request_airdrop_transaction(
drone_addr: &SocketAddr,
id: &Pubkey,
tokens: u64,
block_hash: Hash,
blockhash: Hash,
) -> Result<Transaction, Error> {
info!(
"request_airdrop_transaction: drone_addr={} id={} tokens={} block_hash={}",
drone_addr, id, tokens, block_hash
"request_airdrop_transaction: drone_addr={} id={} tokens={} blockhash={}",
drone_addr, id, tokens, blockhash
);
// TODO: make this async tokio client
let mut stream = TcpStream::connect_timeout(drone_addr, Duration::new(3, 0))?;
stream.set_read_timeout(Some(Duration::new(10, 0)))?;
let req = DroneRequest::GetAirdrop {
tokens,
block_hash,
blockhash,
to: *id,
};
let req = serialize(&req).expect("serialize drone request");
@ -353,11 +353,11 @@ mod tests {
#[test]
fn test_drone_build_airdrop_transaction() {
let to = Keypair::new().pubkey();
let block_hash = Hash::default();
let blockhash = Hash::default();
let request = DroneRequest::GetAirdrop {
tokens: 2,
to,
block_hash,
blockhash,
};
let mint = Keypair::new();
@ -368,7 +368,7 @@ mod tests {
assert_eq!(tx.signatures.len(), 1);
assert_eq!(tx.account_keys, vec![mint_pubkey, to]);
assert_eq!(tx.recent_block_hash, block_hash);
assert_eq!(tx.recent_blockhash, blockhash);
assert_eq!(tx.program_ids, vec![system_program::id()]);
assert_eq!(tx.instructions.len(), 1);
@ -391,11 +391,11 @@ mod tests {
#[test]
fn test_process_drone_request() {
let to = Keypair::new().pubkey();
let block_hash = Hash::new(&to.as_ref());
let blockhash = Hash::new(&to.as_ref());
let tokens = 50;
let req = DroneRequest::GetAirdrop {
tokens,
block_hash,
blockhash,
to,
};
let req = serialize(&req).unwrap();
@ -413,10 +413,10 @@ mod tests {
&[to],
system_program::id(),
&expected_instruction,
block_hash,
blockhash,
0,
);
expected_tx.sign(&[&keypair], block_hash);
expected_tx.sign(&[&keypair], blockhash);
let expected_bytes = serialize(&expected_tx).unwrap();
let mut expected_vec_with_length = vec![0; 2];
LittleEndian::write_u16(&mut expected_vec_with_length, expected_bytes.len() as u16);

View File

@ -11,7 +11,7 @@ fn test_local_drone() {
let keypair = Keypair::new();
let to = Keypair::new().pubkey();
let tokens = 50;
let block_hash = Hash::new(&to.as_ref());
let blockhash = Hash::new(&to.as_ref());
let expected_instruction = SystemInstruction::CreateAccount {
tokens,
space: 0,
@ -22,15 +22,15 @@ fn test_local_drone() {
&[to],
system_program::id(),
&expected_instruction,
block_hash,
blockhash,
0,
);
expected_tx.sign(&[&keypair], block_hash);
expected_tx.sign(&[&keypair], blockhash);
let (sender, receiver) = channel();
run_local_drone(keypair, sender);
let drone_addr = receiver.recv().unwrap();
let result = request_airdrop_transaction(&drone_addr, &to, tokens, block_hash);
let result = request_airdrop_transaction(&drone_addr, &to, tokens, blockhash);
assert_eq!(expected_tx, result.unwrap());
}

View File

@ -74,10 +74,10 @@ fn create_and_fund_vote_account(
));
}
loop {
let block_hash = client.get_recent_block_hash();
info!("create_and_fund_vote_account block_hash={:?}", block_hash);
let blockhash = client.get_recent_blockhash();
info!("create_and_fund_vote_account blockhash={:?}", blockhash);
let transaction =
VoteTransaction::fund_staking_account(node_keypair, vote_account, block_hash, 1, 1);
VoteTransaction::fund_staking_account(node_keypair, vote_account, blockhash, 1, 1);
match client.transfer_signed(&transaction) {
Ok(signature) => {

View File

@ -38,7 +38,7 @@ fn nominal() {
let (genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(100, keypair.pubkey(), 50);
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 ticks = ticks_per_slot as usize;
// Basic validation

View File

@ -24,8 +24,8 @@ impl<'a> RewardsBank<'a> {
rewards_id: Pubkey,
lamports: u64,
) -> Result<()> {
let block_hash = self.bank.last_block_hash();
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, block_hash, lamports, 0);
let blockhash = self.bank.last_blockhash();
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, blockhash, lamports, 0);
self.bank.process_transaction(&tx)
}
@ -35,25 +35,25 @@ impl<'a> RewardsBank<'a> {
vote_id: Pubkey,
lamports: u64,
) -> Result<()> {
let block_hash = self.bank.last_block_hash();
let blockhash = self.bank.last_blockhash();
let tx =
VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
self.bank.process_transaction(&tx)
}
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
let block_hash = self.bank.last_block_hash();
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
let blockhash = self.bank.last_blockhash();
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, blockhash, 0);
self.bank.process_transaction(&tx)?;
self.bank.register_tick(&hash(block_hash.as_ref()));
self.bank.register_tick(&hash(blockhash.as_ref()));
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
}
fn redeem_credits(&self, rewards_id: Pubkey, vote_keypair: &Keypair) -> Result<VoteState> {
let block_hash = self.bank.last_block_hash();
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, block_hash, 0);
let blockhash = self.bank.last_blockhash();
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, blockhash, 0);
self.bank.process_transaction(&tx)?;
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())

View File

@ -18,14 +18,14 @@ impl RewardsTransaction {
pub fn new_account(
from_keypair: &Keypair,
rewards_id: Pubkey,
block_hash: Hash,
blockhash: Hash,
num_tokens: u64,
fee: u64,
) -> Transaction {
SystemTransaction::new_program_account(
from_keypair,
rewards_id,
block_hash,
blockhash,
num_tokens,
RewardsState::max_size() as u64,
id(),
@ -36,7 +36,7 @@ impl RewardsTransaction {
pub fn new_redeem_credits(
vote_keypair: &Keypair,
rewards_id: Pubkey,
block_hash: Hash,
blockhash: Hash,
fee: u64,
) -> Transaction {
let vote_id = vote_keypair.pubkey();
@ -45,6 +45,6 @@ impl RewardsTransaction {
vote_id, rewards_id,
))
.push(VoteInstruction::new_clear_credits(vote_id))
.sign(&[vote_keypair], block_hash)
.sign(&[vote_keypair], blockhash)
}
}

View File

@ -83,7 +83,7 @@ fn entrypoint(
};
storage_account_state.proofs[segment_index].push(proof_info);
}
StorageProgram::AdvertiseStorageRecentBlockHash { hash, entry_height } => {
StorageProgram::AdvertiseStorageRecentBlockhash { hash, entry_height } => {
let original_segments = storage_account_state.entry_height / ENTRIES_PER_SEGMENT;
let segments = entry_height / ENTRIES_PER_SEGMENT;
debug!(
@ -229,7 +229,7 @@ mod test {
let pubkey = keypair.pubkey();
keyed_accounts.push(KeyedAccount::new(&pubkey, true, &mut user_account));
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&keypair,
Hash::default(),
Hash::default(),
@ -287,7 +287,7 @@ mod test {
let mut accounts = [Account::default(), Account::default()];
accounts[0].userdata.resize(16 * 1024, 0);
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&keypair,
Hash::default(),
Hash::default(),
@ -316,7 +316,7 @@ mod test {
let entry_height = 0;
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&keypair,
Hash::default(),
Hash::default(),
@ -334,7 +334,7 @@ mod test {
);
test_transaction(&tx, &mut accounts).unwrap();
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&keypair,
Hash::default(),
Hash::default(),
@ -350,7 +350,7 @@ mod test {
);
test_transaction(&tx, &mut accounts).unwrap();
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&keypair,
Hash::default(),
Hash::default(),

View File

@ -25,7 +25,7 @@ fn get_storage_entry_height(bank: &Bank, account: Pubkey) -> u64 {
0
}
fn get_storage_block_hash(bank: &Bank, account: Pubkey) -> Hash {
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 {
@ -46,23 +46,21 @@ fn test_bank_storage() {
let jill = Keypair::new();
let x = 42;
let block_hash = genesis_block.hash();
let blockhash = genesis_block.hash();
let x2 = x * 2;
let storage_block_hash = hash(&[x2]);
let storage_blockhash = hash(&[x2]);
bank.register_tick(&block_hash);
bank.register_tick(&blockhash);
bank.transfer(10, &alice, jill.pubkey(), block_hash)
.unwrap();
bank.transfer(10, &alice, jill.pubkey(), blockhash).unwrap();
bank.transfer(10, &alice, bob.pubkey(), block_hash).unwrap();
bank.transfer(10, &alice, jack.pubkey(), block_hash)
.unwrap();
bank.transfer(10, &alice, bob.pubkey(), blockhash).unwrap();
bank.transfer(10, &alice, jack.pubkey(), blockhash).unwrap();
let tx = SystemTransaction::new_program_account(
&alice,
bob.pubkey(),
block_hash,
blockhash,
1,
4 * 1024,
storage_program::id(),
@ -71,10 +69,10 @@ fn test_bank_storage() {
bank.process_transaction(&tx).unwrap();
let tx = StorageTransaction::new_advertise_recent_block_hash(
let tx = StorageTransaction::new_advertise_recent_blockhash(
&bob,
storage_block_hash,
block_hash,
storage_blockhash,
blockhash,
ENTRIES_PER_SEGMENT,
);
@ -86,7 +84,7 @@ fn test_bank_storage() {
//let tx = StorageTransaction::new_mining_proof(
// &jack,
// Hash::default(),
// block_hash,
// blockhash,
// entry_height,
// Signature::default(),
//);
@ -97,7 +95,7 @@ fn test_bank_storage() {
ENTRIES_PER_SEGMENT
);
assert_eq!(
get_storage_block_hash(&bank, bob.pubkey()),
storage_block_hash
get_storage_blockhash(&bank, bob.pubkey()),
storage_blockhash
);
}

View File

@ -26,17 +26,17 @@ impl<'a> VoteBank<'a> {
vote_id: Pubkey,
lamports: u64,
) -> Result<()> {
let block_hash = self.bank.last_block_hash();
let blockhash = self.bank.last_blockhash();
let tx =
VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
self.bank.process_transaction(&tx)
}
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
let block_hash = self.bank.last_block_hash();
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
let blockhash = self.bank.last_blockhash();
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, blockhash, 0);
self.bank.process_transaction(&tx)?;
self.bank.register_tick(&hash(block_hash.as_ref()));
self.bank.register_tick(&hash(blockhash.as_ref()));
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
@ -72,7 +72,7 @@ fn test_vote_via_bank_with_no_signature() {
.unwrap();
let mallory_id = mallory_keypair.pubkey();
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
let vote_ix = BuilderInstruction::new(
vote_program::id(),
&VoteInstruction::Vote(Vote::new(0)),
@ -85,7 +85,7 @@ fn test_vote_via_bank_with_no_signature() {
let tx = TransactionBuilder::default()
.push(SystemInstruction::new_move(mallory_id, vote_id, 1))
.push(vote_ix)
.sign(&[&mallory_keypair], block_hash);
.sign(&[&mallory_keypair], blockhash);
let result = bank.process_transaction(&tx);

View File

@ -15,7 +15,7 @@ fn load_program(bank: &Bank, from: &Keypair, loader_id: Pubkey, program: Vec<u8>
let tx = SystemTransaction::new_program_account(
from,
program_account.pubkey(),
bank.last_block_hash(),
bank.last_blockhash(),
1,
program.len() as u64,
loader_id,
@ -32,15 +32,14 @@ fn load_program(bank: &Bank, from: &Keypair, loader_id: Pubkey, program: Vec<u8>
loader_id,
offset,
chunk.to_vec(),
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
bank.process_transaction(&tx).unwrap();
offset += chunk_size as u32;
}
let tx =
LoaderTransaction::new_finalize(&program_account, loader_id, bank.last_block_hash(), 0);
let tx = LoaderTransaction::new_finalize(&program_account, loader_id, bank.last_blockhash(), 0);
bank.process_transaction(&tx).unwrap();
assert_eq!(bank.get_signature_status(&tx.signatures[0]), Some(Ok(())));
@ -63,7 +62,7 @@ fn test_program_native_noop() {
&[],
program_id,
&1u8,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
bank.process_transaction(&tx).unwrap();
@ -86,7 +85,7 @@ fn test_program_native_failure() {
&[],
program_id,
&1u8,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(
@ -141,7 +140,7 @@ fn test_program_bpf_c_noop() {
&[],
program_id,
&vec![1u8],
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
bank.process_transaction(&tx).unwrap();
@ -185,7 +184,7 @@ fn test_program_bpf_c() {
&[],
program_id,
&vec![1u8],
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
bank.process_transaction(&tx).unwrap();
@ -225,7 +224,7 @@ fn test_program_bpf_rust() {
&[],
program_id,
&vec![1u8],
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
bank.process_transaction(&tx).unwrap();

View File

@ -25,7 +25,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {
&mint_keypair,
rando0.pubkey(),
10_000,
bank.last_block_hash(),
bank.last_blockhash(),
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
@ -33,7 +33,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {
// Seed the 'to' account and a cell for its signature.
let rando1 = Keypair::new();
let tx =
SystemTransaction::new_move(&rando0, rando1.pubkey(), 1, bank.last_block_hash(), 0);
SystemTransaction::new_move(&rando0, rando1.pubkey(), 1, bank.last_blockhash(), 0);
assert_eq!(bank.process_transaction(&tx), Ok(()));
// Finally, return the transaction to the benchmark.
@ -41,7 +41,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {
})
.collect();
let mut id = bank.last_block_hash();
let mut id = bank.last_blockhash();
for _ in 0..(MAX_RECENT_TICK_HASHES - 1) {
bank.register_tick(&id);

View File

@ -44,15 +44,15 @@ fn bench_sigs_bloom(bencher: &mut Bencher) {
// 1M TPS * 1s (length of block in sigs) == 1M items in filter
// 1.0E-8 false positive rate
// https://hur.st/bloomfilter/?n=1000000&p=1.0E-8&m=&k=
let block_hash = hash(Hash::default().as_ref());
// eprintln!("block_hash = {:?}", block_hash);
let blockhash = hash(Hash::default().as_ref());
// eprintln!("blockhash = {:?}", blockhash);
let keys = (0..27)
.into_iter()
.map(|i| block_hash.hash_at_index(i))
.map(|i| blockhash.hash_at_index(i))
.collect();
let mut sigs: Bloom<Signature> = Bloom::new(38_340_234, keys);
let mut id = block_hash;
let mut id = blockhash;
let mut falses = 0;
let mut iterations = 0;
bencher.iter(|| {
@ -76,11 +76,11 @@ fn bench_sigs_bloom(bencher: &mut Bencher) {
#[ignore]
fn bench_sigs_hashmap(bencher: &mut Bencher) {
// same structure as above, new
let block_hash = hash(Hash::default().as_ref());
// eprintln!("block_hash = {:?}", block_hash);
let blockhash = hash(Hash::default().as_ref());
// eprintln!("blockhash = {:?}", blockhash);
let mut sigs: HashSet<Signature> = HashSet::new();
let mut id = block_hash;
let mut id = blockhash;
let mut falses = 0;
let mut iterations = 0;
bencher.iter(|| {

View File

@ -27,9 +27,9 @@ pub struct ErrorCounters {
pub account_not_found: usize,
pub account_in_use: usize,
pub account_loaded_twice: usize,
pub block_hash_not_found: usize,
pub block_hash_too_old: usize,
pub reserve_block_hash: usize,
pub blockhash_not_found: usize,
pub blockhash_too_old: usize,
pub reserve_blockhash: usize,
pub insufficient_funds: usize,
pub duplicate_signature: usize,
pub call_chain_too_deep: usize,

View File

@ -23,7 +23,7 @@ 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_BLOCK_HASHES, NUM_TICKS_PER_SECOND};
use solana_sdk::timing::{duration_as_us, MAX_RECENT_BLOCKHASHES, NUM_TICKS_PER_SECOND};
use solana_sdk::token_program;
use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::{self, VoteState};
@ -50,12 +50,12 @@ pub enum BankError {
/// The bank has seen `Signature` before. This can occur under normal operation
/// when a UDP packet is duplicated, as a user error from a client not updating
/// its `recent_block_hash`, or as a double-spend attack.
/// its `recent_blockhash`, or as a double-spend attack.
DuplicateSignature,
/// The bank has not seen the given `recent_block_hash` or the transaction is too old and
/// the `recent_block_hash` has been discarded.
BlockHashNotFound,
/// The bank has not seen the given `recent_blockhash` or the transaction is too old and
/// the `recent_blockhash` has been discarded.
BlockhashNotFound,
/// Proof of History verification failed.
LedgerVerificationFailed,
@ -85,8 +85,8 @@ pub struct Bank {
/// A cache of signature statuses
status_cache: RwLock<BankStatusCache>,
/// FIFO queue of `recent_block_hash` items
block_hash_queue: RwLock<HashQueue>,
/// FIFO queue of `recent_blockhash` items
blockhash_queue: RwLock<HashQueue>,
/// Previous checkpoint of this bank
parent: RwLock<Option<Arc<Bank>>>,
@ -125,7 +125,7 @@ pub struct Bank {
impl Default for HashQueue {
fn default() -> Self {
Self::new(MAX_RECENT_BLOCK_HASHES)
Self::new(MAX_RECENT_BLOCKHASHES)
}
}
@ -155,7 +155,7 @@ impl Bank {
parent.freeze();
let mut bank = Self::default();
bank.block_hash_queue = RwLock::new(parent.block_hash_queue.read().unwrap().clone());
bank.blockhash_queue = RwLock::new(parent.blockhash_queue.read().unwrap().clone());
bank.tick_height
.store(parent.tick_height.load(Ordering::SeqCst), Ordering::SeqCst);
bank.ticks_per_slot = parent.ticks_per_slot;
@ -272,7 +272,7 @@ impl Bank {
&bootstrap_leader_vote_account,
);
self.block_hash_queue
self.blockhash_queue
.write()
.unwrap()
.genesis_hash(&genesis_block.hash());
@ -298,8 +298,8 @@ impl Bank {
}
/// Return the last block hash registered.
pub fn last_block_hash(&self) -> Hash {
self.block_hash_queue.read().unwrap().last_hash()
pub fn last_blockhash(&self) -> Hash {
self.blockhash_queue.read().unwrap().last_hash()
}
/// Forget all signatures. Useful for benchmarking.
@ -312,7 +312,7 @@ impl Bank {
for (i, tx) in txs.iter().enumerate() {
match &res[i] {
Ok(_) => status_cache.add(&tx.signatures[0]),
Err(BankError::BlockHashNotFound) => (),
Err(BankError::BlockhashNotFound) => (),
Err(BankError::DuplicateSignature) => (),
Err(BankError::AccountNotFound) => (),
Err(e) => {
@ -334,7 +334,7 @@ impl Bank {
slots_and_stakes.sort_by(|a, b| a.0.cmp(&b.0));
let max_slot = self.slot_height();
let min_slot = max_slot.saturating_sub(MAX_RECENT_BLOCK_HASHES as u64);
let min_slot = max_slot.saturating_sub(MAX_RECENT_BLOCKHASHES as u64);
let mut total_stake = 0;
for (slot, stake) in slots_and_stakes.iter() {
@ -342,7 +342,7 @@ impl Bank {
total_stake += stake;
if total_stake > supermajority_stake {
return self
.block_hash_queue
.blockhash_queue
.read()
.unwrap()
.hash_height_to_timestamp(*slot);
@ -373,8 +373,8 @@ impl Bank {
// Register a new block hash if at the last tick in the slot
if current_tick_height % self.ticks_per_slot == self.ticks_per_slot - 1 {
let mut block_hash_queue = self.block_hash_queue.write().unwrap();
block_hash_queue.register_hash(hash);
let mut blockhash_queue = self.blockhash_queue.write().unwrap();
blockhash_queue.register_hash(hash);
}
if current_tick_height % NUM_TICKS_PER_SECOND == 0 {
@ -421,13 +421,13 @@ impl Bank {
max_age: usize,
error_counters: &mut ErrorCounters,
) -> Vec<Result<()>> {
let hash_queue = self.block_hash_queue.read().unwrap();
let hash_queue = self.blockhash_queue.read().unwrap();
txs.iter()
.zip(lock_results.into_iter())
.map(|(tx, lock_res)| {
if lock_res.is_ok() && !hash_queue.check_entry_age(tx.recent_block_hash, max_age) {
error_counters.reserve_block_hash += 1;
Err(BankError::BlockHashNotFound)
if lock_res.is_ok() && !hash_queue.check_entry_age(tx.recent_blockhash, max_age) {
error_counters.reserve_blockhash += 1;
Err(BankError::BlockhashNotFound)
} else {
lock_res
}
@ -523,16 +523,16 @@ impl Bank {
.increment_transaction_count(self.accounts_id, tx_count);
inc_new_counter_info!("bank-process_transactions-txs", tx_count);
if 0 != error_counters.block_hash_not_found {
if 0 != error_counters.blockhash_not_found {
inc_new_counter_info!(
"bank-process_transactions-error-block_hash_not_found",
error_counters.block_hash_not_found
"bank-process_transactions-error-blockhash_not_found",
error_counters.blockhash_not_found
);
}
if 0 != error_counters.reserve_block_hash {
if 0 != error_counters.reserve_blockhash {
inc_new_counter_info!(
"bank-process_transactions-error-reserve_block_hash",
error_counters.reserve_block_hash
"bank-process_transactions-error-reserve_blockhash",
error_counters.reserve_blockhash
);
}
if 0 != error_counters.duplicate_signature {
@ -627,21 +627,21 @@ impl Bank {
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
let lock_results = self.lock_accounts(txs);
let results =
self.load_execute_and_commit_transactions(txs, lock_results, MAX_RECENT_BLOCK_HASHES);
self.load_execute_and_commit_transactions(txs, lock_results, MAX_RECENT_BLOCKHASHES);
self.unlock_accounts(txs, &results);
results
}
/// Create, sign, and process a Transaction from `keypair` to `to` of
/// `n` tokens where `block_hash` is the last Entry ID observed by the client.
/// `n` tokens where `blockhash` is the last Entry ID observed by the client.
pub fn transfer(
&self,
n: u64,
keypair: &Keypair,
to: Pubkey,
block_hash: Hash,
blockhash: Hash,
) -> Result<Signature> {
let tx = SystemTransaction::new_account(keypair, to, n, block_hash, 0);
let tx = SystemTransaction::new_account(keypair, to, n, blockhash, 0);
let signature = tx.signatures[0];
self.process_transaction(&tx).map(|_| signature)
}
@ -881,7 +881,7 @@ mod tests {
let (genesis_block, mint_keypair) = GenesisBlock::new(10_000);
let pubkey = Keypair::new().pubkey();
let bank = Bank::new(&genesis_block);
assert_eq!(bank.last_block_hash(), genesis_block.hash());
assert_eq!(bank.last_blockhash(), genesis_block.hash());
bank.transfer(1_000, &mint_keypair, pubkey, genesis_block.hash())
.unwrap();
@ -899,7 +899,7 @@ mod tests {
let key1 = Keypair::new().pubkey();
let key2 = Keypair::new().pubkey();
let bank = Bank::new(&genesis_block);
assert_eq!(bank.last_block_hash(), genesis_block.hash());
assert_eq!(bank.last_blockhash(), genesis_block.hash());
let t1 = SystemTransaction::new_move(&mint_keypair, key1, 1, genesis_block.hash(), 0);
let t2 = SystemTransaction::new_move(&mint_keypair, key2, 1, genesis_block.hash(), 0);
@ -1242,7 +1242,7 @@ mod tests {
let results_alice = bank.load_execute_and_commit_transactions(
&pay_alice,
lock_result,
MAX_RECENT_BLOCK_HASHES,
MAX_RECENT_BLOCKHASHES,
);
assert_eq!(results_alice[0], Ok(()));
@ -1394,11 +1394,11 @@ mod tests {
let pubkey = Keypair::new().pubkey();
bank0
.transfer(1_000, &mint_keypair, pubkey, bank0.last_block_hash())
.transfer(1_000, &mint_keypair, pubkey, bank0.last_blockhash())
.unwrap();
assert_ne!(bank0.hash_internal_state(), initial_state);
bank1
.transfer(1_000, &mint_keypair, pubkey, bank1.last_block_hash())
.transfer(1_000, &mint_keypair, pubkey, bank1.last_blockhash())
.unwrap();
assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state());

View File

@ -31,8 +31,8 @@ impl<T: Clone> Default for StatusCache<T> {
}
impl<T: Clone> StatusCache<T> {
pub fn new(block_hash: &Hash) -> Self {
let keys = (0..27).map(|i| block_hash.hash_at_index(i)).collect();
pub fn new(blockhash: &Hash) -> Self {
let keys = (0..27).map(|i| blockhash.hash_at_index(i)).collect();
Self {
signatures: Bloom::new(38_340_234, keys),
failures: HashMap::new(),
@ -118,8 +118,8 @@ impl<T: Clone> StatusCache<T> {
}
/// Crate a new cache, pushing the old cache into the merged queue
pub fn new_cache(&mut self, block_hash: &Hash) {
let mut old = Self::new(block_hash);
pub fn new_cache(&mut self, blockhash: &Hash) {
let mut old = Self::new(blockhash);
std::mem::swap(&mut old.signatures, &mut self.signatures);
std::mem::swap(&mut old.failures, &mut self.failures);
assert!(old.merges.is_empty());
@ -175,8 +175,8 @@ mod tests {
#[test]
fn test_has_signature() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut status_cache = BankStatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut status_cache = BankStatusCache::new(&blockhash);
assert_eq!(status_cache.has_signature(&sig), false);
assert_eq!(status_cache.get_signature_status(&sig), None);
status_cache.add(&sig);
@ -187,12 +187,12 @@ mod tests {
#[test]
fn test_has_signature_checkpoint() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.get_signature_status(&sig), Some(Ok(())));
let block_hash = hash(block_hash.as_ref());
let second = StatusCache::new(&block_hash);
let blockhash = hash(blockhash.as_ref());
let second = StatusCache::new(&blockhash);
let checkpoints = [&second, &first];
assert_eq!(
BankStatusCache::get_signature_status_all(&checkpoints, &sig),
@ -204,12 +204,12 @@ mod tests {
#[test]
fn test_new_cache() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.get_signature_status(&sig), Some(Ok(())));
let block_hash = hash(block_hash.as_ref());
first.new_cache(&block_hash);
let blockhash = hash(blockhash.as_ref());
first.new_cache(&blockhash);
assert_eq!(first.get_signature_status(&sig), Some(Ok(())));
assert!(first.has_signature(&sig));
first.clear();
@ -220,13 +220,13 @@ mod tests {
#[test]
fn test_new_cache_full() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.get_signature_status(&sig), Some(Ok(())));
for _ in 0..(MAX_CACHE_ENTRIES + 1) {
let block_hash = hash(block_hash.as_ref());
first.new_cache(&block_hash);
let blockhash = hash(blockhash.as_ref());
first.new_cache(&blockhash);
}
assert_eq!(first.get_signature_status(&sig), None);
assert!(!first.has_signature(&sig));
@ -235,17 +235,17 @@ mod tests {
#[test]
fn test_status_cache_squash_has_signature() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = BankStatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.get_signature_status(&sig), Some(Ok(())));
// give first a merge
let block_hash = hash(block_hash.as_ref());
first.new_cache(&block_hash);
let blockhash = hash(blockhash.as_ref());
first.new_cache(&blockhash);
let block_hash = hash(block_hash.as_ref());
let mut second = BankStatusCache::new(&block_hash);
let blockhash = hash(blockhash.as_ref());
let mut second = BankStatusCache::new(&blockhash);
second.squash(&[&first]);
@ -256,21 +256,21 @@ mod tests {
#[test]
#[ignore] // takes a lot of time or RAM or both..
fn test_status_cache_squash_overflow() {
let mut block_hash = hash(Hash::default().as_ref());
let mut cache = BankStatusCache::new(&block_hash);
let mut blockhash = hash(Hash::default().as_ref());
let mut cache = BankStatusCache::new(&blockhash);
let parents: Vec<_> = (0..MAX_CACHE_ENTRIES)
.map(|_| {
block_hash = hash(block_hash.as_ref());
blockhash = hash(blockhash.as_ref());
BankStatusCache::new(&block_hash)
BankStatusCache::new(&blockhash)
})
.collect();
let mut parents_refs: Vec<_> = parents.iter().collect();
block_hash = hash(Hash::default().as_ref());
let mut root = BankStatusCache::new(&block_hash);
blockhash = hash(Hash::default().as_ref());
let mut root = BankStatusCache::new(&blockhash);
let sig = Signature::default();
root.add(&sig);
@ -290,8 +290,8 @@ mod tests {
#[test]
fn test_failure_status() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&blockhash);
first.add(&sig);
first.save_failure_status(&sig, BankError::DuplicateSignature);
assert_eq!(first.has_signature(&sig), true);
@ -304,8 +304,8 @@ mod tests {
#[test]
fn test_clear_signatures() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.has_signature(&sig), true);
first.save_failure_status(&sig, BankError::DuplicateSignature);
@ -320,11 +320,11 @@ mod tests {
#[test]
fn test_clear_signatures_all() {
let sig = Signature::default();
let block_hash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&block_hash);
let blockhash = hash(Hash::default().as_ref());
let mut first = StatusCache::new(&blockhash);
first.add(&sig);
assert_eq!(first.has_signature(&sig), true);
let mut second = StatusCache::new(&block_hash);
let mut second = StatusCache::new(&blockhash);
let mut checkpoints = [&mut second, &mut first];
BankStatusCache::clear_all(&mut checkpoints);
assert_eq!(

View File

@ -20,7 +20,7 @@ impl BudgetTransaction {
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let contract = Keypair::new().pubkey();
@ -29,7 +29,7 @@ impl BudgetTransaction {
TransactionBuilder::new(fee)
.push(SystemInstruction::new_move(from, contract, tokens))
.push(Instruction::new_budget(contract, payment))
.sign(&[from_keypair], recent_block_hash)
.sign(&[from_keypair], recent_blockhash)
}
/// Create and sign a new Transaction. Used for unit-testing.
@ -38,9 +38,9 @@ impl BudgetTransaction {
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
) -> Transaction {
Self::new_payment(from_keypair, to, tokens, recent_block_hash, 0)
Self::new_payment(from_keypair, to, tokens, recent_blockhash, 0)
}
/// Create and sign a new Witness Timestamp. Used for unit-testing.
@ -49,7 +49,7 @@ impl BudgetTransaction {
contract: Pubkey,
to: Pubkey,
dt: DateTime<Utc>,
recent_block_hash: Hash,
recent_blockhash: Hash,
) -> Transaction {
let instruction = Instruction::ApplyTimestamp(dt);
Transaction::new(
@ -57,7 +57,7 @@ impl BudgetTransaction {
&[contract, to],
budget_program::id(),
&instruction,
recent_block_hash,
recent_blockhash,
0,
)
}
@ -67,7 +67,7 @@ impl BudgetTransaction {
from_keypair: &Keypair,
contract: Pubkey,
to: Pubkey,
recent_block_hash: Hash,
recent_blockhash: Hash,
) -> Transaction {
let instruction = Instruction::ApplySignature;
let mut keys = vec![contract];
@ -79,7 +79,7 @@ impl BudgetTransaction {
&keys,
budget_program::id(),
&instruction,
recent_block_hash,
recent_blockhash,
0,
)
}
@ -93,7 +93,7 @@ impl BudgetTransaction {
dt_pubkey: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
) -> Transaction {
let expr = if let Some(from) = cancelable {
BudgetExpr::Or(
@ -118,7 +118,7 @@ impl BudgetTransaction {
&[contract],
budget_program::id(),
&instruction,
recent_block_hash,
recent_blockhash,
0,
)
}
@ -130,7 +130,7 @@ impl BudgetTransaction {
witness: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
) -> Transaction {
let expr = if let Some(from) = cancelable {
BudgetExpr::Or(
@ -155,7 +155,7 @@ impl BudgetTransaction {
&[contract],
budget_program::id(),
&instruction,
recent_block_hash,
recent_blockhash,
0,
)
}

View File

@ -14,7 +14,7 @@ impl LoaderTransaction {
loader: Pubkey,
offset: u32,
bytes: Vec<u8>,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let instruction = LoaderInstruction::Write { offset, bytes };
@ -23,7 +23,7 @@ impl LoaderTransaction {
&[],
loader,
&instruction,
recent_block_hash,
recent_blockhash,
fee,
)
}
@ -31,7 +31,7 @@ impl LoaderTransaction {
pub fn new_finalize(
from_keypair: &Keypair,
loader: Pubkey,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let instruction = LoaderInstruction::Finalize;
@ -40,7 +40,7 @@ impl LoaderTransaction {
&[],
loader,
&instruction,
recent_block_hash,
recent_blockhash,
fee,
)
}

View File

@ -48,7 +48,7 @@ pub enum StorageProgram {
entry_height: u64,
signature: Signature,
},
AdvertiseStorageRecentBlockHash {
AdvertiseStorageRecentBlockhash {
hash: Hash,
entry_height: u64,
},
@ -80,7 +80,7 @@ impl StorageTransaction {
pub fn new_mining_proof(
from_keypair: &Keypair,
sha_state: Hash,
recent_block_hash: Hash,
recent_blockhash: Hash,
entry_height: u64,
signature: Signature,
) -> Transaction {
@ -89,25 +89,25 @@ impl StorageTransaction {
entry_height,
signature,
};
Transaction::new(from_keypair, &[], id(), &program, recent_block_hash, 0)
Transaction::new(from_keypair, &[], id(), &program, recent_blockhash, 0)
}
pub fn new_advertise_recent_block_hash(
pub fn new_advertise_recent_blockhash(
from_keypair: &Keypair,
storage_hash: Hash,
recent_block_hash: Hash,
recent_blockhash: Hash,
entry_height: u64,
) -> Transaction {
let program = StorageProgram::AdvertiseStorageRecentBlockHash {
let program = StorageProgram::AdvertiseStorageRecentBlockhash {
hash: storage_hash,
entry_height,
};
Transaction::new(from_keypair, &[], id(), &program, recent_block_hash, 0)
Transaction::new(from_keypair, &[], id(), &program, recent_blockhash, 0)
}
pub fn new_proof_validation(
from_keypair: &Keypair,
recent_block_hash: Hash,
recent_blockhash: Hash,
entry_height: u64,
proof_mask: Vec<ProofStatus>,
) -> Transaction {
@ -115,15 +115,15 @@ impl StorageTransaction {
entry_height,
proof_mask,
};
Transaction::new(from_keypair, &[], id(), &program, recent_block_hash, 0)
Transaction::new(from_keypair, &[], id(), &program, recent_blockhash, 0)
}
pub fn new_reward_claim(
from_keypair: &Keypair,
recent_block_hash: Hash,
recent_blockhash: Hash,
entry_height: u64,
) -> Transaction {
let program = StorageProgram::ClaimStorageReward { entry_height };
Transaction::new(from_keypair, &[], id(), &program, recent_block_hash, 0)
Transaction::new(from_keypair, &[], id(), &program, recent_blockhash, 0)
}
}

View File

@ -14,7 +14,7 @@ impl SystemTransaction {
pub fn new_program_account(
from_keypair: &Keypair,
to: Pubkey,
recent_block_hash: Hash,
recent_blockhash: Hash,
tokens: u64,
space: u64,
program_id: Pubkey,
@ -30,7 +30,7 @@ impl SystemTransaction {
&[to],
system_program::id(),
&create,
recent_block_hash,
recent_blockhash,
fee,
)
}
@ -40,14 +40,14 @@ impl SystemTransaction {
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let program_id = system_program::id();
Self::new_program_account(
from_keypair,
to,
recent_block_hash,
recent_blockhash,
tokens,
0,
program_id,
@ -57,7 +57,7 @@ impl SystemTransaction {
/// Create and sign new SystemInstruction::Assign transaction
pub fn new_assign(
from_keypair: &Keypair,
recent_block_hash: Hash,
recent_blockhash: Hash,
program_id: Pubkey,
fee: u64,
) -> Transaction {
@ -67,7 +67,7 @@ impl SystemTransaction {
&[],
system_program::id(),
&assign,
recent_block_hash,
recent_blockhash,
fee,
)
}
@ -76,7 +76,7 @@ impl SystemTransaction {
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let move_tokens = SystemInstruction::Move { tokens };
@ -85,7 +85,7 @@ impl SystemTransaction {
&[to],
system_program::id(),
&move_tokens,
recent_block_hash,
recent_blockhash,
fee,
)
}
@ -93,7 +93,7 @@ impl SystemTransaction {
pub fn new_move_many(
from: &Keypair,
moves: &[(Pubkey, u64)],
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let instructions: Vec<_> = moves
@ -109,7 +109,7 @@ impl SystemTransaction {
Transaction::new_with_instructions(
&[from],
&to_keys,
recent_block_hash,
recent_blockhash,
fee,
vec![system_program::id()],
instructions,

View File

@ -11,14 +11,14 @@ pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 64;
/// The time window of recent block hash values that the bank will track the signatures
/// of over. Once the bank discards a block hash, it will reject any transactions that use
/// that `recent_block_hash` in a transaction. Lowering this value reduces memory consumption,
/// but requires clients to update its `recent_block_hash` more frequently. Raising the value
/// that `recent_blockhash` in a transaction. Lowering this value reduces memory consumption,
/// but requires clients to update its `recent_blockhash` more frequently. Raising the value
/// lengthens the time a client must wait to be certain a missing transaction will
/// not be processed by the network.
pub const MAX_HASH_AGE_IN_SECONDS: usize = 120;
pub const MAX_RECENT_TICK_HASHES: usize = NUM_TICKS_PER_SECOND as usize * MAX_HASH_AGE_IN_SECONDS;
pub const MAX_RECENT_BLOCK_HASHES: usize =
pub const MAX_RECENT_BLOCKHASHES: usize =
MAX_RECENT_TICK_HASHES / (DEFAULT_TICKS_PER_SLOT as usize);
pub fn duration_as_us(d: &Duration) -> u64 {

View File

@ -79,13 +79,13 @@ impl Instruction<u8, u8> {
/// An atomic transaction
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Transaction {
/// A set of digital signatures of `account_keys`, `program_ids`, `recent_block_hash`, `fee` and `instructions`, signed by the first
/// A set of digital signatures of `account_keys`, `program_ids`, `recent_blockhash`, `fee` and `instructions`, signed by the first
/// signatures.len() keys of account_keys
pub signatures: Vec<Signature>,
/// All the account keys used by this transaction
pub account_keys: Vec<Pubkey>,
/// The id of a recent ledger entry.
pub recent_block_hash: Hash,
pub recent_blockhash: Hash,
/// The number of tokens paid for processing and storing of this transaction.
pub fee: u64,
/// All the program id keys used to execute this transaction's instructions
@ -101,7 +101,7 @@ impl Transaction {
transaction_keys: &[Pubkey],
program_id: Pubkey,
userdata: &S,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Self {
let program_ids = vec![program_id];
@ -110,7 +110,7 @@ impl Transaction {
Self::new_with_instructions(
&[from_keypair],
transaction_keys,
recent_block_hash,
recent_blockhash,
fee,
program_ids,
instructions,
@ -121,7 +121,7 @@ impl Transaction {
transaction_keys: &[Pubkey],
program_id: Pubkey,
userdata: &T,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Self {
let program_ids = vec![program_id];
@ -132,7 +132,7 @@ impl Transaction {
Self::new_with_instructions::<Keypair>(
&[],
&keys[..],
recent_block_hash,
recent_blockhash,
fee,
program_ids,
instructions,
@ -142,14 +142,14 @@ impl Transaction {
/// * `from_keypair` - The key used to sign the transaction. This key is stored as keys[0]
/// * `account_keys` - The keys for the transaction. These are the program state
/// instances or token recipient keys.
/// * `recent_block_hash` - The PoH hash.
/// * `recent_blockhash` - The PoH hash.
/// * `fee` - The transaction fee.
/// * `program_ids` - The keys that identify programs used in the `instruction` vector.
/// * `instructions` - The programs and their arguments that the transaction will execute atomically
pub fn new_with_instructions<T: KeypairUtil>(
from_keypairs: &[&T],
keys: &[Pubkey],
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
program_ids: Vec<Pubkey>,
instructions: Vec<Instruction<u8, u8>>,
@ -162,12 +162,12 @@ impl Transaction {
let mut tx = Transaction {
signatures: vec![],
account_keys,
recent_block_hash: Hash::default(),
recent_blockhash: Hash::default(),
fee,
program_ids,
instructions,
};
tx.sign(from_keypairs, recent_block_hash);
tx.sign(from_keypairs, recent_blockhash);
tx
}
pub fn userdata(&self, instruction_index: usize) -> &[u8] {
@ -205,8 +205,8 @@ impl Transaction {
let mut wr = Cursor::new(&mut buf[..]);
serialize_vec_with(&mut wr, &self.account_keys, Transaction::serialize_pubkey)
.expect("serialize account_keys");
wr.write_all(self.recent_block_hash.as_ref())
.expect("serialize recent_block_hash");
wr.write_all(self.recent_blockhash.as_ref())
.expect("serialize recent_blockhash");
wr.write_u64::<LittleEndian>(self.fee)
.expect("serialize fee");
serialize_vec_with(&mut wr, &self.program_ids, Transaction::serialize_pubkey)
@ -218,8 +218,8 @@ impl Transaction {
}
/// Sign this transaction.
pub fn sign<T: KeypairUtil>(&mut self, keypairs: &[&T], recent_block_hash: Hash) {
self.recent_block_hash = recent_block_hash;
pub fn sign<T: KeypairUtil>(&mut self, keypairs: &[&T], recent_blockhash: Hash) {
self.recent_blockhash = recent_blockhash;
let message = self.message();
self.signatures = keypairs
.iter()
@ -332,7 +332,7 @@ impl Serialize for Transaction {
.map_err(Error::custom)?;
serialize_vec_with(&mut wr, &self.account_keys, Transaction::serialize_pubkey)
.map_err(Error::custom)?;
wr.write_all(self.recent_block_hash.as_ref())
wr.write_all(self.recent_blockhash.as_ref())
.map_err(Error::custom)?;
wr.write_u64::<LittleEndian>(self.fee)
.map_err(Error::custom)?;
@ -366,7 +366,7 @@ impl<'a> serde::de::Visitor<'a> for TransactionVisitor {
.map_err(Error::custom)?;
let mut buf = [0; size_of::<Hash>()];
rd.read_exact(&mut buf).map_err(Error::custom)?;
let recent_block_hash: Hash = Hash::new(&buf);
let recent_blockhash: Hash = Hash::new(&buf);
let fee = rd.read_u64::<LittleEndian>().map_err(Error::custom)?;
let program_ids: Vec<Pubkey> =
deserialize_vec_with(&mut rd, Transaction::deserialize_pubkey)
@ -376,7 +376,7 @@ impl<'a> serde::de::Visitor<'a> for TransactionVisitor {
Ok(Transaction {
signatures,
account_keys,
recent_block_hash,
recent_blockhash,
fee,
program_ids,
instructions,

View File

@ -91,7 +91,7 @@ impl TransactionBuilder {
}
/// Return a signed transaction.
pub fn sign<T: KeypairUtil>(&self, keypairs: &[&T], recent_block_hash: Hash) -> Transaction {
pub fn sign<T: KeypairUtil>(&self, keypairs: &[&T], recent_blockhash: Hash) -> Transaction {
let program_ids = self.program_ids();
let (mut signed_keys, unsigned_keys) = self.keys();
for (i, keypair) in keypairs.iter().enumerate() {
@ -104,7 +104,7 @@ impl TransactionBuilder {
Transaction::new_with_instructions(
keypairs,
&unsigned_keys,
recent_block_hash,
recent_blockhash,
self.fee,
program_ids,
instructions,

View File

@ -16,20 +16,20 @@ impl VoteTransaction {
pub fn new_vote<T: KeypairUtil>(
voting_keypair: &T,
slot_height: u64,
recent_block_hash: Hash,
recent_blockhash: Hash,
fee: u64,
) -> Transaction {
let vote = Vote { slot_height };
TransactionBuilder::new(fee)
.push(VoteInstruction::new_vote(voting_keypair.pubkey(), vote))
.sign(&[voting_keypair], recent_block_hash)
.sign(&[voting_keypair], recent_blockhash)
}
/// Fund or create the staking account with tokens
pub fn fund_staking_account(
from_keypair: &Keypair,
vote_account_id: Pubkey,
recent_block_hash: Hash,
recent_blockhash: Hash,
num_tokens: u64,
fee: u64,
) -> Transaction {
@ -41,7 +41,7 @@ impl VoteTransaction {
Transaction::new_with_instructions(
&[from_keypair],
&[vote_account_id],
recent_block_hash,
recent_blockhash,
fee,
vec![system_program::id(), vote_program::id()],
vec![
@ -54,7 +54,7 @@ impl VoteTransaction {
/// Choose a node id to `delegate` or `assign` this vote account to
pub fn delegate_vote_account<T: KeypairUtil>(
vote_keypair: &T,
recent_block_hash: Hash,
recent_blockhash: Hash,
node_id: Pubkey,
fee: u64,
) -> Transaction {
@ -63,7 +63,7 @@ impl VoteTransaction {
vote_keypair.pubkey(),
node_id,
))
.sign(&[vote_keypair], recent_block_hash)
.sign(&[vote_keypair], recent_blockhash)
}
fn get_vote(tx: &Transaction, ix_index: usize) -> Option<(Pubkey, Vote, Hash)> {
@ -72,7 +72,7 @@ impl VoteTransaction {
}
let instruction = deserialize(&tx.userdata(ix_index)).unwrap();
if let VoteInstruction::Vote(vote) = instruction {
Some((tx.account_keys[0], vote, tx.recent_block_hash))
Some((tx.account_keys[0], vote, tx.recent_blockhash))
} else {
None
}
@ -93,11 +93,11 @@ mod tests {
fn test_get_votes() {
let keypair = Keypair::new();
let slot_height = 1;
let recent_block_hash = Hash::default();
let transaction = VoteTransaction::new_vote(&keypair, slot_height, recent_block_hash, 0);
let recent_blockhash = Hash::default();
let transaction = VoteTransaction::new_vote(&keypair, slot_height, recent_blockhash, 0);
assert_eq!(
VoteTransaction::get_votes(&transaction),
vec![(keypair.pubkey(), Vote::new(slot_height), recent_block_hash)]
vec![(keypair.pubkey(), Vote::new(slot_height), recent_blockhash)]
);
}
}

View File

@ -44,7 +44,7 @@ fn test_replicator_startup_basic() {
let (genesis_block, mint_keypair) =
GenesisBlock::new_with_leader(1_000_000_000, leader_info.id, 42);
let (leader_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (leader_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let validator_ledger_path = tmp_copy_blocktree!(&leader_ledger_path);
@ -72,11 +72,11 @@ fn test_replicator_startup_basic() {
let voting_keypair = VotingKeypair::new_local(&validator_keypair);
let mut leader_client = mk_client(&leader_info);
let block_hash = leader_client.get_recent_block_hash();
debug!("block_hash: {:?}", block_hash);
let blockhash = leader_client.get_recent_blockhash();
debug!("blockhash: {:?}", blockhash);
leader_client
.transfer(10, &mint_keypair, validator_keypair.pubkey(), &block_hash)
.transfer(10, &mint_keypair, validator_keypair.pubkey(), &blockhash)
.unwrap();
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
@ -98,9 +98,9 @@ fn test_replicator_startup_basic() {
info!("starting transfers..");
for i in 0..64 {
debug!("transfer {}", i);
let block_hash = leader_client.get_recent_block_hash();
let blockhash = leader_client.get_recent_blockhash();
let mut transaction =
SystemTransaction::new_account(&mint_keypair, bob.pubkey(), 1, block_hash, 0);
SystemTransaction::new_account(&mint_keypair, bob.pubkey(), 1, blockhash, 0);
leader_client
.retry_transfer(&mint_keypair, &mut transaction, 5)
.unwrap();
@ -116,13 +116,13 @@ fn test_replicator_startup_basic() {
info!("giving replicator tokens..");
let block_hash = leader_client.get_recent_block_hash();
let blockhash = leader_client.get_recent_blockhash();
// Give the replicator some tokens
let mut tx = SystemTransaction::new_account(
&mint_keypair,
replicator_keypair.pubkey(),
1,
block_hash,
blockhash,
0,
);
leader_client
@ -238,7 +238,7 @@ fn test_replicator_startup_leader_hang() {
let leader_ledger_path = "replicator_test_leader_ledger";
let (genesis_block, _mint_keypair) = GenesisBlock::new(10_000);
let (replicator_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (replicator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
{
let replicator_keypair = Keypair::new();
@ -275,13 +275,13 @@ fn test_replicator_startup_ledger_hang() {
let (genesis_block, _mint_keypair) =
GenesisBlock::new_with_leader(100, leader_keypair.pubkey(), 42);
let (replicator_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (replicator_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
info!("starting leader node");
let leader_node = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_info = leader_node.info.clone();
let (leader_ledger_path, _block_hash) = create_new_tmp_ledger!(&genesis_block);
let (leader_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let validator_ledger_path = tmp_copy_blocktree!(&leader_ledger_path);
{

View File

@ -24,7 +24,7 @@ fn test_rpc_send_tx() {
let request = json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentBlockHash",
"method": "getRecentBlockhash",
"params": json!([])
});
let rpc_addr = leader_data.rpc;
@ -36,13 +36,13 @@ fn test_rpc_send_tx() {
.send()
.unwrap();
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
let block_hash_vec = bs58::decode(json["result"].as_str().unwrap())
let blockhash_vec = bs58::decode(json["result"].as_str().unwrap())
.into_vec()
.unwrap();
let block_hash = Hash::new(&block_hash_vec);
let blockhash = Hash::new(&blockhash_vec);
info!("block_hash: {:?}", block_hash);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
info!("blockhash: {:?}", blockhash);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let serial_tx = serialize(&tx).unwrap();
let client = reqwest::Client::new();

View File

@ -86,7 +86,7 @@ fn test_replay() {
let tvu_addr = target1.info.tvu;
let bank = Bank::new(&genesis_block);
let block_hash = bank.last_block_hash();
let blockhash = bank.last_blockhash();
let bank_forks = BankForks::new(0, bank);
let bank_forks_info = vec![BankForksInfo {
bank_id: 0,
@ -138,7 +138,7 @@ fn test_replay() {
let num_transfers = 10;
let mut transfer_amount = 501;
let bob_keypair = Keypair::new();
let mut cur_hash = block_hash;
let mut cur_hash = blockhash;
for i in 0..num_transfers {
let entry0 = next_entry_mut(&mut cur_hash, i, vec![]);
let entry_tick0 = next_entry_mut(&mut cur_hash, i + 1, vec![]);
@ -147,7 +147,7 @@ fn test_replay() {
&mint_keypair,
bob_keypair.pubkey(),
transfer_amount,
block_hash,
blockhash,
0,
);
let entry_tick1 = next_entry_mut(&mut cur_hash, i + 1, vec![]);

View File

@ -401,7 +401,7 @@ fn process_deploy(
}
}
let block_hash = get_recent_block_hash(&rpc_client)?;
let blockhash = get_recent_blockhash(&rpc_client)?;
let program_id = Keypair::new();
let mut file = File::open(program_location).map_err(|err| {
WalletError::DynamicProgramError(
@ -418,7 +418,7 @@ fn process_deploy(
let mut tx = SystemTransaction::new_program_account(
&config.id,
program_id.pubkey(),
block_hash,
blockhash,
1,
program_userdata.len() as u64,
bpf_loader::id(),
@ -439,7 +439,7 @@ fn process_deploy(
bpf_loader::id(),
(i * USERDATA_CHUNK_SIZE) as u32,
chunk.to_vec(),
block_hash,
blockhash,
0,
)
})
@ -447,7 +447,7 @@ fn process_deploy(
send_and_confirm_transactions(&rpc_client, write_transactions, &program_id)?;
trace!("Finalizing program account");
let mut tx = LoaderTransaction::new_finalize(&program_id, bpf_loader::id(), block_hash, 0);
let mut tx = LoaderTransaction::new_finalize(&program_id, bpf_loader::id(), blockhash, 0);
send_and_confirm_transaction(&rpc_client, &mut tx, &program_id).map_err(|_| {
WalletError::DynamicProgramError("Program finalize transaction failed".to_string())
})?;
@ -468,10 +468,10 @@ fn process_pay(
witnesses: &Option<Vec<Pubkey>>,
cancelable: Option<Pubkey>,
) -> ProcessResult {
let block_hash = get_recent_block_hash(&rpc_client)?;
let blockhash = get_recent_blockhash(&rpc_client)?;
if timestamp == None && *witnesses == None {
let mut tx = SystemTransaction::new_account(&config.id, to, tokens, block_hash, 0);
let mut tx = SystemTransaction::new_account(&config.id, to, tokens, blockhash, 0);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
Ok(signature_str.to_string())
} else if *witnesses == None {
@ -489,7 +489,7 @@ fn process_pay(
let mut tx = SystemTransaction::new_program_account(
&config.id,
contract_funds.pubkey(),
block_hash,
blockhash,
tokens,
0,
budget_program_id,
@ -501,7 +501,7 @@ fn process_pay(
let mut tx = SystemTransaction::new_program_account(
&config.id,
contract_state.pubkey(),
block_hash,
blockhash,
1,
196,
budget_program_id,
@ -518,7 +518,7 @@ fn process_pay(
dt_pubkey,
cancelable,
tokens,
block_hash,
blockhash,
);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
@ -528,7 +528,7 @@ fn process_pay(
})
.to_string())
} else if timestamp == None {
let block_hash = get_recent_block_hash(&rpc_client)?;
let blockhash = get_recent_blockhash(&rpc_client)?;
let witness = if let Some(ref witness_vec) = *witnesses {
witness_vec[0]
@ -546,7 +546,7 @@ fn process_pay(
let mut tx = SystemTransaction::new_program_account(
&config.id,
contract_funds.pubkey(),
block_hash,
blockhash,
tokens,
0,
budget_program_id,
@ -558,7 +558,7 @@ fn process_pay(
let mut tx = SystemTransaction::new_program_account(
&config.id,
contract_state.pubkey(),
block_hash,
blockhash,
1,
196,
budget_program_id,
@ -574,7 +574,7 @@ fn process_pay(
witness,
cancelable,
tokens,
block_hash,
blockhash,
);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
@ -589,9 +589,9 @@ fn process_pay(
}
fn process_cancel(rpc_client: &RpcClient, config: &WalletConfig, pubkey: Pubkey) -> ProcessResult {
let block_hash = get_recent_block_hash(&rpc_client)?;
let blockhash = get_recent_blockhash(&rpc_client)?;
let mut tx =
BudgetTransaction::new_signature(&config.id, pubkey, config.id.pubkey(), block_hash);
BudgetTransaction::new_signature(&config.id, pubkey, config.id.pubkey(), blockhash);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
Ok(signature_str.to_string())
}
@ -622,9 +622,9 @@ fn process_time_elapsed(
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.id, 1)?;
}
let block_hash = get_recent_block_hash(&rpc_client)?;
let blockhash = get_recent_blockhash(&rpc_client)?;
let mut tx = BudgetTransaction::new_timestamp(&config.id, pubkey, to, dt, block_hash);
let mut tx = BudgetTransaction::new_timestamp(&config.id, pubkey, to, dt, blockhash);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
Ok(signature_str.to_string())
@ -643,8 +643,8 @@ fn process_witness(
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.id, 1)?;
}
let block_hash = get_recent_block_hash(&rpc_client)?;
let mut tx = BudgetTransaction::new_signature(&config.id, pubkey, to, block_hash);
let blockhash = get_recent_blockhash(&rpc_client)?;
let mut tx = BudgetTransaction::new_signature(&config.id, pubkey, to, blockhash);
let signature_str = send_and_confirm_transaction(&rpc_client, &mut tx, &config.id)?;
Ok(signature_str.to_string())
@ -714,45 +714,45 @@ pub fn process_command(config: &WalletConfig) -> ProcessResult {
}
}
fn get_recent_block_hash(rpc_client: &RpcClient) -> Result<Hash, Box<dyn error::Error>> {
let result = rpc_client.retry_make_rpc_request(1, &RpcRequest::GetRecentBlockHash, None, 5)?;
fn get_recent_blockhash(rpc_client: &RpcClient) -> Result<Hash, Box<dyn error::Error>> {
let result = rpc_client.retry_make_rpc_request(1, &RpcRequest::GetRecentBlockhash, None, 5)?;
if result.as_str().is_none() {
Err(WalletError::RpcRequestError(
"Received bad block_hash".to_string(),
"Received bad blockhash".to_string(),
))?
}
let block_hash_str = result.as_str().unwrap();
let block_hash_vec = bs58::decode(block_hash_str)
let blockhash_str = result.as_str().unwrap();
let blockhash_vec = bs58::decode(blockhash_str)
.into_vec()
.map_err(|_| WalletError::RpcRequestError("Received bad block_hash".to_string()))?;
Ok(Hash::new(&block_hash_vec))
.map_err(|_| WalletError::RpcRequestError("Received bad blockhash".to_string()))?;
Ok(Hash::new(&blockhash_vec))
}
fn get_next_block_hash(
fn get_next_blockhash(
rpc_client: &RpcClient,
previous_block_hash: &Hash,
previous_blockhash: &Hash,
) -> Result<Hash, Box<dyn error::Error>> {
let mut next_block_hash_retries = 3;
let mut next_blockhash_retries = 3;
loop {
let next_block_hash = get_recent_block_hash(rpc_client)?;
let next_blockhash = get_recent_blockhash(rpc_client)?;
if cfg!(not(test)) {
if next_block_hash != *previous_block_hash {
return Ok(next_block_hash);
if next_blockhash != *previous_blockhash {
return Ok(next_blockhash);
}
} else {
// When using MockRpcClient, get_recent_block_hash() returns a constant value
return Ok(next_block_hash);
// When using MockRpcClient, get_recent_blockhash() returns a constant value
return Ok(next_blockhash);
}
if next_block_hash_retries == 0 {
if next_blockhash_retries == 0 {
Err(WalletError::RpcRequestError(
format!(
"Unable to fetch new block_hash, block_hash stuck at {:?}",
next_block_hash
"Unable to fetch new blockhash, blockhash stuck at {:?}",
next_blockhash
)
.to_string(),
))?;
}
next_block_hash_retries -= 1;
next_blockhash_retries -= 1;
// Retry ~twice during a slot
sleep(Duration::from_millis(
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND,
@ -823,7 +823,7 @@ fn send_and_confirm_transaction(
};
match status {
RpcSignatureStatus::AccountInUse | RpcSignatureStatus::SignatureNotFound => {
// Fetch a new block_hash and re-sign the transaction before sending it again
// Fetch a new blockhash and re-sign the transaction before sending it again
resign_transaction(rpc_client, transaction, signer)?;
send_retries -= 1;
}
@ -900,13 +900,13 @@ fn send_and_confirm_transactions(
}
send_retries -= 1;
// Re-sign any failed transactions with a new block_hash and retry
let block_hash =
get_next_block_hash(rpc_client, &transactions_signatures[0].0.recent_block_hash)?;
// Re-sign any failed transactions with a new blockhash and retry
let blockhash =
get_next_blockhash(rpc_client, &transactions_signatures[0].0.recent_blockhash)?;
transactions = transactions_signatures
.into_iter()
.map(|(mut transaction, _)| {
transaction.sign(&[signer], block_hash);
transaction.sign(&[signer], blockhash);
transaction
})
.collect();
@ -918,8 +918,8 @@ fn resign_transaction(
tx: &mut Transaction,
signer_key: &Keypair,
) -> Result<(), Box<dyn error::Error>> {
let block_hash = get_next_block_hash(rpc_client, &tx.recent_block_hash)?;
tx.sign(&[signer_key], block_hash);
let blockhash = get_next_blockhash(rpc_client, &tx.recent_blockhash)?;
tx.sign(&[signer_key], blockhash);
Ok(())
}
@ -929,8 +929,8 @@ pub fn request_and_confirm_airdrop(
signer: &Keypair,
tokens: u64,
) -> Result<(), Box<dyn error::Error>> {
let block_hash = get_recent_block_hash(rpc_client)?;
let mut tx = request_airdrop_transaction(drone_addr, &signer.pubkey(), tokens, block_hash)?;
let blockhash = get_recent_blockhash(rpc_client)?;
let mut tx = request_airdrop_transaction(drone_addr, &signer.pubkey(), tokens, blockhash)?;
send_and_confirm_transaction(rpc_client, &mut tx, signer)?;
Ok(())
}
@ -1507,19 +1507,19 @@ mod tests {
}
#[test]
fn test_wallet_get_recent_block_hash() {
fn test_wallet_get_recent_blockhash() {
let rpc_client = RpcClient::new("succeeds".to_string());
let vec = bs58::decode(PUBKEY).into_vec().unwrap();
let expected_block_hash = Hash::new(&vec);
let expected_blockhash = Hash::new(&vec);
let block_hash = get_recent_block_hash(&rpc_client);
assert_eq!(block_hash.unwrap(), expected_block_hash);
let blockhash = get_recent_blockhash(&rpc_client);
assert_eq!(blockhash.unwrap(), expected_blockhash);
let rpc_client = RpcClient::new("fails".to_string());
let block_hash = get_recent_block_hash(&rpc_client);
assert!(block_hash.is_err());
let blockhash = get_recent_blockhash(&rpc_client);
assert!(blockhash.is_err());
}
#[test]
@ -1528,8 +1528,8 @@ mod tests {
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);
let signature = send_transaction(&rpc_client, &tx);
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
@ -1564,8 +1564,8 @@ mod tests {
let key = Keypair::new();
let to = Keypair::new().pubkey();
let block_hash = Hash::default();
let mut tx = SystemTransaction::new_account(&key, to, 50, block_hash, 0);
let blockhash = Hash::default();
let mut tx = SystemTransaction::new_account(&key, to, 50, blockhash, 0);
let signer = Keypair::new();
@ -1590,15 +1590,15 @@ mod tests {
let vec = bs58::decode("HUu3LwEzGRsUkuJS121jzkPJW39Kq62pXCTmTa1F9jDL")
.into_vec()
.unwrap();
let block_hash = Hash::new(&vec);
let prev_tx = SystemTransaction::new_account(&key, to, 50, block_hash, 0);
let mut tx = SystemTransaction::new_account(&key, to, 50, block_hash, 0);
let blockhash = Hash::new(&vec);
let prev_tx = SystemTransaction::new_account(&key, to, 50, blockhash, 0);
let mut tx = SystemTransaction::new_account(&key, to, 50, blockhash, 0);
resign_transaction(&rpc_client, &mut tx, &key).unwrap();
assert_ne!(prev_tx, tx);
assert_ne!(prev_tx.signatures, tx.signatures);
assert_ne!(prev_tx.recent_block_hash, tx.recent_block_hash);
assert_ne!(prev_tx.recent_blockhash, tx.recent_blockhash);
assert_eq!(prev_tx.fee, tx.fee);
assert_eq!(prev_tx.account_keys, tx.account_keys);
assert_eq!(prev_tx.instructions, tx.instructions);