Documentation ¶
Overview ¶
Package nodecmd contains command definitions and related functions used for node cmds, such as kcn, kpn, and ken.
Source Files ¶
Each file contains following contents
- accountcmd.go : Provides functions for creating, updating and importing an account.
- chaincmd.go : Provides functions to `init` a block chain,
- consolecmd.go : Provides console functions `attach` and `console`
- migrationcmd.go : Provides functions of DB migration
- defaultcmd.go : Provides functions to start a node
- dumpconfigcmd.go : Provides functions to dump and print current config to stdout
- nodeflags.go : Defines various flags that configure the node
- versioncmd.go : Provides functions to print application's version
Index ¶
- Constants
- Variables
- func BeforeRunBootnode(ctx *cli.Context) error
- func BeforeRunNode(ctx *cli.Context) error
- func CheckCommands(ctx *cli.Context) error
- func CommandNotExist(ctx *cli.Context, s string)
- func FlagsFromYaml(ctx *cli.Context) error
- func GetConsoleCommand(nodeFlags, rpcFlags []cli.Flag) *cli.Command
- func GetDumpConfigCommand(nodeFlags, rpcFlags []cli.Flag) *cli.Command
- func GetGitCommit() string
- func MakeFullNode(ctx *cli.Context) *node.Node
- func MakeGenesis(ctx *cli.Context) *blockchain.Genesis
- func MigrateGlobalFlags(ctx *cli.Context)
- func OnUsageError(context *cli.Context, err error, isSubcommand bool) error
- func RunKlaytnNode(ctx *cli.Context) error
- func UnlockAccount(ctx *cli.Context, ks *keystore.KeyStore, address string, i int, ...) (accounts.Account, string)
- func ValidateGenesisConfig(g *blockchain.Genesis) error
Constants ¶
const ( DECODE_EXTRA = "decode-extra" DECODE_VOTE = "decode-vote" DECODE_GOV = "decode-gov" DECRYPT_KEY = "decrypt-keystore" )
Variables ¶
var ( InitCommand = &cli.Command{ Action: initGenesis, Name: "init", Usage: "Bootstrap and initialize a new genesis block", ArgsUsage: "<genesisPath>", Flags: []cli.Flag{ utils.DbTypeFlag, utils.SingleDBFlag, utils.NumStateTrieShardsFlag, utils.DynamoDBTableNameFlag, utils.DynamoDBRegionFlag, utils.DynamoDBIsProvisionedFlag, utils.DynamoDBReadCapacityFlag, utils.DynamoDBWriteCapacityFlag, utils.DynamoDBReadOnlyFlag, utils.LevelDBCompressionTypeFlag, utils.DataDirFlag, utils.ChainDataDirFlag, utils.RocksDBSecondaryFlag, utils.RocksDBCacheSizeFlag, utils.RocksDBDumpMallocStatFlag, utils.RocksDBFilterPolicyFlag, utils.RocksDBCompressionTypeFlag, utils.RocksDBBottommostCompressionTypeFlag, utils.RocksDBDisableMetricsFlag, utils.RocksDBMaxOpenFilesFlag, utils.RocksDBCacheIndexAndFilterFlag, utils.OverwriteGenesisFlag, utils.LivePruningFlag, }, Category: "BLOCKCHAIN COMMANDS", Description: ` The init command initializes a new genesis block and definition for the network. This is a destructive action and changes the network in which you will be participating. It expects the genesis file as argument.`, } DumpGenesisCommand = &cli.Command{ Action: dumpGenesis, Name: "dumpgenesis", Usage: "Dumps genesis block JSON configuration to stdout", ArgsUsage: "", Flags: []cli.Flag{ utils.CypressFlag, utils.BaobabFlag, }, Category: "BLOCKCHAIN COMMANDS", Description: ` The dumpgenesis command dumps the genesis block configuration in JSON format to stdout.`, } )
var AccountCommand = &cli.Command{ Name: "account", Usage: "Manage accounts", Category: "ACCOUNT COMMANDS", Description: ` Manage accounts, list all existing accounts, import a private key into a new account, create a new account or update an existing account. It supports interactive mode, when you are prompted for password as well as non-interactive mode where passwords are supplied via a given password file. Non-interactive mode is only meant for scripted use on test networks or known safe environments. Make sure you remember the password you gave when creating a new account (with either new or import). Without it you are not able to unlock your account. Note that exporting your key in unencrypted format is NOT supported. Keys are stored under <DATADIR>/keystore. It is safe to transfer the entire directory or the individual keys therein between klay nodes by simply copying. Make sure you backup your keys regularly.`, Before: beforeAccountCmd, Subcommands: []*cli.Command{ { Name: "list", Usage: "Print summary of existing accounts", Action: accountList, Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, }, Description: ` Print a short summary of all accounts`, }, { Name: "new", Usage: "Create a new account", Action: accountCreate, Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.PasswordFileFlag, utils.LightKDFFlag, }, Description: ` Creates a new account and prints the address. The account is saved in encrypted format, you are prompted for a passphrase. You must remember this passphrase to unlock your account in the future. For non-interactive use the passphrase can be specified with the --password flag: Note, this is meant to be used for testing only, it is a bad idea to save your password to file or expose in any other way. `, }, { Name: "update", Usage: "Update an existing account", Action: accountUpdate, ArgsUsage: "<address>", Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.LightKDFFlag, }, Description: ` Update an existing account. The account is saved in the newest version in encrypted format, you are prompted for a passphrase to unlock the account and another to save the updated file. This same command can therefore be used to migrate an account of a deprecated format to the newest format or change the password for an account. For non-interactive use the passphrase can be specified with the --password flag: Since only one password can be given, only format update can be performed, changing your password is only possible interactively. `, }, { Name: "import", Usage: "Import a private key into a new account", Action: accountImport, Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.PasswordFileFlag, utils.LightKDFFlag, }, ArgsUsage: "<keyFile>", Description: ` Imports an unencrypted private key from <keyfile> and creates a new account. Prints the address. The keyfile is assumed to contain an unencrypted private key in hexadecimal format. The account is saved in encrypted format, you are prompted for a passphrase. You must remember this passphrase to unlock your account in the future. For non-interactive use the passphrase can be specified with the --password flag: Note, as you can directly copy your encrypted accounts to another klay instance, this import mechanism is not needed when you transfer an account between nodes. `, }, { Name: "bls-info", Usage: "Fetch BLS public key info of the running node", ArgsUsage: "[endpoint]", Action: accountBlsInfo, Flags: []cli.Flag{ utils.DataDirFlag, }, Description: ` Calculate BLS public key info (the public key and proof-of-possession) then saves to bls-publicinfo-NODEID.json. EXAMPLES # From the local node, by attaching to the default IPC endpoint DATADIR/klay.ipc. kcn account bls-info `, }, { Name: "bls-import", Usage: "Import a BLS private key from an EIP-2335 keystore JSON", Action: accountBlsImport, Flags: []cli.Flag{ utils.DataDirFlag, utils.BlsNodeKeystoreFileFlag, utils.PasswordFileFlag, }, Description: ` Decrypt an EIP-2335 keystore and save the BLS secret key to default location (DATADIR/bls-nodekey). EXAMPLES kcn account bls-import --bls-nodekeystore bls-keystore.json `, }, { Name: "bls-export", Usage: "Export a BLS private key to an EIP-2335 keystore JSON", Action: accountBlsExport, Flags: []cli.Flag{ utils.DataDirFlag, utils.PasswordFileFlag, utils.LightKDFFlag, }, Description: ` Export the BLS secret key from the default location (DATADIR/bls-nodekey) to an EIP-2335 keystore bls-keystore-NODEID.json. EXAMPLES kcn account bls-export `, }, }, }
var AttachCommand = &cli.Command{ Action: remoteConsole, Name: "attach", Usage: "Start an interactive JavaScript environment (connect to node)", ArgsUsage: "[endpoint]", Flags: append(utils.ConsoleFlags, utils.DataDirFlag), Category: "CONSOLE COMMANDS", Description: ` The Klaytn console is an interactive shell for the JavaScript runtime environment which exposes a node admin interface as well as the Ðapp JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console. This command allows to open a console on a running Klaytn node.`, }
var ErrInvalidCmd = errors.New("Invalid command. Check usage through --help command")
var (
MigrationCommand = &cli.Command{
Name: "db-migration",
Usage: "db migration",
Flags: []cli.Flag{},
Category: "DB MIGRATION COMMANDS",
Description: `
The migration command migrates a DB to another DB.
The type of DBs can be different.
(e.g. LevelDB -> LevelDB, LevelDB -> BadgerDB, LevelDB -> DynamoDB)
Note: This feature is only provided when srcDB is single LevelDB.
Note: Do not use db migration while a node is executing.
`,
Subcommands: []*cli.Command{
{
Name: "start",
Usage: "Start db migration",
Flags: dbMigrationFlags,
Action: startMigration,
Description: `
This command starts DB migration.
Even if db dir names are changed in srcDB, the original db dir names are used in dstDB.
(e.g. use 'statetrie' instead of 'statetrie_migrated_xxxxx')
If dst db is singleDB, you should set dst.datadir or db.dst.dynamo.tablename
to the original db dir name.
(e.g. Data dir : 'chaindata/klay/statetrie', Dynamo table name : 'klaytn-statetrie')
Note: This feature is only provided when srcDB is single LevelDB.`,
},
},
}
)
var SnapshotCommand = &cli.Command{ Name: "snapshot", Usage: "A set of commands based on the snapshot", Description: "", Subcommands: []*cli.Command{ { Name: "verify-state", Usage: "Recalculate state hash based on the snapshot for verification", ArgsUsage: "<root>", Action: utils.MigrateFlags(verifyState), Flags: utils.SnapshotFlags, Description: ` klay snapshot verify-state <state-root> will traverse the whole accounts and storages set based on the specified snapshot and recalculate the root hash of state for verification. In other words, this command does the snapshot to trie conversion. `, }, { Name: "trace-trie", Usage: "trace all trie nodes for verification", ArgsUsage: "<root>", Action: utils.MigrateFlags(traceTrie), Flags: utils.SnapshotFlags, Description: ` klaytn statedb trace-trie <state-root> trace all account and storage nodes to find missing data during the migration process. Start tracing from the state root of the last block, reading all nodes and logging the missing nodes. `, }, { Name: "iterate-triedb", Usage: "Iterate StateTrie DB for node count", ArgsUsage: "<root>", Action: utils.MigrateFlags(iterateTrie), Flags: utils.SnapshotFlags, Description: ` klaytn statedb iterate-triedb Count the number of nodes in the state-trie db. `, }, }, }
var UtilCommand = &cli.Command{ Name: "util", Usage: "offline utility", Category: "MISCELLANEOUS COMMANDS", Subcommands: []*cli.Command{ { Name: DECODE_EXTRA, Usage: "<header file (json format)>", Action: action, Description: "Decode header extra field", }, { Name: DECODE_VOTE, Usage: "<hex bytes>", Action: action, Description: "Decode header vote field", }, { Name: DECODE_GOV, Usage: "<hex bytes>", Action: action, Description: "Decode header governance field", }, { Name: DECRYPT_KEY, Usage: "<keystore path> <password>", Action: action, Description: "Decrypt keystore", }, }, }
var VersionCommand = &cli.Command{
Action: version,
Name: "version",
Usage: "Show version number",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
}
Functions ¶
func BeforeRunBootnode ¶
func BeforeRunBootnode(ctx *cli.Context) error
func BeforeRunNode ¶ added in v1.9.1
func BeforeRunNode(ctx *cli.Context) error
func CheckCommands ¶
func CheckCommands(ctx *cli.Context) error
func CommandNotExist ¶
func CommandNotExist(ctx *cli.Context, s string)
func FlagsFromYaml ¶ added in v1.9.1
func FlagsFromYaml(ctx *cli.Context) error
func GetConsoleCommand ¶
func GetConsoleCommand(nodeFlags, rpcFlags []cli.Flag) *cli.Command
GetConsoleCommand returns cli.Command `console` whose flags are initialized with nodeFlags, rpcFlags, and ConsoleFlags.
func GetDumpConfigCommand ¶
func GetDumpConfigCommand(nodeFlags, rpcFlags []cli.Flag) *cli.Command
GetDumpConfigCommand returns cli.Command `dumpconfig` whose flags are initialized with nodeFlags and rpcFlags.
func MakeFullNode ¶
func MakeGenesis ¶ added in v1.10.0
func MakeGenesis(ctx *cli.Context) *blockchain.Genesis
func MigrateGlobalFlags ¶ added in v1.11.0
func MigrateGlobalFlags(ctx *cli.Context)
migrateGlobalFlags makes all global flag values available in the context. This should be called as early as possible in app.Before.
Example:
ken account new --keystore /tmp/mykeystore --lightkdf
is equivalent after calling this method with:
ken --keystore /tmp/mykeystore --lightkdf account new
i.e. in the subcommand Action function of 'account new', ctx.Bool("lightkdf) will return true even if --lightkdf is set as a global option.
This function may become unnecessary when https://github.com/urfave/cli/pull/1245 is merged.
func OnUsageError ¶
func RunKlaytnNode ¶
func RunKlaytnNode(ctx *cli.Context) error
runKlaytnNode is the main entry point into the system if no special subcommand is ran. It creates a default node based on the command line arguments and runs it in blocking mode, waiting for it to be shut down.
func UnlockAccount ¶
func UnlockAccount(ctx *cli.Context, ks *keystore.KeyStore, address string, i int, passwords []string) (accounts.Account, string)
tries unlocking the specified account a few times.
func ValidateGenesisConfig ¶ added in v1.6.0
func ValidateGenesisConfig(g *blockchain.Genesis) error
Types ¶
This section is empty.