diff --git a/consensus/state_processing/src/per_block_processing/process_operations.rs b/consensus/state_processing/src/per_block_processing/process_operations.rs index 8589287dbf..50cf1b8151 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -5,7 +5,6 @@ use crate::common::{ }; use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex}; use crate::VerifySignatures; -use errors::DepositInvalid; use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR}; use types::typenum::U33; @@ -455,12 +454,7 @@ pub fn apply_deposit( pubkey: deposit_data.pubkey, withdrawal_credentials: deposit_data.withdrawal_credentials, amount, - signature: deposit_data.signature.decompress().map_err(|_| { - BlockProcessingError::DepositInvalid { - index: deposit_index, - reason: DepositInvalid::BadBlsBytes, - } - })?, + signature: deposit_data.signature, slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request })?; } else { @@ -478,6 +472,7 @@ pub fn apply_deposit( // [Modified in Electra:EIP7251] if state.fork_name_unchecked() >= ForkName::Electra { + let amount = 0; // Create a new validator. let mut validator = Validator { pubkey: deposit_data.pubkey, @@ -535,12 +530,7 @@ pub fn apply_deposit( pubkey: deposit_data.pubkey, withdrawal_credentials: deposit_data.withdrawal_credentials, amount, - signature: deposit_data.signature.decompress().map_err(|_| { - BlockProcessingError::DepositInvalid { - index: deposit_index, - reason: DepositInvalid::BadBlsBytes, - } - })?, + signature: deposit_data.signature, slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request })?; } @@ -706,7 +696,7 @@ fn is_valid_switch_to_compounding_request( let source_validator = state.get_validator(source_index)?; // Verify the source withdrawal credentials - if let Some(withdrawal_address) = source_validator.get_execution_withdrawal_address(spec) { + if let Some(withdrawal_address) = source_validator.get_eth1_withdrawal_credential(spec) { if withdrawal_address != consolidation_request.source_address { return Ok(false); } @@ -721,6 +711,7 @@ fn is_valid_switch_to_compounding_request( return Ok(false); } // Verify exits for source has not been initiated + // TODO(pawan): this could be set by process_registry_updates too if source_validator.exit_epoch != spec.far_future_epoch { return Ok(false); } @@ -733,6 +724,7 @@ pub fn process_consolidation_request( consolidation_request: &ConsolidationRequest, spec: &ChainSpec, ) -> Result<(), BlockProcessingError> { + dbg!("here"); if is_valid_switch_to_compounding_request(state, consolidation_request, spec)? { let Some(source_index) = state .pubkey_cache() diff --git a/consensus/state_processing/src/per_epoch_processing/single_pass.rs b/consensus/state_processing/src/per_epoch_processing/single_pass.rs index 6de4b9936e..e49b98700f 100644 --- a/consensus/state_processing/src/per_epoch_processing/single_pass.rs +++ b/consensus/state_processing/src/per_epoch_processing/single_pass.rs @@ -168,7 +168,7 @@ pub fn process_epoch_single_pass( let mut next_epoch_cache = PreEpochCache::new_for_next_epoch(state)?; let pending_deposits_ctxt = if fork_name.electra_enabled() && conf.pending_deposits { - Some(PendingDepositsContext::new(state, spec)?) + Some(PendingDepositsContext::new(state, spec, &conf)?) } else { None }; @@ -367,7 +367,7 @@ pub fn process_epoch_single_pass( pubkey: deposit.pubkey, withdrawal_credentials: deposit.withdrawal_credentials, amount: deposit.amount, - signature: deposit.signature.into(), + signature: deposit.signature, }, spec, ) @@ -869,7 +869,11 @@ fn process_single_slashing( } impl PendingDepositsContext { - fn new(state: &BeaconState, spec: &ChainSpec) -> Result { + fn new( + state: &BeaconState, + spec: &ChainSpec, + config: &SinglePassConfig, + ) -> Result { let available_for_processing = state .deposit_balance_to_consume()? .safe_add(state.get_activation_exit_churn_limit(spec)?)?; @@ -925,8 +929,11 @@ impl PendingDepositsContext { // balance update does not happen until *after* the registry update, so we don't need to // account for changes to the effective balance that would push it below the ejection // balance here. - let will_be_exited = validator.is_active_at(current_epoch) - && validator.effective_balance <= spec.ejection_balance; + // Note: we only consider this if registry_updates are enabled in the config. + // EF tests require us to run epoch_processing functions in isolation. + let will_be_exited = config.registry_updates + && (validator.is_active_at(current_epoch) + && validator.effective_balance <= spec.ejection_balance); is_validator_exited = already_exited || will_be_exited; is_validator_withdrawn = validator.withdrawable_epoch < next_epoch; } diff --git a/consensus/state_processing/src/upgrade/electra.rs b/consensus/state_processing/src/upgrade/electra.rs index 270e943bd3..7287bbff08 100644 --- a/consensus/state_processing/src/upgrade/electra.rs +++ b/consensus/state_processing/src/upgrade/electra.rs @@ -73,13 +73,14 @@ pub fn upgrade_to_electra( validator.activation_eligibility_epoch = spec.far_future_epoch; let pubkey = validator.pubkey; let withdrawal_credentials = validator.withdrawal_credentials; + dbg!("is this getting hit"); post.pending_deposits_mut()? .push(PendingDeposit { pubkey, withdrawal_credentials, amount: balance_copy, - signature: Signature::infinity()?, + signature: Signature::infinity()?.into(), slot: spec.genesis_slot, }) .map_err(Error::MilhouseError)?; diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index c04bc6326c..38bbf0feee 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -2152,7 +2152,7 @@ impl BeaconState { pubkey: validator.pubkey, withdrawal_credentials: validator.withdrawal_credentials, amount: excess_balance, - signature: Signature::infinity()?, + signature: Signature::infinity()?.into(), slot: spec.genesis_slot, })?; } diff --git a/consensus/types/src/deposit_request.rs b/consensus/types/src/deposit_request.rs index 7af949fef3..a21760551b 100644 --- a/consensus/types/src/deposit_request.rs +++ b/consensus/types/src/deposit_request.rs @@ -1,5 +1,6 @@ use crate::test_utils::TestRandom; -use crate::{Hash256, PublicKeyBytes, Signature}; +use crate::{Hash256, PublicKeyBytes}; +use bls::SignatureBytes; use serde::{Deserialize, Serialize}; use ssz::Encode; use ssz_derive::{Decode, Encode}; @@ -10,7 +11,6 @@ use tree_hash_derive::TreeHash; arbitrary::Arbitrary, Debug, PartialEq, - Eq, Hash, Clone, Serialize, @@ -25,7 +25,7 @@ pub struct DepositRequest { pub withdrawal_credentials: Hash256, #[serde(with = "serde_utils::quoted_u64")] pub amount: u64, - pub signature: Signature, + pub signature: SignatureBytes, #[serde(with = "serde_utils::quoted_u64")] pub index: u64, } @@ -36,7 +36,7 @@ impl DepositRequest { pubkey: PublicKeyBytes::empty(), withdrawal_credentials: Hash256::ZERO, amount: 0, - signature: Signature::empty(), + signature: SignatureBytes::empty(), index: 0, } .as_ssz_bytes() diff --git a/consensus/types/src/pending_deposit.rs b/consensus/types/src/pending_deposit.rs index 9ee920f1d9..3bee86417d 100644 --- a/consensus/types/src/pending_deposit.rs +++ b/consensus/types/src/pending_deposit.rs @@ -9,7 +9,6 @@ use tree_hash_derive::TreeHash; arbitrary::Arbitrary, Debug, PartialEq, - Eq, Hash, Clone, Serialize, @@ -24,7 +23,7 @@ pub struct PendingDeposit { pub withdrawal_credentials: Hash256, #[serde(with = "serde_utils::quoted_u64")] pub amount: u64, - pub signature: Signature, + pub signature: SignatureBytes, pub slot: Slot, } diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index e94f4b4a0a..941c420b55 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -152,6 +152,17 @@ impl Validator { .flatten() } + pub fn get_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> Option
{ + self.has_eth1_withdrawal_credential(spec) + .then(|| { + self.withdrawal_credentials + .as_slice() + .get(12..) + .map(Address::from_slice) + }) + .flatten() + } + /// Changes withdrawal credentials to the provided eth1 execution address. /// /// WARNING: this function does NO VALIDATION - it just does it! diff --git a/testing/ef_tests/Makefile b/testing/ef_tests/Makefile index b0f97292a0..d5f4997bb7 100644 --- a/testing/ef_tests/Makefile +++ b/testing/ef_tests/Makefile @@ -1,4 +1,4 @@ -TESTS_TAG := v1.5.0-alpha.7 +TESTS_TAG := v1.5.0-alpha.8 TESTS = general minimal mainnet TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))