Merge branch 'dev' into list-rework
This commit is contained in:
commit
16093eb8ce
7
Makefile
7
Makefile
|
@ -59,10 +59,9 @@ open_cov:
|
||||||
|
|
||||||
lint: $(PY_SPEC_ALL_TARGETS)
|
lint: $(PY_SPEC_ALL_TARGETS)
|
||||||
cd $(PY_SPEC_DIR); . venv/bin/activate; \
|
cd $(PY_SPEC_DIR); . venv/bin/activate; \
|
||||||
flake8 --ignore=E252,W504,W503 --max-line-length=120 ./eth2spec; \
|
flake8 --ignore=E252,W504,W503 --max-line-length=120 ./eth2spec \
|
||||||
cd ./eth2spec; \
|
&& cd ./eth2spec && mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs -p phase0 \
|
||||||
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs -p phase0; \
|
&& mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs -p phase1;
|
||||||
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs -p phase1
|
|
||||||
|
|
||||||
install_deposit_contract_test: $(PY_SPEC_ALL_TARGETS)
|
install_deposit_contract_test: $(PY_SPEC_ALL_TARGETS)
|
||||||
cd $(DEPOSIT_CONTRACT_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements-testing.txt
|
cd $(DEPOSIT_CONTRACT_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements-testing.txt
|
||||||
|
|
|
@ -531,9 +531,9 @@ class BeaconState(Container):
|
||||||
# Shuffling
|
# Shuffling
|
||||||
start_shard: Shard
|
start_shard: Shard
|
||||||
randao_mixes: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR]
|
randao_mixes: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR]
|
||||||
active_index_roots: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR] # Digests of the active registry, for light clients
|
active_index_roots: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR] # Active registry digests for light clients
|
||||||
# Slashings
|
# Slashings
|
||||||
slashed_balances: Vector[Gwei, EPOCHS_PER_SLASHED_BALANCES_VECTOR] # Sums of the slashed effective balances
|
slashed_balances: Vector[Gwei, EPOCHS_PER_SLASHED_BALANCES_VECTOR] # Sums of slashed effective balances
|
||||||
# Attestations
|
# Attestations
|
||||||
previous_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
previous_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
||||||
current_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
current_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
||||||
|
@ -1516,17 +1516,16 @@ def process_registry_updates(state: BeaconState) -> None:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def process_slashings(state: BeaconState) -> None:
|
def process_slashings(state: BeaconState) -> None:
|
||||||
current_epoch = get_current_epoch(state)
|
epoch = get_current_epoch(state)
|
||||||
total_balance = get_total_active_balance(state)
|
total_balance = get_total_active_balance(state)
|
||||||
|
|
||||||
# Compute slashed balances in the current epoch
|
# Compute slashed balances in the current epoch
|
||||||
total_at_start = state.slashed_balances[(current_epoch + 1) % EPOCHS_PER_SLASHED_BALANCES_VECTOR]
|
total_at_start = state.slashed_balances[(epoch + 1) % EPOCHS_PER_SLASHED_BALANCES_VECTOR]
|
||||||
total_at_end = state.slashed_balances[current_epoch % EPOCHS_PER_SLASHED_BALANCES_VECTOR]
|
total_at_end = state.slashed_balances[epoch % EPOCHS_PER_SLASHED_BALANCES_VECTOR]
|
||||||
total_penalties = total_at_end - total_at_start
|
total_penalties = total_at_end - total_at_start
|
||||||
|
|
||||||
for index, validator in enumerate(state.validators):
|
for index, validator in enumerate(state.validators):
|
||||||
if validator.slashed and current_epoch == (
|
if validator.slashed and epoch + EPOCHS_PER_SLASHED_BALANCES_VECTOR // 2 == validator.withdrawable_epoch:
|
||||||
validator.withdrawable_epoch - EPOCHS_PER_SLASHED_BALANCES_VECTOR // 2):
|
|
||||||
penalty = max(
|
penalty = max(
|
||||||
validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance,
|
validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance,
|
||||||
validator.effective_balance // MIN_SLASHING_PENALTY_QUOTIENT
|
validator.effective_balance // MIN_SLASHING_PENALTY_QUOTIENT
|
||||||
|
|
Loading…
Reference in New Issue