mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 16:25:21 +00:00
Update migration test data (#881)
* update migration from v0.13 to v0.14 * update dates, add rollback instructions * address review comments * update test files * add hbtc usdx incentives to migration * update genesis time * address review comments
This commit is contained in:
parent
18ee69f480
commit
1dffdd4387
@ -18,7 +18,7 @@ import (
|
|||||||
func MigrateGenesisCmd(_ *server.Context, cdc *codec.Codec) *cobra.Command {
|
func MigrateGenesisCmd(_ *server.Context, cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "migrate [genesis-file]",
|
Use: "migrate [genesis-file]",
|
||||||
Short: "Migrate genesis file from kava v0.11 (or v0.12) to v0.13",
|
Short: "Migrate genesis file from kava v0.11 (or v0.12) to v0.14",
|
||||||
Long: "Migrate the source genesis into the current version, sorts it, and print to STDOUT.",
|
Long: "Migrate the source genesis into the current version, sorts it, and print to STDOUT.",
|
||||||
Example: fmt.Sprintf(`%s migrate /path/to/genesis.json`, version.ServerName),
|
Example: fmt.Sprintf(`%s migrate /path/to/genesis.json`, version.ServerName),
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
|
@ -32,9 +32,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
GenesisTime = time.Date(2021, 3, 4, 15, 0, 0, 0, time.UTC)
|
GenesisTime = time.Date(2021, 3, 24, 15, 0, 0, 0, time.UTC)
|
||||||
RewardEndTime = time.Date(2022, 2, 25, 14, 0, 0, 0, time.UTC)
|
RewardEndTime = time.Date(2022, 3, 24, 14, 0, 0, 0, time.UTC)
|
||||||
ClaimEndTime = time.Date(2026, 2, 25, 14, 0, 0, 0, time.UTC)
|
ClaimEndTime = time.Date(2026, 3, 24, 14, 0, 0, 0, time.UTC)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Migrate translates a genesis file from kava v0.11 (or v0.12) format to kava v0.13.x format.
|
// Migrate translates a genesis file from kava v0.11 (or v0.12) format to kava v0.13.x format.
|
||||||
@ -265,11 +265,12 @@ func Incentive(hardGS v0_11hard.GenesisState, incentiveGS v0_11incentive.Genesis
|
|||||||
usdxMintingRewardPeriods := v0_14incentive.RewardPeriods{}
|
usdxMintingRewardPeriods := v0_14incentive.RewardPeriods{}
|
||||||
usdxRewardsPerSecondMap := make(map[string]sdk.Coin)
|
usdxRewardsPerSecondMap := make(map[string]sdk.Coin)
|
||||||
usdxRewardsPerSecondMap["bnb-a"] = sdk.NewCoin("ukava", sdk.NewInt(122354))
|
usdxRewardsPerSecondMap["bnb-a"] = sdk.NewCoin("ukava", sdk.NewInt(122354))
|
||||||
usdxRewardsPerSecondMap["btcb-a"] = sdk.NewCoin("ukava", sdk.NewInt(158730))
|
usdxRewardsPerSecondMap["btcb-a"] = sdk.NewCoin("ukava", sdk.NewInt(110780))
|
||||||
usdxRewardsPerSecondMap["busd-a"] = sdk.NewCoin("ukava", sdk.NewInt(30588))
|
usdxRewardsPerSecondMap["busd-a"] = sdk.NewCoin("ukava", sdk.NewInt(30588))
|
||||||
usdxRewardsPerSecondMap["hard-a"] = sdk.NewCoin("ukava", sdk.NewInt(23809))
|
usdxRewardsPerSecondMap["hard-a"] = sdk.NewCoin("ukava", sdk.NewInt(23809))
|
||||||
usdxRewardsPerSecondMap["ukava-a"] = sdk.NewCoin("ukava", sdk.NewInt(31746))
|
usdxRewardsPerSecondMap["ukava-a"] = sdk.NewCoin("ukava", sdk.NewInt(31746))
|
||||||
usdxRewardsPerSecondMap["xrpb-a"] = sdk.NewCoin("ukava", sdk.NewInt(31746))
|
usdxRewardsPerSecondMap["xrpb-a"] = sdk.NewCoin("ukava", sdk.NewInt(31746))
|
||||||
|
usdxRewardsPerSecondMap["hbtc-a"] = sdk.NewCoin("ukava", sdk.NewInt(79365))
|
||||||
|
|
||||||
for _, rp := range incentiveGS.RewardPeriods {
|
for _, rp := range incentiveGS.RewardPeriods {
|
||||||
rewardsPerSecond, ok := usdxRewardsPerSecondMap[rp.CollateralType]
|
rewardsPerSecond, ok := usdxRewardsPerSecondMap[rp.CollateralType]
|
||||||
|
@ -41,7 +41,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCDP(t *testing.T) {
|
func TestCDP(t *testing.T) {
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-cdp-state-block-500000.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-cdp-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldGenState v0_11cdp.GenesisState
|
var oldGenState v0_11cdp.GenesisState
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
@ -69,7 +69,7 @@ func TestAuth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-auth-state-block-500000.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-auth-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldGenState auth.GenesisState
|
var oldGenState auth.GenesisState
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
@ -111,7 +111,7 @@ func getAccount(accounts authexported.GenesisAccounts, address sdk.AccAddress) a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIncentive(t *testing.T) {
|
func TestIncentive(t *testing.T) {
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-incentive-state.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-incentive-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldIncentiveGenState v0_11incentive.GenesisState
|
var oldIncentiveGenState v0_11incentive.GenesisState
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
@ -119,7 +119,7 @@ func TestIncentive(t *testing.T) {
|
|||||||
cdc.MustUnmarshalJSON(bz, &oldIncentiveGenState)
|
cdc.MustUnmarshalJSON(bz, &oldIncentiveGenState)
|
||||||
})
|
})
|
||||||
|
|
||||||
bz, err = ioutil.ReadFile(filepath.Join("testdata", "kava-4-harvest-state.json"))
|
bz, err = ioutil.ReadFile(filepath.Join("testdata", "kava-6-harvest-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldHarvestGenState v0_11hard.GenesisState
|
var oldHarvestGenState v0_11hard.GenesisState
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
@ -131,15 +131,15 @@ func TestIncentive(t *testing.T) {
|
|||||||
})
|
})
|
||||||
err = newGenState.Validate()
|
err = newGenState.Validate()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fmt.Printf("Number of incentive claims in kava-4: %d\nNumber of incentive Claims in kava-5: %d\n",
|
fmt.Printf("Number of incentive claims in kava-6: %d\nNumber of incentive Claims in kava-5.1: %d\n",
|
||||||
len(oldIncentiveGenState.Claims), len(newGenState.USDXMintingClaims),
|
len(oldIncentiveGenState.Claims), len(newGenState.USDXMintingClaims),
|
||||||
)
|
)
|
||||||
fmt.Printf("Number of harvest claims in kava-4: %d\nNumber of hard claims in kava-5: %d\n", len(oldHarvestGenState.Claims), len(newGenState.HardLiquidityProviderClaims))
|
fmt.Printf("Number of harvest claims in kava-6: %d\nNumber of hard claims in kava-5.1: %d\n", len(oldHarvestGenState.Claims), len(newGenState.HardLiquidityProviderClaims))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHard(t *testing.T) {
|
func TestHard(t *testing.T) {
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-harvest-state.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-harvest-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldHarvestGenState v0_11hard.GenesisState
|
var oldHarvestGenState v0_11hard.GenesisState
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
@ -154,7 +154,7 @@ func TestHard(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCommittee(t *testing.T) {
|
func TestCommittee(t *testing.T) {
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-committee-state.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-committee-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldGenState v0_11committee.GenesisState
|
var oldGenState v0_11committee.GenesisState
|
||||||
cdc := codec.New()
|
cdc := codec.New()
|
||||||
@ -184,7 +184,7 @@ func TestCommittee(t *testing.T) {
|
|||||||
|
|
||||||
func TestPricefeed(t *testing.T) {
|
func TestPricefeed(t *testing.T) {
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-pricefeed-state.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-pricefeed-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldPricefeedGenState v0_11pricefeed.GenesisState
|
var oldPricefeedGenState v0_11pricefeed.GenesisState
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
@ -196,7 +196,7 @@ func TestPricefeed(t *testing.T) {
|
|||||||
require.Equal(t, len(oldPricefeedGenState.Params.Markets)+1, len(newGenState.Params.Markets))
|
require.Equal(t, len(oldPricefeedGenState.Params.Markets)+1, len(newGenState.Params.Markets))
|
||||||
}
|
}
|
||||||
func TestBep3(t *testing.T) {
|
func TestBep3(t *testing.T) {
|
||||||
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-4-bep3-state.json"))
|
bz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-6-bep3-state.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var oldGenState bep3.GenesisState
|
var oldGenState bep3.GenesisState
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
@ -228,7 +228,7 @@ func TestBep3(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMigrateFull(t *testing.T) {
|
func TestMigrateFull(t *testing.T) {
|
||||||
oldGenDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "kava-4-export.json"))
|
oldGenDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "kava-6-block-127500.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 2) migrate
|
// 2) migrate
|
||||||
|
File diff suppressed because one or more lines are too long
29102
migrate/v0_14/testdata/kava-4-cdp-state-block-500000.json
vendored
29102
migrate/v0_14/testdata/kava-4-cdp-state-block-500000.json
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
migrate/v0_14/testdata/kava-6-bep3-state.json
vendored
Normal file
1
migrate/v0_14/testdata/kava-6-bep3-state.json
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
migrate/v0_14/testdata/kava-6-cdp-state.json
vendored
Normal file
1
migrate/v0_14/testdata/kava-6-cdp-state.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
migrate/v0_14/testdata/kava-6-harvest-state.json
vendored
Normal file
1
migrate/v0_14/testdata/kava-6-harvest-state.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
migrate/v0_14/testdata/kava-6-incentive-state.json
vendored
Normal file
1
migrate/v0_14/testdata/kava-6-incentive-state.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
migrate/v0_14/testdata/kava-6-pricefeed-state.json
vendored
Normal file
1
migrate/v0_14/testdata/kava-6-pricefeed-state.json
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user