Skip to content

Commit

Permalink
fix!: condition that makes redelegation happen on unbonding epoch. (#685
Browse files Browse the repository at this point in the history
)

* fix condition that makes redelegation happen on unbonding epoch.

* add more logs

* add changalog

* move logging to hooks.go
  • Loading branch information
puneet2019 authored Dec 3, 2023
1 parent 1cc3067 commit 5a47b59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

### Bug Fixes

- [685](https://github.com/persistenceOne/pstake-native/pull/685) Fix rebalancing to happen outside of unbonding epochs

## [v2.6.0] - 2023-11-26

### Features
Expand Down
8 changes: 6 additions & 2 deletions x/liquidstakeibc/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,16 +886,20 @@ func (k *Keeper) LSMWorkflow(ctx sdk.Context) {

// RebalanceWorkflow tries to make redelegate transactions to host-chain to balance the delegations as per the weights.
func (k Keeper) RebalanceWorkflow(ctx sdk.Context, epoch int64) {
k.Logger(ctx).Info("Running redelegation workflow.", "epoch", epoch)

hcs := k.GetAllHostChains(ctx)
for _, hc := range hcs {
// skip unbonding epoch, as we do not want to redelegate tokens that might be going through unbond txn in same epoch.
// nothing bad will happen even if we do as long as unbonding txns are triggered before redelegations.
if !liquidstakeibctypes.IsUnbondingEpoch(hc.UnbondingFactor, epoch) {
k.Logger(ctx).Info("redelegation epoch co-incides with unbonding epoch, skipping it")
if liquidstakeibctypes.IsUnbondingEpoch(hc.UnbondingFactor, epoch) {
k.Logger(ctx).Info("redelegation epoch co-incides with unbonding epoch, skipping it for", "chainID", hc.ChainId)
continue
}
msgs := k.GenerateRedelegateMsgs(ctx, *hc)
if len(msgs) == 0 {
k.Logger(ctx).Info("no msgs to redelegate for", "chainID", hc.ChainId)
}
// send one msg per ica
for _, msg := range msgs {
ibcSeq, err := k.GenerateAndExecuteICATx(ctx, hc.ConnectionId, hc.DelegationAccount.Owner, []proto.Message{msg})
Expand Down

0 comments on commit 5a47b59

Please sign in to comment.