Skip to content

Commit 57480ec

Browse files
Grouped Blockchain Create Flags (#2817)
* core test function * lint * lint * address comments * lint * add tests * add more tests * generate node id * remove use local nodes * more e2e tests * add git workflow e2e * fix e2e * update e2e * update e2e * update e2e * update e2e * update e2e * update e2e * completed e2e * lint * more e2e * update cmd description * lint * fix merge * fix merge * add more tests * lint * grouped convert flags * Convert flag groups * lint * refacotr * refactor common flags * fix merge * fix * fix lint * fix lint * refactor common flags * refactor common code * fix e2e err * lint * Fix err * fix e2e * lint * add e2e * add convert e2e * enable e2e * e2e * fix e2e * fix e2e * fix e2e * fix e2e * fix e2e * fix e2e * fix e2e * lint * fix e2e * fix e2e * fix e2e * lint * grouped blockchain create flags * lint * lint * lint * fix --------- Signed-off-by: sukantoraymond <rsukanto@umich.edu>
1 parent 0b2e7ed commit 57480ec

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

cmd/blockchaincmd/create.go

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"strings"
1313
"unicode"
1414

15+
"github.com/spf13/pflag"
16+
1517
"github.com/ava-labs/avalanche-cli/cmd/flags"
1618
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
1719
"github.com/ava-labs/avalanche-cli/pkg/constants"
@@ -90,41 +92,53 @@ the path to your genesis and VM binaries with the --genesis and --vm flags.
9092
By default, running the command with a blockchainName that already exists
9193
causes the command to fail. If you'd like to overwrite an existing
9294
configuration, pass the -f flag.`,
93-
Args: cobrautils.ExactArgs(1),
95+
PreRunE: cobrautils.ExactArgs(1),
9496
RunE: createBlockchainConfig,
9597
PersistentPostRun: handlePostRun,
9698
}
9799
cmd.Flags().StringVar(&genesisPath, "genesis", "", "file path of genesis to use")
98-
cmd.Flags().BoolVar(&createFlags.useSubnetEvm, "evm", false, "use the Subnet-EVM as the base template")
99-
cmd.Flags().BoolVar(&createFlags.useCustomVM, "custom", false, "use a custom VM template")
100-
cmd.Flags().StringVar(&createFlags.vmVersion, "vm-version", "", "version of Subnet-EVM template to use")
101-
cmd.Flags().BoolVar(&createFlags.useLatestPreReleasedVMVersion, preRelease, false, "use latest Subnet-EVM pre-released version, takes precedence over --vm-version")
102-
cmd.Flags().BoolVar(&createFlags.useLatestReleasedVMVersion, latest, false, "use latest Subnet-EVM released version, takes precedence over --vm-version")
103-
cmd.Flags().Uint64Var(&createFlags.chainID, "evm-chain-id", 0, "chain ID to use with Subnet-EVM")
104-
cmd.Flags().StringVar(&createFlags.tokenSymbol, "evm-token", "", "token symbol to use with Subnet-EVM")
105-
cmd.Flags().BoolVar(&createFlags.useProductionDefaults, "evm-defaults", false, "deprecation notice: use '--production-defaults'")
106-
cmd.Flags().BoolVar(&createFlags.useProductionDefaults, "production-defaults", false, "use default production settings for your blockchain")
107-
cmd.Flags().BoolVar(&createFlags.useTestDefaults, "test-defaults", false, "use default test settings for your blockchain")
108100
cmd.Flags().BoolVarP(&forceCreate, forceFlag, "f", false, "overwrite the existing configuration if one exists")
109-
cmd.Flags().StringVar(&vmFile, "vm", "", "file path of custom vm to use. alias to custom-vm-path")
110-
cmd.Flags().StringVar(&vmFile, "custom-vm-path", "", "file path of custom vm to use")
111-
cmd.Flags().StringVar(&customVMRepoURL, "custom-vm-repo-url", "", "custom vm repository url")
112-
cmd.Flags().StringVar(&customVMBranch, "custom-vm-branch", "", "custom vm branch or commit")
113-
cmd.Flags().StringVar(&customVMBuildScript, "custom-vm-build-script", "", "custom vm build-script")
114-
cmd.Flags().BoolVar(&useRepo, "from-github-repo", false, "generate custom VM binary from github repository")
115-
cmd.Flags().BoolVar(&createFlags.useWarp, "warp", true, "generate a vm with warp support (needed for ICM)")
116-
cmd.Flags().BoolVar(&createFlags.useICM, "teleporter", false, "interoperate with other blockchains using ICM")
117-
cmd.Flags().BoolVar(&createFlags.useICM, "icm", false, "interoperate with other blockchains using ICM")
118-
cmd.Flags().BoolVar(&createFlags.useExternalGasToken, "external-gas-token", false, "use a gas token from another blockchain")
119-
cmd.Flags().BoolVar(&createFlags.addICMRegistryToGenesis, "icm-registry-at-genesis", false, "setup ICM registry smart contract on genesis [experimental]")
120-
cmd.Flags().BoolVar(&createFlags.proofOfAuthority, "proof-of-authority", false, "use proof of authority(PoA) for validator management")
121-
cmd.Flags().BoolVar(&createFlags.proofOfStake, "proof-of-stake", false, "use proof of stake(PoS) for validator management")
122-
cmd.Flags().StringVar(&createFlags.validatorManagerOwner, "validator-manager-owner", "", "EVM address that controls Validator Manager Owner")
123-
cmd.Flags().StringVar(&createFlags.proxyContractOwner, "proxy-contract-owner", "", "EVM address that controls ProxyAdmin for TransparentProxy of ValidatorManager contract")
124-
cmd.Flags().BoolVar(&sovereign, "sovereign", true, "set to false if creating non-sovereign blockchain")
125-
cmd.Flags().Uint64Var(&createFlags.rewardBasisPoints, "reward-basis-points", 100, "(PoS only) reward basis points for PoS Reward Calculator")
126101
cmd.Flags().BoolVar(&createFlags.enableDebugging, "debug", true, "enable blockchain debugging")
127-
cmd.Flags().BoolVar(&createFlags.useACP99, "acp99", true, "use ACP99 contracts instead of v1.0.0 for validator managers")
102+
103+
sovGroup := flags.RegisterFlagGroup(cmd, "Subnet-Only-Validators (SOV) Flags", "show-sov-flags", true, func(set *pflag.FlagSet) {
104+
set.BoolVar(&createFlags.useACP99, "acp99", true, "use ACP99 contracts instead of v1.0.0 for validator managers")
105+
set.BoolVar(&createFlags.proofOfAuthority, "proof-of-authority", false, "use proof of authority(PoA) for validator management")
106+
set.BoolVar(&createFlags.proofOfStake, "proof-of-stake", false, "use proof of stake(PoS) for validator management")
107+
set.StringVar(&createFlags.validatorManagerOwner, "validator-manager-owner", "", "EVM address that controls Validator Manager Owner")
108+
set.StringVar(&createFlags.proxyContractOwner, "proxy-contract-owner", "", "EVM address that controls ProxyAdmin for TransparentProxy of ValidatorManager contract")
109+
set.Uint64Var(&createFlags.rewardBasisPoints, "reward-basis-points", 100, "(PoS only) reward basis points for PoS Reward Calculator")
110+
set.BoolVar(&sovereign, "sovereign", true, "set to false if creating non-sovereign blockchain")
111+
})
112+
113+
evmGroup := flags.RegisterFlagGroup(cmd, "EVM Flags", "show-evm-flags", true, func(set *pflag.FlagSet) {
114+
set.BoolVar(&createFlags.useSubnetEvm, "evm", false, "use Subnet-EVM")
115+
set.Uint64Var(&createFlags.chainID, "evm-chain-id", 0, "chain ID to use with Subnet-EVM")
116+
set.StringVar(&createFlags.tokenSymbol, "evm-token", "", "token symbol to use with Subnet-EVM")
117+
set.StringVar(&createFlags.vmVersion, "vm-version", "", "version of Subnet-EVM template to use")
118+
set.BoolVar(&createFlags.useLatestPreReleasedVMVersion, preRelease, false, "use latest Subnet-EVM pre-released version, takes precedence over --vm-version")
119+
set.BoolVar(&createFlags.useLatestReleasedVMVersion, latest, false, "use latest Subnet-EVM released version, takes precedence over --vm-version")
120+
set.BoolVar(&createFlags.useProductionDefaults, "production-defaults", false, "use default production settings for your blockchain")
121+
set.BoolVar(&createFlags.useTestDefaults, "test-defaults", false, "use default test settings for your blockchain")
122+
})
123+
124+
customVMGroup := flags.RegisterFlagGroup(cmd, "Custom VM Flags", "show-custom-vm-flags", true, func(set *pflag.FlagSet) {
125+
set.StringVar(&customVMRepoURL, "custom-vm-repo-url", "", "custom vm repository url")
126+
set.StringVar(&vmFile, "custom-vm-path", "", "file path of custom vm to use")
127+
set.BoolVar(&createFlags.useCustomVM, "custom", false, "use a custom VM")
128+
set.StringVar(&customVMBranch, "custom-vm-branch", "", "custom vm branch or commit")
129+
set.StringVar(&customVMBuildScript, "custom-vm-build-script", "", "custom vm build-script")
130+
set.BoolVar(&useRepo, "from-github-repo", false, "generate custom VM binary from github repository")
131+
})
132+
133+
icmGroup := flags.RegisterFlagGroup(cmd, "ICM Flags", "show-icm-flags", true, func(set *pflag.FlagSet) {
134+
set.BoolVar(&createFlags.useWarp, "warp", true, "generate a vm with warp support (needed for ICM)")
135+
set.BoolVar(&createFlags.useICM, "icm", false, "interoperate with other blockchains using ICM")
136+
set.BoolVar(&createFlags.useExternalGasToken, "external-gas-token", false, "use a gas token from another blockchain")
137+
set.BoolVar(&createFlags.addICMRegistryToGenesis, "icm-registry-at-genesis", false, "setup ICM registry smart contract on genesis [experimental]")
138+
set.BoolVar(&createFlags.useProductionDefaults, "production-defaults", false, "use default production settings for your blockchain")
139+
set.BoolVar(&createFlags.useTestDefaults, "test-defaults", false, "use default test settings for your blockchain")
140+
})
141+
cmd.SetHelpFunc(flags.WithGroupedHelp([]flags.GroupedFlags{sovGroup, evmGroup, customVMGroup, icmGroup}))
128142
return cmd
129143
}
130144

0 commit comments

Comments
 (0)