mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
Fix ef tests
This commit is contained in:
@@ -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<E: EthSpec>(
|
||||
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<E: EthSpec>(
|
||||
|
||||
// [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<E: EthSpec>(
|
||||
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<E: EthSpec>(
|
||||
|
||||
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<E: EthSpec>(
|
||||
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<E: EthSpec>(
|
||||
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()
|
||||
|
||||
@@ -168,7 +168,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
||||
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<E: EthSpec>(
|
||||
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<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Result<Self, Error> {
|
||||
fn new<E: EthSpec>(
|
||||
state: &BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
config: &SinglePassConfig,
|
||||
) -> Result<Self, Error> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -73,13 +73,14 @@ pub fn upgrade_to_electra<E: EthSpec>(
|
||||
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)?;
|
||||
|
||||
@@ -2152,7 +2152,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
pubkey: validator.pubkey,
|
||||
withdrawal_credentials: validator.withdrawal_credentials,
|
||||
amount: excess_balance,
|
||||
signature: Signature::infinity()?,
|
||||
signature: Signature::infinity()?.into(),
|
||||
slot: spec.genesis_slot,
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,17 @@ impl Validator {
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn get_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> Option<Address> {
|
||||
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!
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user