Skip to content

Commit

Permalink
calibration: logic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-stride committed Oct 11, 2023
1 parent e8bad99 commit 876b1e0
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 267 deletions.
1 change: 0 additions & 1 deletion x/stakeibc/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func GetTxCmd() *cobra.Command {
cmd.AddCommand(CmdDeleteValidator())
cmd.AddCommand(CmdRestoreInterchainAccount())
cmd.AddCommand(CmdUpdateValidatorSharesExchRate())
cmd.AddCommand(CmdCalibrateDelegation())
cmd.AddCommand(CmdClearBalance())
cmd.AddCommand(CmdUpdateInnerRedemptionRateBounds())

Expand Down
3 changes: 0 additions & 3 deletions x/stakeibc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ func NewMessageHandler(k keeper.Keeper) sdk.Handler {
case *types.MsgUpdateValidatorSharesExchRate:
res, err := msgServer.UpdateValidatorSharesExchRate(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgCalibrateDelegation:
res, err := msgServer.CalibrateDelegation(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgUpdateInnerRedemptionRateBounds:
res, err := msgServer.UpdateInnerRedemptionRateBounds(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
Expand Down
2 changes: 0 additions & 2 deletions x/stakeibc/keeper/icqcallbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const (
ICQCallbackID_FeeBalance = "feebalance"
ICQCallbackID_Delegation = "delegation"
ICQCallbackID_Validator = "validator"
ICQCallbackID_Calibrate = "calibrate"
)

// ICQCallbacks wrapper struct for stakeibc keeper
Expand Down Expand Up @@ -48,5 +47,4 @@ func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks {
AddICQCallback(ICQCallbackID_FeeBalance, ICQCallback(FeeBalanceCallback)).
AddICQCallback(ICQCallbackID_Delegation, ICQCallback(DelegatorSharesCallback)).
AddICQCallback(ICQCallbackID_Validator, ICQCallback(ValidatorSharesToTokensRateCallback)).
AddICQCallback(ICQCallbackID_Calibrate, ICQCallback(CalibrateDelegationCallback))
}

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected }, expecting name or ( (typecheck)

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected selector or type assertion, found '}' (typecheck)

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected }, expecting name or () (typecheck)

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected }, expecting name or () (typecheck)

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected }, expecting name or () (typecheck)

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / stride amd64 for darwin

syntax error: unexpected }, expecting name or (

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / stride amd64 for linux

syntax error: unexpected }, expecting name or (

Check failure on line 50 in x/stakeibc/keeper/icqcallbacks.go

View workflow job for this annotation

GitHub Actions / stride arm64 for darwin

syntax error: unexpected }, expecting name or (
110 changes: 0 additions & 110 deletions x/stakeibc/keeper/icqcallbacks_callibrate_delegation.go

This file was deleted.

25 changes: 0 additions & 25 deletions x/stakeibc/keeper/msg_server_calibrate_delegation.go

This file was deleted.

58 changes: 0 additions & 58 deletions x/stakeibc/keeper/msg_server_submit_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,61 +492,3 @@ func (k Keeper) SubmitDelegationICQ(ctx sdk.Context, hostZone types.HostZone, va

return nil
}

// Submits an ICQ to get a validator's delegations
// This is called after the validator's sharesToTokens rate is determined
// The timeoutDuration parameter represents the length of the timeout (not to be confused with an actual timestamp)
func (k Keeper) SubmitCalibrationICQ(ctx sdk.Context, hostZone types.HostZone, validatorAddress string) error {
if hostZone.DelegationIcaAddress == "" {
return errorsmod.Wrapf(types.ErrICAAccountNotFound, "no delegation address found for %s", hostZone.ChainId)
}
validator, valIndex, found := GetValidatorFromAddress(hostZone.Validators, validatorAddress)
if !found {
return errorsmod.Wrapf(types.ErrValidatorNotFound, "no registered validator for address (%s)", validatorAddress)
}

// Get the validator and delegator encoded addresses to form the query request
_, validatorAddressBz, err := bech32.DecodeAndConvert(validatorAddress)
if err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid validator address, could not decode (%s)", err.Error())
}
_, delegatorAddressBz, err := bech32.DecodeAndConvert(hostZone.DelegationIcaAddress)
if err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid delegator address, could not decode (%s)", err.Error())
}
queryData := stakingtypes.GetDelegationKey(delegatorAddressBz, validatorAddressBz)

// Store the current validator's delegation in the callback data so we can determine if it changed
// while the query was in flight
callbackData := types.DelegatorSharesQueryCallback{
InitialValidatorDelegation: validator.Delegation,
}
callbackDataBz, err := proto.Marshal(&callbackData)
if err != nil {
return errorsmod.Wrapf(err, "unable to marshal delegator shares callback data")
}

// Update the validator to indicate that the slash query is in progress
validator.SlashQueryInProgress = true
hostZone.Validators[valIndex] = &validator
k.SetHostZone(ctx, hostZone)

// Submit delegator shares ICQ
query := icqtypes.Query{
ChainId: hostZone.ChainId,
ConnectionId: hostZone.ConnectionId,
QueryType: icqtypes.STAKING_STORE_QUERY_WITH_PROOF,
RequestData: queryData,
CallbackModule: types.ModuleName,
CallbackId: ICQCallbackID_Calibrate,
CallbackData: callbackDataBz,
TimeoutDuration: time.Hour,
TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST,
}
if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Error submitting ICQ for delegation, error : %s", err.Error()))
return err
}

return nil
}
2 changes: 0 additions & 2 deletions x/stakeibc/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&ToggleLSMProposal{}, "stakeibc/ToggleLSMProposal", nil)
cdc.RegisterConcrete(&MsgRestoreInterchainAccount{}, "stakeibc/RestoreInterchainAccount", nil)
cdc.RegisterConcrete(&MsgUpdateValidatorSharesExchRate{}, "stakeibc/UpdateValidatorSharesExchRate", nil)
cdc.RegisterConcrete(&MsgCalibrateDelegation{}, "stakeibc/CalibrateDelegation", nil)
cdc.RegisterConcrete(&MsgUpdateInnerRedemptionRateBounds{}, "stakeibc/UpdateInnerRedemptionRateBounds", nil)
// this line is used by starport scaffolding # 2
}
Expand All @@ -41,7 +40,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgDeleteValidator{},
&MsgRestoreInterchainAccount{},
&MsgUpdateValidatorSharesExchRate{},
&MsgCalibrateDelegation{},
&MsgUpdateInnerRedemptionRateBounds{},
)

Expand Down
66 changes: 0 additions & 66 deletions x/stakeibc/types/message_calibrate_delegation.go

This file was deleted.

0 comments on commit 876b1e0

Please sign in to comment.