-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
271 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Deneb -- The Beacon Chain | ||
|
||
**Notice**: This document is a work-in-progress for researchers and implementers. | ||
|
||
## Table of contents | ||
|
||
<!-- TOC --> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Introduction](#introduction) | ||
- [Preset](#preset) | ||
- [Configuration](#configuration) | ||
- [Containers](#containers) | ||
- [Beacon chain state transition function](#beacon-chain-state-transition-function) | ||
- [Block processing](#block-processing) | ||
- [Modified `process_attestation`](#modified-process_attestation) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
||
## Introduction | ||
|
||
This feature allows for inclusion of attestations created during epoch `N` to be included in slots from epoch `N` as well as all slots in epoch `N+1` rather than the current `SLOTS_PER_EPOCH` slot restricted range. This is an extension of the Deneb upgrade. | ||
|
||
## Preset | ||
|
||
## Configuration | ||
|
||
## Containers | ||
|
||
## Beacon chain state transition function | ||
|
||
### Block processing | ||
|
||
#### Modified `process_attestation` | ||
|
||
*Note*: The function `process_attestation` is modified to expand valid slots for inclusion tothose in the `target.epoch` epoch as well as those in the `target.epoch + 1` epoch. | ||
|
||
```python | ||
def process_attestation(state: BeaconState, attestation: Attestation) -> None: | ||
data = attestation.data | ||
assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state)) | ||
assert data.target.epoch == compute_epoch_at_slot(data.slot) | ||
assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot # [Modified in AttSlotRange] | ||
assert data.index < get_committee_count_per_slot(state, data.target.epoch) | ||
|
||
committee = get_beacon_committee(state, data.slot, data.index) | ||
assert len(attestation.aggregation_bits) == len(committee) | ||
|
||
# Participation flag indices | ||
participation_flag_indices = get_attestation_participation_flag_indices(state, data, state.slot - data.slot) | ||
|
||
# Verify signature | ||
assert is_valid_indexed_attestation(state, get_indexed_attestation(state, attestation)) | ||
|
||
# Update epoch participation flags | ||
if data.target.epoch == get_current_epoch(state): | ||
epoch_participation = state.current_epoch_participation | ||
else: | ||
epoch_participation = state.previous_epoch_participation | ||
|
||
proposer_reward_numerator = 0 | ||
for index in get_attesting_indices(state, data, attestation.aggregation_bits): | ||
for flag_index, weight in enumerate(PARTICIPATION_FLAG_WEIGHTS): | ||
if flag_index in participation_flag_indices and not has_flag(epoch_participation[index], flag_index): | ||
epoch_participation[index] = add_flag(epoch_participation[index], flag_index) | ||
proposer_reward_numerator += get_base_reward(state, index) * weight | ||
|
||
# Reward proposer | ||
proposer_reward_denominator = (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR // PROPOSER_WEIGHT | ||
proposer_reward = Gwei(proposer_reward_numerator // proposer_reward_denominator) | ||
increase_balance(state, get_beacon_proposer_index(state), proposer_reward) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Att-Slot-Range -- Fork Logic | ||
|
||
**Notice**: This document is a work-in-progress for researchers and implementers. | ||
|
||
## Table of contents | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Introduction](#introduction) | ||
- [Configuration](#configuration) | ||
- [Helper functions](#helper-functions) | ||
- [Misc](#misc) | ||
- [Modified `compute_fork_version`](#modified-compute_fork_version) | ||
- [Fork to EIP-6110](#fork-to-eip-6110) | ||
- [Fork trigger](#fork-trigger) | ||
- [Upgrading the state](#upgrading-the-state) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Introduction | ||
|
||
This document describes the process of Att-Slot-Range upgrade. | ||
|
||
## Configuration | ||
|
||
Warning: this configuration is not definitive. | ||
|
||
| Name | Value | | ||
| - | - | | ||
| `ATTSLOTRANGE_FORK_VERSION` | `Version('0x05000000')` | | ||
| `ATTSLOTRANGE_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | | ||
|
||
## Helper functions | ||
|
||
### Misc | ||
|
||
#### Modified `compute_fork_version` | ||
|
||
```python | ||
def compute_fork_version(epoch: Epoch) -> Version: | ||
""" | ||
Return the fork version at the given ``epoch``. | ||
""" | ||
if epoch >= ATTSLOTRANGE_FORK_EPOCH: | ||
return ATTSLOTRANGE_FORK_VERSION | ||
if epoch >= DENEB_FORK_EPOCH: | ||
return DENEB_FORK_VERSION | ||
if epoch >= CAPELLA_FORK_EPOCH: | ||
return CAPELLA_FORK_VERSION | ||
if epoch >= BELLATRIX_FORK_EPOCH: | ||
return BELLATRIX_FORK_VERSION | ||
if epoch >= ALTAIR_FORK_EPOCH: | ||
return ALTAIR_FORK_VERSION | ||
return GENESIS_FORK_VERSION | ||
``` | ||
|
||
## Fork to AttSlotRange | ||
|
||
### Fork trigger | ||
|
||
TBD. This fork is defined for testing purposes, the EIP may be combined with other consensus-layer upgrade. | ||
For now, we assume the condition will be triggered at epoch `ATTSLOTRANGE_FORK_EPOCH`. | ||
|
||
Note that for the pure AttSlotRange networks, we don't apply `upgrade_to_attslotrange` since it starts with AttSlotRange version logic. | ||
|
||
### Upgrading the state | ||
|
||
If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ATTSLOTRANGE_FORK_EPOCH, | ||
an irregular state change is made to upgrade to AttSlotRange. | ||
|
||
```python | ||
def upgrade_to_attslotrange(pre: deneb.BeaconState) -> BeaconState: | ||
post = BeaconState( | ||
# Versioning | ||
genesis_time=pre.genesis_time, | ||
genesis_validators_root=pre.genesis_validators_root, | ||
slot=pre.slot, | ||
fork=Fork( | ||
previous_version=pre.fork.current_version, | ||
current_version=ATTSLOTRANGE_FORK_VERSION, # [Modified in Att-Slot-Range] | ||
epoch=deneb.get_current_epoch(pre), | ||
), | ||
# History | ||
latest_block_header=pre.latest_block_header, | ||
block_roots=pre.block_roots, | ||
state_roots=pre.state_roots, | ||
historical_roots=pre.historical_roots, | ||
# Eth1 | ||
eth1_data=pre.eth1_data, | ||
eth1_data_votes=pre.eth1_data_votes, | ||
eth1_deposit_index=pre.eth1_deposit_index, | ||
# Registry | ||
validators=pre.validators, | ||
balances=pre.balances, | ||
# Randomness | ||
randao_mixes=pre.randao_mixes, | ||
# Slashings | ||
slashings=pre.slashings, | ||
# Participation | ||
previous_epoch_participation=pre.previous_epoch_participation, | ||
current_epoch_participation=pre.current_epoch_participation, | ||
# Finality | ||
justification_bits=pre.justification_bits, | ||
previous_justified_checkpoint=pre.previous_justified_checkpoint, | ||
current_justified_checkpoint=pre.current_justified_checkpoint, | ||
finalized_checkpoint=pre.finalized_checkpoint, | ||
# Inactivity | ||
inactivity_scores=pre.inactivity_scores, | ||
# Sync | ||
current_sync_committee=pre.current_sync_committee, | ||
next_sync_committee=pre.next_sync_committee, | ||
# Execution-layer | ||
latest_execution_payload_header=pre.latest_execution_payload_header, | ||
# Withdrawals | ||
next_withdrawal_index=pre.next_withdrawal_index, | ||
next_withdrawal_validator_index=pre.next_withdrawal_validator_index, | ||
# Deep history valid from Capella onwards | ||
historical_summaries=pre.historical_summaries, | ||
) | ||
|
||
return post | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.