Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 43c4242

Browse files
kruspypuneetmahajan
authored andcommitted
merge
1 parent 0b8c6d6 commit 43c4242

File tree

12 files changed

+135
-50
lines changed

12 files changed

+135
-50
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
4040

4141
- [#594](https://github.com/persistenceOne/pstake-native/pull/594) LSM integration.
4242

43+
### Bug Fixes
44+
45+
- [#621](https://github.com/persistenceOne/pstake-native/pull/621) ICA recreation timeout fix.
46+
4347
## [v2.2.2] - 2023-08-07
4448

4549
### Improvements

app/app.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ func NewpStakeApp(
559559
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
560560
AddRoute(liquidstakeibctypes.ModuleName, icaControllerStack)
561561

562-
// TODO: Migrate
563-
//AddRoute(lscosmostypes.ModuleName, icaControllerStack)
564-
565562
app.IBCKeeper.SetRouter(ibcRouter)
566563

567564
// register the proposal types
@@ -780,8 +777,6 @@ func NewpStakeApp(
780777
evidence.NewAppModule(app.EvidenceKeeper),
781778
ibc.NewAppModule(app.IBCKeeper),
782779
transfer.NewAppModule(app.TransferKeeper),
783-
// ibcTransferHooksMiddleware, TODO implement simulationModule interface
784-
//icaModule,
785780
lscosmos.NewAppModule(appCodec, liquidStakeIBCModule, app.LSCosmosKeeper, app.AccountKeeper, app.BankKeeper),
786781
lspersistence.NewAppModule(appCodec, app.LSPersistenceKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
787782
)

app/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func SetAddressPrefixes() {
6262
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bytes))
6363
}
6464

65-
// TODO: Do we want to allow addresses of lengths other than 20 and 32 bytes?
6665
if len(bytes) != 20 && len(bytes) != 32 {
6766
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
6867
}

x/liquidstakeibc/client/query.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ func QueryParamsCmd() *cobra.Command {
4747
Use: "params",
4848
Short: "Query the current liquidstakeibc parameters",
4949
Args: cobra.NoArgs,
50-
Long: strings.TrimSpace(`Query the current liquidstakeibc parameters:
51-
52-
$ <appd> query liquidstakeibc params
53-
`),
50+
Long: strings.TrimSpace(
51+
fmt.Sprintf(
52+
`Query the current liquidstakeibc parameters: $ %s query liquidstakeibc params`,
53+
version.AppName,
54+
),
55+
),
5456
RunE: func(cmd *cobra.Command, _ []string) error {
5557
clientCtx, err := client.GetClientQueryContext(cmd)
5658
if err != nil {

x/liquidstakeibc/client/tx.go

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55
"fmt"
66
"os"
77
"strconv"
8+
"strings"
89

910
"github.com/cosmos/cosmos-sdk/client"
1011
"github.com/cosmos/cosmos-sdk/client/flags"
1112
"github.com/cosmos/cosmos-sdk/client/tx"
1213
sdk "github.com/cosmos/cosmos-sdk/types"
14+
"github.com/cosmos/cosmos-sdk/version"
1315
"github.com/spf13/cobra"
1416

1517
"github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/types"
@@ -44,6 +46,12 @@ func NewRegisterHostChainCmd() *cobra.Command {
4446
Use: "register-host-chain [connection-id] [channel-id] [port-id] [deposit-fee] [restake-fee] [unstake-fee] [redemption-fee] [host-denom] [minimum-deposit] [unbonding-factor] [autocompound-factor]",
4547
Args: cobra.ExactArgs(11),
4648
Short: "Register a host chain",
49+
Long: strings.TrimSpace(
50+
fmt.Sprintf(
51+
`Submit a register host chain transaction: $ %s tx liquidstakeibc register-host-chain connection-0 channel-0 transfer 0.00 0.05 0.00 0.005 uatom 1 4 20`,
52+
version.AppName,
53+
),
54+
),
4755
RunE: func(cmd *cobra.Command, args []string) error {
4856
clientCtx, err := client.GetClientTxContext(cmd)
4957
if err != nil {
@@ -99,6 +107,30 @@ func NewUpdateHostChainCmd() *cobra.Command {
99107
Use: "update-host-chain [chain-id] [updates]",
100108
Args: cobra.ExactArgs(2),
101109
Short: "Update a host chain",
110+
Long: strings.TrimSpace(
111+
fmt.Sprintf(
112+
`Submit an update host chain transaction:
113+
$ %s tx liquidstakeibc update-host-chain gaia-1 '[
114+
{
115+
"key": "active",
116+
"value": "true"
117+
},
118+
{
119+
"key": "set_withdraw_address",
120+
"value": ""
121+
},
122+
{
123+
"key": "flags",
124+
"value": "{\"lsm\": true}"
125+
},
126+
{
127+
"key": "add_validator",
128+
"value": "{\"operator_address\": \"cosmosvaloper1hcqg5wj9t42zawqkqucs7la85ffyv08le09ljt\", \"status\": \"BOND_STATUS_BONDED\", \"weight\": \"1\", \"delegated_amount\": \"0\", \"exchange_rate\": \"0\", \"unbonding_epoch\": 0}"
129+
}
130+
]'`,
131+
version.AppName,
132+
),
133+
),
102134
RunE: func(cmd *cobra.Command, args []string) error {
103135
clientCtx, err := client.GetClientTxContext(cmd)
104136
if err != nil {
@@ -133,7 +165,13 @@ func NewLiquidStakeCmd() *cobra.Command {
133165
cmd := &cobra.Command{
134166
Use: "liquid-stake [amount]",
135167
Short: `Liquid Stake tokens from a registered host chain into stk tokens`,
136-
Args: cobra.ExactArgs(1),
168+
Long: strings.TrimSpace(
169+
fmt.Sprintf(
170+
`Submit a liquid stake transaction: $ %s tx liquidstakeibc liquid-stake 100000000ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2`,
171+
version.AppName,
172+
),
173+
),
174+
Args: cobra.ExactArgs(1),
137175
RunE: func(cmd *cobra.Command, args []string) error {
138176

139177
clientctx, err := client.GetClientTxContext(cmd)
@@ -162,7 +200,13 @@ func NewLiquidUnstakeCmd() *cobra.Command {
162200
cmd := &cobra.Command{
163201
Use: "liquid-unstake [amount]",
164202
Short: `Unstake stk tokens from a registered host chain`,
165-
Args: cobra.ExactArgs(1),
203+
Long: strings.TrimSpace(
204+
fmt.Sprintf(
205+
`Submit a liquid unstake transaction: $ %s tx liquidstakeibc liquid-unstake 100000000stk/uatom`,
206+
version.AppName,
207+
),
208+
),
209+
Args: cobra.ExactArgs(1),
166210
RunE: func(cmd *cobra.Command, args []string) error {
167211

168212
clientctx, err := client.GetClientTxContext(cmd)
@@ -191,7 +235,13 @@ func NewRedeemCmd() *cobra.Command {
191235
cmd := &cobra.Command{
192236
Use: "redeem [amount]",
193237
Short: `Instantly redeem stk tokens from a registered host chain`,
194-
Args: cobra.ExactArgs(1),
238+
Long: strings.TrimSpace(
239+
fmt.Sprintf(
240+
`Submit a redeem transaction: $ %s tx liquidstakeibc redeem 50000000stk/uatom`,
241+
version.AppName,
242+
),
243+
),
244+
Args: cobra.ExactArgs(1),
195245
RunE: func(cmd *cobra.Command, args []string) error {
196246

197247
clientctx, err := client.GetClientTxContext(cmd)
@@ -222,6 +272,30 @@ func NewUpdateParamsCmd() *cobra.Command {
222272
Use: "update-params [params-file]",
223273
Args: cobra.ExactArgs(1),
224274
Short: "Update the module params",
275+
Long: strings.TrimSpace(
276+
fmt.Sprintf(
277+
`Submit an update params transaction: $ %s tx liquidstakeibc update-params /params-file.json
278+
279+
Params file contents:
280+
281+
{
282+
"messages": [{
283+
"@type": "/pstake.liquidstakeibc.v1beta1.MsgUpdateParams",
284+
"authority": "persistence10d07y265gmmuvt4z0w9aw880jnsr700j5w4kch",
285+
"params": {
286+
"admin_address": "persistence10khgeppewe4rgfrcy809r9h00aquwxxxrk6glr",
287+
"fee_address": "persistence1xruvjju28j0a5ud5325rfdak8f5a04h0s30mld"
288+
}
289+
}],
290+
"deposit": "10000000uxprt",
291+
"proposer": "persistence1hcqg5wj9t42zawqkqucs7la85ffyv08ljhhesu",
292+
"title": "Update module addresses",
293+
"summary": "Updates both the admin and the fee address of the module",
294+
"metadata": ""
295+
}`,
296+
version.AppName,
297+
),
298+
),
225299
RunE: func(cmd *cobra.Command, args []string) error {
226300
clientCtx, err := client.GetClientTxContext(cmd)
227301
if err != nil {

x/liquidstakeibc/keeper/abci.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,25 @@ func (k *Keeper) DoRecreateICA(ctx sdk.Context, hc *types.HostChain) {
157157
hc.DelegationAccount.ChannelState != types.ICAAccount_ICA_CHANNEL_CREATING {
158158
if err := k.RegisterICAAccount(ctx, hc.ConnectionId, hc.DelegationAccount.Owner); err != nil {
159159
k.Logger(ctx).Error("error recreating %s delegate ica: %w", hc.ChainId, err)
160-
}
161-
162-
k.Logger(ctx).Info("Recreating delegate ICA.", "chain", hc.ChainId)
160+
} else {
161+
k.Logger(ctx).Info("Recreating delegate ICA.", "chain", hc.ChainId)
163162

164-
hc.DelegationAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATING
165-
k.SetHostChain(ctx, hc)
163+
hc.DelegationAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATING
164+
k.SetHostChain(ctx, hc)
165+
}
166166
}
167167

168168
// if the channel is closed, and it is not being recreated, recreate it
169169
if !k.IsICAChannelActive(ctx, hc, k.GetPortID(hc.RewardsAccount.Owner)) &&
170170
hc.RewardsAccount.ChannelState != types.ICAAccount_ICA_CHANNEL_CREATING {
171171
if err := k.RegisterICAAccount(ctx, hc.ConnectionId, hc.RewardsAccount.Owner); err != nil {
172172
k.Logger(ctx).Error("error recreating %s rewards ica: %w", hc.ChainId, err)
173-
}
174-
175-
k.Logger(ctx).Info("Recreating rewards ICA.", "chain", hc.ChainId)
173+
} else {
174+
k.Logger(ctx).Info("Recreating rewards ICA.", "chain", hc.ChainId)
176175

177-
hc.RewardsAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATING
178-
k.SetHostChain(ctx, hc)
176+
hc.RewardsAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATING
177+
k.SetHostChain(ctx, hc)
178+
}
179179
}
180180
}
181181

x/liquidstakeibc/keeper/grpc_querier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func (suite *IntegrationTestSuite) TestQueryParams() {
3131
req: &types.QueryParamsRequest{},
3232
resp: &types.QueryParamsResponse{
3333
Params: types.Params{
34-
AdminAddress: "persistence10khgeppewe4rgfrcy809r9h00aquwxxxrk6glr",
35-
FeeAddress: "persistence1xruvjju28j0a5ud5325rfdak8f5a04h0s30mld",
34+
AdminAddress: "persistence1gztc3y3k52hjds5nqvl7h9jvfnc33spz47zcjy",
35+
FeeAddress: "persistence1gztc3y3k52hjds5nqvl7h9jvfnc33spz47zcjy",
3636
UpperCValueLimit: decFromStr("1.1"),
3737
LowerCValueLimit: decFromStr("0.85"),
3838
},

x/liquidstakeibc/keeper/ibc.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,15 @@ func (k *Keeper) OnChanOpenAck(
6666
return fmt.Errorf("host chain with id %s is not registered", chainID)
6767
}
6868

69-
// create the ica account
70-
icaAccount := &types.ICAAccount{
71-
Address: address,
72-
Balance: sdk.Coin{Amount: sdk.ZeroInt(), Denom: hc.HostDenom},
73-
Owner: portOwner,
74-
ChannelState: types.ICAAccount_ICA_CHANNEL_CREATED,
75-
}
76-
7769
switch {
7870
case portOwner == hc.DelegationAccount.Owner:
79-
hc.DelegationAccount = icaAccount
71+
hc.DelegationAccount.Address = address
72+
hc.DelegationAccount.Owner = portOwner
73+
hc.DelegationAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATED
8074
case portOwner == hc.RewardsAccount.Owner:
81-
hc.RewardsAccount = icaAccount
75+
hc.RewardsAccount.Address = address
76+
hc.RewardsAccount.Owner = portOwner
77+
hc.RewardsAccount.ChannelState = types.ICAAccount_ICA_CHANNEL_CREATED
8278
default:
8379
k.Logger(ctx).Error("Unrecognised ICA account type for the module", "port-id:", portID, "chain-id", chainID)
8480
return nil

x/liquidstakeibc/keeper/msg_server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ func (k msgServer) RegisterHostChain(
6868
UnbondingFactor: msg.UnbondingFactor,
6969
Active: false,
7070
DelegationAccount: &types.ICAAccount{
71-
Owner: types.DefaultDelegateAccountPortOwner(chainID),
71+
Owner: types.DefaultDelegateAccountPortOwner(chainID),
72+
Balance: sdktypes.Coin{Amount: sdktypes.ZeroInt(), Denom: msg.HostDenom},
7273
},
7374
RewardsAccount: &types.ICAAccount{
74-
Owner: types.DefaultRewardsAccountPortOwner(chainID),
75+
Owner: types.DefaultRewardsAccountPortOwner(chainID),
76+
Balance: sdktypes.Coin{Amount: sdktypes.ZeroInt(), Denom: msg.HostDenom},
7577
},
7678
AutoCompoundFactor: k.CalculateAutocompoundLimit(sdktypes.NewDec(msg.AutoCompoundFactor)),
7779
}

x/liquidstakeibc/types/msgs.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,27 @@ func (m *MsgRegisterHostChain) ValidateBasic() error {
149149
)
150150
}
151151

152+
// minimum deposit must be at least one
152153
if m.MinimumDeposit.LTE(sdk.ZeroInt()) {
153154
return sdkerrors.ErrInvalidRequest.Wrapf(
154155
"minimum deposit should be greater than zero",
155156
)
156157
}
157158

159+
// unbonding factor must be greater than zero
160+
if m.UnbondingFactor <= 0 {
161+
return sdkerrors.ErrInvalidRequest.Wrapf(
162+
"unbonding factor should be greater than zero",
163+
)
164+
}
165+
166+
// autocompound factor must be greater than zero
167+
if m.AutoCompoundFactor <= 0 {
168+
return sdkerrors.ErrInvalidRequest.Wrapf(
169+
"autocompound factor should be greater than zero",
170+
)
171+
}
172+
158173
return nil
159174
}
160175

0 commit comments

Comments
 (0)