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: checkpointing/epoch growth bug #99

Merged
merged 5 commits into from
Aug 22, 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
6 changes: 3 additions & 3 deletions x/checkpointing/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, req abci.RequestBeginBlock)
// if this block is the second block of an epoch
epoch := k.GetEpoch(ctx)
if epoch.IsSecondBlock(ctx) {
// note that this epochNum is obtained before the BeginBlocker of the epoching module is executed
// meaning that the epochNum has not been incremented upon a new epoch
// note that this epochNum is obtained after the BeginBlocker of the epoching module is executed
// meaning that the epochNum has been incremented upon a new epoch
lch := ctx.BlockHeader().LastCommitHash
err := k.BuildRawCheckpoint(ctx, epoch.EpochNumber, lch)
err := k.BuildRawCheckpoint(ctx, epoch.EpochNumber-1, lch)
if err != nil {
panic("failed to generate a raw checkpoint")
}
Expand Down
2 changes: 1 addition & 1 deletion x/epoching/types/epoching.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (e Epoch) GetLastBlockHeight() uint64 {

func (e Epoch) GetSecondBlockHeight() uint64 {
if e.EpochNumber == 0 {
return 0
panic("should not be called when epoch number is zero")
}
return e.FirstBlockHeight + 1
}
Expand Down