mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
update migration command from v0.13 to v0.14 (#880)
* update migration from v0.13 to v0.14 * update dates, add rollback instructions * address review comments
This commit is contained in:
parent
fa97a7db0e
commit
18ee69f480
@ -3,6 +3,7 @@ package migrate
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kava-labs/kava/migrate/v0_14"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -11,8 +12,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/kava-labs/kava/migrate/v0_13"
|
||||
)
|
||||
|
||||
// MigrateGenesisCmd returns a command to execute genesis state migration.
|
||||
@ -31,7 +30,7 @@ func MigrateGenesisCmd(_ *server.Context, cdc *codec.Codec) *cobra.Command {
|
||||
return fmt.Errorf("failed to read genesis document from file %s: %w", importGenesis, err)
|
||||
}
|
||||
|
||||
newGenDoc := v0_13.Migrate(*genDoc)
|
||||
newGenDoc := v0_14.Migrate(*genDoc)
|
||||
|
||||
bz, err := cdc.MarshalJSONIndent(newGenDoc, "", " ")
|
||||
if err != nil {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package v0_13
|
||||
package v0_14
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -17,17 +17,17 @@ import (
|
||||
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/x/bep3"
|
||||
v0_13cdp "github.com/kava-labs/kava/x/cdp"
|
||||
v0_14cdp "github.com/kava-labs/kava/x/cdp"
|
||||
v0_11cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_11"
|
||||
v0_13committee "github.com/kava-labs/kava/x/committee"
|
||||
v0_14committee "github.com/kava-labs/kava/x/committee"
|
||||
v0_11committee "github.com/kava-labs/kava/x/committee/legacy/v0_11"
|
||||
v0_13hard "github.com/kava-labs/kava/x/hard"
|
||||
v0_14hard "github.com/kava-labs/kava/x/hard"
|
||||
v0_11hard "github.com/kava-labs/kava/x/hard/legacy/v0_11"
|
||||
v0_13incentive "github.com/kava-labs/kava/x/incentive"
|
||||
v0_14incentive "github.com/kava-labs/kava/x/incentive"
|
||||
v0_11incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_11"
|
||||
"github.com/kava-labs/kava/x/kavadist"
|
||||
v0_11pricefeed "github.com/kava-labs/kava/x/pricefeed"
|
||||
v0_13pricefeed "github.com/kava-labs/kava/x/pricefeed"
|
||||
v0_14pricefeed "github.com/kava-labs/kava/x/pricefeed"
|
||||
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
|
||||
)
|
||||
|
||||
@ -49,8 +49,8 @@ func Migrate(genDoc tmtypes.GenesisDoc) tmtypes.GenesisDoc {
|
||||
panic(err)
|
||||
}
|
||||
newAppState := MigrateAppState(appStateMap)
|
||||
v0_13Codec := app.MakeCodec()
|
||||
marshaledNewAppState, err := v0_13Codec.MarshalJSON(newAppState)
|
||||
v0_14Codec := app.MakeCodec()
|
||||
marshaledNewAppState, err := v0_14Codec.MarshalJSON(newAppState)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -63,40 +63,40 @@ func Migrate(genDoc tmtypes.GenesisDoc) tmtypes.GenesisDoc {
|
||||
|
||||
// MigrateAppState migrates application state from v0.11 (or v0.12) format to a kava v0.13.x format
|
||||
func MigrateAppState(v0_11AppState genutil.AppMap) genutil.AppMap {
|
||||
v0_13AppState := v0_11AppState
|
||||
v0_14AppState := v0_11AppState
|
||||
cdc := app.MakeCodec()
|
||||
var hardGenState v0_11hard.GenesisState
|
||||
if v0_11AppState[v0_13hard.ModuleName] == nil {
|
||||
if v0_11AppState[v0_14hard.ModuleName] == nil {
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_11hard.ModuleName], &hardGenState)
|
||||
delete(v0_11AppState, v0_11hard.ModuleName)
|
||||
v0_13AppState[v0_13hard.ModuleName] = cdc.MustMarshalJSON(
|
||||
v0_14AppState[v0_14hard.ModuleName] = cdc.MustMarshalJSON(
|
||||
Hard(hardGenState))
|
||||
}
|
||||
delete(v0_13AppState, v0_11hard.ModuleName)
|
||||
delete(v0_14AppState, v0_11hard.ModuleName)
|
||||
if v0_11AppState[v0_11cdp.ModuleName] != nil {
|
||||
var cdpGenState v0_11cdp.GenesisState
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_11cdp.ModuleName], &cdpGenState)
|
||||
delete(v0_11AppState, v0_11cdp.ModuleName)
|
||||
v0_13AppState[v0_13cdp.ModuleName] = cdc.MustMarshalJSON(
|
||||
v0_14AppState[v0_14cdp.ModuleName] = cdc.MustMarshalJSON(
|
||||
CDP(cdpGenState))
|
||||
}
|
||||
if v0_11AppState[v0_11incentive.ModuleName] != nil {
|
||||
var incentiveGenState v0_11incentive.GenesisState
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_13incentive.ModuleName], &incentiveGenState)
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_14incentive.ModuleName], &incentiveGenState)
|
||||
delete(v0_11AppState, v0_11incentive.ModuleName)
|
||||
v0_13AppState[v0_13incentive.ModuleName] = cdc.MustMarshalJSON(Incentive(hardGenState, incentiveGenState))
|
||||
v0_14AppState[v0_14incentive.ModuleName] = cdc.MustMarshalJSON(Incentive(hardGenState, incentiveGenState))
|
||||
}
|
||||
if v0_11AppState[v0_11pricefeed.ModuleName] != nil {
|
||||
var pricefeedGS v0_11pricefeed.GenesisState
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_13pricefeed.ModuleName], &pricefeedGS)
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_14pricefeed.ModuleName], &pricefeedGS)
|
||||
delete(v0_11AppState, v0_11pricefeed.ModuleName)
|
||||
v0_13AppState[v0_13pricefeed.ModuleName] = cdc.MustMarshalJSON(Pricefeed(pricefeedGS))
|
||||
v0_14AppState[v0_14pricefeed.ModuleName] = cdc.MustMarshalJSON(Pricefeed(pricefeedGS))
|
||||
}
|
||||
if v0_11AppState[bep3.ModuleName] != nil {
|
||||
var bep3GS bep3.GenesisState
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[bep3.ModuleName], &bep3GS)
|
||||
delete(v0_11AppState, bep3.ModuleName)
|
||||
v0_13AppState[bep3.ModuleName] = cdc.MustMarshalJSON(Bep3(bep3GS))
|
||||
v0_14AppState[bep3.ModuleName] = cdc.MustMarshalJSON(Bep3(bep3GS))
|
||||
}
|
||||
if v0_11AppState[v0_11committee.ModuleName] != nil {
|
||||
var committeeGS v0_11committee.GenesisState
|
||||
@ -106,32 +106,32 @@ func MigrateAppState(v0_11AppState genutil.AppMap) genutil.AppMap {
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[v0_11committee.ModuleName], &committeeGS)
|
||||
delete(v0_11AppState, v0_11committee.ModuleName)
|
||||
cdc = app.MakeCodec()
|
||||
v0_13AppState[v0_13committee.ModuleName] = cdc.MustMarshalJSON(Committee(committeeGS))
|
||||
v0_14AppState[v0_14committee.ModuleName] = cdc.MustMarshalJSON(Committee(committeeGS))
|
||||
}
|
||||
if v0_11AppState[auth.ModuleName] != nil {
|
||||
var authGS auth.GenesisState
|
||||
cdc.MustUnmarshalJSON(v0_11AppState[auth.ModuleName], &authGS)
|
||||
delete(v0_11AppState, auth.ModuleName)
|
||||
v0_13AppState[auth.ModuleName] = cdc.MustMarshalJSON(Auth(authGS))
|
||||
v0_14AppState[auth.ModuleName] = cdc.MustMarshalJSON(Auth(authGS))
|
||||
}
|
||||
return v0_13AppState
|
||||
return v0_14AppState
|
||||
|
||||
}
|
||||
|
||||
// CDP migrates from a v0.11 cdp genesis state to a v0.13 cdp genesis state
|
||||
func CDP(oldGenState v0_11cdp.GenesisState) v0_13cdp.GenesisState {
|
||||
var newCDPs v0_13cdp.CDPs
|
||||
var newDeposits v0_13cdp.Deposits
|
||||
var newCollateralParams v0_13cdp.CollateralParams
|
||||
var newGenesisAccumulationTimes v0_13cdp.GenesisAccumulationTimes
|
||||
func CDP(oldGenState v0_11cdp.GenesisState) v0_14cdp.GenesisState {
|
||||
var newCDPs v0_14cdp.CDPs
|
||||
var newDeposits v0_14cdp.Deposits
|
||||
var newCollateralParams v0_14cdp.CollateralParams
|
||||
var newGenesisAccumulationTimes v0_14cdp.GenesisAccumulationTimes
|
||||
var previousAccumulationTime time.Time
|
||||
var totalPrincipals v0_13cdp.GenesisTotalPrincipals
|
||||
var totalPrincipals v0_14cdp.GenesisTotalPrincipals
|
||||
newStartingID := oldGenState.StartingCdpID
|
||||
|
||||
totalPrincipalMap := make(map[string]sdk.Int)
|
||||
|
||||
for _, cdp := range oldGenState.CDPs {
|
||||
newCDP := v0_13cdp.NewCDPWithFees(cdp.ID, cdp.Owner, cdp.Collateral, cdp.Type, cdp.Principal, cdp.AccumulatedFees, cdp.FeesUpdated, sdk.OneDec())
|
||||
newCDP := v0_14cdp.NewCDPWithFees(cdp.ID, cdp.Owner, cdp.Collateral, cdp.Type, cdp.Principal, cdp.AccumulatedFees, cdp.FeesUpdated, sdk.OneDec())
|
||||
if previousAccumulationTime.Before(cdp.FeesUpdated) {
|
||||
previousAccumulationTime = cdp.FeesUpdated
|
||||
}
|
||||
@ -145,19 +145,19 @@ func CDP(oldGenState v0_11cdp.GenesisState) v0_13cdp.GenesisState {
|
||||
}
|
||||
|
||||
for _, cp := range oldGenState.Params.CollateralParams {
|
||||
newCollateralParam := v0_13cdp.NewCollateralParam(cp.Denom, cp.Type, cp.LiquidationRatio, cp.DebtLimit, cp.StabilityFee, cp.AuctionSize, cp.LiquidationPenalty, cp.Prefix, cp.SpotMarketID, cp.LiquidationMarketID, sdk.MustNewDecFromStr("0.01"), sdk.NewInt(10), cp.ConversionFactor)
|
||||
newCollateralParam := v0_14cdp.NewCollateralParam(cp.Denom, cp.Type, cp.LiquidationRatio, cp.DebtLimit, cp.StabilityFee, cp.AuctionSize, cp.LiquidationPenalty, cp.Prefix, cp.SpotMarketID, cp.LiquidationMarketID, sdk.MustNewDecFromStr("0.01"), sdk.NewInt(10), cp.ConversionFactor)
|
||||
newCollateralParams = append(newCollateralParams, newCollateralParam)
|
||||
newGenesisAccumulationTime := v0_13cdp.NewGenesisAccumulationTime(cp.Type, previousAccumulationTime, sdk.OneDec())
|
||||
newGenesisAccumulationTime := v0_14cdp.NewGenesisAccumulationTime(cp.Type, previousAccumulationTime, sdk.OneDec())
|
||||
newGenesisAccumulationTimes = append(newGenesisAccumulationTimes, newGenesisAccumulationTime)
|
||||
}
|
||||
|
||||
for _, dep := range oldGenState.Deposits {
|
||||
newDep := v0_13cdp.NewDeposit(dep.CdpID, dep.Depositor, dep.Amount)
|
||||
newDep := v0_14cdp.NewDeposit(dep.CdpID, dep.Depositor, dep.Amount)
|
||||
newDeposits = append(newDeposits, newDep)
|
||||
}
|
||||
|
||||
for ctype, tp := range totalPrincipalMap {
|
||||
totalPrincipal := v0_13cdp.NewGenesisTotalPrincipal(ctype, tp)
|
||||
totalPrincipal := v0_14cdp.NewGenesisTotalPrincipal(ctype, tp)
|
||||
totalPrincipals = append(totalPrincipals, totalPrincipal)
|
||||
}
|
||||
|
||||
@ -165,13 +165,13 @@ func CDP(oldGenState v0_11cdp.GenesisState) v0_13cdp.GenesisState {
|
||||
|
||||
oldDebtParam := oldGenState.Params.DebtParam
|
||||
|
||||
newDebtParam := v0_13cdp.NewDebtParam(oldDebtParam.Denom, oldDebtParam.ReferenceAsset, oldDebtParam.ConversionFactor, oldDebtParam.DebtFloor)
|
||||
newDebtParam := v0_14cdp.NewDebtParam(oldDebtParam.Denom, oldDebtParam.ReferenceAsset, oldDebtParam.ConversionFactor, oldDebtParam.DebtFloor)
|
||||
|
||||
newGlobalDebtLimit := oldGenState.Params.GlobalDebtLimit
|
||||
|
||||
newParams := v0_13cdp.NewParams(newGlobalDebtLimit, newCollateralParams, newDebtParam, oldGenState.Params.SurplusAuctionThreshold, oldGenState.Params.SurplusAuctionLot, oldGenState.Params.DebtAuctionThreshold, oldGenState.Params.DebtAuctionLot, false)
|
||||
newParams := v0_14cdp.NewParams(newGlobalDebtLimit, newCollateralParams, newDebtParam, oldGenState.Params.SurplusAuctionThreshold, oldGenState.Params.SurplusAuctionLot, oldGenState.Params.DebtAuctionThreshold, oldGenState.Params.DebtAuctionLot, false)
|
||||
|
||||
return v0_13cdp.NewGenesisState(
|
||||
return v0_14cdp.NewGenesisState(
|
||||
newParams,
|
||||
newCDPs,
|
||||
newDeposits,
|
||||
@ -184,59 +184,59 @@ func CDP(oldGenState v0_11cdp.GenesisState) v0_13cdp.GenesisState {
|
||||
}
|
||||
|
||||
// Hard migrates from a v0.11 hard (harvest) genesis state to a v0.13 hard genesis state
|
||||
func Hard(genesisState v0_11hard.GenesisState) v0_13hard.GenesisState {
|
||||
v13Deposits := v0_13hard.Deposits{}
|
||||
v13DepositorMap := make(map[string]v0_13hard.Deposit)
|
||||
v13GenesisAccumulationTimes := v0_13hard.GenesisAccumulationTimes{}
|
||||
func Hard(genesisState v0_11hard.GenesisState) v0_14hard.GenesisState {
|
||||
v13Deposits := v0_14hard.Deposits{}
|
||||
v13DepositorMap := make(map[string]v0_14hard.Deposit)
|
||||
v13GenesisAccumulationTimes := v0_14hard.GenesisAccumulationTimes{}
|
||||
v13TotalSupplied := sdk.NewCoins()
|
||||
|
||||
for _, dep := range genesisState.Deposits {
|
||||
v13Deposit, ok := v13DepositorMap[dep.Depositor.String()]
|
||||
if !ok {
|
||||
v13Deposit := v0_13hard.NewDeposit(dep.Depositor, sdk.NewCoins(dep.Amount), v0_13hard.SupplyInterestFactors{v0_13hard.NewSupplyInterestFactor(dep.Amount.Denom, sdk.OneDec())})
|
||||
v13Deposit := v0_14hard.NewDeposit(dep.Depositor, sdk.NewCoins(dep.Amount), v0_14hard.SupplyInterestFactors{v0_14hard.NewSupplyInterestFactor(dep.Amount.Denom, sdk.OneDec())})
|
||||
v13DepositorMap[dep.Depositor.String()] = v13Deposit
|
||||
} else {
|
||||
v13Deposit.Amount = v13Deposit.Amount.Add(dep.Amount)
|
||||
v13Deposit.Index = append(v13Deposit.Index, v0_13hard.NewSupplyInterestFactor(dep.Amount.Denom, sdk.OneDec()))
|
||||
v13Deposit.Index = append(v13Deposit.Index, v0_14hard.NewSupplyInterestFactor(dep.Amount.Denom, sdk.OneDec()))
|
||||
v13DepositorMap[dep.Depositor.String()] = v13Deposit
|
||||
}
|
||||
}
|
||||
|
||||
defaultInterestModel := v0_13hard.NewInterestRateModel(sdk.ZeroDec(), sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("1.0"))
|
||||
newParams := v0_13hard.NewParams(
|
||||
v0_13hard.MoneyMarkets{
|
||||
defaultInterestModel := v0_14hard.NewInterestRateModel(sdk.ZeroDec(), sdk.MustNewDecFromStr("0.05"), sdk.MustNewDecFromStr("0.8"), sdk.MustNewDecFromStr("1.0"))
|
||||
newParams := v0_14hard.NewParams(
|
||||
v0_14hard.MoneyMarkets{
|
||||
|
||||
v0_13hard.NewMoneyMarket("btcb", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "btc:usd", sdk.NewInt(100000000),
|
||||
v0_14hard.NewMoneyMarket("btcb", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "btc:usd", sdk.NewInt(100000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// bnb
|
||||
v0_13hard.NewMoneyMarket("bnb", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "bnb:usd", sdk.NewInt(100000000),
|
||||
v0_14hard.NewMoneyMarket("bnb", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "bnb:usd", sdk.NewInt(100000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// xrpb
|
||||
v0_13hard.NewMoneyMarket("xrpb", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "xrp:usd", sdk.NewInt(100000000),
|
||||
v0_14hard.NewMoneyMarket("xrpb", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "xrp:usd", sdk.NewInt(100000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// busd
|
||||
v0_13hard.NewMoneyMarket("busd", v0_13hard.NewBorrowLimit(true, sdk.MustNewDecFromStr("100000000000000"), sdk.MustNewDecFromStr("0.5")), "busd:usd", sdk.NewInt(100000000),
|
||||
v0_14hard.NewMoneyMarket("busd", v0_14hard.NewBorrowLimit(true, sdk.MustNewDecFromStr("100000000000000"), sdk.MustNewDecFromStr("0.5")), "busd:usd", sdk.NewInt(100000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// usdx
|
||||
v0_13hard.NewMoneyMarket("usdx", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.ZeroDec()), "usdx:usd", sdk.NewInt(1000000),
|
||||
v0_14hard.NewMoneyMarket("usdx", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.ZeroDec()), "usdx:usd", sdk.NewInt(1000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// ukava
|
||||
v0_13hard.NewMoneyMarket("ukava", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "kava:usd", sdk.NewInt(1000000),
|
||||
v0_14hard.NewMoneyMarket("ukava", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "kava:usd", sdk.NewInt(1000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
// hard
|
||||
v0_13hard.NewMoneyMarket("hard", v0_13hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "hard:usd", sdk.NewInt(1000000),
|
||||
v0_14hard.NewMoneyMarket("hard", v0_14hard.NewBorrowLimit(true, sdk.ZeroDec(), sdk.MustNewDecFromStr("0.5")), "hard:usd", sdk.NewInt(1000000),
|
||||
defaultInterestModel,
|
||||
sdk.MustNewDecFromStr("0.025"), sdk.MustNewDecFromStr("0.02"),
|
||||
),
|
||||
@ -253,16 +253,16 @@ func Hard(genesisState v0_11hard.GenesisState) v0_13hard.GenesisState {
|
||||
})
|
||||
|
||||
for _, mm := range newParams.MoneyMarkets {
|
||||
genAccumulationTime := v0_13hard.NewGenesisAccumulationTime(mm.Denom, GenesisTime, sdk.OneDec(), sdk.OneDec())
|
||||
genAccumulationTime := v0_14hard.NewGenesisAccumulationTime(mm.Denom, GenesisTime, sdk.OneDec(), sdk.OneDec())
|
||||
v13GenesisAccumulationTimes = append(v13GenesisAccumulationTimes, genAccumulationTime)
|
||||
}
|
||||
|
||||
return v0_13hard.NewGenesisState(newParams, v13GenesisAccumulationTimes, v13Deposits, v0_13hard.DefaultBorrows, v13TotalSupplied, v0_13hard.DefaultTotalBorrowed, v0_13hard.DefaultTotalReserves)
|
||||
return v0_14hard.NewGenesisState(newParams, v13GenesisAccumulationTimes, v13Deposits, v0_14hard.DefaultBorrows, v13TotalSupplied, v0_14hard.DefaultTotalBorrowed, v0_14hard.DefaultTotalReserves)
|
||||
}
|
||||
|
||||
// Incentive migrates from a v0.11 incentive genesis state to a v0.13 incentive genesis state
|
||||
func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.GenesisState) v0_13incentive.GenesisState {
|
||||
usdxMintingRewardPeriods := v0_13incentive.RewardPeriods{}
|
||||
func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.GenesisState) v0_14incentive.GenesisState {
|
||||
usdxMintingRewardPeriods := v0_14incentive.RewardPeriods{}
|
||||
usdxRewardsPerSecondMap := make(map[string]sdk.Coin)
|
||||
usdxRewardsPerSecondMap["bnb-a"] = sdk.NewCoin("ukava", sdk.NewInt(122354))
|
||||
usdxRewardsPerSecondMap["btcb-a"] = sdk.NewCoin("ukava", sdk.NewInt(158730))
|
||||
@ -276,49 +276,49 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("No rewards per second for collateral type: %s\n", rp.CollateralType))
|
||||
}
|
||||
newRP := v0_13incentive.NewRewardPeriod(true, rp.CollateralType, GenesisTime, RewardEndTime, rewardsPerSecond)
|
||||
newRP := v0_14incentive.NewRewardPeriod(true, rp.CollateralType, GenesisTime, RewardEndTime, rewardsPerSecond)
|
||||
usdxMintingRewardPeriods = append(usdxMintingRewardPeriods, newRP)
|
||||
}
|
||||
|
||||
hardSupplyRewardPeriods := v0_13incentive.MultiRewardPeriods{}
|
||||
hardSupplyRewardPeriods := v0_14incentive.MultiRewardPeriods{}
|
||||
for _, rp := range hardGS.Params.LiquidityProviderSchedules {
|
||||
newRP := v0_13incentive.NewMultiRewardPeriod(true, rp.DepositDenom, rp.Start, rp.End, sdk.NewCoins(rp.RewardsPerSecond))
|
||||
newRP := v0_14incentive.NewMultiRewardPeriod(true, rp.DepositDenom, rp.Start, rp.End, sdk.NewCoins(rp.RewardsPerSecond))
|
||||
hardSupplyRewardPeriods = append(hardSupplyRewardPeriods, newRP)
|
||||
}
|
||||
hardBorrowRewardPeriods := v0_13incentive.MultiRewardPeriods{}
|
||||
hardDelegatorRewardPeriods := v0_13incentive.RewardPeriods{}
|
||||
hardBorrowRewardPeriods := v0_14incentive.MultiRewardPeriods{}
|
||||
hardDelegatorRewardPeriods := v0_14incentive.RewardPeriods{}
|
||||
for _, rp := range hardGS.Params.DelegatorDistributionSchedules {
|
||||
newRP := v0_13incentive.NewRewardPeriod(rp.DistributionSchedule.Active, rp.DistributionSchedule.DepositDenom, rp.DistributionSchedule.Start, rp.DistributionSchedule.End, rp.DistributionSchedule.RewardsPerSecond)
|
||||
newRP := v0_14incentive.NewRewardPeriod(rp.DistributionSchedule.Active, rp.DistributionSchedule.DepositDenom, rp.DistributionSchedule.Start, rp.DistributionSchedule.End, rp.DistributionSchedule.RewardsPerSecond)
|
||||
hardDelegatorRewardPeriods = append(hardDelegatorRewardPeriods, newRP)
|
||||
}
|
||||
params := v0_13incentive.NewParams(usdxMintingRewardPeriods, hardSupplyRewardPeriods, hardBorrowRewardPeriods, hardDelegatorRewardPeriods, v0_13incentive.Multipliers{v0_13incentive.NewMultiplier(v0_13incentive.Small, 1, sdk.MustNewDecFromStr("0.2")), v0_13incentive.NewMultiplier(v0_13incentive.Large, 12, sdk.MustNewDecFromStr("1.0"))}, ClaimEndTime)
|
||||
params := v0_14incentive.NewParams(usdxMintingRewardPeriods, hardSupplyRewardPeriods, hardBorrowRewardPeriods, hardDelegatorRewardPeriods, v0_14incentive.Multipliers{v0_14incentive.NewMultiplier(v0_14incentive.Small, 1, sdk.MustNewDecFromStr("0.2")), v0_14incentive.NewMultiplier(v0_14incentive.Large, 12, sdk.MustNewDecFromStr("1.0"))}, ClaimEndTime)
|
||||
|
||||
usdxGenAccumulationTimes := v0_13incentive.GenesisAccumulationTimes{}
|
||||
usdxGenAccumulationTimes := v0_14incentive.GenesisAccumulationTimes{}
|
||||
|
||||
for _, rp := range params.USDXMintingRewardPeriods {
|
||||
gat := v0_13incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
gat := v0_14incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
usdxGenAccumulationTimes = append(usdxGenAccumulationTimes, gat)
|
||||
}
|
||||
hardSupplyGenAccumulationTimes := v0_13incentive.GenesisAccumulationTimes{}
|
||||
hardSupplyGenAccumulationTimes := v0_14incentive.GenesisAccumulationTimes{}
|
||||
for _, rp := range params.HardSupplyRewardPeriods {
|
||||
gat := v0_13incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
gat := v0_14incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
hardSupplyGenAccumulationTimes = append(hardSupplyGenAccumulationTimes, gat)
|
||||
}
|
||||
hardBorrowGenAccumulationTimes := v0_13incentive.GenesisAccumulationTimes{}
|
||||
hardBorrowGenAccumulationTimes := v0_14incentive.GenesisAccumulationTimes{}
|
||||
for _, rp := range params.HardBorrowRewardPeriods {
|
||||
gat := v0_13incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
gat := v0_14incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
hardBorrowGenAccumulationTimes = append(hardBorrowGenAccumulationTimes, gat)
|
||||
}
|
||||
|
||||
hardDelegatorGenAccumulationTimes := v0_13incentive.GenesisAccumulationTimes{}
|
||||
hardDelegatorGenAccumulationTimes := v0_14incentive.GenesisAccumulationTimes{}
|
||||
|
||||
for _, rp := range params.HardDelegatorRewardPeriods {
|
||||
gat := v0_13incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
gat := v0_14incentive.NewGenesisAccumulationTime(rp.CollateralType, GenesisTime)
|
||||
hardDelegatorGenAccumulationTimes = append(hardDelegatorGenAccumulationTimes, gat)
|
||||
}
|
||||
|
||||
usdxClaims := v0_13incentive.USDXMintingClaims{}
|
||||
usdxClaimMap := make(map[string]v0_13incentive.USDXMintingClaim)
|
||||
usdxClaims := v0_14incentive.USDXMintingClaims{}
|
||||
usdxClaimMap := make(map[string]v0_14incentive.USDXMintingClaim)
|
||||
claimEndMap := make(map[uint64]time.Time)
|
||||
|
||||
for _, cp := range incentiveGS.ClaimPeriods {
|
||||
@ -331,12 +331,12 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
||||
}
|
||||
newClaim, ok := usdxClaimMap[claim.Owner.String()]
|
||||
if !ok {
|
||||
newClaim = v0_13incentive.NewUSDXMintingClaim(claim.Owner, claim.Reward, v0_13incentive.RewardIndexes{v0_13incentive.NewRewardIndex(claim.CollateralType, sdk.ZeroDec())})
|
||||
newClaim = v0_14incentive.NewUSDXMintingClaim(claim.Owner, claim.Reward, v0_14incentive.RewardIndexes{v0_14incentive.NewRewardIndex(claim.CollateralType, sdk.ZeroDec())})
|
||||
} else {
|
||||
newClaim.Reward = newClaim.Reward.Add(claim.Reward)
|
||||
_, found := newClaim.RewardIndexes.GetRewardIndex(claim.CollateralType)
|
||||
if !found {
|
||||
newClaim.RewardIndexes = append(newClaim.RewardIndexes, v0_13incentive.NewRewardIndex(claim.CollateralType, sdk.ZeroDec()))
|
||||
newClaim.RewardIndexes = append(newClaim.RewardIndexes, v0_14incentive.NewRewardIndex(claim.CollateralType, sdk.ZeroDec()))
|
||||
}
|
||||
}
|
||||
usdxClaimMap[newClaim.Owner.String()] = newClaim
|
||||
@ -346,8 +346,8 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
||||
usdxClaims = append(usdxClaims, claim)
|
||||
}
|
||||
|
||||
hardClaims := v0_13incentive.HardLiquidityProviderClaims{}
|
||||
hardClaimMap := make(map[string]v0_13incentive.HardLiquidityProviderClaim)
|
||||
hardClaims := v0_14incentive.HardLiquidityProviderClaims{}
|
||||
hardClaimMap := make(map[string]v0_14incentive.HardLiquidityProviderClaim)
|
||||
|
||||
for _, claim := range hardGS.Claims {
|
||||
newClaim, ok := hardClaimMap[claim.Owner.String()]
|
||||
@ -355,25 +355,25 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
||||
// if claim.Type == "lp" -- hard supply
|
||||
// if claim.Type == "stake" -- hard delegator
|
||||
// hard barrow always empty
|
||||
delegatorIndexes := v0_13incentive.RewardIndexes{}
|
||||
supplyIndexes := v0_13incentive.MultiRewardIndexes{}
|
||||
borrowIndexes := v0_13incentive.MultiRewardIndexes{}
|
||||
delegatorIndexes := v0_14incentive.RewardIndexes{}
|
||||
supplyIndexes := v0_14incentive.MultiRewardIndexes{}
|
||||
borrowIndexes := v0_14incentive.MultiRewardIndexes{}
|
||||
if claim.Type == v0_11hard.Stake {
|
||||
delegatorIndexes = v0_13incentive.RewardIndexes{v0_13incentive.NewRewardIndex(claim.DepositDenom, sdk.ZeroDec())}
|
||||
delegatorIndexes = v0_14incentive.RewardIndexes{v0_14incentive.NewRewardIndex(claim.DepositDenom, sdk.ZeroDec())}
|
||||
}
|
||||
if claim.Type == v0_11hard.LP {
|
||||
supplyIndexes = v0_13incentive.MultiRewardIndexes{v0_13incentive.NewMultiRewardIndex(claim.DepositDenom, v0_13incentive.RewardIndexes{v0_13incentive.NewRewardIndex("hard", sdk.ZeroDec())})}
|
||||
supplyIndexes = v0_14incentive.MultiRewardIndexes{v0_14incentive.NewMultiRewardIndex(claim.DepositDenom, v0_14incentive.RewardIndexes{v0_14incentive.NewRewardIndex("hard", sdk.ZeroDec())})}
|
||||
}
|
||||
newClaim = v0_13incentive.NewHardLiquidityProviderClaim(claim.Owner, sdk.NewCoins(claim.Amount), supplyIndexes, borrowIndexes, delegatorIndexes)
|
||||
newClaim = v0_14incentive.NewHardLiquidityProviderClaim(claim.Owner, sdk.NewCoins(claim.Amount), supplyIndexes, borrowIndexes, delegatorIndexes)
|
||||
} else {
|
||||
newClaim.Reward = newClaim.Reward.Add(claim.Amount)
|
||||
if claim.Type == v0_11hard.Stake {
|
||||
newClaim.DelegatorRewardIndexes = v0_13incentive.RewardIndexes{v0_13incentive.NewRewardIndex(claim.DepositDenom, sdk.ZeroDec())}
|
||||
newClaim.DelegatorRewardIndexes = v0_14incentive.RewardIndexes{v0_14incentive.NewRewardIndex(claim.DepositDenom, sdk.ZeroDec())}
|
||||
}
|
||||
if claim.Type == v0_11hard.LP {
|
||||
_, found := newClaim.SupplyRewardIndexes.GetRewardIndex(claim.DepositDenom)
|
||||
if !found {
|
||||
newClaim.SupplyRewardIndexes = append(newClaim.SupplyRewardIndexes, v0_13incentive.NewMultiRewardIndex(claim.DepositDenom, v0_13incentive.RewardIndexes{v0_13incentive.NewRewardIndex("hard", sdk.ZeroDec())}))
|
||||
newClaim.SupplyRewardIndexes = append(newClaim.SupplyRewardIndexes, v0_14incentive.NewMultiRewardIndex(claim.DepositDenom, v0_14incentive.RewardIndexes{v0_14incentive.NewRewardIndex("hard", sdk.ZeroDec())}))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,7 +387,7 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
||||
sort.Slice(hardClaims, func(i, j int) bool { return hardClaims[i].Owner.String() < hardClaims[j].Owner.String() })
|
||||
sort.Slice(usdxClaims, func(i, j int) bool { return usdxClaims[i].Owner.String() < usdxClaims[j].Owner.String() })
|
||||
|
||||
return v0_13incentive.NewGenesisState(
|
||||
return v0_14incentive.NewGenesisState(
|
||||
params,
|
||||
usdxGenAccumulationTimes,
|
||||
hardSupplyGenAccumulationTimes,
|
||||
@ -446,7 +446,7 @@ func Auth(genesisState auth.GenesisState) auth.GenesisState {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if acc.GetAddress().Equals(supply.NewModuleAddress(v0_13cdp.LiquidatorMacc)) {
|
||||
if acc.GetAddress().Equals(supply.NewModuleAddress(v0_14cdp.LiquidatorMacc)) {
|
||||
liquidatorMaccIndex = idx
|
||||
}
|
||||
if acc.GetAddress().Equals(hardDelegatorAddr) {
|
||||
@ -475,8 +475,8 @@ func Auth(genesisState auth.GenesisState) auth.GenesisState {
|
||||
|
||||
// migrate harvest account to new hard name
|
||||
harvestAcc := genesisState.Accounts[harvestIdx].(*supply.ModuleAccount)
|
||||
harvestAcc.Address = supply.NewModuleAddress(v0_13hard.ModuleAccountName)
|
||||
harvestAcc.Name = v0_13hard.ModuleAccountName
|
||||
harvestAcc.Address = supply.NewModuleAddress(v0_14hard.ModuleAccountName)
|
||||
harvestAcc.Name = v0_14hard.ModuleAccountName
|
||||
harvestAcc.Permissions = []string{supply.Minter}
|
||||
genesisState.Accounts[harvestIdx] = harvestAcc
|
||||
|
||||
@ -531,13 +531,13 @@ func Bep3(genesisState bep3.GenesisState) bep3.GenesisState {
|
||||
}
|
||||
|
||||
// Committee migrates from a v0.11 (or v0.12) committee genesis state to a v0.13 committee genesis state
|
||||
func Committee(genesisState v0_11committee.GenesisState) v0_13committee.GenesisState {
|
||||
committees := []v0_13committee.Committee{}
|
||||
votes := []v0_13committee.Vote{}
|
||||
proposals := []v0_13committee.Proposal{}
|
||||
func Committee(genesisState v0_11committee.GenesisState) v0_14committee.GenesisState {
|
||||
committees := []v0_14committee.Committee{}
|
||||
votes := []v0_14committee.Vote{}
|
||||
proposals := []v0_14committee.Proposal{}
|
||||
|
||||
var newStabilityCommittee v0_13committee.Committee
|
||||
var newSafetyCommittee v0_13committee.Committee
|
||||
var newStabilityCommittee v0_14committee.Committee
|
||||
var newSafetyCommittee v0_14committee.Committee
|
||||
|
||||
for _, com := range genesisState.Committees {
|
||||
if com.ID == 1 {
|
||||
@ -546,33 +546,33 @@ func Committee(genesisState v0_11committee.GenesisState) v0_13committee.GenesisS
|
||||
newStabilityCommittee.Members = com.Members
|
||||
newStabilityCommittee.VoteThreshold = com.VoteThreshold
|
||||
newStabilityCommittee.ProposalDuration = com.ProposalDuration
|
||||
var newStabilityCommitteePermissions []v0_13committee.Permission
|
||||
var newStabilitySubParamPermissions v0_13committee.SubParamChangePermission
|
||||
var newStabilityCommitteePermissions []v0_14committee.Permission
|
||||
var newStabilitySubParamPermissions v0_14committee.SubParamChangePermission
|
||||
|
||||
for _, perm := range com.Permissions {
|
||||
subPerm, ok := perm.(v0_11committee.SubParamChangePermission)
|
||||
if ok {
|
||||
// update AllowedParams
|
||||
var newAllowedParams v0_13committee.AllowedParams
|
||||
var newAllowedParams v0_14committee.AllowedParams
|
||||
for _, ap := range subPerm.AllowedParams {
|
||||
if ap.Subspace == "harvest" {
|
||||
continue
|
||||
}
|
||||
newAP := v0_13committee.AllowedParam(ap)
|
||||
newAP := v0_14committee.AllowedParam(ap)
|
||||
newAllowedParams = append(newAllowedParams, newAP)
|
||||
}
|
||||
hrdaMMAp := v0_13committee.AllowedParam{Subspace: "hard", Key: "MoneyMarkets"}
|
||||
hardLimitAp := v0_13committee.AllowedParam{Subspace: "hard", Key: "MinimumBorrowUSDValue"}
|
||||
hrdaMMAp := v0_14committee.AllowedParam{Subspace: "hard", Key: "MoneyMarkets"}
|
||||
hardLimitAp := v0_14committee.AllowedParam{Subspace: "hard", Key: "MinimumBorrowUSDValue"}
|
||||
newAllowedParams = append(newAllowedParams, hrdaMMAp)
|
||||
newAllowedParams = append(newAllowedParams, hardLimitAp)
|
||||
|
||||
newStabilitySubParamPermissions.AllowedParams = newAllowedParams
|
||||
|
||||
// update AllowedCollateralParams
|
||||
var newCollateralParams v0_13committee.AllowedCollateralParams
|
||||
var newCollateralParams v0_14committee.AllowedCollateralParams
|
||||
collateralTypes := []string{"bnb-a", "busd-a", "busd-b", "btcb-a", "xrpb-a", "ukava-a", "hard-a", "hbtc-a"}
|
||||
for _, cp := range subPerm.AllowedCollateralParams {
|
||||
newCP := v0_13committee.NewAllowedCollateralParam(
|
||||
newCP := v0_14committee.NewAllowedCollateralParam(
|
||||
cp.Type,
|
||||
cp.Denom,
|
||||
cp.LiquidationRatio,
|
||||
@ -597,14 +597,14 @@ func Committee(genesisState v0_11committee.GenesisState) v0_13committee.GenesisS
|
||||
}
|
||||
}
|
||||
if !foundCtype {
|
||||
newCP := v0_13committee.NewAllowedCollateralParam(cType, false, false, true, true, true, false, false, false, false, false, true, true)
|
||||
newCP := v0_14committee.NewAllowedCollateralParam(cType, false, false, true, true, true, false, false, false, false, false, true, true)
|
||||
newCollateralParams = append(newCollateralParams, newCP)
|
||||
}
|
||||
}
|
||||
newStabilitySubParamPermissions.AllowedCollateralParams = newCollateralParams
|
||||
|
||||
// update AllowedDebtParam
|
||||
newDP := v0_13committee.AllowedDebtParam{
|
||||
newDP := v0_14committee.AllowedDebtParam{
|
||||
Denom: subPerm.AllowedDebtParam.Denom,
|
||||
ReferenceAsset: subPerm.AllowedDebtParam.ReferenceAsset,
|
||||
ConversionFactor: subPerm.AllowedDebtParam.ConversionFactor,
|
||||
@ -613,40 +613,40 @@ func Committee(genesisState v0_11committee.GenesisState) v0_13committee.GenesisS
|
||||
newStabilitySubParamPermissions.AllowedDebtParam = newDP
|
||||
|
||||
// update AllowedAssetParams
|
||||
var newAssetParams v0_13committee.AllowedAssetParams
|
||||
var newAssetParams v0_14committee.AllowedAssetParams
|
||||
for _, ap := range subPerm.AllowedAssetParams {
|
||||
newAP := v0_13committee.AllowedAssetParam(ap)
|
||||
newAP := v0_14committee.AllowedAssetParam(ap)
|
||||
newAssetParams = append(newAssetParams, newAP)
|
||||
}
|
||||
newStabilitySubParamPermissions.AllowedAssetParams = newAssetParams
|
||||
|
||||
// Update Allowed Markets
|
||||
var newMarketParams v0_13committee.AllowedMarkets
|
||||
var newMarketParams v0_14committee.AllowedMarkets
|
||||
for _, mp := range subPerm.AllowedMarkets {
|
||||
newMP := v0_13committee.AllowedMarket(mp)
|
||||
newMP := v0_14committee.AllowedMarket(mp)
|
||||
newMarketParams = append(newMarketParams, newMP)
|
||||
}
|
||||
newStabilitySubParamPermissions.AllowedMarkets = newMarketParams
|
||||
|
||||
// Add hard money market committee permissions
|
||||
var newMoneyMarketParams v0_13committee.AllowedMoneyMarkets
|
||||
var newMoneyMarketParams v0_14committee.AllowedMoneyMarkets
|
||||
hardMMDenoms := []string{"bnb", "busd", "btcb", "xrpb", "usdx", "ukava", "hard"}
|
||||
for _, mmDenom := range hardMMDenoms {
|
||||
newMoneyMarketParam := v0_13committee.NewAllowedMoneyMarket(mmDenom, true, false, false, true, true, true)
|
||||
newMoneyMarketParam := v0_14committee.NewAllowedMoneyMarket(mmDenom, true, false, false, true, true, true)
|
||||
newMoneyMarketParams = append(newMoneyMarketParams, newMoneyMarketParam)
|
||||
}
|
||||
newStabilitySubParamPermissions.AllowedMoneyMarkets = newMoneyMarketParams
|
||||
newStabilityCommitteePermissions = append(newStabilityCommitteePermissions, newStabilitySubParamPermissions)
|
||||
}
|
||||
}
|
||||
newStabilityCommitteePermissions = append(newStabilityCommitteePermissions, v0_13committee.TextPermission{})
|
||||
newStabilityCommitteePermissions = append(newStabilityCommitteePermissions, v0_14committee.TextPermission{})
|
||||
newStabilityCommittee.Permissions = newStabilityCommitteePermissions
|
||||
committees = append(committees, newStabilityCommittee)
|
||||
} else {
|
||||
newSafetyCommittee.ID = com.ID
|
||||
newSafetyCommittee.Description = com.Description
|
||||
newSafetyCommittee.Members = com.Members
|
||||
newSafetyCommittee.Permissions = []v0_13committee.Permission{v0_13committee.SoftwareUpgradePermission{}}
|
||||
newSafetyCommittee.Permissions = []v0_14committee.Permission{v0_14committee.SoftwareUpgradePermission{}}
|
||||
newSafetyCommittee.VoteThreshold = com.VoteThreshold
|
||||
newSafetyCommittee.ProposalDuration = com.ProposalDuration
|
||||
committees = append(committees, newSafetyCommittee)
|
||||
@ -654,21 +654,21 @@ func Committee(genesisState v0_11committee.GenesisState) v0_13committee.GenesisS
|
||||
}
|
||||
|
||||
for _, v := range genesisState.Votes {
|
||||
votes = append(votes, v0_13committee.Vote(v))
|
||||
votes = append(votes, v0_14committee.Vote(v))
|
||||
}
|
||||
|
||||
for _, p := range genesisState.Proposals {
|
||||
newPubProp := v0_13committee.PubProposal(p.PubProposal)
|
||||
newProp := v0_13committee.NewProposal(newPubProp, p.ID, p.CommitteeID, p.Deadline)
|
||||
newPubProp := v0_14committee.PubProposal(p.PubProposal)
|
||||
newProp := v0_14committee.NewProposal(newPubProp, p.ID, p.CommitteeID, p.Deadline)
|
||||
proposals = append(proposals, newProp)
|
||||
}
|
||||
return v0_13committee.NewGenesisState(
|
||||
return v0_14committee.NewGenesisState(
|
||||
genesisState.NextProposalID, committees, proposals, votes)
|
||||
}
|
||||
|
||||
// Pricefeed migrates from a v0.11 (or v0.12) pricefeed genesis state to a v0.13 pricefeed genesis state
|
||||
func Pricefeed(genesisState v0_11pricefeed.GenesisState) v0_13pricefeed.GenesisState {
|
||||
newMarkets := v0_13pricefeed.Markets{}
|
||||
func Pricefeed(genesisState v0_11pricefeed.GenesisState) v0_14pricefeed.GenesisState {
|
||||
newMarkets := v0_14pricefeed.Markets{}
|
||||
oracles := genesisState.Params.Markets[0].Oracles
|
||||
|
||||
for _, m := range genesisState.Params.Markets {
|
||||
@ -677,7 +677,7 @@ func Pricefeed(genesisState v0_11pricefeed.GenesisState) v0_13pricefeed.GenesisS
|
||||
usdx := v0_11pricefeed.NewMarket("usdx:usd", "usdx", "usd", oracles, true)
|
||||
newMarkets = append(newMarkets, usdx)
|
||||
|
||||
newPrices := v0_13pricefeed.PostedPrices{}
|
||||
newPrices := v0_14pricefeed.PostedPrices{}
|
||||
|
||||
for _, p := range genesisState.PostedPrices {
|
||||
if p.Expiry.After(GenesisTime) {
|
||||
@ -685,7 +685,7 @@ func Pricefeed(genesisState v0_11pricefeed.GenesisState) v0_13pricefeed.GenesisS
|
||||
}
|
||||
}
|
||||
|
||||
return v0_13pricefeed.NewGenesisState(v0_13pricefeed.NewParams(newMarkets), newPrices)
|
||||
return v0_14pricefeed.NewGenesisState(v0_14pricefeed.NewParams(newMarkets), newPrices)
|
||||
}
|
||||
|
||||
func removeIndex(accs authexported.GenesisAccounts, index int) authexported.GenesisAccounts {
|
@ -1,13 +1,14 @@
|
||||
# Kava-5 Upgrade Instructions
|
||||
# Kava-5.1 Upgrade Instructions
|
||||
|
||||
## Software Version and Key Dates
|
||||
|
||||
* The version of Kava for kava-5 is v0.13.1
|
||||
* Kava-4 validators should prepare to shutdown their nodes March 4th, 2021 at 13:00 UTC
|
||||
* Kava-5 genesis time is set to March 4th, 2021 at 15:00 UTC
|
||||
* The version of cosmos-sdk for kava-5 is v0.39.2
|
||||
* The version of tendermint for kava-5 v0.33.9
|
||||
* The minimum version of golang for kava-5 is 1.13+, 1.15+ has been tested and is recommended.
|
||||
* We will be upgrading from chain-id "kava-6" to chain-id "kava-5.1". This is to keep the features in our roadmap aligned with the features on mainnet going forward.
|
||||
* The version of Kava for kava-5.1 is v0.14.0
|
||||
* Kava-6 validators should prepare to shutdown their nodes March 24th, 2021 at 13:00 UTC by setting `--halt-time` to `1616590800`
|
||||
* Kava-5.1 genesis time is set to March 24th, 2021 at 15:00 UTC
|
||||
* The version of cosmos-sdk for kava-5.1 is v0.39.2
|
||||
* The version of tendermint for kava-5.1 v0.33.9
|
||||
* The minimum version of golang for kava-5.1 is 1.13+, 1.15+ has been tested and is recommended.
|
||||
|
||||
### Risks
|
||||
|
||||
@ -17,44 +18,44 @@ The riskiest thing a validator can do is discover that they made a mistake and r
|
||||
|
||||
### Recovery
|
||||
|
||||
Prior to exporting kava-4 state, validators are encouraged to take a full data snapshot at the export height before proceeding. Snap-shotting depends heavily on infrastructure, but generally this can be done by backing up the .kvd and .kvcli directories.
|
||||
Prior to exporting kava-6 state, validators are encouraged to take a full data snapshot at the export height before proceeding. Snap-shotting depends heavily on infrastructure, but generally this can be done by backing up the .kvd and .kvcli directories.
|
||||
|
||||
It is critically important to back-up the .kvd/data/priv_validator_state.json file after stopping your kvd process. This file is updated every block as your validator participates in consensus rounds. It is a critical file needed to prevent double-signing, in case the upgrade fails and the previous chain needs to be restarted.
|
||||
|
||||
In the event that the upgrade does not succeed, validators and operators must downgrade back to v0.12.2 of the Kava software and restore to their latest snapshot before restarting their nodes.
|
||||
In the event that the upgrade does not succeed, validators and operators must downgrade back to v0.12.4 of the Kava software and restore to their latest snapshot before restarting their nodes.
|
||||
|
||||
## Upgrade Procedure
|
||||
|
||||
### Before the upgrade
|
||||
|
||||
Set your node to produce the final block of kava-4 at __13:00__ UTC March 4th, 2021. To restart your node with that stop time,
|
||||
Set your node to produce the final block of kava-6 at __13:00__ UTC March 24th, 2021. To restart your node with that stop time,
|
||||
|
||||
```sh
|
||||
kvd start --halt-time 1614862800
|
||||
kvd start --halt-time 1616590800
|
||||
```
|
||||
|
||||
You can safely set the halt-time flag at any time.
|
||||
|
||||
### On the day of the upgrade
|
||||
|
||||
__The kava chain is expected to halt at 13:00 UTC, and restart with new software at 15:00 UTC March 4th. Do not stop your node and begin the upgrade before 13:00UTC on March 4th, or you may go offline and be unable to recover until after the upgrade!__
|
||||
__The kava chain is expected to halt at 13:00 UTC, and restart with new software at 15:00 UTC March 24th. Do not stop your node and begin the upgrade before 13:00UTC on March 24th, or you may go offline and be unable to recover until after the upgrade!__
|
||||
|
||||
Kava developers will update this PR with the final block number when it is reached. __Make sure the kvd process is stopped before proceeding and that you have backed up your validator__. Failure to backup your validator could make it impossible to restart your node if the upgrade fails.
|
||||
|
||||
1. Export State (this __MUST__ be done using __v0.12.2__, previous v0.12.x versions will not produce the same genesis hash!)
|
||||
1. Export State (this __MUST__ be done using __v0.12.4__, previous v0.12.x versions will not produce the same genesis hash!)
|
||||
|
||||
```sh
|
||||
kvd export --for-zero-height --height 1267330 > export-genesis.json
|
||||
kvd export --for-zero-height --height PLACEHOLDER > export-genesis.json
|
||||
```
|
||||
|
||||
__Note:__ This can take a while!
|
||||
|
||||
2. Update to kava-5
|
||||
2. Update to kava-5.1
|
||||
|
||||
```sh
|
||||
# in the `kava` folder
|
||||
git pull
|
||||
git checkout v0.13.1
|
||||
git checkout v0.14.0
|
||||
make install
|
||||
|
||||
# verify versions
|
||||
@ -62,8 +63,8 @@ __Note:__ This can take a while!
|
||||
# name: kava
|
||||
# server_name: kvd
|
||||
# client_name: kvcli
|
||||
# version: 0.13.1
|
||||
# commit: 203d7e0063555166808fd560092e6cf64ac19117
|
||||
# version: 0.14.0
|
||||
# commit: PLACEHOLDER
|
||||
# build_tags: netgo,ledger
|
||||
# go: go version go1.15.8 linux/amd64
|
||||
|
||||
@ -74,7 +75,7 @@ __Note:__ This can take a while!
|
||||
# Verify output of genesis migration
|
||||
kvd validate-genesis genesis.json # should say it's valid
|
||||
jq -S -c -M '' genesis.json | shasum -a 256
|
||||
# 5200ab3b16fe6100a67c707688f10e3ee9affeda93a4b472b9bf40faafdd5dc0
|
||||
# PLACEHOLDER
|
||||
|
||||
# Restart node with migrated genesis state
|
||||
cp genesis.json ~/.kvd/config/genesis.json
|
||||
@ -87,4 +88,4 @@ __Note:__ This can take a while!
|
||||
|
||||
### Coordination
|
||||
|
||||
If the kava-5 chain does not launch by March 4, 2021 at 17:00 UTC, the launch should be considered a failure. Validators should restore the state from kava-4 and coordinate a relaunch. In the event of launch failure, coordination will occur in the [Kava discord](https://discord.com/invite/kQzh3Uv).
|
||||
If the kava-5.1 chain does not launch by March 24, 2021 at 17:00 UTC, the launch should be considered a failure and validators should refer to the [rollback]("./rollback.md") instructions to restart the previous kava-6 chain. In the event of launch failure, coordination will occur in the [Kava discord](https://discord.com/invite/kQzh3Uv).
|
@ -1,4 +1,4 @@
|
||||
package v0_13
|
||||
package v0_14
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -20,11 +20,11 @@ import (
|
||||
"github.com/kava-labs/kava/app"
|
||||
"github.com/kava-labs/kava/x/bep3"
|
||||
v0_11cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_11"
|
||||
v0_13committee "github.com/kava-labs/kava/x/committee"
|
||||
v0_14committee "github.com/kava-labs/kava/x/committee"
|
||||
v0_11committee "github.com/kava-labs/kava/x/committee/legacy/v0_11"
|
||||
v0_13hard "github.com/kava-labs/kava/x/hard"
|
||||
v0_14hard "github.com/kava-labs/kava/x/hard"
|
||||
v0_11hard "github.com/kava-labs/kava/x/hard/legacy/v0_11"
|
||||
v0_13incentive "github.com/kava-labs/kava/x/incentive"
|
||||
v0_14incentive "github.com/kava-labs/kava/x/incentive"
|
||||
v0_11incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_11"
|
||||
v0_11pricefeed "github.com/kava-labs/kava/x/pricefeed"
|
||||
validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
|
||||
@ -125,7 +125,7 @@ func TestIncentive(t *testing.T) {
|
||||
require.NotPanics(t, func() {
|
||||
cdc.MustUnmarshalJSON(bz, &oldHarvestGenState)
|
||||
})
|
||||
newGenState := v0_13incentive.GenesisState{}
|
||||
newGenState := v0_14incentive.GenesisState{}
|
||||
require.NotPanics(t, func() {
|
||||
newGenState = Incentive(oldHarvestGenState, oldIncentiveGenState)
|
||||
})
|
||||
@ -145,7 +145,7 @@ func TestHard(t *testing.T) {
|
||||
require.NotPanics(t, func() {
|
||||
cdc.MustUnmarshalJSON(bz, &oldHarvestGenState)
|
||||
})
|
||||
newGenState := v0_13hard.GenesisState{}
|
||||
newGenState := v0_14hard.GenesisState{}
|
||||
require.NotPanics(t, func() {
|
||||
newGenState = Hard(oldHarvestGenState)
|
||||
})
|
||||
@ -175,10 +175,10 @@ func TestCommittee(t *testing.T) {
|
||||
}
|
||||
|
||||
oldSPCP := oldGenState.Committees[0].Permissions[0].(v0_11committee.SubParamChangePermission)
|
||||
newSPCP := newGenState.Committees[0].Permissions[0].(v0_13committee.SubParamChangePermission)
|
||||
require.Equal(t, len(oldSPCP.AllowedParams), len(newSPCP.AllowedParams))
|
||||
newSPCP := newGenState.Committees[0].Permissions[0].(v0_14committee.SubParamChangePermission)
|
||||
require.Equal(t, len(oldSPCP.AllowedParams)-14, len(newSPCP.AllowedParams)) // accounts for removed/redundant keys
|
||||
require.Equal(t, len(oldSPCP.AllowedAssetParams), len(newSPCP.AllowedAssetParams))
|
||||
require.Equal(t, len(oldSPCP.AllowedCollateralParams), len(newSPCP.AllowedCollateralParams))
|
||||
require.Equal(t, len(oldSPCP.AllowedCollateralParams)+3, len(newSPCP.AllowedCollateralParams)) // accounts for new cdp collateral types
|
||||
require.Equal(t, len(oldSPCP.AllowedMarkets), len(newSPCP.AllowedMarkets))
|
||||
}
|
||||
|
40
migrate/v0_14/rollback.md
Normal file
40
migrate/v0_14/rollback.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Kava-5-1 Rollback Instructions
|
||||
|
||||
In the event that the kava-5.1 relaunch is unsuccessful, we will restart the kava-6 chain using the last known state.
|
||||
|
||||
In order to restore the previous chain, the following data must be recovered by validators:
|
||||
|
||||
* The database that contains the state of the previous chain (in ~/.kvd/data by default)
|
||||
* The priv_validator_state.json file of the validator (in ~/.kvd/data by default)
|
||||
|
||||
If you don't have the database data, the Kava developer team or another validator will share a copy of the database via Amazon s3 a similar service. You will be able to download a copy of the data and verify it before starting your node.
|
||||
If you don't have the backup priv_validator_state.json file, you will not have double sign protection on the first block. If this is the case, it's best to consult in the validator discord before starting your node.
|
||||
|
||||
## Restoring state procedure
|
||||
|
||||
1. Copy the contents of your backup data directory back to the $KVD_HOME/data directory. By default this is ~/.kvd/data.
|
||||
|
||||
```
|
||||
# Assumes backup is stored in "backup" directory
|
||||
rm -rf ~/.kvd/data
|
||||
mv backup/.kvd/data ~/.kvd/data
|
||||
```
|
||||
|
||||
2. Install the previous version of kava
|
||||
|
||||
```
|
||||
# from kava directory
|
||||
git checkout v0.12.4
|
||||
make install
|
||||
|
||||
## verify version
|
||||
kvd version --long
|
||||
```
|
||||
|
||||
3. Restart kvd process
|
||||
|
||||
```
|
||||
### be sure to remove --halt-time flag if it is set
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart kvd
|
||||
```
|
Loading…
Reference in New Issue
Block a user