Skip to content

Commit

Permalink
Merge branch 'tomas+tiago/fix-pred-epoch-height' (#384)
Browse files Browse the repository at this point in the history
* tomas+tiago/fix-pred-epoch-height:
  changelog: add #384
  shared/storage: fix the height recorded for a new epoch
  • Loading branch information
brentstone committed Oct 13, 2022
2 parents 7dc409b + 388a69d commit cc00fff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the value recorded for epoch start block height.
([#384](https://github.com/anoma/namada/issues/384))
6 changes: 4 additions & 2 deletions shared/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ where
let evidence_max_age_num_blocks: u64 = 100000;
self.block
.pred_epochs
.new_epoch(height, evidence_max_age_num_blocks);
.new_epoch(height + 1, evidence_max_age_num_blocks);
tracing::info!("Began a new epoch {}", self.block.epoch);
}
self.update_epoch_in_merkle_tree()?;
Expand Down Expand Up @@ -990,10 +990,12 @@ mod tests {
block_height + epoch_duration.min_num_of_blocks);
assert_eq!(storage.next_epoch_min_start_time,
block_time + epoch_duration.min_duration);
assert_eq!(storage.block.pred_epochs.get_epoch(block_height), Some(epoch_before.next()));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height), Some(epoch_before));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height + 1), Some(epoch_before.next()));
} else {
assert_eq!(storage.block.epoch, epoch_before);
assert_eq!(storage.block.pred_epochs.get_epoch(block_height), Some(epoch_before));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height + 1), Some(epoch_before));
}
// Last epoch should only change when the block is committed
assert_eq!(storage.last_epoch, epoch_before);
Expand Down

0 comments on commit cc00fff

Please sign in to comment.