diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index f483adabd5..8b993fa7b7 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -127,7 +127,7 @@ fn main() { exit(1); } } - last_id = entry.id; + last_id = entry.hash; num_entries += 1; if let Err(e) = blocktree_processor::process_entry(&bank, &entry) { diff --git a/src/banking_stage.rs b/src/banking_stage.rs index 8f4d72a374..41f8b95846 100644 --- a/src/banking_stage.rs +++ b/src/banking_stage.rs @@ -412,7 +412,7 @@ mod tests { .collect(); assert!(entries.len() != 0); assert!(entries.verify(&start_hash)); - assert_eq!(entries[entries.len() - 1].id, bank.last_id()); + assert_eq!(entries[entries.len() - 1].hash, bank.last_id()); banking_stage.join().unwrap(); poh_service.close().unwrap(); } @@ -467,7 +467,7 @@ mod tests { entries.iter().for_each(|entries| { assert_eq!(entries.len(), 1); assert!(entries.verify(&last_id)); - last_id = entries.last().unwrap().id; + last_id = entries.last().unwrap().hash; }); drop(entry_receiver); banking_stage.join().unwrap(); diff --git a/src/blockstream.rs b/src/blockstream.rs index 5f462de6fe..3b8de3eb21 100644 --- a/src/blockstream.rs +++ b/src/blockstream.rs @@ -180,7 +180,7 @@ mod test { curr_slot += 1; } let entry = Entry::new(&mut last_id, 1, vec![]); // just ticks - last_id = entry.id; + last_id = entry.hash; blockstream .emit_entry_event(curr_slot, tick_height, leader_id, &entry) .unwrap(); diff --git a/src/blockstream_service.rs b/src/blockstream_service.rs index 03c9f4795e..8ed792086c 100644 --- a/src/blockstream_service.rs +++ b/src/blockstream_service.rs @@ -85,7 +85,7 @@ impl BlockstreamService { }); if i == entries.len() - 1 { blockstream - .emit_block_event(slot, tick_height, slot_leader, entry.id) + .emit_block_event(slot, tick_height, slot_leader, entry.hash) .unwrap_or_else(|e| { debug!("Blockstream error: {:?}, {:?}", e, blockstream.output); }); @@ -138,10 +138,10 @@ mod test { let mut entries = create_ticks(4, Hash::default()); let keypair = Keypair::new(); - let mut last_id = entries[3].id; + let mut last_id = entries[3].hash; let tx = SystemTransaction::new_account(&keypair, keypair.pubkey(), 1, Hash::default(), 0); let entry = Entry::new(&mut last_id, 1, vec![tx]); - last_id = entry.id; + last_id = entry.hash; entries.push(entry); let final_tick = create_ticks(1, last_id); entries.extend_from_slice(&final_tick); diff --git a/src/blocktree.rs b/src/blocktree.rs index e78888770a..588d867b37 100644 --- a/src/blocktree.rs +++ b/src/blocktree.rs @@ -1279,7 +1279,7 @@ impl Iterator for EntryIterator { } } self.db_iterator.next(); - self.last_id = Some(entry.id); + self.last_id = Some(entry.hash); return Some(entry); } } @@ -1301,7 +1301,7 @@ pub fn create_new_ledger(ledger_path: &str, genesis_block: &GenesisBlock) -> Res let entries = crate::entry::create_ticks(ticks_per_slot, genesis_block.last_id()); blocktree.write_entries(0, 0, 0, &entries)?; - Ok(entries.last().unwrap().id) + Ok(entries.last().unwrap().hash) } pub fn genesis<'a, I>(ledger_path: &str, keypair: &Keypair, entries: I) -> Result<()> @@ -1398,7 +1398,7 @@ pub fn tmp_copy_blocktree(from: &str, name: &str) -> String { pub mod tests { use super::*; use crate::entry::{ - create_ticks, make_tiny_test_entries, make_tiny_test_entries_from_id, Entry, EntrySlice, + create_ticks, make_tiny_test_entries, make_tiny_test_entries_from_hash, Entry, EntrySlice, }; use crate::packet::index_blobs; use rand::seq::SliceRandom; @@ -1924,7 +1924,7 @@ pub mod tests { #[test] pub fn test_genesis_and_entry_iterator() { - let entries = make_tiny_test_entries_from_id(&Hash::default(), 10); + let entries = make_tiny_test_entries_from_hash(&Hash::default(), 10); let ledger_path = get_tmp_ledger_path("test_genesis_and_entry_iterator"); { @@ -1942,7 +1942,7 @@ pub mod tests { } #[test] pub fn test_entry_iterator_up_to_consumed() { - let entries = make_tiny_test_entries_from_id(&Hash::default(), 3); + let entries = make_tiny_test_entries_from_hash(&Hash::default(), 3); let ledger_path = get_tmp_ledger_path("test_genesis_and_entry_iterator"); { // put entries except last 2 into ledger diff --git a/src/blocktree_processor.rs b/src/blocktree_processor.rs index e888cb9a29..34a8650e10 100644 --- a/src/blocktree_processor.rs +++ b/src/blocktree_processor.rs @@ -15,7 +15,7 @@ pub fn process_entry(bank: &Bank, entry: &Entry) -> Result<()> { if !entry.is_tick() { first_err(&bank.process_transactions(&entry.transactions))?; } else { - bank.register_tick(&entry.id); + bank.register_tick(&entry.hash); } Ok(()) } @@ -57,7 +57,7 @@ fn par_process_entries(bank: &Bank, entries: &[Entry]) -> Result<()> { if entry.is_tick() { // if its a tick, execute the group and register the tick par_execute_entries(bank, &mt_group)?; - bank.register_tick(&entry.id); + bank.register_tick(&entry.hash); mt_group = vec![]; continue; } @@ -159,7 +159,7 @@ pub fn process_blocktree( warn!("Ledger proof of history failed at entry0"); return Err(BankError::LedgerVerificationFailed); } - last_entry_hash = entry0.id; + last_entry_hash = entry0.hash; entry_height += 1; entries = entries.drain(1..).collect(); } @@ -175,7 +175,7 @@ pub fn process_blocktree( BankError::LedgerVerificationFailed })?; - last_entry_hash = entries.last().unwrap().id; + last_entry_hash = entries.last().unwrap().hash; entry_height += entries.len() as u64; } @@ -201,7 +201,7 @@ pub fn process_blocktree( bank.squash(); if meta.next_slots.is_empty() { - // Reached the end of this fork. Record the final entry height and last entry id + // Reached the end of this fork. Record the final entry height and last entry.hash let bfi = BankForksInfo { bank_id: slot, @@ -258,7 +258,7 @@ mod tests { last_entry_hash: Hash, ) -> Hash { let entries = create_ticks(ticks_per_slot, last_entry_hash); - let last_entry_hash = entries.last().unwrap().id; + let last_entry_hash = entries.last().unwrap().hash; let blobs = entries_to_blobs(&entries, slot, parent_slot); blocktree.insert_data_blobs(blobs.iter()).unwrap(); @@ -298,7 +298,7 @@ mod tests { let parent_slot = 0; let slot = 1; let mut entries = create_ticks(ticks_per_slot, last_id); - last_id = entries.last().unwrap().id; + last_id = entries.last().unwrap().hash; entries.pop(); @@ -352,19 +352,19 @@ mod tests { .expect("Expected to successfully open database ledger"); // Fork 1, ending at slot 3 - let last_slot1_entry_id = + let last_slot1_entry_hash = fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 1, 0, last_entry_hash); last_entry_hash = - fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, last_slot1_entry_id); - let last_fork1_entry_id = + fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, last_slot1_entry_hash); + let last_fork1_entry_hash = fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 3, 2, last_entry_hash); // Fork 2, ending at slot 4 - let last_fork2_entry_id = - fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 4, 1, last_slot1_entry_id); + let last_fork2_entry_hash = + fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 4, 1, last_slot1_entry_hash); - info!("last_fork1_entry_id: {:?}", last_fork1_entry_id); - info!("last_fork2_entry_id: {:?}", last_fork2_entry_id); + info!("last_fork1_entry.hash: {:?}", last_fork1_entry_hash); + info!("last_fork2_entry.hash: {:?}", last_fork2_entry_hash); let (bank_forks, bank_forks_info) = process_blocktree(&genesis_block, &blocktree, None).unwrap(); @@ -430,7 +430,7 @@ mod tests { let bank = Bank::new(&genesis_block); let keypair = Keypair::new(); let entry = next_entry(&genesis_block.last_id(), 1, vec![]); - let tx = SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, entry.id, 0); + let tx = SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, entry.hash, 0); // First, ensure the TX is rejected because of the unregistered last ID assert_eq!( @@ -457,7 +457,7 @@ mod tests { let keypair = Keypair::new(); let tx = SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, last_id, 0); let entry = Entry::new(&last_entry_hash, 1, vec![tx]); - last_entry_hash = entry.id; + last_entry_hash = entry.hash; entries.push(entry); // Add a second Transaction that will produce a @@ -465,7 +465,7 @@ mod tests { let keypair2 = Keypair::new(); let tx = SystemTransaction::new_account(&keypair, keypair2.pubkey(), 42, last_id, 0); let entry = Entry::new(&last_entry_hash, 1, vec![tx]); - last_entry_hash = entry.id; + last_entry_hash = entry.hash; entries.push(entry); } @@ -491,7 +491,7 @@ 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_id(), entries.last().unwrap().id); + assert_eq!(bank.last_id(), entries.last().unwrap().hash); } #[test] @@ -524,7 +524,7 @@ mod tests { // ensure bank can process a tick let tick = next_entry(&genesis_block.last_id(), 1, vec![]); assert_eq!(par_process_entries(&bank, &[tick.clone()]), Ok(())); - assert_eq!(bank.last_id(), tick.id); + assert_eq!(bank.last_id(), tick.hash); } #[test] @@ -542,7 +542,7 @@ mod tests { let entry_1 = next_entry(&last_id, 1, vec![tx]); let tx = SystemTransaction::new_account(&mint_keypair, keypair2.pubkey(), 2, bank.last_id(), 0); - let entry_2 = next_entry(&entry_1.id, 1, vec![tx]); + 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); @@ -581,7 +581,7 @@ mod tests { ); let entry_2_to_3_mint_to_1 = next_entry( - &entry_1_to_mint.id, + &entry_1_to_mint.hash, 1, vec![ SystemTransaction::new_account(&keypair2, keypair3.pubkey(), 2, bank.last_id(), 0), // should be fine @@ -627,7 +627,7 @@ mod tests { let tx = SystemTransaction::new_account(&keypair1, keypair3.pubkey(), 1, bank.last_id(), 0); let entry_1 = next_entry(&last_id, 1, vec![tx]); let tx = SystemTransaction::new_account(&keypair2, keypair4.pubkey(), 1, bank.last_id(), 0); - let entry_2 = next_entry(&entry_1.id, 1, vec![tx]); + 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); @@ -656,19 +656,19 @@ mod tests { // 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, bank.last_id(), 0); let entry_1 = next_entry(&last_id, 1, vec![tx]); - let tick = next_entry(&entry_1.id, 1, vec![]); - let tx = SystemTransaction::new_account(&keypair1, keypair4.pubkey(), 1, tick.id, 0); - let entry_2 = next_entry(&tick.id, 1, vec![tx]); + let tick = next_entry(&entry_1.hash, 1, vec![]); + let tx = SystemTransaction::new_account(&keypair1, keypair4.pubkey(), 1, tick.hash, 0); + let entry_2 = next_entry(&tick.hash, 1, vec![tx]); assert_eq!( par_process_entries(&bank, &[entry_1.clone(), tick.clone(), entry_2.clone()]), Ok(()) ); assert_eq!(bank.get_balance(&keypair3.pubkey()), 1); assert_eq!(bank.get_balance(&keypair4.pubkey()), 1); - assert_eq!(bank.last_id(), tick.id); + assert_eq!(bank.last_id(), tick.hash); // ensure that an error is returned for an empty account (keypair2) - let tx = SystemTransaction::new_account(&keypair2, keypair3.pubkey(), 1, tick.id, 0); - let entry_3 = next_entry(&entry_2.id, 1, vec![tx]); + let tx = SystemTransaction::new_account(&keypair2, keypair3.pubkey(), 1, tick.hash, 0); + let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]); assert_eq!( par_process_entries(&bank, &[entry_3]), Err(BankError::AccountNotFound) diff --git a/src/entry.rs b/src/entry.rs index 2160306670..ac2228510c 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -9,7 +9,7 @@ use bincode::{deserialize, serialize_into, serialized_size}; use chrono::prelude::Utc; use rayon::prelude::*; use solana_sdk::budget_transaction::BudgetTransaction; -use solana_sdk::hash::{hash, Hash}; +use solana_sdk::hash::Hash; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; @@ -25,9 +25,9 @@ pub type EntrySender = Sender>; pub type EntryReceiver = Receiver>; /// Each Entry contains three pieces of data. The `num_hashes` field is the number -/// of hashes performed since the previous entry. The `id` field is the result -/// of hashing `id` from the previous entry `num_hashes` times. The `transactions` -/// field points to Transactions that took place shortly before `id` was generated. +/// of hashes performed since the previous entry. The `hash` field is the result +/// of hashing `hash` from the previous entry `num_hashes` times. The `transactions` +/// field points to Transactions that took place shortly before `hash` was generated. /// /// If you divide `num_hashes` by the amount of time it takes to generate a new hash, you /// get a duration estimate since the last Entry. Since processing power increases @@ -45,7 +45,7 @@ pub struct Entry { pub num_hashes: u64, /// The SHA-256 hash `num_hashes` after the previous Entry ID. - pub id: Hash, + pub hash: Hash, /// An unordered list of transactions that were observed before the Entry ID was /// generated. They may have been observed before a previous Entry ID but were @@ -60,26 +60,26 @@ impl Entry { if num_hashes == 0 && transactions.is_empty() { Entry { num_hashes: 0, - id: *prev_hash, + hash: *prev_hash, transactions, } } else if num_hashes == 0 { // If you passed in transactions, but passed in num_hashes == 0, then // next_hash will generate the next hash and set num_hashes == 1 - let id = next_hash(prev_hash, 1, &transactions); + let hash = next_hash(prev_hash, 1, &transactions); Entry { num_hashes: 1, - id, + hash, transactions, } } else { // Otherwise, the next Entry `num_hashes` after `start_hash`. // If you wanted a tick for instance, then pass in num_hashes = 1 // and transactions = empty - let id = next_hash(prev_hash, num_hashes, &transactions); + let hash = next_hash(prev_hash, num_hashes, &transactions); Entry { num_hashes, - id, + hash, transactions, } } @@ -118,7 +118,7 @@ impl Entry { .iter() .map(|tx| tx.serialized_size().unwrap()) .sum(); - // num_hashes + id + txs + // num_hashes + hash + txs (2 * size_of::() + size_of::()) as u64 + txs_size } @@ -165,32 +165,32 @@ impl Entry { transactions: Vec, ) -> Self { let entry = Self::new(start_hash, *num_hashes, transactions); - *start_hash = entry.id; + *start_hash = entry.hash; *num_hashes = 0; assert!(serialized_size(&entry).unwrap() <= BLOB_DATA_SIZE as u64); entry } /// Creates a Entry from the number of hashes `num_hashes` - /// since the previous transaction and that resulting `id`. + /// since the previous transaction and that resulting `hash`. #[cfg(test)] - pub fn new_tick(num_hashes: u64, id: &Hash) -> Self { + pub fn new_tick(num_hashes: u64, hash: &Hash) -> Self { Entry { num_hashes, - id: *id, + hash: *hash, transactions: vec![], } } - /// Verifies self.id is the result of hashing a `start_hash` `self.num_hashes` times. + /// Verifies self.hash is the result of hashing a `start_hash` `self.num_hashes` times. /// If the transaction is not a Tick, then hash that as well. pub fn verify(&self, start_hash: &Hash) -> bool { let ref_hash = next_hash(start_hash, self.num_hashes, &self.transactions); - if self.id != ref_hash { + if self.hash != ref_hash { warn!( "next_hash is invalid expected: {:?} actual: {:?}", - self.id, ref_hash + self.hash, ref_hash ); return false; } @@ -259,17 +259,17 @@ impl EntrySlice for [Entry] { fn verify(&self, start_hash: &Hash) -> bool { let genesis = [Entry { num_hashes: 0, - id: *start_hash, + hash: *start_hash, transactions: vec![], }]; let entry_pairs = genesis.par_iter().chain(self).zip(self); entry_pairs.all(|(x0, x1)| { - let r = x1.verify(&x0.id); + let r = x1.verify(&x0.hash); if !r { warn!( "entry invalid!: x0: {:?}, x1: {:?} num txs: {}", - x0.id, - x1.id, + x0.hash, + x1.hash, x1.transactions.len() ); } @@ -299,12 +299,12 @@ impl EntrySlice for [Entry] { pub fn next_entry_mut(start: &mut Hash, num_hashes: u64, transactions: Vec) -> Entry { let entry = Entry::new(&start, num_hashes, transactions); - *start = entry.id; + *start = entry.hash; entry } /// Creates the next entries for given transactions, outputs -/// updates start_hash to id of last Entry, sets num_hashes to 0 +/// updates start_hash to hash of last Entry, sets num_hashes to 0 pub fn next_entries_mut( start_hash: &mut Hash, num_hashes: &mut u64, @@ -373,9 +373,9 @@ pub fn next_entries( num_hashes: u64, transactions: Vec, ) -> Vec { - let mut id = *start_hash; + let mut hash = *start_hash; let mut num_hashes = num_hashes; - next_entries_mut(&mut id, &mut num_hashes, transactions) + next_entries_mut(&mut hash, &mut num_hashes, transactions) } pub fn create_ticks(num_ticks: u64, mut hash: Hash) -> Vec { @@ -388,15 +388,15 @@ pub fn create_ticks(num_ticks: u64, mut hash: Hash) -> Vec { ticks } -pub fn make_tiny_test_entries_from_id(start: &Hash, num: usize) -> Vec { +pub fn make_tiny_test_entries_from_hash(start: &Hash, num: usize) -> Vec { let keypair = Keypair::new(); - let mut id = *start; + let mut hash = *start; let mut num_hashes = 0; (0..num) .map(|_| { Entry::new_mut( - &mut id, + &mut hash, &mut num_hashes, vec![BudgetTransaction::new_timestamp( &keypair, @@ -412,13 +412,13 @@ pub fn make_tiny_test_entries_from_id(start: &Hash, num: usize) -> Vec { pub fn make_tiny_test_entries(num: usize) -> Vec { let zero = Hash::default(); - let one = hash(&zero.as_ref()); - make_tiny_test_entries_from_id(&one, num) + let one = solana_sdk::hash::hash(&zero.as_ref()); + make_tiny_test_entries_from_hash(&one, num) } pub fn make_large_test_entries(num_entries: usize) -> Vec { let zero = Hash::default(); - let one = hash(&zero.as_ref()); + let one = solana_sdk::hash::hash(&zero.as_ref()); let keypair = Keypair::new(); let tx = BudgetTransaction::new_timestamp( @@ -465,7 +465,7 @@ pub fn next_entry(prev_hash: &Hash, num_hashes: u64, transactions: Vec 0 || transactions.is_empty()); Entry { num_hashes, - id: next_hash(prev_hash, num_hashes, &transactions), + hash: next_hash(prev_hash, num_hashes, &transactions), transactions, } } @@ -536,11 +536,11 @@ mod tests { let zero = Hash::default(); let tick = next_entry(&zero, 1, vec![]); assert_eq!(tick.num_hashes, 1); - assert_ne!(tick.id, zero); + assert_ne!(tick.hash, zero); let tick = next_entry(&zero, 0, vec![]); assert_eq!(tick.num_hashes, 0); - assert_eq!(tick.id, zero); + assert_eq!(tick.hash, zero); let keypair = Keypair::new(); let tx0 = BudgetTransaction::new_timestamp( @@ -552,7 +552,7 @@ mod tests { ); let entry0 = next_entry(&zero, 1, vec![tx0.clone()]); assert_eq!(entry0.num_hashes, 1); - assert_eq!(entry0.id, next_hash(&zero, 1, &vec![tx0])); + assert_eq!(entry0.hash, next_hash(&zero, 1, &vec![tx0])); } #[test] @@ -587,7 +587,7 @@ mod tests { assert!(vec![next_entry(&zero, 0, vec![]); 2][..].verify(&zero)); // inductive step let mut bad_ticks = vec![next_entry(&zero, 0, vec![]); 2]; - bad_ticks[1].id = one; + bad_ticks[1].hash = one; assert!(!bad_ticks.verify(&zero)); // inductive step, bad } @@ -640,8 +640,8 @@ mod tests { #[test] fn test_next_entries() { solana_logger::setup(); - let id = Hash::default(); - let next_hash = hash(&id.as_ref()); + let hash = Hash::default(); + let next_hash = solana_sdk::hash::hash(&hash.as_ref()); let keypair = Keypair::new(); let vote_account = Keypair::new(); let tx_small = VoteTransaction::new_vote(&vote_account, 1, next_hash, 2); @@ -651,7 +651,7 @@ mod tests { let tx_large_size = tx_large.serialized_size().unwrap() as usize; let entry_size = serialized_size(&Entry { num_hashes: 0, - id: Hash::default(), + hash: Hash::default(), transactions: vec![], }) .unwrap() as usize; @@ -662,15 +662,15 @@ mod tests { // verify no split let transactions = vec![tx_small.clone(); threshold]; - let entries0 = next_entries(&id, 0, transactions.clone()); + let entries0 = next_entries(&hash, 0, transactions.clone()); assert_eq!(entries0.len(), 1); - assert!(entries0.verify(&id)); + assert!(entries0.verify(&hash)); // verify the split with uniform transactions let transactions = vec![tx_small.clone(); threshold * 2]; - let entries0 = next_entries(&id, 0, transactions.clone()); + let entries0 = next_entries(&hash, 0, transactions.clone()); assert_eq!(entries0.len(), 2); - assert!(entries0.verify(&id)); + assert!(entries0.verify(&hash)); // verify the split with small transactions followed by large // transactions @@ -679,9 +679,9 @@ mod tests { transactions.extend(large_transactions); - let entries0 = next_entries(&id, 0, transactions.clone()); + let entries0 = next_entries(&hash, 0, transactions.clone()); assert!(entries0.len() >= 2); - assert!(entries0.verify(&id)); + assert!(entries0.verify(&hash)); } } diff --git a/src/fullnode.rs b/src/fullnode.rs index df2afb0479..e4ec336fbe 100644 --- a/src/fullnode.rs +++ b/src/fullnode.rs @@ -785,7 +785,7 @@ mod tests { ); let blocktree = Blocktree::open_config(&ledger_path, ticks_per_slot).unwrap(); - let last_id = entries.last().unwrap().id; + let last_id = entries.last().unwrap().hash; let entry_height = ticks_per_slot + entries.len() as u64; blocktree.write_entries(1, 0, 0, entries).unwrap(); diff --git a/src/poh_recorder.rs b/src/poh_recorder.rs index c88894dbe6..48474acc5d 100644 --- a/src/poh_recorder.rs +++ b/src/poh_recorder.rs @@ -102,7 +102,7 @@ impl PohRecorder { ); let cache = &self.tick_cache[..cnt]; for t in cache { - working_bank.bank.register_tick(&t.0.id); + working_bank.bank.register_tick(&t.0.hash); } working_bank.sender.send(cache.to_vec()) } else { @@ -162,7 +162,7 @@ impl PohRecorder { assert!(!txs.is_empty(), "Entries without transactions are used to track real-time passing in the ledger and can only be generated with PohRecorder::tick function"); let recorded_entry = Entry { num_hashes: entry.num_hashes, - id: entry.id, + hash: entry.id, transactions: txs, }; trace!("sending entry {}", recorded_entry.is_tick()); @@ -178,7 +178,7 @@ impl PohRecorder { ( Entry { num_hashes: tick.num_hashes, - id: tick.id, + hash: tick.id, transactions: vec![], }, tick.tick_height, diff --git a/src/replay_stage.rs b/src/replay_stage.rs index 66c09c3f58..9c8635642c 100644 --- a/src/replay_stage.rs +++ b/src/replay_stage.rs @@ -138,7 +138,7 @@ impl ReplayStage { *last_entry_hash = entries .last() .expect("Entries cannot be empty at this point") - .id; + .hash; inc_new_counter_info!( "replicate-transactions", @@ -338,7 +338,7 @@ impl ReplayStage { let last_entry = blocktree .get_slot_entries(slot, meta.last_index, Some(1)) .unwrap(); - last_entry_hash = last_entry[0].id; + last_entry_hash = last_entry[0].hash; } let old_bank = bank.clone(); diff --git a/src/storage_stage.rs b/src/storage_stage.rs index a508393c0c..1af789fb4f 100644 --- a/src/storage_stage.rs +++ b/src/storage_stage.rs @@ -421,7 +421,7 @@ impl StorageStage { &storage_state, &keypair, &blocktree, - entry.id, + entry.hash, *entry_height, tx_sender, )?; diff --git a/tests/multinode.rs b/tests/multinode.rs index 6fe4a1f007..de3b4beed8 100644 --- a/tests/multinode.rs +++ b/tests/multinode.rs @@ -1313,7 +1313,7 @@ fn test_full_leader_validator_network() { &last_id, ticks_per_slot, ); - last_id = node_active_set_entries.last().unwrap().id; + last_id = node_active_set_entries.last().unwrap().hash; active_set_entries.extend(node_active_set_entries); } @@ -1702,7 +1702,7 @@ fn stake_fullnode( fn add_tick(last_id: &mut Hash, entries: &mut Vec) -> Hash { let tick = solana::entry::create_ticks(1, *last_id); - *last_id = tick[0].id; + *last_id = tick[0].hash; entries.extend(tick); *last_id } diff --git a/tests/replicator.rs b/tests/replicator.rs index d4ad0119af..cadc506afc 100644 --- a/tests/replicator.rs +++ b/tests/replicator.rs @@ -177,7 +177,7 @@ fn test_replicator_startup_basic() { assert!(br.index() == repair_index); let entry: Entry = deserialize(&br.data()[..br.meta.size]).unwrap(); info!("entry: {:?}", entry); - assert_ne!(entry.id, Hash::default()); + assert_ne!(entry.hash, Hash::default()); received_blob = true; } break;