Skip to content

Commit

Permalink
refactor: use constant interchainstaking begin block interval (#331)
Browse files Browse the repository at this point in the history
* create

* use

* clean

* modify
  • Loading branch information
Alex Johnson authored Mar 3, 2023
1 parent cd4b82b commit f067363
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions x/interchainstaking/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ import (
"github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
)

const blockInterval = 30

type zoneItrFn func(index int64, zoneInfo types.Zone) (stop bool)

// BeginBlocker of interchainstaking module
func (k Keeper) BeginBlocker(ctx sdk.Context) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)

if ctx.BlockHeight()%30 == 0 {
if ctx.BlockHeight()%blockInterval == 0 {
if err := k.GCCompletedRedelegations(ctx); err != nil {
k.Logger(ctx).Error("error in GCCompletedRedelegations", "error", err)
}
}
k.IterateZones(ctx, func(index int64, zone types.Zone) (stop bool) {
if ctx.BlockHeight()%30 == 0 {
if ctx.BlockHeight()%blockInterval == 0 {
// for the tasks below, we cannot panic in begin blocker; as this will crash the chain.
// and as failing here is not terminal we panicking is not necessary, but we should log
// and as failing here is not terminal panicking is not necessary, but we should log
// as an error. we don't return on failure here as we still want to attempt the unrelated
// tasks below.
// commenting this out until we can revisit. in it's current state it causes more issues than it fixes.
// commenting this out until we can revisit. in its current state it causes more issues than it fixes.

if err := k.EnsureWithdrawalAddresses(ctx, &zone); err != nil {
k.Logger(ctx).Error("error in EnsureWithdrawalAddresses", "error", err)
Expand All @@ -39,8 +41,8 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) {
if err := k.GCCompletedUnbondings(ctx, &zone); err != nil {
k.Logger(ctx).Error("error in GCCompletedUnbondings", "error", err)
}

}

connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, zone.ConnectionId)
if found {
consState, found := k.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(ctx, connection.GetClientID())
Expand Down

0 comments on commit f067363

Please sign in to comment.