Skip to content

Commit

Permalink
added log to undelegate icacallback (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs authored Aug 29, 2024
1 parent f4cee77 commit 9bea98d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dockernet/scripts/1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../config.sh

## IBC ATOM from GAIA to STRIDE
$GAIA_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $(STRIDE_ADDRESS) 1000000uatom --from ${GAIA_VAL_PREFIX}1 -y
$GAIA_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $(STRIDE_ADDRESS) 1000000uatom --from ${GAIA_VAL_PREFIX}1 -y --fees 1000000ufee
sleep 10
$STRIDE_MAIN_CMD q bank balances $(STRIDE_ADDRESS)
13 changes: 9 additions & 4 deletions x/stakeibc/keeper/icacallbacks_undelegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ func (k Keeper) UpdateHostZoneUnbondingsAfterUndelegation(
stTokensToBurn = sdk.NewDecFromInt(nativeTokensUnbonded).Quo(impliedRedemptionRate).TruncateInt()
}

k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(chainId, ICACallbackID_Undelegate,
"Epoch Unbonding Record: %d - Native Unbonded: %v, StTokens Burned: %v",
epochNumber, nativeTokensUnbonded, stTokensToBurn))

// Decrement st amount on the record and increment the total
hostZoneUnbonding.StTokensToBurn = hostZoneUnbonding.StTokensToBurn.Sub(stTokensToBurn)
totalStTokensToBurn = totalStTokensToBurn.Add(stTokensToBurn)
Expand All @@ -259,15 +263,15 @@ func (k Keeper) UpdateHostZoneUnbondingsAfterUndelegation(
// Update the unbonding time if the time from this batch is later than what's on the record
if unbondingTime > hostZoneUnbonding.UnbondingTime {
hostZoneUnbonding.UnbondingTime = unbondingTime

k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(chainId, ICACallbackID_Undelegate,
"Epoch Unbonding Record: %d - Setting unbonding time to %d", epochNumber, unbondingTime))
}

// Persist the record changes
if err := k.RecordsKeeper.SetHostZoneUnbondingRecord(ctx, epochNumber, chainId, *hostZoneUnbonding); err != nil {
return totalStTokensToBurn, err
}

k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(chainId, ICACallbackID_Undelegate,
"Epoch Unbonding Record: %d - Setting unbonding time to %d", epochNumber, unbondingTime))
}
return totalStTokensToBurn, nil
}
Expand All @@ -293,6 +297,7 @@ func (k Keeper) BurnStTokensAfterUndelegation(ctx sdk.Context, hostZone types.Ho
if err != nil {
return errorsmod.Wrapf(err, "unable to burn %v%s tokens", stTokenBurnAmount, stCoinDenom)
}
k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(hostZone.ChainId, ICACallbackID_Undelegate, "Burned %v", stCoin))
k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(hostZone.ChainId, ICACallbackID_Undelegate,
"Total Burned from Batch %v", stCoin))
return nil
}

0 comments on commit 9bea98d

Please sign in to comment.