Skip to content

Commit

Permalink
dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Sep 5, 2024
1 parent 1461b79 commit fa3ea9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
25 changes: 22 additions & 3 deletions crates/node/src/shell/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,16 @@ impl MockNode {
}

pub fn next_epoch(&mut self) -> Epoch {
{
println!("next_epoch");
let before = self
.shell
.lock()
.unwrap()
.state
.in_mem()
.get_current_epoch()
.0;
let is_already_switching = {
let mut locked = self.shell.lock().unwrap();

let next_epoch_height =
Expand All @@ -381,10 +390,20 @@ impl MockNode {
{
*height = next_epoch_min_start_height;
}
}
dbg!(locked.state.in_mem().update_epoch_blocks_delay.is_some())
};
println!("1. finalize_and_commit");
self.finalize_and_commit();
if !is_already_switching {
let locked = self.shell.lock().unwrap();
assert_eq!(
locked.state.in_mem().update_epoch_blocks_delay,
Some(EPOCH_SWITCH_BLOCKS_DELAY)
)
};

for _ in 0..EPOCH_SWITCH_BLOCKS_DELAY {
for i in 0..EPOCH_SWITCH_BLOCKS_DELAY {
println!("{}. finalize_and_commit", i + 2);
self.finalize_and_commit();
}
self.shell
Expand Down
10 changes: 5 additions & 5 deletions crates/state/src/wl_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,18 @@ where
time: DateTimeUtc,
parameters: &Parameters,
) -> Result<bool> {
match self.in_mem.update_epoch_blocks_delay.as_mut() {
match dbg!(self.in_mem.update_epoch_blocks_delay.as_mut()) {
None => {
// Check if the new epoch minimum start height and start time
// have been fulfilled. If so, queue the next
// epoch to start two blocks into the future so
// as to align validator set updates + etc with
// tendermint. This is because tendermint has a two block delay
// to validator changes.
let current_epoch_duration_satisfied = height
>= self.in_mem.next_epoch_min_start_height
&& time >= self.in_mem.next_epoch_min_start_time;
if current_epoch_duration_satisfied {
let current_epoch_duration_satisfied =
dbg!(height >= self.in_mem.next_epoch_min_start_height)
&& dbg!(time >= self.in_mem.next_epoch_min_start_time);
if dbg!(current_epoch_duration_satisfied) {
self.in_mem.update_epoch_blocks_delay =
Some(EPOCH_SWITCH_BLOCKS_DELAY);
}
Expand Down

0 comments on commit fa3ea9c

Please sign in to comment.