Change to 2**14 epoch (73 day) custody periods as per #1888
This commit is contained in:
parent
42a9f1afdf
commit
f6d7dac30c
|
@ -196,19 +196,20 @@ GASPRICE_ADJUSTMENT_COEFFICIENT: 8
|
||||||
# Phase 1: Custody Game
|
# Phase 1: Custody Game
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
|
# 1/1024 chance of custody bit 1
|
||||||
|
CUSTODY_PROBABILITY_EXPONENT: 10
|
||||||
|
|
||||||
# Time parameters
|
# Time parameters
|
||||||
# 2**1 (= 2) epochs, 12.8 minutes
|
# 2**1 (= 2) epochs, 12.8 minutes
|
||||||
RANDAO_PENALTY_EPOCHS: 2
|
RANDAO_PENALTY_EPOCHS: 2
|
||||||
|
# 2**15 (= 32,768) epochs, ~146 days
|
||||||
|
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 32768
|
||||||
# 2**14 (= 16,384) epochs ~73 days
|
# 2**14 (= 16,384) epochs ~73 days
|
||||||
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 16384
|
EPOCHS_PER_CUSTODY_PERIOD: 16384
|
||||||
# 2**11 (= 2,048) epochs, ~9 days
|
|
||||||
EPOCHS_PER_CUSTODY_PERIOD: 2048
|
|
||||||
# 2**11 (= 2,048) epochs, ~9 days
|
# 2**11 (= 2,048) epochs, ~9 days
|
||||||
CUSTODY_PERIOD_TO_RANDAO_PADDING: 2048
|
CUSTODY_PERIOD_TO_RANDAO_PADDING: 2048
|
||||||
# 2**7 (= 128) epochs, ~14 hours
|
# 2**15 (= 32,768) epochs, ~146 days
|
||||||
MAX_REVEAL_LATENESS_DECREMENT: 128
|
MAX_CHUNK_CHALLENGE_DELAY: 32768
|
||||||
# 2**14 (= 16,384) epochs
|
|
||||||
CUSTODY_RESPONSE_DEADLINE: 16384
|
|
||||||
|
|
||||||
# Max operations
|
# Max operations
|
||||||
# 2**8 (= 256)
|
# 2**8 (= 256)
|
||||||
|
|
|
@ -199,17 +199,20 @@ GASPRICE_ADJUSTMENT_COEFFICIENT: 8
|
||||||
# Phase 1: Custody Game
|
# Phase 1: Custody Game
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
|
# 1/1024 chance of custody bit 1 [customized for faster testing]
|
||||||
|
CUSTODY_PROBABILITY_EXPONENT: 2
|
||||||
|
|
||||||
# Time parameters
|
# Time parameters
|
||||||
# 2**1 (= 2) epochs
|
# 2**1 (= 2) epochs
|
||||||
RANDAO_PENALTY_EPOCHS: 2
|
RANDAO_PENALTY_EPOCHS: 2
|
||||||
# [customized] quicker for testing
|
# 2**15 (= 32,768) epochs, ~146 days [customized for faster testing]
|
||||||
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 4096
|
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 128
|
||||||
# 2**11 (= 2,048) epochs
|
# 2**14 (= 16,384) epochs ~73 days [customized for faster testing]
|
||||||
EPOCHS_PER_CUSTODY_PERIOD: 8
|
EPOCHS_PER_CUSTODY_PERIOD: 64
|
||||||
# 2**11 (= 2,048) epochs
|
# 2**11 (= 2,048) epochs, ~9 days [customized for faster testing]
|
||||||
CUSTODY_PERIOD_TO_RANDAO_PADDING: 8
|
CUSTODY_PERIOD_TO_RANDAO_PADDING: 16
|
||||||
# 2**14 (= 16,384) epochs
|
# 2**15 (= 32,768) epochs, ~146 days
|
||||||
CUSTODY_RESPONSE_DEADLINE: 32
|
MAX_CHUNK_CHALLENGE_DELAY: 128
|
||||||
|
|
||||||
# Max operations
|
# Max operations
|
||||||
# 2**8 (= 256)
|
# 2**8 (= 256)
|
||||||
|
|
|
@ -69,12 +69,11 @@ This document details the beacon chain additions and changes in Phase 1 of Ether
|
||||||
| Name | Value | Unit | Duration |
|
| Name | Value | Unit | Duration |
|
||||||
| - | - | :-: | :-: |
|
| - | - | :-: | :-: |
|
||||||
| `RANDAO_PENALTY_EPOCHS` | `2**1` (= 2) | epochs | 12.8 minutes |
|
| `RANDAO_PENALTY_EPOCHS` | `2**1` (= 2) | epochs | 12.8 minutes |
|
||||||
| `EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS` | `2**14` (= 16,384) | epochs | ~73 days |
|
| `EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS` | `2**15` (= 32,768) | epochs | ~146 days |
|
||||||
| `EPOCHS_PER_CUSTODY_PERIOD` | `2**11` (= 2,048) | epochs | ~9 days |
|
| `EPOCHS_PER_CUSTODY_PERIOD` | `2**14` (= 16,384) | epochs | ~73 days |
|
||||||
| `CUSTODY_PERIOD_TO_RANDAO_PADDING` | `2**11` (= 2,048) | epochs | ~9 days |
|
| `CUSTODY_PERIOD_TO_RANDAO_PADDING` | `2**11` (= 2,048) | epochs | ~9 days |
|
||||||
| `CHUNK_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days |
|
| `CHUNK_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days |
|
||||||
| `MAX_CHUNK_CHALLENGE_DELAY` | `2**11` (= 2,048) | epochs | ~9 days |
|
| `MAX_CHUNK_CHALLENGE_DELAY` | `2**15` (= 32,768) | epochs | ~146 days |
|
||||||
| `CUSTODY_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days |
|
|
||||||
|
|
||||||
### Max operations per block
|
### Max operations per block
|
||||||
|
|
||||||
|
@ -571,7 +570,7 @@ def process_custody_slashing(state: BeaconState, signed_custody_slashing: Signed
|
||||||
def process_reveal_deadlines(state: BeaconState) -> None:
|
def process_reveal_deadlines(state: BeaconState) -> None:
|
||||||
epoch = get_current_epoch(state)
|
epoch = get_current_epoch(state)
|
||||||
for index, validator in enumerate(state.validators):
|
for index, validator in enumerate(state.validators):
|
||||||
deadline = validator.next_custody_secret_to_reveal + (CUSTODY_RESPONSE_DEADLINE // EPOCHS_PER_CUSTODY_PERIOD)
|
deadline = validator.next_custody_secret_to_reveal + 1
|
||||||
if get_custody_period_for_validator(ValidatorIndex(index), epoch) > deadline:
|
if get_custody_period_for_validator(ValidatorIndex(index), epoch) > deadline:
|
||||||
slash_validator(state, ValidatorIndex(index))
|
slash_validator(state, ValidatorIndex(index))
|
||||||
```
|
```
|
||||||
|
@ -579,7 +578,7 @@ def process_reveal_deadlines(state: BeaconState) -> None:
|
||||||
```python
|
```python
|
||||||
def process_challenge_deadlines(state: BeaconState) -> None:
|
def process_challenge_deadlines(state: BeaconState) -> None:
|
||||||
for custody_chunk_challenge in state.custody_chunk_challenge_records:
|
for custody_chunk_challenge in state.custody_chunk_challenge_records:
|
||||||
if get_current_epoch(state) > custody_chunk_challenge.inclusion_epoch + CUSTODY_RESPONSE_DEADLINE:
|
if get_current_epoch(state) > custody_chunk_challenge.inclusion_epoch + EPOCHS_PER_CUSTODY_PERIOD:
|
||||||
slash_validator(state, custody_chunk_challenge.responder_index, custody_chunk_challenge.challenger_index)
|
slash_validator(state, custody_chunk_challenge.responder_index, custody_chunk_challenge.challenger_index)
|
||||||
index_in_records = state.custody_chunk_challenge_records.index(custody_chunk_challenge)
|
index_in_records = state.custody_chunk_challenge_records.index(custody_chunk_challenge)
|
||||||
state.custody_chunk_challenge_records[index_in_records] = CustodyChunkChallengeRecord()
|
state.custody_chunk_challenge_records[index_in_records] = CustodyChunkChallengeRecord()
|
||||||
|
|
|
@ -147,7 +147,7 @@ def test_multiple_epochs_custody(spec, state):
|
||||||
@with_all_phases_except(['phase0'])
|
@with_all_phases_except(['phase0'])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_many_epochs_custody(spec, state):
|
def test_many_epochs_custody(spec, state):
|
||||||
transition_to(spec, state, state.slot + spec.SLOTS_PER_EPOCH * 20)
|
transition_to(spec, state, state.slot + spec.SLOTS_PER_EPOCH * 10)
|
||||||
shard = 0
|
shard = 0
|
||||||
offset_slots = spec.get_offset_slots(state, shard)
|
offset_slots = spec.get_offset_slots(state, shard)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from eth2spec.test.helpers.custody import (
|
from eth2spec.test.helpers.custody import (
|
||||||
get_valid_chunk_challenge,
|
get_valid_chunk_challenge,
|
||||||
get_shard_transition,
|
get_shard_transition,
|
||||||
get_valid_custody_key_reveal,
|
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.attestations import (
|
from eth2spec.test.helpers.attestations import (
|
||||||
get_valid_on_time_attestation,
|
get_valid_on_time_attestation,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.state import next_epoch_via_block, transition_to
|
from eth2spec.test.helpers.state import transition_to
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
with_all_phases_except,
|
with_all_phases_except,
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
|
@ -17,7 +16,6 @@ from eth2spec.test.phase_0.epoch_processing.run_epoch_process_base import run_ep
|
||||||
from eth2spec.test.phase_1.block_processing.test_process_chunk_challenge import (
|
from eth2spec.test.phase_1.block_processing.test_process_chunk_challenge import (
|
||||||
run_chunk_challenge_processing,
|
run_chunk_challenge_processing,
|
||||||
)
|
)
|
||||||
from eth2spec.test.phase_1.block_processing.test_process_custody_key_reveal import run_custody_key_reveal_processing
|
|
||||||
|
|
||||||
|
|
||||||
def run_process_challenge_deadlines(spec, state):
|
def run_process_challenge_deadlines(spec, state):
|
||||||
|
@ -44,32 +42,15 @@ def test_validator_slashed_after_chunk_challenge(spec, state):
|
||||||
attestation.data.index
|
attestation.data.index
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
spec.initiate_validator_exit(state, validator_index)
|
|
||||||
assert state.validators[validator_index].withdrawable_epoch < spec.FAR_FUTURE_EPOCH
|
|
||||||
|
|
||||||
transition_to(spec, state, state.slot + spec.SLOTS_PER_EPOCH)
|
|
||||||
|
|
||||||
assert state.validators[validator_index].withdrawable_epoch == spec.FAR_FUTURE_EPOCH
|
|
||||||
|
|
||||||
while spec.get_current_epoch(state) < state.validators[validator_index].exit_epoch:
|
|
||||||
next_epoch_via_block(spec, state)
|
|
||||||
while (state.validators[validator_index].next_custody_secret_to_reveal
|
|
||||||
<= spec.get_custody_period_for_validator(
|
|
||||||
validator_index,
|
|
||||||
state.validators[validator_index].exit_epoch - 1)):
|
|
||||||
custody_key_reveal = get_valid_custody_key_reveal(spec, state, validator_index=validator_index)
|
|
||||||
_, _, _ = run_custody_key_reveal_processing(spec, state, custody_key_reveal)
|
|
||||||
|
|
||||||
next_epoch_via_block(spec, state)
|
|
||||||
|
|
||||||
challenge = get_valid_chunk_challenge(spec, state, attestation, shard_transition)
|
challenge = get_valid_chunk_challenge(spec, state, attestation, shard_transition)
|
||||||
|
|
||||||
_, _, _ = run_chunk_challenge_processing(spec, state, challenge)
|
_, _, _ = run_chunk_challenge_processing(spec, state, challenge)
|
||||||
|
|
||||||
assert state.validators[validator_index].slashed == 0
|
assert state.validators[validator_index].slashed == 0
|
||||||
|
|
||||||
transition_to(spec, state, state.slot + (spec.CUSTODY_RESPONSE_DEADLINE +
|
transition_to(spec, state, state.slot + spec.MAX_CHUNK_CHALLENGE_DELAY * spec.SLOTS_PER_EPOCH)
|
||||||
spec.EPOCHS_PER_CUSTODY_PERIOD) * spec.SLOTS_PER_EPOCH)
|
|
||||||
|
state.validators[validator_index].slashed = 0
|
||||||
|
|
||||||
yield from run_process_challenge_deadlines(spec, state)
|
yield from run_process_challenge_deadlines(spec, state)
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,13 @@ def run_process_challenge_deadlines(spec, state):
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_validator_slashed_after_reveal_deadline(spec, state):
|
def test_validator_slashed_after_reveal_deadline(spec, state):
|
||||||
assert state.validators[0].slashed == 0
|
assert state.validators[0].slashed == 0
|
||||||
|
|
||||||
transition_to(spec, state, spec.get_randao_epoch_for_custody_period(0, 0) * spec.SLOTS_PER_EPOCH)
|
transition_to(spec, state, spec.get_randao_epoch_for_custody_period(0, 0) * spec.SLOTS_PER_EPOCH)
|
||||||
|
|
||||||
transition_to(spec, state, state.slot + ((spec.CUSTODY_RESPONSE_DEADLINE)
|
# Need to run at least one reveal so that not all validators are slashed (otherwise spec fails to find proposers)
|
||||||
* spec.SLOTS_PER_EPOCH))
|
custody_key_reveal = get_valid_custody_key_reveal(spec, state, validator_index=1)
|
||||||
|
_, _, _ = run_custody_key_reveal_processing(spec, state, custody_key_reveal)
|
||||||
|
|
||||||
|
transition_to(spec, state, state.slot + spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH)
|
||||||
|
|
||||||
state.validators[0].slashed = 0
|
state.validators[0].slashed = 0
|
||||||
|
|
||||||
|
@ -34,15 +36,14 @@ def test_validator_slashed_after_reveal_deadline(spec, state):
|
||||||
@with_all_phases_except(['phase0'])
|
@with_all_phases_except(['phase0'])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_validator_not_slashed_after_reveal(spec, state):
|
def test_validator_not_slashed_after_reveal(spec, state):
|
||||||
state.slot += spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH
|
transition_to(spec, state, spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH)
|
||||||
custody_key_reveal = get_valid_custody_key_reveal(spec, state)
|
custody_key_reveal = get_valid_custody_key_reveal(spec, state)
|
||||||
|
|
||||||
_, _, _ = run_custody_key_reveal_processing(spec, state, custody_key_reveal)
|
_, _, _ = run_custody_key_reveal_processing(spec, state, custody_key_reveal)
|
||||||
|
|
||||||
assert state.validators[0].slashed == 0
|
assert state.validators[0].slashed == 0
|
||||||
|
|
||||||
transition_to(spec, state, state.slot + ((spec.CUSTODY_RESPONSE_DEADLINE)
|
transition_to(spec, state, state.slot + spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH)
|
||||||
* spec.SLOTS_PER_EPOCH))
|
|
||||||
|
|
||||||
yield from run_process_challenge_deadlines(spec, state)
|
yield from run_process_challenge_deadlines(spec, state)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue