-
Notifications
You must be signed in to change notification settings - Fork 117
[Test Coverage Improvement] Validator Manager Flags #2690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 20 commits
74082f2
8c8d665
96d874c
aaca645
0bd0dbe
6138faa
4ddcc73
09520e3
9b37e4b
02d80b4
de14ae6
b3aceaf
db5a674
a5d6789
7902334
225bb19
3a31816
217a03e
5befbb6
9782ca1
d523864
ac6ee98
8334125
e377c10
c09efdc
143512e
631591c
0b23ce4
9c03b43
d1ab0ea
aac4455
bcd19e3
4a3ce8a
817ad66
7daf566
b1436fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ import ( | |
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/ava-labs/avalanche-cli/cmd/flags" | ||
|
|
||
| "github.com/ava-labs/avalanche-cli/pkg/blockchain" | ||
| "github.com/ava-labs/avalanche-cli/pkg/cobrautils" | ||
| "github.com/ava-labs/avalanche-cli/pkg/constants" | ||
|
|
@@ -53,17 +55,12 @@ var ( | |
| pop string | ||
| remainingBalanceOwnerAddr string | ||
| disableOwnerAddr string | ||
| rpcURL string | ||
| aggregatorLogLevel string | ||
| aggregatorLogToStdout bool | ||
| delegationFee uint16 | ||
| errNoSubnetID = errors.New("failed to find the subnet ID for this subnet, has it been deployed/created on this network?") | ||
| errMutuallyExclusiveDurationOptions = errors.New("--use-default-duration/--use-default-validator-params and --staking-period are mutually exclusive") | ||
| errMutuallyExclusiveStartOptions = errors.New("--use-default-start-time/--use-default-validator-params and --start-time are mutually exclusive") | ||
| errMutuallyExclusiveWeightOptions = errors.New("--use-default-validator-params and --weight are mutually exclusive") | ||
| ErrNotPermissionedSubnet = errors.New("subnet is not permissioned") | ||
| aggregatorExtraEndpoints []string | ||
| aggregatorAllowPrivatePeers bool | ||
| clusterNameFlagValue string | ||
| createLocalValidator bool | ||
| externalValidatorManagerOwner bool | ||
|
|
@@ -91,7 +88,8 @@ Testnet or Mainnet.`, | |
| Args: cobrautils.MaximumNArgs(1), | ||
| } | ||
| networkoptions.AddNetworkFlagsToCmd(cmd, &globalNetworkFlags, true, networkoptions.DefaultSupportedNetworkOptions) | ||
|
|
||
| flags.AddRPCFlagToCmd(cmd) | ||
| flags.AddSignatureAggregatorFlagsToCmd(cmd) | ||
| cmd.Flags().StringVarP(&keyName, "key", "k", "", "select the key to use [fuji/devnet only]") | ||
| cmd.Flags().Float64Var( | ||
| &balanceAVAX, | ||
|
|
@@ -110,11 +108,6 @@ Testnet or Mainnet.`, | |
| cmd.Flags().BoolVar(&createLocalValidator, "create-local-validator", false, "create additional local validator and add it to existing running local node") | ||
| cmd.Flags().BoolVar(&partialSync, "partial-sync", true, "set primary network partial sync for new validators") | ||
| cmd.Flags().StringVar(&nodeEndpoint, "node-endpoint", "", "gather node id/bls from publicly available avalanchego apis on the given endpoint") | ||
| cmd.Flags().StringSliceVar(&aggregatorExtraEndpoints, "aggregator-extra-endpoints", nil, "endpoints for extra nodes that are needed in signature aggregation") | ||
| cmd.Flags().BoolVar(&aggregatorAllowPrivatePeers, "aggregator-allow-private-peers", true, "allow the signature aggregator to connect to peers with private IP") | ||
| cmd.Flags().StringVar(&rpcURL, "rpc", "", "connect to validator manager at the given rpc endpoint") | ||
| cmd.Flags().StringVar(&aggregatorLogLevel, "aggregator-log-level", constants.DefaultAggregatorLogLevel, "log level to use with signature aggregator") | ||
| cmd.Flags().BoolVar(&aggregatorLogToStdout, "aggregator-log-to-stdout", false, "use stdout for signature aggregator logs") | ||
| cmd.Flags().DurationVar(&duration, "staking-period", 0, "how long this validator will be staking") | ||
| cmd.Flags().BoolVar(&useDefaultStartTime, "default-start-time", false, "(for Subnets, not L1s) use default start time for subnet validator (5 minutes later for fuji & mainnet, 30 seconds later for devnet)") | ||
| cmd.Flags().StringVar(&startTimeStr, "start-time", "", "(for Subnets, not L1s) UTC start time when this validator starts validating, in 'YYYY-MM-DD HH:MM:SS' format") | ||
|
|
@@ -183,13 +176,13 @@ func addValidator(cmd *cobra.Command, args []string) error { | |
| } | ||
|
|
||
| if len(args) == 0 { | ||
| if rpcURL == "" { | ||
| rpcURL, err = app.Prompt.CaptureURL("What is the RPC endpoint?", false) | ||
| if flags.RPC == "" { | ||
|
||
| flags.RPC, err = app.Prompt.CaptureURL("What is the RPC endpoint?", false) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } | ||
| sc, err = importL1(blockchainIDStr, rpcURL, network) | ||
| sc, err = importL1(blockchainIDStr, flags.RPC, network) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -313,8 +306,6 @@ func addValidator(cmd *cobra.Command, args []string) error { | |
| if err := app.UpdateSidecar(&sc); err != nil { | ||
| return err | ||
| } | ||
| // make sure extra validator endpoint added for the new node | ||
| aggregatorExtraEndpoints = append(aggregatorExtraEndpoints, constants.LocalAPIEndpoint) | ||
| } | ||
|
|
||
| if nodeIDStr == "" { | ||
|
|
@@ -360,6 +351,7 @@ func addValidator(cmd *cobra.Command, args []string) error { | |
| remainingBalanceOwnerAddr, | ||
| disableOwnerAddr, | ||
| sc, | ||
| flags.RPC, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -384,6 +376,7 @@ func CallAddValidator( | |
| remainingBalanceOwnerAddr string, | ||
| disableOwnerAddr string, | ||
| sc models.Sidecar, | ||
| rpcURL string, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the point of passing this and other global variables (flags in this case) to this function as arguments as opposed to just using them directly?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the goal is to be able to call this command from another command, and pass to it only the needed values. this concept is best represented in the tokentransferrer deploy cmd, here the implementation is partial. |
||
| ) error { | ||
| nodeID, err := ids.NodeIDFromString(nodeIDStr) | ||
| if err != nil { | ||
|
|
@@ -526,17 +519,15 @@ func CallAddValidator( | |
| Threshold: 1, | ||
| Addresses: disableOwnerAddrID, | ||
| } | ||
|
|
||
| extraAggregatorPeers, err := blockchain.GetAggregatorExtraPeers(app, clusterNameFlagValue, aggregatorExtraEndpoints) | ||
| extraAggregatorPeers, err := blockchain.GetAggregatorExtraPeers(app, clusterNameFlagValue) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| aggregatorLogger, err := utils.NewLogger( | ||
| constants.SignatureAggregatorLogName, | ||
| aggregatorLogLevel, | ||
| flags.SigAggFlags, | ||
| constants.DefaultAggregatorLogLevel, | ||
| app.GetAggregatorLogDir(clusterNameFlagValue), | ||
| aggregatorLogToStdout, | ||
| ux.Logger.PrintToUser, | ||
| ) | ||
| if err != nil { | ||
|
|
@@ -560,7 +551,6 @@ func CallAddValidator( | |
| disableOwners, | ||
| weight, | ||
| extraAggregatorPeers, | ||
| aggregatorAllowPrivatePeers, | ||
| aggregatorLogger, | ||
| pos, | ||
| delegationFee, | ||
|
|
@@ -605,7 +595,6 @@ func CallAddValidator( | |
| ownerPrivateKey, | ||
| validationID, | ||
| extraAggregatorPeers, | ||
| aggregatorAllowPrivatePeers, | ||
| aggregatorLogger, | ||
| validatorManagerAddress, | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ import ( | |
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/ava-labs/avalanche-cli/cmd/flags" | ||
|
|
||
| "github.com/ava-labs/avalanche-cli/pkg/blockchain" | ||
| "github.com/ava-labs/avalanche-cli/pkg/cobrautils" | ||
| "github.com/ava-labs/avalanche-cli/pkg/constants" | ||
|
|
@@ -51,7 +53,8 @@ The L1 has to be a Proof of Authority L1.`, | |
| Args: cobrautils.ExactArgs(1), | ||
| } | ||
| networkoptions.AddNetworkFlagsToCmd(cmd, &globalNetworkFlags, true, networkoptions.DefaultSupportedNetworkOptions) | ||
|
|
||
| flags.AddRPCFlagToCmd(cmd) | ||
|
||
| flags.AddSignatureAggregatorFlagsToCmd(cmd) | ||
| cmd.Flags().StringVarP(&keyName, "key", "k", "", "select the key to use [fuji/devnet only]") | ||
| cmd.Flags().Uint64Var(&newWeight, "weight", 0, "set the new staking weight of the validator") | ||
| cmd.Flags().BoolVarP(&useEwoq, "ewoq", "e", false, "use ewoq key [fuji/devnet only]") | ||
|
|
@@ -61,11 +64,6 @@ The L1 has to be a Proof of Authority L1.`, | |
| cmd.Flags().StringSliceVar(&ledgerAddresses, "ledger-addrs", []string{}, "use the given ledger addresses") | ||
| cmd.Flags().BoolVar(&externalValidatorManagerOwner, "external-evm-signature", false, "set this value to true when signing validator manager tx outside of cli (for multisig or ledger)") | ||
| cmd.Flags().StringVar(&validatorManagerOwner, "validator-manager-owner", "", "force using this address to issue transactions to the validator manager") | ||
| cmd.Flags().StringSliceVar(&aggregatorExtraEndpoints, "aggregator-extra-endpoints", nil, "endpoints for extra nodes that are needed in signature aggregation") | ||
| cmd.Flags().BoolVar(&aggregatorAllowPrivatePeers, "aggregator-allow-private-peers", true, "allow the signature aggregator to connect to peers with private IP") | ||
| cmd.Flags().StringVar(&aggregatorLogLevel, "aggregator-log-level", constants.DefaultAggregatorLogLevel, "log level to use with signature aggregator") | ||
| cmd.Flags().BoolVar(&aggregatorLogToStdout, "aggregator-log-to-stdout", false, "use stdout for signature aggregator logs") | ||
| cmd.Flags().StringVar(&rpcURL, "rpc", "", "connect to validator manager at the given rpc endpoint") | ||
| cmd.Flags().StringVar(&initiateTxHash, "initiate-tx-hash", "", "initiate tx is already issued, with the given hash") | ||
| return cmd | ||
| } | ||
|
|
@@ -151,8 +149,8 @@ func setWeight(_ *cobra.Command, args []string) error { | |
| BlockchainName: blockchainName, | ||
| } | ||
|
|
||
| if rpcURL == "" { | ||
| rpcURL, _, err = contract.GetBlockchainEndpoints( | ||
| if flags.RPC == "" { | ||
| flags.RPC, _, err = contract.GetBlockchainEndpoints( | ||
felipemadero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app, | ||
| network, | ||
| chainSpec, | ||
|
|
@@ -167,7 +165,7 @@ func setWeight(_ *cobra.Command, args []string) error { | |
| return fmt.Errorf("unable to find Validator Manager address") | ||
| } | ||
| validatorManagerAddress = sc.Networks[network.Name()].ValidatorManagerAddress | ||
| validationID, err := validator.GetValidationID(rpcURL, nodeID, validatorManagerAddress) | ||
| validationID, err := validator.GetValidationID(flags.RPC, nodeID, validatorManagerAddress) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -275,6 +273,7 @@ func setWeight(_ *cobra.Command, args []string) error { | |
| 0, // automatic uptime | ||
| isBootstrapValidatorForNetwork(nodeID, sc.Networks[network.Name()]), | ||
| false, // don't force | ||
| flags.RPC, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
|
|
@@ -305,6 +304,7 @@ func setWeight(_ *cobra.Command, args []string) error { | |
| remainingBalanceOwnerAddr, | ||
| disableOwnerAddr, | ||
| sc, | ||
| flags.RPC, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -351,19 +351,18 @@ func changeWeightACP99( | |
| } | ||
| validatorManagerAddress = sc.Networks[network.Name()].ValidatorManagerAddress | ||
|
|
||
| ux.Logger.PrintToUser(logging.Yellow.Wrap("RPC Endpoint: %s"), rpcURL) | ||
| ux.Logger.PrintToUser(logging.Yellow.Wrap("RPC Endpoint: %s"), flags.RPC) | ||
|
|
||
| clusterName := sc.Networks[network.Name()].ClusterName | ||
| extraAggregatorPeers, err := blockchain.GetAggregatorExtraPeers(app, clusterName, aggregatorExtraEndpoints) | ||
| extraAggregatorPeers, err := blockchain.GetAggregatorExtraPeers(app, clusterName) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| aggregatorLogger, err := utils.NewLogger( | ||
| constants.SignatureAggregatorLogName, | ||
| aggregatorLogLevel, | ||
| flags.SigAggFlags, | ||
| constants.DefaultAggregatorLogLevel, | ||
| app.GetAggregatorLogDir(clusterName), | ||
| aggregatorLogToStdout, | ||
| ux.Logger.PrintToUser, | ||
| ) | ||
| if err != nil { | ||
|
|
@@ -378,14 +377,13 @@ func changeWeightACP99( | |
| ux.Logger.PrintToUser, | ||
| app, | ||
| network, | ||
| rpcURL, | ||
| flags.RPC, | ||
| chainSpec, | ||
| externalValidatorManagerOwner, | ||
| validatorManagerOwner, | ||
| ownerPrivateKey, | ||
| nodeID, | ||
| extraAggregatorPeers, | ||
| aggregatorAllowPrivatePeers, | ||
| aggregatorLogger, | ||
| validatorManagerAddress, | ||
| weight, | ||
|
|
@@ -429,14 +427,13 @@ func changeWeightACP99( | |
| aggregatorCtx, | ||
| app, | ||
| network, | ||
| rpcURL, | ||
| flags.RPC, | ||
| chainSpec, | ||
| externalValidatorManagerOwner, | ||
| validatorManagerOwner, | ||
| ownerPrivateKey, | ||
| validationID, | ||
| extraAggregatorPeers, | ||
| aggregatorAllowPrivatePeers, | ||
| aggregatorLogger, | ||
| validatorManagerAddress, | ||
| signedMessage, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.