Skip to content

Commit

Permalink
Rename Merge to Bellatrix (#5601)
Browse files Browse the repository at this point in the history
* Rename Merge to Bellatrix

* Remove tree-hash-cache which got readded from the rebase
  • Loading branch information
macladson authored Apr 25, 2024
1 parent 3203456 commit 13f94ef
Show file tree
Hide file tree
Showing 104 changed files with 808 additions and 714 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PROFILE ?= release

# List of all hard forks. This list is used to set env variables for several tests so that
# they run for different forks.
FORKS=phase0 altair merge capella deneb electra
FORKS=phase0 altair bellatrix capella deneb electra

# Extra flags for Cargo
CARGO_INSTALL_EXTRA_FLAGS?=
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/attestation_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
match state {
BeaconState::Base(_) => self.compute_attestation_rewards_base(state, validators),
BeaconState::Altair(_)
| BeaconState::Merge(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_)
| BeaconState::Electra(_) => self.compute_attestation_rewards_altair(state, validators),
Expand Down
4 changes: 3 additions & 1 deletion beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,9 @@ 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 = match current_fork {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => one_epoch_prior,
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => {
one_epoch_prior
}
// EIP-7045
ForkName::Deneb | ForkName::Electra => one_epoch_prior
.epoch(E::slots_per_epoch())
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/beacon_block_streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use types::{
SignedBlindedBeaconBlock, Slot,
};
use types::{
ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadElectra, ExecutionPayloadHeader,
ExecutionPayloadMerge,
ExecutionPayload, ExecutionPayloadBellatrix, ExecutionPayloadCapella, ExecutionPayloadElectra,
ExecutionPayloadHeader,
};

#[derive(PartialEq)]
Expand Down Expand Up @@ -95,7 +95,7 @@ fn reconstruct_default_header_block<E: EthSpec>(
.map_err(BeaconChainError::InconsistentFork)?;

let payload: ExecutionPayload<E> = match fork {
ForkName::Merge => ExecutionPayloadMerge::default().into(),
ForkName::Bellatrix => ExecutionPayloadBellatrix::default().into(),
ForkName::Capella => ExecutionPayloadCapella::default().into(),
ForkName::Deneb => ExecutionPayloadDeneb::default().into(),
ForkName::Electra => ExecutionPayloadElectra::default().into(),
Expand Down
16 changes: 8 additions & 8 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,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::Merge = current_fork {
if let ForkName::Base | ForkName::Altair | ForkName::Bellatrix = current_fork {
Ok(false)
} else {
Ok(true)
Expand Down Expand Up @@ -4823,7 +4823,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// allows it to run concurrently with things like attestation packing.
let prepare_payload_handle = match &state {
BeaconState::Base(_) | BeaconState::Altair(_) => None,
BeaconState::Merge(_)
BeaconState::Bellatrix(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_)
| BeaconState::Electra(_) => {
Expand Down Expand Up @@ -5083,17 +5083,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
None,
Uint256::zero(),
),
BeaconState::Merge(_) => {
BeaconState::Bellatrix(_) => {
let block_proposal_contents =
block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?;
let execution_payload_value = block_proposal_contents.block_value().to_owned();
(
BeaconBlock::Merge(BeaconBlockMerge {
BeaconBlock::Bellatrix(BeaconBlockBellatrix {
slot,
proposer_index,
parent_root,
state_root: Hash256::zero(),
body: BeaconBlockBodyMerge {
body: BeaconBlockBodyBellatrix {
randao_reveal,
eth1_data,
graffiti,
Expand Down Expand Up @@ -5541,7 +5541,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} 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::Merge => None,
ForkName::Base | ForkName::Altair | ForkName::Bellatrix => None,
ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
let chain = self.clone();
self.spawn_blocking_handle(
Expand All @@ -5556,7 +5556,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
};

let parent_beacon_block_root = match prepare_slot_fork {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => None,
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => None,
ForkName::Deneb | ForkName::Electra => {
Some(pre_payload_attributes.parent_beacon_block_root)
}
Expand Down Expand Up @@ -6599,7 +6599,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {

match fork_name {
ForkName::Altair
| ForkName::Merge
| ForkName::Bellatrix
| ForkName::Capella
| ForkName::Deneb
| ForkName::Electra => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use types::*;

/// The time before the Bellatrix fork when we will start issuing warnings about preparation.
pub const SECONDS_IN_A_WEEK: u64 = 604800;
pub const MERGE_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;
pub const BELLATRIX_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;

#[derive(Default, Debug, Serialize, Deserialize)]
pub struct MergeConfig {
Expand Down Expand Up @@ -81,7 +81,7 @@ impl MergeConfig {
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "type")]
pub enum MergeReadiness {
pub enum BellatrixReadiness {
/// The node is ready, as far as we can tell.
Ready {
config: MergeConfig,
Expand All @@ -94,29 +94,29 @@ pub enum MergeReadiness {
NoExecutionEndpoint,
}

impl fmt::Display for MergeReadiness {
impl fmt::Display for BellatrixReadiness {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MergeReadiness::Ready {
BellatrixReadiness::Ready {
config: params,
current_difficulty,
} => {
write!(
f,
"This node appears ready for the merge. \
"This node appears ready for Bellatrix \
Params: {}, current_difficulty: {:?}",
params, current_difficulty
)
}
MergeReadiness::NotSynced => write!(
BellatrixReadiness::NotSynced => write!(
f,
"The execution endpoint is connected and configured, \
however it is not yet synced"
),
MergeReadiness::NoExecutionEndpoint => write!(
BellatrixReadiness::NoExecutionEndpoint => write!(
f,
"The --execution-endpoint flag is not specified, this is a \
requirement for the merge"
requirement for Bellatrix"
),
}
}
Expand All @@ -143,43 +143,43 @@ pub enum GenesisExecutionPayloadStatus {

impl<T: BeaconChainTypes> BeaconChain<T> {
/// Returns `true` if user has an EL configured, or if the Bellatrix fork has occurred or will
/// occur within `MERGE_READINESS_PREPARATION_SECONDS`.
/// occur within `BELLATRIX_READINESS_PREPARATION_SECONDS`.
pub fn is_time_to_prepare_for_bellatrix(&self, current_slot: Slot) -> bool {
if let Some(bellatrix_epoch) = self.spec.bellatrix_fork_epoch {
let bellatrix_slot = bellatrix_epoch.start_slot(T::EthSpec::slots_per_epoch());
let merge_readiness_preparation_slots =
MERGE_READINESS_PREPARATION_SECONDS / self.spec.seconds_per_slot;
let bellatrix_readiness_preparation_slots =
BELLATRIX_READINESS_PREPARATION_SECONDS / self.spec.seconds_per_slot;

if self.execution_layer.is_some() {
// The user has already configured an execution layer, start checking for readiness
// right away.
true
} else {
// Return `true` if Bellatrix has happened or is within the preparation time.
current_slot + merge_readiness_preparation_slots > bellatrix_slot
current_slot + bellatrix_readiness_preparation_slots > bellatrix_slot
}
} else {
// The Bellatrix fork epoch has not been defined yet, no need to prepare.
false
}
}

/// Attempts to connect to the EL and confirm that it is ready for the merge.
pub async fn check_merge_readiness(&self, current_slot: Slot) -> MergeReadiness {
/// Attempts to connect to the EL and confirm that it is ready for Bellatrix.
pub async fn check_bellatrix_readiness(&self, current_slot: Slot) -> BellatrixReadiness {
if let Some(el) = self.execution_layer.as_ref() {
if !el.is_synced_for_notifier(current_slot).await {
// The EL is not synced.
return MergeReadiness::NotSynced;
return BellatrixReadiness::NotSynced;
}
let params = MergeConfig::from_chainspec(&self.spec);
let current_difficulty = el.get_current_difficulty().await.ok();
MergeReadiness::Ready {
BellatrixReadiness::Ready {
config: params,
current_difficulty,
}
} else {
// There is no EL configured.
MergeReadiness::NoExecutionEndpoint
BellatrixReadiness::NoExecutionEndpoint
}
}

Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/capella_readiness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Duration;
use types::*;

/// The time before the Capella fork when we will start issuing warnings about preparation.
use super::merge_readiness::SECONDS_IN_A_WEEK;
use super::bellatrix_readiness::SECONDS_IN_A_WEEK;
pub const CAPELLA_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;
pub const ENGINE_CAPABILITIES_REFRESH_INTERVAL: u64 = 300;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,17 +989,17 @@ mod test {

// go to bellatrix slot
harness.extend_to_slot(bellatrix_fork_slot).await;
let merge_head = &harness.chain.head_snapshot().beacon_block;
assert!(merge_head.as_merge().is_ok());
assert_eq!(merge_head.slot(), bellatrix_fork_slot);
let bellatrix_head = &harness.chain.head_snapshot().beacon_block;
assert!(bellatrix_head.as_bellatrix().is_ok());
assert_eq!(bellatrix_head.slot(), bellatrix_fork_slot);
assert!(
merge_head
bellatrix_head
.message()
.body()
.execution_payload()
.unwrap()
.is_default_with_empty_roots(),
"Merge head is default payload"
"Bellatrix head is default payload"
);
// Trigger the terminal PoW block.
harness
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/deneb_readiness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Duration;
use types::*;

/// The time before the Deneb fork when we will start issuing warnings about preparation.
use super::merge_readiness::SECONDS_IN_A_WEEK;
use super::bellatrix_readiness::SECONDS_IN_A_WEEK;
pub const DENEB_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;
pub const ENGINE_CAPABILITIES_REFRESH_INTERVAL: u64 = 300;

Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/electra_readiness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::time::Duration;
use types::*;

/// The time before the Electra fork when we will start issuing warnings about preparation.
use super::merge_readiness::SECONDS_IN_A_WEEK;
use super::bellatrix_readiness::SECONDS_IN_A_WEEK;
pub const ELECTRA_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;
pub const ENGINE_CAPABILITIES_REFRESH_INTERVAL: u64 = 300;

Expand Down
14 changes: 7 additions & 7 deletions beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn validate_execution_payload_for_gossip<T: BeaconChainTypes>(
block: BeaconBlockRef<'_, T::EthSpec>,
chain: &BeaconChain<T>,
) -> Result<(), BlockError<T::EthSpec>> {
// Only apply this validation if this is a merge beacon block.
// Only apply this validation if this is a Bellatrix beacon block.
if let Ok(execution_payload) = block.body().execution_payload() {
// This logic should match `is_execution_enabled`. We use only the execution block hash of
// the parent here in order to avoid loading the parent state during gossip verification.
Expand Down Expand Up @@ -385,7 +385,7 @@ pub fn validate_execution_payload_for_gossip<T: BeaconChainTypes>(
/// ## Errors
///
/// Will return an error when using a pre-merge fork `state`. Ensure to only run this function
/// after the merge fork.
/// after the Bellatrix fork.
///
/// ## Specification
///
Expand Down Expand Up @@ -415,13 +415,13 @@ pub fn get_execution_payload<T: BeaconChainTypes>(
&BeaconState::Capella(_) | &BeaconState::Deneb(_) | &BeaconState::Electra(_) => {
Some(get_expected_withdrawals(state, spec)?.into())
}
&BeaconState::Merge(_) => None,
&BeaconState::Bellatrix(_) => None,
// These shouldn't happen but they're here to make the pattern irrefutable
&BeaconState::Base(_) | &BeaconState::Altair(_) => None,
};
let parent_beacon_block_root = match state {
BeaconState::Deneb(_) | BeaconState::Electra(_) => Some(parent_block_root),
BeaconState::Merge(_) | BeaconState::Capella(_) => None,
BeaconState::Bellatrix(_) | BeaconState::Capella(_) => None,
// These shouldn't happen but they're here to make the pattern irrefutable
BeaconState::Base(_) | BeaconState::Altair(_) => None,
};
Expand Down Expand Up @@ -457,12 +457,12 @@ pub fn get_execution_payload<T: BeaconChainTypes>(

/// Prepares an execution payload for inclusion in a block.
///
/// Will return `Ok(None)` if the merge fork has occurred, but a terminal block has not been found.
/// Will return `Ok(None)` if the Bellatrix fork has occurred, but a terminal block has not been found.
///
/// ## Errors
///
/// Will return an error when using a pre-merge fork `state`. Ensure to only run this function
/// after the merge fork.
/// Will return an error when using a pre-Bellatrix fork `state`. Ensure to only run this function
/// after the Bellatrix fork.
///
/// ## Specification
///
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod beacon_chain;
mod beacon_fork_choice_store;
pub mod beacon_proposer_cache;
mod beacon_snapshot;
pub mod bellatrix_readiness;
pub mod blob_verification;
pub mod block_reward;
mod block_times_cache;
Expand Down Expand Up @@ -35,7 +36,6 @@ pub mod kzg_utils;
pub mod light_client_finality_update_verification;
pub mod light_client_optimistic_update_verification;
mod light_client_server_cache;
pub mod merge_readiness;
pub mod metrics;
pub mod migrate;
mod naive_aggregation_pool;
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ where
let block_contents: SignedBlockContentsTuple<E> = match *signed_block {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
| SignedBeaconBlock::Merge(_)
| SignedBeaconBlock::Bellatrix(_)
| SignedBeaconBlock::Capella(_) => (signed_block, None),
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => {
(signed_block, block_response.blob_items)
Expand Down Expand Up @@ -944,7 +944,7 @@ where
let block_contents: SignedBlockContentsTuple<E> = match *signed_block {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
| SignedBeaconBlock::Merge(_)
| SignedBeaconBlock::Bellatrix(_)
| SignedBeaconBlock::Capella(_) => (signed_block, None),
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => {
(signed_block, block_response.blob_items)
Expand Down
Loading

0 comments on commit 13f94ef

Please sign in to comment.