Add {fork_name}_enabled functions (#5951)

* add fork_name_enabled fn to Forkname impl

* refactor codebase to use new fork_enabled fn

* fmt

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into fork-ord-impl

* small code cleanup

* resolve merge conflicts

* fix beacon chain test

* merge conflicts

* fix ef test issue

* resolve merge conflicts
This commit is contained in:
Eitan Seri-Levi
2024-10-02 19:00:52 -07:00
committed by GitHub
parent dd08ebb2b0
commit 82faf975b3
22 changed files with 223 additions and 251 deletions

View File

@@ -1144,13 +1144,14 @@ pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(
let current_fork =
spec.fork_name_at_slot::<E>(slot_clock.now().ok_or(BeaconChainError::UnableToReadSlot)?);
let earliest_permissible_slot = if !current_fork.deneb_enabled() {
one_epoch_prior
// EIP-7045
} else {
let earliest_permissible_slot = if current_fork.deneb_enabled() {
// EIP-7045
one_epoch_prior
.epoch(E::slots_per_epoch())
.start_slot(E::slots_per_epoch())
} else {
one_epoch_prior
};
if attestation_slot < earliest_permissible_slot {

View File

@@ -2619,11 +2619,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// Check if the current slot is greater than or equal to the Capella fork epoch.
pub fn current_slot_is_post_capella(&self) -> Result<bool, Error> {
let current_fork = self.spec.fork_name_at_slot::<T::EthSpec>(self.slot()?);
if let ForkName::Base | ForkName::Altair | ForkName::Bellatrix = current_fork {
Ok(false)
} else {
Ok(true)
}
Ok(current_fork.capella_enabled())
}
/// Import a BLS to execution change to the op pool.
@@ -5945,26 +5941,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
payload_attributes
} else {
let prepare_slot_fork = self.spec.fork_name_at_slot::<T::EthSpec>(prepare_slot);
let withdrawals = match prepare_slot_fork {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix => None,
ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
let chain = self.clone();
self.spawn_blocking_handle(
move || {
chain.get_expected_withdrawals(&forkchoice_update_params, prepare_slot)
},
"prepare_beacon_proposer_withdrawals",
)
.await?
.map(Some)?
}
let withdrawals = if prepare_slot_fork.capella_enabled() {
let chain = self.clone();
self.spawn_blocking_handle(
move || chain.get_expected_withdrawals(&forkchoice_update_params, prepare_slot),
"prepare_beacon_proposer_withdrawals",
)
.await?
.map(Some)?
} else {
None
};
let parent_beacon_block_root = match prepare_slot_fork {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => None,
ForkName::Deneb | ForkName::Electra => {
Some(pre_payload_attributes.parent_beacon_block_root)
}
let parent_beacon_block_root = if prepare_slot_fork.deneb_enabled() {
Some(pre_payload_attributes.parent_beacon_block_root)
} else {
None
};
let payload_attributes = PayloadAttributes::new(
@@ -6110,27 +6103,27 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// `execution_engine_forkchoice_lock` apart from the one here.
let forkchoice_lock = execution_layer.execution_engine_forkchoice_lock().await;
let (head_block_root, head_hash, justified_hash, finalized_hash) = if let Some(head_hash) =
params.head_hash
{
(
params.head_root,
head_hash,
params
.justified_hash
.unwrap_or_else(ExecutionBlockHash::zero),
params
.finalized_hash
.unwrap_or_else(ExecutionBlockHash::zero),
)
} else {
// The head block does not have an execution block hash. We must check to see if we
// happen to be the proposer of the transition block, in which case we still need to
// send forkchoice_updated.
match self.spec.fork_name_at_slot::<T::EthSpec>(next_slot) {
// We are pre-bellatrix; no need to update the EL.
ForkName::Base | ForkName::Altair => return Ok(()),
_ => {
let (head_block_root, head_hash, justified_hash, finalized_hash) =
if let Some(head_hash) = params.head_hash {
(
params.head_root,
head_hash,
params
.justified_hash
.unwrap_or_else(ExecutionBlockHash::zero),
params
.finalized_hash
.unwrap_or_else(ExecutionBlockHash::zero),
)
} else {
// The head block does not have an execution block hash. We must check to see if we
// happen to be the proposer of the transition block, in which case we still need to
// send forkchoice_updated.
if self
.spec
.fork_name_at_slot::<T::EthSpec>(next_slot)
.bellatrix_enabled()
{
// We are post-bellatrix
if let Some(payload_attributes) = execution_layer
.payload_attributes(next_slot, params.head_root)
@@ -6164,9 +6157,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// We are not a proposer, no need to update the EL.
return Ok(());
}
} else {
return Ok(());
}
}
};
};
let forkchoice_updated_response = execution_layer
.notify_forkchoice_updated(
@@ -7009,7 +7003,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.finalized_checkpoint()
.epoch
.sync_committee_period(&self.spec)?;
self.light_client_server_cache.get_light_client_bootstrap(
&self.store,
block_root,

View File

@@ -359,22 +359,24 @@ impl GossipTester {
}
pub fn earliest_valid_attestation_slot(&self) -> Slot {
let offset = match self.harness.spec.fork_name_at_epoch(self.epoch()) {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
// Subtract an additional slot since the harness will be exactly on the start of the
// slot and the propagation tolerance will allow an extra slot.
E::slots_per_epoch() + 1
}
let offset = if self
.harness
.spec
.fork_name_at_epoch(self.epoch())
.deneb_enabled()
{
// EIP-7045
ForkName::Deneb | ForkName::Electra => {
let epoch_slot_offset = (self.slot() % E::slots_per_epoch()).as_u64();
if epoch_slot_offset != 0 {
E::slots_per_epoch() + epoch_slot_offset
} else {
// Here the propagation tolerance will cause the cutoff to be an entire epoch earlier
2 * E::slots_per_epoch()
}
let epoch_slot_offset = (self.slot() % E::slots_per_epoch()).as_u64();
if epoch_slot_offset != 0 {
E::slots_per_epoch() + epoch_slot_offset
} else {
// Here the propagation tolerance will cause the cutoff to be an entire epoch earlier
2 * E::slots_per_epoch()
}
} else {
// Subtract an additional slot since the harness will be exactly on the start of the
// slot and the propagation tolerance will allow an extra slot.
E::slots_per_epoch() + 1
};
self.slot()

View File

@@ -436,7 +436,7 @@ async fn capella_readiness_logging<T: BeaconChainTypes>(
.snapshot
.beacon_state
.fork_name_unchecked()
>= ForkName::Capella;
.capella_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();
@@ -496,7 +496,7 @@ async fn deneb_readiness_logging<T: BeaconChainTypes>(
.snapshot
.beacon_state
.fork_name_unchecked()
>= ForkName::Deneb;
.deneb_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();

View File

@@ -661,21 +661,18 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
},
};
match execution_payload.fork_name() {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {}
ForkName::Deneb | ForkName::Electra => {
// get random number between 0 and Max Blobs
let mut rng = self.rng.lock();
let num_blobs = rng.gen::<usize>() % (E::max_blobs_per_block() + 1);
let (bundle, transactions) = generate_blobs(num_blobs)?;
for tx in Vec::from(transactions) {
execution_payload
.transactions_mut()
.push(tx)
.map_err(|_| "transactions are full".to_string())?;
}
self.blobs_bundles.insert(id, bundle);
if execution_payload.fork_name().deneb_enabled() {
// get random number between 0 and Max Blobs
let mut rng = self.rng.lock();
let num_blobs = rng.gen::<usize>() % (E::max_blobs_per_block() + 1);
let (bundle, transactions) = generate_blobs(num_blobs)?;
for tx in Vec::from(transactions) {
execution_payload
.transactions_mut()
.push(tx)
.map_err(|_| "transactions are full".to_string())?;
}
self.blobs_bundles.insert(id, bundle);
}
*execution_payload.block_hash_mut() =

View File

@@ -479,16 +479,18 @@ pub fn serve<E: EthSpec>(
let prev_randao = head_state
.get_randao_mix(head_state.current_epoch())
.map_err(|_| reject("couldn't get prev randao"))?;
let expected_withdrawals = match fork {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix => None,
ForkName::Capella | ForkName::Deneb | ForkName::Electra => Some(
let expected_withdrawals = if fork.capella_enabled() {
Some(
builder
.beacon_client
.get_expected_withdrawals(&StateId::Head)
.await
.unwrap()
.data,
),
)
} else {
None
};
let payload_attributes = match fork {

View File

@@ -11,11 +11,9 @@ pub fn build_block_contents<E: EthSpec>(
BeaconBlockResponseWrapper::Blinded(block) => {
Ok(ProduceBlockV3Response::Blinded(block.block))
}
BeaconBlockResponseWrapper::Full(block) => match fork_name {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => Ok(
ProduceBlockV3Response::Full(FullBlockContents::Block(block.block)),
),
ForkName::Deneb | ForkName::Electra => {
BeaconBlockResponseWrapper::Full(block) => {
if fork_name.deneb_enabled() {
let BeaconBlockResponse {
block,
state: _,
@@ -37,7 +35,11 @@ pub fn build_block_contents<E: EthSpec>(
blobs,
}),
))
} else {
Ok(ProduceBlockV3Response::Full(FullBlockContents::Block(
block.block,
)))
}
},
}
}
}

View File

@@ -4,7 +4,7 @@ use safe_arith::SafeArith;
use state_processing::per_block_processing::get_expected_withdrawals;
use state_processing::state_advance::partial_state_advance;
use std::sync::Arc;
use types::{BeaconState, EthSpec, ForkName, Slot, Withdrawals};
use types::{BeaconState, EthSpec, Slot, Withdrawals};
const MAX_EPOCH_LOOKAHEAD: u64 = 2;
@@ -53,7 +53,8 @@ fn get_next_withdrawals_sanity_checks<T: BeaconChainTypes>(
}
let fork = chain.spec.fork_name_at_slot::<T::EthSpec>(proposal_slot);
if let ForkName::Base | ForkName::Altair | ForkName::Bellatrix = fork {
if !fork.capella_enabled() {
return Err(warp_utils::reject::custom_bad_request(
"the specified state is a pre-capella state.".to_string(),
));

View File

@@ -440,28 +440,22 @@ pub fn gossipsub_config(
fork_context: Arc<ForkContext>,
) -> Vec<u8> {
let topic_bytes = message.topic.as_str().as_bytes();
match fork_context.current_fork() {
ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella
| ForkName::Deneb
| ForkName::Electra => {
let topic_len_bytes = topic_bytes.len().to_le_bytes();
let mut vec = Vec::with_capacity(
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),
);
vec.extend_from_slice(&prefix);
vec.extend_from_slice(&topic_len_bytes);
vec.extend_from_slice(topic_bytes);
vec.extend_from_slice(&message.data);
vec
}
ForkName::Base => {
let mut vec = Vec::with_capacity(prefix.len() + message.data.len());
vec.extend_from_slice(&prefix);
vec.extend_from_slice(&message.data);
vec
}
if fork_context.current_fork().altair_enabled() {
let topic_len_bytes = topic_bytes.len().to_le_bytes();
let mut vec = Vec::with_capacity(
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),
);
vec.extend_from_slice(&prefix);
vec.extend_from_slice(&topic_len_bytes);
vec.extend_from_slice(topic_bytes);
vec.extend_from_slice(&message.data);
vec
} else {
let mut vec = Vec::with_capacity(prefix.len() + message.data.len());
vec.extend_from_slice(&prefix);
vec.extend_from_slice(&message.data);
vec
}
}
let message_domain_valid_snappy = gossipsub_config_params.message_domain_valid_snappy;

View File

@@ -151,12 +151,10 @@ const REQUEST_TIMEOUT: u64 = 15;
/// Returns the maximum bytes that can be sent across the RPC.
pub fn max_rpc_size(fork_context: &ForkContext, max_chunk_size: usize) -> usize {
match fork_context.current_fork() {
ForkName::Altair | ForkName::Base => max_chunk_size / 10,
ForkName::Bellatrix => max_chunk_size,
ForkName::Capella => max_chunk_size,
ForkName::Deneb => max_chunk_size,
ForkName::Electra => max_chunk_size,
if fork_context.current_fork().bellatrix_enabled() {
max_chunk_size
} else {
max_chunk_size / 10
}
}

View File

@@ -252,28 +252,25 @@ impl<E: EthSpec> PubsubMessage<E> {
Ok(PubsubMessage::BeaconBlock(Arc::new(beacon_block)))
}
GossipKind::BlobSidecar(blob_index) => {
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
Some(ForkName::Deneb | ForkName::Electra) => {
if let Some(fork_name) =
fork_context.from_context_bytes(gossip_topic.fork_digest)
{
if fork_name.deneb_enabled() {
let blob_sidecar = Arc::new(
BlobSidecar::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
);
Ok(PubsubMessage::BlobSidecar(Box::new((
return Ok(PubsubMessage::BlobSidecar(Box::new((
*blob_index,
blob_sidecar,
))))
))));
}
Some(
ForkName::Base
| ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella,
)
| None => Err(format!(
"beacon_blobs_and_sidecar topic invalid for given fork digest {:?}",
gossip_topic.fork_digest
)),
}
Err(format!(
"beacon_blobs_and_sidecar topic invalid for given fork digest {:?}",
gossip_topic.fork_digest
))
}
GossipKind::DataColumnSidecar(subnet_id) => {
match fork_context.from_context_bytes(gossip_topic.fork_digest) {

View File

@@ -16,7 +16,7 @@ use std::collections::{hash_map::Entry, HashMap};
use std::sync::Arc;
use tokio_stream::StreamExt;
use types::blob_sidecar::BlobIdentifier;
use types::{Epoch, EthSpec, FixedBytesExtended, ForkName, Hash256, Slot};
use types::{Epoch, EthSpec, FixedBytesExtended, Hash256, Slot};
impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
/* Auxiliary functions */
@@ -564,14 +564,10 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self.chain
.epoch()
.map_or(self.chain.spec.max_request_blocks, |epoch| {
match self.chain.spec.fork_name_at_epoch(epoch) {
ForkName::Deneb | ForkName::Electra => {
self.chain.spec.max_request_blocks_deneb
}
ForkName::Base
| ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella => self.chain.spec.max_request_blocks,
if self.chain.spec.fork_name_at_epoch(epoch).deneb_enabled() {
self.chain.spec.max_request_blocks_deneb
} else {
self.chain.spec.max_request_blocks
}
});
if *req.count() > max_request_size {

View File

@@ -537,21 +537,20 @@ mod tests {
} else {
panic!("Should have sent a batch request to the peer")
};
let blob_req_id = match fork_name {
ForkName::Deneb | ForkName::Electra => {
if let Ok(NetworkMessage::SendRequest {
peer_id,
request: _,
request_id,
}) = self.network_rx.try_recv()
{
assert_eq!(&peer_id, expected_peer);
Some(request_id)
} else {
panic!("Should have sent a batch request to the peer")
}
let blob_req_id = if fork_name.deneb_enabled() {
if let Ok(NetworkMessage::SendRequest {
peer_id,
request: _,
request_id,
}) = self.network_rx.try_recv()
{
assert_eq!(&peer_id, expected_peer);
Some(request_id)
} else {
panic!("Should have sent a batch request to the peer")
}
_ => None,
} else {
None
};
(block_req_id, blob_req_id)
}

View File

@@ -1678,27 +1678,23 @@ impl<E: EthSpec> FullBlockContents<E> {
bytes: &[u8],
fork_name: ForkName,
) -> Result<Self, ssz::DecodeError> {
match fork_name {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
BeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
.map(|block| FullBlockContents::Block(block))
}
ForkName::Deneb | ForkName::Electra => {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
if fork_name.deneb_enabled() {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
let mut decoder = builder.build()?;
let block = decoder.decode_next_with(|bytes| {
BeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
})?;
let kzg_proofs = decoder.decode_next()?;
let blobs = decoder.decode_next()?;
let mut decoder = builder.build()?;
let block = decoder
.decode_next_with(|bytes| BeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name))?;
let kzg_proofs = decoder.decode_next()?;
let blobs = decoder.decode_next()?;
Ok(FullBlockContents::new(block, Some((kzg_proofs, blobs))))
}
Ok(FullBlockContents::new(block, Some((kzg_proofs, blobs))))
} else {
BeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
.map(|block| FullBlockContents::Block(block))
}
}
@@ -1738,15 +1734,14 @@ impl<E: EthSpec> ForkVersionDeserialize for FullBlockContents<E> {
value: serde_json::value::Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
match fork_name {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
Ok(FullBlockContents::Block(
BeaconBlock::deserialize_by_fork::<'de, D>(value, fork_name)?,
))
}
ForkName::Deneb | ForkName::Electra => Ok(FullBlockContents::BlockContents(
if fork_name.deneb_enabled() {
Ok(FullBlockContents::BlockContents(
BlockContents::deserialize_by_fork::<'de, D>(value, fork_name)?,
)),
))
} else {
Ok(FullBlockContents::Block(
BeaconBlock::deserialize_by_fork::<'de, D>(value, fork_name)?,
))
}
}
}
@@ -1838,28 +1833,25 @@ impl<E: EthSpec> PublishBlockRequest<E> {
/// SSZ decode with fork variant determined by `fork_name`.
pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result<Self, ssz::DecodeError> {
match fork_name {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
SignedBeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
.map(|block| PublishBlockRequest::Block(Arc::new(block)))
}
ForkName::Deneb | ForkName::Electra => {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
if fork_name.deneb_enabled() {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
let mut decoder = builder.build()?;
let block = decoder.decode_next_with(|bytes| {
SignedBeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
})?;
let kzg_proofs = decoder.decode_next()?;
let blobs = decoder.decode_next()?;
Ok(PublishBlockRequest::new(
Arc::new(block),
Some((kzg_proofs, blobs)),
))
}
let mut decoder = builder.build()?;
let block = decoder.decode_next_with(|bytes| {
SignedBeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
})?;
let kzg_proofs = decoder.decode_next()?;
let blobs = decoder.decode_next()?;
Ok(PublishBlockRequest::new(
Arc::new(block),
Some((kzg_proofs, blobs)),
))
} else {
SignedBeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
.map(|block| PublishBlockRequest::Block(Arc::new(block)))
}
}

View File

@@ -196,13 +196,14 @@ impl<E: EthSpec> ForkVersionDeserialize for LightClientBootstrap<E> {
value: Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
match fork_name {
ForkName::Base => Err(serde::de::Error::custom(format!(
if fork_name.altair_enabled() {
Ok(serde_json::from_value::<LightClientBootstrap<E>>(value)
.map_err(serde::de::Error::custom))?
} else {
Err(serde::de::Error::custom(format!(
"LightClientBootstrap failed to deserialize: unsupported fork '{}'",
fork_name
))),
_ => Ok(serde_json::from_value::<LightClientBootstrap<E>>(value)
.map_err(serde::de::Error::custom))?,
)))
}
}
}

View File

@@ -212,15 +212,14 @@ impl<E: EthSpec> ForkVersionDeserialize for LightClientFinalityUpdate<E> {
value: Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
match fork_name {
ForkName::Base => Err(serde::de::Error::custom(format!(
if fork_name.altair_enabled() {
serde_json::from_value::<LightClientFinalityUpdate<E>>(value)
.map_err(serde::de::Error::custom)
} else {
Err(serde::de::Error::custom(format!(
"LightClientFinalityUpdate failed to deserialize: unsupported fork '{}'",
fork_name
))),
_ => Ok(
serde_json::from_value::<LightClientFinalityUpdate<E>>(value)
.map_err(serde::de::Error::custom),
)?,
)))
}
}
}

View File

@@ -129,11 +129,10 @@ impl<E: EthSpec> LightClientHeader<E> {
}
pub fn ssz_max_var_len_for_fork(fork_name: ForkName) -> usize {
match fork_name {
ForkName::Base | ForkName::Altair => 0,
ForkName::Bellatrix | ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
ExecutionPayloadHeader::<E>::ssz_max_var_len_for_fork(fork_name)
}
if fork_name.capella_enabled() {
ExecutionPayloadHeader::<E>::ssz_max_var_len_for_fork(fork_name)
} else {
0
}
}
}

View File

@@ -198,15 +198,16 @@ impl<E: EthSpec> ForkVersionDeserialize for LightClientOptimisticUpdate<E> {
value: Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
match fork_name {
ForkName::Base => Err(serde::de::Error::custom(format!(
"LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'",
fork_name
))),
_ => Ok(
if fork_name.altair_enabled() {
Ok(
serde_json::from_value::<LightClientOptimisticUpdate<E>>(value)
.map_err(serde::de::Error::custom),
)?,
)?
} else {
Err(serde::de::Error::custom(format!(
"LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'",
fork_name
)))
}
}
}

View File

@@ -41,12 +41,11 @@ impl VoluntaryExit {
spec: &ChainSpec,
) -> SignedVoluntaryExit {
let fork_name = spec.fork_name_at_epoch(self.epoch);
let fork_version = match fork_name {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
spec.fork_version_for_name(fork_name)
}
let fork_version = if fork_name.deneb_enabled() {
// EIP-7044
ForkName::Deneb | ForkName::Electra => spec.fork_version_for_name(ForkName::Capella),
spec.fork_version_for_name(ForkName::Capella)
} else {
spec.fork_version_for_name(fork_name)
};
let domain =
spec.compute_domain(Domain::VoluntaryExit, fork_version, genesis_validators_root);

View File

@@ -270,7 +270,7 @@ impl<E: EthSpec> Operation<E> for SyncAggregate<E> {
}
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name != ForkName::Base
fork_name.altair_enabled()
}
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {

View File

@@ -967,8 +967,8 @@ impl<E: EthSpec + TypeName> Handler for KzgInclusionMerkleProofValidityHandler<E
}
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
// Enabled in Deneb
fork_name == ForkName::Deneb
// TODO(electra) re-enable for electra once merkle proof issues for electra are resolved
fork_name.deneb_enabled() && !fork_name.electra_enabled()
}
}
@@ -994,7 +994,7 @@ impl<E: EthSpec + TypeName> Handler for LightClientUpdateHandler<E> {
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
// Enabled in Altair
// TODO(electra) re-enable once https://github.com/sigp/lighthouse/issues/6002 is resolved
fork_name != ForkName::Base && fork_name != ForkName::Electra
fork_name.altair_enabled() && fork_name != ForkName::Electra
}
}

View File

@@ -19,8 +19,8 @@ use task_executor::TaskExecutor;
use types::{
attestation::Error as AttestationError, graffiti::GraffitiString, AbstractExecPayload, Address,
AggregateAndProof, Attestation, BeaconBlock, BlindedPayload, ChainSpec, ContributionAndProof,
Domain, Epoch, EthSpec, Fork, ForkName, Graffiti, Hash256, PublicKeyBytes, SelectionProof,
Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedRoot,
Domain, Epoch, EthSpec, Fork, Graffiti, Hash256, PublicKeyBytes, SelectionProof, Signature,
SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedRoot,
SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncAggregatorSelectionData,
SyncCommitteeContribution, SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId,
ValidatorRegistrationData, VoluntaryExit,
@@ -353,17 +353,9 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
fn signing_context(&self, domain: Domain, signing_epoch: Epoch) -> SigningContext {
if domain == Domain::VoluntaryExit {
match self.spec.fork_name_at_epoch(signing_epoch) {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
SigningContext {
domain,
epoch: signing_epoch,
fork: self.fork(signing_epoch),
genesis_validators_root: self.genesis_validators_root,
}
}
if self.spec.fork_name_at_epoch(signing_epoch).deneb_enabled() {
// EIP-7044
ForkName::Deneb | ForkName::Electra => SigningContext {
SigningContext {
domain,
epoch: signing_epoch,
fork: Fork {
@@ -372,7 +364,14 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
epoch: signing_epoch,
},
genesis_validators_root: self.genesis_validators_root,
},
}
} else {
SigningContext {
domain,
epoch: signing_epoch,
fork: self.fork(signing_epoch),
genesis_validators_root: self.genesis_validators_root,
}
}
} else {
SigningContext {