Skip to content

Commit

Permalink
Fix: checkpointing/epoch growth bug (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry authored Aug 22, 2022
1 parent 9489958 commit b21c381
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit b21c381

Please sign in to comment.