Apply @michaelsproul's feedback
This commit is contained in:
parent
ae218015b7
commit
1b00c10ed3
|
@ -215,11 +215,11 @@ def process_epoch(state: BeaconState) -> None:
|
|||
process_rewards_and_penalties(state)
|
||||
process_registry_updates(state)
|
||||
process_slashings(state)
|
||||
process_eth1_data_votes_updates(state)
|
||||
process_effective_balances_updates(state)
|
||||
process_slashings_updates(state)
|
||||
process_randao_mixes_updates(state)
|
||||
process_historical_roots_updates(state)
|
||||
process_eth1_data_reset(state)
|
||||
process_effective_balance_updates(state)
|
||||
process_slashings_reset(state)
|
||||
process_randao_mixes_reset(state)
|
||||
process_historical_roots_update(state)
|
||||
process_participation_record_updates(state)
|
||||
# Light client patch
|
||||
process_sync_committee_updates(state)
|
||||
|
|
|
@ -1255,11 +1255,11 @@ def process_epoch(state: BeaconState) -> None:
|
|||
process_rewards_and_penalties(state)
|
||||
process_registry_updates(state)
|
||||
process_slashings(state)
|
||||
process_eth1_data_votes_updates(state)
|
||||
process_effective_balances_updates(state)
|
||||
process_slashings_updates(state)
|
||||
process_randao_mixes_updates(state)
|
||||
process_historical_roots_updates(state)
|
||||
process_eth1_data_reset(state)
|
||||
process_effective_balance_updates(state)
|
||||
process_slashings_reset(state)
|
||||
process_randao_mixes_reset(state)
|
||||
process_historical_roots_update(state)
|
||||
process_participation_record_updates(state)
|
||||
```
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ def process_slashings(state: BeaconState) -> None:
|
|||
|
||||
#### Eth1 data votes updates
|
||||
```python
|
||||
def process_eth1_data_votes_updates(state: BeaconState) -> None:
|
||||
def process_eth1_data_reset(state: BeaconState) -> None:
|
||||
next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
# Reset eth1 data votes
|
||||
if next_epoch % EPOCHS_PER_ETH1_VOTING_PERIOD == 0:
|
||||
|
@ -1579,7 +1579,7 @@ def process_eth1_data_votes_updates(state: BeaconState) -> None:
|
|||
#### Effective balances updates
|
||||
|
||||
```python
|
||||
def process_effective_balances_updates(state: BeaconState) -> None:
|
||||
def process_effective_balance_updates(state: BeaconState) -> None:
|
||||
# Update effective balances with hysteresis
|
||||
for index, validator in enumerate(state.validators):
|
||||
balance = state.balances[index]
|
||||
|
@ -1596,7 +1596,7 @@ def process_effective_balances_updates(state: BeaconState) -> None:
|
|||
#### Slashings balances updates
|
||||
|
||||
```python
|
||||
def process_slashings_updates(state: BeaconState) -> None:
|
||||
def process_slashings_reset(state: BeaconState) -> None:
|
||||
next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
# Reset slashings
|
||||
state.slashings[next_epoch % EPOCHS_PER_SLASHINGS_VECTOR] = Gwei(0)
|
||||
|
@ -1605,7 +1605,7 @@ def process_slashings_updates(state: BeaconState) -> None:
|
|||
#### Randao mixes updates
|
||||
|
||||
```python
|
||||
def process_randao_mixes_updates(state: BeaconState) -> None:
|
||||
def process_randao_mixes_reset(state: BeaconState) -> None:
|
||||
current_epoch = get_current_epoch(state)
|
||||
next_epoch = Epoch(current_epoch + 1)
|
||||
# Set randao mix
|
||||
|
@ -1614,7 +1614,7 @@ def process_randao_mixes_updates(state: BeaconState) -> None:
|
|||
|
||||
#### Historical roots updates
|
||||
```python
|
||||
def process_historical_roots_updates(state: BeaconState) -> None:
|
||||
def process_historical_roots_update(state: BeaconState) -> None:
|
||||
# Set historical root accumulator
|
||||
next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
if next_epoch % (SLOTS_PER_HISTORICAL_ROOT // SLOTS_PER_EPOCH) == 0:
|
||||
|
|
|
@ -1057,11 +1057,11 @@ def process_epoch(state: BeaconState) -> None:
|
|||
process_reveal_deadlines(state) # Phase 1
|
||||
process_challenge_deadlines(state) # Phase 1
|
||||
process_slashings(state)
|
||||
process_eth1_data_votes_updates(state)
|
||||
process_effective_balances_updates(state)
|
||||
process_slashings_updates(state)
|
||||
process_randao_mixes_updates(state)
|
||||
process_historical_roots_updates(state)
|
||||
process_eth1_data_reset(state)
|
||||
process_effective_balance_updates(state)
|
||||
process_slashings_reset(state)
|
||||
process_randao_mixes_reset(state)
|
||||
process_historical_roots_update(state)
|
||||
process_participation_record_updates(state)
|
||||
process_phase_1_final_updates(state) # Phase 1
|
||||
```
|
||||
|
|
|
@ -7,11 +7,11 @@ process_calls = [
|
|||
'process_reveal_deadlines',
|
||||
'process_challenge_deadlines',
|
||||
'process_slashings',
|
||||
'process_eth1_data_votes_updates',
|
||||
'process_effective_balances_updates',
|
||||
'process_slashings_updates',
|
||||
'process_randao_mixes_updates',
|
||||
'process_historical_roots_updates',
|
||||
'process_eth1_data_reset',
|
||||
'process_effective_balance_updates',
|
||||
'process_slashings_reset',
|
||||
'process_randao_mixes_reset',
|
||||
'process_historical_roots_update',
|
||||
'process_participation_record_updates',
|
||||
# LIGHTCLIENT_PATCH
|
||||
'process_sync_committee_updates',
|
||||
|
|
|
@ -4,8 +4,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_effective_balances_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_effective_balances_updates')
|
||||
def run_process_effective_balance_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_effective_balance_updates')
|
||||
|
||||
|
||||
@with_all_phases
|
||||
|
@ -13,7 +13,7 @@ def run_process_effective_balances_updates(spec, state):
|
|||
def test_effective_balance_hysteresis(spec, state):
|
||||
# Prepare state up to the final-updates.
|
||||
# Then overwrite the balances, we only want to focus to be on the hysteresis based changes.
|
||||
run_epoch_processing_to(spec, state, 'process_effective_balances_updates')
|
||||
run_epoch_processing_to(spec, state, 'process_effective_balance_updates')
|
||||
# Set some edge cases for balances
|
||||
max = spec.MAX_EFFECTIVE_BALANCE
|
||||
min = spec.EJECTION_BALANCE
|
||||
|
@ -44,7 +44,7 @@ def test_effective_balance_hysteresis(spec, state):
|
|||
state.validators[i].effective_balance = pre_eff
|
||||
state.balances[i] = bal
|
||||
|
||||
yield from run_process_effective_balances_updates(spec, state)
|
||||
yield from run_process_effective_balance_updates(spec, state)
|
||||
|
||||
for i, (_, _, post_eff, name) in enumerate(cases):
|
||||
assert state.validators[i].effective_balance == post_eff, name
|
|
@ -5,8 +5,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
from eth2spec.test.helpers.state import transition_to
|
||||
|
||||
|
||||
def run_process_eth1_data_votes_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_eth1_data_votes_updates')
|
||||
def run_process_eth1_data_reset(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_eth1_data_reset')
|
||||
|
||||
|
||||
@with_all_phases
|
||||
|
@ -22,7 +22,7 @@ def test_eth1_vote_no_reset(spec, state):
|
|||
deposit_count=state.eth1_deposit_index,
|
||||
block_hash=b'\xbb' * 32))
|
||||
|
||||
yield from run_process_eth1_data_votes_updates(spec, state)
|
||||
yield from run_process_eth1_data_reset(spec, state)
|
||||
|
||||
assert len(state.eth1_data_votes) == spec.SLOTS_PER_EPOCH
|
||||
|
||||
|
@ -38,6 +38,6 @@ def test_eth1_vote_reset(spec, state):
|
|||
deposit_count=state.eth1_deposit_index,
|
||||
block_hash=b'\xbb' * 32))
|
||||
|
||||
yield from run_process_eth1_data_votes_updates(spec, state)
|
||||
yield from run_process_eth1_data_reset(spec, state)
|
||||
|
||||
assert len(state.eth1_data_votes) == 0
|
|
@ -4,8 +4,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_historical_roots_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_roots_updates')
|
||||
def run_process_historical_roots_update(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_roots_update')
|
||||
|
||||
|
||||
@with_all_phases
|
||||
|
@ -15,6 +15,6 @@ def test_historical_root_accumulator(spec, state):
|
|||
state.slot = spec.SLOTS_PER_HISTORICAL_ROOT - 1
|
||||
history_len = len(state.historical_roots)
|
||||
|
||||
yield from run_process_historical_roots_updates(spec, state)
|
||||
yield from run_process_historical_roots_update(spec, state)
|
||||
|
||||
assert len(state.historical_roots) == history_len + 1
|
|
@ -4,8 +4,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_randao_mixes_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_randao_mixes_updates')
|
||||
def run_process_randao_mixes_reset(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_randao_mixes_reset')
|
||||
|
||||
|
||||
@with_all_phases
|
||||
|
@ -14,7 +14,7 @@ def test_updated_randao_mixes(spec, state):
|
|||
next_epoch = spec.get_current_epoch(state) + 1
|
||||
state.randao_mixes[next_epoch % spec.EPOCHS_PER_HISTORICAL_VECTOR] = b'\x56' * 32
|
||||
|
||||
yield from run_process_randao_mixes_updates(spec, state)
|
||||
yield from run_process_randao_mixes_reset(spec, state)
|
||||
|
||||
assert state.randao_mixes[next_epoch % spec.EPOCHS_PER_HISTORICAL_VECTOR] == spec.get_randao_mix(
|
||||
state, spec.get_current_epoch(state)
|
|
@ -4,8 +4,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_slashings_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_slashings_updates')
|
||||
def run_process_slashings_reset(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_slashings_reset')
|
||||
|
||||
|
||||
@with_all_phases
|
||||
|
@ -15,6 +15,6 @@ def test_flush_slashings(spec, state):
|
|||
state.slashings[next_epoch % spec.EPOCHS_PER_SLASHINGS_VECTOR] = 100
|
||||
assert state.slashings[next_epoch % spec.EPOCHS_PER_SLASHINGS_VECTOR] != 0
|
||||
|
||||
yield from run_process_slashings_updates(spec, state)
|
||||
yield from run_process_slashings_reset(spec, state)
|
||||
|
||||
assert state.slashings[next_epoch % spec.EPOCHS_PER_SLASHINGS_VECTOR] == 0
|
|
@ -43,11 +43,11 @@ Sub-transitions:
|
|||
- `rewards_and_penalties`
|
||||
- `registry_updates`
|
||||
- `slashings`
|
||||
- `eth1_data_votes_updates`
|
||||
- `effective_balances_updates`
|
||||
- `slashings_updates`
|
||||
- `randao_mixes_updates`
|
||||
- `historical_roots_updates`
|
||||
- `eth1_data_reset`
|
||||
- `effective_balance_updates`
|
||||
- `slashings_reset`
|
||||
- `randao_mixes_reset`
|
||||
- `historical_roots_update`
|
||||
- `participation_record_updates`
|
||||
|
||||
The resulting state should match the expected `post` state.
|
||||
|
|
|
@ -37,11 +37,11 @@ if __name__ == "__main__":
|
|||
'rewards_and_penalties',
|
||||
'registry_updates',
|
||||
'slashings',
|
||||
'eth1_data_votes_updates',
|
||||
'effective_balances_updates',
|
||||
'slashings_updates',
|
||||
'randao_mixes_updates',
|
||||
'historical_roots_updates',
|
||||
'eth1_data_reset',
|
||||
'effective_balance_updates',
|
||||
'slashings_reset',
|
||||
'randao_mixes_reset',
|
||||
'historical_roots_update',
|
||||
'participation_record_updates',
|
||||
]}
|
||||
phase_1_mods = {**{key: 'eth2spec.test.phase1.epoch_processing.test_process_' + key for key in [
|
||||
|
|
Loading…
Reference in New Issue