mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-20 15:05:21 +00:00
Add IBC markets to pricefeed migration (#1131)
* Add ibc markets to pricefeed * Default empty oracles if no markets * Update pricefeed migration tests * Add ibc markets to testdata genesis pricefeed * Add existing pricefeed markets and new ibc markets to committee permissions * Remove stray empty branch * Panic on committee migration if pricefeed app state is missing * Remove redundant import
This commit is contained in:
parent
d71f406ceb
commit
1a51d1fb00
@ -55,12 +55,19 @@ func migrateKavaAppState(appState genutiltypes.AppMap, clientCtx client.Context)
|
||||
|
||||
// Migrate x/committee
|
||||
if appState[v015committee.ModuleName] != nil {
|
||||
if appState[v015pricefeed.ModuleName] == nil {
|
||||
panic("pricefeed app state is missing, committee migration requires pricefeed app state")
|
||||
}
|
||||
|
||||
var pricefeedGenState v015pricefeed.GenesisState
|
||||
v15Codec.MustUnmarshalJSON(appState[v015pricefeed.ModuleName], &pricefeedGenState)
|
||||
|
||||
// unmarshal relative source genesis application state
|
||||
var genState v015committee.GenesisState
|
||||
v15Codec.MustUnmarshalJSON(appState[v015committee.ModuleName], &genState)
|
||||
|
||||
// replace migrated genstate with previous genstate
|
||||
appState[v015committee.ModuleName] = v16Codec.MustMarshalJSON(v016committee.Migrate(genState))
|
||||
appState[v015committee.ModuleName] = v16Codec.MustMarshalJSON(v016committee.Migrate(genState, pricefeedGenState))
|
||||
}
|
||||
|
||||
// Migrate x/bep3
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
v036supply "github.com/cosmos/cosmos-sdk/x/bank/legacy/v036"
|
||||
v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v038"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
genutil "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
@ -46,7 +45,7 @@ func TestMigrateFull(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
encodingConfig := app.MakeEncodingConfig()
|
||||
var appMap genutil.AppMap
|
||||
var appMap genutiltypes.AppMap
|
||||
err = tmjson.Unmarshal(newGenDoc.AppState, &appMap)
|
||||
assert.NoError(t, err)
|
||||
err = app.ModuleBasics.ValidateGenesis(encodingConfig.Marshaler, encodingConfig.TxConfig, appMap)
|
||||
|
120
migrate/v0_16/testdata/genesis-v16.json
vendored
120
migrate/v0_16/testdata/genesis-v16.json
vendored
@ -453,6 +453,76 @@
|
||||
"market_id": "bnb:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "atom",
|
||||
"market_id": "atom:usd",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "atom",
|
||||
"market_id": "atom:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "akt",
|
||||
"market_id": "akt:usd",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "akt",
|
||||
"market_id": "akt:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "luna",
|
||||
"market_id": "luna:usd",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "luna",
|
||||
"market_id": "luna:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "osmo",
|
||||
"market_id": "osmo:usd",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "osmo",
|
||||
"market_id": "osmo:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "ust",
|
||||
"market_id": "ust:usd",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"base_asset": "ust",
|
||||
"market_id": "ust:usd:30",
|
||||
"oracles": ["kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"],
|
||||
"quote_asset": "usd"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1382,6 +1452,56 @@
|
||||
"key": "market_id",
|
||||
"val": "busd:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "atom:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "atom:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "akt:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "akt:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "luna:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "luna:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "osmo:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "osmo:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "ust:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "ust:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -24,6 +24,8 @@ import (
|
||||
v016hardtypes "github.com/kava-labs/kava/x/hard/types"
|
||||
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
|
||||
v016kavadist "github.com/kava-labs/kava/x/kavadist/types"
|
||||
v015pricefeed "github.com/kava-labs/kava/x/pricefeed/legacy/v0_15"
|
||||
v016pricefeedmigration "github.com/kava-labs/kava/x/pricefeed/legacy/v0_16"
|
||||
v016pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
)
|
||||
|
||||
@ -61,7 +63,11 @@ type subspaceKeyPair struct {
|
||||
}
|
||||
|
||||
// migrateSubParamPermissions converts v15 SubParamChangePermissions to v16 ParamsChangePermission
|
||||
func migrateSubParamPermissions(permission v015committee.SubParamChangePermission, isStabilityCommittee bool) *v016committee.ParamsChangePermission {
|
||||
func migrateSubParamPermissions(
|
||||
permission v015committee.SubParamChangePermission,
|
||||
isStabilityCommittee bool,
|
||||
oldPricefeedState v015pricefeed.GenesisState,
|
||||
) *v016committee.ParamsChangePermission {
|
||||
changes := v016committee.AllowedParamsChanges{}
|
||||
|
||||
// migrate allowed params
|
||||
@ -171,6 +177,39 @@ func migrateSubParamPermissions(permission v015committee.SubParamChangePermissio
|
||||
requirement.AllowedSubparamAttrChanges = allowed
|
||||
requirements = append(requirements, requirement)
|
||||
}
|
||||
|
||||
if isStabilityCommittee {
|
||||
// Add permissions for existing pricefeed markets that are missing in allowed_markets
|
||||
outer:
|
||||
for _, oldPricefeedMarket := range oldPricefeedState.Params.Markets {
|
||||
// Skip if this oldPricefeedMarket already exists in requirements
|
||||
for _, marketRequirement := range requirements {
|
||||
if marketRequirement.Val == oldPricefeedMarket.MarketID {
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
|
||||
requirement := v016committee.SubparamRequirement{
|
||||
Key: "market_id",
|
||||
Val: oldPricefeedMarket.MarketID,
|
||||
AllowedSubparamAttrChanges: []string{"active"},
|
||||
}
|
||||
|
||||
requirements = append(requirements, requirement)
|
||||
}
|
||||
|
||||
// Add new IBC denoms for stability committee
|
||||
for _, market := range v016pricefeedmigration.NewIBCMarkets {
|
||||
requirement := v016committee.SubparamRequirement{
|
||||
Key: "market_id",
|
||||
Val: market.MarketID,
|
||||
AllowedSubparamAttrChanges: []string{"active"},
|
||||
}
|
||||
|
||||
requirements = append(requirements, requirement)
|
||||
}
|
||||
}
|
||||
|
||||
change.MultiSubparamsRequirements = requirements
|
||||
changes = append(changes, change)
|
||||
}
|
||||
@ -215,7 +254,11 @@ func migrateSubParamPermissions(permission v015committee.SubParamChangePermissio
|
||||
}
|
||||
}
|
||||
|
||||
func migratePermission(v015permission v015committee.Permission, isStabilityCommittee bool) *codectypes.Any {
|
||||
func migratePermission(
|
||||
v015permission v015committee.Permission,
|
||||
isStabilityCommittee bool,
|
||||
oldPricefeedState v015pricefeed.GenesisState,
|
||||
) *codectypes.Any {
|
||||
var protoProposal proto.Message
|
||||
|
||||
switch v015permission := v015permission.(type) {
|
||||
@ -246,7 +289,7 @@ func migratePermission(v015permission v015committee.Permission, isStabilityCommi
|
||||
}
|
||||
case v015committee.SubParamChangePermission:
|
||||
{
|
||||
protoProposal = migrateSubParamPermissions(v015permission, isStabilityCommittee)
|
||||
protoProposal = migrateSubParamPermissions(v015permission, isStabilityCommittee, oldPricefeedState)
|
||||
}
|
||||
default:
|
||||
panic(fmt.Errorf("'%s' is not a valid permission", v015permission))
|
||||
@ -274,7 +317,7 @@ func migrateTallyOption(oldTallyOption v015committee.TallyOption) v016committee.
|
||||
}
|
||||
}
|
||||
|
||||
func migrateCommittee(committee v015committee.Committee) *codectypes.Any {
|
||||
func migrateCommittee(committee v015committee.Committee, oldPricefeedState v015pricefeed.GenesisState) *codectypes.Any {
|
||||
var protoProposal proto.Message
|
||||
switch committee := committee.(type) {
|
||||
case v015committee.MemberCommittee:
|
||||
@ -282,7 +325,7 @@ func migrateCommittee(committee v015committee.Committee) *codectypes.Any {
|
||||
permissions := make([]*codectypes.Any, len(committee.Permissions))
|
||||
for i, permission := range committee.Permissions {
|
||||
isStabilityCommittee := committee.GetID() == 1
|
||||
permissions[i] = migratePermission(permission, isStabilityCommittee)
|
||||
permissions[i] = migratePermission(permission, isStabilityCommittee, oldPricefeedState)
|
||||
}
|
||||
|
||||
protoProposal = &v016committee.MemberCommittee{
|
||||
@ -301,7 +344,7 @@ func migrateCommittee(committee v015committee.Committee) *codectypes.Any {
|
||||
{
|
||||
permissions := make([]*codectypes.Any, len(committee.Permissions))
|
||||
for i, permission := range committee.Permissions {
|
||||
permissions[i] = migratePermission(permission, false)
|
||||
permissions[i] = migratePermission(permission, false, oldPricefeedState)
|
||||
}
|
||||
|
||||
protoProposal = &v016committee.TokenCommittee{
|
||||
@ -322,12 +365,6 @@ func migrateCommittee(committee v015committee.Committee) *codectypes.Any {
|
||||
panic(fmt.Errorf("'%s' is not a valid committee", committee))
|
||||
}
|
||||
|
||||
// Make some updates to the stability committee
|
||||
if committee.GetID() == 1 {
|
||||
// Add requirement to collatora params
|
||||
|
||||
}
|
||||
|
||||
// Convert the content into Any.
|
||||
contentAny, err := codectypes.NewAnyWithValue(protoProposal)
|
||||
if err != nil {
|
||||
@ -337,10 +374,10 @@ func migrateCommittee(committee v015committee.Committee) *codectypes.Any {
|
||||
return contentAny
|
||||
}
|
||||
|
||||
func migrateCommittees(v015committees v015committee.Committees) []*codectypes.Any {
|
||||
func migrateCommittees(v015committees v015committee.Committees, oldPricefeedState v015pricefeed.GenesisState) []*codectypes.Any {
|
||||
committees := make([]*codectypes.Any, len(v015committees))
|
||||
for i, committee := range v015committees {
|
||||
committees[i] = migrateCommittee(committee)
|
||||
committees[i] = migrateCommittee(committee, oldPricefeedState)
|
||||
}
|
||||
return committees
|
||||
}
|
||||
@ -477,10 +514,13 @@ func migrateVotes(v15votes []v015committee.Vote) []v016committee.Vote {
|
||||
return votes
|
||||
}
|
||||
|
||||
func Migrate(oldState v015committee.GenesisState) *v016committee.GenesisState {
|
||||
func Migrate(
|
||||
oldState v015committee.GenesisState,
|
||||
oldPricefeedState v015pricefeed.GenesisState,
|
||||
) *v016committee.GenesisState {
|
||||
newState := v016committee.GenesisState{
|
||||
NextProposalID: oldState.NextProposalID,
|
||||
Committees: migrateCommittees(oldState.Committees),
|
||||
Committees: migrateCommittees(oldState.Committees, oldPricefeedState),
|
||||
Proposals: migrateProposals(oldState.Proposals),
|
||||
Votes: migrateVotes(oldState.Votes),
|
||||
}
|
||||
|
@ -356,8 +356,9 @@ func (s *migrateTestSuite) TestMigrate_Committee_SubparamPermissions() {
|
||||
}
|
||||
expectedProposal, err := v016committee.NewMemberCommittee(2, "test", s.addresses, []v016committee.Permission{tc.v016permission}, oldCommittee.VoteThreshold, oldCommittee.ProposalDuration, v016committee.TALLY_OPTION_FIRST_PAST_THE_POST)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.v15genstate.Committees = []v015committee.Committee{oldCommittee}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Committees, 1)
|
||||
s.Equal(expectedProposal, genState.GetCommittees()[0])
|
||||
})
|
||||
|
@ -23,15 +23,18 @@ import (
|
||||
v016committee "github.com/kava-labs/kava/x/committee/types"
|
||||
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
|
||||
v016kavadist "github.com/kava-labs/kava/x/kavadist/types"
|
||||
v015pricefeed "github.com/kava-labs/kava/x/pricefeed/legacy/v0_15"
|
||||
v016pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
)
|
||||
|
||||
type migrateTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
addresses []sdk.AccAddress
|
||||
v15genstate v015committee.GenesisState
|
||||
cdc codec.Codec
|
||||
legacyCdc *codec.LegacyAmino
|
||||
addresses []sdk.AccAddress
|
||||
v15genstate v015committee.GenesisState
|
||||
v15pricefeedgenstate v015pricefeed.GenesisState
|
||||
cdc codec.Codec
|
||||
legacyCdc *codec.LegacyAmino
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) SetupTest() {
|
||||
@ -64,17 +67,69 @@ func (s *migrateTestSuite) TestMigrate_JSON() {
|
||||
file := filepath.Join("testdata", "v15-committee.json")
|
||||
data, err := ioutil.ReadFile(file)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = s.legacyCdc.UnmarshalJSON(data, &s.v15genstate)
|
||||
s.Require().NoError(err)
|
||||
genstate := Migrate(s.v15genstate)
|
||||
|
||||
pricefeedFile := filepath.Join("testdata", "v15-pricefeed.json")
|
||||
pricefeedData, err := ioutil.ReadFile(pricefeedFile)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = s.legacyCdc.UnmarshalJSON(pricefeedData, &s.v15pricefeedgenstate)
|
||||
s.Require().NoError(err)
|
||||
|
||||
genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
actual := s.cdc.MustMarshalJSON(genstate)
|
||||
|
||||
file = filepath.Join("testdata", "v16-committee.json")
|
||||
expected, err := ioutil.ReadFile(file)
|
||||
|
||||
s.Require().NoError(err)
|
||||
s.Require().JSONEq(string(expected), string(actual))
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_PricefeedPermissions() {
|
||||
file := filepath.Join("testdata", "v15-committee.json")
|
||||
data, err := ioutil.ReadFile(file)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = s.legacyCdc.UnmarshalJSON(data, &s.v15genstate)
|
||||
s.Require().NoError(err)
|
||||
|
||||
pricefeedFile := filepath.Join("testdata", "v15-pricefeed.json")
|
||||
pricefeedData, err := ioutil.ReadFile(pricefeedFile)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = s.legacyCdc.UnmarshalJSON(pricefeedData, &s.v15pricefeedgenstate)
|
||||
s.Require().NoError(err)
|
||||
|
||||
genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
|
||||
var uniqueMarkets = make(map[string]bool)
|
||||
|
||||
for _, permission := range genstate.GetCommittees()[0].GetPermissions() {
|
||||
paramChangePermission, ok := permission.(v016committee.ParamsChangePermission)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, allowedParamChanges := range paramChangePermission.AllowedParamsChanges {
|
||||
if allowedParamChanges.Subspace == v016pricefeedtypes.ModuleName {
|
||||
for _, req := range allowedParamChanges.MultiSubparamsRequirements {
|
||||
_, found := uniqueMarkets[req.Val]
|
||||
s.Require().Falsef(
|
||||
found,
|
||||
"pricefeed market MultiSubparamsRequirement for %v is duplicated",
|
||||
req.Val,
|
||||
)
|
||||
|
||||
uniqueMarkets[req.Val] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_TokenCommittee() {
|
||||
oldTokenCommittee := v015committee.TokenCommittee{
|
||||
BaseCommittee: v015committee.BaseCommittee{
|
||||
@ -89,10 +144,12 @@ func (s *migrateTestSuite) TestMigrate_TokenCommittee() {
|
||||
Quorum: sdk.NewDec(40),
|
||||
TallyDenom: "ukava",
|
||||
}
|
||||
|
||||
expectedTokenCommittee, err := v016committee.NewTokenCommittee(1, "test", s.addresses, []v016committee.Permission{}, oldTokenCommittee.VoteThreshold, oldTokenCommittee.ProposalDuration, v016committee.TALLY_OPTION_DEADLINE, oldTokenCommittee.Quorum, oldTokenCommittee.TallyDenom)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.v15genstate.Committees = []v015committee.Committee{oldTokenCommittee}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Committees, 1)
|
||||
s.Equal(expectedTokenCommittee, genState.GetCommittees()[0])
|
||||
}
|
||||
@ -136,7 +193,7 @@ func (s *migrateTestSuite) TestMigrate_Committee_TallyOption() {
|
||||
expectedProposal, err := v016committee.NewMemberCommittee(2, "test", s.addresses, []v016committee.Permission{}, oldCommittee.VoteThreshold, oldCommittee.ProposalDuration, tc.v016tallyOption)
|
||||
s.Require().NoError(err)
|
||||
s.v15genstate.Committees = []v015committee.Committee{oldCommittee}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Committees, 1)
|
||||
s.Equal(expectedProposal.GetTallyOption(), genState.GetCommittees()[0].GetTallyOption())
|
||||
})
|
||||
@ -212,7 +269,7 @@ func (s *migrateTestSuite) TestMigrate_Committee_Permissions() {
|
||||
expectedProposal, err := v016committee.NewMemberCommittee(2, "test", s.addresses, []v016committee.Permission{tc.v016permission}, oldCommittee.VoteThreshold, oldCommittee.ProposalDuration, v016committee.TALLY_OPTION_FIRST_PAST_THE_POST)
|
||||
s.Require().NoError(err)
|
||||
s.v15genstate.Committees = []v015committee.Committee{oldCommittee}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Committees, 1)
|
||||
s.Equal(expectedProposal, genState.GetCommittees()[0])
|
||||
})
|
||||
@ -323,7 +380,7 @@ func (s *migrateTestSuite) TestMigrate_Proposals() {
|
||||
expectedProposal, err := v016committee.NewProposal(tc.v016proposal, 1, 2, deadline)
|
||||
s.Require().NoError(err)
|
||||
s.v15genstate.Proposals = []v015committee.Proposal{oldProposal}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Proposals, 1)
|
||||
s.Equal(expectedProposal, genState.Proposals[0])
|
||||
})
|
||||
@ -371,7 +428,7 @@ func (s *migrateTestSuite) TestMigrate_Votes() {
|
||||
VoteType: tc.v016VoteType,
|
||||
}
|
||||
s.v15genstate.Votes = []v015committee.Vote{oldVote}
|
||||
genState := Migrate(s.v15genstate)
|
||||
genState := Migrate(s.v15genstate, s.v15pricefeedgenstate)
|
||||
s.Require().Len(genState.Votes, 1)
|
||||
s.Equal(expectedVote, genState.Votes[0])
|
||||
})
|
||||
|
312
x/committee/legacy/v0_16/testdata/v15-pricefeed.json
vendored
Normal file
312
x/committee/legacy/v0_16/testdata/v15-pricefeed.json
vendored
Normal file
@ -0,0 +1,312 @@
|
||||
{
|
||||
"params": {
|
||||
"markets": [
|
||||
{
|
||||
"market_id": "bnb:usd",
|
||||
"base_asset": "bnb",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "bnb:usd:30",
|
||||
"base_asset": "bnb",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "btc:usd",
|
||||
"base_asset": "btc",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "btc:usd:30",
|
||||
"base_asset": "btc",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "xrp:usd",
|
||||
"base_asset": "xrp",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "xrp:usd:30",
|
||||
"base_asset": "xrp",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "busd:usd",
|
||||
"base_asset": "busd",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "busd:usd:30",
|
||||
"base_asset": "busd",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "kava:usd",
|
||||
"base_asset": "kava",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "kava:usd:30",
|
||||
"base_asset": "kava",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "hard:usd",
|
||||
"base_asset": "hard",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "hard:usd:30",
|
||||
"base_asset": "hard",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "usdx:usd",
|
||||
"base_asset": "usdx",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "usdx:usd:30",
|
||||
"base_asset": "usdx",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "usdx:usd:720",
|
||||
"base_asset": "usdx",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "swp:usd",
|
||||
"base_asset": "swp",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "swp:usd:30",
|
||||
"base_asset": "swp",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava12dyshua9nkvx9w8ywp72wdnzrc4t4mnnycz0dl",
|
||||
"kava1tuxyepdrkwraa22k99w04c0wa64tgh70mv87fs",
|
||||
"kava1ueak7nzesm3pnev6lngp6lgk0ry02djz8pjpcg",
|
||||
"kava1sl62nqm89c780yxm3m9lp3tacmpnfljq6tytvl",
|
||||
"kava1ujfrlcd0ted58mzplnyxzklsw0sqevlgxndanp",
|
||||
"kava17fatl3wzxvk4rwfu3tqsctdp5x9vute67j9ufj",
|
||||
"kava19rjk5qmmwywnzfccwzyn02jywgpwjqf60afj92",
|
||||
"kava1xd39avn2f008jmvua0eupg39zsp2xn3wf802vn",
|
||||
"kava1pt6q4kdmwawr3thm9cd82pq7hml8u84rd0f3jy",
|
||||
"kava13tpwqygswyzupqfggfgh9dmtgthgucn5wpfksh"
|
||||
],
|
||||
"active": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -293,6 +293,101 @@
|
||||
"key": "market_id",
|
||||
"val": "busd:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "kava:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "kava:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "hard:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "hard:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "usdx:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "usdx:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "usdx:usd:720",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "swp:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "swp:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "atom:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "atom:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "akt:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "akt:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "luna:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "luna:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "osmo:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "osmo:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "ust:usd",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
},
|
||||
{
|
||||
"key": "market_id",
|
||||
"val": "ust:usd:30",
|
||||
"allowed_subparam_attr_changes": ["active"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,10 +1,84 @@
|
||||
package v0_16
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
v015pricefeed "github.com/kava-labs/kava/x/pricefeed/legacy/v0_15"
|
||||
v016pricefeed "github.com/kava-labs/kava/x/pricefeed/types"
|
||||
)
|
||||
|
||||
var NewIBCMarkets = []v016pricefeed.Market{
|
||||
{
|
||||
MarketID: "atom:usd",
|
||||
BaseAsset: "atom",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "atom:usd:30",
|
||||
BaseAsset: "atom",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "akt:usd",
|
||||
BaseAsset: "akt",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "akt:usd:30",
|
||||
BaseAsset: "akt",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "luna:usd",
|
||||
BaseAsset: "luna",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "luna:usd:30",
|
||||
BaseAsset: "luna",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "osmo:usd",
|
||||
BaseAsset: "osmo",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "osmo:usd:30",
|
||||
BaseAsset: "osmo",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "ust:usd",
|
||||
BaseAsset: "ust",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "ust:usd:30",
|
||||
BaseAsset: "ust",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: nil,
|
||||
Active: true,
|
||||
},
|
||||
}
|
||||
|
||||
func migrateParams(params v015pricefeed.Params) v016pricefeed.Params {
|
||||
markets := make(v016pricefeed.Markets, len(params.Markets))
|
||||
for i, market := range params.Markets {
|
||||
@ -16,9 +90,28 @@ func migrateParams(params v015pricefeed.Params) v016pricefeed.Params {
|
||||
Active: market.Active,
|
||||
}
|
||||
}
|
||||
|
||||
markets = addIbcMarkets(markets)
|
||||
|
||||
return v016pricefeed.Params{Markets: markets}
|
||||
}
|
||||
|
||||
func addIbcMarkets(markets v016pricefeed.Markets) v016pricefeed.Markets {
|
||||
var oracles []types.AccAddress
|
||||
|
||||
if len(markets) > 0 {
|
||||
oracles = markets[0].Oracles
|
||||
}
|
||||
|
||||
for _, newMarket := range NewIBCMarkets {
|
||||
// newMarket is a copy, should not affect other uses of NewIBCMarkets
|
||||
newMarket.Oracles = oracles
|
||||
markets = append(markets, newMarket)
|
||||
}
|
||||
|
||||
return markets
|
||||
}
|
||||
|
||||
func migratePostedPrices(oldPostedPrices v015pricefeed.PostedPrices) v016pricefeed.PostedPrices {
|
||||
newPrices := make(v016pricefeed.PostedPrices, len(oldPostedPrices))
|
||||
for i, price := range oldPostedPrices {
|
||||
|
@ -42,7 +42,7 @@ func (s *migrateTestSuite) SetupTest() {
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_JSON() {
|
||||
// Migrate v15 pricefeed to v16
|
||||
data := `{
|
||||
v15Params := `{
|
||||
"params": {
|
||||
"markets": [
|
||||
{
|
||||
@ -76,14 +76,145 @@ func (s *migrateTestSuite) TestMigrate_JSON() {
|
||||
}
|
||||
]
|
||||
}`
|
||||
err := s.legacyCdc.UnmarshalJSON([]byte(data), &s.v15genstate)
|
||||
|
||||
expectedV16Params := `{
|
||||
"params": {
|
||||
"markets": [
|
||||
{
|
||||
"market_id": "bnb:usd",
|
||||
"base_asset": "bnb",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "bnb:usd:30",
|
||||
"base_asset": "bnb",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "atom:usd",
|
||||
"base_asset": "atom",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "atom:usd:30",
|
||||
"base_asset": "atom",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "akt:usd",
|
||||
"base_asset": "akt",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "akt:usd:30",
|
||||
"base_asset": "akt",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "luna:usd",
|
||||
"base_asset": "luna",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "luna:usd:30",
|
||||
"base_asset": "luna",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "osmo:usd",
|
||||
"base_asset": "osmo",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "osmo:usd:30",
|
||||
"base_asset": "osmo",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "ust:usd",
|
||||
"base_asset": "ust",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"market_id": "ust:usd:30",
|
||||
"base_asset": "ust",
|
||||
"quote_asset": "usd",
|
||||
"oracles": [
|
||||
"kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em"
|
||||
],
|
||||
"active": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"posted_prices": [
|
||||
{
|
||||
"market_id": "bnb:usd",
|
||||
"oracle_address": "kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em",
|
||||
"price": "215.962650000000001782",
|
||||
"expiry": "2022-07-20T00:00:00Z"
|
||||
},
|
||||
{
|
||||
"market_id": "bnb:usd:30",
|
||||
"oracle_address": "kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em",
|
||||
"price": "217.962650000000001782",
|
||||
"expiry": "2022-07-20T00:00:00Z"
|
||||
}
|
||||
]
|
||||
}`
|
||||
|
||||
err := s.legacyCdc.UnmarshalJSON([]byte(v15Params), &s.v15genstate)
|
||||
s.Require().NoError(err)
|
||||
genstate := Migrate(s.v15genstate)
|
||||
|
||||
// v16 pricefeed json should be the same as v15
|
||||
// v16 pricefeed json should be the same as v15 but with IBC markets added
|
||||
actual := s.cdc.MustMarshalJSON(genstate)
|
||||
|
||||
s.Require().NoError(err)
|
||||
s.Require().JSONEq(data, string(actual))
|
||||
s.Require().JSONEq(expectedV16Params, string(actual))
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_Params() {
|
||||
@ -107,6 +238,76 @@ func (s *migrateTestSuite) TestMigrate_Params() {
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "atom:usd",
|
||||
BaseAsset: "atom",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "atom:usd:30",
|
||||
BaseAsset: "atom",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "akt:usd",
|
||||
BaseAsset: "akt",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "akt:usd:30",
|
||||
BaseAsset: "akt",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "luna:usd",
|
||||
BaseAsset: "luna",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "luna:usd:30",
|
||||
BaseAsset: "luna",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "osmo:usd",
|
||||
BaseAsset: "osmo",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "osmo:usd:30",
|
||||
BaseAsset: "osmo",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "ust:usd",
|
||||
BaseAsset: "ust",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
{
|
||||
MarketID: "ust:usd:30",
|
||||
BaseAsset: "ust",
|
||||
QuoteAsset: "usd",
|
||||
Oracles: s.addresses,
|
||||
Active: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
genState := Migrate(s.v15genstate)
|
||||
|
Loading…
Reference in New Issue
Block a user