-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Ensure doppelganger detects attestations in blocks #2495
Conversation
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.
Generally wondering if we are OK with creating and populating the new cache even when doppelganger is disabled?
@@ -2305,6 +2311,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |||
Err(e) => Err(BlockError::BeaconChainError(e.into())), | |||
}?; | |||
|
|||
if attestation_target_epoch + OBSERVED_ATTESTERS_MAX_CAPACITY >= current_epoch { |
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.
I think OBSERVED_ATTESTERS_EPOCH_CAPACITY
would be a little clearer, to distinguish this from the total number of attesters in the cache
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.
Also the cache's lowest_permissible_epoch
(which it prunes based on) is based off of the target_epoch - (MAX_CAPACITY - 1)
so this check might have too wide a range.
{ | ||
debug!( | ||
self.log, | ||
"Failed register observed block attester"; |
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.
"Failed register observed block attester"; | |
"Failed to register observed block attester"; |
All comments addressed, thanks for the review @realbigsean. I'll wait for your approval before merging this one :) |
commit db48997 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 14:21:39 2021 +1000 Add observed_block_attesters commit a8da027 Author: Paul Hauner <[email protected]> Date: Wed Aug 4 14:03:49 2021 +1000 Rename observed_attesters to observed_gossip_attesters
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.
Looks good to me!
bors r+ |
## Issue Addressed NA ## Proposed Changes When testing our (not-yet-released) Doppelganger implementation, I noticed that we aren't detecting attestations included in blocks (only those on the gossip network). This is because during [block processing](https://github.com/sigp/lighthouse/blob/e8c0d1f19b2736efb83c67a247e0022da5eaa7bb/beacon_node/beacon_chain/src/beacon_chain.rs#L2168) we only update the `observed_attestations` cache with each attestation, but not the `observed_attesters` cache. This is the correct behaviour when we consider the [p2p spec](https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md): > [IGNORE] There has been no other valid attestation seen on an attestation subnet that has an identical attestation.data.target.epoch and participating validator index. We're doing the right thing here and still allowing attestations on gossip that we've seen in a block. However, this doesn't work so nicely for Doppelganger. To resolve this, I've taken the following steps: - Add a `observed_block_attesters` cache. - Rename `observed_attesters` to `observed_gossip_attesters`. ## TODO - [x] Add a test to ensure a validator that's been seen in a block attestation (but not a gossip attestation) returns `true` for `BeaconChain::validator_seen_at_epoch`. - [x] Add a test to ensure `observed_block_attesters` isn't polluted via gossip attestations and vice versa. Co-authored-by: realbigsean <[email protected]>
Pull request successfully merged into unstable. Build succeeded: |
## Issue Addressed NA ## Proposed Changes When testing our (not-yet-released) Doppelganger implementation, I noticed that we aren't detecting attestations included in blocks (only those on the gossip network). This is because during [block processing](https://github.com/sigp/lighthouse/blob/e8c0d1f19b2736efb83c67a247e0022da5eaa7bb/beacon_node/beacon_chain/src/beacon_chain.rs#L2168) we only update the `observed_attestations` cache with each attestation, but not the `observed_attesters` cache. This is the correct behaviour when we consider the [p2p spec](https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md): > [IGNORE] There has been no other valid attestation seen on an attestation subnet that has an identical attestation.data.target.epoch and participating validator index. We're doing the right thing here and still allowing attestations on gossip that we've seen in a block. However, this doesn't work so nicely for Doppelganger. To resolve this, I've taken the following steps: - Add a `observed_block_attesters` cache. - Rename `observed_attesters` to `observed_gossip_attesters`. ## TODO - [x] Add a test to ensure a validator that's been seen in a block attestation (but not a gossip attestation) returns `true` for `BeaconChain::validator_seen_at_epoch`. - [x] Add a test to ensure `observed_block_attesters` isn't polluted via gossip attestations and vice versa. Co-authored-by: realbigsean <[email protected]>
Issue Addressed
NA
Proposed Changes
When testing our (not-yet-released) Doppelganger implementation, I noticed that we aren't detecting attestations included in blocks (only those on the gossip network).
This is because during block processing we only update the
observed_attestations
cache with each attestation, but not theobserved_attesters
cache. This is the correct behaviour when we consider the p2p spec:We're doing the right thing here and still allowing attestations on gossip that we've seen in a block. However, this doesn't work so nicely for Doppelganger.
To resolve this, I've taken the following steps:
observed_block_attesters
cache.observed_attesters
toobserved_gossip_attesters
.TODO
true
forBeaconChain::validator_seen_at_epoch
.observed_block_attesters
isn't polluted via gossip attestations and vice versa.