diff --git a/app/app.go b/app/app.go index f587268a..feedf4f9 100644 --- a/app/app.go +++ b/app/app.go @@ -894,6 +894,7 @@ func NewMilkyWayApp( app.RecordsKeeper, app.ICACallbacksKeeper, app.RateLimitKeeper, + app.OPChildKeeper, ) app.StakeIBCKeeper.SetHooks(stakeibctypes.NewMultiStakeIBCHooks()) icaCallbacksStack = stakeibc.NewIBCMiddleware(icaCallbacksStack, app.StakeIBCKeeper) diff --git a/utils/admins.go b/utils/admins.go deleted file mode 100644 index 173b9845..00000000 --- a/utils/admins.go +++ /dev/null @@ -1,5 +0,0 @@ -package utils - -var Admins = map[string]bool{ - "init163ynqsk9tnv5zted5v9upk9scgtnq2eqr6x7sh": true, -} diff --git a/utils/utils.go b/utils/utils.go index b1c4da6b..9ca475be 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -31,17 +31,6 @@ func FilterDepositRecords(arr []recordstypes.DepositRecord, condition func(recor return ret } -func Int64ToCoinString(amount int64, denom string) string { - return strconv.FormatInt(amount, 10) + denom -} - -func ValidateAdminAddress(address string) error { - if !Admins[address] { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "address (%s) is not an admin", address) - } - return nil -} - func Min(a int, b int) int { if a < b { return a @@ -58,15 +47,6 @@ func StringMapKeys[V any](m map[string]V) []string { return keys } -func Int32MapKeys[V any](m map[int32]V) []int32 { - keys := make([]int32, 0, len(m)) - for k := range m { - keys = append(keys, k) - } - sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) - return keys -} - // ============================== ADDRESS VERIFICATION UTILS ================================ // ref: https://github.com/cosmos/cosmos-sdk/blob/b75c2ebcfab1a6b535723f1ac2889a2fc2509520/types/address.go#L177 diff --git a/x/stakeibc/keeper/abci.go b/x/stakeibc/keeper/abci.go index a2a11895..a18ae58c 100644 --- a/x/stakeibc/keeper/abci.go +++ b/x/stakeibc/keeper/abci.go @@ -24,7 +24,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { // set rate limit on stAsset stDenom := types.StAssetDenomFromHostZoneDenom(hz.HostDenom) - k.RatelimitKeeper.AddDenomToBlacklist(ctx, stDenom) + k.rateLimitKeeper.AddDenomToBlacklist(ctx, stDenom) k.Logger(ctx).Error(fmt.Sprintf("[INVARIANT BROKEN!!!] %s's RR is %s. ERR: %v", hz.GetChainId(), hz.RedemptionRate.String(), err.Error())) ctx.EventManager().EmitEvent( diff --git a/x/stakeibc/keeper/claim.go b/x/stakeibc/keeper/claim.go index 7a286fc5..30922ebf 100644 --- a/x/stakeibc/keeper/claim.go +++ b/x/stakeibc/keeper/claim.go @@ -64,7 +64,7 @@ func (k msgServer) ClaimUndelegatedTokens(goCtx context.Context, msg *types.MsgC // Set claimIsPending to true, so that the record can't be double claimed userRedemptionRecord.ClaimIsPending = true - k.RecordsKeeper.SetUserRedemptionRecord(ctx, *userRedemptionRecord) + k.recordsKeeper.SetUserRedemptionRecord(ctx, *userRedemptionRecord) return &types.MsgClaimUndelegatedTokensResponse{}, nil } @@ -72,7 +72,7 @@ func (k msgServer) ClaimUndelegatedTokens(goCtx context.Context, msg *types.MsgC func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error) { // grab the UserRedemptionRecord from the store userRedemptionRecordKey := recordstypes.UserRedemptionRecordKeyFormatter(msg.HostZoneId, msg.Epoch, msg.Receiver) - userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordKey) + userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordKey) if !found { errMsg := fmt.Sprintf("User redemption record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId) k.Logger(ctx).Error(errMsg) @@ -80,7 +80,7 @@ func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClai } // check that the record is claimable - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, userRedemptionRecord.EpochNumber, msg.HostZoneId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, userRedemptionRecord.EpochNumber, msg.HostZoneId) if !found { errMsg := fmt.Sprintf("Host zone unbonding record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId) k.Logger(ctx).Error(errMsg) diff --git a/x/stakeibc/keeper/community_pool.go b/x/stakeibc/keeper/community_pool.go index 089b3bf4..4b418a33 100644 --- a/x/stakeibc/keeper/community_pool.go +++ b/x/stakeibc/keeper/community_pool.go @@ -153,7 +153,7 @@ func (k Keeper) QueryCommunityPoolIcaBalance( TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { return errorsmod.Wrapf(err, "Error submitting query for pool ica balance") } diff --git a/x/stakeibc/keeper/delegation.go b/x/stakeibc/keeper/delegation.go index c0175154..bf7828d4 100644 --- a/x/stakeibc/keeper/delegation.go +++ b/x/stakeibc/keeper/delegation.go @@ -81,7 +81,7 @@ func (k Keeper) DelegateOnHost(ctx sdk.Context, hostZone types.HostZone, amt sdk // update the record state to DELEGATION_IN_PROGRESS depositRecord.Status = recordstypes.DepositRecord_DELEGATION_IN_PROGRESS - k.RecordsKeeper.SetDepositRecord(ctx, depositRecord) + k.recordsKeeper.SetDepositRecord(ctx, depositRecord) return nil } diff --git a/x/stakeibc/keeper/grpc_query.go b/x/stakeibc/keeper/grpc_query.go index e2ae1802..8985ac4e 100644 --- a/x/stakeibc/keeper/grpc_query.go +++ b/x/stakeibc/keeper/grpc_query.go @@ -40,7 +40,7 @@ func (k Keeper) ModuleAddress(goCtx context.Context, req *types.QueryModuleAddre ctx := sdk.UnwrapSDKContext(goCtx) - addr := k.AccountKeeper.GetModuleAccount(ctx, req.Name).GetAddress().String() + addr := k.accountKeeper.GetModuleAccount(ctx, req.Name).GetAddress().String() return &types.QueryModuleAddressResponse{Addr: addr}, nil } @@ -121,7 +121,7 @@ func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbo } currentDay := dayEpochTracker.EpochNumber - epochUnbondingRecords := k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) + epochUnbondingRecords := k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) for _, epochUnbondingRecord := range epochUnbondingRecords { for _, hostZoneUnbonding := range epochUnbondingRecord.GetHostZoneUnbondings() { @@ -142,7 +142,7 @@ func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbo } } if targetAddress { - userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId) + userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId) if !found { continue // the record has already been claimed } @@ -229,7 +229,7 @@ func (k Keeper) InterchainAccountFromAddress(goCtx context.Context, req *types.Q return nil, status.Errorf(codes.InvalidArgument, "could not find account: %s", err) } - addr, found := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, req.ConnectionId, portID) + addr, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, req.ConnectionId, portID) if !found { return nil, status.Errorf(codes.NotFound, "no account found for portID %s", portID) } @@ -243,7 +243,7 @@ func (k Keeper) NextPacketSequence(c context.Context, req *types.QueryGetNextPac } ctx := sdk.UnwrapSDKContext(c) - sequence, found := k.IBCKeeper.ChannelKeeper.GetNextSequenceSend(ctx, req.PortId, req.ChannelId) + sequence, found := k.ibcKeeper.ChannelKeeper.GetNextSequenceSend(ctx, req.PortId, req.ChannelId) if !found { return nil, status.Error(codes.InvalidArgument, "channel and port combination not found") } diff --git a/x/stakeibc/keeper/hooks.go b/x/stakeibc/keeper/hooks.go index 544c17cc..7dd7e21a 100644 --- a/x/stakeibc/keeper/hooks.go +++ b/x/stakeibc/keeper/hooks.go @@ -47,7 +47,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf // Create a new deposit record for each host zone and the grab all deposit records k.CreateDepositRecordsForEpoch(ctx, epochNumber) - depositRecords := k.RecordsKeeper.GetAllDepositRecord(ctx) + depositRecords := k.recordsKeeper.GetAllDepositRecord(ctx) // TODO: move this to an external function that anyone can call, so that we don't have to call it every epoch k.SetWithdrawalAddress(ctx) diff --git a/x/stakeibc/keeper/host_zone.go b/x/stakeibc/keeper/host_zone.go index b9282d65..200216ff 100644 --- a/x/stakeibc/keeper/host_zone.go +++ b/x/stakeibc/keeper/host_zone.go @@ -123,7 +123,7 @@ func (k Keeper) UnregisterHostZone(ctx sdk.Context, chainId string) error { // Burn all outstanding stTokens stTokenDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.HostDenom) - for _, account := range k.AccountKeeper.GetAllAccounts(ctx) { + for _, account := range k.accountKeeper.GetAllAccounts(ctx) { stTokenBalance := k.bankKeeper.GetBalance(ctx, account.GetAddress(), stTokenDenom) stTokensToBurn := sdk.NewCoins(stTokenBalance) if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, account.GetAddress(), types.ModuleName, stTokensToBurn); err != nil { @@ -135,26 +135,26 @@ func (k Keeper) UnregisterHostZone(ctx sdk.Context, chainId string) error { } // Set the escrow'd tokens to 0 (all the escrowed tokens should have been burned from the above) - k.RecordsKeeper.TransferKeeper.SetTotalEscrowForDenom(ctx, sdk.NewCoin(stTokenDenom, sdkmath.ZeroInt())) + k.recordsKeeper.TransferKeeper.SetTotalEscrowForDenom(ctx, sdk.NewCoin(stTokenDenom, sdkmath.ZeroInt())) // Remove module accounts depositAddress := types.NewHostZoneDepositAddress(chainId) communityPoolStakeAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolStakeHoldingAddressKey) communityPoolRedeemAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolRedeemHoldingAddressKey) - k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, depositAddress)) - k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, communityPoolStakeAddress)) - k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, communityPoolRedeemAddress)) + k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, depositAddress)) + k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, communityPoolStakeAddress)) + k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, communityPoolRedeemAddress)) // Remove all deposit records for the host zone - for _, depositRecord := range k.RecordsKeeper.GetAllDepositRecord(ctx) { + for _, depositRecord := range k.recordsKeeper.GetAllDepositRecord(ctx) { if depositRecord.HostZoneId == chainId { - k.RecordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id) + k.recordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id) } } // Remove all epoch unbonding records for the host zone - for _, epochUnbondingRecord := range k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) { + for _, epochUnbondingRecord := range k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) { updatedHostZoneUnbondings := []*recordstypes.HostZoneUnbonding{} for _, hostZoneUnbonding := range epochUnbondingRecord.HostZoneUnbondings { if hostZoneUnbonding.HostZoneId != chainId { @@ -162,23 +162,23 @@ func (k Keeper) UnregisterHostZone(ctx sdk.Context, chainId string) error { } } epochUnbondingRecord.HostZoneUnbondings = updatedHostZoneUnbondings - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord) } // Remove all user redemption records for the host zone - for _, userRedemptionRecord := range k.RecordsKeeper.GetAllUserRedemptionRecord(ctx) { + for _, userRedemptionRecord := range k.recordsKeeper.GetAllUserRedemptionRecord(ctx) { if userRedemptionRecord.HostZoneId == chainId { - k.RecordsKeeper.RemoveUserRedemptionRecord(ctx, userRedemptionRecord.Id) + k.recordsKeeper.RemoveUserRedemptionRecord(ctx, userRedemptionRecord.Id) } } // Remove whitelisted address pairs from rate limit module - rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() - k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.DepositAddress, hostZone.DelegationIcaAddress) - k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.FeeIcaAddress, rewardCollectorAddress.String()) - k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolStakeHoldingAddress) - k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolRedeemHoldingAddress) - k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolStakeHoldingAddress, hostZone.CommunityPoolReturnIcaAddress) + rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.DepositAddress, hostZone.DelegationIcaAddress) + k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.FeeIcaAddress, rewardCollectorAddress.String()) + k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolStakeHoldingAddress) + k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolRedeemHoldingAddress) + k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolStakeHoldingAddress, hostZone.CommunityPoolReturnIcaAddress) // Finally, remove the host zone struct k.RemoveHostZone(ctx, chainId) diff --git a/x/stakeibc/keeper/ibc.go b/x/stakeibc/keeper/ibc.go index 0d099494..64a57031 100644 --- a/x/stakeibc/keeper/ibc.go +++ b/x/stakeibc/keeper/ibc.go @@ -18,11 +18,11 @@ import ( func (k Keeper) OnChanOpenAck(ctx sdk.Context, portID, channelID string) error { // Lookup connection ID, counterparty chain ID, and ICA address from the channel ID - controllerConnectionId, _, err := k.IBCKeeper.ChannelKeeper.GetChannelConnection(ctx, portID, channelID) + controllerConnectionId, _, err := k.ibcKeeper.ChannelKeeper.GetChannelConnection(ctx, portID, channelID) if err != nil { return err } - address, found := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, controllerConnectionId, portID) + address, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, controllerConnectionId, portID) if !found { k.Logger(ctx).Info(fmt.Sprintf("No ICA address associated with connection %s and port %s", controllerConnectionId, portID)) return nil @@ -117,7 +117,7 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres // Once the delegation channel is registered, whitelist epochly transfers so they're not rate limited // Epochly transfers go from the deposit address to the delegation address if portId == delegationPortID { - k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ + k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ Sender: hostZone.DepositAddress, Receiver: hostZone.DelegationIcaAddress, }) @@ -126,8 +126,8 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres // Once the fee channel is registered, whitelist reward transfers so they're not rate limited // Reward transfers go from the fee address to the reward collector if portId == feePortID { - rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() - k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ + rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ Sender: hostZone.FeeIcaAddress, Receiver: rewardCollectorAddress.String(), }) @@ -136,11 +136,11 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres // Once the community pool deposit ICA is registered, whitelist epochly community pool transfers // from the deposit ICA to the community pool holding accounts if portId == communityPoolDepositPortID { - k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ + k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ Sender: hostZone.CommunityPoolDepositIcaAddress, Receiver: hostZone.CommunityPoolStakeHoldingAddress, }) - k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ + k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ Sender: hostZone.CommunityPoolDepositIcaAddress, Receiver: hostZone.CommunityPoolRedeemHoldingAddress, }) @@ -149,7 +149,7 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres // Once the community pool return ICA is registered, whitelist epochly community pool transfers // from the community pool stake holding account to the community pool return ICA if portId == communityPoolReturnPortID { - k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ + k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{ Sender: hostZone.CommunityPoolStakeHoldingAddress, Receiver: hostZone.CommunityPoolReturnIcaAddress, }) @@ -202,14 +202,14 @@ func (k Keeper) StoreTradeRouteIcaAddress(ctx sdk.Context, callbackChainId, call // Retrieves the light client time for a given connection func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) (uint64, error) { // get light client's latest height - conn, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) + conn, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) if !found { errMsg := fmt.Sprintf("invalid connection id, %s not found", connectionID) k.Logger(ctx).Error(errMsg) return 0, fmt.Errorf(errMsg) } // TODO(TEST-112) make sure to update host LCs here! - latestConsensusClientState, found := k.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(ctx, conn.ClientId) + latestConsensusClientState, found := k.ibcKeeper.ClientKeeper.GetLatestClientConsensusState(ctx, conn.ClientId) if !found { errMsg := fmt.Sprintf("client id %s not found for connection %s", conn.ClientId, connectionID) k.Logger(ctx).Error(errMsg) @@ -224,13 +224,13 @@ func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) ( // Retrieves the light client time for a given connection func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string) (uint64, error) { // get light client's latest height - conn, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) + conn, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) if !found { errMsg := fmt.Sprintf("invalid connection id, %s not found", connectionID) k.Logger(ctx).Error(errMsg) return 0, fmt.Errorf(errMsg) } - clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, conn.ClientId) + clientState, found := k.ibcKeeper.ClientKeeper.GetClientState(ctx, conn.ClientId) if !found { errMsg := fmt.Sprintf("client id %s not found for connection %s", conn.ClientId, connectionID) k.Logger(ctx).Error(errMsg) @@ -248,11 +248,11 @@ func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string) // Lookup a chain ID from a connection ID by looking up the client state func (k Keeper) GetChainIdFromConnectionId(ctx sdk.Context, connectionID string) (string, error) { - connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) + connection, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID) if !found { return "", errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection %s not found", connectionID) } - clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) + clientState, found := k.ibcKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) if !found { return "", errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client %s not found", connection.ClientId) } diff --git a/x/stakeibc/keeper/icacallbacks_claim.go b/x/stakeibc/keeper/icacallbacks_claim.go index 104cef97..65fd4955 100644 --- a/x/stakeibc/keeper/icacallbacks_claim.go +++ b/x/stakeibc/keeper/icacallbacks_claim.go @@ -48,7 +48,7 @@ func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackRe "Starting claim callback for Redemption Record: %s", claimCallback.UserRedemptionRecordId)) // Grab the associated user redemption record - userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, claimCallback.GetUserRedemptionRecordId()) + userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, claimCallback.GetUserRedemptionRecordId()) if !found { return errorsmod.Wrapf(types.ErrRecordNotFound, "user redemption record not found %s", claimCallback.GetUserRedemptionRecordId()) } @@ -60,7 +60,7 @@ func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackRe icacallbackstypes.AckResponseStatus_TIMEOUT, packet)) userRedemptionRecord.ClaimIsPending = false - k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) + k.recordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) return nil } @@ -72,7 +72,7 @@ func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackRe // after an error, a user should be able to retry the claim userRedemptionRecord.ClaimIsPending = false - k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) + k.recordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) return nil } @@ -80,7 +80,7 @@ func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackRe icacallbackstypes.AckResponseStatus_SUCCESS, packet)) // Upon success, remove the record and decrement the unbonded amount on the host zone unbonding record - k.RecordsKeeper.RemoveUserRedemptionRecord(ctx, claimCallback.GetUserRedemptionRecordId()) + k.recordsKeeper.RemoveUserRedemptionRecord(ctx, claimCallback.GetUserRedemptionRecordId()) err = k.DecrementHostZoneUnbonding(ctx, userRedemptionRecord, *claimCallback) if err != nil { k.Logger(ctx).Error(fmt.Sprintf("ClaimCallback failed (DecrementHostZoneUnbonding), packet %v, err: %s", packet, err.Error())) @@ -94,7 +94,7 @@ func (k Keeper) ClaimCallback(ctx sdk.Context, packet channeltypes.Packet, ackRe // After a user claims their unbonded tokens, the claim amount is decremented from the corresponding host zone unbonding record func (k Keeper) DecrementHostZoneUnbonding(ctx sdk.Context, userRedemptionRecord recordstypes.UserRedemptionRecord, callbackArgs types.ClaimCallback) error { // fetch the hzu associated with the user unbonding record - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, callbackArgs.EpochNumber, callbackArgs.ChainId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, callbackArgs.EpochNumber, callbackArgs.ChainId) if !found { return errorsmod.Wrapf(types.ErrRecordNotFound, "host zone unbonding not found %s", callbackArgs.ChainId) } @@ -103,10 +103,10 @@ func (k Keeper) DecrementHostZoneUnbonding(ctx sdk.Context, userRedemptionRecord hostZoneUnbonding.NativeTokenAmount = hostZoneUnbonding.NativeTokenAmount.Sub(userRedemptionRecord.NativeTokenAmount) // save the updated hzu on the epoch unbonding record - epochUnbondingRecord, success := k.RecordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, callbackArgs.EpochNumber, callbackArgs.ChainId, hostZoneUnbonding) + epochUnbondingRecord, success := k.recordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, callbackArgs.EpochNumber, callbackArgs.ChainId, hostZoneUnbonding) if !success { return errorsmod.Wrapf(types.ErrRecordNotFound, "epoch unbonding record not found %s", callbackArgs.ChainId) } - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, *epochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, *epochUnbondingRecord) return nil } diff --git a/x/stakeibc/keeper/icacallbacks_delegate.go b/x/stakeibc/keeper/icacallbacks_delegate.go index e3c9ce7b..7efdb7e9 100644 --- a/x/stakeibc/keeper/icacallbacks_delegate.go +++ b/x/stakeibc/keeper/icacallbacks_delegate.go @@ -58,7 +58,7 @@ func (k Keeper) DelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ac return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "host zone not found %s", chainId) } recordId := delegateCallback.DepositRecordId - depositRecord, found := k.RecordsKeeper.GetDepositRecord(ctx, recordId) + depositRecord, found := k.recordsKeeper.GetDepositRecord(ctx, recordId) if !found { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "deposit record not found %d", recordId) } @@ -87,7 +87,7 @@ func (k Keeper) DelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ac // Reset deposit record status depositRecord.Status = recordstypes.DepositRecord_DELEGATION_QUEUE - k.RecordsKeeper.SetDepositRecord(ctx, depositRecord) + k.recordsKeeper.SetDepositRecord(ctx, depositRecord) return nil } @@ -103,7 +103,7 @@ func (k Keeper) DelegateCallback(ctx sdk.Context, packet channeltypes.Packet, ac } k.SetHostZone(ctx, hostZone) - k.RecordsKeeper.RemoveDepositRecord(ctx, cast.ToUint64(recordId)) + k.recordsKeeper.RemoveDepositRecord(ctx, cast.ToUint64(recordId)) k.Logger(ctx).Info(fmt.Sprintf("[DELEGATION] success on %s", chainId)) return nil } diff --git a/x/stakeibc/keeper/icacallbacks_detokenize.go b/x/stakeibc/keeper/icacallbacks_detokenize.go index 12ff8e56..2069b068 100644 --- a/x/stakeibc/keeper/icacallbacks_detokenize.go +++ b/x/stakeibc/keeper/icacallbacks_detokenize.go @@ -53,7 +53,7 @@ func (k Keeper) DetokenizeCallback(ctx sdk.Context, packet channeltypes.Packet, k.Logger(ctx).Error(utils.LogICACallbackStatusWithHostZone(chainId, ICACallbackID_Detokenize, icacallbackstypes.AckResponseStatus_FAILURE, packet)) - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, *deposit, recordstypes.LSMTokenDeposit_DETOKENIZATION_FAILED) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, *deposit, recordstypes.LSMTokenDeposit_DETOKENIZATION_FAILED) return nil } @@ -61,7 +61,7 @@ func (k Keeper) DetokenizeCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_SUCCESS, packet)) // If the ICA succeeded, remove the token deposit - k.RecordsKeeper.RemoveLSMTokenDeposit(ctx, deposit.ChainId, deposit.Denom) + k.recordsKeeper.RemoveLSMTokenDeposit(ctx, deposit.ChainId, deposit.Denom) // Determine the actual number of tokens that were turned to native stake // (this can be slightly different than the amount initiated in the redeem tokens tx diff --git a/x/stakeibc/keeper/icacallbacks_redemption.go b/x/stakeibc/keeper/icacallbacks_redemption.go index 92757d11..abb593ac 100644 --- a/x/stakeibc/keeper/icacallbacks_redemption.go +++ b/x/stakeibc/keeper/icacallbacks_redemption.go @@ -64,7 +64,7 @@ func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_FAILURE, packet)) // Reset unbondings record status - err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { return err } @@ -81,7 +81,7 @@ func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, } // Upon success, update the unbonding record status to CLAIMABLE - err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_CLAIMABLE) + err = k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_CLAIMABLE) if err != nil { return err } diff --git a/x/stakeibc/keeper/icacallbacks_reinvest.go b/x/stakeibc/keeper/icacallbacks_reinvest.go index f1ff939e..842f4bd2 100644 --- a/x/stakeibc/keeper/icacallbacks_reinvest.go +++ b/x/stakeibc/keeper/icacallbacks_reinvest.go @@ -98,7 +98,7 @@ func (k Keeper) ReinvestCallback(ctx sdk.Context, packet channeltypes.Packet, ac Source: recordstypes.DepositRecord_WITHDRAWAL_ICA, DepositEpochNumber: strideEpochTracker.EpochNumber, } - k.RecordsKeeper.AppendDepositRecord(ctx, record) + k.recordsKeeper.AppendDepositRecord(ctx, record) // Encode the fee account address for the query request // The query request consists of the fee account address and denom @@ -132,7 +132,7 @@ func (k Keeper) ReinvestCallback(ctx sdk.Context, packet channeltypes.Packet, ac TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Error submitting ICQ for fee balance, error %s", err.Error())) return err } diff --git a/x/stakeibc/keeper/icacallbacks_undelegate.go b/x/stakeibc/keeper/icacallbacks_undelegate.go index a872b78c..d445d233 100644 --- a/x/stakeibc/keeper/icacallbacks_undelegate.go +++ b/x/stakeibc/keeper/icacallbacks_undelegate.go @@ -67,7 +67,7 @@ func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_FAILURE, packet)) // Reset unbondings record status - if err := k.RecordsKeeper.SetHostZoneUnbondingStatus( + if err := k.recordsKeeper.SetHostZoneUnbondingStatus( ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, @@ -108,7 +108,7 @@ func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, } // Upon success, add host zone unbondings to the exit transfer queue - err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { return err } @@ -164,13 +164,13 @@ func (k Keeper) UpdateHostZoneUnbondings( ) (stTokenBurnAmount sdkmath.Int, err error) { stTokenBurnAmount = sdkmath.ZeroInt() for _, epochNumber := range undelegateCallback.EpochUnbondingRecordIds { - epochUnbondingRecord, found := k.RecordsKeeper.GetEpochUnbondingRecord(ctx, epochNumber) + epochUnbondingRecord, found := k.recordsKeeper.GetEpochUnbondingRecord(ctx, epochNumber) if !found { errMsg := fmt.Sprintf("Unable to find epoch unbonding record for epoch: %d", epochNumber) k.Logger(ctx).Error(errMsg) return sdkmath.ZeroInt(), errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, errMsg) } - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, chainId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, chainId) if !found { errMsg := fmt.Sprintf("Host zone unbonding not found (%s) in epoch unbonding record: %d", chainId, epochNumber) k.Logger(ctx).Error(errMsg) @@ -183,13 +183,13 @@ func (k Keeper) UpdateHostZoneUnbondings( // Update the bonded time hostZoneUnbonding.UnbondingTime = cast.ToUint64(latestCompletionTime.UnixNano()) - updatedEpochUnbondingRecord, success := k.RecordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding) + updatedEpochUnbondingRecord, success := k.recordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding) if !success { k.Logger(ctx).Error(fmt.Sprintf("Failed to set host zone epoch unbonding record: epochNumber %d, chainId %s, hostZoneUnbonding %+v", epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding)) return sdkmath.ZeroInt(), errorsmod.Wrapf(types.ErrEpochNotFound, "couldn't set host zone epoch unbonding record") } - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) k.Logger(ctx).Info(utils.LogICACallbackWithHostZone(chainId, ICACallbackID_Undelegate, "Epoch Unbonding Record: %d - Seting unbonding time to %s", epochNumber, latestCompletionTime.String())) diff --git a/x/stakeibc/keeper/icqcallbacks_delegator_shares.go b/x/stakeibc/keeper/icqcallbacks_delegator_shares.go index 64d80b56..41f6a845 100644 --- a/x/stakeibc/keeper/icqcallbacks_delegator_shares.go +++ b/x/stakeibc/keeper/icqcallbacks_delegator_shares.go @@ -80,7 +80,7 @@ func DelegatorSharesCallback(k Keeper, ctx sdk.Context, args []byte, query icqty } query.CallbackData = callbackDataBz - if err := k.InterchainQueryKeeper.RetryICQRequest(ctx, query); err != nil { + if err := k.interchainQueryKeeper.RetryICQRequest(ctx, query); err != nil { return errorsmod.Wrapf(err, "unable to resubmit delegator shares query") } return nil @@ -248,7 +248,7 @@ func (k Keeper) SlashValidatorOnHostZone(ctx sdk.Context, hostZone types.HostZon "Delegation updated to: %v, Weight updated to: %v", validator.Delegation, validator.Weight)) // Update the redemption rate - depositRecords := k.RecordsKeeper.GetAllDepositRecord(ctx) + depositRecords := k.recordsKeeper.GetAllDepositRecord(ctx) k.UpdateRedemptionRateForHostZone(ctx, hostZone, depositRecords) return nil diff --git a/x/stakeibc/keeper/icqcallbacks_fee_balance.go b/x/stakeibc/keeper/icqcallbacks_fee_balance.go index e30576cf..5a61a7a1 100644 --- a/x/stakeibc/keeper/icqcallbacks_fee_balance.go +++ b/x/stakeibc/keeper/icqcallbacks_fee_balance.go @@ -59,7 +59,7 @@ func FeeBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Q } // get counterparty chain's transfer channel - transferChannel, found := k.IBCKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) + transferChannel, found := k.ibcKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) if !found { return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "transfer channel %s not found", hostZone.TransferChannelId) } @@ -67,7 +67,7 @@ func FeeBalanceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Q // Prepare a MsgTransfer from the fee account to the rewards collector account rewardsCoin := sdk.NewCoin(hostZone.HostDenom, feeBalanceAmount) - rewardsCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + rewardsCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() transferMsg := ibctypes.NewMsgTransfer( transfertypes.PortID, counterpartyChannelId, diff --git a/x/stakeibc/keeper/icqcallbacks_validator_exchange_rate.go b/x/stakeibc/keeper/icqcallbacks_validator_exchange_rate.go index 9972d5e6..f8494176 100644 --- a/x/stakeibc/keeper/icqcallbacks_validator_exchange_rate.go +++ b/x/stakeibc/keeper/icqcallbacks_validator_exchange_rate.go @@ -192,5 +192,5 @@ func (k Keeper) FailLSMLiquidStake(ctx sdk.Context, hostZone types.HostZone, lsm k.Logger(ctx).Error(errorMessage) // Remove the LSMTokenDeposit - k.RecordsKeeper.RemoveLSMTokenDeposit(ctx, lsmLiquidStake.Deposit.ChainId, lsmLiquidStake.Deposit.Denom) + k.recordsKeeper.RemoveLSMTokenDeposit(ctx, lsmLiquidStake.Deposit.ChainId, lsmLiquidStake.Deposit.Denom) } diff --git a/x/stakeibc/keeper/interchainaccounts.go b/x/stakeibc/keeper/interchainaccounts.go index eb19de9c..b1f50ff6 100644 --- a/x/stakeibc/keeper/interchainaccounts.go +++ b/x/stakeibc/keeper/interchainaccounts.go @@ -177,7 +177,7 @@ func (k Keeper) SubmitTxs( protoMsgs = append(protoMsgs, msg) } - channelID, found := k.ICAControllerKeeper.GetActiveChannelID(ctx, connectionId, portID) + channelID, found := k.icaControllerKeeper.GetActiveChannelID(ctx, connectionId, portID) if !found { return 0, errorsmod.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID) } @@ -193,7 +193,7 @@ func (k Keeper) SubmitTxs( } // Submit ICA tx - msgServer := icacontrollerkeeper.NewMsgServerImpl(&k.ICAControllerKeeper) + msgServer := icacontrollerkeeper.NewMsgServerImpl(&k.icaControllerKeeper) relativeTimeoutOffset := timeoutTimestamp - uint64(ctx.BlockTime().UnixNano()) msgSendTx := icacontrollertypes.NewMsgSendTx(owner, connectionId, relativeTimeoutOffset, packetData) res, err := msgServer.SendTx(ctx, msgSendTx) @@ -213,7 +213,7 @@ func (k Keeper) SubmitTxs( CallbackArgs: callbackArgs, } k.Logger(ctx).Info(utils.LogWithHostZone(chainId, "Storing callback data: %+v", callback)) - k.ICACallbacksKeeper.SetCallbackData(ctx, callback) + k.icaCallbacksKeeper.SetCallbackData(ctx, callback) } return sequence, nil @@ -238,7 +238,7 @@ func (k Keeper) SubmitICATxWithoutCallback( relativeTimeoutOffset := timeoutTimestamp - uint64(ctx.BlockTime().UnixNano()) // Submit ICA, no need to store callback data or register callback function - icaMsgServer := icacontrollerkeeper.NewMsgServerImpl(&k.ICAControllerKeeper) + icaMsgServer := icacontrollerkeeper.NewMsgServerImpl(&k.icaControllerKeeper) msgSendTx := icacontrollertypes.NewMsgSendTx(icaAccountOwner, connectionId, relativeTimeoutOffset, packetData) _, err = icaMsgServer.SendTx(ctx, msgSendTx) if err != nil { @@ -261,7 +261,7 @@ func (k Keeper) RegisterTradeRouteICAAccount( if err != nil { return account, err } - connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionId) + connection, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionId) if !found { return account, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, connectionId) } @@ -291,8 +291,8 @@ func (k Keeper) RegisterTradeRouteICAAccount( // Check if an ICA account has already been created // (in the event that this trade route was removed and then added back) // If so, there's no need to register a new ICA - _, channelFound := k.ICAControllerKeeper.GetOpenActiveChannel(ctx, connectionId, portID) - icaAddress, icaFound := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, connectionId, portID) + _, channelFound := k.icaControllerKeeper.GetOpenActiveChannel(ctx, connectionId, portID) + icaAddress, icaFound := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, connectionId, portID) if channelFound && icaFound { account = types.ICAAccount{ ChainId: chainId, @@ -304,7 +304,7 @@ func (k Keeper) RegisterTradeRouteICAAccount( } // Otherwise, if there's no account already, register a new one - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, connectionId, owner, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, connectionId, owner, appVersion); err != nil { return account, err } diff --git a/x/stakeibc/keeper/interchainqueries.go b/x/stakeibc/keeper/interchainqueries.go index 32c4eae9..038d2c99 100644 --- a/x/stakeibc/keeper/interchainqueries.go +++ b/x/stakeibc/keeper/interchainqueries.go @@ -70,7 +70,7 @@ func (k Keeper) SubmitValidatorSharesToTokensRateICQ( TimeoutDuration: timeoutDuration, TimeoutPolicy: timeoutPolicy, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, true); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, true); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Error submitting ICQ for validator sharesToTokens rate, error %s", err.Error())) return err } @@ -137,7 +137,7 @@ func (k Keeper) SubmitDelegationICQ(ctx sdk.Context, hostZone types.HostZone, va TimeoutDuration: time.Hour, TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + 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 } @@ -185,7 +185,7 @@ func (k Keeper) SubmitCalibrationICQ(ctx sdk.Context, hostZone types.HostZone, v TimeoutDuration: time.Hour, TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { return err } @@ -233,7 +233,7 @@ func (k Keeper) SubmitWithdrawalHostBalanceICQ(ctx sdk.Context, hostZone types.H TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Error querying for withdrawal balance, error: %s", err.Error())) return err } diff --git a/x/stakeibc/keeper/keeper.go b/x/stakeibc/keeper/keeper.go index a0ca83aa..22175ec8 100644 --- a/x/stakeibc/keeper/keeper.go +++ b/x/stakeibc/keeper/keeper.go @@ -25,20 +25,20 @@ import ( type ( Keeper struct { - // *cosmosibckeeper.Keeper cdc codec.Codec storeKey storetypes.StoreKey memKey storetypes.StoreKey authority string - ICAControllerKeeper icacontrollerkeeper.Keeper - IBCKeeper ibckeeper.Keeper + icaControllerKeeper icacontrollerkeeper.Keeper + ibcKeeper ibckeeper.Keeper bankKeeper bankkeeper.Keeper - AccountKeeper types.AccountKeeper - InterchainQueryKeeper icqkeeper.Keeper - RecordsKeeper recordsmodulekeeper.Keeper - ICACallbacksKeeper icacallbackskeeper.Keeper + accountKeeper types.AccountKeeper + interchainQueryKeeper icqkeeper.Keeper + recordsKeeper recordsmodulekeeper.Keeper + icaCallbacksKeeper icacallbackskeeper.Keeper hooks types.StakeIBCHooks - RatelimitKeeper types.RatelimitKeeper + rateLimitKeeper types.RatelimitKeeper + opChildKeeper types.OPChildKeeper params collections.Item[types.Params] } ) @@ -51,12 +51,13 @@ func NewKeeper( authority string, accountKeeper types.AccountKeeper, bankKeeper bankkeeper.Keeper, - icacontrollerkeeper icacontrollerkeeper.Keeper, + icaControllerKeeper icacontrollerkeeper.Keeper, ibcKeeper ibckeeper.Keeper, interchainQueryKeeper icqkeeper.Keeper, RecordsKeeper recordsmodulekeeper.Keeper, - ICACallbacksKeeper icacallbackskeeper.Keeper, - RatelimitKeeper types.RatelimitKeeper, + icaCallbacksKeeper icacallbackskeeper.Keeper, + rateLimitKeeper types.RatelimitKeeper, + opChildKeeper types.OPChildKeeper, ) Keeper { sb := collections.NewSchemaBuilder(storeService) return Keeper{ @@ -64,14 +65,15 @@ func NewKeeper( storeKey: storeKey, memKey: memKey, authority: authority, - AccountKeeper: accountKeeper, + accountKeeper: accountKeeper, bankKeeper: bankKeeper, - ICAControllerKeeper: icacontrollerkeeper, - IBCKeeper: ibcKeeper, - InterchainQueryKeeper: interchainQueryKeeper, - RecordsKeeper: RecordsKeeper, - ICACallbacksKeeper: ICACallbacksKeeper, - RatelimitKeeper: RatelimitKeeper, + icaControllerKeeper: icaControllerKeeper, + ibcKeeper: ibcKeeper, + interchainQueryKeeper: interchainQueryKeeper, + recordsKeeper: RecordsKeeper, + icaCallbacksKeeper: icaCallbacksKeeper, + rateLimitKeeper: rateLimitKeeper, + opChildKeeper: opChildKeeper, params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), } } @@ -96,6 +98,26 @@ func (k Keeper) GetAuthority() string { return k.authority } +// ValidateAdminAddress makes sure that the given address is the one of an account that can perform admin operations. +func (k Keeper) ValidateAdminAddress(ctx sdk.Context, address string) error { + // The authority can always perform admin operations. + if k.GetAuthority() == address { + return nil + } + + // The OpChild admin can always perform admin operations + opChildParams, err := k.opChildKeeper.GetParams(ctx) + if err != nil { + return err + } + + if opChildParams.Admin == address { + return nil + } + + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "address (%s) is not an admin", address) +} + func (k Keeper) GetICATimeoutNanos(ctx sdk.Context, epochType string) (uint64, error) { epochTracker, found := k.GetEpochTracker(ctx, epochType) if !found { diff --git a/x/stakeibc/keeper/lsm.go b/x/stakeibc/keeper/lsm.go index 7efd35af..f6c4e038 100644 --- a/x/stakeibc/keeper/lsm.go +++ b/x/stakeibc/keeper/lsm.go @@ -117,7 +117,7 @@ func (k Keeper) GetLSMTokenDenomTrace(ctx sdk.Context, denom string) (transferty } // Lookup the trace from the hash - denomTrace, found := k.RecordsKeeper.TransferKeeper.GetDenomTrace(ctx, hash) + denomTrace, found := k.recordsKeeper.TransferKeeper.GetDenomTrace(ctx, hash) if !found { return transfertypes.DenomTrace{}, errorsmod.Wrapf(types.ErrInvalidLSMToken, "denom trace not found for %s", denom) } @@ -255,7 +255,7 @@ func (k Keeper) StartLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake } // Check if we already have tokens with this denom in records - _, found := k.RecordsKeeper.GetLSMTokenDeposit(ctx, hostZone.ChainId, lsmLiquidStake.Deposit.Denom) + _, found := k.recordsKeeper.GetLSMTokenDeposit(ctx, hostZone.ChainId, lsmLiquidStake.Deposit.Denom) if found { return types.LSMLiquidStake{}, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "there is already a previous record with this denom being processed: %s", lsmLiquidStake.Deposit.Denom) @@ -273,7 +273,7 @@ func (k Keeper) StartLSMLiquidStake(ctx sdk.Context, msg types.MsgLSMLiquidStake // Add the stToken to this deposit record lsmLiquidStake.Deposit.StToken = stCoin - k.RecordsKeeper.SetLSMTokenDeposit(ctx, *lsmLiquidStake.Deposit) + k.recordsKeeper.SetLSMTokenDeposit(ctx, *lsmLiquidStake.Deposit) return lsmLiquidStake, nil } @@ -353,7 +353,7 @@ func (k Keeper) FinishLSMLiquidStake(ctx sdk.Context, lsmLiquidStake types.LSMLi } // Update the deposit status - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, lsmTokenDeposit, recordstypes.LSMTokenDeposit_TRANSFER_QUEUE) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, lsmTokenDeposit, recordstypes.LSMTokenDeposit_TRANSFER_QUEUE) // Update the slash query progress on the validator if err := k.IncrementValidatorSlashQueryProgress( @@ -382,7 +382,7 @@ func (k Keeper) TransferAllLSMDeposits(ctx sdk.Context) { } // Submit an IBC transfer for all queued deposits - queuedDeposits := k.RecordsKeeper.GetLSMDepositsForHostZoneWithStatus( + queuedDeposits := k.recordsKeeper.GetLSMDepositsForHostZoneWithStatus( ctx, hostZone.ChainId, recordstypes.LSMTokenDeposit_TRANSFER_QUEUE, @@ -391,7 +391,7 @@ func (k Keeper) TransferAllLSMDeposits(ctx sdk.Context) { // If the IBC transfer fails to get off the ground, flag the deposit as FAILED // This is highly unlikely and would indicate a larger problem - if err := k.RecordsKeeper.IBCTransferLSMToken( + if err := k.recordsKeeper.IBCTransferLSMToken( ctx, deposit, hostZone.TransferChannelId, @@ -400,13 +400,13 @@ func (k Keeper) TransferAllLSMDeposits(ctx sdk.Context) { ); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Unable to submit IBC Transfer of LSMToken for %v%s on %s: %s", deposit.Amount, deposit.Denom, hostZone.ChainId, err.Error())) - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_TRANSFER_FAILED) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_TRANSFER_FAILED) continue } k.Logger(ctx).Info(fmt.Sprintf("Submitted IBC Transfer for LSM deposit %v%s on %s", deposit.Amount, deposit.Denom, hostZone.ChainId)) - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_TRANSFER_IN_PROGRESS) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_TRANSFER_IN_PROGRESS) } } } @@ -456,7 +456,7 @@ func (k Keeper) DetokenizeLSMDeposit(ctx sdk.Context, hostZone types.HostZone, d } // Mark the deposit as IN_PROGRESS - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_DETOKENIZATION_IN_PROGRESS) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, deposit, recordstypes.LSMTokenDeposit_DETOKENIZATION_IN_PROGRESS) // Update the validator to say that it has a delegation change in progress if err := k.IncrementValidatorDelegationChangesInProgress(&hostZone, deposit.ValidatorAddress); err != nil { @@ -481,14 +481,14 @@ func (k Keeper) DetokenizeAllLSMDeposits(ctx sdk.Context) { } // If the delegation channel is not open, skip this host zone - _, isOpen := k.ICAControllerKeeper.GetOpenActiveChannel(ctx, hostZone.ConnectionId, delegationICAPortID) + _, isOpen := k.icaControllerKeeper.GetOpenActiveChannel(ctx, hostZone.ConnectionId, delegationICAPortID) if !isOpen { k.Logger(ctx).Error(fmt.Sprintf("Skipping detokenization ICAs for %s - Delegation ICA channel is closed", hostZone.ChainId)) continue } // If the delegation channel is open, submit the detokenize ICA - queuedDeposits := k.RecordsKeeper.GetLSMDepositsForHostZoneWithStatus( + queuedDeposits := k.recordsKeeper.GetLSMDepositsForHostZoneWithStatus( ctx, hostZone.ChainId, recordstypes.LSMTokenDeposit_DETOKENIZATION_QUEUE, diff --git a/x/stakeibc/keeper/msg_server.go b/x/stakeibc/keeper/msg_server.go index 3ace4c73..1bf2b2d6 100644 --- a/x/stakeibc/keeper/msg_server.go +++ b/x/stakeibc/keeper/msg_server.go @@ -47,8 +47,13 @@ var _ types.MsgServer = msgServer{} func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegisterHostZone) (*types.MsgRegisterHostZoneResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + // Get ConnectionEnd (for counterparty connection) - connectionEnd, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, msg.ConnectionId) + connectionEnd, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, msg.ConnectionId) if !found { errMsg := fmt.Sprintf("invalid connection id, %s not found", msg.ConnectionId) k.Logger(ctx).Error(errMsg) @@ -99,17 +104,17 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // create and save the zones's module account depositAddress := types.NewHostZoneDepositAddress(chainId) - if err := utils.CreateModuleAccount(ctx, k.AccountKeeper, depositAddress); err != nil { + if err := utils.CreateModuleAccount(ctx, k.accountKeeper, depositAddress); err != nil { return nil, errorsmod.Wrapf(err, "unable to create deposit account for host zone %s", chainId) } // Create the host zone's community pool holding accounts communityPoolStakeAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolStakeHoldingAddressKey) communityPoolRedeemAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolRedeemHoldingAddressKey) - if err := utils.CreateModuleAccount(ctx, k.AccountKeeper, communityPoolStakeAddress); err != nil { + if err := utils.CreateModuleAccount(ctx, k.accountKeeper, communityPoolStakeAddress); err != nil { return nil, errorsmod.Wrapf(err, "unable to create community pool stake account for host zone %s", chainId) } - if err := utils.CreateModuleAccount(ctx, k.AccountKeeper, communityPoolRedeemAddress); err != nil { + if err := utils.CreateModuleAccount(ctx, k.accountKeeper, communityPoolRedeemAddress); err != nil { return nil, errorsmod.Wrapf(err, "unable to create community pool redeem account for host zone %s", chainId) } @@ -173,7 +178,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // generate delegate account // NOTE: in the future, if we implement proxy governance, we'll need many more delegate accounts delegateAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_DELEGATION) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, delegateAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, delegateAccount, appVersion); err != nil { errMsg := fmt.Sprintf("unable to register delegation account, err: %s", err.Error()) k.Logger(ctx).Error(errMsg) return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, errMsg) @@ -181,7 +186,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // generate fee account feeAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_FEE) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, feeAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, feeAccount, appVersion); err != nil { errMsg := fmt.Sprintf("unable to register fee account, err: %s", err.Error()) k.Logger(ctx).Error(errMsg) return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, errMsg) @@ -189,7 +194,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // generate withdrawal account withdrawalAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_WITHDRAWAL) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, withdrawalAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, withdrawalAccount, appVersion); err != nil { errMsg := fmt.Sprintf("unable to register withdrawal account, err: %s", err.Error()) k.Logger(ctx).Error(errMsg) return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, errMsg) @@ -197,7 +202,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // generate redemption account redemptionAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_REDEMPTION) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, redemptionAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, redemptionAccount, appVersion); err != nil { errMsg := fmt.Sprintf("unable to register redemption account, err: %s", err.Error()) k.Logger(ctx).Error(errMsg) return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, errMsg) @@ -205,13 +210,13 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste // create community pool deposit account communityPoolDepositAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_COMMUNITY_POOL_DEPOSIT) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, communityPoolDepositAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, communityPoolDepositAccount, appVersion); err != nil { return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, "failed to register community pool deposit ICA") } // create community pool return account communityPoolReturnAccount := types.FormatHostZoneICAOwner(chainId, types.ICAAccountType_COMMUNITY_POOL_RETURN) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, communityPoolReturnAccount, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, zone.ConnectionId, communityPoolReturnAccount, appVersion); err != nil { return nil, errorsmod.Wrapf(types.ErrFailedToRegisterHostZone, "failed to register community pool return ICA") } @@ -221,7 +226,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste if !found { return nil, errorsmod.Wrapf(types.ErrEpochNotFound, "epoch tracker (%s) not found", epochtypes.DAY_EPOCH) } - epochUnbondingRecord, found := k.RecordsKeeper.GetEpochUnbondingRecord(ctx, dayEpochTracker.EpochNumber) + epochUnbondingRecord, found := k.recordsKeeper.GetEpochUnbondingRecord(ctx, dayEpochTracker.EpochNumber) if !found { errMsg := "unable to find latest epoch unbonding record" k.Logger(ctx).Error(errMsg) @@ -234,14 +239,14 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste HostZoneId: zone.ChainId, Status: recordstypes.HostZoneUnbonding_UNBONDING_QUEUE, } - updatedEpochUnbondingRecord, success := k.RecordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding) + updatedEpochUnbondingRecord, success := k.recordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding) if !success { errMsg := fmt.Sprintf("Failed to set host zone epoch unbonding record: epochNumber %d, chainId %s, hostZoneUnbonding %v", epochUnbondingRecord.EpochNumber, chainId, hostZoneUnbonding) k.Logger(ctx).Error(errMsg) return nil, errorsmod.Wrapf(types.ErrEpochNotFound, errMsg) } - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) // create an empty deposit record for the host zone strideEpochTracker, found := k.GetEpochTracker(ctx, epochtypes.STRIDE_EPOCH) @@ -256,7 +261,7 @@ func (k msgServer) RegisterHostZone(goCtx context.Context, msg *types.MsgRegiste Status: recordstypes.DepositRecord_TRANSFER_QUEUE, DepositEpochNumber: strideEpochTracker.EpochNumber, } - k.RecordsKeeper.AppendDepositRecord(ctx, depositRecord) + k.recordsKeeper.AppendDepositRecord(ctx, depositRecord) // register stToken to consumer reward denom whitelist so that // stToken rewards can be distributed to provider validators @@ -309,6 +314,11 @@ func (ms msgServer) UpdateHostZoneParams(goCtx context.Context, msg *types.MsgUp func (k msgServer) AddValidators(goCtx context.Context, msg *types.MsgAddValidators) (*types.MsgAddValidatorsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + for _, validator := range msg.Validators { if err := k.AddValidatorToHostZone(ctx, msg.HostZone, *validator, false); err != nil { return nil, err @@ -331,6 +341,11 @@ func (k msgServer) AddValidators(goCtx context.Context, msg *types.MsgAddValidat func (k msgServer) DeleteValidator(goCtx context.Context, msg *types.MsgDeleteValidator) (*types.MsgDeleteValidatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + err := k.RemoveValidatorFromHostZone(ctx, msg.HostZone, msg.ValAddr) if err != nil { errMsg := fmt.Sprintf("Validator (%s) not removed from host zone (%s) | err: %s", msg.ValAddr, msg.HostZone, err.Error()) @@ -344,6 +359,11 @@ func (k msgServer) DeleteValidator(goCtx context.Context, msg *types.MsgDeleteVa func (k msgServer) ChangeValidatorWeight(goCtx context.Context, msg *types.MsgChangeValidatorWeights) (*types.MsgChangeValidatorWeightsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + hostZone, found := k.GetHostZone(ctx, msg.HostZone) if !found { return nil, types.ErrInvalidHostZone @@ -377,6 +397,12 @@ func (k msgServer) ChangeValidatorWeight(goCtx context.Context, msg *types.MsgCh func (k msgServer) RebalanceValidators(goCtx context.Context, msg *types.MsgRebalanceValidators) (*types.MsgRebalanceValidatorsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + k.Logger(ctx).Info(fmt.Sprintf("RebalanceValidators executing %v", msg)) if err := k.RebalanceDelegationsForHostZone(ctx, msg.HostZone); err != nil { @@ -388,6 +414,11 @@ func (k msgServer) RebalanceValidators(goCtx context.Context, msg *types.MsgReba func (k msgServer) ClearBalance(goCtx context.Context, msg *types.MsgClearBalance) (*types.MsgClearBalanceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + zone, found := k.GetHostZone(ctx, msg.ChainId) if !found { return nil, errorsmod.Wrapf(types.ErrInvalidHostZone, "chainId: %s", msg.ChainId) @@ -478,7 +509,7 @@ func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) if !found { return nil, errorsmod.Wrapf(sdkerrors.ErrNotFound, "no epoch number for epoch (%s)", epochtypes.STRIDE_EPOCH) } - depositRecord, found := k.RecordsKeeper.GetTransferDepositRecordByEpochAndChain(ctx, strideEpochTracker.EpochNumber, hostZone.ChainId) + depositRecord, found := k.recordsKeeper.GetTransferDepositRecordByEpochAndChain(ctx, strideEpochTracker.EpochNumber, hostZone.ChainId) if !found { return nil, errorsmod.Wrapf(sdkerrors.ErrNotFound, "no deposit record for epoch (%d)", strideEpochTracker.EpochNumber) } @@ -520,7 +551,7 @@ func (k msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) // Update the liquid staked amount on the deposit record depositRecord.Amount = depositRecord.Amount.Add(msg.Amount) - k.RecordsKeeper.SetDepositRecord(ctx, *depositRecord) + k.recordsKeeper.SetDepositRecord(ctx, *depositRecord) // Emit liquid stake event EmitSuccessfulLiquidStakeEvent(ctx, msg, *hostZone, stAmount) @@ -591,7 +622,7 @@ func (k msgServer) RedeemStake(goCtx context.Context, msg *types.MsgRedeemStake) // ----------------- UNBONDING RECORD KEEPING ----------------- // Fetch the record redemptionId := recordstypes.UserRedemptionRecordKeyFormatter(hostZone.ChainId, epochTracker.EpochNumber, msg.Receiver) - userRedemptionRecord, userHasRedeemedThisEpoch := k.RecordsKeeper.GetUserRedemptionRecord(ctx, redemptionId) + userRedemptionRecord, userHasRedeemedThisEpoch := k.recordsKeeper.GetUserRedemptionRecord(ctx, redemptionId) if userHasRedeemedThisEpoch { k.Logger(ctx).Info(fmt.Sprintf("UserRedemptionRecord found for %s", redemptionId)) // Add the unbonded amount to the UserRedemptionRecord @@ -616,13 +647,13 @@ func (k msgServer) RedeemStake(goCtx context.Context, msg *types.MsgRedeemStake) } // then add undelegation amount to epoch unbonding records - epochUnbondingRecord, found := k.RecordsKeeper.GetEpochUnbondingRecord(ctx, epochTracker.EpochNumber) + epochUnbondingRecord, found := k.recordsKeeper.GetEpochUnbondingRecord(ctx, epochTracker.EpochNumber) if !found { k.Logger(ctx).Error("latest epoch unbonding record not found") return nil, errorsmod.Wrapf(recordstypes.ErrEpochUnbondingRecordNotFound, "latest epoch unbonding record not found") } // get relevant host zone on this epoch unbonding record - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) if !found { return nil, errorsmod.Wrapf(types.ErrInvalidHostZone, "host zone not found in unbondings: %s", hostZone.ChainId) } @@ -648,7 +679,7 @@ func (k msgServer) RedeemStake(goCtx context.Context, msg *types.MsgRedeemStake) hostZoneUnbonding.StTokenAmount = hostZoneUnbonding.StTokenAmount.Add(msg.Amount) // Actually set the records, we wait until now to prevent any errors - k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) + k.recordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) // Set the UserUnbondingRecords on the proper HostZoneUnbondingRecord hostZoneUnbondings := epochUnbondingRecord.GetHostZoneUnbondings() @@ -656,12 +687,12 @@ func (k msgServer) RedeemStake(goCtx context.Context, msg *types.MsgRedeemStake) hostZoneUnbondings = []*recordstypes.HostZoneUnbonding{} epochUnbondingRecord.HostZoneUnbondings = hostZoneUnbondings } - updatedEpochUnbondingRecord, success := k.RecordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId, hostZoneUnbonding) + updatedEpochUnbondingRecord, success := k.recordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId, hostZoneUnbonding) if !success { k.Logger(ctx).Error(fmt.Sprintf("Failed to set host zone epoch unbonding record: epochNumber %d, chainId %s, hostZoneUnbonding %v", epochUnbondingRecord.EpochNumber, hostZone.ChainId, hostZoneUnbonding)) return nil, errorsmod.Wrapf(types.ErrEpochNotFound, "couldn't set host zone epoch unbonding record") } - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, *updatedEpochUnbondingRecord) k.Logger(ctx).Info(fmt.Sprintf("executed redeem stake: %s", msg.String())) EmitSuccessfulRedeemStakeEvent(ctx, msg, hostZone, nativeAmount, msg.Amount) @@ -942,7 +973,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms ctx := sdk.UnwrapSDKContext(goCtx) // Get ConnectionEnd (for counterparty connection) - connectionEnd, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, msg.ConnectionId) + connectionEnd, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, msg.ConnectionId) if !found { return nil, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection %s not found", msg.ConnectionId) } @@ -953,7 +984,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms if err != nil { return nil, err } - _, exists := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, msg.ConnectionId, portID) + _, exists := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, msg.ConnectionId, portID) if !exists { return nil, errorsmod.Wrapf(types.ErrInvalidInterchainAccountAddress, "ICA controller account address not found: %s", msg.AccountOwner) @@ -967,7 +998,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms TxType: icatypes.TxTypeSDKMultiMsg, })) - if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, msg.ConnectionId, msg.AccountOwner, appVersion); err != nil { + if err := k.icaControllerKeeper.RegisterInterchainAccount(ctx, msg.ConnectionId, msg.AccountOwner, appVersion); err != nil { return nil, errorsmod.Wrapf(err, "unable to register account for owner %s", msg.AccountOwner) } @@ -986,23 +1017,23 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms k.SetHostZone(ctx, hostZone) // revert DELEGATION_IN_PROGRESS records for the closed ICA channel (so that they can be staked) - depositRecords := k.RecordsKeeper.GetAllDepositRecord(ctx) + depositRecords := k.recordsKeeper.GetAllDepositRecord(ctx) for _, depositRecord := range depositRecords { // only revert records for the select host zone if depositRecord.HostZoneId == hostZone.ChainId && depositRecord.Status == recordtypes.DepositRecord_DELEGATION_IN_PROGRESS { depositRecord.Status = recordtypes.DepositRecord_DELEGATION_QUEUE k.Logger(ctx).Info(fmt.Sprintf("Setting DepositRecord %d to status DepositRecord_DELEGATION_IN_PROGRESS", depositRecord.Id)) - k.RecordsKeeper.SetDepositRecord(ctx, depositRecord) + k.recordsKeeper.SetDepositRecord(ctx, depositRecord) } } // revert epoch unbonding records for the closed ICA channel - epochUnbondingRecords := k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) + epochUnbondingRecords := k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) epochNumberForPendingUnbondingRecords := []uint64{} epochNumberForPendingTransferRecords := []uint64{} for _, epochUnbondingRecord := range epochUnbondingRecords { // only revert records for the select host zone - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) if !found { k.Logger(ctx).Info(fmt.Sprintf("No HostZoneUnbonding found for chainId: %s, epoch: %d", hostZone.ChainId, epochUnbondingRecord.EpochNumber)) continue @@ -1023,7 +1054,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms } } // Revert UNBONDING_IN_PROGRESS records to UNBONDING_QUEUE - err := k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingUnbondingRecords, recordtypes.HostZoneUnbonding_UNBONDING_QUEUE) + err := k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingUnbondingRecords, recordtypes.HostZoneUnbonding_UNBONDING_QUEUE) if err != nil { errMsg := fmt.Sprintf("unable to update host zone unbonding record status to %s for chainId: %s and epochUnbondingRecordIds: %v, err: %s", recordtypes.HostZoneUnbonding_UNBONDING_QUEUE.String(), hostZone.ChainId, epochNumberForPendingUnbondingRecords, err) @@ -1032,7 +1063,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms } // Revert EXIT_TRANSFER_IN_PROGRESS records to EXIT_TRANSFER_QUEUE - err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingTransferRecords, recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingTransferRecords, recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { errMsg := fmt.Sprintf("unable to update host zone unbonding record status to %s for chainId: %s and epochUnbondingRecordIds: %v, err: %s", recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE.String(), hostZone.ChainId, epochNumberForPendingTransferRecords, err) @@ -1041,10 +1072,10 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms } // Revert all pending LSM Detokenizations from status DETOKENIZATION_IN_PROGRESS to status DETOKENIZATION_QUEUE - pendingDeposits := k.RecordsKeeper.GetLSMDepositsForHostZoneWithStatus(ctx, hostZone.ChainId, recordtypes.LSMTokenDeposit_DETOKENIZATION_IN_PROGRESS) + pendingDeposits := k.recordsKeeper.GetLSMDepositsForHostZoneWithStatus(ctx, hostZone.ChainId, recordtypes.LSMTokenDeposit_DETOKENIZATION_IN_PROGRESS) for _, lsmDeposit := range pendingDeposits { k.Logger(ctx).Info(fmt.Sprintf("Setting LSMTokenDeposit %s to status DETOKENIZATION_QUEUE", lsmDeposit.Denom)) - k.RecordsKeeper.UpdateLSMTokenDepositStatus(ctx, lsmDeposit, recordtypes.LSMTokenDeposit_DETOKENIZATION_QUEUE) + k.recordsKeeper.UpdateLSMTokenDepositStatus(ctx, lsmDeposit, recordtypes.LSMTokenDeposit_DETOKENIZATION_QUEUE) } } @@ -1085,6 +1116,11 @@ func (k msgServer) CalibrateDelegation(goCtx context.Context, msg *types.MsgCali func (k msgServer) UpdateInnerRedemptionRateBounds(goCtx context.Context, msg *types.MsgUpdateInnerRedemptionRateBounds) (*types.MsgUpdateInnerRedemptionRateBoundsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + // Note: we're intentionally not checking the zone is halted zone, found := k.GetHostZone(ctx, msg.ChainId) if !found { @@ -1123,6 +1159,11 @@ func (k msgServer) UpdateInnerRedemptionRateBounds(goCtx context.Context, msg *t func (k msgServer) ResumeHostZone(goCtx context.Context, msg *types.MsgResumeHostZone) (*types.MsgResumeHostZoneResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + // Get Host Zone hostZone, found := k.GetHostZone(ctx, msg.ChainId) if !found { @@ -1140,7 +1181,7 @@ func (k msgServer) ResumeHostZone(goCtx context.Context, msg *types.MsgResumeHos // remove from blacklist stDenom := types.StAssetDenomFromHostZoneDenom(hostZone.HostDenom) - k.RatelimitKeeper.RemoveDenomFromBlacklist(ctx, stDenom) + k.rateLimitKeeper.RemoveDenomFromBlacklist(ctx, stDenom) // Resume zone hostZone.Halted = false @@ -1156,6 +1197,11 @@ func (k msgServer) SetCommunityPoolRebate( ) (*types.MsgSetCommunityPoolRebateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + hostZone, found := k.GetHostZone(ctx, msg.ChainId) if !found { return nil, types.ErrHostZoneNotFound.Wrapf("host zone %s not found", msg.ChainId) @@ -1193,6 +1239,11 @@ func (k msgServer) ToggleTradeController( ) (*types.MsgToggleTradeControllerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the admin address + if err := k.ValidateAdminAddress(ctx, msg.Creator); err != nil { + return nil, err + } + // Fetch the trade ICA which will be the granter tradeRoute, found := k.GetTradeRouteFromTradeAccountChainId(ctx, msg.ChainId) if !found { diff --git a/x/stakeibc/keeper/records.go b/x/stakeibc/keeper/records.go index 03218329..a489187e 100644 --- a/x/stakeibc/keeper/records.go +++ b/x/stakeibc/keeper/records.go @@ -25,7 +25,7 @@ func (k Keeper) CreateDepositRecordsForEpoch(ctx sdk.Context, epochNumber uint64 Status: recordstypes.DepositRecord_TRANSFER_QUEUE, DepositEpochNumber: epochNumber, } - k.RecordsKeeper.AppendDepositRecord(ctx, depositRecord) + k.recordsKeeper.AppendDepositRecord(ctx, depositRecord) } } @@ -52,7 +52,7 @@ func (k Keeper) CreateEpochUnbondingRecord(ctx sdk.Context, epochNumber uint64) EpochNumber: cast.ToUint64(epochNumber), HostZoneUnbondings: hostZoneUnbondings, } - k.RecordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord) + k.recordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord) return true } @@ -60,7 +60,7 @@ func (k Keeper) CreateEpochUnbondingRecord(ctx sdk.Context, epochNumber uint64) func (k Keeper) CleanupEpochUnbondingRecords(ctx sdk.Context, epochNumber uint64) bool { k.Logger(ctx).Info("Cleaning Claimed Epoch Unbonding Records...") - for _, epochUnbondingRecord := range k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) { + for _, epochUnbondingRecord := range k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) { shouldDeleteEpochUnbondingRecord := true hostZoneUnbondings := epochUnbondingRecord.HostZoneUnbondings @@ -74,7 +74,7 @@ func (k Keeper) CleanupEpochUnbondingRecords(ctx sdk.Context, epochNumber uint64 } if shouldDeleteEpochUnbondingRecord { k.Logger(ctx).Info(fmt.Sprintf(" EpochUnbondingRecord %d - All unbondings claimed, removing record", epochUnbondingRecord.EpochNumber)) - k.RecordsKeeper.RemoveEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber) + k.recordsKeeper.RemoveEpochUnbondingRecord(ctx, epochUnbondingRecord.EpochNumber) } else { k.Logger(ctx).Info(fmt.Sprintf(" EpochUnbondingRecord %d - Has unclaimed unbondings", epochUnbondingRecord.EpochNumber)) } diff --git a/x/stakeibc/keeper/redemption_rate.go b/x/stakeibc/keeper/redemption_rate.go index 96423b22..c21d3092 100644 --- a/x/stakeibc/keeper/redemption_rate.go +++ b/x/stakeibc/keeper/redemption_rate.go @@ -124,7 +124,7 @@ func (k Keeper) GetUndelegatedBalance(chainId string, depositRecords []recordsty // must be used to denominate it's value in native tokens func (k Keeper) GetTotalTokenizedDelegations(ctx sdk.Context, hostZone types.HostZone) sdkmath.LegacyDec { total := sdkmath.ZeroInt() - for _, deposit := range k.RecordsKeeper.GetLSMDepositsForHostZone(ctx, hostZone.ChainId) { + for _, deposit := range k.recordsKeeper.GetLSMDepositsForHostZone(ctx, hostZone.ChainId) { if deposit.Status != recordstypes.LSMTokenDeposit_DEPOSIT_PENDING { validator, _, found := GetValidatorFromAddress(hostZone.Validators, deposit.ValidatorAddress) if !found { diff --git a/x/stakeibc/keeper/redemption_sweep.go b/x/stakeibc/keeper/redemption_sweep.go index 4b571fe5..8a3d25f9 100644 --- a/x/stakeibc/keeper/redemption_sweep.go +++ b/x/stakeibc/keeper/redemption_sweep.go @@ -23,7 +23,7 @@ func (k Keeper) SweepAllUnbondedTokensForHostZone(ctx sdk.Context, hostZone type for _, epochUnbondingRecord := range epochUnbondingRecords { // Get all the unbondings associated with the epoch + host zone pair - hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) + hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbondingRecord.EpochNumber, hostZone.ChainId) if !found { continue } @@ -102,7 +102,7 @@ func (k Keeper) SweepAllUnbondedTokensForHostZone(ctx sdk.Context, hostZone type k.Logger(ctx).Info(utils.LogWithHostZone(hostZone.ChainId, "ICA MsgSend Successfully Sent")) // Update the host zone unbonding records to status IN_PROGRESS - err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_IN_PROGRESS) + err = k.recordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_IN_PROGRESS) if err != nil { k.Logger(ctx).Error(err.Error()) return false, sdkmath.ZeroInt() @@ -128,7 +128,7 @@ func (k Keeper) SweepAllUnbondedTokens(ctx sdk.Context) (success bool, successfu failedSweeps = []string{} hostZones := k.GetAllActiveHostZone(ctx) - epochUnbondingRecords := k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) + epochUnbondingRecords := k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) for _, hostZone := range hostZones { hostZoneSuccess, sweepAmount := k.SweepAllUnbondedTokensForHostZone(ctx, hostZone, epochUnbondingRecords) if hostZoneSuccess { diff --git a/x/stakeibc/keeper/reward_allocation.go b/x/stakeibc/keeper/reward_allocation.go index 9fa3123f..894ac573 100644 --- a/x/stakeibc/keeper/reward_allocation.go +++ b/x/stakeibc/keeper/reward_allocation.go @@ -14,7 +14,7 @@ import ( // Liquid Stake Reward Collector Balance func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types.MsgServer) bool { k.Logger(ctx).Info("Liquid Staking reward collector balance") - rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() rewardedTokens := k.bankKeeper.GetAllBalances(ctx, rewardCollectorAddress) if rewardedTokens.Equal(sdk.Coins{}) { k.Logger(ctx).Info("No reward to allocate from RewardCollector") @@ -50,7 +50,7 @@ func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types. // Sweep stTokens from Reward Collector to Fee Collector func (k Keeper) SweepStTokensFromRewardCollToFeeColl(ctx sdk.Context) error { // Send all stTokens to fee collector to distribute to delegator later - rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() rewardCollCoins := k.bankKeeper.GetAllBalances(ctx, rewardCollectorAddress) k.Logger(ctx).Info(fmt.Sprintf("Reward collector has %s", rewardCollCoins.String())) diff --git a/x/stakeibc/keeper/reward_converter.go b/x/stakeibc/keeper/reward_converter.go index 0167d0bc..ebea24aa 100644 --- a/x/stakeibc/keeper/reward_converter.go +++ b/x/stakeibc/keeper/reward_converter.go @@ -469,7 +469,7 @@ func (k Keeper) WithdrawalRewardBalanceQuery(ctx sdk.Context, route types.TradeR TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { return err } @@ -520,7 +520,7 @@ func (k Keeper) TradeRewardBalanceQuery(ctx sdk.Context, route types.TradeRoute) TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { return err } @@ -571,7 +571,7 @@ func (k Keeper) TradeConvertedBalanceQuery(ctx sdk.Context, route types.TradeRou TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { return err } @@ -622,7 +622,7 @@ func (k Keeper) PoolPriceQuery(ctx sdk.Context, route types.TradeRoute) error { TimeoutDuration: timeoutDuration, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { + if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Error querying pool spot price, error: %s", err.Error())) return err } diff --git a/x/stakeibc/keeper/transfer.go b/x/stakeibc/keeper/transfer.go index 9bc35d67..0dd8c066 100644 --- a/x/stakeibc/keeper/transfer.go +++ b/x/stakeibc/keeper/transfer.go @@ -39,7 +39,7 @@ func (k Keeper) TransferExistingDepositsToHostZones(ctx sdk.Context, epochNumber // if a TRANSFER_QUEUE record has 0 balance and was created in the previous epoch, it's safe to remove since it will never be updated or used if depositRecord.Amount.LTE(sdkmath.ZeroInt()) && depositRecord.DepositEpochNumber < epochNumber { k.Logger(ctx).Info(utils.LogWithHostZone(depositRecord.HostZoneId, "Empty deposit record - Removing.")) - k.RecordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id) + k.recordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id) continue } @@ -81,7 +81,7 @@ func (k Keeper) TransferExistingDepositsToHostZones(ctx sdk.Context, epochNumber k.Logger(ctx).Info(utils.LogWithHostZone(depositRecord.HostZoneId, "Transfer Msg: %+v", msg)) // transfer the deposit record and update its status to TRANSFER_IN_PROGRESS - err := k.RecordsKeeper.IBCTransferNativeTokens(ctx, msg, depositRecord) + err := k.recordsKeeper.IBCTransferNativeTokens(ctx, msg, depositRecord) if err != nil { k.Logger(ctx).Error(fmt.Sprintf("[TransferExistingDepositsToHostZones] Failed to initiate IBC transfer to host zone, HostZone: %v, Channel: %v, Amount: %v, ModuleAddress: %v, DelegateAddress: %v, Timeout: %v", hostZone.ChainId, hostZone.TransferChannelId, transferCoin, hostZone.DepositAddress, hostZone.DelegationIcaAddress, timeoutTimestamp)) @@ -102,7 +102,7 @@ func (k Keeper) TransferCommunityPoolDepositToHolding(ctx sdk.Context, hostZone } // get the hostZone counterparty transfer channel for sending tokens from hostZone to Stride - transferChannel, found := k.IBCKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) + transferChannel, found := k.ibcKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) if !found { return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "transfer channel %s not found", hostZone.TransferChannelId) } @@ -189,7 +189,7 @@ func (k Keeper) TransferHoldingToCommunityPoolReturn(ctx sdk.Context, hostZone t memo, ) - msgTransferResponse, err := k.RecordsKeeper.TransferKeeper.Transfer(sdk.WrapSDKContext(ctx), msg) + msgTransferResponse, err := k.recordsKeeper.TransferKeeper.Transfer(sdk.WrapSDKContext(ctx), msg) if err != nil { return errorsmod.Wrapf(err, "Error submitting ibc transfer for %+v", coin) } @@ -207,7 +207,7 @@ func (k Keeper) GetStIbcDenomOnHostZone(ctx sdk.Context, hostZone types.HostZone stDenomOnStride := types.StAssetDenomFromHostZoneDenom(nativeDenom) // use counterparty transfer channel because tokens come through this channel to hostZone - transferChannel, found := k.IBCKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) + transferChannel, found := k.ibcKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) if !found { return "", channeltypes.ErrChannelNotFound.Wrap(hostZone.TransferChannelId) } diff --git a/x/stakeibc/keeper/unbonding.go b/x/stakeibc/keeper/unbonding.go index 1cf9db6d..d52f6a69 100644 --- a/x/stakeibc/keeper/unbonding.go +++ b/x/stakeibc/keeper/unbonding.go @@ -49,8 +49,8 @@ func (k Keeper) GetQueuedHostZoneUnbondingRecords( chainId string, ) (epochNumbers []uint64, epochToHostZoneUnbondingMap map[uint64]recordstypes.HostZoneUnbonding) { epochToHostZoneUnbondingMap = map[uint64]recordstypes.HostZoneUnbonding{} - for _, epochUnbonding := range k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) { - hostZoneRecord, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbonding.EpochNumber, chainId) + for _, epochUnbonding := range k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) { + hostZoneRecord, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, epochUnbonding.EpochNumber, chainId) if !found { continue } @@ -87,7 +87,7 @@ func (k Keeper) RefreshUserRedemptionRecordNativeAmounts( // Loop and set the native amount for each record, keeping track of the total totalNativeAmount = sdkmath.ZeroInt() for _, userRedemptionRecordId := range userRedemptionRecordIds { - userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId) + userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId) if !found { k.Logger(ctx).Error(utils.LogWithHostZone(chainId, "No user redemption record found for id %s", userRedemptionRecordId)) continue @@ -99,7 +99,7 @@ func (k Keeper) RefreshUserRedemptionRecordNativeAmounts( // Set the native amount on the record userRedemptionRecord.NativeTokenAmount = nativeAmount - k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) + k.recordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) } return totalNativeAmount } @@ -123,7 +123,7 @@ func (k Keeper) RefreshHostZoneUnbondingNativeTokenAmount( // Then set the total on the host zone unbonding record hostZoneUnbondingRecord.NativeTokenAmount = totalNativeAmount - return k.RecordsKeeper.SetHostZoneUnbondingRecord(ctx, epochNumber, chainId, hostZoneUnbondingRecord) + return k.recordsKeeper.SetHostZoneUnbondingRecord(ctx, epochNumber, chainId, hostZoneUnbondingRecord) } // Given a mapping of epoch unbonding record IDs to host zone unbonding records, @@ -527,7 +527,7 @@ func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) err } // Update the epoch unbonding record status - if err := k.RecordsKeeper.SetHostZoneUnbondingStatus( + if err := k.recordsKeeper.SetHostZoneUnbondingStatus( ctx, hostZone.ChainId, epochUnbondingRecordIds, diff --git a/x/stakeibc/keeper/validator.go b/x/stakeibc/keeper/validator.go index 07287a45..0c76cb3b 100644 --- a/x/stakeibc/keeper/validator.go +++ b/x/stakeibc/keeper/validator.go @@ -85,7 +85,7 @@ func (k Keeper) RemoveValidatorFromHostZone(ctx sdk.Context, chainId string, val } // Check for LSMTokenDeposit records with this specific validator address - lsmTokenDeposits := k.RecordsKeeper.GetAllLSMTokenDeposit(ctx) + lsmTokenDeposits := k.recordsKeeper.GetAllLSMTokenDeposit(ctx) for _, lsmTokenDeposit := range lsmTokenDeposits { if lsmTokenDeposit.ValidatorAddress == validatorAddress { return errorsmod.Wrapf(types.ErrUnableToRemoveValidator, "Validator (%s) still has at least one LSMTokenDeposit (%+v)", validatorAddress, lsmTokenDeposit) diff --git a/x/stakeibc/types/expected_keepers.go b/x/stakeibc/types/expected_keepers.go index eea1bb00..f92acdc9 100644 --- a/x/stakeibc/types/expected_keepers.go +++ b/x/stakeibc/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types" sdk "github.com/cosmos/cosmos-sdk/types" + opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) @@ -46,3 +47,7 @@ type RatelimitKeeper interface { SetWhitelistedAddressPair(ctx sdk.Context, whitelist ratelimittypes.WhitelistedAddressPair) RemoveWhitelistedAddressPair(ctx sdk.Context, sender, receiver string) } + +type OPChildKeeper interface { + GetParams(ctx context.Context) (opchildtypes.Params, error) +} diff --git a/x/stakeibc/types/message_add_validators.go b/x/stakeibc/types/message_add_validators.go index 5a41d458..ca7691ab 100644 --- a/x/stakeibc/types/message_add_validators.go +++ b/x/stakeibc/types/message_add_validators.go @@ -6,8 +6,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgAddValidators = "add_validators" @@ -48,9 +46,6 @@ func (msg *MsgAddValidators) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } if len(msg.Validators) == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "at least one validator must be provided") diff --git a/x/stakeibc/types/message_change_validator_weight.go b/x/stakeibc/types/message_change_validator_weight.go index 57ee8889..0e20bd26 100644 --- a/x/stakeibc/types/message_change_validator_weight.go +++ b/x/stakeibc/types/message_change_validator_weight.go @@ -4,8 +4,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgChangeValidatorWeights = "change_validator_weight" @@ -46,9 +44,6 @@ func (msg *MsgChangeValidatorWeights) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } if msg.HostZone == "" { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "host zone must be specified") } diff --git a/x/stakeibc/types/message_clear_balance.go b/x/stakeibc/types/message_clear_balance.go index e78ee501..dc4e9777 100644 --- a/x/stakeibc/types/message_clear_balance.go +++ b/x/stakeibc/types/message_clear_balance.go @@ -7,8 +7,6 @@ import ( errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgClearBalance = "clear_balance" @@ -50,9 +48,6 @@ func (msg *MsgClearBalance) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } // basic checks on host denom if len(msg.ChainId) == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "chainid is required") diff --git a/x/stakeibc/types/message_delete_validator.go b/x/stakeibc/types/message_delete_validator.go index 3a73fcd6..ec2d9c00 100644 --- a/x/stakeibc/types/message_delete_validator.go +++ b/x/stakeibc/types/message_delete_validator.go @@ -4,8 +4,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgDeleteValidator = "delete_validator" @@ -46,8 +44,5 @@ func (msg *MsgDeleteValidator) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } return nil } diff --git a/x/stakeibc/types/message_rebalance_validators.go b/x/stakeibc/types/message_rebalance_validators.go index f6825107..03bc3ac6 100644 --- a/x/stakeibc/types/message_rebalance_validators.go +++ b/x/stakeibc/types/message_rebalance_validators.go @@ -6,8 +6,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const ( @@ -53,9 +51,6 @@ func (msg *MsgRebalanceValidators) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } if (msg.NumRebalance < MinNumRebalanceValidators) || (msg.NumRebalance > MaxNumRebalanceValidators) { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, fmt.Sprintf("invalid number of validators to rebalance (%d)", msg.NumRebalance)) } diff --git a/x/stakeibc/types/message_register_host_zone.go b/x/stakeibc/types/message_register_host_zone.go index 7184376e..45134e34 100644 --- a/x/stakeibc/types/message_register_host_zone.go +++ b/x/stakeibc/types/message_register_host_zone.go @@ -9,8 +9,6 @@ import ( errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgRegisterHostZone = "register_host_zone" @@ -73,9 +71,6 @@ func (msg *MsgRegisterHostZone) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } // VALIDATE DENOMS // host denom cannot be empty if msg.HostDenom == "" { diff --git a/x/stakeibc/types/message_resume_host_zone.go b/x/stakeibc/types/message_resume_host_zone.go index 23074443..565106ce 100644 --- a/x/stakeibc/types/message_resume_host_zone.go +++ b/x/stakeibc/types/message_resume_host_zone.go @@ -4,8 +4,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgResumeHostZone = "resume_host_zone" @@ -45,8 +43,5 @@ func (msg *MsgResumeHostZone) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } return nil } diff --git a/x/stakeibc/types/message_set_community_pool_rebate.go b/x/stakeibc/types/message_set_community_pool_rebate.go index 53bee33b..4d5ebfce 100644 --- a/x/stakeibc/types/message_set_community_pool_rebate.go +++ b/x/stakeibc/types/message_set_community_pool_rebate.go @@ -8,8 +8,6 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgSetCommunityPoolRebate = "set_community_pool_rebate" @@ -56,9 +54,6 @@ func (msg *MsgSetCommunityPoolRebate) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } if msg.ChainId == "" { return errors.New("chain ID must be specified") } diff --git a/x/stakeibc/types/message_toggle_trade_controller.go b/x/stakeibc/types/message_toggle_trade_controller.go index 906b4aa4..1047caa4 100644 --- a/x/stakeibc/types/message_toggle_trade_controller.go +++ b/x/stakeibc/types/message_toggle_trade_controller.go @@ -7,8 +7,6 @@ import ( errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgToggleTradeController = "toggle_trade_controller" @@ -50,9 +48,6 @@ func (msg *MsgToggleTradeController) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } if msg.ChainId == "" { return errors.New("chain ID must be specified") } diff --git a/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go b/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go index a2f5f5d5..3ac121fe 100644 --- a/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go +++ b/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go @@ -5,8 +5,6 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/milkyway-labs/milkyway/utils" ) const TypeMsgUpdateInnerRedemptionRateBounds = "update_inner_redemption_rate_bounds" @@ -52,8 +50,5 @@ func (msg *MsgUpdateInnerRedemptionRateBounds) ValidateBasic() error { if msg.MaxInnerRedemptionRate.LTE(msg.MinInnerRedemptionRate) { return errorsmod.Wrapf(ErrInvalidBounds, "Inner max safety threshold (%s) is less than inner min safety threshold (%s)", msg.MaxInnerRedemptionRate, msg.MinInnerRedemptionRate) } - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return err - } return nil }