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
24 changes: 24 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

minttypes "github.com/ingenuity-build/quicksilver/x/mint/types"
)

// upgrade name consts: vMMmmppUpgradeName (M=Major, m=minor, p=patch)
Expand All @@ -16,12 +18,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 +82,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(50000000000000).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.NewDecWithPrec(80, 2),
PoolIncentives: sdk.NewDecWithPrec(17, 2),
ParticipationRewards: sdk.NewDec(0),
CommunityPool: sdk.NewDecWithPrec(3, 2),
}
app.MintKeeper.SetParams(ctx, params)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
}
}
235 changes: 235 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
package app

import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
"github.com/ingenuity-build/quicksilver/utils"
icskeeper "github.com/ingenuity-build/quicksilver/x/interchainstaking/keeper"
icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types"
minttypes "github.com/ingenuity-build/quicksilver/x/mint/types"
tokenfactorytypes "github.com/ingenuity-build/quicksilver/x/tokenfactory/types"
"github.com/stretchr/testify/suite"
"testing"
"time"
)

// TODO: this test runs in isolation, but fails as part of `make test`.
// In the `make test` context, MintCoins() seems to have no effect. Why is this?
// func TestReplaceZone(t *testing.T) {
Expand Down Expand Up @@ -67,3 +82,223 @@ package app
// require.False(t, app.AirdropKeeper.GetZoneDropAccountBalance(ctx, "osmotest-4").Amount.Equal(sdk.NewInt(1000000)))
// require.True(t, app.AirdropKeeper.GetZoneDropAccountBalance(ctx, "osmo-test-4").Amount.Equal(sdk.NewInt(1000000)))
// }

func init() {
ibctesting.DefaultTestingAppInit = SetupTestingApp
}

// TestKeeperTestSuite runs all the tests within this package.
func TestAppTestSuite(t *testing.T) {
suite.Run(t, new(AppTestSuite))
}

func newQuicksilverPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort
path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort

return path
}

type AppTestSuite struct {
suite.Suite

coordinator *ibctesting.Coordinator

// testing chains used for convenience and readability
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain

path *ibctesting.Path
}

func (s *AppTestSuite) GetQuicksilverApp(chain *ibctesting.TestChain) *Quicksilver {
app, ok := chain.App.(*Quicksilver)
if !ok {
panic("not quicksilver app")
}

return app
}

// SetupTest creates a coordinator with 2 test chains.
func (suite *AppTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) // initializes 2 test chains
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) // convenience and readability
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) // convenience and readability

suite.path = newQuicksilverPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(suite.path)

suite.coordinator.CurrentTime = time.Now().UTC()
suite.coordinator.UpdateTime()

suite.initTestZone()
}

func (suite *AppTestSuite) initTestZone() {
// test zone
zone := icstypes.Zone{
ConnectionId: suite.path.EndpointA.ConnectionID,
ChainId: suite.chainB.ChainID,
AccountPrefix: "bcosmos",
LocalDenom: "uqatom",
BaseDenom: "uatom",
MultiSend: false,
LiquidityModule: true,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)

// cosmos zone
zone = icstypes.Zone{
ConnectionId: "connection-77001",
ChainId: "cosmoshub-4",
AccountPrefix: "cosmos",
LocalDenom: "uqatom",
BaseDenom: "uatom",
MultiSend: false,
LiquidityModule: false,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)

// osmosis zone
zone = icstypes.Zone{
ConnectionId: "connection-77002",
ChainId: "osmosis-1",
AccountPrefix: "osmo",
LocalDenom: "uqosmo",
BaseDenom: "uosmo",
MultiSend: false,
LiquidityModule: true,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)
// uni-5 zone
zone = icstypes.Zone{
ConnectionId: "connection-77003",
ChainId: "uni-5",
AccountPrefix: "juno",
LocalDenom: "uqjunox",
BaseDenom: "ujunox",
MultiSend: false,
LiquidityModule: true,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetZone(suite.chainA.GetContext(), &zone)

reciept := icstypes.Receipt{
ChainId: "uni-5",
Sender: utils.GenerateAccAddressForTest().String(),
Txhash: "TestDeposit01",
Amount: sdk.NewCoins(
sdk.NewCoin(
"ujunox",
sdk.NewIntFromUint64(2000000), // 20% deposit
),
),
}

suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetReceipt(suite.chainA.GetContext(), reciept)

ubRecord := icstypes.UnbondingRecord{
ChainId: "uni-5",
EpochNumber: 1,
Validator: "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn",
RelatedTxhash: []string{"ABC012"},
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetUnbondingRecord(suite.chainA.GetContext(), ubRecord)

rdRecord := icstypes.RedelegationRecord{
ChainId: "uni-5",
EpochNumber: 1,
Source: "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn",
Destination: "junovaloper1z89utvygweg5l56fsk8ak7t6hh88fd0aa9ywed",
Amount: 3000000,
CompletionTime: time.Time(suite.chainA.GetContext().BlockTime().Add(time.Hour)),
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetRedelegationRecord(suite.chainA.GetContext(), rdRecord)

rdRecord = icstypes.RedelegationRecord{
ChainId: "osmosis-1",
EpochNumber: 1,
Source: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc",
Destination: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk",
Amount: 3000000,
CompletionTime: time.Time{},
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetRedelegationRecord(suite.chainA.GetContext(), rdRecord)

delRecord := icstypes.Delegation{
Amount: sdk.NewCoin(zone.BaseDenom, sdk.NewInt(17000)),
DelegationAddress: "juno1z89utvygweg5l56fsk8ak7t6hh88fd0azcjpz5",
Height: 10,
ValidatorAddress: "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn",
RedelegationEnd: -62135596800,
}

suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetDelegation(suite.chainA.GetContext(), &zone, delRecord)

wRecord := icstypes.WithdrawalRecord{
ChainId: "uni-5",
Delegator: utils.GenerateAccAddressForTest().String(),
Distribution: []*icstypes.Distribution{
{Valoper: "junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn", Amount: 1000000},
{Valoper: "junovaloper1z89utvygweg5l56fsk8ak7t6hh88fd0aa9ywed", Amount: 1000000},
},
Recipient: "juno1z89utvygweg5l56fsk8ak7t6hh88fd0azcjpz5",
Amount: sdk.NewCoins(sdk.NewCoin("ujunox", sdk.NewInt(4000000))),
BurnAmount: sdk.NewCoin("ujunox", sdk.NewInt(4000000)),
Txhash: "7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
Status: icskeeper.WithdrawStatusQueued,
}
suite.GetQuicksilverApp(suite.chainA).InterchainstakingKeeper.SetWithdrawalRecord(suite.chainA.GetContext(), wRecord)

err := suite.GetQuicksilverApp(suite.chainA).BankKeeper.MintCoins(suite.chainA.GetContext(), tokenfactorytypes.ModuleName, sdk.NewCoins(sdk.NewCoin("uqjunox", sdkmath.NewInt(202000000))))
if err != nil {
return
}
addr1, err := utils.AccAddressFromBech32("quick17v9kk34km3w6hdjs2sn5s5qjdu2zrm0m3rgtmq", "quick")
if err != nil {
return
}
addr2, err := utils.AccAddressFromBech32("quick16x03wcp37kx5e8ehckjxvwcgk9j0cqnhcccnty", "quick")
if err != nil {
return
}

err = suite.GetQuicksilverApp(suite.chainA).BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), tokenfactorytypes.ModuleName, addr1, sdk.NewCoins(sdk.NewCoin("uqjunox", sdkmath.NewInt(1600000))))
if err != nil {
return
}
err = suite.GetQuicksilverApp(suite.chainA).BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), tokenfactorytypes.ModuleName, addr2, sdk.NewCoins(sdk.NewCoin("uqjunox", sdkmath.NewInt(200000000))))
if err != nil {
return
}
err = suite.GetQuicksilverApp(suite.chainA).BankKeeper.SendCoinsFromModuleToModule(suite.chainA.GetContext(), tokenfactorytypes.ModuleName, icstypes.EscrowModuleAccount, sdk.NewCoins(sdk.NewCoin("uqjunox", sdkmath.NewInt(400000))))
if err != nil {
return
}
}

func (s *AppTestSuite) TestV010400rc6UpgradeHandler() {
app := s.GetQuicksilverApp(s.chainA)
handler := v010205UpgradeHandler(app)
ctx := s.chainA.GetContext()

expectedVal := sdk.NewDec(50000000000000).Quo(sdk.NewDec(365))
expectedProportions := minttypes.DistributionProportions{
Staking: sdk.NewDecWithPrec(80, 2),
PoolIncentives: sdk.NewDecWithPrec(17, 2),
ParticipationRewards: sdk.NewDec(0),
CommunityPool: sdk.NewDecWithPrec(3, 2),
}
_, err := handler(ctx, types.Plan{}, app.mm.GetVersionMap())
s.Require().NoError(err)

// assert EpochProvisions
minter := app.MintKeeper.GetMinter(ctx)
s.Require().Equal(expectedVal, minter.EpochProvisions)

// assert DistributionProportions
params := app.MintKeeper.GetParams(ctx)
s.Require().Equal(expectedProportions, params.DistributionProportions)

}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/iam v0.7.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/errors v1.0.0-beta.7
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down
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 {}
Loading