cosmos-sdk/x/genutil/client/cli/migrate.go

140 lines
3.9 KiB
Go
Raw Normal View History

2019-07-03 09:21:34 -07:00
package cli
import (
"encoding/json"
2019-07-03 09:21:34 -07:00
"fmt"
2019-09-26 09:07:15 -07:00
"sort"
2019-07-03 09:21:34 -07:00
"time"
"github.com/pkg/errors"
2019-07-03 09:21:34 -07:00
"github.com/spf13/cobra"
0.39->0.40 CLI `migrate` command (#6839) * WIP on BaseAccount protobuf pub_key * WIP on BaseAccount.PubKey * Migrate supply * Change validator_slash_event * Add evidence * Add evidence to genutil migrate * Fix lint * Add println * No _ in package name * Add slashing migrate * Add tests for slashing * Add capacity to array * stray fmt.Prinlnt * WIP on BaseAccount pub key * Put current types in v0_40 * Add evidence old types * Remove useless impl * Add RegisterInterface * Add clientCtx to argument * Register evidence interfaces * Update PubKey * Update Account * Docs * WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Fix compile errors * Remove pk conversion in ante handler * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Override Amino marshaling for proto pubkeys * Merge master * Make proto-gen * Start removal of old PubKeyMultisigThreshold references * Fix tests * Fix solomachine * Fix ante handler tests * Pull latest go-amino * Remove ed25519 * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Fix build * Fix lint * Fix lint * Add comment * Register crypto.PubKey * Add empty key in BuildSimTx * Simplify proto names * Unpack interfaces for signing desc * Fix IBC tests? * Format proto * Use secp256k1 in ibc * Fixed merge issues * Uncomment tests * Update x/ibc/testing/solomachine.go * UnpackInterfaces for solomachine types * Remove old multisig * Add amino marshal for multisig * Fix lint * Correctly register amino * One test left! * Remove old struct * Fix test * Fix test * Unpack into tmcrypto * Remove old threshold pubkey tests * Fix register amino * Fix lint * Use sdk crypto PubKey in multisig UnpackInterfaces * Potential fix? * Register LegacyAminoPubKey * Register our own PubKey * Register tmcrypto PubKey * Register both PubKeys * Register interfaces in test * Refactor fiels * Add comments * Remove old cosmos-sdk/crypto/keys reference * Use anil's suggestion * Add norace back * Use our own ed25519 * Fix pubkey types * Fix network tests * Fix more tests * Make ibc work? * Use TM pubkey in NewValidator * Fix lint * Put interface in tpyes * rerun CI * Better name register * Remove stray code * Add ed25519 tests * Check nil * Correct interface impl assert * rerun CI * Add fix for Bech32 * Address comments * FIx lint * Add tests for solomachine unpack interfaces * Fix query tx by hash * Better name in amino register * Fix lint * Add back ed25519 test (fixes #7352) * go mod tidy * Fix merge issues * Sort import * Add test for backwards-compatibility * Fix tests * Fix merge issue * Fix merge issues * Fix tests build * Fix tests * Marshal to proto * Fix 040 marshalling * Remove dontcover * Fix equivocation * Add vesting * Fix vesting * Fix slashing test * Fix evidence test * Remove pb.go files * Fix legacy auth tests * deterministic tests help * Fix auth tests * Remove useless code * Small cleanups * Add comment * Fix migrate hub * fmt.Println * No need to marshal indent * Update proto comment * Fix merge issues * Support nil pubkey * Use protobuf empty * Address comments * Fix tests * Unify legacy package names Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: blushi <marie.gauthier63@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Zaki Manian <zaki@manian.org> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-05 14:28:14 -07:00
tmjson "github.com/tendermint/tendermint/libs/json"
2019-07-03 09:21:34 -07:00
0.39->0.40 CLI `migrate` command (#6839) * WIP on BaseAccount protobuf pub_key * WIP on BaseAccount.PubKey * Migrate supply * Change validator_slash_event * Add evidence * Add evidence to genutil migrate * Fix lint * Add println * No _ in package name * Add slashing migrate * Add tests for slashing * Add capacity to array * stray fmt.Prinlnt * WIP on BaseAccount pub key * Put current types in v0_40 * Add evidence old types * Remove useless impl * Add RegisterInterface * Add clientCtx to argument * Register evidence interfaces * Update PubKey * Update Account * Docs * WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Fix compile errors * Remove pk conversion in ante handler * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Override Amino marshaling for proto pubkeys * Merge master * Make proto-gen * Start removal of old PubKeyMultisigThreshold references * Fix tests * Fix solomachine * Fix ante handler tests * Pull latest go-amino * Remove ed25519 * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Fix build * Fix lint * Fix lint * Add comment * Register crypto.PubKey * Add empty key in BuildSimTx * Simplify proto names * Unpack interfaces for signing desc * Fix IBC tests? * Format proto * Use secp256k1 in ibc * Fixed merge issues * Uncomment tests * Update x/ibc/testing/solomachine.go * UnpackInterfaces for solomachine types * Remove old multisig * Add amino marshal for multisig * Fix lint * Correctly register amino * One test left! * Remove old struct * Fix test * Fix test * Unpack into tmcrypto * Remove old threshold pubkey tests * Fix register amino * Fix lint * Use sdk crypto PubKey in multisig UnpackInterfaces * Potential fix? * Register LegacyAminoPubKey * Register our own PubKey * Register tmcrypto PubKey * Register both PubKeys * Register interfaces in test * Refactor fiels * Add comments * Remove old cosmos-sdk/crypto/keys reference * Use anil's suggestion * Add norace back * Use our own ed25519 * Fix pubkey types * Fix network tests * Fix more tests * Make ibc work? * Use TM pubkey in NewValidator * Fix lint * Put interface in tpyes * rerun CI * Better name register * Remove stray code * Add ed25519 tests * Check nil * Correct interface impl assert * rerun CI * Add fix for Bech32 * Address comments * FIx lint * Add tests for solomachine unpack interfaces * Fix query tx by hash * Better name in amino register * Fix lint * Add back ed25519 test (fixes #7352) * go mod tidy * Fix merge issues * Sort import * Add test for backwards-compatibility * Fix tests * Fix merge issue * Fix merge issues * Fix tests build * Fix tests * Marshal to proto * Fix 040 marshalling * Remove dontcover * Fix equivocation * Add vesting * Fix vesting * Fix slashing test * Fix evidence test * Remove pb.go files * Fix legacy auth tests * deterministic tests help * Fix auth tests * Remove useless code * Small cleanups * Add comment * Fix migrate hub * fmt.Println * No need to marshal indent * Update proto comment * Fix merge issues * Support nil pubkey * Use protobuf empty * Address comments * Fix tests * Unify legacy package names Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: blushi <marie.gauthier63@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Zaki Manian <zaki@manian.org> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-05 14:28:14 -07:00
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
2019-07-03 09:21:34 -07:00
"github.com/cosmos/cosmos-sdk/version"
refactor: Rename x/{mod}/legacy to x/{mod}/migrations (#9628) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #8700 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-07-05 07:55:51 -07:00
v040 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v040"
v043 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v043"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
2019-07-03 09:21:34 -07:00
)
const flagGenesisTime = "genesis-time"
2019-09-26 09:07:15 -07:00
// Allow applications to extend and modify the migration process.
//
// Ref: https://github.com/cosmos/cosmos-sdk/issues/5041
var migrationMap = types.MigrationMap{
"v0.42": v040.Migrate, // NOTE: v0.40, v0.41 and v0.42 are genesis compatible.
"v0.43": v043.Migrate,
2019-07-03 09:21:34 -07:00
}
2019-09-26 09:07:15 -07:00
// GetMigrationCallback returns a MigrationCallback for a given version.
func GetMigrationCallback(version string) types.MigrationCallback {
2019-09-26 09:07:15 -07:00
return migrationMap[version]
}
// GetMigrationVersions get all migration version in a sorted slice.
func GetMigrationVersions() []string {
versions := make([]string, len(migrationMap))
2019-07-03 09:21:34 -07:00
2019-09-26 09:07:15 -07:00
var i int
2019-09-26 09:07:15 -07:00
for version := range migrationMap {
versions[i] = version
i++
}
sort.Strings(versions)
2019-09-26 09:07:15 -07:00
return versions
}
// MigrateGenesisCmd returns a command to execute genesis state migration.
func MigrateGenesisCmd() *cobra.Command {
2019-07-03 09:21:34 -07:00
cmd := &cobra.Command{
Use: "migrate [target-version] [genesis-file]",
Short: "Migrate genesis to a specified target version",
Long: fmt.Sprintf(`Migrate the source genesis into the target version and print to STDOUT.
Example:
$ %s migrate v0.36 /path/to/genesis.json --chain-id=cosmoshub-3 --genesis-time=2019-04-22T17:00:00Z
`, version.AppName),
2019-07-03 09:21:34 -07:00
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
0.39->0.40 CLI `migrate` command (#6839) * WIP on BaseAccount protobuf pub_key * WIP on BaseAccount.PubKey * Migrate supply * Change validator_slash_event * Add evidence * Add evidence to genutil migrate * Fix lint * Add println * No _ in package name * Add slashing migrate * Add tests for slashing * Add capacity to array * stray fmt.Prinlnt * WIP on BaseAccount pub key * Put current types in v0_40 * Add evidence old types * Remove useless impl * Add RegisterInterface * Add clientCtx to argument * Register evidence interfaces * Update PubKey * Update Account * Docs * WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Fix compile errors * Remove pk conversion in ante handler * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Override Amino marshaling for proto pubkeys * Merge master * Make proto-gen * Start removal of old PubKeyMultisigThreshold references * Fix tests * Fix solomachine * Fix ante handler tests * Pull latest go-amino * Remove ed25519 * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Fix build * Fix lint * Fix lint * Add comment * Register crypto.PubKey * Add empty key in BuildSimTx * Simplify proto names * Unpack interfaces for signing desc * Fix IBC tests? * Format proto * Use secp256k1 in ibc * Fixed merge issues * Uncomment tests * Update x/ibc/testing/solomachine.go * UnpackInterfaces for solomachine types * Remove old multisig * Add amino marshal for multisig * Fix lint * Correctly register amino * One test left! * Remove old struct * Fix test * Fix test * Unpack into tmcrypto * Remove old threshold pubkey tests * Fix register amino * Fix lint * Use sdk crypto PubKey in multisig UnpackInterfaces * Potential fix? * Register LegacyAminoPubKey * Register our own PubKey * Register tmcrypto PubKey * Register both PubKeys * Register interfaces in test * Refactor fiels * Add comments * Remove old cosmos-sdk/crypto/keys reference * Use anil's suggestion * Add norace back * Use our own ed25519 * Fix pubkey types * Fix network tests * Fix more tests * Make ibc work? * Use TM pubkey in NewValidator * Fix lint * Put interface in tpyes * rerun CI * Better name register * Remove stray code * Add ed25519 tests * Check nil * Correct interface impl assert * rerun CI * Add fix for Bech32 * Address comments * FIx lint * Add tests for solomachine unpack interfaces * Fix query tx by hash * Better name in amino register * Fix lint * Add back ed25519 test (fixes #7352) * go mod tidy * Fix merge issues * Sort import * Add test for backwards-compatibility * Fix tests * Fix merge issue * Fix merge issues * Fix tests build * Fix tests * Marshal to proto * Fix 040 marshalling * Remove dontcover * Fix equivocation * Add vesting * Fix vesting * Fix slashing test * Fix evidence test * Remove pb.go files * Fix legacy auth tests * deterministic tests help * Fix auth tests * Remove useless code * Small cleanups * Add comment * Fix migrate hub * fmt.Println * No need to marshal indent * Update proto comment * Fix merge issues * Support nil pubkey * Use protobuf empty * Address comments * Fix tests * Unify legacy package names Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: blushi <marie.gauthier63@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Zaki Manian <zaki@manian.org> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-05 14:28:14 -07:00
clientCtx := client.GetClientContextFromCmd(cmd)
2019-09-26 09:07:15 -07:00
var err error
2019-07-03 09:21:34 -07:00
target := args[0]
importGenesis := args[1]
genDoc, err := validateGenDoc(importGenesis)
2019-07-03 09:21:34 -07:00
if err != nil {
return err
}
// Since some default values are valid values, we just print to
// make sure the user didn't forget to update these values.
if genDoc.ConsensusParams.Evidence.MaxBytes == 0 {
fmt.Printf("Warning: consensus_params.evidence.max_bytes is set to 0. If this is"+
" deliberate, feel free to ignore this warning. If not, please have a look at the chain"+
" upgrade guide at %s.\n", chainUpgradeGuide)
2019-07-03 09:21:34 -07:00
}
var initialState types.AppMap
if err := json.Unmarshal(genDoc.AppState, &initialState); err != nil {
2019-09-26 09:07:15 -07:00
return errors.Wrap(err, "failed to JSON unmarshal initial genesis state")
}
2019-07-03 09:21:34 -07:00
2019-09-26 09:07:15 -07:00
migrationFunc := GetMigrationCallback(target)
if migrationFunc == nil {
return fmt.Errorf("unknown migration function for version: %s", target)
2019-07-03 09:21:34 -07:00
}
2019-09-26 09:07:15 -07:00
// TODO: handler error from migrationFunc call
0.39->0.40 CLI `migrate` command (#6839) * WIP on BaseAccount protobuf pub_key * WIP on BaseAccount.PubKey * Migrate supply * Change validator_slash_event * Add evidence * Add evidence to genutil migrate * Fix lint * Add println * No _ in package name * Add slashing migrate * Add tests for slashing * Add capacity to array * stray fmt.Prinlnt * WIP on BaseAccount pub key * Put current types in v0_40 * Add evidence old types * Remove useless impl * Add RegisterInterface * Add clientCtx to argument * Register evidence interfaces * Update PubKey * Update Account * Docs * WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Fix compile errors * Remove pk conversion in ante handler * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Override Amino marshaling for proto pubkeys * Merge master * Make proto-gen * Start removal of old PubKeyMultisigThreshold references * Fix tests * Fix solomachine * Fix ante handler tests * Pull latest go-amino * Remove ed25519 * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Fix build * Fix lint * Fix lint * Add comment * Register crypto.PubKey * Add empty key in BuildSimTx * Simplify proto names * Unpack interfaces for signing desc * Fix IBC tests? * Format proto * Use secp256k1 in ibc * Fixed merge issues * Uncomment tests * Update x/ibc/testing/solomachine.go * UnpackInterfaces for solomachine types * Remove old multisig * Add amino marshal for multisig * Fix lint * Correctly register amino * One test left! * Remove old struct * Fix test * Fix test * Unpack into tmcrypto * Remove old threshold pubkey tests * Fix register amino * Fix lint * Use sdk crypto PubKey in multisig UnpackInterfaces * Potential fix? * Register LegacyAminoPubKey * Register our own PubKey * Register tmcrypto PubKey * Register both PubKeys * Register interfaces in test * Refactor fiels * Add comments * Remove old cosmos-sdk/crypto/keys reference * Use anil's suggestion * Add norace back * Use our own ed25519 * Fix pubkey types * Fix network tests * Fix more tests * Make ibc work? * Use TM pubkey in NewValidator * Fix lint * Put interface in tpyes * rerun CI * Better name register * Remove stray code * Add ed25519 tests * Check nil * Correct interface impl assert * rerun CI * Add fix for Bech32 * Address comments * FIx lint * Add tests for solomachine unpack interfaces * Fix query tx by hash * Better name in amino register * Fix lint * Add back ed25519 test (fixes #7352) * go mod tidy * Fix merge issues * Sort import * Add test for backwards-compatibility * Fix tests * Fix merge issue * Fix merge issues * Fix tests build * Fix tests * Marshal to proto * Fix 040 marshalling * Remove dontcover * Fix equivocation * Add vesting * Fix vesting * Fix slashing test * Fix evidence test * Remove pb.go files * Fix legacy auth tests * deterministic tests help * Fix auth tests * Remove useless code * Small cleanups * Add comment * Fix migrate hub * fmt.Println * No need to marshal indent * Update proto comment * Fix merge issues * Support nil pubkey * Use protobuf empty * Address comments * Fix tests * Unify legacy package names Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: blushi <marie.gauthier63@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Zaki Manian <zaki@manian.org> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-05 14:28:14 -07:00
newGenState := migrationFunc(initialState, clientCtx)
2019-09-26 09:07:15 -07:00
genDoc.AppState, err = json.Marshal(newGenState)
2019-09-26 09:07:15 -07:00
if err != nil {
return errors.Wrap(err, "failed to JSON marshal migrated genesis state")
}
2019-07-03 09:21:34 -07:00
genesisTime, _ := cmd.Flags().GetString(flagGenesisTime)
2019-07-03 09:21:34 -07:00
if genesisTime != "" {
var t time.Time
err := t.UnmarshalText([]byte(genesisTime))
if err != nil {
return errors.Wrap(err, "failed to unmarshal genesis time")
2019-07-03 09:21:34 -07:00
}
genDoc.GenesisTime = t
}
chainID, _ := cmd.Flags().GetString(flags.FlagChainID)
if chainID != "" {
genDoc.ChainID = chainID
2019-07-03 09:21:34 -07:00
}
0.39->0.40 CLI `migrate` command (#6839) * WIP on BaseAccount protobuf pub_key * WIP on BaseAccount.PubKey * Migrate supply * Change validator_slash_event * Add evidence * Add evidence to genutil migrate * Fix lint * Add println * No _ in package name * Add slashing migrate * Add tests for slashing * Add capacity to array * stray fmt.Prinlnt * WIP on BaseAccount pub key * Put current types in v0_40 * Add evidence old types * Remove useless impl * Add RegisterInterface * Add clientCtx to argument * Register evidence interfaces * Update PubKey * Update Account * Docs * WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Fix compile errors * Remove pk conversion in ante handler * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Override Amino marshaling for proto pubkeys * Merge master * Make proto-gen * Start removal of old PubKeyMultisigThreshold references * Fix tests * Fix solomachine * Fix ante handler tests * Pull latest go-amino * Remove ed25519 * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Fix build * Fix lint * Fix lint * Add comment * Register crypto.PubKey * Add empty key in BuildSimTx * Simplify proto names * Unpack interfaces for signing desc * Fix IBC tests? * Format proto * Use secp256k1 in ibc * Fixed merge issues * Uncomment tests * Update x/ibc/testing/solomachine.go * UnpackInterfaces for solomachine types * Remove old multisig * Add amino marshal for multisig * Fix lint * Correctly register amino * One test left! * Remove old struct * Fix test * Fix test * Unpack into tmcrypto * Remove old threshold pubkey tests * Fix register amino * Fix lint * Use sdk crypto PubKey in multisig UnpackInterfaces * Potential fix? * Register LegacyAminoPubKey * Register our own PubKey * Register tmcrypto PubKey * Register both PubKeys * Register interfaces in test * Refactor fiels * Add comments * Remove old cosmos-sdk/crypto/keys reference * Use anil's suggestion * Add norace back * Use our own ed25519 * Fix pubkey types * Fix network tests * Fix more tests * Make ibc work? * Use TM pubkey in NewValidator * Fix lint * Put interface in tpyes * rerun CI * Better name register * Remove stray code * Add ed25519 tests * Check nil * Correct interface impl assert * rerun CI * Add fix for Bech32 * Address comments * FIx lint * Add tests for solomachine unpack interfaces * Fix query tx by hash * Better name in amino register * Fix lint * Add back ed25519 test (fixes #7352) * go mod tidy * Fix merge issues * Sort import * Add test for backwards-compatibility * Fix tests * Fix merge issue * Fix merge issues * Fix tests build * Fix tests * Marshal to proto * Fix 040 marshalling * Remove dontcover * Fix equivocation * Add vesting * Fix vesting * Fix slashing test * Fix evidence test * Remove pb.go files * Fix legacy auth tests * deterministic tests help * Fix auth tests * Remove useless code * Small cleanups * Add comment * Fix migrate hub * fmt.Println * No need to marshal indent * Update proto comment * Fix merge issues * Support nil pubkey * Use protobuf empty * Address comments * Fix tests * Unify legacy package names Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: blushi <marie.gauthier63@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Zaki Manian <zaki@manian.org> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-10-05 14:28:14 -07:00
bz, err := tmjson.Marshal(genDoc)
2019-07-03 09:21:34 -07:00
if err != nil {
return errors.Wrap(err, "failed to marshal genesis doc")
2019-07-03 09:21:34 -07:00
}
2019-09-26 09:07:15 -07:00
sortedBz, err := sdk.SortJSON(bz)
if err != nil {
return errors.Wrap(err, "failed to sort JSON genesis doc")
}
cmd.Println(string(sortedBz))
2019-07-03 09:21:34 -07:00
return nil
},
}
2019-09-26 09:07:15 -07:00
cmd.Flags().String(flagGenesisTime, "", "override genesis_time with this flag")
cmd.Flags().String(flags.FlagChainID, "", "override chain_id with this flag")
2019-07-03 09:21:34 -07:00
return cmd
}