2021-07-09 09:53:10 +00:00
|
|
|
package morph
|
|
|
|
|
|
|
|
import (
|
2024-02-01 07:20:17 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/ape"
|
2024-02-01 13:38:20 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/balance"
|
2024-02-01 14:28:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/config"
|
2024-02-01 14:36:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/container"
|
2024-02-02 06:06:24 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/contract"
|
2024-02-01 13:11:17 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/frostfsid"
|
2024-02-01 14:41:44 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/netmap"
|
2024-02-01 14:53:00 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/node"
|
2024-02-01 13:58:48 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/notary"
|
2024-02-01 12:55:33 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/policy"
|
2024-02-01 13:31:46 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/proxy"
|
2024-01-31 14:26:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
2021-07-09 09:53:10 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2024-02-01 13:58:48 +00:00
|
|
|
alphabetSizeFlag = "size"
|
|
|
|
|
2024-02-01 12:21:51 +00:00
|
|
|
storageWalletLabelFlag = "label"
|
|
|
|
storageGasCLIFlag = "initial-gas"
|
|
|
|
storageGasConfigFlag = "storage.initial_gas"
|
|
|
|
|
|
|
|
maxObjectSizeCLIFlag = "max-object-size"
|
|
|
|
|
2024-02-01 14:28:10 +00:00
|
|
|
epochDurationCLIFlag = "epoch-duration"
|
|
|
|
|
|
|
|
containerFeeCLIFlag = "container-fee"
|
|
|
|
containerAliasFeeCLIFlag = "container-alias-fee"
|
|
|
|
|
|
|
|
candidateFeeCLIFlag = "candidate-fee"
|
|
|
|
|
|
|
|
homomorphicHashDisabledCLIFlag = "homomorphic-disabled"
|
|
|
|
|
2024-02-01 14:36:26 +00:00
|
|
|
withdrawFeeCLIFlag = "withdraw-fee"
|
2024-01-31 14:26:26 +00:00
|
|
|
|
|
|
|
walletAddressFlag = "wallet-address"
|
2021-07-09 09:53:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// RootCmd is a root command of config section.
|
|
|
|
RootCmd = &cobra.Command{
|
|
|
|
Use: "morph",
|
2022-06-28 06:03:52 +00:00
|
|
|
Short: "Section for morph network configuration commands",
|
2021-07-09 09:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
generateAlphabetCmd = &cobra.Command{
|
|
|
|
Use: "generate-alphabet",
|
|
|
|
Short: "Generate alphabet wallets for consensus nodes of the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
|
|
|
// PreRun fixes https://github.com/spf13/viper/issues/233
|
2024-02-01 06:51:24 +00:00
|
|
|
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
|
2021-07-09 09:53:10 +00:00
|
|
|
},
|
|
|
|
RunE: generateAlphabetCreds,
|
|
|
|
}
|
|
|
|
|
|
|
|
initCmd = &cobra.Command{
|
|
|
|
Use: "init",
|
|
|
|
Short: "Initialize side chain network with smart-contracts and network settings",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
2024-02-01 06:51:24 +00:00
|
|
|
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
|
2024-01-31 14:26:26 +00:00
|
|
|
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
2024-02-01 12:21:51 +00:00
|
|
|
_ = viper.BindPFlag(util.EpochDurationInitFlag, cmd.Flags().Lookup(epochDurationCLIFlag))
|
|
|
|
_ = viper.BindPFlag(util.MaxObjectSizeInitFlag, cmd.Flags().Lookup(maxObjectSizeCLIFlag))
|
2024-02-01 14:28:10 +00:00
|
|
|
_ = viper.BindPFlag(util.HomomorphicHashDisabledInitFlag, cmd.Flags().Lookup(homomorphicHashDisabledCLIFlag))
|
|
|
|
_ = viper.BindPFlag(util.CandidateFeeInitFlag, cmd.Flags().Lookup(candidateFeeCLIFlag))
|
|
|
|
_ = viper.BindPFlag(util.ContainerFeeInitFlag, cmd.Flags().Lookup(containerFeeCLIFlag))
|
|
|
|
_ = viper.BindPFlag(util.ContainerAliasFeeInitFlag, cmd.Flags().Lookup(containerAliasFeeCLIFlag))
|
|
|
|
_ = viper.BindPFlag(util.WithdrawFeeInitFlag, cmd.Flags().Lookup(withdrawFeeCLIFlag))
|
2024-01-31 14:26:26 +00:00
|
|
|
_ = viper.BindPFlag(util.ProtoConfigPath, cmd.Flags().Lookup(util.ProtoConfigPath))
|
2021-07-09 09:53:10 +00:00
|
|
|
},
|
|
|
|
RunE: initializeSideChainCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
generateStorageCmd = &cobra.Command{
|
|
|
|
Use: "generate-storage-wallet",
|
|
|
|
Short: "Generate storage node wallet for the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
2024-02-01 06:51:24 +00:00
|
|
|
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
|
2024-01-31 14:26:26 +00:00
|
|
|
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
2021-07-26 08:01:53 +00:00
|
|
|
_ = viper.BindPFlag(storageGasConfigFlag, cmd.Flags().Lookup(storageGasCLIFlag))
|
2021-07-09 09:53:10 +00:00
|
|
|
},
|
|
|
|
RunE: generateStorageCreds,
|
|
|
|
}
|
|
|
|
|
2021-08-25 07:35:16 +00:00
|
|
|
refillGasCmd = &cobra.Command{
|
|
|
|
Use: "refill-gas",
|
|
|
|
Short: "Refill GAS of storage node's wallet in the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
2024-02-01 06:51:24 +00:00
|
|
|
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
|
2024-01-31 14:26:26 +00:00
|
|
|
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
2024-02-01 13:58:48 +00:00
|
|
|
_ = viper.BindPFlag(util.RefillGasAmountFlag, cmd.Flags().Lookup(util.RefillGasAmountFlag))
|
2021-08-25 07:35:16 +00:00
|
|
|
},
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2024-02-01 13:58:48 +00:00
|
|
|
return refillGas(cmd, util.RefillGasAmountFlag, false)
|
2021-08-25 07:35:16 +00:00
|
|
|
},
|
|
|
|
}
|
2021-07-09 09:53:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2023-03-23 06:55:26 +00:00
|
|
|
initGenerateAlphabetCmd()
|
|
|
|
initInitCmd()
|
|
|
|
initDeployCmd()
|
|
|
|
initGenerateStorageCmd()
|
2024-02-01 14:59:53 +00:00
|
|
|
RootCmd.AddCommand(netmap.ForceNewEpoch)
|
2024-02-01 14:53:00 +00:00
|
|
|
RootCmd.AddCommand(node.RemoveCmd)
|
2024-02-01 12:55:33 +00:00
|
|
|
RootCmd.AddCommand(policy.Set)
|
|
|
|
RootCmd.AddCommand(policy.Dump)
|
2024-02-02 06:06:24 +00:00
|
|
|
RootCmd.AddCommand(contract.DumpHashesCmd)
|
2024-02-01 14:28:10 +00:00
|
|
|
RootCmd.AddCommand(config.SetCmd)
|
|
|
|
RootCmd.AddCommand(config.DumpCmd)
|
2024-02-01 13:38:20 +00:00
|
|
|
RootCmd.AddCommand(balance.DumpCmd)
|
2024-02-02 06:49:03 +00:00
|
|
|
RootCmd.AddCommand(contract.UpdateCmd)
|
2024-02-01 14:36:26 +00:00
|
|
|
RootCmd.AddCommand(container.ListCmd)
|
|
|
|
RootCmd.AddCommand(container.RestoreCmd)
|
|
|
|
RootCmd.AddCommand(container.DumpCmd)
|
2023-03-23 06:55:26 +00:00
|
|
|
initRefillGasCmd()
|
2024-02-01 13:58:48 +00:00
|
|
|
RootCmd.AddCommand(notary.DepositCmd)
|
2024-02-01 14:41:44 +00:00
|
|
|
RootCmd.AddCommand(netmap.CandidatesCmd)
|
2023-12-21 13:33:37 +00:00
|
|
|
|
2024-02-01 07:20:17 +00:00
|
|
|
RootCmd.AddCommand(ape.Cmd)
|
2024-02-01 13:31:46 +00:00
|
|
|
RootCmd.AddCommand(proxy.AddAccountCmd)
|
|
|
|
RootCmd.AddCommand(proxy.RemoveAccountCmd)
|
2024-01-12 10:54:00 +00:00
|
|
|
|
2024-02-01 13:11:17 +00:00
|
|
|
RootCmd.AddCommand(frostfsid.Cmd)
|
2023-12-21 09:26:47 +00:00
|
|
|
}
|
|
|
|
|
2023-03-23 06:55:26 +00:00
|
|
|
func initRefillGasCmd() {
|
|
|
|
RootCmd.AddCommand(refillGasCmd)
|
2024-02-01 06:51:24 +00:00
|
|
|
refillGasCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
2024-01-31 14:26:26 +00:00
|
|
|
refillGasCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
2024-02-01 13:58:48 +00:00
|
|
|
refillGasCmd.Flags().String(util.StorageWalletFlag, "", "Path to storage node wallet")
|
2023-03-23 06:55:26 +00:00
|
|
|
refillGasCmd.Flags().String(walletAddressFlag, "", "Address of wallet")
|
2024-02-01 13:58:48 +00:00
|
|
|
refillGasCmd.Flags().String(util.RefillGasAmountFlag, "", "Additional amount of GAS to transfer")
|
|
|
|
refillGasCmd.MarkFlagsMutuallyExclusive(walletAddressFlag, util.StorageWalletFlag)
|
2023-03-23 06:55:26 +00:00
|
|
|
}
|
2022-06-27 14:47:13 +00:00
|
|
|
|
2023-03-23 06:55:26 +00:00
|
|
|
func initGenerateStorageCmd() {
|
|
|
|
RootCmd.AddCommand(generateStorageCmd)
|
2024-02-01 06:51:24 +00:00
|
|
|
generateStorageCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
2024-01-31 14:26:26 +00:00
|
|
|
generateStorageCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
2024-02-01 13:58:48 +00:00
|
|
|
generateStorageCmd.Flags().String(util.StorageWalletFlag, "", "Path to new storage node wallet")
|
2023-03-23 06:55:26 +00:00
|
|
|
generateStorageCmd.Flags().String(storageGasCLIFlag, "", "Initial amount of GAS to transfer")
|
|
|
|
generateStorageCmd.Flags().StringP(storageWalletLabelFlag, "l", "", "Wallet label")
|
|
|
|
}
|
2023-01-31 10:33:33 +00:00
|
|
|
|
2023-03-23 06:55:26 +00:00
|
|
|
func initInitCmd() {
|
|
|
|
RootCmd.AddCommand(initCmd)
|
2024-02-01 06:51:24 +00:00
|
|
|
initCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
2024-01-31 14:26:26 +00:00
|
|
|
initCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
2024-02-01 12:21:51 +00:00
|
|
|
initCmd.Flags().String(util.ContractsInitFlag, "", util.ContractsInitFlagDesc)
|
|
|
|
initCmd.Flags().String(util.ContractsURLFlag, "", util.ContractsURLFlagDesc)
|
2023-03-23 06:55:26 +00:00
|
|
|
initCmd.Flags().Uint(epochDurationCLIFlag, 240, "Amount of side chain blocks in one FrostFS epoch")
|
|
|
|
initCmd.Flags().Uint(maxObjectSizeCLIFlag, 67108864, "Max single object size in bytes")
|
|
|
|
initCmd.Flags().Bool(homomorphicHashDisabledCLIFlag, false, "Disable object homomorphic hashing")
|
|
|
|
// Defaults are taken from neo-preodolenie.
|
|
|
|
initCmd.Flags().Uint64(containerFeeCLIFlag, 1000, "Container registration fee")
|
|
|
|
initCmd.Flags().Uint64(containerAliasFeeCLIFlag, 500, "Container alias fee")
|
2024-01-31 14:26:26 +00:00
|
|
|
initCmd.Flags().String(util.ProtoConfigPath, "", "Path to the consensus node configuration")
|
2024-02-01 12:21:51 +00:00
|
|
|
initCmd.Flags().String(util.LocalDumpFlag, "", "Path to the blocks dump file")
|
|
|
|
initCmd.MarkFlagsMutuallyExclusive(util.ContractsInitFlag, util.ContractsURLFlag)
|
2023-03-23 06:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func initGenerateAlphabetCmd() {
|
|
|
|
RootCmd.AddCommand(generateAlphabetCmd)
|
2024-02-01 06:51:24 +00:00
|
|
|
generateAlphabetCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
2023-03-23 06:55:26 +00:00
|
|
|
generateAlphabetCmd.Flags().Uint(alphabetSizeFlag, 7, "Amount of alphabet wallets to generate")
|
|
|
|
}
|
|
|
|
|
|
|
|
func initDeployCmd() {
|
|
|
|
RootCmd.AddCommand(deployCmd)
|
2021-07-09 09:53:10 +00:00
|
|
|
}
|