From 3afa7b0dabe0bd535625fd6f950149c2b461006a Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 10 Jan 2020 15:47:07 +1100 Subject: [PATCH] Print validator pubkeys during generation (#791) * Start docker docs * Add progress * Update docker.md * Add note about geth syncing * Fix env to use geth * Update docs * Remove sigp goerli node * Change text about eth1 syncing * Address comments from @pscott * Add links to beaconcha.in * Add instructions for starting an eth1 node * Print validator pubkeys during generation * Fix typo * Re-organise Syncing log * Add notes about finding the validator pubkey * Fix double-0x prefix bug * Fix typo --- account_manager/src/lib.rs | 20 ++++++++++++++++++-- book/src/become-a-validator-docker.md | 9 +++++++++ book/src/become-a-validator-source.md | 3 +++ eth2/utils/bls/src/public_key.rs | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/account_manager/src/lib.rs b/account_manager/src/lib.rs index e6d02d614..b0f3525b1 100644 --- a/account_manager/src/lib.rs +++ b/account_manager/src/lib.rs @@ -130,6 +130,7 @@ fn run_new_validator_subcommand( &methods, deposit_value, &context.eth2_config.spec, + &env.core_context().log, )?; if matches.is_present("send-deposits") { @@ -249,6 +250,7 @@ fn make_validators( methods: &[KeygenMethod], deposit_value: u64, spec: &ChainSpec, + log: &Logger, ) -> Result, String> { methods .par_iter() @@ -262,11 +264,25 @@ fn make_validators( KeygenMethod::ThreadRandom => builder.thread_random_keypairs(), }; - builder + let validator = builder .create_directory(datadir.clone())? .write_keypair_files()? .write_eth1_data_file()? - .build() + .build()?; + + let pubkey = &validator + .voting_keypair + .as_ref() + .ok_or_else(|| "Generated validator must have voting keypair".to_string())? + .pk; + + info!( + log, + "Saved new validator to disk"; + "voting_pubkey" => format!("{:?}", pubkey) + ); + + Ok(validator) }) .collect() } diff --git a/book/src/become-a-validator-docker.md b/book/src/become-a-validator-docker.md index 22649a930..7fb03845d 100644 --- a/book/src/become-a-validator-docker.md +++ b/book/src/become-a-validator-docker.md @@ -49,6 +49,15 @@ Start the docker-compose environment (you may need to use `sudo`): $ docker-compose up ``` +Watch the output of this command for the `Saved new validator to disk` log, as +the `voting_pubkey` is the primary identifier for your new validator. This is +useful for finding your validator in block explorers. Here's an example of the +log: + +```bash +validator_client_1 | Jan 10 12:06:05.632 INFO Saved new validator to disk voting_pubkey: 0x8fc28504448783b10b0a7f5a321505b07ad2ad8d6a8430b8868a0fcdedee43766bee725855506626085776e020dfa472 +``` + > Note: the docker-compose setup includes a fast-synced geth node. You can > expect the `beacon_node` to log some eth1-related errors whilst the geth node > boots and becomes synced. This will only happen on the first start of the diff --git a/book/src/become-a-validator-source.md b/book/src/become-a-validator-source.md index 1e197e2b4..d0555f0f3 100644 --- a/book/src/become-a-validator-source.md +++ b/book/src/become-a-validator-source.md @@ -74,6 +74,9 @@ Generate new validator BLS keypairs using: $ lighthouse account validator new random ``` +Take note of the `voting_pubkey` of the new validator. This will be the primary +identifier of the validator. This is how you can find your validator in block +explorers. You've completed this step when you see the equivalent line: diff --git a/eth2/utils/bls/src/public_key.rs b/eth2/utils/bls/src/public_key.rs index 789e4faf6..095d1989f 100644 --- a/eth2/utils/bls/src/public_key.rs +++ b/eth2/utils/bls/src/public_key.rs @@ -81,7 +81,7 @@ impl fmt::Display for PublicKey { impl fmt::Debug for PublicKey { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "0x{}", self.as_hex_string()) + write!(f, "{}", self.as_hex_string()) } }