Skip to content

Commit

Permalink
Rename SHARD_COMMITTEE_PERIOD
Browse files Browse the repository at this point in the history
This commit renames SHARD_COMMITTEE_PERIOD to MIN_VALIDATOR_ACTIVE_PERIOD.
Since we don't have shard committees anymore, naming things after shard
committees doesn't make sense. This commit renames it to
MIN_VALIDATOR_ACTIVE_PERIOD so that it means the minimum period that the
validator has to be active before exiting.
  • Loading branch information
ppopth committed Sep 25, 2024
1 parent 0c5ad81 commit bc239e9
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 103 deletions.
2 changes: 1 addition & 1 deletion configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ SECONDS_PER_ETH1_BLOCK: 14
# 2**8 (= 256) epochs ~27 hours
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
# 2**8 (= 256) epochs ~27 hours
SHARD_COMMITTEE_PERIOD: 256
MIN_VALIDATOR_ACTIVE_PERIOD: 256
# 2**11 (= 2,048) Eth1 blocks ~8 hours
ETH1_FOLLOW_DISTANCE: 2048

Expand Down
2 changes: 1 addition & 1 deletion configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SECONDS_PER_ETH1_BLOCK: 14
# 2**8 (= 256) epochs
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
# [customized] higher frequency of committee turnover and faster time to acceptable voluntary exit
SHARD_COMMITTEE_PERIOD: 64
MIN_VALIDATOR_ACTIVE_PERIOD: 64
# [customized] process deposits more quickly, but insecure
ETH1_FOLLOW_DISTANCE: 16

Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
# Exits must specify an epoch when they become valid; they are not valid before then
assert get_current_epoch(state) >= voluntary_exit.epoch
# Verify the validator has been active long enough
assert get_current_epoch(state) >= validator.activation_epoch + SHARD_COMMITTEE_PERIOD
assert get_current_epoch(state) >= validator.activation_epoch + MIN_VALIDATOR_ACTIVE_PERIOD
# Verify signature
# [Modified in Deneb:EIP7044]
domain = compute_domain(DOMAIN_VOLUNTARY_EXIT, CAPELLA_FORK_VERSION, state.genesis_validators_root)
Expand Down
4 changes: 2 additions & 2 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
# Exits must specify an epoch when they become valid; they are not valid before then
assert get_current_epoch(state) >= voluntary_exit.epoch
# Verify the validator has been active long enough
assert get_current_epoch(state) >= validator.activation_epoch + SHARD_COMMITTEE_PERIOD
assert get_current_epoch(state) >= validator.activation_epoch + MIN_VALIDATOR_ACTIVE_PERIOD
# Only exit validator if it has no pending withdrawals in the queue
assert get_pending_balance_to_withdraw(state, voluntary_exit.validator_index) == 0 # [New in Electra:EIP7251]
# Verify signature
Expand Down Expand Up @@ -1368,7 +1368,7 @@ def process_withdrawal_request(
if validator.exit_epoch != FAR_FUTURE_EPOCH:
return
# Verify the validator has been active long enough
if get_current_epoch(state) < validator.activation_epoch + SHARD_COMMITTEE_PERIOD:
if get_current_epoch(state) < validator.activation_epoch + MIN_VALIDATOR_ACTIVE_PERIOD:
return

pending_balance_to_withdraw = get_pending_balance_to_withdraw(state, index)
Expand Down
4 changes: 2 additions & 2 deletions specs/phase0/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Testnets and other types of chain instances may use a different configuration.
| `SECONDS_PER_SLOT` | `uint64(12)` | seconds | 12 seconds |
| `SECONDS_PER_ETH1_BLOCK` | `uint64(14)` | seconds | 14 seconds |
| `MIN_VALIDATOR_WITHDRAWABILITY_DELAY` | `uint64(2**8)` (= 256) | epochs | ~27 hours |
| `SHARD_COMMITTEE_PERIOD` | `uint64(2**8)` (= 256) | epochs | ~27 hours |
| `MIN_VALIDATOR_ACTIVE_PERIOD` | `uint64(2**8)` (= 256) | epochs | ~27 hours |
| `ETH1_FOLLOW_DISTANCE` | `uint64(2**11)` (= 2,048) | Eth1 blocks | ~8 hours |

### Validator cycle
Expand Down Expand Up @@ -1931,7 +1931,7 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
# Exits must specify an epoch when they become valid; they are not valid before then
assert get_current_epoch(state) >= voluntary_exit.epoch
# Verify the validator has been active long enough
assert get_current_epoch(state) >= validator.activation_epoch + SHARD_COMMITTEE_PERIOD
assert get_current_epoch(state) >= validator.activation_epoch + MIN_VALIDATOR_ACTIVE_PERIOD
# Verify signature
domain = get_domain(state, DOMAIN_VOLUNTARY_EXIT, voluntary_exit.epoch)
signing_root = compute_signing_root(voluntary_exit, domain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ def _exit_validator_from_committee_and_transition_state(spec,
@spec_state_test
@always_bls
def test_sync_committee_with_participating_exited_member(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

# move forward via some blocks
for _ in range(3):
Expand Down Expand Up @@ -590,8 +590,8 @@ def test_sync_committee_with_participating_exited_member(spec, state):
@spec_state_test
@always_bls
def test_sync_committee_with_nonparticipating_exited_member(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

# move forward via some blocks
for _ in range(3):
Expand Down Expand Up @@ -633,8 +633,8 @@ def test_sync_committee_with_nonparticipating_exited_member(spec, state):
@spec_state_test
@always_bls
def test_sync_committee_with_participating_withdrawable_member(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

# move forward via some blocks
for _ in range(3):
Expand Down Expand Up @@ -672,8 +672,8 @@ def test_sync_committee_with_participating_withdrawable_member(spec, state):
@spec_state_test
@always_bls
def test_sync_committee_with_nonparticipating_withdrawable_member(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

# move forward via some blocks
for _ in range(3):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def test_transition_with_deposit_right_before_fork(state, fork_epoch, spec, post
def test_transition_with_voluntary_exit_right_after_fork(state, fork_epoch, spec, post_spec, pre_tag, post_tag):
"""
Create a voluntary exit right *after* the transition.
fork_epoch=66 because minimal preset `SHARD_COMMITTEE_PERIOD` is 64 epochs.
fork_epoch=66 because minimal preset `MIN_VALIDATOR_ACTIVE_PERIOD` is 64 epochs.
"""
# Fast forward to the future epoch so that validator can do voluntary exit
state.slot = spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot = spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

yield from run_transition_with_operation(
state,
Expand All @@ -166,10 +166,10 @@ def test_transition_with_voluntary_exit_right_after_fork(state, fork_epoch, spec
def test_transition_with_voluntary_exit_right_before_fork(state, fork_epoch, spec, post_spec, pre_tag, post_tag):
"""
Create a voluntary exit right *before* the transition.
fork_epoch=66 because minimal preset `SHARD_COMMITTEE_PERIOD` is 64 epochs.
fork_epoch=66 because minimal preset `MIN_VALIDATOR_ACTIVE_PERIOD` is 64 epochs.
"""
# Fast forward to the future epoch so that validator can do voluntary exit
state.slot = spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot = spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

yield from run_transition_with_operation(
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def run_voluntary_exit_processing_test(

voluntary_exit_epoch = 0 if is_before_fork_epoch else state.fork.epoch

# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

current_epoch = spec.get_current_epoch(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def test_deposit_and_bls_change(spec, state):
@with_capella_and_later
@spec_state_test
def test_exit_and_bls_change(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

index = 0
signed_address_change = get_signed_address_change(spec, state, validator_index=index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@with_electra_and_later
@spec_state_test
def test_min_balance_exit(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
# This state has 64 validators each with 32 ETH
current_epoch = spec.get_current_epoch(state)
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch)
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_min_balance_exit(spec, state):
@with_electra_and_later
@spec_state_test
def test_min_balance_exits_up_to_churn(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
# This state has 64 validators each with 32 ETH
single_validator_balance = spec.MIN_ACTIVATION_BALANCE
churn_limit = spec.get_activation_exit_churn_limit(state)
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_min_balance_exits_up_to_churn(spec, state):
@with_electra_and_later
@spec_state_test
def test_min_balance_exits_above_churn(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
# This state has 64 validators each with 32 ETH
single_validator_balance = spec.MIN_ACTIVATION_BALANCE
expected_exit_epoch = spec.compute_activation_exit_epoch(
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_min_balance_exits_above_churn(spec, state):
"With CHURN_LIMIT_QUOTIENT=32, can't change validator balance without changing churn_limit",
)
def test_max_balance_exit(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
churn_limit = spec.get_activation_exit_churn_limit(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_max_balance_exit(spec, state):
"With CHURN_LIMIT_QUOTIENT=32, can't change validator balance without changing churn_limit",
)
def test_exit_with_balance_equal_to_churn_limit(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
churn_limit = spec.get_activation_exit_churn_limit(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_exit_with_balance_equal_to_churn_limit(spec, state):
"With CHURN_LIMIT_QUOTIENT=32, can't change validator balance without changing churn_limit",
)
def test_exit_with_balance_multiple_of_churn_limit(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
churn_limit = spec.get_activation_exit_churn_limit(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down Expand Up @@ -292,7 +292,7 @@ def test_exit_with_balance_multiple_of_churn_limit(spec, state):
"With CHURN_LIMIT_QUOTIENT=32, can't change validator balance without changing churn_limit",
)
def test_exit_existing_churn_and_churn_limit_balance(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
churn_limit = spec.get_activation_exit_churn_limit(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down Expand Up @@ -339,7 +339,7 @@ def test_exit_existing_churn_and_churn_limit_balance(spec, state):
"With CHURN_LIMIT_QUOTIENT=32, can't change validator balance without changing churn_limit",
)
def test_exit_existing_churn_and_balance_multiple_of_churn_limit(spec, state):
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH
current_epoch = spec.get_current_epoch(state)
churn_limit = spec.get_activation_exit_churn_limit(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down Expand Up @@ -386,8 +386,8 @@ def test_exit_existing_churn_and_balance_multiple_of_churn_limit(spec, state):
@with_electra_and_later
@spec_state_test
def test_invalid_validator_has_pending_withdrawal(spec, state):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
# move state forward MIN_VALIDATOR_ACTIVE_PERIOD epochs to allow for exit
state.slot += spec.config.MIN_VALIDATOR_ACTIVE_PERIOD * spec.SLOTS_PER_EPOCH

current_epoch = spec.get_current_epoch(state)
validator_index = spec.get_active_validator_indices(state, current_epoch)[0]
Expand Down
Loading

0 comments on commit bc239e9

Please sign in to comment.