diff --git a/x/epochs/abci.go b/x/epochs/abci.go index 5406d89afe9..884d05e2339 100644 --- a/x/epochs/abci.go +++ b/x/epochs/abci.go @@ -17,11 +17,15 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { logger := k.Logger(ctx) - // Has it not started, and is the block time > initial epoch start time - shouldInitialEpochStart := !epochInfo.EpochCountingStarted && !epochInfo.StartTime.After(ctx.BlockTime()) + // If blocktime < initial epoch start time, return + if ctx.BlockTime().Before(epochInfo.StartTime) { + return + } + // if epoch counting hasn't started, signal we need to start. + shouldInitialEpochStart := !epochInfo.EpochCountingStarted epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) - shouldEpochStart := (ctx.BlockTime().After(epochEndTime) && !epochInfo.StartTime.After(ctx.BlockTime())) || shouldInitialEpochStart + shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart if !shouldEpochStart { return false