Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions node/src/block_producer/block_producer_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,16 @@ impl BlockProducerEnabled {
consensus_state,
},
};
let body_hash = protocol_state.body.hash();
let hash = StateHash::from_hashes(&protocol_state.previous_state_hash, &body_hash);

// TODO(binier): test
let chain_proof_len = pred_block.constants().delta.as_u32() as usize;
let delta_block_chain_proof = match chain_proof_len {
0 => (hash.clone(), List::new()),
0 => (pred_block.hash().clone(), List::new()),
chain_proof_len => {
let mut iter = chain.iter().rev().take(chain_proof_len).rev();
let first_hash = iter
.next()
.map_or_else(|| hash.clone(), |b| b.hash().clone());
// TODO(binier): test
let mut iter = chain.iter().rev().take(chain_proof_len + 1).rev();
let first_hash = iter.next().unwrap().hash().clone();
let body_hashes = iter
.map(|b| b.header().protocol_state.body.hash())
.chain(std::iter::once(body_hash))
.map(StateBodyHash::from)
.collect();
(first_hash, body_hashes)
Expand All @@ -409,6 +404,7 @@ impl BlockProducerEnabled {
staged_ledger_diff: diff.clone(),
},
};
let block_hash = block.protocol_state.hash();

self.current = BlockProducerCurrentState::BlockUnprovenBuilt {
time: meta.time(),
Expand All @@ -419,7 +415,7 @@ impl BlockProducerEnabled {
pending_coinbase_witness,
stake_proof_sparse_ledger,
block,
block_hash: hash,
block_hash,
}
}
BlockProducerAction::BlockProveInit => {}
Expand Down
4 changes: 3 additions & 1 deletion node/src/consensus/consensus_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ fn transition_frontier_new_best_tip<S: crate::Service>(store: &mut Store<S>) {
let old_best_tip = state.transition_frontier.best_tip()?;
let mut iter = state.transition_frontier.best_chain.iter();
if old_best_tip.hash() == pred_hash {
iter.next();
if old_best_tip.height() > old_best_tip.constants().k.as_u32() {
iter.next();
}
let root_block = iter.next()?.clone();
let hashes = iter.map(|b| b.hash.clone()).collect();
Some((hashes, root_block))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl P2pConnectionOutgoingAction {
}
store.dispatch(P2pConnectionOutgoingAction::FinalizePending { peer_id });
} else {
store.service().outgoing_init(opts);
store.dispatch(P2pConnectionOutgoingAction::OfferSdpCreatePending { peer_id });
}
}
Expand Down