Skip to content

Commit

Permalink
revert: limit size to enqueue unbound delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Jan 3, 2024
1 parent c27e6b7 commit b4ae22d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
8 changes: 1 addition & 7 deletions x/stake/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ func handleMatureUnbondingDelegations(k keeper.Keeper, ctx sdk.Context) ([]types
}

const (
maxProcessedRefundCount = 10
maxUnboundPerBreatheBlock = 100
maxProcessedRefundCount = 10
)

func handleRefundStake(ctx sdk.Context, sideChainPrefix []byte, k keeper.Keeper) sdk.Events {
Expand All @@ -282,11 +281,6 @@ func handleRefundStake(ctx sdk.Context, sideChainPrefix []byte, k keeper.Keeper)
count := 0
boundDenom := k.BondDenom(sideChainCtx)
bscSideChainId := k.ScKeeper.BscSideChainId(ctx)
unBoundingDelegationSize := k.GetUnbondingSizeInQueue(sideChainCtx, ctx.BlockHeader().Time.Add(k.UnbondingTime(ctx)))
if unBoundingDelegationSize >= maxUnboundPerBreatheBlock {
ctx.Logger().Info("unBoundingDelegation exceed the maxUnboundPerBreatheBlock")
return refundEvents
}

for ; iterator.Valid(); iterator.Next() {
delegation := types.MustUnmarshalDelegation(k.CDC(), iterator.Key(), iterator.Value())
Expand Down
10 changes: 0 additions & 10 deletions x/stake/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,6 @@ func (k Keeper) UnbondingQueueIterator(ctx sdk.Context, endTime time.Time) sdk.I
return store.Iterator(UnbondingQueueKey, sdk.InclusiveEndBytes(GetUnbondingDelegationTimeKey(endTime)))
}

func (k Keeper) GetUnbondingSizeInQueue(ctx sdk.Context, endTime time.Time) int {
unbondingTimesliceIterator := k.UnbondingQueueIterator(ctx, endTime)
defer unbondingTimesliceIterator.Close()
size := 0
for ; unbondingTimesliceIterator.Valid(); unbondingTimesliceIterator.Next() {
size++
}
return size
}

// Returns a concatenated list of all the timeslices before currTime, and deletes the timeslices from the queue
func (k Keeper) DequeueAllMatureUnbondingQueue(ctx sdk.Context, currTime time.Time) (matureUnbonds []types.DVPair) {
store := ctx.KVStore(k.storeKey)
Expand Down

0 comments on commit b4ae22d

Please sign in to comment.