Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: pectra -> electra #598

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/modules/ejector/ejector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EJECTOR_VALIDATORS_COUNT_TO_EJECT,
)
from src.modules.ejector.data_encode import encode_data
from src.modules.ejector.sweep import get_sweep_delay_in_epochs_post_pectra
from src.modules.ejector.sweep import get_sweep_delay_in_epochs_post_electra
from src.modules.ejector.types import EjectorProcessingState, ReportData
from src.modules.submodules.consensus import ConsensusModule, InitialEpochIsYetToArriveRevert
from src.modules.submodules.oracle_module import BaseModule, ModuleExecuteDelay
Expand Down Expand Up @@ -324,11 +324,11 @@ def _get_sweep_delay_in_epochs(self, blockstamp: ReferenceBlockStamp) -> int:
chain_config = self.get_chain_config(blockstamp)
electra_epoch = int(spec.ELECTRA_FORK_EPOCH)
if self.get_consensus_version(blockstamp) < 3 or blockstamp.ref_epoch < electra_epoch:
return self._get_sweep_delay_in_epochs_pre_pectra(blockstamp)
return self._get_sweep_delay_in_epochs_pre_electra(blockstamp)
state = self.w3.cc.get_state_view(blockstamp)
return get_sweep_delay_in_epochs_post_pectra(state, chain_config)
return get_sweep_delay_in_epochs_post_electra(state, chain_config)

def _get_sweep_delay_in_epochs_pre_pectra(self, blockstamp: ReferenceBlockStamp) -> int:
def _get_sweep_delay_in_epochs_pre_electra(self, blockstamp: ReferenceBlockStamp) -> int:
chain_config = self.get_chain_config(blockstamp)

total_withdrawable_validators = len(self._get_withdrawable_validators(blockstamp))
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ejector/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Withdrawal:
amount: int


def get_sweep_delay_in_epochs_post_pectra(state: BeaconStateView, spec: ChainConfig) -> int:
def get_sweep_delay_in_epochs_post_electra(state: BeaconStateView, spec: ChainConfig) -> int:
"""
This method predicts the average withdrawal delay in epochs.
It is assumed that on average, a validator sweep is achieved in half the time of a full sweep cycle.
Expand Down
4 changes: 2 additions & 2 deletions src/services/bunker_cases/abnormal_cl_rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ def _get_lido_validators_balance_with_vault(
spec = self.w3.cc.get_config_spec()
if epoch >= int(spec.ELECTRA_FORK_EPOCH):
state = self.w3.cc.get_state_view(blockstamp)
pending_deposits_sum = LidoValidatorsProvider.calculate_total_eth1_bridge_deposits_amount(
total_eth1_bridge_deposits_amount = LidoValidatorsProvider.calculate_total_eth1_bridge_deposits_amount(
lido_validators, state.pending_deposits
)
total_balance += pending_deposits_sum
total_balance += total_eth1_bridge_deposits_amount

return Gwei(total_balance)

Expand Down
6 changes: 3 additions & 3 deletions tests/modules/ejector/test_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from src.constants import MAX_WITHDRAWALS_PER_PAYLOAD, MIN_ACTIVATION_BALANCE
from src.modules.ejector.sweep import (
get_sweep_delay_in_epochs_post_pectra,
get_sweep_delay_in_epochs_post_electra,
get_pending_partial_withdrawals,
get_validators_withdrawals,
Withdrawal,
Expand All @@ -19,7 +19,7 @@


@pytest.mark.unit
def test_get_sweep_delay_in_epochs_post_pectra(monkeypatch):
def test_get_sweep_delay_in_epochs_post_electra(monkeypatch):
# Create mock objects for state and spec
state = Mock(spec=BeaconStateView)
spec = Mock(spec=ChainConfig)
Expand All @@ -32,7 +32,7 @@ def test_get_sweep_delay_in_epochs_post_pectra(monkeypatch):
Mock(return_value=predicted_withdrawals),
)
# Calculate delay
result = get_sweep_delay_in_epochs_post_pectra(state, spec)
result = get_sweep_delay_in_epochs_post_electra(state, spec)

# Assert the delay calculation is correct
expected_delay = math.ceil(predicted_withdrawals / MAX_WITHDRAWALS_PER_PAYLOAD / int(spec.slots_per_epoch)) // 2
Expand Down
Loading