From b35f8fff7410d42b9af911d181569f3dfd66118f Mon Sep 17 00:00:00 2001 From: vbuterin Date: Wed, 2 Sep 2020 12:26:27 +0800 Subject: [PATCH 1/3] Add a constant for slash penalty multiplier Make the multipler on slashed penalties (if portion `p` of validators are slashed each one loses `k*p` an explicit constant). --- specs/phase0/beacon-chain.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/phase0/beacon-chain.md b/specs/phase0/beacon-chain.md index ca7b0b858..c302e46c5 100644 --- a/specs/phase0/beacon-chain.md +++ b/specs/phase0/beacon-chain.md @@ -195,6 +195,7 @@ The following values are (non-configurable) constants used throughout the specif | `HYSTERESIS_QUOTIENT` | `uint64(4)` | | `HYSTERESIS_DOWNWARD_MULTIPLIER` | `uint64(1)` | | `HYSTERESIS_UPWARD_MULTIPLIER` | `uint64(5)` | +| `PROPORTIONAL_SLASHING_MULTIPLIER` | `uint64(3)` | - For the safety of committees, `TARGET_COMMITTEE_SIZE` exceeds [the recommended minimum committee size of 111](http://web.archive.org/web/20190504131341/https://vitalik.ca/files/Ithaca201807_Sharding.pdf); with sufficient active validators (at least `SLOTS_PER_EPOCH * TARGET_COMMITTEE_SIZE`), the shuffling algorithm ensures committee sizes of at least `TARGET_COMMITTEE_SIZE`. (Unbiasable randomness with a Verifiable Delay Function (VDF) will improve committee robustness and lower the safe minimum committee size.) @@ -1557,7 +1558,7 @@ def process_slashings(state: BeaconState) -> None: for index, validator in enumerate(state.validators): if validator.slashed and epoch + EPOCHS_PER_SLASHINGS_VECTOR // 2 == validator.withdrawable_epoch: increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from penalty numerator to avoid uint64 overflow - penalty_numerator = validator.effective_balance // increment * min(sum(state.slashings) * 3, total_balance) + penalty_numerator = validator.effective_balance // increment * min(sum(state.slashings) * PROPORTIONAL_SLASHING_MULTIPLIER, total_balance) penalty = penalty_numerator // total_balance * increment decrease_balance(state, ValidatorIndex(index), penalty) ``` From eed2df37f422ac036e7470bfa1267fe5389e9b49 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 3 Sep 2020 17:27:20 +0800 Subject: [PATCH 2/3] Make linter happy --- specs/phase0/beacon-chain.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/phase0/beacon-chain.md b/specs/phase0/beacon-chain.md index c302e46c5..62c75b045 100644 --- a/specs/phase0/beacon-chain.md +++ b/specs/phase0/beacon-chain.md @@ -1555,10 +1555,11 @@ def process_registry_updates(state: BeaconState) -> None: def process_slashings(state: BeaconState) -> None: epoch = get_current_epoch(state) total_balance = get_total_active_balance(state) + adjusted_total_slashing_balance = min(sum(state.slashings) * PROPORTIONAL_SLASHING_MULTIPLIER, total_balance) for index, validator in enumerate(state.validators): if validator.slashed and epoch + EPOCHS_PER_SLASHINGS_VECTOR // 2 == validator.withdrawable_epoch: increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from penalty numerator to avoid uint64 overflow - penalty_numerator = validator.effective_balance // increment * min(sum(state.slashings) * PROPORTIONAL_SLASHING_MULTIPLIER, total_balance) + penalty_numerator = validator.effective_balance // increment * adjusted_total_slashing_balance penalty = penalty_numerator // total_balance * increment decrease_balance(state, ValidatorIndex(index), penalty) ``` From c995da420e1e73eda78894d31838eaff1fb947d2 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 3 Sep 2020 21:39:00 +0800 Subject: [PATCH 3/3] Update config files --- configs/mainnet/phase0.yaml | 2 ++ configs/minimal/phase0.yaml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configs/mainnet/phase0.yaml b/configs/mainnet/phase0.yaml index 616baaf34..48a479d80 100644 --- a/configs/mainnet/phase0.yaml +++ b/configs/mainnet/phase0.yaml @@ -27,6 +27,8 @@ HYSTERESIS_QUOTIENT: 4 HYSTERESIS_DOWNWARD_MULTIPLIER: 1 # 5 (plus 1.25) HYSTERESIS_UPWARD_MULTIPLIER: 5 +# 3 +PROPORTIONAL_SLASHING_MULTIPLIER: 3 # Fork Choice diff --git a/configs/minimal/phase0.yaml b/configs/minimal/phase0.yaml index 78cd60177..02afa369c 100644 --- a/configs/minimal/phase0.yaml +++ b/configs/minimal/phase0.yaml @@ -26,7 +26,8 @@ HYSTERESIS_QUOTIENT: 4 HYSTERESIS_DOWNWARD_MULTIPLIER: 1 # 5 (plus 1.25) HYSTERESIS_UPWARD_MULTIPLIER: 5 - +# 3 +PROPORTIONAL_SLASHING_MULTIPLIER: 3 # Fork Choice