Skip to content

Commit

Permalink
Merge branch 'unstable' of https://github.com/sigp/lighthouse into de…
Browse files Browse the repository at this point in the history
…precate-http-spec-fork-and-http-allow-sync-stalled
  • Loading branch information
eserilev committed Apr 3, 2024
2 parents da14923 + 969d12d commit bb92668
Show file tree
Hide file tree
Showing 290 changed files with 4,780 additions and 3,155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ jobs:
run: |
make
- name: Install lcli
# TODO: uncomment after the version of lcli in https://github.com/sigp/lighthouse/pull/5137
# TODO: uncomment after the version of lcli in https://github.com/sigp/lighthouse/pull/5137
# is installed on the runners
# if: env.SELF_HOSTED_RUNNERS == 'false'
run: make install-lcli
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
FORKS=phase0 altair merge capella deneb electra

# Extra flags for Cargo
CARGO_INSTALL_EXTRA_FLAGS?=
Expand Down
2 changes: 1 addition & 1 deletion account_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
}

/// Run the account manager, returning an error if the operation did not succeed.
pub fn run<T: EthSpec>(matches: &ArgMatches<'_>, env: Environment<T>) -> Result<(), String> {
pub fn run<E: EthSpec>(matches: &ArgMatches<'_>, env: Environment<E>) -> Result<(), String> {
match matches.subcommand() {
(wallet::CMD, Some(matches)) => wallet::cli_run(matches)?,
(validator::CMD, Some(matches)) => validator::cli_run(matches, env)?,
Expand Down
4 changes: 2 additions & 2 deletions account_manager/src/validator/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
}

pub fn cli_run<T: EthSpec>(
pub fn cli_run<E: EthSpec>(
matches: &ArgMatches,
env: Environment<T>,
env: Environment<E>,
validator_dir: PathBuf,
) -> Result<(), String> {
let spec = env.core_context().eth2_config.spec;
Expand Down
4 changes: 2 additions & 2 deletions account_manager/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.subcommand(exit::cli_app())
}

pub fn cli_run<T: EthSpec>(matches: &ArgMatches, env: Environment<T>) -> Result<(), String> {
pub fn cli_run<E: EthSpec>(matches: &ArgMatches, env: Environment<E>) -> Result<(), String> {
let validator_base_dir = if matches.value_of("datadir").is_some() {
let path: PathBuf = clap_utils::parse_required(matches, "datadir")?;
path.join(DEFAULT_VALIDATOR_DIR)
Expand All @@ -49,7 +49,7 @@ pub fn cli_run<T: EthSpec>(matches: &ArgMatches, env: Environment<T>) -> Result<
eprintln!("validator-dir path: {:?}", validator_base_dir);

match matches.subcommand() {
(create::CMD, Some(matches)) => create::cli_run::<T>(matches, env, validator_base_dir),
(create::CMD, Some(matches)) => create::cli_run::<E>(matches, env, validator_base_dir),
(modify::CMD, Some(matches)) => modify::cli_run(matches, validator_base_dir),
(import::CMD, Some(matches)) => import::cli_run(matches, validator_base_dir),
(list::CMD, Some(_)) => list::cli_run(validator_base_dir),
Expand Down
6 changes: 3 additions & 3 deletions account_manager/src/validator/slashing_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
)
}

pub fn cli_run<T: EthSpec>(
pub fn cli_run<E: EthSpec>(
matches: &ArgMatches<'_>,
env: Environment<T>,
env: Environment<E>,
validator_base_dir: PathBuf,
) -> Result<(), String> {
let slashing_protection_db_path = validator_base_dir.join(SLASHING_PROTECTION_FILENAME);
Expand All @@ -64,7 +64,7 @@ pub fn cli_run<T: EthSpec>(
.ok_or("Unable to get testnet configuration from the environment")?;

let genesis_validators_root = eth2_network_config
.genesis_validators_root::<T>()?
.genesis_validators_root::<E>()?
.ok_or_else(|| "Unable to get genesis state, has genesis occurred?".to_string())?;

match matches.subcommand() {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "beacon_node"
version = "5.1.2"
version = "5.1.3"
authors = [
"Paul Hauner <paul@paulhauner.com>",
"Age Manning <Age@AgeManning.com",
Expand Down
3 changes: 2 additions & 1 deletion beacon_node/beacon_chain/src/attestation_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
BeaconState::Altair(_)
| BeaconState::Merge(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_) => self.compute_attestation_rewards_altair(state, validators),
| BeaconState::Deneb(_)
| BeaconState::Electra(_) => self.compute_attestation_rewards_altair(state, validators),
}
}

Expand Down
10 changes: 5 additions & 5 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(
let earliest_permissible_slot = match current_fork {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => one_epoch_prior,
// EIP-7045
ForkName::Deneb => one_epoch_prior
ForkName::Deneb | ForkName::Electra => one_epoch_prior
.epoch(E::slots_per_epoch())
.start_slot(E::slots_per_epoch()),
};
Expand Down Expand Up @@ -1121,13 +1121,13 @@ pub fn verify_attestation_signature<T: BeaconChainTypes>(

/// Verifies that the `attestation.data.target.root` is indeed the target root of the block at
/// `attestation.data.beacon_block_root`.
pub fn verify_attestation_target_root<T: EthSpec>(
pub fn verify_attestation_target_root<E: EthSpec>(
head_block: &ProtoBlock,
attestation: &Attestation<T>,
attestation: &Attestation<E>,
) -> Result<(), Error> {
// Check the attestation target root.
let head_block_epoch = head_block.slot.epoch(T::slots_per_epoch());
let attestation_epoch = attestation.data.slot.epoch(T::slots_per_epoch());
let head_block_epoch = head_block.slot.epoch(E::slots_per_epoch());
let attestation_epoch = attestation.data.slot.epoch(E::slots_per_epoch());
if head_block_epoch > attestation_epoch {
// The epoch references an invalid head block from a future epoch.
//
Expand Down
32 changes: 16 additions & 16 deletions beacon_node/beacon_chain/src/attester_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct CommitteeLengths {

impl CommitteeLengths {
/// Instantiate `Self` using `state.current_epoch()`.
pub fn new<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> Result<Self, Error> {
pub fn new<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Result<Self, Error> {
let active_validator_indices_len = if let Ok(committee_cache) =
state.committee_cache(RelativeEpoch::Current)
{
Expand All @@ -102,21 +102,21 @@ impl CommitteeLengths {
}

/// Get the count of committees per each slot of `self.epoch`.
pub fn get_committee_count_per_slot<T: EthSpec>(
pub fn get_committee_count_per_slot<E: EthSpec>(
&self,
spec: &ChainSpec,
) -> Result<usize, Error> {
T::get_committee_count_per_slot(self.active_validator_indices_len, spec).map_err(Into::into)
E::get_committee_count_per_slot(self.active_validator_indices_len, spec).map_err(Into::into)
}

/// Get the length of the committee at the given `slot` and `committee_index`.
pub fn get_committee_length<T: EthSpec>(
pub fn get_committee_length<E: EthSpec>(
&self,
slot: Slot,
committee_index: CommitteeIndex,
spec: &ChainSpec,
) -> Result<CommitteeLength, Error> {
let slots_per_epoch = T::slots_per_epoch();
let slots_per_epoch = E::slots_per_epoch();
let request_epoch = slot.epoch(slots_per_epoch);

// Sanity check.
Expand All @@ -128,7 +128,7 @@ impl CommitteeLengths {
}

let slots_per_epoch = slots_per_epoch as usize;
let committees_per_slot = self.get_committee_count_per_slot::<T>(spec)?;
let committees_per_slot = self.get_committee_count_per_slot::<E>(spec)?;
let index_in_epoch = compute_committee_index_in_epoch(
slot,
slots_per_epoch,
Expand Down Expand Up @@ -162,7 +162,7 @@ pub struct AttesterCacheValue {

impl AttesterCacheValue {
/// Instantiate `Self` using `state.current_epoch()`.
pub fn new<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> Result<Self, Error> {
pub fn new<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Result<Self, Error> {
let current_justified_checkpoint = state.current_justified_checkpoint();
let committee_lengths = CommitteeLengths::new(state, spec)?;
Ok(Self {
Expand All @@ -172,14 +172,14 @@ impl AttesterCacheValue {
}

/// Get the justified checkpoint and committee length for some `slot` and `committee_index`.
fn get<T: EthSpec>(
fn get<E: EthSpec>(
&self,
slot: Slot,
committee_index: CommitteeIndex,
spec: &ChainSpec,
) -> Result<(JustifiedCheckpoint, CommitteeLength), Error> {
self.committee_lengths
.get_committee_length::<T>(slot, committee_index, spec)
.get_committee_length::<E>(slot, committee_index, spec)
.map(|committee_length| (self.current_justified_checkpoint, committee_length))
}
}
Expand Down Expand Up @@ -216,12 +216,12 @@ impl AttesterCacheKey {
/// ## Errors
///
/// May error if `epoch` is out of the range of `state.block_roots`.
pub fn new<T: EthSpec>(
pub fn new<E: EthSpec>(
epoch: Epoch,
state: &BeaconState<T>,
state: &BeaconState<E>,
latest_block_root: Hash256,
) -> Result<Self, Error> {
let slots_per_epoch = T::slots_per_epoch();
let slots_per_epoch = E::slots_per_epoch();
let decision_slot = epoch.start_slot(slots_per_epoch).saturating_sub(1_u64);

let decision_root = if decision_slot.epoch(slots_per_epoch) == epoch {
Expand Down Expand Up @@ -255,7 +255,7 @@ pub struct AttesterCache {
impl AttesterCache {
/// Get the justified checkpoint and committee length for the `slot` and `committee_index` in
/// the state identified by the cache `key`.
pub fn get<T: EthSpec>(
pub fn get<E: EthSpec>(
&self,
key: &AttesterCacheKey,
slot: Slot,
Expand All @@ -265,14 +265,14 @@ impl AttesterCache {
self.cache
.read()
.get(key)
.map(|cache_item| cache_item.get::<T>(slot, committee_index, spec))
.map(|cache_item| cache_item.get::<E>(slot, committee_index, spec))
.transpose()
}

/// Cache the `state.current_epoch()` values if they are not already present in the state.
pub fn maybe_cache_state<T: EthSpec>(
pub fn maybe_cache_state<E: EthSpec>(
&self,
state: &BeaconState<T>,
state: &BeaconState<E>,
latest_block_root: Hash256,
spec: &ChainSpec,
) -> Result<(), Error> {
Expand Down
16 changes: 11 additions & 5 deletions beacon_node/beacon_chain/src/beacon_block_streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use types::{
SignedBlindedBeaconBlock, Slot,
};
use types::{
ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadHeader, ExecutionPayloadMerge,
ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadElectra, ExecutionPayloadHeader,
ExecutionPayloadMerge,
};

#[derive(PartialEq)]
Expand Down Expand Up @@ -98,6 +99,7 @@ fn reconstruct_default_header_block<E: EthSpec>(
ForkName::Merge => ExecutionPayloadMerge::default().into(),
ForkName::Capella => ExecutionPayloadCapella::default().into(),
ForkName::Deneb => ExecutionPayloadDeneb::default().into(),
ForkName::Electra => ExecutionPayloadElectra::default().into(),
ForkName::Base | ForkName::Altair => {
return Err(Error::PayloadReconstruction(format!(
"Block with fork variant {} has execution payload",
Expand Down Expand Up @@ -712,19 +714,21 @@ mod tests {
}

#[tokio::test]
async fn check_all_blocks_from_altair_to_deneb() {
async fn check_all_blocks_from_altair_to_electra() {
let slots_per_epoch = MinimalEthSpec::slots_per_epoch() as usize;
let num_epochs = 8;
let num_epochs = 10;
let bellatrix_fork_epoch = 2usize;
let capella_fork_epoch = 4usize;
let deneb_fork_epoch = 6usize;
let electra_fork_epoch = 8usize;
let num_blocks_produced = num_epochs * slots_per_epoch;

let mut spec = test_spec::<MinimalEthSpec>();
spec.altair_fork_epoch = Some(Epoch::new(0));
spec.bellatrix_fork_epoch = Some(Epoch::new(bellatrix_fork_epoch as u64));
spec.capella_fork_epoch = Some(Epoch::new(capella_fork_epoch as u64));
spec.deneb_fork_epoch = Some(Epoch::new(deneb_fork_epoch as u64));
spec.electra_fork_epoch = Some(Epoch::new(electra_fork_epoch as u64));

let harness = get_harness(VALIDATOR_COUNT, spec.clone());
// go to bellatrix fork
Expand Down Expand Up @@ -833,19 +837,21 @@ mod tests {
}

#[tokio::test]
async fn check_fallback_altair_to_deneb() {
async fn check_fallback_altair_to_electra() {
let slots_per_epoch = MinimalEthSpec::slots_per_epoch() as usize;
let num_epochs = 8;
let num_epochs = 10;
let bellatrix_fork_epoch = 2usize;
let capella_fork_epoch = 4usize;
let deneb_fork_epoch = 6usize;
let electra_fork_epoch = 8usize;
let num_blocks_produced = num_epochs * slots_per_epoch;

let mut spec = test_spec::<MinimalEthSpec>();
spec.altair_fork_epoch = Some(Epoch::new(0));
spec.bellatrix_fork_epoch = Some(Epoch::new(bellatrix_fork_epoch as u64));
spec.capella_fork_epoch = Some(Epoch::new(capella_fork_epoch as u64));
spec.deneb_fork_epoch = Some(Epoch::new(deneb_fork_epoch as u64));
spec.electra_fork_epoch = Some(Epoch::new(electra_fork_epoch as u64));

let harness = get_harness(VALIDATOR_COUNT, spec);

Expand Down
Loading

0 comments on commit bb92668

Please sign in to comment.