-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Conversation
* 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). |
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
// Refuse to sign any attestation with: | |
// - source.epoch < min(att.source_epoch for att in data.signed_attestations if att.pubkey == attester_pubkey), OR | |
// - target_epoch <= min(att.target_epoch for att in data.signed_attestations if att.pubkey == attester_pubkey) | |
// (spec v4, Slashing Protection Database Interchange Format) | |
const attestationLowerBound = await this.attestationLowerBound.get(pubKey); | |
if (attestationLowerBound) { | |
const {minSourceEpoch, minTargetEpoch} = attestationLowerBound; | |
if (attestation.sourceEpoch < minSourceEpoch) { | |
throw new InvalidAttestationError({ | |
code: InvalidAttestationErrorCode.SOURCE_LESS_THAN_LOWER_BOUND, | |
sourceEpoch: attestation.sourceEpoch, | |
minSourceEpoch, | |
}); | |
} | |
if (attestation.targetEpoch <= minTargetEpoch) { | |
throw new InvalidAttestationError({ | |
code: InvalidAttestationErrorCode.TARGET_LESS_THAN_OR_EQ_LOWER_BOUND, | |
targetEpoch: attestation.targetEpoch, | |
minTargetEpoch, | |
}); | |
} | |
} |
* on first startup with an empty db. See https://github.com/ChainSafe/lodestar/issues/5356 for more details on the issue. | ||
* | ||
* 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 comment
The 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.
Performance Report✔️ no performance regression detected Full benchmark results
|
842dbea
to
f738b3c
Compare
f738b3c
to
d997504
Compare
🎉 This PR is included in v1.9.0 🎉 |
Motivation
Closes #5356
Description
Limits number of epochs in the past to check for surrounding attestations (min-span) to 4096.
DB size
Running with 2k keys, the DB size was initially 4GB and is now reduced to 100MB.
Metrics
These are the metrics when running a VC with 2k keys and an empty db.
There are still quite a lot of read/writes but it goes down very fast compared to initially and does no longer cause instability in VC.
Request times do not show any I/O lag, previously was running into timeouts (10 seconds).
For the first 1-2 minutes there is still a increased step times diff but it goes down very fast, after a few minutes instead of hours as before.
Metrics look good to me now, there are no big issues and also need to keep in mind that those metrics are collected running 2k validators which is not a normal setup. This also only happens if the db is empty, meaning for most setups only on initial installation.