Add auction migration (#1220)

* add initial auction migration from Levi's work

* reserve bid_duration field name as well

* refactor auction specifc migration code to legacy v0_17 pkg

* Add auction migration specific test. Delete v016 migration files. Add makefile target for running migration tests.

Co-authored-by: galxy25 <levismschoen@gmail.com>
This commit is contained in:
Nick DeLuca 2022-04-22 11:36:05 -07:00 committed by GitHub
parent afdbc04e16
commit bbb2235ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 923 additions and 8912 deletions

3
.gitignore vendored
View File

@ -21,3 +21,6 @@ build
node_modules
docs/node_modules
docs/.vuepress/dist
# Ignore macOS file system metadata
.DS_Store

View File

@ -251,6 +251,10 @@ test:
test-cli: build
@go test ./cli_test -tags cli_test -v -p 4
# Run tests for migration cli command
test-migrate:
@go test -v -count=1 ./migrate/...
# Kick start lots of sims on an AWS cluster.
# This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3
start-remote-sims:

View File

@ -1,239 +0,0 @@
package v0_16
import (
"time"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
v036supply "github.com/cosmos/cosmos-sdk/x/bank/legacy/v036"
v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v038"
v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
v039crisis "github.com/cosmos/cosmos-sdk/x/crisis/legacy/v039"
v040crisis "github.com/cosmos/cosmos-sdk/x/crisis/legacy/v040"
v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v036"
v038distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v038"
v040distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v040"
v038evidence "github.com/cosmos/cosmos-sdk/x/evidence/legacy/v038"
v040evidence "github.com/cosmos/cosmos-sdk/x/evidence/legacy/v040"
v039genutil "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v039"
v040genutil "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v040"
v043genutil "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v043"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
v036gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v036"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v040"
v039mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v039"
v040mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v040"
v036params "github.com/cosmos/cosmos-sdk/x/params/legacy/v036"
v039slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v039"
v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v040"
v038staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v038"
v040staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v040"
v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/legacy/v038"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibctypes "github.com/cosmos/ibc-go/v3/modules/core/types"
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
v015validatorvesting "github.com/kava-labs/kava/x/validator-vesting/legacy/v0_15"
)
func migrateGenutil(oldGenState v039genutil.GenesisState) *genutiltypes.GenesisState {
return &genutiltypes.GenesisState{
GenTxs: oldGenState.GenTxs,
}
}
func MigrateCosmosAppState(appState genutiltypes.AppMap, clientCtx client.Context, genesisTime time.Time) genutiltypes.AppMap {
appState = migrateV040(appState, clientCtx, genesisTime)
appState = migrateV043(appState, clientCtx)
appState = addIbcGenesisStates(appState, clientCtx)
return appState
}
func addIbcGenesisStates(appState genutiltypes.AppMap, clientCtx client.Context) genutiltypes.AppMap {
appState[capabilitytypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(capabilitytypes.DefaultGenesis())
appState[ibchost.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibctypes.DefaultGenesisState())
appState[ibctransfertypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibctransfertypes.DefaultGenesisState())
return appState
}
// migrateV043 migrates cosmos modules from v0.40 to a v0.43 genesis state.
func migrateV043(appState genutiltypes.AppMap, clientCtx client.Context) genutiltypes.AppMap {
return v043genutil.Migrate(appState, clientCtx)
}
// migrateV040 migrates cosmos modules from v0.39 to a v0.40 genesis state.
// This is based on the genutil/legacy/v40 migration logic but adapted to handle custom types from the kava module.
func migrateV040(appState genutiltypes.AppMap, clientCtx client.Context, genesisTime time.Time) genutiltypes.AppMap {
setConfigIfUnsealed()
v039Codec := codec.NewLegacyAmino()
v039auth.RegisterLegacyAminoCodec(v039Codec)
v036gov.RegisterLegacyAminoCodec(v039Codec)
v036distr.RegisterLegacyAminoCodec(v039Codec)
v036params.RegisterLegacyAminoCodec(v039Codec)
v038upgrade.RegisterLegacyAminoCodec(v039Codec)
v015kavadist.RegisterLegacyAminoCodec(v039Codec)
v015validatorvesting.RegisterLegacyAminoCodec(v039Codec)
v039Codec.RegisterInterface((*v038evidence.Evidence)(nil), nil)
v040Codec := clientCtx.Codec
if appState[v038bank.ModuleName] != nil {
// unmarshal relative source genesis application state
var bankGenState v038bank.GenesisState
v039Codec.MustUnmarshalJSON(appState[v038bank.ModuleName], &bankGenState)
// unmarshal x/auth genesis state to retrieve all account balances
var authGenState v039auth.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState)
// unmarshal x/supply genesis state to retrieve total supply
var supplyGenState v036supply.GenesisState
v039Codec.MustUnmarshalJSON(appState[v036supply.ModuleName], &supplyGenState)
// delete deprecated x/bank genesis state
delete(appState, v038bank.ModuleName)
// delete deprecated x/supply genesis state
delete(appState, v036supply.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040bank.ModuleName] = v040Codec.MustMarshalJSON(v040bank.Migrate(bankGenState, authGenState, supplyGenState))
}
// remove balances from existing accounts
if appState[v039auth.ModuleName] != nil {
// unmarshal relative source genesis application state
var authGenState v039auth.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState)
// delete deprecated x/auth genesis state
delete(appState, v039auth.ModuleName)
// Run our custom auth v40 migration on the v039 auth gen state
appState[v040auth.ModuleName] = v040Codec.MustMarshalJSON(MigrateAuthV040(authGenState, genesisTime))
}
// Migrate x/crisis.
if appState[v039crisis.ModuleName] != nil {
// unmarshal relative source genesis application state
var crisisGenState v039crisis.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039crisis.ModuleName], &crisisGenState)
// delete deprecated x/crisis genesis state
delete(appState, v039crisis.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040crisis.ModuleName] = v040Codec.MustMarshalJSON(v040crisis.Migrate(crisisGenState))
}
// Migrate x/distribution.
if appState[v038distr.ModuleName] != nil {
// unmarshal relative source genesis application state
var distributionGenState v038distr.GenesisState
v039Codec.MustUnmarshalJSON(appState[v038distr.ModuleName], &distributionGenState)
// delete deprecated x/distribution genesis state
delete(appState, v038distr.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040distr.ModuleName] = v040Codec.MustMarshalJSON(v040distr.Migrate(distributionGenState))
}
// Migrate x/evidence.
if appState[v038evidence.ModuleName] != nil {
// unmarshal relative source genesis application state
var evidenceGenState v038evidence.GenesisState
v039Codec.MustUnmarshalJSON(appState[v038evidence.ModuleName], &evidenceGenState)
// delete deprecated x/evidence genesis state
delete(appState, v038evidence.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040evidence.ModuleName] = v040Codec.MustMarshalJSON(v040evidence.Migrate(evidenceGenState))
}
// Migrate x/gov.
if appState[v036gov.ModuleName] != nil {
// unmarshal relative source genesis application state
var govGenState v036gov.GenesisState
v039Codec.MustUnmarshalJSON(appState[v036gov.ModuleName], &govGenState)
// delete deprecated x/gov genesis state
delete(appState, v036gov.ModuleName)
// Run our custom gov v40 migration on the v039 gov gen state
appState[v040gov.ModuleName] = v040Codec.MustMarshalJSON(MigrateGovV040(govGenState))
}
// Migrate x/mint.
if appState[v039mint.ModuleName] != nil {
// unmarshal relative source genesis application state
var mintGenState v039mint.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039mint.ModuleName], &mintGenState)
// delete deprecated x/mint genesis state
delete(appState, v039mint.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040mint.ModuleName] = v040Codec.MustMarshalJSON(v040mint.Migrate(mintGenState))
}
// Migrate x/slashing.
if appState[v039slashing.ModuleName] != nil {
// unmarshal relative source genesis application state
var slashingGenState v039slashing.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039slashing.ModuleName], &slashingGenState)
// delete deprecated x/slashing genesis state
delete(appState, v039slashing.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040slashing.ModuleName] = v040Codec.MustMarshalJSON(v040slashing.Migrate(slashingGenState))
}
// Migrate x/staking.
if appState[v038staking.ModuleName] != nil {
// unmarshal relative source genesis application state
var stakingGenState v038staking.GenesisState
v039Codec.MustUnmarshalJSON(appState[v038staking.ModuleName], &stakingGenState)
// Update historical entries to 10000
stakingGenState.Params.HistoricalEntries = 10000
// delete deprecated x/staking genesis state
delete(appState, v038staking.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040staking.ModuleName] = v040Codec.MustMarshalJSON(v040staking.Migrate(stakingGenState))
}
// Migrate x/genutil
if appState[v039genutil.ModuleName] != nil {
// unmarshal relative source genesis application state
var genutilGenState v039genutil.GenesisState
v039Codec.MustUnmarshalJSON(appState[v039genutil.ModuleName], &genutilGenState)
// delete deprecated x/staking genesis state
delete(appState, v039genutil.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040genutil.ModuleName] = v040Codec.MustMarshalJSON(migrateGenutil(genutilGenState))
}
return appState
}

View File

@ -1,202 +0,0 @@
/**
* The v0_16 x/auth migration logic is adapted from
* https://github.com/cosmos/cosmos-sdk/blob/b75c29fc15d3320ec0c7596dbd7c787c48dccad8/x/auth/legacy/v040/migrate.go
*
* The original migration code is changed here to support the following custom Account from the kava modules.
* - `x/validator-vesting/ValidatorVestingAccount`
*/
package v0_16
import (
"time"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/types"
v040vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
v015validatorvesting "github.com/kava-labs/kava/x/validator-vesting/legacy/v0_15"
)
// convertBaseAccount converts a 0.39 BaseAccount to a 0.40 BaseAccount.
func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount {
var any *codectypes.Any
if old.PubKey != nil {
var err error
any, err = codectypes.NewAnyWithValue(old.PubKey)
if err != nil {
panic(err)
}
}
return &v040auth.BaseAccount{
Address: old.Address.String(),
PubKey: any,
AccountNumber: old.AccountNumber,
Sequence: old.Sequence,
}
}
// convertBaseVestingAccount converts a 0.39 BaseVestingAccount to a 0.40 BaseVestingAccount.
func convertBaseVestingAccount(old *v039auth.BaseVestingAccount) *v040vesting.BaseVestingAccount {
baseAccount := convertBaseAccount(old.BaseAccount)
return &v040vesting.BaseVestingAccount{
BaseAccount: baseAccount,
OriginalVesting: old.OriginalVesting,
DelegatedFree: old.DelegatedFree,
DelegatedVesting: old.DelegatedVesting,
EndTime: old.EndTime,
}
}
// ResetPeriodicVestingAccount resets a periodic vesting account to a new start
// time. The account is modified in place, and vesting periods before the new
// start time are removed from the account.
func ResetPeriodicVestingAccount(vacc *v040vesting.PeriodicVestingAccount, startTime time.Time) {
currentPeriod := vacc.StartTime
newOriginalVesting := sdk.Coins{}
newStartTime := startTime.Unix()
newPeriods := v040vesting.Periods{}
for _, period := range vacc.VestingPeriods {
currentPeriod = currentPeriod + period.Length
// Periods less than the newStartTime are still vesting,
// so adjust their length and add them to the newPeriods
if newStartTime < currentPeriod {
// adjust the length of the first vesting period
// to be relative to the new start time
if len(newPeriods) == 0 {
period.Length = currentPeriod - newStartTime
}
newOriginalVesting = newOriginalVesting.Add(period.Amount...)
newPeriods = append(newPeriods, period)
}
}
// If the new original vesting amount is less than the delegated vesting amount, set delegated vesting
// to the new original vesting amount, and add the difference to the delegated free amount
for _, delegatedVestingCoin := range vacc.DelegatedVesting {
newDelegatedVestingCoin := sdk.NewCoin(delegatedVestingCoin.Denom, sdk.MinInt(delegatedVestingCoin.Amount, newOriginalVesting.AmountOf(delegatedVestingCoin.Denom)))
delegationAdjustment := delegatedVestingCoin.Sub(newDelegatedVestingCoin)
if !delegationAdjustment.IsZero() {
vacc.DelegatedVesting = vacc.DelegatedVesting.Sub(sdk.NewCoins(delegationAdjustment))
vacc.DelegatedFree = vacc.DelegatedFree.Add(delegationAdjustment)
}
}
// update vesting account
vacc.StartTime = newStartTime
vacc.OriginalVesting = newOriginalVesting
vacc.VestingPeriods = newPeriods
// ensure end time is >= start time
if vacc.StartTime >= vacc.EndTime {
vacc.EndTime = vacc.StartTime
}
}
// Migrate accepts exported x/auth genesis state from v0.38/v0.39 and migrates
// it to v0.40 x/auth genesis state. The migration includes:
//
// - Removing coins from account encoding.
// - Re-encode in v0.40 GenesisState.
func MigrateAuthV040(authGenState v039auth.GenesisState, genesisTime time.Time) *v040auth.GenesisState {
// Convert v0.39 accounts to v0.40 ones.
var v040Accounts = make([]v040auth.GenesisAccount, len(authGenState.Accounts))
for i, v039Account := range authGenState.Accounts {
switch v039Account := v039Account.(type) {
case *v039auth.BaseAccount:
{
v040Accounts[i] = convertBaseAccount(v039Account)
}
case *v039auth.ModuleAccount:
{
v040Accounts[i] = &v040auth.ModuleAccount{
BaseAccount: convertBaseAccount(v039Account.BaseAccount),
Name: v039Account.Name,
Permissions: v039Account.Permissions,
}
}
case *v039auth.BaseVestingAccount:
{
v040Accounts[i] = convertBaseVestingAccount(v039Account)
}
case *v039auth.ContinuousVestingAccount:
{
v040Accounts[i] = &v040vesting.ContinuousVestingAccount{
BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount),
StartTime: v039Account.StartTime,
}
}
case *v039auth.DelayedVestingAccount:
{
v040Accounts[i] = &v040vesting.DelayedVestingAccount{
BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount),
}
}
case *v039auth.PeriodicVestingAccount:
{
vestingPeriods := make([]v040vesting.Period, len(v039Account.VestingPeriods))
for j, period := range v039Account.VestingPeriods {
vestingPeriods[j] = v040vesting.Period{
Length: period.Length,
Amount: period.Amount,
}
}
vacc := v040vesting.PeriodicVestingAccount{
BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount),
StartTime: v039Account.StartTime,
VestingPeriods: vestingPeriods,
}
ResetPeriodicVestingAccount(&vacc, genesisTime)
// If periodic vesting account has zero periods, convert back
// to a base account
if genesisTime.Unix() >= vacc.EndTime {
v040Accounts[i] = vacc.BaseVestingAccount.BaseAccount
} else {
v040Accounts[i] = &vacc
}
}
case *v015validatorvesting.ValidatorVestingAccount:
{
// Convert validator vesting accounts to base accounts since no more vesting is needed
v040Accounts[i] = convertBaseAccount(v039Account.BaseAccount)
}
default:
panic(sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "got invalid type %T", v039Account))
}
}
// Convert v0.40 accounts into Anys.
anys := make([]*codectypes.Any, len(v040Accounts))
for i, v040Account := range v040Accounts {
any, err := codectypes.NewAnyWithValue(v040Account)
if err != nil {
panic(err)
}
anys[i] = any
}
return &v040auth.GenesisState{
Params: v040auth.Params{
MaxMemoCharacters: authGenState.Params.MaxMemoCharacters,
TxSigLimit: authGenState.Params.TxSigLimit,
TxSizeCostPerByte: authGenState.Params.TxSizeCostPerByte,
SigVerifyCostED25519: authGenState.Params.SigVerifyCostED25519,
SigVerifyCostSecp256k1: authGenState.Params.SigVerifyCostSecp256k1,
},
Accounts: anys,
}
}

View File

@ -1,237 +0,0 @@
/**
* The v0_16 x/gov migration logic is adapted from
* https://github.com/cosmos/cosmos-sdk/blob/b75c29fc15d3320ec0c7596dbd7c787c48dccad8/x/gov/legacy/v040/migrate.go
*
* The original migration code is changed here to support the following custom proposals from the kava modules.
* - `x/kavadist/CommunityPoolMultiSpendProposal`
*
* Note: The committee modules also adds the `CommitteeChangeProposal` and `CommitteeDeleteProposal`.
* However, we should not have any proposals of these type on mainet so we should be good to ignore them here.
*/
package v0_16
import (
"fmt"
proto "github.com/gogo/protobuf/proto"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v036"
v040distr "github.com/cosmos/cosmos-sdk/x/distribution/types"
v034gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v034"
v036gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v036"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/types"
v036params "github.com/cosmos/cosmos-sdk/x/params/legacy/v036"
v040params "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/legacy/v038"
v040upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/types"
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
v016kavadist "github.com/kava-labs/kava/x/kavadist/types"
)
func migrateVoteOption(oldVoteOption v034gov.VoteOption) v040gov.VoteOption {
switch oldVoteOption {
case v034gov.OptionEmpty:
return v040gov.OptionEmpty
case v034gov.OptionYes:
return v040gov.OptionYes
case v034gov.OptionAbstain:
return v040gov.OptionAbstain
case v034gov.OptionNo:
return v040gov.OptionNo
case v034gov.OptionNoWithVeto:
return v040gov.OptionNoWithVeto
default:
panic(fmt.Errorf("'%s' is not a valid vote option", oldVoteOption))
}
}
func migrateProposalStatus(oldProposalStatus v034gov.ProposalStatus) v040gov.ProposalStatus {
switch oldProposalStatus {
case v034gov.StatusNil:
return v040gov.StatusNil
case v034gov.StatusDepositPeriod:
return v040gov.StatusDepositPeriod
case v034gov.StatusVotingPeriod:
return v040gov.StatusVotingPeriod
case v034gov.StatusPassed:
return v040gov.StatusPassed
case v034gov.StatusRejected:
return v040gov.StatusRejected
case v034gov.StatusFailed:
return v040gov.StatusFailed
default:
panic(fmt.Errorf("'%s' is not a valid proposal status", oldProposalStatus))
}
}
func migrateContent(oldContent v036gov.Content) *codectypes.Any {
var protoProposal proto.Message
switch oldContent := oldContent.(type) {
case v036gov.TextProposal:
{
protoProposal = &v040gov.TextProposal{
Title: oldContent.Title,
Description: oldContent.Description,
}
// Convert the content into Any.
contentAny, err := codectypes.NewAnyWithValue(protoProposal)
if err != nil {
panic(err)
}
return contentAny
}
case v036distr.CommunityPoolSpendProposal:
{
protoProposal = &v040distr.CommunityPoolSpendProposal{
Title: oldContent.Title,
Description: oldContent.Description,
Recipient: oldContent.Recipient.String(),
Amount: oldContent.Amount,
}
}
case v038upgrade.CancelSoftwareUpgradeProposal:
{
protoProposal = &v040upgrade.CancelSoftwareUpgradeProposal{
Description: oldContent.Description,
Title: oldContent.Title,
}
}
case v038upgrade.SoftwareUpgradeProposal:
{
protoProposal = &v040upgrade.SoftwareUpgradeProposal{
Description: oldContent.Description,
Title: oldContent.Title,
Plan: v040upgrade.Plan{
Name: oldContent.Plan.Name,
Height: oldContent.Plan.Height,
Info: oldContent.Plan.Info,
},
}
}
case v036params.ParameterChangeProposal:
{
newChanges := make([]v040params.ParamChange, len(oldContent.Changes))
for i, oldChange := range oldContent.Changes {
newChanges[i] = v040params.ParamChange{
Subspace: oldChange.Subspace,
Key: oldChange.Key,
Value: oldChange.Value,
}
}
protoProposal = &v040params.ParameterChangeProposal{
Description: oldContent.Description,
Title: oldContent.Title,
Changes: newChanges,
}
}
case v015kavadist.CommunityPoolMultiSpendProposal:
{
newRecipients := make([]v016kavadist.MultiSpendRecipient, len(oldContent.RecipientList))
for i, recipient := range oldContent.RecipientList {
newRecipients[i] = v016kavadist.MultiSpendRecipient{
Address: recipient.Address.String(),
Amount: recipient.Amount,
}
}
protoProposal = &v016kavadist.CommunityPoolMultiSpendProposal{
Description: oldContent.Description,
Title: oldContent.Title,
RecipientList: newRecipients,
}
}
default:
panic(fmt.Errorf("%T is not a valid proposal content type", oldContent))
}
// Convert the content into Any.
contentAny, err := codectypes.NewAnyWithValue(protoProposal)
if err != nil {
panic(err)
}
return contentAny
}
// MigrateGovV036 accepts exported v0.36 x/gov genesis state and migrates it to
// v0.40 x/gov genesis state. The migration includes:
//
// - Convert vote option & proposal status from byte to enum.
// - Migrate proposal content to Any.
// - Convert addresses from bytes to bech32 strings.
// - Re-encode in v0.40 GenesisState.
func MigrateGovV040(oldGovState v036gov.GenesisState) *v040gov.GenesisState {
newDeposits := make([]v040gov.Deposit, len(oldGovState.Deposits))
for i, oldDeposit := range oldGovState.Deposits {
newDeposits[i] = v040gov.Deposit{
ProposalId: oldDeposit.ProposalID,
Depositor: oldDeposit.Depositor.String(),
Amount: oldDeposit.Amount,
}
}
newVotes := make([]v040gov.Vote, len(oldGovState.Votes))
for i, oldVote := range oldGovState.Votes {
newVotes[i] = v040gov.Vote{
ProposalId: oldVote.ProposalID,
Voter: oldVote.Voter.String(),
Option: migrateVoteOption(oldVote.Option),
}
}
newProposals := make([]v040gov.Proposal, len(oldGovState.Proposals))
for i, oldProposal := range oldGovState.Proposals {
newProposals[i] = v040gov.Proposal{
ProposalId: oldProposal.ProposalID,
Content: migrateContent(oldProposal.Content),
Status: migrateProposalStatus(oldProposal.Status),
FinalTallyResult: v040gov.TallyResult{
Yes: oldProposal.FinalTallyResult.Yes,
Abstain: oldProposal.FinalTallyResult.Abstain,
No: oldProposal.FinalTallyResult.No,
NoWithVeto: oldProposal.FinalTallyResult.NoWithVeto,
},
SubmitTime: oldProposal.SubmitTime,
DepositEndTime: oldProposal.DepositEndTime,
TotalDeposit: oldProposal.TotalDeposit,
VotingStartTime: oldProposal.VotingStartTime,
VotingEndTime: oldProposal.VotingEndTime,
}
}
return &v040gov.GenesisState{
StartingProposalId: oldGovState.StartingProposalID,
Deposits: newDeposits,
Votes: newVotes,
Proposals: newProposals,
DepositParams: v040gov.DepositParams{
MinDeposit: oldGovState.DepositParams.MinDeposit,
MaxDepositPeriod: oldGovState.DepositParams.MaxDepositPeriod,
},
VotingParams: v040gov.VotingParams{
VotingPeriod: oldGovState.VotingParams.VotingPeriod,
},
TallyParams: v040gov.TallyParams{
Quorum: oldGovState.TallyParams.Quorum,
Threshold: oldGovState.TallyParams.Threshold,
VetoThreshold: oldGovState.TallyParams.Veto,
},
}
}

View File

@ -1,93 +0,0 @@
package v0_16
import (
"encoding/json"
"io/ioutil"
"path/filepath"
"testing"
"time"
"github.com/cosmos/cosmos-sdk/client"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/stretchr/testify/assert"
"github.com/kava-labs/kava/app"
)
// Periodic vesting account periods will change depending on the genesis time.
// This test genesis time is used to be able to change the actual genesis time
// without breaking the tests.
var TestGenesisTime = time.Date(2021, 11, 30, 15, 0, 0, 0, time.UTC)
func TestCosmosMigrate_Gov(t *testing.T) {
// The gov json contains a gov app state with 3 different proposals.
// Two of the proposals are from cosmos while the 3rd one is kavadist/CommunityPoolMultiSpendProposal.
original := getTestDataJSON("appstate-gov-v15.json")
expected := getTestDataJSON("appstate-gov-v16.json")
actual := mustMigrateCosmosAppStateJSON(original)
assert.JSONEq(t, expected, actual)
}
func TestCosmosMigrate_Bank(t *testing.T) {
// The bank json tests migrating the bank, auth, and supply modules
// The json contains the kava ValidatorVestingAccount account and tests for
// both the correct proto migration & moving account coins and supply to the bank module.
original := getTestDataJSON("appstate-bank-v15.json")
expected := getTestDataJSON("appstate-bank-v16.json")
actual := mustMigrateCosmosAppStateJSON(original)
assert.JSONEq(t, expected, actual)
}
func TestCosmosMigrate_Distribution(t *testing.T) {
original := getTestDataJSON("appstate-distribution-v15.json")
expected := getTestDataJSON("appstate-distribution-v16.json")
actual := mustMigrateCosmosAppStateJSON(original)
assert.JSONEq(t, expected, actual)
}
func TestCosmosMigrate_Staking(t *testing.T) {
original := getTestDataJSON("appstate-staking-v15.json")
expected := getTestDataJSON("appstate-staking-v16.json")
actual := mustMigrateCosmosAppStateJSON(original)
assert.JSONEq(t, expected, actual)
}
func TestCosmosMigrate_Modules(t *testing.T) {
original := getTestDataJSON("appstate-cosmos-v15.json")
expected := getTestDataJSON("appstate-cosmos-v16.json")
actual := mustMigrateCosmosAppStateJSON(original)
assert.JSONEq(t, expected, actual)
}
// mustMigrateCosmosAppStateJSON migrate v15 app state json to v16
func mustMigrateCosmosAppStateJSON(appStateJson string) string {
var appState genutiltypes.AppMap
if err := json.Unmarshal([]byte(appStateJson), &appState); err != nil {
panic(err)
}
ctx := newClientContext()
appState = migrateV040(appState, ctx, TestGenesisTime)
appState = migrateV043(appState, ctx)
actual, err := json.Marshal(appState)
if err != nil {
panic(err)
}
return string(actual)
}
func getTestDataJSON(filename string) string {
file := filepath.Join("testdata", filename)
data, err := ioutil.ReadFile(file)
if err != nil {
panic(err)
}
return string(data)
}
func newClientContext() client.Context {
config := app.MakeEncodingConfig()
return client.Context{}.
WithCodec(config.Marshaler).
WithLegacyAmino(config.Amino).
WithInterfaceRegistry(config.InterfaceRegistry)
}

View File

View File

@ -1,155 +0,0 @@
package v0_16
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v036"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
v036params "github.com/cosmos/cosmos-sdk/x/params/legacy/v036"
v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/legacy/v038"
v015auction "github.com/kava-labs/kava/x/auction/legacy/v0_15"
v016auction "github.com/kava-labs/kava/x/auction/legacy/v0_16"
v015bep3 "github.com/kava-labs/kava/x/bep3/legacy/v0_15"
v016bep3 "github.com/kava-labs/kava/x/bep3/legacy/v0_16"
v015cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_15"
v016cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_16"
v015committee "github.com/kava-labs/kava/x/committee/legacy/v0_15"
v016committee "github.com/kava-labs/kava/x/committee/legacy/v0_16"
v015hard "github.com/kava-labs/kava/x/hard/legacy/v0_15"
v016hard "github.com/kava-labs/kava/x/hard/legacy/v0_16"
v015incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_15"
v016incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_16"
v015issuance "github.com/kava-labs/kava/x/issuance/legacy/v0_15"
v016issuance "github.com/kava-labs/kava/x/issuance/legacy/v0_16"
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
v016kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_16"
v015pricefeed "github.com/kava-labs/kava/x/pricefeed/legacy/v0_15"
v016pricefeed "github.com/kava-labs/kava/x/pricefeed/legacy/v0_16"
v015swap "github.com/kava-labs/kava/x/swap/legacy/v0_15"
v016swap "github.com/kava-labs/kava/x/swap/legacy/v0_16"
v015validatorvesting "github.com/kava-labs/kava/x/validator-vesting/legacy/v0_15"
)
func migrateKavaAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
v15Codec := codec.NewLegacyAmino()
v015auction.RegisterLegacyAminoCodec(v15Codec)
v015committee.RegisterLegacyAminoCodec(v15Codec)
v015kavadist.RegisterLegacyAminoCodec(v15Codec)
v036distr.RegisterLegacyAminoCodec(v15Codec)
v038upgrade.RegisterLegacyAminoCodec(v15Codec)
v036params.RegisterLegacyAminoCodec(v15Codec)
v16Codec := clientCtx.Codec
// Migrate x/auction
if appState[v015auction.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015auction.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015auction.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015auction.ModuleName] = v16Codec.MustMarshalJSON(v016auction.Migrate(genState))
}
// 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, pricefeedGenState))
}
// Migrate x/bep3
if appState[v015bep3.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015bep3.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015bep3.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015bep3.ModuleName] = v16Codec.MustMarshalJSON(v016bep3.Migrate(genState))
}
// Migrate x/swap
if appState[v015swap.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015swap.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015swap.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015swap.ModuleName] = v16Codec.MustMarshalJSON(v016swap.Migrate(genState))
}
// Migrate x/kavadist
if appState[v015kavadist.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015kavadist.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015kavadist.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015kavadist.ModuleName] = v16Codec.MustMarshalJSON(v016kavadist.Migrate(genState))
}
// Migrate x/cdp
if appState[v015cdp.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015cdp.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015cdp.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015cdp.ModuleName] = v16Codec.MustMarshalJSON(v016cdp.Migrate(genState))
}
// Migrate x/issuance
if appState[v015issuance.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015issuance.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015issuance.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015issuance.ModuleName] = v16Codec.MustMarshalJSON(v016issuance.Migrate(genState))
}
// Migrate x/pricefeed
if appState[v015pricefeed.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015pricefeed.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015pricefeed.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015pricefeed.ModuleName] = v16Codec.MustMarshalJSON(v016pricefeed.Migrate(genState))
}
// Migrate x/hard
if appState[v015hard.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015hard.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015hard.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015hard.ModuleName] = v16Codec.MustMarshalJSON(v016hard.Migrate(genState))
}
// Migrate x/incentive
if appState[v015incentive.ModuleName] != nil {
// unmarshal relative source genesis application state
var genState v015incentive.GenesisState
v15Codec.MustUnmarshalJSON(appState[v015incentive.ModuleName], &genState)
// replace migrated genstate with previous genstate
appState[v015incentive.ModuleName] = v16Codec.MustMarshalJSON(v016incentive.Migrate(genState))
}
// Remove x/validator-vesting
delete(appState, v015validatorvesting.ModuleName)
}

View File

@ -1,485 +0,0 @@
package legacyaccounts
import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v034"
)
// legacy implemtation of accounts that allows checking the spendable balance for any account,
// in addition support periodic vesting account methods
type Account interface {
GetAddress() sdk.AccAddress
GetCoins() sdk.Coins
SpendableCoins(blockTime time.Time) sdk.Coins
}
type GenesisAccounts []GenesisAccount
type GenesisAccount interface {
Account
}
type VestingAccount interface {
Account
GetVestedCoins(blockTime time.Time) sdk.Coins
GetVestingCoins(blockTime time.Time) sdk.Coins
GetStartTime() int64
GetEndTime() int64
GetOriginalVesting() sdk.Coins
GetDelegatedFree() sdk.Coins
GetDelegatedVesting() sdk.Coins
}
type GenesisState struct {
Params v034auth.Params `json:"params" yaml:"params"`
Accounts GenesisAccounts `json:"accounts" yaml:"accounts"`
}
//-----------------------------------------------------------------------------
// BaseAccount
var _ Account = (*BaseAccount)(nil)
var _ GenesisAccount = (*BaseAccount)(nil)
type BaseAccount struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
}
func NewBaseAccount(
address sdk.AccAddress, coins sdk.Coins, pk cryptotypes.PubKey, accountNumber, sequence uint64,
) *BaseAccount {
return &BaseAccount{
Address: address,
Coins: coins,
PubKey: pk,
AccountNumber: accountNumber,
Sequence: sequence,
}
}
func (acc BaseAccount) GetAddress() sdk.AccAddress {
return acc.Address
}
func (acc *BaseAccount) GetCoins() sdk.Coins {
return acc.Coins
}
func (acc *BaseAccount) SpendableCoins(_ time.Time) sdk.Coins {
return acc.GetCoins()
}
type Period struct {
Length int64 `json:"length" yaml:"length"` // length of the period, in seconds
Amount sdk.Coins `json:"amount" yaml:"amount"` // amount of coins vesting during this period
}
type Periods []Period
var _ VestingAccount = (*PeriodicVestingAccount)(nil)
var _ GenesisAccount = (*PeriodicVestingAccount)(nil)
type vestingAccountJSON struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"`
PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"`
EndTime int64 `json:"end_time" yaml:"end_time"`
// custom fields based on concrete vesting type which can be omitted
StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"`
VestingPeriods Periods `json:"vesting_periods,omitempty" yaml:"vesting_periods,omitempty"`
}
type BaseVestingAccount struct {
*BaseAccount
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` // coins in account upon initialization
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` // coins that are vested and delegated
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // coins that vesting and delegated
EndTime int64 `json:"end_time" yaml:"end_time"` // when the coins become unlocked
}
func (bva *BaseVestingAccount) UnmarshalJSON(bz []byte) error {
var alias vestingAccountJSON
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
bva.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence)
bva.OriginalVesting = alias.OriginalVesting
bva.DelegatedFree = alias.DelegatedFree
bva.DelegatedVesting = alias.DelegatedVesting
bva.EndTime = alias.EndTime
return nil
}
func (bva BaseVestingAccount) SpendableCoinsVestingAccount(vestingCoins sdk.Coins) sdk.Coins {
var spendableCoins sdk.Coins
bc := bva.GetCoins()
for _, coin := range bc {
baseAmt := coin.Amount
vestingAmt := vestingCoins.AmountOf(coin.Denom)
delVestingAmt := bva.DelegatedVesting.AmountOf(coin.Denom)
// compute min((BC + DV) - V, BC) per the specification
min := sdk.MinInt(baseAmt.Add(delVestingAmt).Sub(vestingAmt), baseAmt)
spendableCoin := sdk.NewCoin(coin.Denom, min)
if !spendableCoin.IsZero() {
spendableCoins = spendableCoins.Add(spendableCoin)
}
}
return spendableCoins
}
func (bva BaseVestingAccount) GetOriginalVesting() sdk.Coins {
return bva.OriginalVesting
}
func (bva BaseVestingAccount) GetDelegatedFree() sdk.Coins {
return bva.DelegatedFree
}
func (bva BaseVestingAccount) GetDelegatedVesting() sdk.Coins {
return bva.DelegatedVesting
}
func (bva BaseVestingAccount) GetEndTime() int64 {
return bva.EndTime
}
//-----------------------------------------------------------------------------
// Continuous Vesting Account
type ContinuousVestingAccount struct {
*BaseVestingAccount
StartTime int64 `json:"start_time" yaml:"start_time"` // when the coins start to vest
}
func (cva *ContinuousVestingAccount) UnmarshalJSON(bz []byte) error {
var alias vestingAccountJSON
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
cva.BaseVestingAccount = &BaseVestingAccount{
BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence),
OriginalVesting: alias.OriginalVesting,
DelegatedFree: alias.DelegatedFree,
DelegatedVesting: alias.DelegatedVesting,
EndTime: alias.EndTime,
}
cva.StartTime = alias.StartTime
return nil
}
func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins {
var vestedCoins sdk.Coins
// We must handle the case where the start time for a vesting account has
// been set into the future or when the start of the chain is not exactly
// known.
if blockTime.Unix() <= cva.StartTime {
return vestedCoins
} else if blockTime.Unix() >= cva.EndTime {
return cva.OriginalVesting
}
// calculate the vesting scalar
x := blockTime.Unix() - cva.StartTime
y := cva.EndTime - cva.StartTime
s := sdk.NewDec(x).Quo(sdk.NewDec(y))
for _, ovc := range cva.OriginalVesting {
vestedAmt := ovc.Amount.ToDec().Mul(s).RoundInt()
vestedCoins = append(vestedCoins, sdk.NewCoin(ovc.Denom, vestedAmt))
}
return vestedCoins
}
func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
return cva.OriginalVesting.Sub(cva.GetVestedCoins(blockTime))
}
func (cva ContinuousVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins {
return cva.BaseVestingAccount.SpendableCoinsVestingAccount(cva.GetVestingCoins(blockTime))
}
func (cva ContinuousVestingAccount) GetStartTime() int64 {
return cva.StartTime
}
//-----------------------------------------------------------------------------
// Periodic Vesting Account
type PeriodicVestingAccount struct {
*BaseVestingAccount
StartTime int64 `json:"start_time" yaml:"start_time"` // when the coins start to vest
VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"` // the vesting schedule
}
// NewPeriodicVestingAccountRaw creates a new PeriodicVestingAccount object from BaseVestingAccount
func NewPeriodicVestingAccountRaw(bva *BaseVestingAccount, startTime int64, periods Periods) *PeriodicVestingAccount {
return &PeriodicVestingAccount{
BaseVestingAccount: bva,
StartTime: startTime,
VestingPeriods: periods,
}
}
func (pva PeriodicVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins {
var vestedCoins sdk.Coins
// We must handle the case where the start time for a vesting account has
// been set into the future or when the start of the chain is not exactly
// known.
if blockTime.Unix() <= pva.StartTime {
return vestedCoins
} else if blockTime.Unix() >= pva.EndTime {
return pva.OriginalVesting
}
// track the start time of the next period
currentPeriodStartTime := pva.StartTime
// for each period, if the period is over, add those coins as vested and check the next period.
for _, period := range pva.VestingPeriods {
x := blockTime.Unix() - currentPeriodStartTime
if x < period.Length {
break
}
vestedCoins = vestedCoins.Add(period.Amount...)
// Update the start time of the next period
currentPeriodStartTime += period.Length
}
return vestedCoins
}
func (pva PeriodicVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
vestedCoins := pva.GetVestedCoins(blockTime)
return pva.OriginalVesting.Sub(vestedCoins)
}
func (pva PeriodicVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins {
vestingCoins := pva.GetVestingCoins(blockTime)
return pva.BaseVestingAccount.SpendableCoinsVestingAccount(vestingCoins)
}
func (pva PeriodicVestingAccount) GetStartTime() int64 {
return pva.StartTime
}
//-----------------------------------------------------------------------------
// Delayed Vesting Account
type DelayedVestingAccount struct {
*BaseVestingAccount
}
// UnmarshalJSON unmarshals raw JSON bytes into a DelayedVestingAccount.
func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error {
var alias vestingAccountJSON
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
dva.BaseVestingAccount = &BaseVestingAccount{
BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence),
OriginalVesting: alias.OriginalVesting,
DelegatedFree: alias.DelegatedFree,
DelegatedVesting: alias.DelegatedVesting,
EndTime: alias.EndTime,
}
return nil
}
// UnmarshalJSON unmarshals raw JSON bytes into a PeriodicVestingAccount.
func (pva *PeriodicVestingAccount) UnmarshalJSON(bz []byte) error {
var alias vestingAccountJSON
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
pva.BaseVestingAccount = &BaseVestingAccount{
BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence),
OriginalVesting: alias.OriginalVesting,
DelegatedFree: alias.DelegatedFree,
DelegatedVesting: alias.DelegatedVesting,
EndTime: alias.EndTime,
}
pva.StartTime = alias.StartTime
pva.VestingPeriods = alias.VestingPeriods
return nil
}
func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins {
if blockTime.Unix() >= dva.EndTime {
return dva.OriginalVesting
}
return nil
}
func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
return dva.OriginalVesting.Sub(dva.GetVestedCoins(blockTime))
}
func (dva DelayedVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins {
return dva.BaseVestingAccount.SpendableCoinsVestingAccount(dva.GetVestingCoins(blockTime))
}
func (dva DelayedVestingAccount) GetStartTime() int64 {
return 0
}
type ModuleAccount struct {
*BaseAccount
Name string `json:"name" yaml:"name"` // name of the module
Permissions []string `json:"permissions" yaml:"permissions"` // permissions of module account
}
type moduleAccountPretty struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"`
PubKey string `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
Name string `json:"name" yaml:"name"`
Permissions []string `json:"permissions" yaml:"permissions"`
}
// UnmarshalJSON unmarshals raw JSON bytes into a ModuleAccount.
func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error {
var alias moduleAccountPretty
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
ma.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, nil, alias.AccountNumber, alias.Sequence)
ma.Name = alias.Name
ma.Permissions = alias.Permissions
return nil
}
type VestingProgress struct {
PeriodComplete bool `json:"period_complete" yaml:"period_complete"`
VestingSuccessful bool `json:"vesting_successful" yaml:"vesting_successful"`
}
type CurrentPeriodProgress struct {
MissedBlocks int64 `json:"missed_blocks" yaml:"missed_blocks"`
TotalBlocks int64 `json:"total_blocks" yaml:"total_blocks"`
}
type ValidatorVestingAccount struct {
*PeriodicVestingAccount
ValidatorAddress sdk.ConsAddress `json:"validator_address" yaml:"validator_address"`
ReturnAddress sdk.AccAddress `json:"return_address" yaml:"return_address"`
SigningThreshold int64 `json:"signing_threshold" yaml:"signing_threshold"`
CurrentPeriodProgress CurrentPeriodProgress `json:"current_period_progress" yaml:"current_period_progress"`
VestingPeriodProgress []VestingProgress `json:"vesting_period_progress" yaml:"vesting_period_progress"`
DebtAfterFailedVesting sdk.Coins `json:"debt_after_failed_vesting" yaml:"debt_after_failed_vesting"`
}
type validatorVestingAccountJSON struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence" yaml:"sequence"`
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"`
EndTime int64 `json:"end_time" yaml:"end_time"`
// non-base vesting account fields
StartTime int64 `json:"start_time" yaml:"start_time"`
VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"`
ValidatorAddress sdk.ConsAddress `json:"validator_address" yaml:"validator_address"`
ReturnAddress sdk.AccAddress `json:"return_address" yaml:"return_address"`
SigningThreshold int64 `json:"signing_threshold" yaml:"signing_threshold"`
CurrentPeriodProgress CurrentPeriodProgress `json:"current_period_progress" yaml:"current_period_progress"`
VestingPeriodProgress []VestingProgress `json:"vesting_period_progress" yaml:"vesting_period_progress"`
DebtAfterFailedVesting sdk.Coins `json:"debt_after_failed_vesting" yaml:"debt_after_failed_vesting"`
}
// UnmarshalJSON unmarshals raw JSON bytes into a ValidatorVestingAccount.
func (vva *ValidatorVestingAccount) UnmarshalJSON(bz []byte) error {
var alias validatorVestingAccountJSON
if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil {
return err
}
ba := NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence)
bva := &BaseVestingAccount{
BaseAccount: ba,
OriginalVesting: alias.OriginalVesting,
DelegatedFree: alias.DelegatedFree,
DelegatedVesting: alias.DelegatedVesting,
EndTime: alias.EndTime,
}
pva := NewPeriodicVestingAccountRaw(bva, alias.StartTime, alias.VestingPeriods)
vva.PeriodicVestingAccount = pva
vva.ValidatorAddress = alias.ValidatorAddress
vva.ReturnAddress = alias.ReturnAddress
vva.SigningThreshold = alias.SigningThreshold
vva.CurrentPeriodProgress = alias.CurrentPeriodProgress
vva.VestingPeriodProgress = alias.VestingPeriodProgress
vva.DebtAfterFailedVesting = alias.DebtAfterFailedVesting
return nil
}
func (vva ValidatorVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins {
var vestedCoins sdk.Coins
if blockTime.Unix() <= vva.StartTime {
return vestedCoins
}
currentPeriodStartTime := vva.StartTime
numberPeriods := len(vva.VestingPeriods)
for i := 0; i < numberPeriods; i++ {
x := blockTime.Unix() - currentPeriodStartTime
if x >= vva.VestingPeriods[i].Length {
if vva.VestingPeriodProgress[i].PeriodComplete {
vestedCoins = vestedCoins.Add(vva.VestingPeriods[i].Amount...)
}
currentPeriodStartTime += vva.VestingPeriods[i].Length
} else {
break
}
}
return vestedCoins
}
func (vva ValidatorVestingAccount) GetFailedVestedCoins() sdk.Coins {
var failedVestedCoins sdk.Coins
numberPeriods := len(vva.VestingPeriods)
for i := 0; i < numberPeriods; i++ {
if vva.VestingPeriodProgress[i].PeriodComplete {
if !vva.VestingPeriodProgress[i].VestingSuccessful {
failedVestedCoins = failedVestedCoins.Add(vva.VestingPeriods[i].Amount...)
}
} else {
break
}
}
return failedVestedCoins
}
func (vva ValidatorVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins {
return vva.OriginalVesting.Sub(vva.GetVestedCoins(blockTime))
}
func (vva ValidatorVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins {
return vva.BaseVestingAccount.SpendableCoinsVestingAccount(vva.GetVestingCoins(blockTime))
}
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cryptocodec.RegisterCrypto(cdc)
cdc.RegisterInterface((*GenesisAccount)(nil), nil)
cdc.RegisterInterface((*Account)(nil), nil)
cdc.RegisterInterface((*VestingAccount)(nil), nil)
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil)
cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil)
cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil)
cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil)
cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil)
cdc.RegisterConcrete(&ValidatorVestingAccount{}, "cosmos-sdk/ValidatorVestingAccount", nil)
cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil)
}

View File

@ -1,56 +0,0 @@
package v0_16
import (
"encoding/json"
"fmt"
"time"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/kava-labs/kava/app"
tmtypes "github.com/tendermint/tendermint/types"
)
var (
GenesisTime = time.Date(2022, 1, 19, 16, 0, 0, 0, time.UTC)
ChainID = "kava-9"
)
func setConfigIfUnsealed() {
config := sdk.GetConfig()
if config.GetBech32AccountAddrPrefix() == "kava" {
return
}
app.SetSDKConfig()
}
// Migrate converts v15 genesis doc to v16 genesis doc
func Migrate(genDoc *tmtypes.GenesisDoc, ctx client.Context) (*tmtypes.GenesisDoc, error) {
setConfigIfUnsealed()
var appState genutiltypes.AppMap
var err error
if err := json.Unmarshal(genDoc.AppState, &appState); err != nil {
return nil, fmt.Errorf("failed to marchal app state from genesis doc: %w", err)
}
MigrateCosmosAppState(appState, ctx, GenesisTime)
migrateKavaAppState(appState, ctx)
genDoc.AppState, err = json.Marshal(appState)
if err != nil {
return nil, err
}
genDoc.GenesisTime = GenesisTime
genDoc.ChainID = ChainID
genDoc.InitialHeight = 1
genDoc.ConsensusParams.Version.AppVersion = 1
genDoc.ConsensusParams.Evidence.MaxBytes = 50000
return genDoc, nil
}

View File

@ -1,99 +0,0 @@
# kava-9 Upgrade Instructions
## Software Version and Key Dates
- We will be upgrading from chain-id "kava-8" to chain-id "kava-9".
- The version of Kava for kava-9 is v0.16.0
- The kava-8 chain will be shutdown with a `SoftwareUpgradeProposal` that activates at block height __1803250__, which is approximately 14:00 UTC on January, 19 2022.
- kava-9 genesis time is set to January 19, 2022 at 16:00 UTC
- The version of cosmos-sdk for kava-9 is v0.44.5
- The version of tendermint for kava-9 v0.34.14
- The minimum version of golang for kava-9 is __1.17+__.
__NOTE__: As part of the upgrade to kava-9, the `kvd` and `kvcli` binaries were combined into a single blockchain binary named `kava`. When restarting the chain, be sure to use `kava start` and not the deprecated `kvd start`.
### Risks
As a validator, performing the upgrade procedure on your consensus nodes carries a heightened risk of double-signing and being slashed. The most important piece of this procedure is verifying your software version and genesis file hash before starting your validator and signing.
The riskiest thing a validator can do is discover that they made a mistake and repeat the upgrade procedure again during the network startup. If you discover a mistake in the process, the best thing to do is wait for the network to start before correcting it. If the network is halted and you have started with a different genesis file than the expected one, seek advice from a Kava developer before resetting your validator.
### Recovery
Prior to exporting kava-8 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.15.2 of the Kava software and restore to their latest snapshot before restarting their nodes.
## Upgrade Procedure
### Before the upgrade
Kava Labs has submitted a `SoftwareUpgradeProposal` that specifies block height __1803250__ as the final block height for kava-8. This height corresponds to approximately 14:00 UTC on January 19th. Once the proposal passes, the chain will shutdown automatically at the specified height and does not require manual intervention by validators.
### On the day of the upgrade
**The kava chain is expected to halt at block height __1803250__, at approximately 14:00 UTC, and restart with new software at 16:00 UTC January 19th. Do not stop your node and begin the upgrade before 14:00UTC on January 19th, or you may go offline and be unable to recover until after the upgrade!**
**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.15.x**)
```sh
# verify version before export:
kvd version --long
# name: kava
# server_name: kvd
# client_name: kvcli
# version: 0.15.0 (any 0.15 version is fine)
# commit: 8691ac44ed0e65db7ebc4a2fe85c58c717f63c39
# build_tags: netgo,ledger
# go: go version go1.17.1 linux/amd64
# export genesis using v0.15.x
kvd export --for-zero-height --height 1803249 > export-genesis.json
```
**Note:** This can take a while!
2. Update to kava-9
```sh
# in the `kava` folder
git pull
git checkout v0.16.0
make install
# verify versions
kava version --long
# name: kava
# server_name: kava
# version: v0.16.0
# commit: [PLACEHOLDER]
# build_tags: netgo,ledger
# go: go version go1.17.1 linux/amd64
# Migrate genesis state
kava migrate export-genesis.json > genesis.json
# Verify output of genesis migration
kava validate-genesis genesis.json # should say it's valid
kava assert-invariants genesis.json # should say invariants pass
jq -S -c -M '' genesis.json | shasum -a 256
# [PLACEHOLDER]
# Restart node with migrated genesis state
cp genesis.json ~/.kava/config/genesis.json
kava unsafe-reset-all
# Restart node -
# ! Be sure to remove --halt-time flag if it is set in systemd/docker
# NOTE: THE BINARY IS NOW NAMED KAVA
kava start
```
### Coordination
If the kava-9 chain does not launch by January 19, 2022 at 20:00 UTC, the launch should be considered a failure and validators should refer to the [rollback](./rollback.md) instructions to restart the previous kava-8 chain. In the event of launch failure, coordination will occur in the [Kava discord](https://discord.com/invite/kQzh3Uv).

View File

@ -1,183 +0,0 @@
package v0_16
import (
"io/ioutil"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
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"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/migrate/v0_16/legacyaccounts"
)
func TestMigrateGenesisDoc(t *testing.T) {
expected := getTestDataJSON("genesis-v16.json")
genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v15.json"))
assert.NoError(t, err)
actualGenDoc, err := Migrate(genDoc, newClientContext())
assert.NoError(t, err)
actualJson, err := tmjson.Marshal(actualGenDoc)
assert.NoError(t, err)
assert.JSONEq(t, expected, string(actualJson))
assert.LessOrEqual(t, actualGenDoc.ConsensusParams.Evidence.MaxBytes, actualGenDoc.ConsensusParams.Block.MaxBytes)
}
func TestMigrateFull(t *testing.T) {
t.Skip() // avoid committing mainnet state - test also currently fails due to https://github.com/cosmos/cosmos-sdk/issues/10862. If you apply the patch, it will pass
genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "kava-8-block-1627000.json"))
assert.NoError(t, err)
newGenDoc, err := Migrate(genDoc, newClientContext())
assert.NoError(t, err)
encodingConfig := app.MakeEncodingConfig()
var appMap genutiltypes.AppMap
err = tmjson.Unmarshal(newGenDoc.AppState, &appMap)
assert.NoError(t, err)
err = app.ModuleBasics.ValidateGenesis(encodingConfig.Marshaler, encodingConfig.TxConfig, appMap)
assert.NoError(t, err)
tApp := app.NewTestApp()
require.NotPanics(t, func() {
tApp.InitializeFromGenesisStatesWithTimeAndChainID(newGenDoc.GenesisTime, newGenDoc.ChainID, app.GenesisState(appMap))
})
}
func TestAccountBalances(t *testing.T) {
t.Skip() // avoid committing test data
setConfigIfUnsealed()
// load auth state from kava-8 with empty accounts removed (keeps size down)
authbz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-8-test-auth-state.json"))
require.NoError(t, err)
// load bank state from kava-8, required for migration
bankbz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-8-test-bank-state.json"))
require.NoError(t, err)
// load supply state from kava-8, required for migration
supplybz, err := ioutil.ReadFile(filepath.Join("testdata", "kava-8-test-supply-state.json"))
require.NoError(t, err)
// codec to read old auth data
v039Codec := codec.NewLegacyAmino()
legacyaccounts.RegisterLegacyAminoCodec(v039Codec)
// store old auth genesis state for comparison to migrated state
var prevAuthGenState legacyaccounts.GenesisState
v039Codec.MustUnmarshalJSON(authbz, &prevAuthGenState)
// migrate auth state to kava-9, with periodic vesting account changes and bank conversion
appState := genutiltypes.AppMap{
v039auth.ModuleName: authbz,
v038bank.ModuleName: bankbz,
v036supply.ModuleName: supplybz,
}
clientCtx := newClientContext()
appState = MigrateCosmosAppState(appState, clientCtx, GenesisTime)
// store new auth and bank state
var migratedAuthGenState authtypes.GenesisState
clientCtx.Codec.MustUnmarshalJSON(appState[authtypes.ModuleName], &migratedAuthGenState)
var migratedBankGenState banktypes.GenesisState
clientCtx.Codec.MustUnmarshalJSON(appState[banktypes.ModuleName], &migratedBankGenState)
// store map of accouauthexportednt coins from the bank module
migratedAccCoins := make(map[string]sdk.Coins)
for _, bal := range migratedBankGenState.Balances {
migratedAccCoins[bal.Address] = bal.Coins
}
for i, anyAcc := range migratedAuthGenState.Accounts {
var acc authtypes.AccountI
err := clientCtx.InterfaceRegistry.UnpackAny(anyAcc, &acc)
require.NoError(t, err)
oldAcc := prevAuthGenState.Accounts[i]
oldAcc.SpendableCoins(GenesisTime)
newBalance, ok := migratedAccCoins[acc.GetAddress().String()]
// all accounts have a corresponding balance
require.True(t, ok, "expected balance to exist")
// this is the same account
require.Equal(t, oldAcc.GetAddress(), acc.GetAddress(), "expected account address to match")
// the owned coins did not change
require.Equal(t, oldAcc.GetCoins(), newBalance, "expected base coins to not change")
// ensure spenable coins at genesis time is equal
require.Equal(t, oldAcc.SpendableCoins(GenesisTime), getSpendableCoinsForAccount(acc, newBalance, GenesisTime), "expected spendable coins to not change")
// check 30 days
futureDate := GenesisTime.Add(30 * 24 * time.Hour)
require.Equal(t, oldAcc.SpendableCoins(futureDate), getSpendableCoinsForAccount(acc, newBalance, futureDate), "expected spendable coins to not change")
// check 90 days
futureDate = GenesisTime.Add(90 * 24 * time.Hour)
require.Equal(t, oldAcc.SpendableCoins(futureDate), getSpendableCoinsForAccount(acc, newBalance, futureDate), "expected spendable coins to not change")
// check 180 days
futureDate = GenesisTime.Add(180 * 24 * time.Hour)
require.Equal(t, oldAcc.SpendableCoins(futureDate), getSpendableCoinsForAccount(acc, newBalance, futureDate), "expected spendable coins to not change")
// check 365 days
futureDate = GenesisTime.Add(365 * 24 * time.Hour)
require.Equal(t, oldAcc.SpendableCoins(futureDate), getSpendableCoinsForAccount(acc, newBalance, futureDate), "expected spendable coins to not change")
// check 2 years
futureDate = GenesisTime.Add(2 * 365 * 24 * time.Hour)
require.Equal(t, oldAcc.SpendableCoins(futureDate), getSpendableCoinsForAccount(acc, newBalance, futureDate), "expected spendable coins to not change")
if vacc, ok := acc.(*vestingtypes.PeriodicVestingAccount); ok {
// old account must be a periodic vesting account
oldVacc, ok := oldAcc.(*legacyaccounts.PeriodicVestingAccount)
require.True(t, ok)
// total delegated coins must match
oldTotalDelegated := oldVacc.DelegatedFree.Add(oldVacc.DelegatedVesting...)
newTotalDelegated := vacc.DelegatedFree.Add(vacc.DelegatedVesting...)
require.Equal(t, oldTotalDelegated, newTotalDelegated, "expected total amount of tracked delegations to not change")
// delegated vesting must be less or equal to original vesting
require.True(t, vacc.DelegatedVesting.IsAllLTE(vacc.OriginalVesting), "expected delegated vesting to be less or equal to original vesting")
// vested coins must be nil for the new account
require.Equal(t, sdk.Coins(nil), vacc.GetVestedCoins(GenesisTime), "expected no vested coins at genesis time")
// vesting coins must not be nil
require.NotEqual(t, sdk.Coins(nil), vacc.GetVestingCoins(GenesisTime), "expected vesting coins to be greater than 0")
// new account as less than or equal
require.LessOrEqual(t, len(vacc.VestingPeriods), len(oldVacc.VestingPeriods), "expected vesting periods of new account to be less than or equal to old")
// start time should equal genesis time
require.Equal(t, vacc.StartTime, GenesisTime.Unix(), "expected start time to be equal to genesis time")
// end time should not change
require.Equal(t, oldVacc.EndTime, vacc.EndTime, "expected end time to not change")
// end time should be after genesis time
require.Greater(t, vacc.EndTime, GenesisTime.Unix(), "expected end time to be after genesis time")
// vesting account must have one or more periods
require.GreaterOrEqual(t, len(vacc.VestingPeriods), 1, "expected one or more vesting periods")
}
}
}
func getSpendableCoinsForAccount(acc authtypes.AccountI, balance sdk.Coins, blockTime time.Time) sdk.Coins {
if vacc, ok := acc.(vestexported.VestingAccount); ok {
return balance.Sub(vacc.LockedCoins(blockTime))
}
return balance
}

View File

@ -1,231 +0,0 @@
package v0_16
import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/stretchr/testify/assert"
)
func createVestingAccount(balance sdk.Coins, vestingStart time.Time, vestingPeriods vestingtypes.Periods) *vestingtypes.PeriodicVestingAccount {
key := secp256k1.GenPrivKey()
pub := key.PubKey()
addr := sdk.AccAddress(pub.Address())
acc := authtypes.NewBaseAccount(addr, pub, 1, 1)
originalVesting := sdk.NewCoins()
for _, vp := range vestingPeriods {
originalVesting = originalVesting.Add(vp.Amount...)
}
return vestingtypes.NewPeriodicVestingAccount(acc, originalVesting, vestingStart.Unix(), vestingPeriods)
}
func TestResetPeriodVestingAccount_NoVestingPeriods(t *testing.T) {
vestingStartTime := time.Now().Add(-1 * time.Hour)
vacc := createVestingAccount(sdk.Coins{}, vestingStartTime, vestingtypes.Periods{})
newVestingStartTime := vestingStartTime.Add(time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.Coins{}, vacc.OriginalVesting, "expected original vesting to be zero")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, newVestingStartTime.Unix(), vacc.EndTime, "expected vesting end time to be updated")
assert.Equal(t, []vestingtypes.Period{}, vacc.VestingPeriods, "expected vesting periods to be empty")
}
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 15 days (-15 days in past)
Amount: balance,
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.Coins{}, vacc.OriginalVesting, "expected original vesting to be zero")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, newVestingStartTime.Unix(), vacc.EndTime, "expected vesting end time to be updated")
assert.Equal(t, []vestingtypes.Period{}, vacc.VestingPeriods, "expected vesting periods to be empty")
}
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 45 * 24 * 60 * 60, // 45 days
Amount: balance,
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
// new period length 15 days
expectedEndtime := newVestingStartTime.Add(15 * 24 * time.Hour).Unix()
// new period length changed, amount unchanged
expectedPeriods := []vestingtypes.Period{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: balance,
},
}
assert.Equal(t, balance, vacc.OriginalVesting, "expected original vesting to be unchanged")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
}
func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 30 * 24 * 60 * 60, // 30 days - exact on the start time
Amount: balance,
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
// new period length is 0
expectedEndtime := newVestingStartTime.Unix()
// new period length changed, amount unchanged
expectedPeriods := []vestingtypes.Period{}
assert.Equal(t, sdk.Coins{}, vacc.OriginalVesting, "expected original vesting to be unchanged")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
}
func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(4e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +30 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
// new period length 15 days
expectedEndtime := newVestingStartTime.Add(30 * 24 * time.Hour).Unix()
// new period length changed, amount unchanged
expectedPeriods := []vestingtypes.Period{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
}
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
}
func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(3e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
vacc.TrackDelegation(vestingStartTime, balance, balance)
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
}
func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(3e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
}
vacc := createVestingAccount(balance, vestingStartTime, periods)
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))))
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified")
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
}

View File

@ -1,45 +0,0 @@
# Kava-9 Rollback Instructions
In the event that the Kava-9 relaunch is unsuccessful, we will restart the Kava-8 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 or 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. Stop your node
```sh
kava stop
```
2. Copy the contents of your backup data directory back to the $KVD_HOME/data directory. By default this is ~/.kvd/data.
```sh
# Assumes backup is stored in "backup" directory
rm -rf ~/.kvd/data
mv backup/.kvd/data ~/.kvd/data
```
3. Install the previous version of kava
```sh
# from kava directory
git checkout v0.15.2
make install
## verify version
kvd version --long
```
4. Start kvd process
```sh
### be sure to remove --halt-time flag if it is set
sudo systemctl daemon-reload
sudo systemctl start kvd
```

View File

@ -1,593 +0,0 @@
{
"auth": {
"accounts": [
{
"type": "cosmos-sdk/ModuleAccount",
"value": {
"address": "kava1cj7njkw2g9fqx4e768zc75dp9sks8u9znxrf0w",
"coins": [
{
"denom": "hard",
"amount": "1000000000000"
},
{
"denom": "swp",
"amount": "1000000000000"
},
{
"denom": "ukava",
"amount": "1000000000000"
}
],
"public_key": null,
"account_number": "0",
"sequence": "0",
"name": "kavadist",
"permissions": ["minter"]
}
},
{
"type": "cosmos-sdk/ModuleAccount",
"value": {
"address": "kava1a42xtwfzphuuu9mdp0es6633wu5mm8fhm789v3",
"coins": [
{
"denom": "usdx",
"amount": "1000000000"
}
],
"public_key": null,
"account_number": "0",
"sequence": "1",
"name": "hard",
"permissions": ["minter", "burner"]
}
},
{
"type": "cosmos-sdk/ModuleAccount",
"value": {
"account_number": "32",
"address": "kava1mfru9azs5nua2wxcd4sq64g5nt7nn4n8s2w8cu",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
},
{
"amount": "4100000000000",
"denom": "usdx"
}
],
"name": "swap",
"permissions": null,
"public_key": "",
"sequence": "3"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1ypjp0m04pyp73hwgtc0dgkx0e9rrydecm054da",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1agcvt07tcw0tglu0hmwdecsnuxp2yd45f3avgm",
"coins": [
{
"amount": "100000000000000",
"denom": "bnb"
},
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": {
"type": "tendermint/PubKeySecp256k1",
"value": "A7WkS5eJAiPE/gl7n4I5qa5JsREvQM5fkdgCEPhNfj0h"
},
"sequence": "0"
}
},
{
"type": "cosmos-sdk/PeriodicVestingAccount",
"value": {
"address": "kava1z3ytjpr6ancl8gw80z6f47z9smug7986x29vtj",
"coins": [
{
"denom": "ukava",
"amount": "565077579"
},
{
"denom": "usdx",
"amount": "1363200"
}
],
"public_key": null,
"account_number": "0",
"sequence": "0",
"original_vesting": [
{
"denom": "ukava",
"amount": "560159828"
}
],
"delegated_free": [],
"delegated_vesting": [],
"end_time": "1628213878",
"start_time": "1596677878",
"vesting_periods": [
{
"length": "31536000",
"amount": [
{
"denom": "ukava",
"amount": "560159828"
}
]
}
]
}
},
{
"type": "cosmos-sdk/PeriodicVestingAccount",
"value": {
"address": "kava1jun8w7meyvgxl68fsjrsdhnv87zursv7dwlgee",
"coins": [
{
"denom": "swp",
"amount": "15915874"
},
{
"denom": "ukava",
"amount": "1000000"
}
],
"public_key": null,
"account_number": "0",
"sequence": "0",
"original_vesting": [
{
"denom": "swp",
"amount": "14791996"
}
],
"delegated_free": [],
"delegated_vesting": [],
"end_time": "1665767828",
"start_time": "1632973114",
"vesting_periods": [
{
"length": "3937114",
"amount": [
{
"denom": "swp",
"amount": "684"
}
]
},
{
"length": "28857600",
"amount": [
{
"denom": "swp",
"amount": "14791312"
}
]
}
]
}
},
{
"type": "cosmos-sdk/ValidatorVestingAccount",
"value": {
"address": "kava1h932rkxxhwf0gz3gq23qsnedgax5vwuxw4ufhy",
"coins": [
{
"denom": "ukava",
"amount": "2499984990625"
}
],
"public_key": null,
"account_number": "0",
"sequence": "0",
"original_vesting": [
{
"denom": "ukava",
"amount": "1499974990625"
}
],
"delegated_free": [],
"delegated_vesting": [],
"end_time": "1636120800",
"start_time": "1572962400",
"vesting_periods": [
{
"length": "31622400",
"amount": [
{
"denom": "ukava",
"amount": "416659707952"
}
]
},
{
"length": "7948800",
"amount": [
{
"denom": "ukava",
"amount": "270828734420"
}
]
},
{
"length": "7689600",
"amount": [
{
"denom": "ukava",
"amount": "270828734420"
}
]
},
{
"length": "7948800",
"amount": [
{
"denom": "ukava",
"amount": "270828734420"
}
]
},
{
"length": "7948800",
"amount": [
{
"denom": "ukava",
"amount": "270829079413"
}
]
}
],
"validator_address": "kavavalcons16mkm6ggf280kjtsxnvzur7tnqttgavj4mzr4zf",
"return_address": "kava1qvsus5qg8yhre7k2c78xkkw4nvqqgev7ezrja8",
"signing_threshold": "90",
"current_period_progress": {
"missed_blocks": "0",
"total_blocks": "1"
},
"vesting_period_progress": [
{
"period_complete": false,
"vesting_successful": false
},
{
"period_complete": false,
"vesting_successful": false
},
{
"period_complete": false,
"vesting_successful": false
},
{
"period_complete": false,
"vesting_successful": false
},
{
"period_complete": false,
"vesting_successful": false
}
],
"debt_after_failed_vesting": []
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "140367",
"address": "kava1kla4wl0ccv7u85cemvs3y987hqk0afcv7vue84",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "140267",
"address": "kava14q5sawxdxtpap5x5sgzj7v4sp3ucncjlpuk3hs",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1tfvn5t8qwngqd2q427za2mel48pcus3z9u73fl",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1j9je7f6s0v6k7dmgv6u5k5ru202f5ffsc7af04",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1ektgdyy0z23qqnd67ns3qvfzgfgjd5xe82lf5c",
"coins": [
{
"amount": "10000000000000000",
"denom": "busd"
},
{
"amount": "10000000000000000",
"denom": "bnb"
},
{
"amount": "10000000000000000",
"denom": "xrpb"
},
{
"amount": "10000000000000000",
"denom": "btcb"
},
{
"amount": "10000000000000000",
"denom": "hbtc"
},
{
"amount": "100000000000000000",
"denom": "usdx"
},
{
"amount": "1000000000000000000",
"denom": "hard"
},
{
"amount": "1000000000000000000",
"denom": "swp"
},
{
"amount": "10000000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1g33w0mh4mjllhaj3y4dcwkwquxgwrma9ga5t94",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1ynf22ap74j6znl503a56y23x5stfr0aw5kntp8",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1fwfwmt6vupf3m9uvpdsuuc4dga8p5dtl4npcqz",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1sw54s6gq76acm35ls6m5c0kr93dstgrh6eftld",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1t4dvu32e309pzhmdn3aqcjlj79h9876plynrfm",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
},
{
"type": "cosmos-sdk/Account",
"value": {
"account_number": "0",
"address": "kava1wuzhkn2f8nqe2aprnwt3jkjvvr9m7dlkpumtz2",
"coins": [
{
"amount": "1000000000000",
"denom": "ukava"
}
],
"public_key": null,
"sequence": "0"
}
}
],
"params": {
"max_memo_characters": "256",
"sig_verify_cost_ed25519": "590",
"sig_verify_cost_secp256k1": "1000",
"tx_sig_limit": "7",
"tx_size_cost_per_byte": "10"
}
},
"bank": {
"send_enabled": true
},
"supply": {
"supply": [
{
"amount": "30467659434006",
"denom": "bnb"
},
{
"amount": "107149210616",
"denom": "btcb"
},
{
"amount": "10290947060016617",
"denom": "busd"
},
{
"amount": "149509607333687",
"denom": "debt"
},
{
"amount": "200000000000000",
"denom": "hard"
},
{
"amount": "50000000000",
"denom": "hbtc"
},
{
"amount": "250000000000000",
"denom": "swp"
},
{
"amount": "149780247604867",
"denom": "ukava"
},
{
"amount": "149509607333687",
"denom": "usdx"
},
{
"amount": "4126898198548806",
"denom": "xrpb"
}
]
}
}

View File

@ -1,342 +0,0 @@
{
"auth": {
"params": {
"max_memo_characters": "256",
"tx_sig_limit": "7",
"tx_size_cost_per_byte": "10",
"sig_verify_cost_ed25519": "590",
"sig_verify_cost_secp256k1": "1000"
},
"accounts": [
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
"address": "kava1cj7njkw2g9fqx4e768zc75dp9sks8u9znxrf0w",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
"name": "kavadist",
"permissions": ["minter"]
},
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
"address": "kava1a42xtwfzphuuu9mdp0es6633wu5mm8fhm789v3",
"pub_key": null,
"account_number": "0",
"sequence": "1"
},
"name": "hard",
"permissions": ["minter", "burner"]
},
{
"@type": "/cosmos.auth.v1beta1.ModuleAccount",
"base_account": {
"address": "kava1mfru9azs5nua2wxcd4sq64g5nt7nn4n8s2w8cu",
"pub_key": null,
"account_number": "32",
"sequence": "3"
},
"name": "swap",
"permissions": []
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1ypjp0m04pyp73hwgtc0dgkx0e9rrydecm054da",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1agcvt07tcw0tglu0hmwdecsnuxp2yd45f3avgm",
"pub_key": {
"@type": "/cosmos.crypto.secp256k1.PubKey",
"key": "A7WkS5eJAiPE/gl7n4I5qa5JsREvQM5fkdgCEPhNfj0h"
},
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1z3ytjpr6ancl8gw80z6f47z9smug7986x29vtj",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount",
"base_vesting_account": {
"base_account": {
"address": "kava1jun8w7meyvgxl68fsjrsdhnv87zursv7dwlgee",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
"original_vesting": [
{
"denom": "swp",
"amount": "14791312"
}
],
"delegated_free": [],
"delegated_vesting": [],
"end_time": "1665767828"
},
"start_time": "1638284400",
"vesting_periods": [
{
"length": "27483428",
"amount": [
{
"denom": "swp",
"amount": "14791312"
}
]
}
]
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1h932rkxxhwf0gz3gq23qsnedgax5vwuxw4ufhy",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1kla4wl0ccv7u85cemvs3y987hqk0afcv7vue84",
"pub_key": null,
"account_number": "140367",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava14q5sawxdxtpap5x5sgzj7v4sp3ucncjlpuk3hs",
"pub_key": null,
"account_number": "140267",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1tfvn5t8qwngqd2q427za2mel48pcus3z9u73fl",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1j9je7f6s0v6k7dmgv6u5k5ru202f5ffsc7af04",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1ektgdyy0z23qqnd67ns3qvfzgfgjd5xe82lf5c",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1g33w0mh4mjllhaj3y4dcwkwquxgwrma9ga5t94",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1ynf22ap74j6znl503a56y23x5stfr0aw5kntp8",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1fwfwmt6vupf3m9uvpdsuuc4dga8p5dtl4npcqz",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1sw54s6gq76acm35ls6m5c0kr93dstgrh6eftld",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1t4dvu32e309pzhmdn3aqcjlj79h9876plynrfm",
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
{
"@type": "/cosmos.auth.v1beta1.BaseAccount",
"address": "kava1wuzhkn2f8nqe2aprnwt3jkjvvr9m7dlkpumtz2",
"pub_key": null,
"account_number": "0",
"sequence": "0"
}
]
},
"bank": {
"params": { "send_enabled": [], "default_send_enabled": true },
"balances": [
{
"address": "kava1cj7njkw2g9fqx4e768zc75dp9sks8u9znxrf0w",
"coins": [
{
"denom": "hard",
"amount": "1000000000000"
},
{ "denom": "swp", "amount": "1000000000000" },
{ "denom": "ukava", "amount": "1000000000000" }
]
},
{
"address": "kava1a42xtwfzphuuu9mdp0es6633wu5mm8fhm789v3",
"coins": [{ "denom": "usdx", "amount": "1000000000" }]
},
{
"address": "kava1mfru9azs5nua2wxcd4sq64g5nt7nn4n8s2w8cu",
"coins": [
{ "denom": "ukava", "amount": "1000000000000" },
{ "denom": "usdx", "amount": "4100000000000" }
]
},
{
"address": "kava1ypjp0m04pyp73hwgtc0dgkx0e9rrydecm054da",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1agcvt07tcw0tglu0hmwdecsnuxp2yd45f3avgm",
"coins": [
{ "denom": "bnb", "amount": "100000000000000" },
{ "denom": "ukava", "amount": "1000000000000" }
]
},
{
"address": "kava1z3ytjpr6ancl8gw80z6f47z9smug7986x29vtj",
"coins": [
{ "denom": "ukava", "amount": "565077579" },
{ "denom": "usdx", "amount": "1363200" }
]
},
{
"address": "kava1jun8w7meyvgxl68fsjrsdhnv87zursv7dwlgee",
"coins": [
{ "denom": "swp", "amount": "15915874" },
{ "denom": "ukava", "amount": "1000000" }
]
},
{
"address": "kava1h932rkxxhwf0gz3gq23qsnedgax5vwuxw4ufhy",
"coins": [{ "denom": "ukava", "amount": "2499984990625" }]
},
{
"address": "kava1kla4wl0ccv7u85cemvs3y987hqk0afcv7vue84",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava14q5sawxdxtpap5x5sgzj7v4sp3ucncjlpuk3hs",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1tfvn5t8qwngqd2q427za2mel48pcus3z9u73fl",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1j9je7f6s0v6k7dmgv6u5k5ru202f5ffsc7af04",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1ektgdyy0z23qqnd67ns3qvfzgfgjd5xe82lf5c",
"coins": [
{ "denom": "bnb", "amount": "10000000000000000" },
{ "denom": "btcb", "amount": "10000000000000000" },
{ "denom": "busd", "amount": "10000000000000000" },
{ "denom": "hard", "amount": "1000000000000000000" },
{ "denom": "hbtc", "amount": "10000000000000000" },
{ "denom": "swp", "amount": "1000000000000000000" },
{ "denom": "ukava", "amount": "10000000000000000" },
{ "denom": "usdx", "amount": "100000000000000000" },
{ "denom": "xrpb", "amount": "10000000000000000" }
]
},
{
"address": "kava1g33w0mh4mjllhaj3y4dcwkwquxgwrma9ga5t94",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1ynf22ap74j6znl503a56y23x5stfr0aw5kntp8",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1acge4tcvhf3q6fh53fgwaa7vsq40wvx6wn50em",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1fwfwmt6vupf3m9uvpdsuuc4dga8p5dtl4npcqz",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1sw54s6gq76acm35ls6m5c0kr93dstgrh6eftld",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1t4dvu32e309pzhmdn3aqcjlj79h9876plynrfm",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
},
{
"address": "kava1wuzhkn2f8nqe2aprnwt3jkjvvr9m7dlkpumtz2",
"coins": [{ "denom": "ukava", "amount": "1000000000000" }]
}
],
"supply": [
{ "denom": "bnb", "amount": "30467659434006" },
{ "denom": "btcb", "amount": "107149210616" },
{ "denom": "busd", "amount": "10290947060016617" },
{ "denom": "debt", "amount": "149509607333687" },
{ "denom": "hard", "amount": "200000000000000" },
{ "denom": "hbtc", "amount": "50000000000" },
{ "denom": "swp", "amount": "250000000000000" },
{ "denom": "ukava", "amount": "149780247604867" },
{ "denom": "usdx", "amount": "149509607333687" },
{ "denom": "xrpb", "amount": "4126898198548806" }
],
"denom_metadata": []
}
}

View File

@ -1,63 +0,0 @@
{
"crisis": {
"constant_fee": {
"amount": "1333000000",
"denom": "ukava"
}
},
"evidence": {
"evidence": null,
"params": {
"max_evidence_age": "1814400000000000"
}
},
"genutil": {
"gentxs": []
},
"mint": {
"minter": {
"annual_provisions": "29956047968909.000000000000000000",
"inflation": "0.200000000000000000"
},
"params": {
"blocks_per_year": "5256000",
"goal_bonded": "0.670000000000000000",
"inflation_max": "0.200000000000000000",
"inflation_min": "0.150000000000000000",
"inflation_rate_change": "0.130000000000000000",
"mint_denom": "ukava"
}
},
"params": null,
"slashing": {
"missed_blocks": {
"kavavalcons1029jhm4lz26q78ftrmazf8hw7lmrt08l2vq3cs": [
{
"index": "3538",
"missed": false
},
{
"index": "3539",
"missed": false
}
]
},
"params": {
"downtime_jail_duration": "600000000000",
"min_signed_per_window": "0.050000000000000000",
"signed_blocks_window": "10000",
"slash_fraction_double_sign": "0.050000000000000000",
"slash_fraction_downtime": "0.000100000000000000"
},
"signing_infos": {
"kavavalcons1wy67mmvmr2ge6apmtfykhnqpejtnd0apaktk72": {
"address": "kavavalcons1wy67mmvmr2ge6apmtfykhnqpejtnd0apaktk72",
"index_offset": "1058101",
"jailed_until": "2021-08-14T05:05:11.063230794Z",
"missed_blocks_counter": "2",
"start_height": "0",
"tombstoned": false
}
}
}
}

View File

@ -1,53 +0,0 @@
{
"crisis": { "constant_fee": { "denom": "ukava", "amount": "1333000000" } },
"evidence": { "evidence": [] },
"genutil": {
"gen_txs": []
},
"mint": {
"minter": {
"inflation": "0.200000000000000000",
"annual_provisions": "29956047968909.000000000000000000"
},
"params": {
"mint_denom": "ukava",
"inflation_rate_change": "0.130000000000000000",
"inflation_max": "0.200000000000000000",
"inflation_min": "0.150000000000000000",
"goal_bonded": "0.670000000000000000",
"blocks_per_year": "5256000"
}
},
"params": null,
"slashing": {
"params": {
"signed_blocks_window": "10000",
"min_signed_per_window": "0.050000000000000000",
"downtime_jail_duration": "600s",
"slash_fraction_double_sign": "0.050000000000000000",
"slash_fraction_downtime": "0.000100000000000000"
},
"signing_infos": [
{
"address": "kavavalcons1wy67mmvmr2ge6apmtfykhnqpejtnd0apaktk72",
"validator_signing_info": {
"address": "kavavalcons1wy67mmvmr2ge6apmtfykhnqpejtnd0apaktk72",
"start_height": "0",
"index_offset": "1058101",
"jailed_until": "2021-08-14T05:05:11.063230794Z",
"tombstoned": false,
"missed_blocks_counter": "2"
}
}
],
"missed_blocks": [
{
"address": "kavavalcons1029jhm4lz26q78ftrmazf8hw7lmrt08l2vq3cs",
"missed_blocks": [
{ "index": "3538", "missed": false },
{ "index": "3539", "missed": false }
]
}
]
}
}

View File

@ -1,132 +0,0 @@
{
"distribution": {
"delegator_starting_infos": [
{
"delegator_address": "kava1qyc2cfl0nw8r95dsdw534x99wq0xcj9rksmhx4",
"starting_info": {
"creation_height": "0",
"previous_period": "1",
"stake": "2998500334.489037908092278841"
},
"validator_address": "kavavaloper1qyc2cfl0nw8r95dsdw534x99wq0xcj9rmxpl7z"
}
],
"delegator_withdraw_infos": [],
"fee_pool": {
"community_pool": [
{
"amount": "16.000000000000000000",
"denom": "hard"
},
{
"amount": "895205479550.000000000000000000",
"denom": "swp"
},
{
"amount": "10026788897860.477125780244640707",
"denom": "ukava"
},
{
"amount": "8830.545647782965054425",
"denom": "usdx"
}
]
},
"outstanding_rewards": [
{
"outstanding_rewards": null,
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v"
},
{
"outstanding_rewards": [
{
"amount": "11080916.970485109335869445",
"denom": "ukava"
},
{
"amount": "0.649424494235324733",
"denom": "usdx"
}
],
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa"
}
],
"params": {
"base_proposer_reward": "0.010000000000000000",
"bonus_proposer_reward": "0.040000000000000000",
"community_tax": "0.000000000000000000",
"withdraw_addr_enabled": false
},
"previous_proposer": "kavavalcons198lz0kngm8eeyfwxlp42rtt4kt3aswsc63tf6t",
"validator_accumulated_commissions": [
{
"accumulated": null,
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v"
},
{
"accumulated": [
{
"amount": "3686239.375558734707570950",
"denom": "ukava"
},
{
"amount": "0.479786725383815797",
"denom": "usdx"
}
],
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa"
}
],
"validator_current_rewards": [
{
"rewards": {
"period": "12",
"rewards": null
},
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v"
},
{
"rewards": {
"period": "55",
"rewards": [
{
"amount": "1573825.556046395044080460",
"denom": "ukava"
}
]
},
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa"
}
],
"validator_historical_rewards": [
{
"period": "40888",
"rewards": {
"cumulative_reward_ratio": [
{
"amount": "0.051970252339178715",
"denom": "ukava"
},
{
"amount": "0.000000007223525470",
"denom": "usdx"
}
],
"reference_count": 1
},
"validator_address": "kavavaloper1ppj7c8tqt2e3rzqtmztsmd6ea6u3nz6qggcp5e"
}
],
"validator_slash_events": [
{
"height": "10001",
"period": "5",
"validator_address": "kavavaloper1u3yuwhuh46nqjvw5pjy6krpcksfm0nyeujw8jz",
"validator_slash_event": {
"fraction": "0.000099999627751999",
"validator_period": "5"
}
}
]
}
}

View File

@ -1,98 +0,0 @@
{
"distribution": {
"params": {
"community_tax": "0.000000000000000000",
"base_proposer_reward": "0.010000000000000000",
"bonus_proposer_reward": "0.040000000000000000",
"withdraw_addr_enabled": false
},
"fee_pool": {
"community_pool": [
{ "denom": "hard", "amount": "16.000000000000000000" },
{ "denom": "swp", "amount": "895205479550.000000000000000000" },
{ "denom": "ukava", "amount": "10026788897860.477125780244640707" },
{ "denom": "usdx", "amount": "8830.545647782965054425" }
]
},
"delegator_withdraw_infos": [],
"previous_proposer": "kavavalcons198lz0kngm8eeyfwxlp42rtt4kt3aswsc63tf6t",
"outstanding_rewards": [
{
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v",
"outstanding_rewards": []
},
{
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa",
"outstanding_rewards": [
{ "denom": "ukava", "amount": "11080916.970485109335869445" },
{ "denom": "usdx", "amount": "0.649424494235324733" }
]
}
],
"validator_accumulated_commissions": [
{
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v",
"accumulated": { "commission": [] }
},
{
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa",
"accumulated": {
"commission": [
{ "denom": "ukava", "amount": "3686239.375558734707570950" },
{ "denom": "usdx", "amount": "0.479786725383815797" }
]
}
}
],
"validator_historical_rewards": [
{
"validator_address": "kavavaloper1ppj7c8tqt2e3rzqtmztsmd6ea6u3nz6qggcp5e",
"period": "40888",
"rewards": {
"cumulative_reward_ratio": [
{ "denom": "ukava", "amount": "0.051970252339178715" },
{ "denom": "usdx", "amount": "0.000000007223525470" }
],
"reference_count": 1
}
}
],
"validator_current_rewards": [
{
"validator_address": "kavavaloper1lv04hlf9tsmha42vd6yetf4r9g0tf3l36v243v",
"rewards": { "rewards": [], "period": "12" }
},
{
"validator_address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa",
"rewards": {
"rewards": [
{ "denom": "ukava", "amount": "1573825.556046395044080460" }
],
"period": "55"
}
}
],
"delegator_starting_infos": [
{
"delegator_address": "kava1qyc2cfl0nw8r95dsdw534x99wq0xcj9rksmhx4",
"validator_address": "kavavaloper1qyc2cfl0nw8r95dsdw534x99wq0xcj9rmxpl7z",
"starting_info": {
"previous_period": "1",
"stake": "2998500334.489037908092278841",
"height": "0"
}
}
],
"validator_slash_events": [
{
"validator_address": "kavavaloper1u3yuwhuh46nqjvw5pjy6krpcksfm0nyeujw8jz",
"height": "10001",
"period": "5",
"validator_slash_event": {
"validator_period": "5",
"fraction": "0.000099999627751999"
}
}
]
}
}

View File

@ -1,127 +0,0 @@
{
"gov": {
"deposit_params": {
"max_deposit_period": "600000000000",
"min_deposit": [{ "amount": "200000000", "denom": "ukava" }]
},
"deposits": null,
"proposals": [
{
"content": {
"type": "cosmos-sdk/TextProposal",
"value": {
"description": "test",
"title": "Nominate Kava Stability Committee"
}
},
"deposit_end_time": "2020-05-27T00:03:48.610420744Z",
"final_tally_result": {
"abstain": "388367903902",
"no": "0",
"no_with_veto": "0",
"yes": "45414514436439"
},
"id": "5",
"proposal_status": "Passed",
"submit_time": "2020-05-13T00:03:48.610420744Z",
"total_deposit": [
{
"amount": "1100000000",
"denom": "ukava"
}
],
"voting_end_time": "2020-05-30T02:13:16.534185463Z",
"voting_start_time": "2020-05-16T02:13:16.534185463Z"
},
{
"content": {
"type": "cosmos-sdk/ParameterChangeProposal",
"value": {
"changes": [
{
"key": "sendenabled",
"subspace": "bank",
"value": "true"
}
],
"description": "Enable transactions",
"title": "Enable Transactions Param Change"
}
},
"deposit_end_time": "2019-11-30T18:31:15.707527932Z",
"final_tally_result": {
"abstain": "0",
"no": "0",
"no_with_veto": "0",
"yes": "56424920427790"
},
"id": "1",
"proposal_status": "Passed",
"submit_time": "2019-11-16T18:31:15.707527932Z",
"total_deposit": [
{
"amount": "1024601000",
"denom": "ukava"
}
],
"voting_end_time": "2019-12-03T02:48:16.507225189Z",
"voting_start_time": "2019-11-19T02:48:16.507225189Z"
},
{
"content": {
"type": "kava/CommunityPoolMultiSpendProposal",
"value": {
"description": "Test multi spend",
"recipient_list": [
{
"address": "kava1vnymr7yzccxm6dtudczdawnmsj9664j4u9d7hq",
"amount": [
{
"amount": "125000000",
"denom": "swp"
}
]
},
{
"address": "kava19c069thwekzlfedw4n23us762n7hf3tgxkez6c",
"amount": [
{
"amount": "125000000",
"denom": "swp"
}
]
}
],
"title": "Kava Swap incentivized testnet winner payouts"
}
},
"deposit_end_time": "2021-10-11T14:16:06.431414048Z",
"final_tally_result": {
"abstain": "628394106179",
"no": "8857306862926",
"no_with_veto": "4093971",
"yes": "1600056548411"
},
"id": "63",
"proposal_status": "Rejected",
"submit_time": "2021-09-27T14:16:06.431414048Z",
"total_deposit": [
{
"amount": "1000000000",
"denom": "ukava"
}
],
"voting_end_time": "2021-10-04T14:16:06.431414048Z",
"voting_start_time": "2021-09-27T14:16:06.431414048Z"
}
],
"starting_proposal_id": "1",
"tally_params": {
"quorum": "0.334000000000000000",
"threshold": "0.500000000000000000",
"veto": "0.334000000000000000"
},
"votes": null,
"voting_params": { "voting_period": "600000000000" }
}
}

View File

@ -1,92 +0,0 @@
{
"gov": {
"starting_proposal_id": "1",
"deposits": [],
"votes": [],
"proposals": [
{
"proposal_id": "5",
"content": {
"@type": "/cosmos.gov.v1beta1.TextProposal",
"title": "Nominate Kava Stability Committee",
"description": "test"
},
"status": "PROPOSAL_STATUS_PASSED",
"final_tally_result": {
"yes": "45414514436439",
"abstain": "388367903902",
"no": "0",
"no_with_veto": "0"
},
"submit_time": "2020-05-13T00:03:48.610420744Z",
"deposit_end_time": "2020-05-27T00:03:48.610420744Z",
"total_deposit": [{ "denom": "ukava", "amount": "1100000000" }],
"voting_start_time": "2020-05-16T02:13:16.534185463Z",
"voting_end_time": "2020-05-30T02:13:16.534185463Z"
},
{
"proposal_id": "1",
"content": {
"@type": "/cosmos.params.v1beta1.ParameterChangeProposal",
"title": "Enable Transactions Param Change",
"description": "Enable transactions",
"changes": [
{ "subspace": "bank", "key": "sendenabled", "value": "true" }
]
},
"status": "PROPOSAL_STATUS_PASSED",
"final_tally_result": {
"yes": "56424920427790",
"abstain": "0",
"no": "0",
"no_with_veto": "0"
},
"submit_time": "2019-11-16T18:31:15.707527932Z",
"deposit_end_time": "2019-11-30T18:31:15.707527932Z",
"total_deposit": [{ "denom": "ukava", "amount": "1024601000" }],
"voting_start_time": "2019-11-19T02:48:16.507225189Z",
"voting_end_time": "2019-12-03T02:48:16.507225189Z"
},
{
"proposal_id": "63",
"content": {
"@type": "/kava.kavadist.v1beta1.CommunityPoolMultiSpendProposal",
"title": "Kava Swap incentivized testnet winner payouts",
"description": "Test multi spend",
"recipient_list": [
{
"address": "kava1vnymr7yzccxm6dtudczdawnmsj9664j4u9d7hq",
"amount": [{ "denom": "swp", "amount": "125000000" }]
},
{
"address": "kava19c069thwekzlfedw4n23us762n7hf3tgxkez6c",
"amount": [{ "denom": "swp", "amount": "125000000" }]
}
]
},
"status": "PROPOSAL_STATUS_REJECTED",
"final_tally_result": {
"yes": "1600056548411",
"abstain": "628394106179",
"no": "8857306862926",
"no_with_veto": "4093971"
},
"submit_time": "2021-09-27T14:16:06.431414048Z",
"deposit_end_time": "2021-10-11T14:16:06.431414048Z",
"total_deposit": [{ "denom": "ukava", "amount": "1000000000" }],
"voting_start_time": "2021-09-27T14:16:06.431414048Z",
"voting_end_time": "2021-10-04T14:16:06.431414048Z"
}
],
"deposit_params": {
"min_deposit": [{ "denom": "ukava", "amount": "200000000" }],
"max_deposit_period": "600s"
},
"voting_params": { "voting_period": "600s" },
"tally_params": {
"quorum": "0.334000000000000000",
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000"
}
}
}

View File

@ -1,83 +0,0 @@
{
"staking": {
"delegations": [
{
"delegator_address": "kava1ll7ekzdq2zanxqgvx7rt8w8d4u7qmys62qq7c9",
"shares": "2989000.000000000000000000",
"validator_address": "kavavaloper1jl42l225565y3hm9dm4my33hjgdzleucqryhlx"
}
],
"exported": true,
"last_total_power": "87090141",
"last_validator_powers": [
{
"Address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa",
"Power": "1135"
}
],
"params": {
"bond_denom": "ukava",
"historical_entries": 0,
"max_entries": 7,
"max_validators": 100,
"unbonding_time": "3600000000000"
},
"redelegations": [
{
"delegator_address": "kava1lu79dv2zncqknysg3qax0am859ee8du0k894qk",
"entries": [
{
"completion_time": "2021-11-21T05:23:07.223503021Z",
"creation_height": "781609",
"initial_balance": "53000000",
"shares_dst": "53000000.000000000000000000"
}
],
"validator_dst_address": "kavavaloper140g8fnnl46mlvfhygj3zvjqlku6x0fwu6lgey7",
"validator_src_address": "kavavaloper1m4maus4725x5x4xzu9ac2rk5eu7thld4g0whvc"
}
],
"unbonding_delegations": [
{
"delegator_address": "kava1ll35md2djrt4q5s4naxedfhq7ghyt9ncf2j5zd",
"entries": [
{
"balance": "176686927",
"completion_time": "2021-11-15T16:52:53.992989413Z",
"creation_height": "710207",
"initial_balance": "176686927"
}
],
"validator_address": "kavavaloper1jl42l225565y3hm9dm4my33hjgdzleucqryhlx"
}
],
"validators": [
{
"commission": {
"commission_rates": {
"max_change_rate": "0.500000000000000000",
"max_rate": "0.500000000000000000",
"rate": "0.500000000000000000"
},
"update_time": "2020-02-05T09:55:51.495267155Z"
},
"consensus_pubkey": "kavavalconspub1zcjduepqyj4j29k7hn58g7n6ert7mm4m7d0kllrx6h5rzzgpvjdt69r80zsq3az2xq",
"delegator_shares": "3000000001.511717782247836219",
"description": {
"details": "\"Trustless Digital Asset Management\", Twitter: @StakeCapital, operated by @bneiluj @leopoldjoy",
"identity": "",
"moniker": "Stake Capital",
"security_contact": "",
"website": ""
},
"jailed": true,
"min_self_delegation": "1",
"operator_address": "kavavaloper1qyc2cfl0nw8r95dsdw534x99wq0xcj9rmxpl7z",
"status": 0,
"tokens": "2998500336",
"unbonding_height": "0",
"unbonding_time": "2021-01-06T14:07:27.057806845Z"
}
]
}
}

View File

@ -1,86 +0,0 @@
{
"staking": {
"params": {
"unbonding_time": "3600s",
"max_validators": 100,
"max_entries": 7,
"historical_entries": 10000,
"bond_denom": "ukava"
},
"last_total_power": "87090141",
"last_validator_powers": [
{
"address": "kavavaloper1leujfugjvuhxqdwlmc7hezra6j5fugk75ttlaa",
"power": "1135"
}
],
"validators": [
{
"operator_address": "kavavaloper1qyc2cfl0nw8r95dsdw534x99wq0xcj9rmxpl7z",
"consensus_pubkey": {
"@type": "/cosmos.crypto.ed25519.PubKey",
"key": "JKslFt686HR6esjX7e67819v/GbV6DEJAWSavRRneKA="
},
"jailed": true,
"status": "BOND_STATUS_UNBONDED",
"tokens": "2998500336",
"delegator_shares": "3000000001.511717782247836219",
"description": {
"moniker": "Stake Capital",
"identity": "",
"website": "",
"security_contact": "",
"details": "\"Trustless Digital Asset Management\", Twitter: @StakeCapital, operated by @bneiluj @leopoldjoy"
},
"unbonding_height": "0",
"unbonding_time": "2021-01-06T14:07:27.057806845Z",
"commission": {
"commission_rates": {
"rate": "0.500000000000000000",
"max_rate": "0.500000000000000000",
"max_change_rate": "0.500000000000000000"
},
"update_time": "2020-02-05T09:55:51.495267155Z"
},
"min_self_delegation": "1"
}
],
"delegations": [
{
"delegator_address": "kava1ll7ekzdq2zanxqgvx7rt8w8d4u7qmys62qq7c9",
"validator_address": "kavavaloper1jl42l225565y3hm9dm4my33hjgdzleucqryhlx",
"shares": "2989000.000000000000000000"
}
],
"unbonding_delegations": [
{
"delegator_address": "kava1ll35md2djrt4q5s4naxedfhq7ghyt9ncf2j5zd",
"validator_address": "kavavaloper1jl42l225565y3hm9dm4my33hjgdzleucqryhlx",
"entries": [
{
"creation_height": "710207",
"completion_time": "2021-11-15T16:52:53.992989413Z",
"initial_balance": "176686927",
"balance": "176686927"
}
]
}
],
"redelegations": [
{
"delegator_address": "kava1lu79dv2zncqknysg3qax0am859ee8du0k894qk",
"validator_src_address": "kavavaloper1m4maus4725x5x4xzu9ac2rk5eu7thld4g0whvc",
"validator_dst_address": "kavavaloper140g8fnnl46mlvfhygj3zvjqlku6x0fwu6lgey7",
"entries": [
{
"creation_height": "781609",
"completion_time": "2021-11-21T05:23:07.223503021Z",
"initial_balance": "53000000",
"shares_dst": "53000000.000000000000000000"
}
]
}
],
"exported": true
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
### Testing kava-9 migration
To verify that the migration procedure for kava-9 is deterministic, run the following commands to compute the genesis hash of a known block.
```sh
# install latest v0.16 release candidate
cd $HOME/kava # replace if location of kava directory is different
git fetch
git checkout v0.16.0-rc3
make install
cd $HOME
# download block 1627000 from kava-8
wget https://kava-genesis-files.s3.amazonaws.com/kava-8/block-export-1627000.json
# run the migration (make sure there are no other kava processes running)
kava migrate block-export-1627000.json > block-export-1627000-migrated.json
# calculate hash of migrated file
jq -S -c -M '' block-export-1627000-migrated.json | shasum -a 256
```

View File

@ -2,6 +2,8 @@ package v0_17
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authz "github.com/cosmos/cosmos-sdk/x/authz"
@ -12,9 +14,16 @@ import (
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
bridgetypes "github.com/kava-labs/kava-bridge/x/bridge/types"
v016auction "github.com/kava-labs/kava/x/auction/legacy/v0_16"
v017auction "github.com/kava-labs/kava/x/auction/legacy/v0_17"
auctiontypes "github.com/kava-labs/kava/x/auction/types"
)
func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
interfaceRegistry := types.NewInterfaceRegistry()
v016auction.RegisterInterfaces(interfaceRegistry)
v16Codec := codec.NewProtoCodec(interfaceRegistry)
codec := clientCtx.Codec
// x/emvutil
@ -54,4 +63,15 @@ func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
// x/authz
authzState := authz.DefaultGenesisState()
appState[authz.ModuleName] = codec.MustMarshalJSON(authzState)
// x/auction
if appState[auctiontypes.ModuleName] != nil {
var v16GenState v016auction.GenesisState
v16Codec.MustUnmarshalJSON(appState[auctiontypes.ModuleName], &v16GenState)
migratedState := v017auction.Migrate(v16GenState)
encodedState := codec.MustMarshalJSON(migratedState)
appState[auctiontypes.ModuleName] = encodedState
}
}

View File

@ -18,6 +18,7 @@ import (
evmtypes "github.com/tharsis/ethermint/x/evm/types"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
auctiontypes "github.com/kava-labs/kava/x/auction/types"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
)
@ -58,6 +59,14 @@ func TestMigrateEvm(t *testing.T) {
})
}
func TestMigrateXAuction(t *testing.T) {
appMap, ctx := migrateToV17AndGetAppMap(t)
var genstate auctiontypes.GenesisState
err := ctx.Codec.UnmarshalJSON(appMap[auctiontypes.ModuleName], &genstate)
assert.NoError(t, err)
assert.Len(t, genstate.Auctions, 3)
}
func TestMigrateFeeMarket(t *testing.T) {
appMap, ctx := migrateToV17AndGetAppMap(t)
var genstate feemarkettypes.GenesisState

View File

@ -22,7 +22,8 @@
"next_auction_id": "12",
"params": {
"max_auction_duration": "172800s",
"bid_duration": "600s",
"forward_bid_duration": "86400s",
"reverse_bid_duration": "3600s",
"increment_surplus": "0.010000000000000000",
"increment_debt": "0.010000000000000000",
"increment_collateral": "0.010000000000000000"

View File

@ -22,11 +22,13 @@ message GenesisState {
// Params defines the parameters for the issuance module.
message Params {
reserved 2;
reserved "bid_duration";
google.protobuf.Duration max_auction_duration = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
google.protobuf.Duration forward_bid_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
google.protobuf.Duration reverse_bid_duration = 6 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
google.protobuf.Duration forward_bid_duration = 6 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
google.protobuf.Duration reverse_bid_duration = 7 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
bytes increment_surplus = 3
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];

View File

@ -0,0 +1,16 @@
package types
import (
types "github.com/cosmos/cosmos-sdk/codec/types"
v017auction "github.com/kava-labs/kava/x/auction/types"
)
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterInterface(
"kava.auction.v1beta1.GenesisAuction",
(*v017auction.GenesisAuction)(nil),
&v017auction.SurplusAuction{},
&v017auction.DebtAuction{},
&v017auction.CollateralAuction{},
)
}

View File

@ -0,0 +1,761 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: kava/auction/v1beta1/genesis.proto
package types
import (
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
types "github.com/cosmos/cosmos-sdk/codec/types"
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
_ "google.golang.org/protobuf/types/known/durationpb"
io "io"
math "math"
math_bits "math/bits"
time "time"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var _ = time.Kitchen
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the auction module's genesis state.
type GenesisState struct {
NextAuctionId uint64 `protobuf:"varint,1,opt,name=next_auction_id,json=nextAuctionId,proto3" json:"next_auction_id,omitempty"`
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
// Genesis auctions
Auctions []*types.Any `protobuf:"bytes,3,rep,name=auctions,proto3" json:"auctions,omitempty"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
func (*GenesisState) ProtoMessage() {}
func (*GenesisState) Descriptor() ([]byte, []int) {
return fileDescriptor_d0e5cb58293042f7, []int{0}
}
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *GenesisState) XXX_Merge(src proto.Message) {
xxx_messageInfo_GenesisState.Merge(m, src)
}
func (m *GenesisState) XXX_Size() int {
return m.Size()
}
func (m *GenesisState) XXX_DiscardUnknown() {
xxx_messageInfo_GenesisState.DiscardUnknown(m)
}
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
// Params defines the parameters for the issuance module.
type Params struct {
MaxAuctionDuration time.Duration `protobuf:"bytes,1,opt,name=max_auction_duration,json=maxAuctionDuration,proto3,stdduration" json:"max_auction_duration"`
BidDuration time.Duration `protobuf:"bytes,2,opt,name=bid_duration,json=bidDuration,proto3,stdduration" json:"bid_duration"`
IncrementSurplus github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=increment_surplus,json=incrementSurplus,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_surplus"`
IncrementDebt github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=increment_debt,json=incrementDebt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_debt"`
IncrementCollateral github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=increment_collateral,json=incrementCollateral,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_collateral"`
}
func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_d0e5cb58293042f7, []int{1}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Params.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Params) XXX_Merge(src proto.Message) {
xxx_messageInfo_Params.Merge(m, src)
}
func (m *Params) XXX_Size() int {
return m.Size()
}
func (m *Params) XXX_DiscardUnknown() {
xxx_messageInfo_Params.DiscardUnknown(m)
}
var xxx_messageInfo_Params proto.InternalMessageInfo
var fileDescriptor_d0e5cb58293042f7 = []byte{
// 466 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x31, 0x6f, 0xd3, 0x40,
0x14, 0xc7, 0x7d, 0x4d, 0x88, 0xaa, 0x4b, 0x5a, 0xe0, 0xf0, 0xe0, 0x56, 0xc8, 0x89, 0x32, 0x54,
0x61, 0xc8, 0x59, 0x0d, 0x1b, 0x5b, 0x4d, 0x44, 0xc5, 0x86, 0x5c, 0x75, 0x81, 0x21, 0xba, 0xb3,
0x0f, 0x63, 0xd5, 0xf6, 0x45, 0xbe, 0x73, 0x95, 0x7c, 0x0b, 0x46, 0x3e, 0x08, 0x03, 0x13, 0x73,
0xc4, 0xd4, 0x11, 0x31, 0x14, 0x48, 0xbe, 0x08, 0xf2, 0xdd, 0xe5, 0x82, 0x80, 0x01, 0x75, 0xca,
0xdd, 0x7b, 0xff, 0xff, 0xef, 0xfd, 0x9f, 0x2e, 0x86, 0xc3, 0x2b, 0x72, 0x4d, 0x02, 0x52, 0xc7,
0x32, 0xe3, 0x65, 0x70, 0x7d, 0x4a, 0x99, 0x24, 0xa7, 0x41, 0xca, 0x4a, 0x26, 0x32, 0x81, 0xe7,
0x15, 0x97, 0x1c, 0xb9, 0x8d, 0x06, 0x1b, 0x0d, 0x36, 0x9a, 0x63, 0x37, 0xe5, 0x29, 0x57, 0x82,
0xa0, 0x39, 0x69, 0xed, 0xf1, 0x51, 0xca, 0x79, 0x9a, 0xb3, 0x40, 0xdd, 0x68, 0xfd, 0x36, 0x20,
0xe5, 0x72, 0xdb, 0x8a, 0xb9, 0x28, 0xb8, 0x98, 0x69, 0x8f, 0xbe, 0x98, 0x96, 0xff, 0xa7, 0x2b,
0xa9, 0x2b, 0xa2, 0xa6, 0xa9, 0xca, 0xf0, 0x13, 0x80, 0xbd, 0x73, 0x9d, 0xe9, 0x42, 0x12, 0xc9,
0xd0, 0x09, 0xbc, 0x5f, 0xb2, 0x85, 0x9c, 0x99, 0x50, 0xb3, 0x2c, 0xf1, 0xc0, 0x00, 0x8c, 0xda,
0xd1, 0x41, 0x53, 0x3e, 0xd3, 0xd5, 0x97, 0x09, 0x7a, 0x06, 0x3b, 0x73, 0x52, 0x91, 0x42, 0x78,
0x7b, 0x03, 0x30, 0xea, 0x4e, 0x1e, 0xe3, 0x7f, 0xed, 0x82, 0x5f, 0x29, 0x4d, 0xd8, 0x5e, 0xdd,
0xf6, 0x9d, 0xc8, 0x38, 0xd0, 0x14, 0xee, 0x1b, 0x9d, 0xf0, 0x5a, 0x83, 0xd6, 0xa8, 0x3b, 0x71,
0xb1, 0xce, 0x89, 0xb7, 0x39, 0xf1, 0x59, 0xb9, 0x0c, 0xd1, 0x97, 0x8f, 0xe3, 0x43, 0x93, 0xce,
0x4c, 0x8e, 0xac, 0x73, 0xf8, 0xb9, 0x05, 0x3b, 0x1a, 0x8f, 0x2e, 0xa1, 0x5b, 0x90, 0x85, 0xcd,
0xbc, 0xdd, 0x51, 0x25, 0xef, 0x4e, 0x8e, 0xfe, 0x82, 0x4f, 0x8d, 0x20, 0xdc, 0x6f, 0x72, 0x7d,
0xf8, 0xde, 0x07, 0x11, 0x2a, 0xc8, 0xc2, 0xcc, 0xd8, 0x76, 0xd1, 0x0b, 0xd8, 0xa3, 0x59, 0xb2,
0xc3, 0xed, 0xfd, 0x3f, 0xae, 0x4b, 0xb3, 0xc4, 0x72, 0xde, 0xc0, 0x87, 0x59, 0x19, 0x57, 0xac,
0x60, 0xa5, 0x9c, 0x89, 0xba, 0x9a, 0xe7, 0x75, 0xb3, 0x38, 0x18, 0xf5, 0x42, 0xdc, 0x38, 0xbe,
0xdd, 0xf6, 0x4f, 0xd2, 0x4c, 0xbe, 0xab, 0x29, 0x8e, 0x79, 0x61, 0x1e, 0xd0, 0xfc, 0x8c, 0x45,
0x72, 0x15, 0xc8, 0xe5, 0x9c, 0x09, 0x3c, 0x65, 0x71, 0xf4, 0xc0, 0x82, 0x2e, 0x34, 0x07, 0x5d,
0xc2, 0xc3, 0x1d, 0x3c, 0x61, 0x54, 0x7a, 0xed, 0x3b, 0x91, 0x0f, 0x2c, 0x65, 0xca, 0xa8, 0x44,
0x04, 0xba, 0x3b, 0x6c, 0xcc, 0xf3, 0x9c, 0x48, 0x56, 0x91, 0xdc, 0xbb, 0x77, 0x27, 0xf8, 0x23,
0xcb, 0x7a, 0x6e, 0x51, 0xe1, 0xf9, 0xea, 0xa7, 0xef, 0xac, 0xd6, 0x3e, 0xb8, 0x59, 0xfb, 0xe0,
0xc7, 0xda, 0x07, 0xef, 0x37, 0xbe, 0x73, 0xb3, 0xf1, 0x9d, 0xaf, 0x1b, 0xdf, 0x79, 0xfd, 0xe4,
0x37, 0x74, 0xf3, 0xd7, 0x1a, 0xe7, 0x84, 0x0a, 0x75, 0x0a, 0x16, 0xf6, 0xb3, 0x52, 0x13, 0x68,
0x47, 0xbd, 0xc4, 0xd3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x20, 0xff, 0x87, 0x73, 0x03,
0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Auctions) > 0 {
for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
}
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if m.NextAuctionId != 0 {
i = encodeVarintGenesis(dAtA, i, uint64(m.NextAuctionId))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *Params) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Params) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size := m.IncrementCollateral.Size()
i -= size
if _, err := m.IncrementCollateral.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
{
size := m.IncrementDebt.Size()
i -= size
if _, err := m.IncrementDebt.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
{
size := m.IncrementSurplus.Size()
i -= size
if _, err := m.IncrementSurplus.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.BidDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidDuration):])
if err2 != nil {
return 0, err2
}
i -= n2
i = encodeVarintGenesis(dAtA, i, uint64(n2))
i--
dAtA[i] = 0x12
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration):])
if err3 != nil {
return 0, err3
}
i -= n3
i = encodeVarintGenesis(dAtA, i, uint64(n3))
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
offset -= sovGenesis(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *GenesisState) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.NextAuctionId != 0 {
n += 1 + sovGenesis(uint64(m.NextAuctionId))
}
l = m.Params.Size()
n += 1 + l + sovGenesis(uint64(l))
if len(m.Auctions) > 0 {
for _, e := range m.Auctions {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
func (m *Params) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration)
n += 1 + l + sovGenesis(uint64(l))
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.BidDuration)
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementSurplus.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementDebt.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementCollateral.Size()
n += 1 + l + sovGenesis(uint64(l))
return n
}
func sovGenesis(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozGenesis(x uint64) (n int) {
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *GenesisState) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field NextAuctionId", wireType)
}
m.NextAuctionId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.NextAuctionId |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Auctions = append(m.Auctions, &types.Any{})
if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Params) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Params: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field MaxAuctionDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAuctionDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BidDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.BidDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementSurplus", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementSurplus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementDebt", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementCollateral", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.IncrementCollateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipGenesis(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowGenesis
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthGenesis
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupGenesis
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthGenesis
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -1,95 +0,0 @@
package v0_16
import (
"fmt"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
v015auction "github.com/kava-labs/kava/x/auction/legacy/v0_15"
v016auction "github.com/kava-labs/kava/x/auction/types"
)
func migrateBaseAuction(auction v015auction.BaseAuction) v016auction.BaseAuction {
return v016auction.BaseAuction{
ID: auction.ID,
Initiator: auction.GetInitiator(),
Lot: auction.GetLot(),
Bidder: auction.GetBidder(),
Bid: auction.GetBid(),
HasReceivedBids: auction.GetHasReceivedBids(),
EndTime: auction.GetEndTime(),
MaxEndTime: auction.GetMaxEndTime(),
}
}
func migrateAuction(auction v015auction.Auction) *codectypes.Any {
var protoAuction v016auction.GenesisAuction
switch auction := auction.(type) {
case v015auction.SurplusAuction:
{
protoAuction = &v016auction.SurplusAuction{
BaseAuction: migrateBaseAuction(auction.BaseAuction),
}
}
case v015auction.DebtAuction:
{
protoAuction = &v016auction.DebtAuction{
BaseAuction: migrateBaseAuction(auction.BaseAuction),
CorrespondingDebt: auction.CorrespondingDebt,
}
}
case v015auction.CollateralAuction:
{
lotReturns := v016auction.WeightedAddresses{
Addresses: auction.LotReturns.Addresses,
Weights: auction.LotReturns.Weights,
}
if err := lotReturns.Validate(); err != nil {
panic(err)
}
protoAuction = &v016auction.CollateralAuction{
BaseAuction: migrateBaseAuction(auction.BaseAuction),
CorrespondingDebt: auction.CorrespondingDebt,
MaxBid: auction.MaxBid,
LotReturns: lotReturns,
}
}
default:
panic(fmt.Errorf("'%s' is not a valid auction", auction))
}
// Convert the content into Any.
contentAny, err := codectypes.NewAnyWithValue(protoAuction)
if err != nil {
panic(err)
}
return contentAny
}
func migrateAuctions(auctions v015auction.GenesisAuctions) []*codectypes.Any {
anyAuctions := make([]*codectypes.Any, len(auctions))
for i, auction := range auctions {
anyAuctions[i] = migrateAuction(auction)
}
return anyAuctions
}
func migrateParams(params v015auction.Params) v016auction.Params {
return v016auction.Params{
MaxAuctionDuration: params.MaxAuctionDuration,
BidDuration: params.BidDuration,
IncrementSurplus: params.IncrementSurplus,
IncrementDebt: params.IncrementDebt,
IncrementCollateral: params.IncrementCollateral,
}
}
func Migrate(oldState v015auction.GenesisState) *v016auction.GenesisState {
return &v016auction.GenesisState{
NextAuctionId: oldState.NextAuctionID,
Params: migrateParams(oldState.Params),
Auctions: migrateAuctions(oldState.Auctions),
}
}

View File

@ -1,238 +0,0 @@
package v0_16
import (
"io/ioutil"
"path/filepath"
"testing"
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
app "github.com/kava-labs/kava/app"
v015auction "github.com/kava-labs/kava/x/auction/legacy/v0_15"
v016auction "github.com/kava-labs/kava/x/auction/types"
)
type migrateTestSuite struct {
suite.Suite
addresses []sdk.AccAddress
v15genstate v015auction.GenesisState
cdc codec.Codec
legacyCdc *codec.LegacyAmino
}
func (s *migrateTestSuite) SetupTest() {
app.SetSDKConfig()
s.v15genstate = v015auction.GenesisState{
NextAuctionID: 1,
Params: v015auction.Params{},
Auctions: v015auction.GenesisAuctions{},
}
config := app.MakeEncodingConfig()
s.cdc = config.Marshaler
legacyCodec := codec.NewLegacyAmino()
v015auction.RegisterLegacyAminoCodec(legacyCodec)
s.legacyCdc = legacyCodec
_, accAddresses := app.GeneratePrivKeyAddressPairs(10)
s.addresses = accAddresses
}
func (s *migrateTestSuite) TestMigrate_JSON() {
// Migrate v15 auction to v16
file := filepath.Join("testdata", "v15-auction.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)
// Compare expect v16 auction json with migrated json
actual := s.cdc.MustMarshalJSON(genstate)
file = filepath.Join("testdata", "v16-auction.json")
expected, err := ioutil.ReadFile(file)
s.Require().NoError(err)
s.Require().JSONEq(string(expected), string(actual))
}
func (s *migrateTestSuite) TestMigrate_Auction() {
now := time.Now()
testcases := []struct {
name string
oldAuction v015auction.GenesisAuction
newAuction v016auction.GenesisAuction
}{
{
name: "collateral auction",
oldAuction: v015auction.CollateralAuction{
BaseAuction: v015auction.BaseAuction{
ID: 1,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 1),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 1),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: true,
},
CorrespondingDebt: sdk.NewInt64Coin("kava", 1),
MaxBid: sdk.NewInt64Coin("kava", 1),
LotReturns: v015auction.WeightedAddresses{
Addresses: s.addresses[:2],
Weights: []sdk.Int{sdk.NewInt(1), sdk.NewInt(1)},
},
},
newAuction: &v016auction.CollateralAuction{
BaseAuction: v016auction.BaseAuction{
ID: 1,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 1),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 1),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: true,
},
CorrespondingDebt: sdk.NewInt64Coin("kava", 1),
MaxBid: sdk.NewInt64Coin("kava", 1),
LotReturns: v016auction.WeightedAddresses{
Addresses: s.addresses[:2],
Weights: []sdk.Int{sdk.NewInt(1), sdk.NewInt(1)},
},
},
},
{
name: "surplus auction",
oldAuction: v015auction.SurplusAuction{
BaseAuction: v015auction.BaseAuction{
ID: 2,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 12),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 12),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: false,
},
},
newAuction: &v016auction.SurplusAuction{
BaseAuction: v016auction.BaseAuction{
ID: 2,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 12),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 12),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: false,
},
},
},
{
name: "debt auction",
oldAuction: v015auction.DebtAuction{
BaseAuction: v015auction.BaseAuction{
ID: 3,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 1),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 1),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: true,
},
CorrespondingDebt: sdk.NewInt64Coin("kava", 20),
},
newAuction: &v016auction.DebtAuction{
BaseAuction: v016auction.BaseAuction{
ID: 3,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 1),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 1),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: true,
},
CorrespondingDebt: sdk.NewInt64Coin("kava", 20),
},
},
}
for _, tc := range testcases {
s.Run(tc.name, func() {
s.v15genstate.Auctions = v015auction.GenesisAuctions{tc.oldAuction}
genState := Migrate(s.v15genstate)
s.Require().Len(genState.Auctions, 1)
expectedAuctions, err := v016auction.UnpackGenesisAuctions(genState.Auctions)
s.Require().NoError(err)
s.Equal(tc.newAuction, expectedAuctions[0])
})
}
}
func (s *migrateTestSuite) TestMigrate_GenState() {
now := time.Now()
v15params := v015auction.Params{
MaxAuctionDuration: time.Duration(time.Hour * 24 * 7),
BidDuration: time.Duration(time.Hour * 24 * 4),
IncrementSurplus: sdk.MustNewDecFromStr("0.01"),
IncrementDebt: sdk.MustNewDecFromStr("0.02"),
IncrementCollateral: sdk.MustNewDecFromStr("0.03"),
}
v16params := v016auction.Params{
MaxAuctionDuration: v15params.MaxAuctionDuration,
BidDuration: v15params.BidDuration,
IncrementSurplus: v15params.IncrementSurplus,
IncrementDebt: v15params.IncrementDebt,
IncrementCollateral: v15params.IncrementCollateral,
}
expectedAuction := &v016auction.SurplusAuction{
BaseAuction: v016auction.BaseAuction{
ID: 2,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 12),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 12),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: false,
},
}
// Prepare v015genstate
s.v15genstate = v015auction.GenesisState{
NextAuctionID: 10,
Params: v15params,
Auctions: v015auction.GenesisAuctions{
v015auction.SurplusAuction{
BaseAuction: v015auction.BaseAuction{
ID: 2,
Initiator: s.addresses[0].String(),
Lot: sdk.NewInt64Coin("kava", 12),
Bidder: s.addresses[1],
Bid: sdk.NewInt64Coin("kava", 12),
EndTime: now,
MaxEndTime: now,
HasReceivedBids: false,
},
},
},
}
expectedGenState, err := v016auction.NewGenesisState(10, v16params, []v016auction.GenesisAuction{expectedAuction})
s.Require().NoError(err)
genState := Migrate(s.v15genstate)
s.Equal(expectedGenState, genState)
}
func TestMigrateTestSuite(t *testing.T) {
suite.Run(t, new(migrateTestSuite))
}

View File

@ -0,0 +1,25 @@
package v0_17
import (
v016auction "github.com/kava-labs/kava/x/auction/legacy/v0_16"
v017auction "github.com/kava-labs/kava/x/auction/types"
)
func Migrate(oldState v016auction.GenesisState) *v017auction.GenesisState {
return &v017auction.GenesisState{
NextAuctionId: oldState.NextAuctionId,
Params: migrateParams(oldState.Params),
Auctions: oldState.Auctions,
}
}
func migrateParams(params v016auction.Params) v017auction.Params {
return v017auction.Params{
MaxAuctionDuration: params.MaxAuctionDuration,
ForwardBidDuration: v017auction.DefaultForwardBidDuration,
ReverseBidDuration: v017auction.DefaultReverseBidDuration,
IncrementSurplus: params.IncrementSurplus,
IncrementDebt: params.IncrementDebt,
IncrementCollateral: params.IncrementCollateral,
}
}

View File

@ -74,8 +74,8 @@ var xxx_messageInfo_GenesisState proto.InternalMessageInfo
// Params defines the parameters for the issuance module.
type Params struct {
MaxAuctionDuration time.Duration `protobuf:"bytes,1,opt,name=max_auction_duration,json=maxAuctionDuration,proto3,stdduration" json:"max_auction_duration"`
ForwardBidDuration time.Duration `protobuf:"bytes,2,opt,name=forward_bid_duration,json=forwardBidDuration,proto3,stdduration" json:"forward_bid_duration"`
ReverseBidDuration time.Duration `protobuf:"bytes,6,opt,name=reverse_bid_duration,json=reverseBidDuration,proto3,stdduration" json:"reverse_bid_duration"`
ForwardBidDuration time.Duration `protobuf:"bytes,6,opt,name=forward_bid_duration,json=forwardBidDuration,proto3,stdduration" json:"forward_bid_duration"`
ReverseBidDuration time.Duration `protobuf:"bytes,7,opt,name=reverse_bid_duration,json=reverseBidDuration,proto3,stdduration" json:"reverse_bid_duration"`
IncrementSurplus github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=increment_surplus,json=incrementSurplus,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_surplus"`
IncrementDebt github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=increment_debt,json=incrementDebt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_debt"`
IncrementCollateral github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=increment_collateral,json=incrementCollateral,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"increment_collateral"`
@ -124,38 +124,38 @@ func init() {
}
var fileDescriptor_d0e5cb58293042f7 = []byte{
// 487 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0x6f, 0xd3, 0x30,
0x18, 0xc6, 0xe3, 0xad, 0x54, 0x93, 0xbb, 0x0d, 0x30, 0x39, 0x64, 0x13, 0x4a, 0xab, 0x1e, 0xa6,
0x72, 0xa8, 0xa3, 0x95, 0x1b, 0xb7, 0x85, 0x4a, 0x13, 0x37, 0x94, 0x69, 0x17, 0x38, 0x44, 0x4e,
0xe2, 0x85, 0x68, 0x49, 0x5c, 0xd9, 0x4e, 0x69, 0xbf, 0x05, 0x47, 0x3e, 0x00, 0x1f, 0x81, 0x03,
0x1f, 0xa1, 0xe2, 0xb4, 0x23, 0xe2, 0x30, 0xa0, 0xfd, 0x22, 0x28, 0xb6, 0x9b, 0x96, 0x3f, 0x97,
0xed, 0x14, 0xfb, 0x7d, 0x9f, 0xe7, 0xf7, 0x3e, 0x4e, 0x1c, 0xd8, 0xbf, 0x26, 0x53, 0xe2, 0x91,
0x2a, 0x96, 0x19, 0x2b, 0xbd, 0xe9, 0x69, 0x44, 0x25, 0x39, 0xf5, 0x52, 0x5a, 0x52, 0x91, 0x09,
0x3c, 0xe1, 0x4c, 0x32, 0x64, 0xd7, 0x1a, 0x6c, 0x34, 0xd8, 0x68, 0x8e, 0xed, 0x94, 0xa5, 0x4c,
0x09, 0xbc, 0x7a, 0xa5, 0xb5, 0xc7, 0x47, 0x29, 0x63, 0x69, 0x4e, 0x3d, 0xb5, 0x8b, 0xaa, 0x2b,
0x8f, 0x94, 0xf3, 0x75, 0x2b, 0x66, 0xa2, 0x60, 0x22, 0xd4, 0x1e, 0xbd, 0x31, 0x2d, 0xf7, 0x6f,
0x57, 0x52, 0x71, 0xa2, 0xa6, 0xa9, 0x4a, 0xff, 0x0b, 0x80, 0xfb, 0xe7, 0x3a, 0xd3, 0x85, 0x24,
0x92, 0xa2, 0x13, 0xf8, 0xb0, 0xa4, 0x33, 0x19, 0x9a, 0x50, 0x61, 0x96, 0x38, 0xa0, 0x07, 0x06,
0xad, 0xe0, 0xa0, 0x2e, 0x9f, 0xe9, 0xea, 0xab, 0x04, 0xbd, 0x80, 0xed, 0x09, 0xe1, 0xa4, 0x10,
0xce, 0x4e, 0x0f, 0x0c, 0x3a, 0xa3, 0xa7, 0xf8, 0x7f, 0x67, 0xc1, 0xaf, 0x95, 0xc6, 0x6f, 0x2d,
0x6e, 0xbb, 0x56, 0x60, 0x1c, 0x68, 0x0c, 0xf7, 0x8c, 0x4e, 0x38, 0xbb, 0xbd, 0xdd, 0x41, 0x67,
0x64, 0x63, 0x9d, 0x13, 0xaf, 0x73, 0xe2, 0xb3, 0x72, 0xee, 0xa3, 0xaf, 0x9f, 0x87, 0x87, 0x26,
0x9d, 0x99, 0x1c, 0x34, 0xce, 0xfe, 0xa7, 0x16, 0x6c, 0x6b, 0x3c, 0xba, 0x84, 0x76, 0x41, 0x66,
0x4d, 0xe6, 0xf5, 0x19, 0x55, 0xf2, 0xce, 0xe8, 0xe8, 0x1f, 0xf8, 0xd8, 0x08, 0xfc, 0xbd, 0x3a,
0xd7, 0xc7, 0x1f, 0x5d, 0x10, 0xa0, 0x82, 0xcc, 0xcc, 0x8c, 0x75, 0xb7, 0xc6, 0x5e, 0x31, 0xfe,
0x9e, 0xf0, 0x24, 0x8c, 0xb2, 0x64, 0x83, 0xdd, 0xb9, 0x03, 0xd6, 0x00, 0xfc, 0x2c, 0xd9, 0xc6,
0x72, 0x3a, 0xa5, 0x5c, 0xd0, 0x3f, 0xb1, 0xed, 0x3b, 0x60, 0x0d, 0x60, 0x1b, 0xfb, 0x16, 0x3e,
0xce, 0xca, 0x98, 0xd3, 0x82, 0x96, 0x32, 0x14, 0x15, 0x9f, 0xe4, 0x55, 0xfd, 0x7a, 0xc1, 0x60,
0xdf, 0xc7, 0xb5, 0xf1, 0xfb, 0x6d, 0xf7, 0x24, 0xcd, 0xe4, 0xbb, 0x2a, 0xc2, 0x31, 0x2b, 0xcc,
0x35, 0x31, 0x8f, 0xa1, 0x48, 0xae, 0x3d, 0x39, 0x9f, 0x50, 0x81, 0xc7, 0x34, 0x0e, 0x1e, 0x35,
0xa0, 0x0b, 0xcd, 0x41, 0x97, 0xf0, 0x70, 0x03, 0x4f, 0x68, 0x24, 0x9d, 0xd6, 0xbd, 0xc8, 0x07,
0x0d, 0x65, 0x4c, 0x23, 0x89, 0x08, 0xb4, 0x37, 0xd8, 0x98, 0xe5, 0x39, 0x91, 0x94, 0x93, 0xdc,
0x79, 0x70, 0x2f, 0xf8, 0x93, 0x86, 0xf5, 0xb2, 0x41, 0xf9, 0xe7, 0x8b, 0x5f, 0xae, 0xb5, 0x58,
0xba, 0xe0, 0x66, 0xe9, 0x82, 0x9f, 0x4b, 0x17, 0x7c, 0x58, 0xb9, 0xd6, 0xcd, 0xca, 0xb5, 0xbe,
0xad, 0x5c, 0xeb, 0xcd, 0xb3, 0x2d, 0x74, 0x7d, 0x81, 0x87, 0x39, 0x89, 0x84, 0x5a, 0x79, 0xb3,
0xe6, 0xe7, 0x55, 0x13, 0xa2, 0xb6, 0xfa, 0x20, 0xcf, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x71,
0x67, 0x8c, 0x47, 0xd9, 0x03, 0x00, 0x00,
// 496 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xc1, 0x6e, 0xd3, 0x30,
0x18, 0xc7, 0x93, 0x35, 0x94, 0xca, 0xed, 0xc6, 0x30, 0x39, 0x64, 0x13, 0x4a, 0xab, 0x1e, 0xa6,
0x72, 0xa8, 0xa3, 0x95, 0x1b, 0xb7, 0x85, 0x4a, 0x13, 0x9c, 0x50, 0xa6, 0x5d, 0xe0, 0x10, 0x39,
0x89, 0x17, 0xa2, 0x25, 0x71, 0x65, 0x3b, 0xa5, 0x7d, 0x0b, 0x8e, 0x3c, 0x08, 0x87, 0x3d, 0x42,
0xc5, 0x69, 0x47, 0xc4, 0x61, 0x40, 0xfb, 0x22, 0x28, 0x8e, 0x9b, 0x16, 0xd8, 0x65, 0x3d, 0xd5,
0xfe, 0xbe, 0xff, 0xf7, 0xfb, 0xff, 0xed, 0x3a, 0xa0, 0x7f, 0x8d, 0xa7, 0xd8, 0xc1, 0x45, 0x28,
0x12, 0x9a, 0x3b, 0xd3, 0xd3, 0x80, 0x08, 0x7c, 0xea, 0xc4, 0x24, 0x27, 0x3c, 0xe1, 0x68, 0xc2,
0xa8, 0xa0, 0xd0, 0x2c, 0x35, 0x48, 0x69, 0x90, 0xd2, 0x1c, 0x9b, 0x31, 0x8d, 0xa9, 0x14, 0x38,
0xe5, 0xaa, 0xd2, 0x1e, 0x1f, 0xc5, 0x94, 0xc6, 0x29, 0x71, 0xe4, 0x2e, 0x28, 0xae, 0x1c, 0x9c,
0xcf, 0xd7, 0xad, 0x90, 0xf2, 0x8c, 0x72, 0xbf, 0x9a, 0xa9, 0x36, 0xaa, 0x65, 0xff, 0x3b, 0x15,
0x15, 0x0c, 0x4b, 0x37, 0x59, 0xe9, 0xdf, 0xe8, 0xa0, 0x73, 0x5e, 0x65, 0xba, 0x10, 0x58, 0x10,
0x78, 0x02, 0x9e, 0xe4, 0x64, 0x26, 0x7c, 0x15, 0xca, 0x4f, 0x22, 0x4b, 0xef, 0xe9, 0x03, 0xc3,
0xdb, 0x2f, 0xcb, 0x67, 0x55, 0xf5, 0x4d, 0x04, 0x5f, 0x81, 0xe6, 0x04, 0x33, 0x9c, 0x71, 0x6b,
0xaf, 0xa7, 0x0f, 0xda, 0xa3, 0xe7, 0xe8, 0xbe, 0xb3, 0xa0, 0x77, 0x52, 0xe3, 0x1a, 0x8b, 0xbb,
0xae, 0xe6, 0xa9, 0x09, 0x38, 0x06, 0x2d, 0xa5, 0xe3, 0x56, 0xa3, 0xd7, 0x18, 0xb4, 0x47, 0x26,
0xaa, 0x72, 0xa2, 0x75, 0x4e, 0x74, 0x96, 0xcf, 0x5d, 0xf8, 0xed, 0xeb, 0xf0, 0x40, 0xa5, 0x53,
0xce, 0x5e, 0x3d, 0xd9, 0xbf, 0x31, 0x40, 0xb3, 0xc2, 0xc3, 0x4b, 0x60, 0x66, 0x78, 0x56, 0x67,
0x5e, 0x9f, 0x51, 0x26, 0x6f, 0x8f, 0x8e, 0xfe, 0x83, 0x8f, 0x95, 0xc0, 0x6d, 0x95, 0xb9, 0xbe,
0xfc, 0xec, 0xea, 0x1e, 0xcc, 0xf0, 0x4c, 0x79, 0xac, 0xbb, 0x25, 0xf6, 0x8a, 0xb2, 0x4f, 0x98,
0x45, 0x7e, 0x90, 0x44, 0x1b, 0x6c, 0xf3, 0x01, 0x58, 0x05, 0x70, 0x93, 0x68, 0x1b, 0xcb, 0xc8,
0x94, 0x30, 0x4e, 0xfe, 0xc6, 0x3e, 0x7e, 0x00, 0x56, 0x01, 0xb6, 0xb1, 0x1f, 0xc0, 0xd3, 0x24,
0x0f, 0x19, 0xc9, 0x48, 0x2e, 0x7c, 0x5e, 0xb0, 0x49, 0x5a, 0x94, 0xd7, 0xab, 0x0f, 0x3a, 0x2e,
0x2a, 0x07, 0x7f, 0xdc, 0x75, 0x4f, 0xe2, 0x44, 0x7c, 0x2c, 0x02, 0x14, 0xd2, 0x4c, 0x3d, 0x13,
0xf5, 0x33, 0xe4, 0xd1, 0xb5, 0x23, 0xe6, 0x13, 0xc2, 0xd1, 0x98, 0x84, 0xde, 0x61, 0x0d, 0xba,
0xa8, 0x38, 0xf0, 0x12, 0x1c, 0x6c, 0xe0, 0x11, 0x09, 0x84, 0x65, 0xec, 0x44, 0xde, 0xaf, 0x29,
0x63, 0x12, 0x08, 0x88, 0x81, 0xb9, 0xc1, 0x86, 0x34, 0x4d, 0xb1, 0x20, 0x0c, 0xa7, 0xd6, 0xa3,
0x9d, 0xe0, 0xcf, 0x6a, 0xd6, 0xeb, 0x1a, 0xf5, 0xd6, 0x68, 0xed, 0x1d, 0x36, 0xbc, 0xce, 0xf6,
0x4d, 0xbb, 0xe7, 0x8b, 0xdf, 0xb6, 0xb6, 0x58, 0xda, 0xfa, 0xed, 0xd2, 0xd6, 0x7f, 0x2d, 0x6d,
0xfd, 0xf3, 0xca, 0xd6, 0x6e, 0x57, 0xb6, 0xf6, 0x7d, 0x65, 0x6b, 0xef, 0x5f, 0x6c, 0xd9, 0x95,
0x8f, 0x7a, 0x98, 0xe2, 0x80, 0xcb, 0x95, 0x33, 0xab, 0x3f, 0x68, 0xe9, 0x1a, 0x34, 0xe5, 0x9f,
0xf4, 0xf2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x72, 0x5f, 0x95, 0x2e, 0xed, 0x03, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@ -237,6 +237,14 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i -= n2
i = encodeVarintGenesis(dAtA, i, uint64(n2))
i--
dAtA[i] = 0x3a
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.ForwardBidDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.ForwardBidDuration):])
if err3 != nil {
return 0, err3
}
i -= n3
i = encodeVarintGenesis(dAtA, i, uint64(n3))
i--
dAtA[i] = 0x32
{
size := m.IncrementCollateral.Size()
@ -268,14 +276,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
}
i--
dAtA[i] = 0x1a
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.ForwardBidDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.ForwardBidDuration):])
if err3 != nil {
return 0, err3
}
i -= n3
i = encodeVarintGenesis(dAtA, i, uint64(n3))
i--
dAtA[i] = 0x12
n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration):])
if err4 != nil {
return 0, err4
@ -326,14 +326,14 @@ func (m *Params) Size() (n int) {
_ = l
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAuctionDuration)
n += 1 + l + sovGenesis(uint64(l))
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.ForwardBidDuration)
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementSurplus.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementDebt.Size()
n += 1 + l + sovGenesis(uint64(l))
l = m.IncrementCollateral.Size()
n += 1 + l + sovGenesis(uint64(l))
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.ForwardBidDuration)
n += 1 + l + sovGenesis(uint64(l))
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.ReverseBidDuration)
n += 1 + l + sovGenesis(uint64(l))
return n
@ -543,39 +543,6 @@ func (m *Params) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ForwardBidDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.ForwardBidDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IncrementSurplus", wireType)
@ -676,6 +643,39 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ForwardBidDuration", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.ForwardBidDuration, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ReverseBidDuration", wireType)
}

View File

@ -16,7 +16,7 @@ const (
// DefaultMaxAuctionDuration max length of auction
DefaultMaxAuctionDuration time.Duration = 2 * 24 * time.Hour
// DefaultForwardBidDuration how long an auction gets extended when someone bids for a forward auction
DefaultForwardBidDuration time.Duration = 8 * time.Hour
DefaultForwardBidDuration time.Duration = 24 * time.Hour
// DefaultReverseBidDuration how long an auction gets extended when someone bids for a reverse auction
DefaultReverseBidDuration time.Duration = 1 * time.Hour
)