Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions specs/_features/eip8148/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def get_validators_sweep_withdrawals(
amount=balance,
)
)
withdrawal_index += WithdrawalIndex(1)
withdrawal_index += 1
# [Modified in EIP8148]
elif is_partially_withdrawable_validator(validator, balance, sweep_threshold):
withdrawals.append(
Expand All @@ -434,9 +434,9 @@ def get_validators_sweep_withdrawals(
amount=balance - get_effective_sweep_threshold(validator, sweep_threshold),
)
)
withdrawal_index += WithdrawalIndex(1)
withdrawal_index += 1

validator_index = ValidatorIndex((validator_index + 1) % len(state.validators))
validator_index = (validator_index + 1) % len(state.validators)
processed_count += 1

return withdrawals, withdrawal_index, processed_count
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip8205/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def process_preregistration_request(state: BeaconState, request: Preregistration
preregistration = StoredPreregistration(
pubkey=pubkey,
withdrawal_credentials=request.withdrawal_credentials,
expiry_slot=Slot(state.slot + PREREGISTRATION_EXPIRY_SLOTS),
expiry_slot=state.slot + PREREGISTRATION_EXPIRY_SLOTS,
)
index = get_stored_preregistration_index(state, pubkey)
if index is not None:
Expand Down
4 changes: 2 additions & 2 deletions specs/_features/eip8321/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ from the front.

```python
def process_pending_randao_commitments(state: BeaconState) -> None:
next_epoch = Epoch(get_current_epoch(state) + 1)
next_epoch = get_current_epoch(state) + 1
next_pending_commitment = 0
for pending_commitment in state.pending_randao_commitments:
if pending_commitment.activation_epoch > next_epoch:
Expand Down Expand Up @@ -503,7 +503,7 @@ def process_randao_commitment_registration(
PendingRandaoCommitment(
validator_index=index,
commitment=registration.commitment,
activation_epoch=Epoch(get_current_epoch(state) + COMMITMENT_REGISTRATION_DELAY),
activation_epoch=get_current_epoch(state) + COMMITMENT_REGISTRATION_DELAY,
)
)
```
32 changes: 15 additions & 17 deletions specs/altair/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def get_next_sync_committee_indices(state: BeaconState) -> Sequence[ValidatorInd
"""
Return the sync committee indices, with possible duplicates, for the next sync committee.
"""
epoch = Epoch(get_current_epoch(state) + 1)
epoch = get_current_epoch(state) + 1

MAX_RANDOM_BYTE = 2**8 - 1
active_validator_indices = get_active_validator_indices(state, epoch)
Expand Down Expand Up @@ -388,7 +388,7 @@ def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
Return the base reward for the validator defined by ``index`` with respect to the current ``state``.
"""
increments = state.validators[index].effective_balance // EFFECTIVE_BALANCE_INCREMENT
return Gwei(increments * get_base_reward_per_increment(state))
return increments * get_base_reward_per_increment(state)
```

#### `get_unslashed_participating_indices`
Expand Down Expand Up @@ -477,9 +477,9 @@ def get_flag_index_deltas(
if index in unslashed_participating_indices:
if not is_in_inactivity_leak(state):
reward_numerator = base_reward * weight * unslashed_participating_increments
rewards[index] += Gwei(reward_numerator // (active_increments * WEIGHT_DENOMINATOR))
rewards[index] += reward_numerator // (active_increments * WEIGHT_DENOMINATOR)
elif flag_index != TIMELY_HEAD_FLAG_INDEX:
penalties[index] += Gwei(base_reward * weight // WEIGHT_DENOMINATOR)
penalties[index] += base_reward * weight // WEIGHT_DENOMINATOR
return rewards, penalties
```

Expand All @@ -502,7 +502,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
state.validators[index].effective_balance * state.inactivity_scores[index]
)
penalty_denominator = INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_ALTAIR
penalties[index] += Gwei(penalty_numerator // penalty_denominator)
penalties[index] += penalty_numerator // penalty_denominator
return rewards, penalties
```

Expand All @@ -528,7 +528,7 @@ def slash_validator(
validator = state.validators[slashed_index]
validator.slashed = Boolean(True)
validator.withdrawable_epoch = max(
validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR)
validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR
)
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
decrease_balance(
Expand All @@ -539,10 +539,10 @@ def slash_validator(
proposer_index = get_beacon_proposer_index(state)
if whistleblower_index is None:
whistleblower_index = proposer_index
whistleblower_reward = Gwei(validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT)
proposer_reward = Gwei(whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR)
whistleblower_reward = validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT
proposer_reward = whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR
increase_balance(state, proposer_index, proposer_reward)
increase_balance(state, whistleblower_index, Gwei(whistleblower_reward - proposer_reward))
increase_balance(state, whistleblower_index, whistleblower_reward - proposer_reward)
```

### Block processing
Expand Down Expand Up @@ -661,7 +661,7 @@ def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) ->
)
if bit
]
previous_slot = max(state.slot, Slot(1)) - Slot(1)
previous_slot = max(state.slot, Slot(1)) - 1
domain = get_domain(state, DOMAIN_SYNC_COMMITTEE, compute_epoch_at_slot(previous_slot))
signing_root = compute_signing_root(get_block_root_at_slot(state, previous_slot), domain)
# Note: eth_fast_aggregate_verify works with a singleton list containing an aggregated key
Expand All @@ -671,14 +671,12 @@ def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) ->

# Compute participant and proposer rewards
total_active_increments = get_total_active_balance(state) // EFFECTIVE_BALANCE_INCREMENT
total_base_rewards = Gwei(get_base_reward_per_increment(state) * total_active_increments)
max_participant_rewards = Gwei(
total_base_rewards = get_base_reward_per_increment(state) * total_active_increments
max_participant_rewards = (
total_base_rewards * SYNC_REWARD_WEIGHT // WEIGHT_DENOMINATOR // Uint64(SLOTS_PER_EPOCH)
)
participant_reward = Gwei(max_participant_rewards // SYNC_COMMITTEE_SIZE)
proposer_reward = Gwei(
participant_reward * PROPOSER_WEIGHT // (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
)
participant_reward = max_participant_rewards // SYNC_COMMITTEE_SIZE
proposer_reward = participant_reward * PROPOSER_WEIGHT // (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)

# Apply participant and proposer rewards
all_pubkeys = [v.pubkey for v in state.validators]
Expand Down Expand Up @@ -836,7 +834,7 @@ def process_participation_flag_updates(state: BeaconState) -> None:

```python
def process_sync_committee_updates(state: BeaconState) -> None:
next_epoch = get_current_epoch(state) + Epoch(1)
next_epoch = get_current_epoch(state) + 1
if next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
state.current_sync_committee = state.next_sync_committee
state.next_sync_committee = get_next_sync_committee(state)
Expand Down
2 changes: 1 addition & 1 deletion specs/altair/light-client/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def validate_light_client_update(
)
if bit
]
fork_version_slot = max(update.signature_slot, Slot(1)) - Slot(1)
fork_version_slot = max(update.signature_slot, Slot(1)) - 1
fork_version = compute_fork_version(compute_epoch_at_slot(fork_version_slot))
domain = compute_domain(DOMAIN_SYNC_COMMITTEE, fork_version, genesis_validators_root)
signing_root = compute_signing_root(update.attested_header.beacon, domain)
Expand Down
2 changes: 1 addition & 1 deletion specs/altair/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_sync_subcommittee_pubkeys(
) -> Sequence[BLSPubkey]:
# Committees assigned to `slot` sign for `slot - 1`
# This creates the exceptional logic below when transitioning between sync committee periods
next_slot_epoch = compute_epoch_at_slot(Slot(state.slot + 1))
next_slot_epoch = compute_epoch_at_slot(state.slot + 1)
if compute_sync_committee_period(get_current_epoch(state)) == compute_sync_committee_period(
next_slot_epoch
):
Expand Down
2 changes: 1 addition & 1 deletion specs/altair/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ subcommittees.
def compute_subnets_for_sync_committee(
state: BeaconState, validator_index: ValidatorIndex
) -> Set[SubnetID]:
next_slot_epoch = compute_epoch_at_slot(Slot(state.slot + 1))
next_slot_epoch = compute_epoch_at_slot(state.slot + 1)
if compute_sync_committee_period(get_current_epoch(state)) == compute_sync_committee_period(
next_slot_epoch
):
Expand Down
10 changes: 5 additions & 5 deletions specs/bellatrix/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
)
# [Modified in Bellatrix]
penalty_denominator = INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_BELLATRIX
penalties[index] += Gwei(penalty_numerator // penalty_denominator)
penalties[index] += penalty_numerator // penalty_denominator
return rewards, penalties
```

Expand All @@ -325,7 +325,7 @@ def slash_validator(
validator = state.validators[slashed_index]
validator.slashed = Boolean(True)
validator.withdrawable_epoch = max(
validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR)
validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR
)
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
# [Modified in Bellatrix]
Expand All @@ -336,10 +336,10 @@ def slash_validator(
proposer_index = get_beacon_proposer_index(state)
if whistleblower_index is None:
whistleblower_index = proposer_index
whistleblower_reward = Gwei(validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT)
proposer_reward = Gwei(whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR)
whistleblower_reward = validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT
proposer_reward = whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR
increase_balance(state, proposer_index, proposer_reward)
increase_balance(state, whistleblower_index, Gwei(whistleblower_reward - proposer_reward))
increase_balance(state, whistleblower_index, whistleblower_reward - proposer_reward)
```

## Beacon chain state transition function
Expand Down
16 changes: 7 additions & 9 deletions specs/capella/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def process_epoch(state: BeaconState) -> None:
```python
def process_historical_summaries_update(state: BeaconState) -> None:
# Set historical block root accumulator.
next_epoch = Epoch(get_current_epoch(state) + 1)
next_epoch = get_current_epoch(state) + 1
if next_epoch % Uint64(SLOTS_PER_HISTORICAL_ROOT // SLOTS_PER_EPOCH) == 0:
historical_summary = HistoricalSummary(
block_summary_root=hash_tree_root(state.block_roots),
Expand Down Expand Up @@ -455,7 +455,7 @@ def get_validators_sweep_withdrawals(
amount=balance,
)
)
withdrawal_index += WithdrawalIndex(1)
withdrawal_index += 1
elif is_partially_withdrawable_validator(validator, balance):
withdrawals.append(
Withdrawal(
Expand All @@ -465,9 +465,9 @@ def get_validators_sweep_withdrawals(
amount=balance - MAX_EFFECTIVE_BALANCE,
)
)
withdrawal_index += WithdrawalIndex(1)
withdrawal_index += 1

validator_index = ValidatorIndex((validator_index + 1) % len(state.validators))
validator_index = (validator_index + 1) % len(state.validators)
processed_count += 1

return withdrawals, withdrawal_index, processed_count
Expand Down Expand Up @@ -507,7 +507,7 @@ def update_next_withdrawal_index(state: BeaconState, withdrawals: Sequence[Withd
# Update the next withdrawal index if this block contained withdrawals
if len(withdrawals) != 0:
latest_withdrawal = withdrawals[-1]
state.next_withdrawal_index = WithdrawalIndex(latest_withdrawal.index + 1)
state.next_withdrawal_index = latest_withdrawal.index + 1
```

#### New `update_next_withdrawal_validator_index`
Expand All @@ -519,14 +519,12 @@ def update_next_withdrawal_validator_index(
# Update the next validator index to start the next withdrawal sweep
if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD:
# Next sweep starts after the latest withdrawal's validator index
next_validator_index = ValidatorIndex(
(withdrawals[-1].validator_index + 1) % len(state.validators)
)
next_validator_index = (withdrawals[-1].validator_index + 1) % len(state.validators)
state.next_withdrawal_validator_index = next_validator_index
else:
# Advance sweep by the max length of the sweep if there was not a full set of withdrawals
next_index = state.next_withdrawal_validator_index + MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP
next_validator_index = ValidatorIndex(next_index % len(state.validators))
next_validator_index = next_index % len(state.validators)
state.next_withdrawal_validator_index = next_validator_index
```

Expand Down
4 changes: 2 additions & 2 deletions specs/deneb/light-client/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def is_valid_light_client_header(header: LightClientHeader) -> bool:

# [New in Deneb:EIP4844]
if epoch < DENEB_FORK_EPOCH:
if header.execution.blob_gas_used != Uint64(0):
if header.execution.blob_gas_used != 0:
return False
if header.execution.excess_blob_gas != Uint64(0):
if header.execution.excess_blob_gas != 0:
return False

if epoch < CAPELLA_FORK_EPOCH:
Expand Down
4 changes: 2 additions & 2 deletions specs/deneb/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def is_current_or_previous_epoch(
(with MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance).
"""
is_current = is_within_epoch(store, epoch, current_time_ms)
is_previous = is_within_epoch(store, Epoch(epoch + 1), current_time_ms)
is_previous = is_within_epoch(store, epoch + 1, current_time_ms)
return is_current or is_previous
```

Expand All @@ -244,7 +244,7 @@ def compute_max_request_blob_sidecars() -> Uint64:
"""
Return the maximum number of blob sidecars in a single request.
"""
return Uint64(MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK)
return MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
```

### New `verify_blob_sidecar_inclusion_proof`
Expand Down
Loading