Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the height recorded for a new epoch #594

Merged
merged 2 commits into from
Oct 14, 2022
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/594-fix-pred-epoch-height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the value recorded for epoch start block height.
([#594](https://github.com/anoma/namada/pull/594))
18 changes: 13 additions & 5 deletions shared/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ where
let evidence_max_age_num_blocks: u64 = 100000;
self.block
.pred_epochs
.new_epoch(height + 1, evidence_max_age_num_blocks);
.new_epoch(height, evidence_max_age_num_blocks);
tracing::info!("Began a new epoch {}", self.block.epoch);
}
self.update_epoch_in_merkle_tree()?;
Expand Down Expand Up @@ -992,12 +992,20 @@ 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));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height + 1), Some(epoch_before.next()));
assert_eq!(
storage.block.pred_epochs.get_epoch(BlockHeight(block_height.0 - 1)),
Some(epoch_before));
assert_eq!(
storage.block.pred_epochs.get_epoch(block_height),
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));
assert_eq!(
storage.block.pred_epochs.get_epoch(BlockHeight(block_height.0 - 1)),
Some(epoch_before));
assert_eq!(
storage.block.pred_epochs.get_epoch(block_height),
Some(epoch_before));
}
// Last epoch should only change when the block is committed
assert_eq!(storage.last_epoch, epoch_before);
Expand Down