Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 1.2.5 #350

Merged
merged 14 commits into from
Mar 15, 2023
23 changes: 23 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"fmt"
minttypes "github.com/ingenuity-build/quicksilver/x/mint/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -16,12 +17,14 @@ const (
DevnetChainID = "quicktest-1"

v010204UpgradeName = "v1.2.4"
v010205UpgradeName = "v1.2.5"
v010300UpgradeName = "v1.3.0" // retained for testy
)

func setUpgradeHandlers(app *Quicksilver) {
app.UpgradeKeeper.SetUpgradeHandler(v010300UpgradeName, noOpUpgradeHandler(app)) // retained for testy
app.UpgradeKeeper.SetUpgradeHandler(v010204UpgradeName, v010204UpgradeHandler(app))
app.UpgradeKeeper.SetUpgradeHandler(v010205UpgradeName, v010205UpgradeHandler(app))

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand Down Expand Up @@ -78,3 +81,23 @@ func v010204UpgradeHandler(app *Quicksilver) upgradetypes.UpgradeHandler {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
}
}

func v010205UpgradeHandler(app *Quicksilver) upgradetypes.UpgradeHandler {
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
//update minter epoch-provisions
minter := app.MintKeeper.GetMinter(ctx)
minter.EpochProvisions = sdk.NewDec(50000000).Quo(sdk.NewDec(365))
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
app.MintKeeper.SetMinter(ctx, minter)

//update params
params := app.MintKeeper.GetParams(ctx)
params.DistributionProportions = minttypes.DistributionProportions{
Staking: sdk.NewDec(0.8),
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
PoolIncentives: sdk.NewDec(0.17),
ParticipationRewards: sdk.NewDec(0),
CommunityPool: sdk.NewDec(0.03),
}
app.MintKeeper.SetParams(ctx, params)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
}
}
16 changes: 16 additions & 0 deletions proto/quicksilver/interchainstaking/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "quicksilver/interchainstaking/v1/interchainstaking.proto";
import "quicksilver/interchainstaking/v1/proposals.proto";
import "google/api/annotations.proto";

option go_package = "github.com/ingenuity-build/quicksilver/x/interchainstaking/types";
Expand All @@ -28,6 +29,21 @@ service Msg {
body : "*"
};
};

rpc GovCloseChannel(MsgGovCloseChannel) returns (MsgGovCloseChannelResponse) {
option (google.api.http) = {
post : "/quicksilver/tx/v1/interchainstaking/close_channel"
body : "*"
};
};

rpc GovReopenChannel(MsgGovReopenChannel)
returns (MsgGovReopenChannelResponse) {
option (google.api.http) = {
post : "/quicksilver/tx/v1/interchainstaking/reopen_channel"
body : "*"
};
};
}

// MsgRequestRedemption represents a message type to request a burn of qAssets
Expand Down
44 changes: 26 additions & 18 deletions proto/quicksilver/interchainstaking/v1/proposals.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,34 @@ message UpdateZoneValue {
string value = 2 [ (gogoproto.moretags) = "yaml:\"value\"" ];
}

// message ReopenChannel {
// option (gogoproto.equal) = false;
// option (gogoproto.goproto_getters) = false;
// option (gogoproto.goproto_stringer) = false;
message MsgGovReopenChannel {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string title = 1;
string description = 2;

// string title = 1;
// string description = 2;
string connection_id = 3 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ];
string port_id = 4 [ (gogoproto.moretags) = "yaml:\"port_id\"" ];

// string connection_id = 3 [ (gogoproto.moretags) = "yaml:\"connection_id\""
// ]; string channel_id = 4 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
// }
string authority = 5 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// message CloseChannel {
// option (gogoproto.equal) = false;
// option (gogoproto.goproto_getters) = false;
// option (gogoproto.goproto_stringer) = false;
// MsgGovReopenChannelResponse defines the MsgGovReopenChannel response type.
message MsgGovReopenChannelResponse {}

// string title = 1;
// string description = 2;
message MsgGovCloseChannel {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string title = 1;
string description = 2;

string channel_id = 3 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
string port_id = 4 [ (gogoproto.moretags) = "yaml:\"port_id\"" ];

string authority = 5 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// string connection_id = 3 [ (gogoproto.moretags) = "yaml:\"connection_id\""
// ]; string channel_id = 4 [ (gogoproto.moretags) = "yaml:\"channel_id\"" ];
// }
// MsgGovCloseChannelResponse defines the MsgGovCloseChannel response type.
message MsgGovCloseChannelResponse {}
28 changes: 27 additions & 1 deletion x/interchainstaking/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func GetTxCmd() *cobra.Command {

txCmd.AddCommand(GetSignalIntentTxCmd())
txCmd.AddCommand(GetRequestRedemptionTxCmd())
txCmd.AddCommand(GetReopenChannelTxCmd())

return txCmd
}
Expand Down Expand Up @@ -93,6 +94,31 @@ func GetRequestRedemptionTxCmd() *cobra.Command {
return cmd
}

// GetReopenChannelTxCmd returns a CLI command handler for creating a Reopen ICA port transaction.
func GetReopenChannelTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "reopen [connection] [port]",
Short: `Reopen closed ICA port.`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
connectionID := args[0]
port := args[1]

msg := types.NewMsgGovReopenChannel(connectionID, port, clientCtx.GetFromAddress())

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

// GetCmdSubmitRegisterProposal implements the command to submit a register-zone proposal
func GetCmdSubmitRegisterProposal() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -178,7 +204,7 @@ func ParseZoneRegistrationProposal(cdc codec.JSONCodec, proposalFile string) (ty
return proposal, nil
}

// GetCmdSubmitRegisterProposal implements the command to submit a register-zone proposal
// GetCmdSubmitUpdateProposal implements the command to submit a register-zone proposal
func GetCmdSubmitUpdateProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "update-zone [proposal-file]",
Expand Down
22 changes: 21 additions & 1 deletion x/interchainstaking/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"bytes"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"time"

"github.com/cosmos/cosmos-sdk/telemetry"
Expand All @@ -16,7 +17,26 @@ type zoneItrFn func(index int64, zoneInfo types.Zone) (stop bool)
// BeginBlocker of interchainstaking module
func (k Keeper) BeginBlocker(ctx sdk.Context) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)

//post upgrade-v1.2.5 processing
if ctx.BlockHeight() == 14540740 {
k.IterateReceipts(ctx, func(_ int64, receiptInfo types.Receipt) (stop bool) {
if receiptInfo.ChainId == "regen-1" && receiptInfo.Completed == nil {
sendMsg := banktypes.MsgSend{
FromAddress: "",
ToAddress: "",
Amount: receiptInfo.Amount,
}
zone, found := k.GetZone(ctx, "regen-1")
if found {
err := k.handleSendToDelegate(ctx, &zone, &sendMsg, receiptInfo.Txhash)
if err != nil {
panic(err)
}
}
}
return false
})
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
}
if ctx.BlockHeight()%30 == 0 {
if err := k.GCCompletedRedelegations(ctx); err != nil {
k.Logger(ctx).Error("error in GCCompletedRedelegations", "error", err)
Expand Down
6 changes: 6 additions & 0 deletions x/interchainstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"sort"
"time"

Expand All @@ -26,6 +27,7 @@ import (
ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types"
"github.com/tendermint/tendermint/libs/log"

config "github.com/ingenuity-build/quicksilver/cmd/config"
"github.com/ingenuity-build/quicksilver/utils"
claimsmanagerkeeper "github.com/ingenuity-build/quicksilver/x/claimsmanager/keeper"
interchainquerykeeper "github.com/ingenuity-build/quicksilver/x/interchainquery/keeper"
Expand Down Expand Up @@ -81,6 +83,10 @@ func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, accountKeeper auth
}
}

func (k *Keeper) GetGovAuthority(ctx sdk.Context) string {
return sdk.MustBech32ifyAddressBytes(config.Bech32Prefix, k.AccountKeeper.GetModuleAddress(govtypes.ModuleName))
}

// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
Expand Down
76 changes: 76 additions & 0 deletions x/interchainstaking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"encoding/hex"
"errors"
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"sort"
"strings"
"time"

"cosmossdk.io/math"
Expand Down Expand Up @@ -317,3 +319,77 @@ func (k Keeper) EmitValsetRequery(ctx sdk.Context, connectionID string, chainID
)
return nil
}

// GovReopenChannel reopens an ICA channel.
func (k msgServer) GovReopenChannel(goCtx context.Context, msg *types.MsgGovReopenChannel) (*types.MsgGovReopenChannelResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// validate the zone exists, and the format is valid (e.g. quickgaia-1.delegate)
parts := strings.Split(msg.PortId, ".")
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
if len(parts) != 2 {
return &types.MsgGovReopenChannelResponse{}, errors.New("invalid port format")
}

if _, found := k.GetZone(ctx, parts[0]); !found {
return &types.MsgGovReopenChannelResponse{}, errors.New("invalid port format; zone not found")
}

if parts[1] != "delegate" && parts[1] != "deposit" && parts[1] != "performance" && parts[1] != "withdrawal" {
return &types.MsgGovReopenChannelResponse{}, errors.New("invalid port format; unexpected account")
}

if err := k.Keeper.registerInterchainAccount(ctx, msg.ConnectionId, msg.PortId); err != nil {
return &types.MsgGovReopenChannelResponse{}, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
sdk.NewEvent(
types.EventTypeReopenICA,
sdk.NewAttribute(types.AttributeKeyPortID, msg.PortId),
sdk.NewAttribute(types.AttributeKeyConnectionID, msg.ConnectionId),
),
})

return &types.MsgGovReopenChannelResponse{}, nil
}

// GovCloseChannel closes an ICA channel.
func (k msgServer) GovCloseChannel(goCtx context.Context, msg *types.MsgGovCloseChannel) (*types.MsgGovCloseChannelResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// checking msg authority is the gov module address
if k.Keeper.GetGovAuthority(ctx) != msg.Authority {
return &types.MsgGovCloseChannelResponse{},
govtypes.ErrInvalidSigner.Wrapf(
"invalid authority: expected %s, got %s",
k.Keeper.GetGovAuthority(ctx), msg.Authority,
)
}

_, cap, err := k.Keeper.IBCKeeper.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId)
if err != nil {
return &types.MsgGovCloseChannelResponse{}, err
}

if err := k.IBCKeeper.ChannelKeeper.ChanCloseInit(ctx, msg.PortId, msg.ChannelId, cap); err != nil {
return &types.MsgGovCloseChannelResponse{}, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
sdk.NewEvent(
types.EventTypeReopenICA,
sdk.NewAttribute(types.AttributeKeyPortID, msg.PortId),
sdk.NewAttribute(types.AttributeKeyChannelID, msg.ChannelId),
),
})

return &types.MsgGovCloseChannelResponse{}, nil
}
3 changes: 3 additions & 0 deletions x/interchainstaking/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
(*sdk.Msg)(nil),
&MsgSignalIntent{},
&MsgRequestRedemption{},
&MsgGovCloseChannel{},
&MsgGovReopenChannel{},

)

registry.RegisterImplementations(
Expand Down
4 changes: 4 additions & 0 deletions x/interchainstaking/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package types
const (
EventTypeRegisterZone = "register_zone"
EventTypeRedemptionRequest = "request_redemption"
EventTypeCloseICA = "close_ica_channel"
EventTypeReopenICA = "reopen_ica_channel"

AttributeKeyConnectionID = "connection_id"
AttributeKeyRecipientChain = "chain_id"
AttributeKeyRecipientAddress = "recipient"
AttributeKeyBurnAmount = "burn_amount"
AttributeKeyRedeemAmount = "redeem_amount"
AttributeKeySourceAddress = "source"
AttributeKeyPortID = "port_name"
AttributeKeyChannelID = "channel_id"

AttributeValueCategory = ModuleName
)
Loading