From 388ec32b556853f32fafe3d722c33871f380aab8 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 26 Aug 2024 21:43:35 +1000 Subject: [PATCH] Implement Electra spec v1.5.0-alpha.5 (#6305) * Implement spec v1.5.0-alpha.5 * Merge remote-tracking branch 'origin/unstable' into spec-1.5.0-alpha.5 * Ignore broken Electra light client tests --- .../src/per_epoch_processing/single_pass.rs | 14 +++++++++----- testing/ef_tests/Makefile | 2 +- testing/ef_tests/check_all_files_accessed.py | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/consensus/state_processing/src/per_epoch_processing/single_pass.rs b/consensus/state_processing/src/per_epoch_processing/single_pass.rs index b604d621e22..51f45b87e80 100644 --- a/consensus/state_processing/src/per_epoch_processing/single_pass.rs +++ b/consensus/state_processing/src/per_epoch_processing/single_pass.rs @@ -811,6 +811,7 @@ impl PendingBalanceDepositsContext { .deposit_balance_to_consume()? .safe_add(state.get_activation_exit_churn_limit(spec)?)?; let current_epoch = state.current_epoch(); + let next_epoch = state.next_epoch()?; let mut processed_amount = 0; let mut next_deposit_index = 0; let mut validator_deposits_to_process = HashMap::new(); @@ -827,17 +828,20 @@ impl PendingBalanceDepositsContext { // does not happen until after this (but in the spec happens before). However it's not // hard to work out: we don't need to know exactly what value the `exit_epoch` will // take, just whether it is non-default. Nor do we need to know the value of - // `withdrawable_epoch`, because `current_epoch <= withdrawable_epoch` will evaluate to + // `withdrawable_epoch`, because `next_epoch <= withdrawable_epoch` will evaluate to // `true` both for the actual value & the default placeholder value (`FAR_FUTURE_EPOCH`). let validator = state.get_validator(deposit.index as usize)?; let already_exited = validator.exit_epoch < spec.far_future_epoch; // In the spec process_registry_updates is called before process_pending_balance_deposits // so we must account for process_registry_updates ejecting the validator for low balance - // and setting the exit_epoch to < far_future_epoch + // and setting the exit_epoch to < far_future_epoch. Note that in the spec the effective + // balance update does not happen until *after* the registry update, so we don't need to + // account for changes to the effective balance that would push it below the ejection + // balance here. let will_be_exited = validator.is_active_at(current_epoch) && validator.effective_balance <= spec.ejection_balance; if already_exited || will_be_exited { - if state.current_epoch() <= validator.withdrawable_epoch { + if next_epoch <= validator.withdrawable_epoch { deposits_to_postpone.push(deposit.clone()); } else { // Deposited balance will never become active. Increase balance but do not @@ -906,7 +910,7 @@ fn process_pending_consolidations( spec: &ChainSpec, ) -> Result<(), Error> { let mut next_pending_consolidation: usize = 0; - let current_epoch = state.current_epoch(); + let next_epoch = state.next_epoch()?; let pending_consolidations = state.pending_consolidations()?.clone(); let mut affected_validators = BTreeSet::new(); @@ -919,7 +923,7 @@ fn process_pending_consolidations( next_pending_consolidation.safe_add_assign(1)?; continue; } - if source_validator.withdrawable_epoch > current_epoch { + if source_validator.withdrawable_epoch > next_epoch { break; } diff --git a/testing/ef_tests/Makefile b/testing/ef_tests/Makefile index 59e08e5d259..0aa5f1d38db 100644 --- a/testing/ef_tests/Makefile +++ b/testing/ef_tests/Makefile @@ -1,4 +1,4 @@ -TESTS_TAG := v1.5.0-alpha.3 +TESTS_TAG := v1.5.0-alpha.5 TESTS = general minimal mainnet TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS)) diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index d8f5b3e78dc..9495047e7f9 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -26,15 +26,15 @@ "tests/.*/.*/ssz_static/Eth1Block/", "tests/.*/.*/ssz_static/PowBlock/", # light_client - # "tests/.*/.*/light_client", "tests/.*/.*/light_client/single_merkle_proof", "tests/.*/.*/light_client/sync", + "tests/.*/electra/light_client/update_ranking", # LightClientStore "tests/.*/.*/ssz_static/LightClientStore", # LightClientSnapshot "tests/.*/.*/ssz_static/LightClientSnapshot", # One of the EF researchers likes to pack the tarballs on a Mac - ".*\.DS_Store.*", + ".*\\.DS_Store.*", # More Mac weirdness. "tests/mainnet/bellatrix/operations/deposit/pyspec_tests/deposit_with_previous_fork_version__valid_ineffective/._meta.yaml", # bls tests are moved to bls12-381-tests directory @@ -49,7 +49,8 @@ # TODO(electra) re-enable once https://github.com/sigp/lighthouse/issues/6002 is resolved "tests/.*/electra/ssz_static/LightClientUpdate", "tests/.*/electra/ssz_static/LightClientFinalityUpdate", - "tests/.*/electra/ssz_static/LightClientBootstrap" + "tests/.*/electra/ssz_static/LightClientBootstrap", + "tests/.*/electra/merkle_proof", ]