Skip to content

Commit 0d34847

Browse files
committed
Fix grace_period_end value when building inputs for block proof
1 parent f63efa5 commit 0d34847

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

node/src/block_producer/block_producer_reducer.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ use mina_p2p_messages::{
1212
StagedLedgerDiffBodyStableV1, StateBodyHash, StateHash, UnsignedExtendedUInt32StableV1,
1313
},
1414
};
15-
use openmina_core::{block::ArcBlockWithHash, constants::constraint_constants};
15+
use openmina_core::{
16+
block::ArcBlockWithHash, consensus::ConsensusConstants, constants::constraint_constants,
17+
};
1618
use openmina_core::{
1719
bug_condition,
1820
consensus::{
19-
global_sub_window, grace_period_end, in_same_checkpoint_window, in_seed_update_range,
20-
relative_sub_window,
21+
global_sub_window, in_same_checkpoint_window, in_seed_update_range, relative_sub_window,
2122
},
2223
};
2324
use redux::{callback, Dispatcher, Timestamp};
@@ -49,6 +50,7 @@ impl BlockProducerEnabled {
4950
let Ok(global_state) = state_context.get_substate_mut() else {
5051
return;
5152
};
53+
let consensus_constants = &global_state.config.consensus_constants;
5254

5355
let best_chain = &global_state.transition_frontier.best_chain;
5456
let Some(state) = global_state.block_producer.as_mut() else {
@@ -220,7 +222,7 @@ impl BlockProducerEnabled {
220222
dispatcher.push(BlockProducerEffectfulAction::StagedLedgerDiffCreateSuccess);
221223
}
222224
BlockProducerAction::BlockUnprovenBuild => {
223-
state.reduce_block_unproved_build(meta.time());
225+
state.reduce_block_unproved_build(consensus_constants, meta.time());
224226

225227
let dispatcher = state_context.into_dispatcher();
226228
dispatcher.push(BlockProducerEffectfulAction::BlockUnprovenBuild);
@@ -351,7 +353,11 @@ impl BlockProducerEnabled {
351353
}
352354
}
353355

354-
fn reduce_block_unproved_build(&mut self, time: Timestamp) {
356+
fn reduce_block_unproved_build(
357+
&mut self,
358+
consensus_constants: &ConsensusConstants,
359+
time: Timestamp,
360+
) {
355361
let BlockProducerCurrentState::StagedLedgerDiffCreateSuccess {
356362
won_slot,
357363
chain,
@@ -493,15 +499,15 @@ impl BlockProducerEnabled {
493499
} else {
494500
gt_pred_sub_window || lt_next_sub_window
495501
};
496-
if is_same_global_sub_window || are_windows_overlapping && !within_range {
502+
if is_same_global_sub_window || (are_windows_overlapping && !within_range) {
497503
density
498504
} else {
499505
0
500506
}
501507
})
502508
.collect::<Vec<_>>();
503509

504-
let grace_period_end = grace_period_end(pred_block.constants());
510+
let grace_period_end = consensus_constants.grace_period_end;
505511
let min_window_density = if is_same_global_sub_window
506512
|| curr_global_slot_since_hard_fork.slot_number.as_u32() < grace_period_end
507513
{

0 commit comments

Comments
 (0)