Skip to content

Commit bf2e898

Browse files
authored
Merge branch 'master' into eip8025-clean-up
2 parents bbc7d16 + 566e1eb commit bf2e898

30 files changed

Lines changed: 140 additions & 152 deletions

specs/_features/eip8148/beacon-chain.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def get_validators_sweep_withdrawals(
422422
amount=balance,
423423
)
424424
)
425-
withdrawal_index += WithdrawalIndex(1)
425+
withdrawal_index += 1
426426
# [Modified in EIP8148]
427427
elif is_partially_withdrawable_validator(validator, balance, sweep_threshold):
428428
withdrawals.append(
@@ -434,9 +434,9 @@ def get_validators_sweep_withdrawals(
434434
amount=balance - get_effective_sweep_threshold(validator, sweep_threshold),
435435
)
436436
)
437-
withdrawal_index += WithdrawalIndex(1)
437+
withdrawal_index += 1
438438

439-
validator_index = ValidatorIndex((validator_index + 1) % len(state.validators))
439+
validator_index = (validator_index + 1) % len(state.validators)
440440
processed_count += 1
441441

442442
return withdrawals, withdrawal_index, processed_count

specs/_features/eip8205/beacon-chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def process_preregistration_request(state: BeaconState, request: Preregistration
416416
preregistration = StoredPreregistration(
417417
pubkey=pubkey,
418418
withdrawal_credentials=request.withdrawal_credentials,
419-
expiry_slot=Slot(state.slot + PREREGISTRATION_EXPIRY_SLOTS),
419+
expiry_slot=state.slot + PREREGISTRATION_EXPIRY_SLOTS,
420420
)
421421
index = get_stored_preregistration_index(state, pubkey)
422422
if index is not None:

specs/_features/eip8321/beacon-chain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ from the front.
369369

370370
```python
371371
def process_pending_randao_commitments(state: BeaconState) -> None:
372-
next_epoch = Epoch(get_current_epoch(state) + 1)
372+
next_epoch = get_current_epoch(state) + 1
373373
next_pending_commitment = 0
374374
for pending_commitment in state.pending_randao_commitments:
375375
if pending_commitment.activation_epoch > next_epoch:
@@ -503,7 +503,7 @@ def process_randao_commitment_registration(
503503
PendingRandaoCommitment(
504504
validator_index=index,
505505
commitment=registration.commitment,
506-
activation_epoch=Epoch(get_current_epoch(state) + COMMITMENT_REGISTRATION_DELAY),
506+
activation_epoch=get_current_epoch(state) + COMMITMENT_REGISTRATION_DELAY,
507507
)
508508
)
509509
```

specs/altair/beacon-chain.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def get_next_sync_committee_indices(state: BeaconState) -> Sequence[ValidatorInd
325325
"""
326326
Return the sync committee indices, with possible duplicates, for the next sync committee.
327327
"""
328-
epoch = Epoch(get_current_epoch(state) + 1)
328+
epoch = get_current_epoch(state) + 1
329329

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

394394
#### `get_unslashed_participating_indices`
@@ -477,9 +477,9 @@ def get_flag_index_deltas(
477477
if index in unslashed_participating_indices:
478478
if not is_in_inactivity_leak(state):
479479
reward_numerator = base_reward * weight * unslashed_participating_increments
480-
rewards[index] += Gwei(reward_numerator // (active_increments * WEIGHT_DENOMINATOR))
480+
rewards[index] += reward_numerator // (active_increments * WEIGHT_DENOMINATOR)
481481
elif flag_index != TIMELY_HEAD_FLAG_INDEX:
482-
penalties[index] += Gwei(base_reward * weight // WEIGHT_DENOMINATOR)
482+
penalties[index] += base_reward * weight // WEIGHT_DENOMINATOR
483483
return rewards, penalties
484484
```
485485

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

@@ -528,7 +528,7 @@ def slash_validator(
528528
validator = state.validators[slashed_index]
529529
validator.slashed = Boolean(True)
530530
validator.withdrawable_epoch = max(
531-
validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR)
531+
validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR
532532
)
533533
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
534534
decrease_balance(
@@ -539,10 +539,10 @@ def slash_validator(
539539
proposer_index = get_beacon_proposer_index(state)
540540
if whistleblower_index is None:
541541
whistleblower_index = proposer_index
542-
whistleblower_reward = Gwei(validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT)
543-
proposer_reward = Gwei(whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR)
542+
whistleblower_reward = validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT
543+
proposer_reward = whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR
544544
increase_balance(state, proposer_index, proposer_reward)
545-
increase_balance(state, whistleblower_index, Gwei(whistleblower_reward - proposer_reward))
545+
increase_balance(state, whistleblower_index, whistleblower_reward - proposer_reward)
546546
```
547547

548548
### Block processing
@@ -661,7 +661,7 @@ def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) ->
661661
)
662662
if bit
663663
]
664-
previous_slot = max(state.slot, Slot(1)) - Slot(1)
664+
previous_slot = max(state.slot, Slot(1)) - 1
665665
domain = get_domain(state, DOMAIN_SYNC_COMMITTEE, compute_epoch_at_slot(previous_slot))
666666
signing_root = compute_signing_root(get_block_root_at_slot(state, previous_slot), domain)
667667
# Note: eth_fast_aggregate_verify works with a singleton list containing an aggregated key
@@ -671,14 +671,12 @@ def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) ->
671671

672672
# Compute participant and proposer rewards
673673
total_active_increments = get_total_active_balance(state) // EFFECTIVE_BALANCE_INCREMENT
674-
total_base_rewards = Gwei(get_base_reward_per_increment(state) * total_active_increments)
675-
max_participant_rewards = Gwei(
674+
total_base_rewards = get_base_reward_per_increment(state) * total_active_increments
675+
max_participant_rewards = (
676676
total_base_rewards * SYNC_REWARD_WEIGHT // WEIGHT_DENOMINATOR // Uint64(SLOTS_PER_EPOCH)
677677
)
678-
participant_reward = Gwei(max_participant_rewards // SYNC_COMMITTEE_SIZE)
679-
proposer_reward = Gwei(
680-
participant_reward * PROPOSER_WEIGHT // (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
681-
)
678+
participant_reward = max_participant_rewards // SYNC_COMMITTEE_SIZE
679+
proposer_reward = participant_reward * PROPOSER_WEIGHT // (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
682680

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

837835
```python
838836
def process_sync_committee_updates(state: BeaconState) -> None:
839-
next_epoch = get_current_epoch(state) + Epoch(1)
837+
next_epoch = get_current_epoch(state) + 1
840838
if next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
841839
state.current_sync_committee = state.next_sync_committee
842840
state.next_sync_committee = get_next_sync_committee(state)

specs/altair/light-client/sync-protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def validate_light_client_update(
479479
)
480480
if bit
481481
]
482-
fork_version_slot = max(update.signature_slot, Slot(1)) - Slot(1)
482+
fork_version_slot = max(update.signature_slot, Slot(1)) - 1
483483
fork_version = compute_fork_version(compute_epoch_at_slot(fork_version_slot))
484484
domain = compute_domain(DOMAIN_SYNC_COMMITTEE, fork_version, genesis_validators_root)
485485
signing_root = compute_signing_root(update.attested_header.beacon, domain)

specs/altair/p2p-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_sync_subcommittee_pubkeys(
115115
) -> Sequence[BLSPubkey]:
116116
# Committees assigned to `slot` sign for `slot - 1`
117117
# This creates the exceptional logic below when transitioning between sync committee periods
118-
next_slot_epoch = compute_epoch_at_slot(Slot(state.slot + 1))
118+
next_slot_epoch = compute_epoch_at_slot(state.slot + 1)
119119
if compute_sync_committee_period(get_current_epoch(state)) == compute_sync_committee_period(
120120
next_slot_epoch
121121
):

specs/altair/validator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ subcommittees.
394394
def compute_subnets_for_sync_committee(
395395
state: BeaconState, validator_index: ValidatorIndex
396396
) -> Set[SubnetID]:
397-
next_slot_epoch = compute_epoch_at_slot(Slot(state.slot + 1))
397+
next_slot_epoch = compute_epoch_at_slot(state.slot + 1)
398398
if compute_sync_committee_period(get_current_epoch(state)) == compute_sync_committee_period(
399399
next_slot_epoch
400400
):

specs/bellatrix/beacon-chain.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
300300
)
301301
# [Modified in Bellatrix]
302302
penalty_denominator = INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_BELLATRIX
303-
penalties[index] += Gwei(penalty_numerator // penalty_denominator)
303+
penalties[index] += penalty_numerator // penalty_denominator
304304
return rewards, penalties
305305
```
306306

@@ -325,7 +325,7 @@ def slash_validator(
325325
validator = state.validators[slashed_index]
326326
validator.slashed = Boolean(True)
327327
validator.withdrawable_epoch = max(
328-
validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR)
328+
validator.withdrawable_epoch, epoch + EPOCHS_PER_SLASHINGS_VECTOR
329329
)
330330
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
331331
# [Modified in Bellatrix]
@@ -336,10 +336,10 @@ def slash_validator(
336336
proposer_index = get_beacon_proposer_index(state)
337337
if whistleblower_index is None:
338338
whistleblower_index = proposer_index
339-
whistleblower_reward = Gwei(validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT)
340-
proposer_reward = Gwei(whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR)
339+
whistleblower_reward = validator.effective_balance // WHISTLEBLOWER_REWARD_QUOTIENT
340+
proposer_reward = whistleblower_reward * PROPOSER_WEIGHT // WEIGHT_DENOMINATOR
341341
increase_balance(state, proposer_index, proposer_reward)
342-
increase_balance(state, whistleblower_index, Gwei(whistleblower_reward - proposer_reward))
342+
increase_balance(state, whistleblower_index, whistleblower_reward - proposer_reward)
343343
```
344344

345345
## Beacon chain state transition function

specs/capella/beacon-chain.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def process_epoch(state: BeaconState) -> None:
378378
```python
379379
def process_historical_summaries_update(state: BeaconState) -> None:
380380
# Set historical block root accumulator.
381-
next_epoch = Epoch(get_current_epoch(state) + 1)
381+
next_epoch = get_current_epoch(state) + 1
382382
if next_epoch % Uint64(SLOTS_PER_HISTORICAL_ROOT // SLOTS_PER_EPOCH) == 0:
383383
historical_summary = HistoricalSummary(
384384
block_summary_root=hash_tree_root(state.block_roots),
@@ -455,7 +455,7 @@ def get_validators_sweep_withdrawals(
455455
amount=balance,
456456
)
457457
)
458-
withdrawal_index += WithdrawalIndex(1)
458+
withdrawal_index += 1
459459
elif is_partially_withdrawable_validator(validator, balance):
460460
withdrawals.append(
461461
Withdrawal(
@@ -465,9 +465,9 @@ def get_validators_sweep_withdrawals(
465465
amount=balance - MAX_EFFECTIVE_BALANCE,
466466
)
467467
)
468-
withdrawal_index += WithdrawalIndex(1)
468+
withdrawal_index += 1
469469

470-
validator_index = ValidatorIndex((validator_index + 1) % len(state.validators))
470+
validator_index = (validator_index + 1) % len(state.validators)
471471
processed_count += 1
472472

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

513513
#### New `update_next_withdrawal_validator_index`
@@ -519,14 +519,12 @@ def update_next_withdrawal_validator_index(
519519
# Update the next validator index to start the next withdrawal sweep
520520
if len(withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD:
521521
# Next sweep starts after the latest withdrawal's validator index
522-
next_validator_index = ValidatorIndex(
523-
(withdrawals[-1].validator_index + 1) % len(state.validators)
524-
)
522+
next_validator_index = (withdrawals[-1].validator_index + 1) % len(state.validators)
525523
state.next_withdrawal_validator_index = next_validator_index
526524
else:
527525
# Advance sweep by the max length of the sweep if there was not a full set of withdrawals
528526
next_index = state.next_withdrawal_validator_index + MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP
529-
next_validator_index = ValidatorIndex(next_index % len(state.validators))
527+
next_validator_index = next_index % len(state.validators)
530528
state.next_withdrawal_validator_index = next_validator_index
531529
```
532530

specs/deneb/light-client/sync-protocol.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def is_valid_light_client_header(header: LightClientHeader) -> bool:
6666

6767
# [New in Deneb:EIP4844]
6868
if epoch < DENEB_FORK_EPOCH:
69-
if header.execution.blob_gas_used != Uint64(0):
69+
if header.execution.blob_gas_used != 0:
7070
return False
71-
if header.execution.excess_blob_gas != Uint64(0):
71+
if header.execution.excess_blob_gas != 0:
7272
return False
7373

7474
if epoch < CAPELLA_FORK_EPOCH:

0 commit comments

Comments
 (0)