From e5fc6bab485fa54d7e518b325f4eb9201ba5c6a1 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 14 Sep 2020 10:58:15 +0000 Subject: [PATCH] Remove redundant decompression in process_deposit (#1610) ## Issue Addressed Closes #1076 ## Proposed Changes Remove an extra unnecessary decompression of the deposit public key from `process_deposit`. The key is decompressed and used to verify the signature in `verify_deposit_signature`, making this initial decompression redundant. ## Additional Info This is _not_ a consensus-breaking change because keys which previously failed the early decompression check will not be found in the pubkey cache (they are invalid), and will be checked and rejected as part of `verify_deposit_signature`. --- consensus/state_processing/src/per_block_processing.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/consensus/state_processing/src/per_block_processing.rs b/consensus/state_processing/src/per_block_processing.rs index 65ac70a5f1..d6747b65e5 100644 --- a/consensus/state_processing/src/per_block_processing.rs +++ b/consensus/state_processing/src/per_block_processing.rs @@ -450,10 +450,6 @@ pub fn process_deposit( // depositing validator already exists in the registry. state.update_pubkey_cache()?; - let pubkey: PublicKey = match deposit.data.pubkey.decompress() { - Err(_) => return Ok(()), //bad public key => return early - Ok(k) => k, - }; // Get an `Option` where `u64` is the validator index if this deposit public key // already exists in the beacon_state. let validator_index = get_existing_validator_index(state, &deposit.data.pubkey) @@ -473,7 +469,7 @@ pub fn process_deposit( // Create a new validator. let validator = Validator { - pubkey: pubkey.into(), + pubkey: deposit.data.pubkey.clone(), withdrawal_credentials: deposit.data.withdrawal_credentials, activation_eligibility_epoch: spec.far_future_epoch, activation_epoch: spec.far_future_epoch,