-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
fix(slashing-protection): limit min-max surround epoch lookback to 4096 #5454
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -5,13 +5,29 @@ import {SurroundAttestationError, SurroundAttestationErrorCode} from "./errors.j | |
// surround vote checking with min-max surround | ||
// https://github.com/protolambda/eth2-surround#min-max-surround | ||
|
||
/** | ||
* Number of epochs in the past to check for surrounding attestations. | ||
* | ||
* This value can be limited to a reasonable high amount as Lodestar does not solely rely on this strategy but also | ||
* implements the minimal strategy which has been formally proven to be safe (https://github.com/michaelsproul/slashing-proofs). | ||
* | ||
* Limiting this value is required due to practical reasons as otherwise there would be a min-span DB read and write | ||
* for each validator from current epoch until genesis which massively increases DB size and causes I/O lag, resulting in | ||
* instability on first startup with an empty DB. See https://github.com/ChainSafe/lodestar/issues/5356 for more details. | ||
* | ||
* The value 4096 has been chosen as it is the default used by slashers (https://lighthouse-book.sigmaprime.io/slasher.html#history-length) | ||
* and is generally higher than the weak subjectivity period. However, it would still be risky if we just relied on min-max surround | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now, the weak subjectivity period for goerli is 3686 epochs and for mainnet 3442 epochs. |
||
* for slashing protection, as slashers can be configured to collect slashable attestations over a longer period. | ||
*/ | ||
const DEFAULT_MAX_EPOCH_LOOKBACK = 4096; | ||
|
||
export class MinMaxSurround implements IMinMaxSurround { | ||
private store: IDistanceStore; | ||
private maxEpochLookback: number; | ||
|
||
constructor(store: IDistanceStore, options?: {maxEpochLookback?: number}) { | ||
this.store = store; | ||
this.maxEpochLookback = options?.maxEpochLookback ?? Infinity; | ||
this.maxEpochLookback = options?.maxEpochLookback ?? DEFAULT_MAX_EPOCH_LOOKBACK; | ||
} | ||
|
||
async assertNoSurround(pubKey: BLSPubkey, attestation: MinMaxSurroundAttestation): Promise<void> { | ||
|
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.
Minimal strategy refers to conditions 4 and 5 from EIP-3076 and is implemented in Lodestar
lodestar/packages/validator/src/slashingProtection/attestation/index.ts
Lines 99 to 121 in 3ed8d04