mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 14:24:44 +00:00
Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra-engine-api
This commit is contained in:
@@ -4,7 +4,6 @@ use super::signature_sets::{Error as SignatureSetError, *};
|
||||
use crate::per_block_processing::errors::{AttestationInvalid, BlockOperationError};
|
||||
use crate::{ConsensusContext, ContextError};
|
||||
use bls::{verify_signature_sets, PublicKey, PublicKeyBytes, SignatureSet};
|
||||
use rayon::prelude::*;
|
||||
use std::borrow::Cow;
|
||||
use types::{
|
||||
AbstractExecPayload, BeaconState, BeaconStateError, ChainSpec, EthSpec, Hash256,
|
||||
@@ -411,15 +410,10 @@ impl<'a> ParallelSignatureSets<'a> {
|
||||
/// It is not possible to know exactly _which_ signature is invalid here, just that
|
||||
/// _at least one_ was invalid.
|
||||
///
|
||||
/// Uses `rayon` to do a map-reduce of Vitalik's method across multiple cores.
|
||||
/// Blst library spreads the signature verification work across multiple available cores, so
|
||||
/// this function is already parallelized.
|
||||
#[must_use]
|
||||
pub fn verify(self) -> bool {
|
||||
let num_sets = self.sets.len();
|
||||
let num_chunks = std::cmp::max(1, num_sets / rayon::current_num_threads());
|
||||
self.sets
|
||||
.into_par_iter()
|
||||
.chunks(num_chunks)
|
||||
.map(|chunk| verify_signature_sets(chunk.iter()))
|
||||
.reduce(|| true, |current, this| current && this)
|
||||
verify_signature_sets(self.sets.iter())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn process_operations<E: EthSpec, Payload: AbstractExecPayload<E>>(
|
||||
process_bls_to_execution_changes(state, bls_to_execution_changes, verify_signatures, spec)?;
|
||||
}
|
||||
|
||||
if state.fork_name_unchecked() >= ForkName::Electra {
|
||||
if state.fork_name_unchecked().electra_enabled() {
|
||||
let requests = block_body.execution_payload()?.withdrawal_requests()?;
|
||||
if let Some(requests) = requests {
|
||||
process_execution_layer_withdrawal_requests(state, &requests, spec)?;
|
||||
|
||||
@@ -161,7 +161,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
||||
let mut next_epoch_cache = PreEpochCache::new_for_next_epoch(state)?;
|
||||
|
||||
let pending_balance_deposits_ctxt =
|
||||
if fork_name >= ForkName::Electra && conf.pending_balance_deposits {
|
||||
if fork_name.electra_enabled() && conf.pending_balance_deposits {
|
||||
Some(PendingBalanceDepositsContext::new(state, spec)?)
|
||||
} else {
|
||||
None
|
||||
@@ -197,7 +197,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
||||
// Compute shared values required for different parts of epoch processing.
|
||||
let rewards_ctxt = &RewardsAndPenaltiesContext::new(progressive_balances, state_ctxt, spec)?;
|
||||
|
||||
let mut activation_queues = if fork_name < ForkName::Electra {
|
||||
let mut activation_queues = if !fork_name.electra_enabled() {
|
||||
let activation_queue = epoch_cache
|
||||
.activation_queue()?
|
||||
.get_validators_eligible_for_activation(
|
||||
@@ -325,7 +325,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
||||
}
|
||||
}
|
||||
|
||||
if conf.registry_updates && fork_name >= ForkName::Electra {
|
||||
if conf.registry_updates && fork_name.electra_enabled() {
|
||||
if let Ok(earliest_exit_epoch_state) = state.earliest_exit_epoch_mut() {
|
||||
*earliest_exit_epoch_state =
|
||||
earliest_exit_epoch.ok_or(Error::MissingEarliestExitEpoch)?;
|
||||
@@ -354,7 +354,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
|
||||
|
||||
// Process consolidations outside the single-pass loop, as they depend on balances for multiple
|
||||
// validators and cannot be computed accurately inside the loop.
|
||||
if fork_name >= ForkName::Electra && conf.pending_consolidations {
|
||||
if fork_name.electra_enabled() && conf.pending_consolidations {
|
||||
process_pending_consolidations(
|
||||
state,
|
||||
&mut next_epoch_cache,
|
||||
@@ -554,7 +554,7 @@ fn process_single_registry_update(
|
||||
exit_balance_to_consume: Option<&mut u64>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
if state_ctxt.fork_name < ForkName::Electra {
|
||||
if !state_ctxt.fork_name.electra_enabled() {
|
||||
let (activation_queue, next_epoch_activation_queue) =
|
||||
activation_queues.ok_or(Error::SinglePassMissingActivationQueue)?;
|
||||
process_single_registry_update_pre_electra(
|
||||
@@ -664,7 +664,7 @@ fn initiate_validator_exit(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let exit_queue_epoch = if state_ctxt.fork_name >= ForkName::Electra {
|
||||
let exit_queue_epoch = if state_ctxt.fork_name.electra_enabled() {
|
||||
compute_exit_epoch_and_update_churn(
|
||||
validator,
|
||||
state_ctxt,
|
||||
|
||||
Reference in New Issue
Block a user