Rename last_entry_id variables to last_entry_hash
This commit is contained in:
parent
251b0957f1
commit
e993d511e3
|
@ -115,13 +115,13 @@ pub fn process_blocktree(
|
||||||
let slot = 0;
|
let slot = 0;
|
||||||
let bank = Arc::new(Bank::new_with_paths(&genesis_block, account_paths));
|
let bank = Arc::new(Bank::new_with_paths(&genesis_block, account_paths));
|
||||||
let entry_height = 0;
|
let entry_height = 0;
|
||||||
let last_entry_id = bank.last_id();
|
let last_entry_hash = bank.last_id();
|
||||||
vec![(slot, bank, entry_height, last_entry_id)]
|
vec![(slot, bank, entry_height, last_entry_hash)]
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut fork_info = vec![];
|
let mut fork_info = vec![];
|
||||||
while !pending_slots.is_empty() {
|
while !pending_slots.is_empty() {
|
||||||
let (slot, starting_bank, starting_entry_height, mut last_entry_id) =
|
let (slot, starting_bank, starting_entry_height, mut last_entry_hash) =
|
||||||
pending_slots.pop().unwrap();
|
pending_slots.pop().unwrap();
|
||||||
|
|
||||||
let bank = Arc::new(Bank::new_from_parent_and_id(
|
let bank = Arc::new(Bank::new_from_parent_and_id(
|
||||||
|
@ -155,17 +155,17 @@ pub fn process_blocktree(
|
||||||
return Err(BankError::LedgerVerificationFailed);
|
return Err(BankError::LedgerVerificationFailed);
|
||||||
}
|
}
|
||||||
let entry0 = &entries[0];
|
let entry0 = &entries[0];
|
||||||
if !(entry0.is_tick() && entry0.verify(&last_entry_id)) {
|
if !(entry0.is_tick() && entry0.verify(&last_entry_hash)) {
|
||||||
warn!("Ledger proof of history failed at entry0");
|
warn!("Ledger proof of history failed at entry0");
|
||||||
return Err(BankError::LedgerVerificationFailed);
|
return Err(BankError::LedgerVerificationFailed);
|
||||||
}
|
}
|
||||||
last_entry_id = entry0.id;
|
last_entry_hash = entry0.id;
|
||||||
entry_height += 1;
|
entry_height += 1;
|
||||||
entries = entries.drain(1..).collect();
|
entries = entries.drain(1..).collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !entries.is_empty() {
|
if !entries.is_empty() {
|
||||||
if !entries.verify(&last_entry_id) {
|
if !entries.verify(&last_entry_hash) {
|
||||||
warn!("Ledger proof of history failed at entry: {}", entry_height);
|
warn!("Ledger proof of history failed at entry: {}", entry_height);
|
||||||
return Err(BankError::LedgerVerificationFailed);
|
return Err(BankError::LedgerVerificationFailed);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ pub fn process_blocktree(
|
||||||
BankError::LedgerVerificationFailed
|
BankError::LedgerVerificationFailed
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
last_entry_id = entries.last().unwrap().id;
|
last_entry_hash = entries.last().unwrap().id;
|
||||||
entry_height += entries.len() as u64;
|
entry_height += entries.len() as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ pub fn process_blocktree(
|
||||||
));
|
));
|
||||||
trace!("Add child bank for slot={}", next_slot);
|
trace!("Add child bank for slot={}", next_slot);
|
||||||
// bank_forks.insert(*next_slot, child_bank);
|
// bank_forks.insert(*next_slot, child_bank);
|
||||||
(*next_slot, child_bank, entry_height, last_entry_id)
|
(*next_slot, child_bank, entry_height, last_entry_hash)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// reverse sort by slot, so the next slot to be processed can be pop()ed
|
// reverse sort by slot, so the next slot to be processed can be pop()ed
|
||||||
|
@ -255,15 +255,15 @@ mod tests {
|
||||||
ticks_per_slot: u64,
|
ticks_per_slot: u64,
|
||||||
slot: u64,
|
slot: u64,
|
||||||
parent_slot: u64,
|
parent_slot: u64,
|
||||||
last_entry_id: Hash,
|
last_entry_hash: Hash,
|
||||||
) -> Hash {
|
) -> Hash {
|
||||||
let entries = create_ticks(ticks_per_slot, last_entry_id);
|
let entries = create_ticks(ticks_per_slot, last_entry_hash);
|
||||||
let last_entry_id = entries.last().unwrap().id;
|
let last_entry_hash = entries.last().unwrap().id;
|
||||||
|
|
||||||
let blobs = entries_to_blobs(&entries, slot, parent_slot);
|
let blobs = entries_to_blobs(&entries, slot, parent_slot);
|
||||||
blocktree.insert_data_blobs(blobs.iter()).unwrap();
|
blocktree.insert_data_blobs(blobs.iter()).unwrap();
|
||||||
|
|
||||||
last_entry_id
|
last_entry_hash
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -332,7 +332,7 @@ mod tests {
|
||||||
// Create a new ledger with slot 0 full of ticks
|
// Create a new ledger with slot 0 full of ticks
|
||||||
let (ledger_path, last_id) = create_new_tmp_ledger!(&genesis_block);
|
let (ledger_path, last_id) = create_new_tmp_ledger!(&genesis_block);
|
||||||
debug!("ledger_path: {:?}", ledger_path);
|
debug!("ledger_path: {:?}", ledger_path);
|
||||||
let mut last_entry_id = last_id;
|
let mut last_entry_hash = last_id;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Build a blocktree in the ledger with the following fork structure:
|
Build a blocktree in the ledger with the following fork structure:
|
||||||
|
@ -353,11 +353,11 @@ mod tests {
|
||||||
|
|
||||||
// Fork 1, ending at slot 3
|
// Fork 1, ending at slot 3
|
||||||
let last_slot1_entry_id =
|
let last_slot1_entry_id =
|
||||||
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 1, 0, last_entry_id);
|
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 1, 0, last_entry_hash);
|
||||||
last_entry_id =
|
last_entry_hash =
|
||||||
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, last_slot1_entry_id);
|
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 2, 1, last_slot1_entry_id);
|
||||||
let last_fork1_entry_id =
|
let last_fork1_entry_id =
|
||||||
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 3, 2, last_entry_id);
|
fill_blocktree_slot_with_ticks(&blocktree, ticks_per_slot, 3, 2, last_entry_hash);
|
||||||
|
|
||||||
// Fork 2, ending at slot 4
|
// Fork 2, ending at slot 4
|
||||||
let last_fork2_entry_id =
|
let last_fork2_entry_id =
|
||||||
|
@ -451,26 +451,26 @@ mod tests {
|
||||||
debug!("ledger_path: {:?}", ledger_path);
|
debug!("ledger_path: {:?}", ledger_path);
|
||||||
|
|
||||||
let mut entries = vec![];
|
let mut entries = vec![];
|
||||||
let mut last_entry_id = last_id;
|
let mut last_entry_hash = last_id;
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
// Transfer one token from the mint to a random account
|
// Transfer one token from the mint to a random account
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let tx = SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, last_id, 0);
|
let tx = SystemTransaction::new_account(&mint_keypair, keypair.pubkey(), 1, last_id, 0);
|
||||||
let entry = Entry::new(&last_entry_id, 1, vec![tx]);
|
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
||||||
last_entry_id = entry.id;
|
last_entry_hash = entry.id;
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
|
|
||||||
// Add a second Transaction that will produce a
|
// Add a second Transaction that will produce a
|
||||||
// ProgramError<0, ResultWithNegativeTokens> error when processed
|
// ProgramError<0, ResultWithNegativeTokens> error when processed
|
||||||
let keypair2 = Keypair::new();
|
let keypair2 = Keypair::new();
|
||||||
let tx = SystemTransaction::new_account(&keypair, keypair2.pubkey(), 42, last_id, 0);
|
let tx = SystemTransaction::new_account(&keypair, keypair2.pubkey(), 42, last_id, 0);
|
||||||
let entry = Entry::new(&last_entry_id, 1, vec![tx]);
|
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
||||||
last_entry_id = entry.id;
|
last_entry_hash = entry.id;
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill up the rest of slot 1 with ticks
|
// Fill up the rest of slot 1 with ticks
|
||||||
entries.extend(create_ticks(genesis_block.ticks_per_slot, last_entry_id));
|
entries.extend(create_ticks(genesis_block.ticks_per_slot, last_entry_hash));
|
||||||
|
|
||||||
let blocktree =
|
let blocktree =
|
||||||
Blocktree::open(&ledger_path).expect("Expected to successfully open database ledger");
|
Blocktree::open(&ledger_path).expect("Expected to successfully open database ledger");
|
||||||
|
|
|
@ -449,8 +449,8 @@ pub fn make_active_set_entries(
|
||||||
// 1) Assume the active_keypair node has no tokens staked
|
// 1) Assume the active_keypair node has no tokens staked
|
||||||
let transfer_tx =
|
let transfer_tx =
|
||||||
SystemTransaction::new_account(&token_source, active_keypair.pubkey(), stake, *last_id, 0);
|
SystemTransaction::new_account(&token_source, active_keypair.pubkey(), stake, *last_id, 0);
|
||||||
let mut last_entry_id = *last_id;
|
let mut last_entry_hash = *last_id;
|
||||||
let transfer_entry = next_entry_mut(&mut last_entry_id, 1, vec![transfer_tx]);
|
let transfer_entry = next_entry_mut(&mut last_entry_hash, 1, vec![transfer_tx]);
|
||||||
|
|
||||||
// 2) Create and register a vote account for active_keypair
|
// 2) Create and register a vote account for active_keypair
|
||||||
let voting_keypair = VotingKeypair::new_local(active_keypair);
|
let voting_keypair = VotingKeypair::new_local(active_keypair);
|
||||||
|
@ -458,15 +458,15 @@ pub fn make_active_set_entries(
|
||||||
|
|
||||||
let new_vote_account_tx =
|
let new_vote_account_tx =
|
||||||
VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *last_id, 1, 1);
|
VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *last_id, 1, 1);
|
||||||
let new_vote_account_entry = next_entry_mut(&mut last_entry_id, 1, vec![new_vote_account_tx]);
|
let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]);
|
||||||
|
|
||||||
// 3) Create vote entry
|
// 3) Create vote entry
|
||||||
let vote_tx = VoteTransaction::new_vote(&voting_keypair, slot_height_to_vote_on, *last_id, 0);
|
let vote_tx = VoteTransaction::new_vote(&voting_keypair, slot_height_to_vote_on, *last_id, 0);
|
||||||
let vote_entry = next_entry_mut(&mut last_entry_id, 1, vec![vote_tx]);
|
let vote_entry = next_entry_mut(&mut last_entry_hash, 1, vec![vote_tx]);
|
||||||
|
|
||||||
// 4) Create `num_ending_ticks` empty ticks
|
// 4) Create `num_ending_ticks` empty ticks
|
||||||
let mut entries = vec![transfer_entry, new_vote_account_entry, vote_entry];
|
let mut entries = vec![transfer_entry, new_vote_account_entry, vote_entry];
|
||||||
let empty_ticks = create_ticks(num_ending_ticks, last_entry_id);
|
let empty_ticks = create_ticks(num_ending_ticks, last_entry_hash);
|
||||||
entries.extend(empty_ticks);
|
entries.extend(empty_ticks);
|
||||||
|
|
||||||
(entries, voting_keypair)
|
(entries, voting_keypair)
|
||||||
|
|
|
@ -144,8 +144,8 @@ impl PohRecorder {
|
||||||
/// A recorder to synchronize PoH with the following data structures
|
/// A recorder to synchronize PoH with the following data structures
|
||||||
/// * bank - the LastId's queue is updated on `tick` and `record` events
|
/// * bank - the LastId's queue is updated on `tick` and `record` events
|
||||||
/// * sender - the Entry channel that outputs to the ledger
|
/// * sender - the Entry channel that outputs to the ledger
|
||||||
pub fn new(tick_height: u64, last_entry_id: Hash) -> Self {
|
pub fn new(tick_height: u64, last_entry_hash: Hash) -> Self {
|
||||||
let poh = Poh::new(last_entry_id, tick_height);
|
let poh = Poh::new(last_entry_hash, tick_height);
|
||||||
PohRecorder {
|
PohRecorder {
|
||||||
poh,
|
poh,
|
||||||
tick_cache: vec![],
|
tick_cache: vec![],
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl ReplayStage {
|
||||||
voting_keypair: &Option<Arc<T>>,
|
voting_keypair: &Option<Arc<T>>,
|
||||||
forward_entry_sender: &EntrySender,
|
forward_entry_sender: &EntrySender,
|
||||||
current_blob_index: &mut u64,
|
current_blob_index: &mut u64,
|
||||||
last_entry_id: &mut Hash,
|
last_entry_hash: &mut Hash,
|
||||||
subscriptions: &Arc<RpcSubscriptions>,
|
subscriptions: &Arc<RpcSubscriptions>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Coalesce all the available entries into a single vote
|
// Coalesce all the available entries into a single vote
|
||||||
|
@ -76,7 +76,7 @@ impl ReplayStage {
|
||||||
let mut num_entries_to_write = entries.len();
|
let mut num_entries_to_write = entries.len();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
if !entries.as_slice().verify(last_entry_id) {
|
if !entries.as_slice().verify(last_entry_hash) {
|
||||||
inc_new_counter_info!("replicate_stage-verify-fail", entries.len());
|
inc_new_counter_info!("replicate_stage-verify-fail", entries.len());
|
||||||
return Err(Error::BlobError(BlobError::VerificationFailed));
|
return Err(Error::BlobError(BlobError::VerificationFailed));
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ impl ReplayStage {
|
||||||
|
|
||||||
// If leader rotation happened, only write the entries up to leader rotation.
|
// If leader rotation happened, only write the entries up to leader rotation.
|
||||||
entries.truncate(num_entries_to_write);
|
entries.truncate(num_entries_to_write);
|
||||||
*last_entry_id = entries
|
*last_entry_hash = entries
|
||||||
.last()
|
.last()
|
||||||
.expect("Entries cannot be empty at this point")
|
.expect("Entries cannot be empty at this point")
|
||||||
.id;
|
.id;
|
||||||
|
@ -219,7 +219,7 @@ impl ReplayStage {
|
||||||
|
|
||||||
(Some(slot), leader_id, max_tick_height_for_slot)
|
(Some(slot), leader_id, max_tick_height_for_slot)
|
||||||
};
|
};
|
||||||
let mut last_entry_id = bank.last_id();
|
let mut last_entry_hash = bank.last_id();
|
||||||
let mut current_blob_index = 0;
|
let mut current_blob_index = 0;
|
||||||
|
|
||||||
// Start the replay stage loop
|
// Start the replay stage loop
|
||||||
|
@ -302,7 +302,7 @@ impl ReplayStage {
|
||||||
&voting_keypair,
|
&voting_keypair,
|
||||||
&forward_entry_sender,
|
&forward_entry_sender,
|
||||||
&mut current_blob_index,
|
&mut current_blob_index,
|
||||||
&mut last_entry_id,
|
&mut last_entry_hash,
|
||||||
&subscriptions_,
|
&subscriptions_,
|
||||||
) {
|
) {
|
||||||
error!("{} process_entries failed: {:?}", my_id, e);
|
error!("{} process_entries failed: {:?}", my_id, e);
|
||||||
|
@ -338,7 +338,7 @@ impl ReplayStage {
|
||||||
let last_entry = blocktree
|
let last_entry = blocktree
|
||||||
.get_slot_entries(slot, meta.last_index, Some(1))
|
.get_slot_entries(slot, meta.last_index, Some(1))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
last_entry_id = last_entry[0].id;
|
last_entry_hash = last_entry[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_bank = bank.clone();
|
let old_bank = bank.clone();
|
||||||
|
@ -495,7 +495,7 @@ mod test {
|
||||||
let (bank_forks, bank_forks_info, blocktree, l_receiver) =
|
let (bank_forks, bank_forks_info, blocktree, l_receiver) =
|
||||||
new_banks_from_blocktree(&my_ledger_path, None);
|
new_banks_from_blocktree(&my_ledger_path, None);
|
||||||
let bank = bank_forks.working_bank();
|
let bank = bank_forks.working_bank();
|
||||||
let last_entry_id = bank.last_id();
|
let last_entry_hash = bank.last_id();
|
||||||
|
|
||||||
let blocktree = Arc::new(blocktree);
|
let blocktree = Arc::new(blocktree);
|
||||||
let (replay_stage, _slot_full_receiver, ledger_writer_recv) = ReplayStage::new(
|
let (replay_stage, _slot_full_receiver, ledger_writer_recv) = ReplayStage::new(
|
||||||
|
@ -516,7 +516,7 @@ mod test {
|
||||||
cluster_info_me.write().unwrap().push_vote(vote);
|
cluster_info_me.write().unwrap().push_vote(vote);
|
||||||
|
|
||||||
info!("Send ReplayStage an entry, should see it on the ledger writer receiver");
|
info!("Send ReplayStage an entry, should see it on the ledger writer receiver");
|
||||||
let next_tick = create_ticks(1, last_entry_id);
|
let next_tick = create_ticks(1, last_entry_hash);
|
||||||
blocktree.write_entries(1, 0, 0, next_tick.clone()).unwrap();
|
blocktree.write_entries(1, 0, 0, next_tick.clone()).unwrap();
|
||||||
|
|
||||||
let received_tick = ledger_writer_recv
|
let received_tick = ledger_writer_recv
|
||||||
|
@ -541,7 +541,7 @@ mod test {
|
||||||
// Set up the cluster info
|
// Set up the cluster info
|
||||||
let cluster_info_me = Arc::new(RwLock::new(ClusterInfo::new(my_node.info.clone())));
|
let cluster_info_me = Arc::new(RwLock::new(ClusterInfo::new(my_node.info.clone())));
|
||||||
let (forward_entry_sender, _forward_entry_receiver) = channel();
|
let (forward_entry_sender, _forward_entry_receiver) = channel();
|
||||||
let mut last_entry_id = Hash::default();
|
let mut last_entry_hash = Hash::default();
|
||||||
let mut current_blob_index = 0;
|
let mut current_blob_index = 0;
|
||||||
let mut last_id = Hash::default();
|
let mut last_id = Hash::default();
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
|
@ -560,7 +560,7 @@ mod test {
|
||||||
&voting_keypair,
|
&voting_keypair,
|
||||||
&forward_entry_sender,
|
&forward_entry_sender,
|
||||||
&mut current_blob_index,
|
&mut current_blob_index,
|
||||||
&mut last_entry_id,
|
&mut last_entry_hash,
|
||||||
&Arc::new(RpcSubscriptions::default()),
|
&Arc::new(RpcSubscriptions::default()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ mod test {
|
||||||
&voting_keypair,
|
&voting_keypair,
|
||||||
&forward_entry_sender,
|
&forward_entry_sender,
|
||||||
&mut current_blob_index,
|
&mut current_blob_index,
|
||||||
&mut last_entry_id,
|
&mut last_entry_hash,
|
||||||
&Arc::new(RpcSubscriptions::default()),
|
&Arc::new(RpcSubscriptions::default()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue