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
1 change: 0 additions & 1 deletion node/src/block_producer/block_producer_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub enum BlockProducerAction {
proof: Box<MinaBaseProofStableV2>,
},
BlockProduced,
#[action_event(level = trace)]
BlockInject,
BlockInjected,
}
Expand Down
9 changes: 8 additions & 1 deletion node/src/block_producer/block_producer_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,19 @@ impl BlockProducerCurrentState {
}

pub fn won_slot_should_produce(&self, now: redux::Timestamp) -> bool {
// TODO(binier): maybe have runtime estimate
#[cfg(not(target_arch = "wasm32"))]
const BLOCK_PRODUCTION_ESTIMATE: u64 = Duration::from_secs(5).as_nanos() as u64;
#[cfg(target_arch = "wasm32")]
const BLOCK_PRODUCTION_ESTIMATE: u64 = Duration::from_secs(20).as_nanos() as u64;

let slot_interval = Duration::from_secs(3 * 60).as_nanos() as u64;
match self {
Self::WonSlot { won_slot, .. } | Self::WonSlotWait { won_slot, .. } => {
// Make sure to only producer blocks when in the slot interval
let slot_upper_bound = won_slot.slot_time + slot_interval;
now >= won_slot.slot_time && now < slot_upper_bound
let estimated_produced_time = now + BLOCK_PRODUCTION_ESTIMATE;
estimated_produced_time >= won_slot.slot_time && now < slot_upper_bound
}
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion node/src/consensus/consensus_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl redux::EnablingCondition<crate::State> for ConsensusAction {
state.transition_frontier.sync.best_tip(),
])
.flatten()
.all(|b| b.hash() == best_tip.hash()
.any(|b| b.hash() == best_tip.hash()
|| !consensus_take(b.consensus_state(), best_tip.consensus_state(), b.hash(), best_tip.hash())) {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions node/src/snark_pool/candidate/snark_pool_candidate_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub enum SnarkPoolCandidateAction {
peer_id: PeerId,
info: SnarkInfo,
},
#[action_event(level = trace)]
WorkFetchAll,
WorkFetchInit {
peer_id: PeerId,
Expand All @@ -34,6 +35,7 @@ pub enum SnarkPoolCandidateAction {
peer_id: PeerId,
work: Snark,
},
#[action_event(level = trace)]
WorkVerifyNext,
WorkVerifyPending {
peer_id: PeerId,
Expand Down
3 changes: 3 additions & 0 deletions node/src/snark_pool/snark_pool_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum SnarkPoolAction {
snark: Snark,
sender: PeerId,
},
#[action_event(level = trace)]
P2pSendAll,
P2pSend {
peer_id: PeerId,
Expand Down Expand Up @@ -78,6 +79,8 @@ impl redux::EnablingCondition<crate::State> for SnarkPoolAction {
SnarkPoolAction::P2pSend { peer_id } => state
.p2p
.get_ready_peer(peer_id)
// can't propagate empty snarkpool
.filter(|_| !state.snark_pool.is_empty())
// Only send commitments/snarks if peer has the same best tip,
// or its best tip is extension of our best tip. In such case
// no commitment/snark will be dropped by peer, because it
Expand Down
4 changes: 4 additions & 0 deletions node/src/snark_pool/snark_pool_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ impl SnarkPoolState {
}
}

pub fn is_empty(&self) -> bool {
self.list.is_empty()
}

pub fn last_index(&self) -> u64 {
self.list.last_key_value().map_or(0, |(k, _)| *k)
}
Expand Down
Loading