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
Basic aggregation strategy #1311
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e79b519
Add naive aggregation strategy
hwwhww b83de22
spec v0.9.2 minor updates
hwwhww d11b69c
PR feeback, thanks to NIC619
hwwhww d3ab714
Split it into two AttestationPool: aggregated_attestation_pool and un…
hwwhww 4929cee
Rework topic_validators
hwwhww df7e029
Only run `validate_attestation_signature` instead of full `validate_a…
hwwhww 49a2cf2
Propose with both attestation pools
hwwhww 01b78f6
Fix after rebasing
hwwhww File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we also assume that there's no overlap between attesters in each attestation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay to have overlapped
aggregation_bits
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC currently we don't support validating aggregated signature where there's duplicated signature being aggregated. I would suggest we add a note in docstring or add a check and logging if there's duplicated signature being aggregated. So that it would be easier to debug or less likely to make mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. And I will split it into two
AttestationPool
:aggregated_attestation_pool
andunaggregated_attestation_pool
. Thanks! 👍