mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +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::per_block_processing::errors::{BlockProcessingError, IntoWithIndex};
|
||||||
use crate::VerifySignatures;
|
use crate::VerifySignatures;
|
||||||
use errors::DepositInvalid;
|
|
||||||
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
|
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
|
||||||
use types::typenum::U33;
|
use types::typenum::U33;
|
||||||
|
|
||||||
@@ -455,12 +454,7 @@ pub fn apply_deposit<E: EthSpec>(
|
|||||||
pubkey: deposit_data.pubkey,
|
pubkey: deposit_data.pubkey,
|
||||||
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
amount,
|
amount,
|
||||||
signature: deposit_data.signature.decompress().map_err(|_| {
|
signature: deposit_data.signature,
|
||||||
BlockProcessingError::DepositInvalid {
|
|
||||||
index: deposit_index,
|
|
||||||
reason: DepositInvalid::BadBlsBytes,
|
|
||||||
}
|
|
||||||
})?,
|
|
||||||
slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request
|
slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request
|
||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
@@ -478,6 +472,7 @@ pub fn apply_deposit<E: EthSpec>(
|
|||||||
|
|
||||||
// [Modified in Electra:EIP7251]
|
// [Modified in Electra:EIP7251]
|
||||||
if state.fork_name_unchecked() >= ForkName::Electra {
|
if state.fork_name_unchecked() >= ForkName::Electra {
|
||||||
|
let amount = 0;
|
||||||
// Create a new validator.
|
// Create a new validator.
|
||||||
let mut validator = Validator {
|
let mut validator = Validator {
|
||||||
pubkey: deposit_data.pubkey,
|
pubkey: deposit_data.pubkey,
|
||||||
@@ -535,12 +530,7 @@ pub fn apply_deposit<E: EthSpec>(
|
|||||||
pubkey: deposit_data.pubkey,
|
pubkey: deposit_data.pubkey,
|
||||||
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
withdrawal_credentials: deposit_data.withdrawal_credentials,
|
||||||
amount,
|
amount,
|
||||||
signature: deposit_data.signature.decompress().map_err(|_| {
|
signature: deposit_data.signature,
|
||||||
BlockProcessingError::DepositInvalid {
|
|
||||||
index: deposit_index,
|
|
||||||
reason: DepositInvalid::BadBlsBytes,
|
|
||||||
}
|
|
||||||
})?,
|
|
||||||
slot: spec.genesis_slot, // Use `genesis_slot` to distinguish from a pending deposit request
|
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)?;
|
let source_validator = state.get_validator(source_index)?;
|
||||||
// Verify the source withdrawal credentials
|
// 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 {
|
if withdrawal_address != consolidation_request.source_address {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -721,6 +711,7 @@ fn is_valid_switch_to_compounding_request<E: EthSpec>(
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
// Verify exits for source has not been initiated
|
// 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 {
|
if source_validator.exit_epoch != spec.far_future_epoch {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -733,6 +724,7 @@ pub fn process_consolidation_request<E: EthSpec>(
|
|||||||
consolidation_request: &ConsolidationRequest,
|
consolidation_request: &ConsolidationRequest,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<(), BlockProcessingError> {
|
) -> Result<(), BlockProcessingError> {
|
||||||
|
dbg!("here");
|
||||||
if is_valid_switch_to_compounding_request(state, consolidation_request, spec)? {
|
if is_valid_switch_to_compounding_request(state, consolidation_request, spec)? {
|
||||||
let Some(source_index) = state
|
let Some(source_index) = state
|
||||||
.pubkey_cache()
|
.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 mut next_epoch_cache = PreEpochCache::new_for_next_epoch(state)?;
|
||||||
|
|
||||||
let pending_deposits_ctxt = if fork_name.electra_enabled() && conf.pending_deposits {
|
let pending_deposits_ctxt = if fork_name.electra_enabled() && conf.pending_deposits {
|
||||||
Some(PendingDepositsContext::new(state, spec)?)
|
Some(PendingDepositsContext::new(state, spec, &conf)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@@ -367,7 +367,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
|||||||
pubkey: deposit.pubkey,
|
pubkey: deposit.pubkey,
|
||||||
withdrawal_credentials: deposit.withdrawal_credentials,
|
withdrawal_credentials: deposit.withdrawal_credentials,
|
||||||
amount: deposit.amount,
|
amount: deposit.amount,
|
||||||
signature: deposit.signature.into(),
|
signature: deposit.signature,
|
||||||
},
|
},
|
||||||
spec,
|
spec,
|
||||||
)
|
)
|
||||||
@@ -869,7 +869,11 @@ fn process_single_slashing(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PendingDepositsContext {
|
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
|
let available_for_processing = state
|
||||||
.deposit_balance_to_consume()?
|
.deposit_balance_to_consume()?
|
||||||
.safe_add(state.get_activation_exit_churn_limit(spec)?)?;
|
.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
|
// 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
|
// account for changes to the effective balance that would push it below the ejection
|
||||||
// balance here.
|
// balance here.
|
||||||
let will_be_exited = validator.is_active_at(current_epoch)
|
// Note: we only consider this if registry_updates are enabled in the config.
|
||||||
&& validator.effective_balance <= spec.ejection_balance;
|
// 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_exited = already_exited || will_be_exited;
|
||||||
is_validator_withdrawn = validator.withdrawable_epoch < next_epoch;
|
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;
|
validator.activation_eligibility_epoch = spec.far_future_epoch;
|
||||||
let pubkey = validator.pubkey;
|
let pubkey = validator.pubkey;
|
||||||
let withdrawal_credentials = validator.withdrawal_credentials;
|
let withdrawal_credentials = validator.withdrawal_credentials;
|
||||||
|
dbg!("is this getting hit");
|
||||||
|
|
||||||
post.pending_deposits_mut()?
|
post.pending_deposits_mut()?
|
||||||
.push(PendingDeposit {
|
.push(PendingDeposit {
|
||||||
pubkey,
|
pubkey,
|
||||||
withdrawal_credentials,
|
withdrawal_credentials,
|
||||||
amount: balance_copy,
|
amount: balance_copy,
|
||||||
signature: Signature::infinity()?,
|
signature: Signature::infinity()?.into(),
|
||||||
slot: spec.genesis_slot,
|
slot: spec.genesis_slot,
|
||||||
})
|
})
|
||||||
.map_err(Error::MilhouseError)?;
|
.map_err(Error::MilhouseError)?;
|
||||||
|
|||||||
@@ -2152,7 +2152,7 @@ impl<E: EthSpec> BeaconState<E> {
|
|||||||
pubkey: validator.pubkey,
|
pubkey: validator.pubkey,
|
||||||
withdrawal_credentials: validator.withdrawal_credentials,
|
withdrawal_credentials: validator.withdrawal_credentials,
|
||||||
amount: excess_balance,
|
amount: excess_balance,
|
||||||
signature: Signature::infinity()?,
|
signature: Signature::infinity()?.into(),
|
||||||
slot: spec.genesis_slot,
|
slot: spec.genesis_slot,
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use crate::test_utils::TestRandom;
|
use crate::test_utils::TestRandom;
|
||||||
use crate::{Hash256, PublicKeyBytes, Signature};
|
use crate::{Hash256, PublicKeyBytes};
|
||||||
|
use bls::SignatureBytes;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ssz::Encode;
|
use ssz::Encode;
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
@@ -10,7 +11,6 @@ use tree_hash_derive::TreeHash;
|
|||||||
arbitrary::Arbitrary,
|
arbitrary::Arbitrary,
|
||||||
Debug,
|
Debug,
|
||||||
PartialEq,
|
PartialEq,
|
||||||
Eq,
|
|
||||||
Hash,
|
Hash,
|
||||||
Clone,
|
Clone,
|
||||||
Serialize,
|
Serialize,
|
||||||
@@ -25,7 +25,7 @@ pub struct DepositRequest {
|
|||||||
pub withdrawal_credentials: Hash256,
|
pub withdrawal_credentials: Hash256,
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
#[serde(with = "serde_utils::quoted_u64")]
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
pub signature: Signature,
|
pub signature: SignatureBytes,
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
#[serde(with = "serde_utils::quoted_u64")]
|
||||||
pub index: u64,
|
pub index: u64,
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ impl DepositRequest {
|
|||||||
pubkey: PublicKeyBytes::empty(),
|
pubkey: PublicKeyBytes::empty(),
|
||||||
withdrawal_credentials: Hash256::ZERO,
|
withdrawal_credentials: Hash256::ZERO,
|
||||||
amount: 0,
|
amount: 0,
|
||||||
signature: Signature::empty(),
|
signature: SignatureBytes::empty(),
|
||||||
index: 0,
|
index: 0,
|
||||||
}
|
}
|
||||||
.as_ssz_bytes()
|
.as_ssz_bytes()
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use tree_hash_derive::TreeHash;
|
|||||||
arbitrary::Arbitrary,
|
arbitrary::Arbitrary,
|
||||||
Debug,
|
Debug,
|
||||||
PartialEq,
|
PartialEq,
|
||||||
Eq,
|
|
||||||
Hash,
|
Hash,
|
||||||
Clone,
|
Clone,
|
||||||
Serialize,
|
Serialize,
|
||||||
@@ -24,7 +23,7 @@ pub struct PendingDeposit {
|
|||||||
pub withdrawal_credentials: Hash256,
|
pub withdrawal_credentials: Hash256,
|
||||||
#[serde(with = "serde_utils::quoted_u64")]
|
#[serde(with = "serde_utils::quoted_u64")]
|
||||||
pub amount: u64,
|
pub amount: u64,
|
||||||
pub signature: Signature,
|
pub signature: SignatureBytes,
|
||||||
pub slot: Slot,
|
pub slot: Slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,17 @@ impl Validator {
|
|||||||
.flatten()
|
.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.
|
/// Changes withdrawal credentials to the provided eth1 execution address.
|
||||||
///
|
///
|
||||||
/// WARNING: this function does NO VALIDATION - it just does it!
|
/// 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
|
TESTS = general minimal mainnet
|
||||||
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))
|
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user