From 76b9010bc823b6ae7e3d664923de6c578b2f9035 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Tue, 21 Feb 2023 22:12:38 +0000 Subject: [PATCH] Update docs re public endpoint. --- cmd/nodeinfo.go | 24 +++++++++++++++++++++++- cmd/validator/credentials/set/process.go | 3 +++ docs/changingwithdrawalcredentials.md | 18 ++++++++++++------ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/cmd/nodeinfo.go b/cmd/nodeinfo.go index 7fdef9a..2b682c6 100644 --- a/cmd/nodeinfo.go +++ b/cmd/nodeinfo.go @@ -24,6 +24,9 @@ import ( "github.com/wealdtech/ethdo/util" ) +// defaultBeaconNode is used if no other connection is supplied. +var defaultBeaconNode = "http://mainnet-consensus.attestant.io/" + var nodeInfoCmd = &cobra.Command{ Use: "info", Short: "Obtain information about a node", @@ -36,7 +39,26 @@ In quiet mode this will return 0 if the node information can be obtained, otherw ctx := context.Background() eth2Client, err := util.ConnectToBeaconNode(ctx, viper.GetString("connection"), viper.GetDuration("timeout"), viper.GetBool("allow-insecure-connections")) - errCheck(err, "Failed to connect to Ethereum 2 beacon node") + if err != nil { + if viper.GetString("connection") != "" { + // The user provided a connection, so don't second-guess them by using a different node. + fmt.Fprintln(os.Stderr, err.Error()) + return + } + + // The user did not provide a connection, so attempt to use the default node. + if viper.GetBool("debug") { + fmt.Fprintf(os.Stderr, "No node connection, attempting to use %s\n", defaultBeaconNode) + } + eth2Client, err = util.ConnectToBeaconNode(ctx, defaultBeaconNode, viper.GetDuration("timeout"), viper.GetBool("allow-insecure-connections")) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + return + } + if !viper.GetBool("quiet") { + fmt.Fprintf(os.Stderr, "No connection supplied; using mainnet public access endpoint\n") + } + } if quiet { os.Exit(_exitSuccess) diff --git a/cmd/validator/credentials/set/process.go b/cmd/validator/credentials/set/process.go index 8c84dd9..f416228 100644 --- a/cmd/validator/credentials/set/process.go +++ b/cmd/validator/credentials/set/process.go @@ -725,6 +725,9 @@ func (c *command) setup(ctx context.Context) error { if err != nil { return err } + if !c.quiet { + fmt.Fprintf(os.Stderr, "No connection supplied; using mainnet public access endpoint\n") + } } // Set up chaintime. diff --git a/docs/changingwithdrawalcredentials.md b/docs/changingwithdrawalcredentials.md index 4f477ae..5617369 100644 --- a/docs/changingwithdrawalcredentials.md +++ b/docs/changingwithdrawalcredentials.md @@ -59,27 +59,33 @@ Here the copy of `ethdo` with access to private keys is on an offline computer, ## Preparation Regardless of the method selected, preparation must take place on the online computer to ensure that `ethdo` can access your consensus node. `ethdo` will attempt to find a local consensus node automatically, but if not then an explicit connection value will be required. To find out if `ethdo` has access to the consensus node run: -``` -ethdo node info --verbose +```sh +ethdo node info ``` The result should be something similar to the following: ``` -Version: teku/v22.9.1/linux-x86_64/-privatebuild-openjdk64bitservervm-java-14 Syncing: false ``` -It is important to confirm that the "Syncing" value is "false". If this is "true" it means that the node is currently syncing, and you will need to wait for the process to finish before proceeding. +Alternatively, the result may look like this: -If this command instead returns an error you will need to add an explicit connection string. For example, if your consensus node is serving its REST API on port 12345 then you should add `--connection=http://localhost:12345` to all `ethdo` commands in this process, for example: +``` +No connection supplied; using mainnet public access endpoint +Syncing: false +``` + +which means that a local consensus node was not accessed and instead a public endpoint specifically assigned to handle these operations was used instead. If you do have a local consensus node but see this message it means that the local node could not be accessed, usually because it is running on a non-standard port. If this is the case for your configuration, you need to let `ethdo` know where the consensus node's REST API is. For example, if your consensus node is serving its REST API on port 12345 then you should add `--connection=http://localhost:12345` to all `ethdo` commands in this process, for example: ```sh -ethdo --connection=http://localhost:12345 node info --verbose +ethdo --connection=http://localhost:12345 node info ``` Note that some consensus nodes may require configuration to serve their REST API. Please refer to the documentation of your specific consensus node to enable this. +Regardless of your method used above, it is important to confirm that the "Syncing" value is "false". If this is "true" it means that the node is currently syncing, and you will need to wait for the process to finish before proceeding. + Once the preparation is complete you should select either basic or advanced operation, depending on your requirements. ## Basic operation