This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1311 from hwwhww/aggregation_strategy
Basic aggregation strategy
- Loading branch information
Showing
21 changed files
with
1,210 additions
and
235 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,57 @@ | ||
from typing import Tuple | ||
|
||
from eth_utils import ValidationError | ||
|
||
from eth2.beacon.state_machines.forks.serenity.block_validation import ( | ||
validate_attestation_slot, | ||
) | ||
from eth2.beacon.types.attestations import Attestation | ||
from eth2.beacon.typing import CommitteeIndex, SigningRoot, Slot | ||
from eth2.configs import Eth2Config | ||
|
||
from .pool import OperationPool | ||
|
||
|
||
def is_valid_slot( | ||
attestation: Attestation, current_slot: Slot, config: Eth2Config | ||
) -> bool: | ||
try: | ||
validate_attestation_slot( | ||
attestation.data.slot, | ||
current_slot, | ||
config.SLOTS_PER_EPOCH, | ||
config.MIN_ATTESTATION_INCLUSION_DELAY, | ||
) | ||
except ValidationError: | ||
return False | ||
else: | ||
return True | ||
|
||
|
||
class AttestationPool(OperationPool[Attestation]): | ||
pass | ||
def get_valid_attestation_by_current_slot( | ||
self, slot: Slot, config: Eth2Config | ||
) -> Tuple[Attestation, ...]: | ||
return tuple( | ||
filter( | ||
lambda attestation: is_valid_slot(attestation, slot, config), | ||
self._pool_storage.values(), | ||
) | ||
) | ||
|
||
def get_acceptable_attestations( | ||
self, | ||
slot: Slot, | ||
committee_index: CommitteeIndex, | ||
beacon_block_root: SigningRoot, | ||
) -> Tuple[Attestation, ...]: | ||
return tuple( | ||
filter( | ||
lambda attestation: ( | ||
beacon_block_root == attestation.data.beacon_block_root | ||
and slot == attestation.data.slot | ||
and committee_index == attestation.data.index | ||
), | ||
self._pool_storage.values(), | ||
) | ||
) |
199 changes: 199 additions & 0 deletions
199
eth2/beacon/scripts/quickstart_state/keygen_100_validators.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.