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 BeforeRunKlaytn(ctx *cli.Context) error
- func CheckCommands(ctx *cli.Context) error
- func CommandNotExist(ctx *cli.Context, s string)
- 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 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 ( SCNNetworkType = "scn" // Service Chain Network MNNetworkType = "mn" // Mainnet Network )
Variables ¶
var ( InitCommand = cli.Command{ Action: utils.MigrateFlags(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.OverwriteGenesisFlag, }, 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: utils.MigrateFlags(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 ( ConsoleFlags = []cli.Flag{utils.JSpathFlag, utils.ExecFlag, utils.PreloadJSFlag} AttachCommand = cli.Command{ Action: utils.MigrateFlags(remoteConsole), Name: "attach", Usage: "Start an interactive JavaScript environment (connect to node)", ArgsUsage: "[endpoint]", Flags: append(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 ( 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.`, Subcommands: []cli.Command{ { Name: "list", Usage: "Print summary of existing accounts", Action: utils.MigrateFlags(accountList), Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, }, Description: ` Print a short summary of all accounts`, }, { Name: "new", Usage: "Create a new account", Action: utils.MigrateFlags(accountCreate), Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.PasswordFileFlag, utils.LightKDFFlag, }, Description: ` klay account new 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: utils.MigrateFlags(accountUpdate), ArgsUsage: "<address>", Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.LightKDFFlag, }, Description: ` klay account update <address> 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: klay account update [options] <address> 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: utils.MigrateFlags(accountImport), Flags: []cli.Flag{ utils.DataDirFlag, utils.KeyStoreDirFlag, utils.PasswordFileFlag, utils.LightKDFFlag, }, ArgsUsage: "<keyFile>", Description: ` klay account import <keyfile> 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: klay account import [options] <keyfile> 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. `, }, }, } )
var CommonNodeFlags = []cli.Flag{ utils.BootnodesFlag, utils.IdentityFlag, utils.UnlockedAccountFlag, utils.PasswordFileFlag, utils.DbTypeFlag, utils.DataDirFlag, utils.OverwriteGenesisFlag, utils.StartBlockNumberFlag, utils.KeyStoreDirFlag, utils.TxPoolNoLocalsFlag, utils.TxPoolAllowLocalAnchorTxFlag, utils.TxPoolDenyRemoteTxFlag, utils.TxPoolJournalFlag, utils.TxPoolJournalIntervalFlag, utils.TxPoolPriceLimitFlag, utils.TxPoolPriceBumpFlag, utils.TxPoolExecSlotsAccountFlag, utils.TxPoolExecSlotsAllFlag, utils.TxPoolNonExecSlotsAccountFlag, utils.TxPoolNonExecSlotsAllFlag, utils.TxPoolLifetimeFlag, utils.TxPoolKeepLocalsFlag, utils.SyncModeFlag, utils.GCModeFlag, utils.LightKDFFlag, utils.SingleDBFlag, utils.NumStateTrieShardsFlag, utils.LevelDBCompressionTypeFlag, utils.LevelDBNoBufferPoolFlag, utils.DBNoPerformanceMetricsFlag, utils.DynamoDBTableNameFlag, utils.DynamoDBRegionFlag, utils.DynamoDBIsProvisionedFlag, utils.DynamoDBReadCapacityFlag, utils.DynamoDBWriteCapacityFlag, utils.DynamoDBReadOnlyFlag, utils.LevelDBCacheSizeFlag, utils.NoParallelDBWriteFlag, utils.SenderTxHashIndexingFlag, utils.TrieMemoryCacheSizeFlag, utils.TrieBlockIntervalFlag, utils.TriesInMemoryFlag, utils.CacheTypeFlag, utils.CacheScaleFlag, utils.CacheUsageLevelFlag, utils.MemorySizeFlag, utils.TrieNodeCacheTypeFlag, utils.NumFetcherPrefetchWorkerFlag, utils.UseSnapshotForPrefetchFlag, utils.TrieNodeCacheLimitFlag, utils.TrieNodeCacheSavePeriodFlag, utils.TrieNodeCacheRedisEndpointsFlag, utils.TrieNodeCacheRedisClusterFlag, utils.TrieNodeCacheRedisPublishBlockFlag, utils.TrieNodeCacheRedisSubscribeBlockFlag, utils.ListenPortFlag, utils.SubListenPortFlag, utils.MultiChannelUseFlag, utils.MaxConnectionsFlag, utils.MaxRequestContentLengthFlag, utils.MaxPendingPeersFlag, utils.TargetGasLimitFlag, utils.NATFlag, utils.NoDiscoverFlag, utils.RWTimerWaitTimeFlag, utils.RWTimerIntervalFlag, utils.NetrestrictFlag, utils.NodeKeyFileFlag, utils.NodeKeyHexFlag, utils.VMEnableDebugFlag, utils.VMLogTargetFlag, utils.VMTraceInternalTxFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, utils.RPCVirtualHostsFlag, utils.RPCNonEthCompatibleFlag, utils.MetricsEnabledFlag, utils.PrometheusExporterFlag, utils.PrometheusExporterPortFlag, utils.ExtraDataFlag, utils.SrvTypeFlag, utils.AutoRestartFlag, utils.RestartTimeOutFlag, utils.DaemonPathFlag, utils.ConfigFileFlag, utils.APIFilterGetLogsMaxItemsFlag, utils.APIFilterGetLogsDeadlineFlag, utils.OpcodeComputationCostLimitFlag, utils.SnapshotFlag, utils.SnapshotCacheSizeFlag, }
Common flags that configure the node
var CommonRPCFlags = []cli.Flag{ utils.RPCEnabledFlag, utils.RPCListenAddrFlag, utils.RPCPortFlag, utils.RPCApiFlag, utils.RPCGlobalGasCap, utils.RPCGlobalEthTxFeeCapFlag, utils.WSEnabledFlag, utils.WSListenAddrFlag, utils.WSPortFlag, utils.GRPCEnabledFlag, utils.GRPCListenAddrFlag, utils.GRPCPortFlag, utils.RPCConcurrencyLimit, utils.WSApiFlag, utils.WSAllowedOriginsFlag, utils.WSMaxSubscriptionPerConn, utils.WSReadDeadLine, utils.WSWriteDeadLine, utils.WSMaxConnections, utils.IPCDisabledFlag, utils.IPCPathFlag, utils.RPCReadTimeout, utils.RPCWriteTimeoutFlag, utils.RPCIdleTimeoutFlag, utils.RPCExecutionTimeoutFlag, }
Common RPC flags
var DBMigrationFlags = []cli.Flag{ utils.DstDbTypeFlag, utils.DstDataDirFlag, utils.DstSingleDBFlag, utils.DstLevelDBCompressionTypeFlag, utils.DstNumStateTrieShardsFlag, utils.DstDynamoDBTableNameFlag, utils.DstDynamoDBRegionFlag, utils.DstDynamoDBIsProvisionedFlag, utils.DstDynamoDBReadCapacityFlag, utils.DstDynamoDBWriteCapacityFlag, }
var KCNFlags = []cli.Flag{ utils.RewardbaseFlag, utils.CypressFlag, utils.BaobabFlag, utils.BlockGenerationIntervalFlag, utils.BlockGenerationTimeLimitFlag, }
var KENFlags = []cli.Flag{ utils.ServiceChainSignerFlag, utils.CypressFlag, utils.BaobabFlag, utils.ChildChainIndexingFlag, utils.MainBridgeFlag, utils.MainBridgeListenPortFlag, utils.KESNodeTypeServiceFlag, utils.EnableChainDataFetcherFlag, utils.ChainDataFetcherMode, utils.ChainDataFetcherNoDefault, utils.ChainDataFetcherNumHandlers, utils.ChainDataFetcherJobChannelSize, utils.ChainDataFetcherChainEventSizeFlag, utils.ChainDataFetcherKASDBHostFlag, utils.ChainDataFetcherKASDBPortFlag, utils.ChainDataFetcherKASDBNameFlag, utils.ChainDataFetcherKASDBUserFlag, utils.ChainDataFetcherKASDBPasswordFlag, utils.ChainDataFetcherKASCacheUse, utils.ChainDataFetcherKASCacheURLFlag, utils.ChainDataFetcherKASXChainIdFlag, utils.ChainDataFetcherKASBasicAuthParamFlag, utils.ChainDataFetcherKafkaReplicasFlag, utils.ChainDataFetcherKafkaBrokersFlag, utils.ChainDataFetcherKafkaPartitionsFlag, utils.ChainDataFetcherKafkaTopicResourceFlag, utils.ChainDataFetcherKafkaTopicEnvironmentFlag, utils.ChainDataFetcherKafkaMaxMessageBytesFlag, utils.ChainDataFetcherKafkaSegmentSizeBytesFlag, utils.ChainDataFetcherKafkaRequiredAcksFlag, utils.ChainDataFetcherKafkaMessageVersionFlag, utils.ChainDataFetcherKafkaProducerIdFlag, utils.EnableDBSyncerFlag, utils.DBHostFlag, utils.DBPortFlag, utils.DBNameFlag, utils.DBUserFlag, utils.DBPasswordFlag, utils.EnabledLogModeFlag, utils.MaxIdleConnsFlag, utils.MaxOpenConnsFlag, utils.ConnMaxLifeTimeFlag, utils.BlockSyncChannelSizeFlag, utils.DBSyncerModeFlag, utils.GenQueryThreadFlag, utils.InsertThreadFlag, utils.BulkInsertSizeFlag, utils.EventModeFlag, utils.MaxBlockDiffFlag, utils.TxResendIntervalFlag, utils.TxResendCountFlag, utils.TxResendUseLegacyFlag, }
var KPNFlags = []cli.Flag{ utils.TxResendIntervalFlag, utils.TxResendCountFlag, utils.TxResendUseLegacyFlag, utils.CypressFlag, utils.BaobabFlag, utils.TxPoolSpamThrottlerDisableFlag, }
var KSCNFlags = []cli.Flag{ utils.RewardbaseFlag, utils.BlockGenerationIntervalFlag, utils.BlockGenerationTimeLimitFlag, utils.ServiceChainSignerFlag, utils.AnchoringPeriodFlag, utils.SentChainTxsLimit, utils.MainBridgeFlag, utils.MainBridgeListenPortFlag, utils.ChildChainIndexingFlag, utils.SubBridgeFlag, utils.SubBridgeListenPortFlag, utils.ParentChainIDFlag, utils.VTRecoveryFlag, utils.VTRecoveryIntervalFlag, utils.ServiceChainNewAccountFlag, utils.ServiceChainAnchoringFlag, utils.ServiceChainParentOperatorTxGasLimitFlag, utils.ServiceChainChildOperatorTxGasLimitFlag, utils.KASServiceChainAnchorFlag, utils.KASServiceChainAnchorPeriodFlag, utils.KASServiceChainAnchorUrlFlag, utils.KASServiceChainAnchorOperatorFlag, utils.KASServiceChainSecretKeyFlag, utils.KASServiceChainAccessKeyFlag, utils.KASServiceChainXChainIdFlag, utils.KASServiceChainAnchorRequestTimeoutFlag, }
var KSENFlags = []cli.Flag{ utils.ServiceChainSignerFlag, utils.ChildChainIndexingFlag, utils.MainBridgeFlag, utils.MainBridgeListenPortFlag, utils.SubBridgeFlag, utils.SubBridgeListenPortFlag, utils.AnchoringPeriodFlag, utils.SentChainTxsLimit, utils.ParentChainIDFlag, utils.VTRecoveryFlag, utils.VTRecoveryIntervalFlag, utils.ServiceChainAnchoringFlag, utils.KESNodeTypeServiceFlag, utils.ServiceChainParentOperatorTxGasLimitFlag, utils.ServiceChainChildOperatorTxGasLimitFlag, utils.EnableChainDataFetcherFlag, utils.ChainDataFetcherMode, utils.ChainDataFetcherNoDefault, utils.ChainDataFetcherNumHandlers, utils.ChainDataFetcherJobChannelSize, utils.ChainDataFetcherChainEventSizeFlag, utils.ChainDataFetcherKASDBHostFlag, utils.ChainDataFetcherKASDBPortFlag, utils.ChainDataFetcherKASDBNameFlag, utils.ChainDataFetcherKASDBUserFlag, utils.ChainDataFetcherKASDBPasswordFlag, utils.ChainDataFetcherKASCacheUse, utils.ChainDataFetcherKASCacheURLFlag, utils.ChainDataFetcherKASXChainIdFlag, utils.ChainDataFetcherKASBasicAuthParamFlag, utils.ChainDataFetcherKafkaReplicasFlag, utils.ChainDataFetcherKafkaBrokersFlag, utils.ChainDataFetcherKafkaPartitionsFlag, utils.ChainDataFetcherKafkaTopicResourceFlag, utils.ChainDataFetcherKafkaTopicEnvironmentFlag, utils.ChainDataFetcherKafkaMaxMessageBytesFlag, utils.ChainDataFetcherKafkaSegmentSizeBytesFlag, utils.ChainDataFetcherKafkaRequiredAcksFlag, utils.ChainDataFetcherKafkaMessageVersionFlag, utils.ChainDataFetcherKafkaProducerIdFlag, utils.KASServiceChainAnchorFlag, utils.KASServiceChainAnchorPeriodFlag, utils.KASServiceChainAnchorUrlFlag, utils.KASServiceChainAnchorOperatorFlag, utils.KASServiceChainSecretKeyFlag, utils.KASServiceChainAccessKeyFlag, utils.KASServiceChainXChainIdFlag, utils.KASServiceChainAnchorRequestTimeoutFlag, utils.EnableDBSyncerFlag, utils.DBHostFlag, utils.DBPortFlag, utils.DBNameFlag, utils.DBUserFlag, utils.DBPasswordFlag, utils.EnabledLogModeFlag, utils.MaxIdleConnsFlag, utils.MaxOpenConnsFlag, utils.ConnMaxLifeTimeFlag, utils.BlockSyncChannelSizeFlag, utils.DBSyncerModeFlag, utils.GenQueryThreadFlag, utils.InsertThreadFlag, utils.BulkInsertSizeFlag, utils.EventModeFlag, utils.MaxBlockDiffFlag, utils.TxResendIntervalFlag, utils.TxResendCountFlag, utils.TxResendUseLegacyFlag, }
var KSPNFlags = []cli.Flag{ utils.TxResendIntervalFlag, utils.TxResendCountFlag, utils.TxResendUseLegacyFlag, utils.TxPoolSpamThrottlerDisableFlag, utils.ServiceChainSignerFlag, utils.AnchoringPeriodFlag, utils.SentChainTxsLimit, utils.MainBridgeFlag, utils.MainBridgeListenPortFlag, utils.ChildChainIndexingFlag, utils.SubBridgeFlag, utils.SubBridgeListenPortFlag, utils.ParentChainIDFlag, utils.VTRecoveryFlag, utils.VTRecoveryIntervalFlag, utils.ServiceChainNewAccountFlag, utils.ServiceChainAnchoringFlag, utils.ServiceChainParentOperatorTxGasLimitFlag, utils.ServiceChainChildOperatorTxGasLimitFlag, utils.KASServiceChainAnchorFlag, utils.KASServiceChainAnchorPeriodFlag, utils.KASServiceChainAnchorUrlFlag, utils.KASServiceChainAnchorOperatorFlag, utils.KASServiceChainSecretKeyFlag, utils.KASServiceChainAccessKeyFlag, utils.KASServiceChainXChainIdFlag, utils.KASServiceChainAnchorRequestTimeoutFlag, }
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: utils.MigrateFlags(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 VersionCommand = cli.Command{ Action: utils.MigrateFlags(version), Name: "version", Usage: "Show version number", ArgsUsage: " ", Category: "MISCELLANEOUS COMMANDS", }
Functions ¶
func BeforeRunBootnode ¶
func BeforeRunBootnode(ctx *cli.Context) error
func BeforeRunKlaytn ¶
func BeforeRunKlaytn(ctx *cli.Context) error
func CheckCommands ¶
func CheckCommands(ctx *cli.Context) error
func CommandNotExist ¶
func CommandNotExist(ctx *cli.Context, s string)
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 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.