Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthouse into electra-engine-api

This commit is contained in:
realbigsean
2024-05-24 10:58:28 -04:00
110 changed files with 2290 additions and 1667 deletions

View File

@@ -5,6 +5,7 @@ use derivative::Derivative;
use serde::{Deserialize, Serialize};
use ssz::{Decode, DecodeError};
use ssz_derive::{Decode, Encode};
use std::fmt;
use std::marker::PhantomData;
use superstruct::superstruct;
use test_random_derive::TestRandom;
@@ -869,6 +870,23 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> ForkVersionDeserialize
))
}
}
pub enum BlockImportSource {
Gossip,
Lookup,
RangeSync,
HttpApi,
}
impl fmt::Display for BlockImportSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
BlockImportSource::Gossip => write!(f, "gossip"),
BlockImportSource::Lookup => write!(f, "lookup"),
BlockImportSource::RangeSync => write!(f, "range_sync"),
BlockImportSource::HttpApi => write!(f, "http_api"),
}
}
}
#[cfg(test)]
mod tests {

View File

@@ -115,6 +115,22 @@ impl<E: EthSpec> IndexedAttestation<E> {
IndexedAttestation::Electra(att) => att.attesting_indices.first(),
}
}
pub fn to_electra(self) -> Result<IndexedAttestationElectra<E>, ssz_types::Error> {
Ok(match self {
Self::Base(att) => {
let extended_attesting_indices: VariableList<u64, E::MaxValidatorsPerSlot> =
VariableList::new(att.attesting_indices.to_vec())?;
IndexedAttestationElectra {
attesting_indices: extended_attesting_indices,
data: att.data,
signature: att.signature,
}
}
Self::Electra(att) => att,
})
}
}
impl<'a, E: EthSpec> IndexedAttestationRef<'a, E> {

View File

@@ -130,7 +130,7 @@ pub use crate::attester_slashing::{
pub use crate::beacon_block::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBellatrix, BeaconBlockCapella,
BeaconBlockDeneb, BeaconBlockElectra, BeaconBlockRef, BeaconBlockRefMut, BlindedBeaconBlock,
EmptyBlock,
BlockImportSource, EmptyBlock,
};
pub use crate::beacon_block_body::{
BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyBellatrix,

View File

@@ -140,18 +140,6 @@ impl Validator {
is_compounding_withdrawal_credential(self.withdrawal_credentials, spec)
}
/// Get the eth1 withdrawal address if this validator has one initialized.
pub fn get_eth1_withdrawal_address(&self, spec: &ChainSpec) -> Option<Address> {
self.has_eth1_withdrawal_credential(spec)
.then(|| {
self.withdrawal_credentials
.as_bytes()
.get(12..)
.map(Address::from_slice)
})
.flatten()
}
/// Get the execution withdrawal address if this validator has one initialized.
pub fn get_execution_withdrawal_address(&self, spec: &ChainSpec) -> Option<Address> {
self.has_execution_withdrawal_credential(spec)