@lodestar/validator 1.48.0-dev.b6386729a9 → 1.48.0-dev.b71ab45af3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/slashingProtection/attestation/attestationByTargetRepository.d.ts +0 -2
- package/lib/slashingProtection/attestation/attestationByTargetRepository.d.ts.map +1 -1
- package/lib/slashingProtection/attestation/attestationByTargetRepository.js +0 -11
- package/lib/slashingProtection/attestation/attestationByTargetRepository.js.map +1 -1
- package/lib/slashingProtection/attestation/errors.d.ts +1 -10
- package/lib/slashingProtection/attestation/errors.d.ts.map +1 -1
- package/lib/slashingProtection/attestation/errors.js +0 -5
- package/lib/slashingProtection/attestation/errors.js.map +1 -1
- package/lib/slashingProtection/attestation/index.d.ts.map +1 -1
- package/lib/slashingProtection/attestation/index.js +2 -41
- package/lib/slashingProtection/attestation/index.js.map +1 -1
- package/lib/slashingProtection/minMaxSurround/minMaxSurround.d.ts +1 -3
- package/lib/slashingProtection/minMaxSurround/minMaxSurround.d.ts.map +1 -1
- package/lib/slashingProtection/minMaxSurround/minMaxSurround.js +2 -7
- package/lib/slashingProtection/minMaxSurround/minMaxSurround.js.map +1 -1
- package/package.json +13 -13
- package/src/slashingProtection/attestation/attestationByTargetRepository.ts +0 -12
- package/src/slashingProtection/attestation/errors.ts +0 -10
- package/src/slashingProtection/attestation/index.ts +2 -43
- package/src/slashingProtection/minMaxSurround/minMaxSurround.ts +3 -9
|
@@ -18,8 +18,6 @@ export declare class AttestationByTargetRepository {
|
|
|
18
18
|
private readonly maxKey;
|
|
19
19
|
constructor(db: LodestarValidatorDatabaseController);
|
|
20
20
|
getAll(pubkey: BLSPubkey, limit?: number): Promise<SlashingProtectionAttestation[]>;
|
|
21
|
-
/** Attestation with the highest target epoch recorded for `pubkey`, or null if none */
|
|
22
|
-
getLatest(pubkey: BLSPubkey): Promise<SlashingProtectionAttestation | null>;
|
|
23
21
|
get(pubkey: BLSPubkey, targetEpoch: Epoch): Promise<SlashingProtectionAttestation | null>;
|
|
24
22
|
set(pubkey: BLSPubkey, atts: SlashingProtectionAttestation[]): Promise<void>;
|
|
25
23
|
listPubkeys(): Promise<BLSPubkey[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationByTargetRepository.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/attestationByTargetRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAM,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAC,MAAM,EAAuB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAC,mCAAmC,EAAC,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAC,6BAA6B,EAAC,MAAM,aAAa,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,6BAA6B;IAS5B,SAAS,CAAC,EAAE,EAAE,mCAAmC;IAR7D,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC;IACpD,SAAS,CAAC,MAAM,SAAgD;IAEhE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC,YAAsB,EAAE,EAAE,mCAAmC,EAQ5D;IAEK,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAQxF;
|
|
1
|
+
{"version":3,"file":"attestationByTargetRepository.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/attestationByTargetRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAM,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAC,MAAM,EAAuB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAC,mCAAmC,EAAC,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAC,6BAA6B,EAAC,MAAM,aAAa,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,6BAA6B;IAS5B,SAAS,CAAC,EAAE,EAAE,mCAAmC;IAR7D,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC;IACpD,SAAS,CAAC,MAAM,SAAgD;IAEhE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC,YAAsB,EAAE,EAAE,mCAAmC,EAQ5D;IAEK,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAQxF;IAEK,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,GAAG,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAG9F;IAEK,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjF;IAEK,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAGxC;IAED,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;CASlB"}
|
|
@@ -36,17 +36,6 @@ export class AttestationByTargetRepository {
|
|
|
36
36
|
});
|
|
37
37
|
return attestations.map((attestation) => this.type.deserialize(attestation));
|
|
38
38
|
}
|
|
39
|
-
/** Attestation with the highest target epoch recorded for `pubkey`, or null if none */
|
|
40
|
-
async getLatest(pubkey) {
|
|
41
|
-
const [att] = await this.db.values({
|
|
42
|
-
gte: this.encodeKey(pubkey, 0),
|
|
43
|
-
lt: this.encodeKey(pubkey, Number.MAX_SAFE_INTEGER),
|
|
44
|
-
reverse: true,
|
|
45
|
-
limit: 1,
|
|
46
|
-
bucketId: this.bucketId,
|
|
47
|
-
});
|
|
48
|
-
return att ? this.type.deserialize(att) : null;
|
|
49
|
-
}
|
|
50
39
|
async get(pubkey, targetEpoch) {
|
|
51
40
|
const att = await this.db.get(this.encodeKey(pubkey, targetEpoch), this.dbReqOpts);
|
|
52
41
|
return att && this.type.deserialize(att);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestationByTargetRepository.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/attestationByTargetRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAO,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAC,gBAAgB,EAAa,SAAS,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAmB,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAC,MAAM,EAAE,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAE1D;;;;GAIG;AACH,MAAM,OAAO,6BAA6B;IASlB,EAAE;IARd,IAAI,CAAsC;IAC1C,MAAM,GAAG,MAAM,CAAC,qCAAqC,CAAC;IAE/C,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,SAAS,GAAc,EAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC;IACjD,MAAM,CAAa;IACnB,MAAM,CAAa;IAEpC,YAAsB,EAAuC;kBAAvC,EAAE;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC;YAC5B,WAAW,EAAE,GAAG,CAAC,KAAK;YACtB,WAAW,EAAE,GAAG,CAAC,KAAK;YACtB,WAAW,EAAE,GAAG,CAAC,IAAI;SACtB,CAAC,CAAC,CAAC,wBAAwB;QAC5B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAiB,EAAE,KAAc;QAC5C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;YACxC,KAAK;YACL,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9B,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACnD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"attestationByTargetRepository.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/attestationByTargetRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAO,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAC,gBAAgB,EAAa,SAAS,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAmB,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,E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AM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACzG,CAAC;IAEO,SAAS,CAAC,GAAe;QAC/B,OAAO;YACL,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,YAAY,CAAC;YACpE,WAAW,EAAE,UAAU,CACrB,GAAG,CAAC,KAAK,CAAC,gBAAgB,GAAG,YAAY,EAAE,gBAAgB,GAAG,YAAY,GAAG,OAAO,CAAC,EACrF,IAAI,CACL;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -27,12 +27,7 @@ export declare enum InvalidAttestationErrorCode {
|
|
|
27
27
|
* The attestation is invalid because its target epoch is less than or equal to the lower
|
|
28
28
|
* bound on target epochs for this validator.
|
|
29
29
|
*/
|
|
30
|
-
TARGET_LESS_THAN_OR_EQ_LOWER_BOUND = "ERR_INVALID_ATTESTATION_TARGET_LESS_THAN_OR_EQ_LOWER_BOUND"
|
|
31
|
-
/**
|
|
32
|
-
* The attestation is invalid because its source epoch is below the min-max span lookback window of the
|
|
33
|
-
* latest attestation of this validator, where a surround vote could not be detected.
|
|
34
|
-
*/
|
|
35
|
-
SOURCE_BELOW_MIN_SPAN_LOOKBACK = "ERR_INVALID_ATTESTATION_SOURCE_BELOW_MIN_SPAN_LOOKBACK"
|
|
30
|
+
TARGET_LESS_THAN_OR_EQ_LOWER_BOUND = "ERR_INVALID_ATTESTATION_TARGET_LESS_THAN_OR_EQ_LOWER_BOUND"
|
|
36
31
|
}
|
|
37
32
|
type InvalidAttestationErrorType = {
|
|
38
33
|
code: InvalidAttestationErrorCode.DOUBLE_VOTE;
|
|
@@ -56,10 +51,6 @@ type InvalidAttestationErrorType = {
|
|
|
56
51
|
code: InvalidAttestationErrorCode.TARGET_LESS_THAN_OR_EQ_LOWER_BOUND;
|
|
57
52
|
targetEpoch: Epoch;
|
|
58
53
|
minTargetEpoch: Epoch;
|
|
59
|
-
} | {
|
|
60
|
-
code: InvalidAttestationErrorCode.SOURCE_BELOW_MIN_SPAN_LOOKBACK;
|
|
61
|
-
sourceEpoch: Epoch;
|
|
62
|
-
minSourceEpoch: Epoch;
|
|
63
54
|
};
|
|
64
55
|
export declare class InvalidAttestationError extends LodestarError<InvalidAttestationErrorType> {
|
|
65
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,6BAA6B,EAAC,MAAM,aAAa,CAAC;AAE1D,oBAAY,2BAA2B;IACrC;;OAEG;IACH,WAAW,wCAAwC;IACnD;;OAEG;IACH,kBAAkB,+CAA+C;IACjE;;OAEG;IACH,kBAAkB,+CAA+C;IACjE;;OAEG;IACH,qBAAqB,kDAAkD;IACvE;;;OAGG;IACH,4BAA4B,yDAAyD;IACrF;;;OAGG;IACH,kCAAkC,+DAA+D;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,6BAA6B,EAAC,MAAM,aAAa,CAAC;AAE1D,oBAAY,2BAA2B;IACrC;;OAEG;IACH,WAAW,wCAAwC;IACnD;;OAEG;IACH,kBAAkB,+CAA+C;IACjE;;OAEG;IACH,kBAAkB,+CAA+C;IACjE;;OAEG;IACH,qBAAqB,kDAAkD;IACvE;;;OAGG;IACH,4BAA4B,yDAAyD;IACrF;;;OAGG;IACH,kCAAkC,+DAA+D;CAClG;AAED,KAAK,2BAA2B,GAC5B;IACE,IAAI,EAAE,2BAA2B,CAAC,WAAW,CAAC;IAC9C,WAAW,EAAE,6BAA6B,CAAC;IAC3C,IAAI,EAAE,6BAA6B,CAAC;CACrC,GACD;IACE,IAAI,EAAE,2BAA2B,CAAC,kBAAkB,CAAC;IACrD,WAAW,EAAE,6BAA6B,CAAC;IAE3C,IAAI,EAAE,6BAA6B,GAAG,IAAI,CAAC;CAC5C,GACD;IACE,IAAI,EAAE,2BAA2B,CAAC,kBAAkB,CAAC;IACrD,WAAW,EAAE,6BAA6B,CAAC;IAE3C,IAAI,EAAE,6BAA6B,GAAG,IAAI,CAAC;CAC5C,GACD;IACE,IAAI,EAAE,2BAA2B,CAAC,qBAAqB,CAAC;CACzD,GACD;IACE,IAAI,EAAE,2BAA2B,CAAC,4BAA4B,CAAC;IAC/D,WAAW,EAAE,KAAK,CAAC;IACnB,cAAc,EAAE,KAAK,CAAC;CACvB,GACD;IACE,IAAI,EAAE,2BAA2B,CAAC,kCAAkC,CAAC;IACrE,WAAW,EAAE,KAAK,CAAC;IACnB,cAAc,EAAE,KAAK,CAAC;CACvB,CAAC;AAEN,qBAAa,uBAAwB,SAAQ,aAAa,CAAC,2BAA2B,CAAC;CAAG"}
|
|
@@ -27,11 +27,6 @@ export var InvalidAttestationErrorCode;
|
|
|
27
27
|
* bound on target epochs for this validator.
|
|
28
28
|
*/
|
|
29
29
|
InvalidAttestationErrorCode["TARGET_LESS_THAN_OR_EQ_LOWER_BOUND"] = "ERR_INVALID_ATTESTATION_TARGET_LESS_THAN_OR_EQ_LOWER_BOUND";
|
|
30
|
-
/**
|
|
31
|
-
* The attestation is invalid because its source epoch is below the min-max span lookback window of the
|
|
32
|
-
* latest attestation of this validator, where a surround vote could not be detected.
|
|
33
|
-
*/
|
|
34
|
-
InvalidAttestationErrorCode["SOURCE_BELOW_MIN_SPAN_LOOKBACK"] = "ERR_INVALID_ATTESTATION_SOURCE_BELOW_MIN_SPAN_LOOKBACK";
|
|
35
30
|
})(InvalidAttestationErrorCode || (InvalidAttestationErrorCode = {}));
|
|
36
31
|
export class InvalidAttestationError extends LodestarError {
|
|
37
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,CAAN,IAAY,2BA2BX;AA3BD,WAAY,2BAA2B;IACrC;;OAEG;IACH,kFAAmD,CAAA;IACnD;;OAEG;IACH,gGAAiE,CAAA;IACjE;;OAEG;IACH,gGAAiE,CAAA;IACjE;;OAEG;IACH,sGAAuE,CAAA;IACvE;;;OAGG;IACH,oHAAqF,CAAA;IACrF;;;OAGG;IACH,gIAAiG,CAAA;AACnG,CAAC,EA3BW,2BAA2B,KAA3B,2BAA2B,QA2BtC;AAkCD,MAAM,OAAO,uBAAwB,SAAQ,aAA0C;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAyD,MAAM,4BAA4B,CAAC;AAClH,OAAO,EAAC,6BAA6B,EAAC,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAC,6BAA6B,EAAC,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAC,+BAA+B,EAAC,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAC,uBAAuB,EAAE,2BAA2B,EAAC,MA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IAC3D,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,cAAc,CAAiB;IAEvC,YACE,mBAAmB,EAAE,6BAA6B,EAClD,qBAAqB,EAAE,+BAA+B,EACtD,cAAc,EAAE,cAAc,EAK/B;IAED;;;OAGG;IACG,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ5G;IAED;;OAEG;IACG,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,6BAA6B,GAAG,OAAO,CAAC,UAAU,CAAC,CAuEzG;IAED;;;;OAIG;IACG,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpG;IAED;;OAEG;IACG,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAE3G;IAED;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcxG;IAED;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAEpF;IAEK,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAExC;CACF"}
|
|
@@ -38,16 +38,9 @@ export class SlashingProtectionAttestationService {
|
|
|
38
38
|
if (attestation.sourceEpoch > attestation.targetEpoch) {
|
|
39
39
|
throw new InvalidAttestationError({ code: InvalidAttestationErrorCode.SOURCE_EXCEEDS_TARGET });
|
|
40
40
|
}
|
|
41
|
-
const latestAtt = await this.attestationByTarget.getLatest(pubKey);
|
|
42
41
|
// Check for a double vote. Namely, an existing attestation with the same target epoch,
|
|
43
|
-
// and a different signing root.
|
|
44
|
-
|
|
45
|
-
if (latestAtt && latestAtt.targetEpoch === attestation.targetEpoch) {
|
|
46
|
-
sameTargetAtt = latestAtt;
|
|
47
|
-
}
|
|
48
|
-
else if (latestAtt && latestAtt.targetEpoch > attestation.targetEpoch) {
|
|
49
|
-
sameTargetAtt = await this.attestationByTarget.get(pubKey, attestation.targetEpoch);
|
|
50
|
-
}
|
|
42
|
+
// and a different signing root.
|
|
43
|
+
const sameTargetAtt = await this.attestationByTarget.get(pubKey, attestation.targetEpoch);
|
|
51
44
|
if (sameTargetAtt) {
|
|
52
45
|
// Interchange format allows for attestations without signing_root, then assume root is equal
|
|
53
46
|
if (isEqualNonZeroRoot(sameTargetAtt.signingRoot, attestation.signingRoot)) {
|
|
@@ -59,19 +52,6 @@ export class SlashingProtectionAttestationService {
|
|
|
59
52
|
prev: sameTargetAtt,
|
|
60
53
|
});
|
|
61
54
|
}
|
|
62
|
-
// Min-span entries only exist within the lookback window below each recorded source epoch, a surround vote
|
|
63
|
-
// with an older source epoch is undetectable by min-max surround and must be rejected outright. Recorded
|
|
64
|
-
// attestations are surround-free, so the latest one has the highest source epoch and the widest window.
|
|
65
|
-
if (latestAtt) {
|
|
66
|
-
const minSourceEpoch = this.minMaxSurround.minSpanCoverageStart(latestAtt.sourceEpoch);
|
|
67
|
-
if (attestation.sourceEpoch < minSourceEpoch) {
|
|
68
|
-
throw new InvalidAttestationError({
|
|
69
|
-
code: InvalidAttestationErrorCode.SOURCE_BELOW_MIN_SPAN_LOOKBACK,
|
|
70
|
-
sourceEpoch: attestation.sourceEpoch,
|
|
71
|
-
minSourceEpoch,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
55
|
// Check for a surround vote
|
|
76
56
|
try {
|
|
77
57
|
await this.minMaxSurround.assertNoSurround(pubKey, attestation);
|
|
@@ -139,25 +119,6 @@ export class SlashingProtectionAttestationService {
|
|
|
139
119
|
* Interchange import / export functionality
|
|
140
120
|
*/
|
|
141
121
|
async importAttestations(pubkey, attestations) {
|
|
142
|
-
// Min-max surround misses a surround vote beyond its lookback, require the highest target attestation to
|
|
143
|
-
// have the highest source epoch as `checkAttestation` relies on it
|
|
144
|
-
let latestAtt = await this.attestationByTarget.getLatest(pubkey);
|
|
145
|
-
let maxSourceAtt = latestAtt;
|
|
146
|
-
for (const attestation of attestations) {
|
|
147
|
-
if (latestAtt === null || attestation.targetEpoch >= latestAtt.targetEpoch) {
|
|
148
|
-
latestAtt = attestation;
|
|
149
|
-
}
|
|
150
|
-
if (maxSourceAtt === null || attestation.sourceEpoch > maxSourceAtt.sourceEpoch) {
|
|
151
|
-
maxSourceAtt = attestation;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (latestAtt && maxSourceAtt && latestAtt.sourceEpoch < maxSourceAtt.sourceEpoch) {
|
|
155
|
-
throw new InvalidAttestationError({
|
|
156
|
-
code: InvalidAttestationErrorCode.NEW_SURROUNDS_PREV,
|
|
157
|
-
attestation: latestAtt,
|
|
158
|
-
prev: maxSourceAtt,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
122
|
await this.attestationByTarget.set(pubkey, attestations);
|
|
162
123
|
// Pre-compute spans for all attestations
|
|
163
124
|
for (const attestation of attestations) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,wBAAwB,EAAE,4BAA4B,EAAC,MAAM,4BAA4B,CAAC;AAElH,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EAAC,6BAA6B,EAAC,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAC,+BAA+B,EAAC,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAC,uBAAuB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AACjF,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,EACvB,2BAA2B,GAC5B,CAAC;AAEF,IAAK,UAGJ;AAHD,WAAK,UAAU;IACb,iDAAmC,CAAA;IACnC,mCAAqB,CAAA;AACvB,CAAC,EAHI,UAAU,KAAV,UAAU,QAGd;AAED,MAAM,OAAO,oCAAoC;IACvC,mBAAmB,CAAgC;IACnD,qBAAqB,CAAkC;IACvD,cAAc,CAAiB;IAEvC,YACE,mBAAkD,EAClD,qBAAsD,EACtD,cAA8B;QAE9B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,yBAAyB,CAAC,MAAiB,EAAE,WAA0C;QAC3F,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAEpE,IAAI,UAAU,KAAK,UAAU,CAAC,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACpD,CAAC;QAED,uDAAuD;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAiB,EAAE,WAA0C;QAClF,yEAAyE;QACzE,sFAAsF;QACtF,IAAI,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;YACtD,MAAM,IAAI,uBAAuB,CAAC,EAAC,IAAI,EAAE,2BAA2B,CAAC,qBAAqB,EAAC,CAAC,CAAC;QAC/F,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/slashingProtection/attestation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,wBAAwB,EAAE,4BAA4B,EAAC,MAAM,4BAA4B,CAAC;AAElH,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EAAC,6BAA6B,EA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AC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEzD,yCAAyC;QACzC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACnE,CAAC;QAED,oCAAoC;QACpC,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;QAC5F,MAAM,cAAc,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;QAC5F,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YACrD,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,EAAE,EAAC,cAAc,EAAE,cAAc,EAAC,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAiB;QACxC,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BLSPubkey
|
|
1
|
+
import { BLSPubkey } from "@lodestar/types";
|
|
2
2
|
import { IDistanceStore, IMinMaxSurround, MinMaxSurroundAttestation } from "./interface.js";
|
|
3
3
|
export declare class MinMaxSurround implements IMinMaxSurround {
|
|
4
4
|
private store;
|
|
@@ -6,8 +6,6 @@ export declare class MinMaxSurround implements IMinMaxSurround {
|
|
|
6
6
|
constructor(store: IDistanceStore, options?: {
|
|
7
7
|
maxEpochLookback?: number;
|
|
8
8
|
});
|
|
9
|
-
/** Lowest epoch with a min-span entry after inserting an attestation with `sourceEpoch` */
|
|
10
|
-
minSpanCoverageStart(sourceEpoch: Epoch): Epoch;
|
|
11
9
|
assertNoSurround(pubKey: BLSPubkey, attestation: MinMaxSurroundAttestation): Promise<void>;
|
|
12
10
|
insertAttestation(pubKey: BLSPubkey, attestation: MinMaxSurroundAttestation): Promise<void>;
|
|
13
11
|
private updateMinSpan;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minMaxSurround.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/minMaxSurround/minMaxSurround.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"minMaxSurround.d.ts","sourceRoot":"","sources":["../../../src/slashingProtection/minMaxSurround/minMaxSurround.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAgB,cAAc,EAAE,eAAe,EAAE,yBAAyB,EAAC,MAAM,gBAAgB,CAAC;AAqBzG,qBAAa,cAAe,YAAW,eAAe;IACpD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YAAY,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAC,EAGvE;IAEK,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/F;IAEK,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhG;YAIa,aAAa;YAkBb,oBAAoB;YAcpB,aAAa;YAgBb,mBAAmB;CAWlC"}
|
|
@@ -5,8 +5,7 @@ import { SurroundAttestationError, SurroundAttestationErrorCode } from "./errors
|
|
|
5
5
|
* Number of epochs in the past to check for surrounding attestations.
|
|
6
6
|
*
|
|
7
7
|
* This value can be limited to a reasonable high amount as Lodestar does not solely rely on this strategy but also
|
|
8
|
-
*
|
|
9
|
-
* strategy (formally proven safe, https://github.com/michaelsproul/slashing-proofs) relaxed by this lookback.
|
|
8
|
+
* implements the minimal strategy which has been formally proven to be safe (https://github.com/michaelsproul/slashing-proofs).
|
|
10
9
|
*
|
|
11
10
|
* Limiting this value is required due to practical reasons as otherwise there would be a min-span DB read and write
|
|
12
11
|
* for each validator from current epoch until genesis which massively increases DB size and causes I/O lag, resulting in
|
|
@@ -24,10 +23,6 @@ export class MinMaxSurround {
|
|
|
24
23
|
this.store = store;
|
|
25
24
|
this.maxEpochLookback = options?.maxEpochLookback ?? DEFAULT_MAX_EPOCH_LOOKBACK;
|
|
26
25
|
}
|
|
27
|
-
/** Lowest epoch with a min-span entry after inserting an attestation with `sourceEpoch` */
|
|
28
|
-
minSpanCoverageStart(sourceEpoch) {
|
|
29
|
-
return Math.max(0, sourceEpoch - 1 - this.maxEpochLookback);
|
|
30
|
-
}
|
|
31
26
|
async assertNoSurround(pubKey, attestation) {
|
|
32
27
|
await this.assertNotSurrounding(pubKey, attestation);
|
|
33
28
|
await this.assertNotSurrounded(pubKey, attestation);
|
|
@@ -39,7 +34,7 @@ export class MinMaxSurround {
|
|
|
39
34
|
// min span
|
|
40
35
|
async updateMinSpan(pubKey, attestation) {
|
|
41
36
|
await this.assertNotSurrounding(pubKey, attestation);
|
|
42
|
-
const untilEpoch =
|
|
37
|
+
const untilEpoch = Math.max(0, attestation.sourceEpoch - 1 - this.maxEpochLookback);
|
|
43
38
|
const values = [];
|
|
44
39
|
for (let epoch = attestation.sourceEpoch - 1; epoch >= untilEpoch; epoch--) {
|
|
45
40
|
const minSpan = await this.store.minSpan.get(pubKey, epoch);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minMaxSurround.js","sourceRoot":"","sources":["../../../src/slashingProtection/minMaxSurround/minMaxSurround.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,wBAAwB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAC;AAGnF,+CAA+C;AAC/C,gEAAgE;AAEhE
|
|
1
|
+
{"version":3,"file":"minMaxSurround.js","sourceRoot":"","sources":["../../../src/slashingProtection/minMaxSurround/minMaxSurround.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,wBAAwB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAC;AAGnF,+CAA+C;AAC/C,gEAAgE;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAExC,MAAM,OAAO,cAAc;IACjB,KAAK,CAAiB;IACtB,gBAAgB,CAAS;IAEjC,YAAY,KAAqB,EAAE,OAAqC;QACtE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,IAAI,0BAA0B,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,MAAiB,EAAE,WAAsC;QAC9E,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAiB,EAAE,WAAsC;QAC/E,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;IAED,WAAW;IAEH,KAAK,CAAC,aAAa,CAAC,MAAiB,EAAE,WAAsC;QACnF,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAErD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,WAAW,GAAG,CAA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AAO;aACtD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodestar/validator",
|
|
3
|
-
"version": "1.48.0-dev.
|
|
3
|
+
"version": "1.48.0-dev.b71ab45af3",
|
|
4
4
|
"description": "A Typescript implementation of the validator client",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,22 +49,22 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@chainsafe/lodestar-z": "catalog:",
|
|
52
|
-
"@chainsafe/ssz": "^1.
|
|
53
|
-
"@lodestar/api": "^1.48.0-dev.
|
|
54
|
-
"@lodestar/config": "^1.48.0-dev.
|
|
55
|
-
"@lodestar/db": "^1.48.0-dev.
|
|
56
|
-
"@lodestar/params": "^1.48.0-dev.
|
|
57
|
-
"@lodestar/state-transition": "^1.48.0-dev.
|
|
58
|
-
"@lodestar/types": "^1.48.0-dev.
|
|
59
|
-
"@lodestar/utils": "^1.48.0-dev.
|
|
52
|
+
"@chainsafe/ssz": "^1.6.3",
|
|
53
|
+
"@lodestar/api": "^1.48.0-dev.b71ab45af3",
|
|
54
|
+
"@lodestar/config": "^1.48.0-dev.b71ab45af3",
|
|
55
|
+
"@lodestar/db": "^1.48.0-dev.b71ab45af3",
|
|
56
|
+
"@lodestar/params": "^1.48.0-dev.b71ab45af3",
|
|
57
|
+
"@lodestar/state-transition": "^1.48.0-dev.b71ab45af3",
|
|
58
|
+
"@lodestar/types": "^1.48.0-dev.b71ab45af3",
|
|
59
|
+
"@lodestar/utils": "^1.48.0-dev.b71ab45af3",
|
|
60
60
|
"strict-event-emitter-types": "^2.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@lodestar/logger": "^1.48.0-dev.
|
|
64
|
-
"@lodestar/spec-test-util": "^1.48.0-dev.
|
|
65
|
-
"@lodestar/test-utils": "^1.48.0-dev.
|
|
63
|
+
"@lodestar/logger": "^1.48.0-dev.b71ab45af3",
|
|
64
|
+
"@lodestar/spec-test-util": "^1.48.0-dev.b71ab45af3",
|
|
65
|
+
"@lodestar/test-utils": "^1.48.0-dev.b71ab45af3",
|
|
66
66
|
"@vekexasia/bigint-buffer2": "^1.1.1",
|
|
67
67
|
"rimraf": "^4.4.1"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d74208f6b07d25e15478c90f54a84c97d59860a4"
|
|
70
70
|
}
|
|
@@ -41,18 +41,6 @@ export class AttestationByTargetRepository {
|
|
|
41
41
|
return attestations.map((attestation) => this.type.deserialize(attestation));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/** Attestation with the highest target epoch recorded for `pubkey`, or null if none */
|
|
45
|
-
async getLatest(pubkey: BLSPubkey): Promise<SlashingProtectionAttestation | null> {
|
|
46
|
-
const [att] = await this.db.values({
|
|
47
|
-
gte: this.encodeKey(pubkey, 0),
|
|
48
|
-
lt: this.encodeKey(pubkey, Number.MAX_SAFE_INTEGER),
|
|
49
|
-
reverse: true,
|
|
50
|
-
limit: 1,
|
|
51
|
-
bucketId: this.bucketId,
|
|
52
|
-
});
|
|
53
|
-
return att ? this.type.deserialize(att) : null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
44
|
async get(pubkey: BLSPubkey, targetEpoch: Epoch): Promise<SlashingProtectionAttestation | null> {
|
|
57
45
|
const att = await this.db.get(this.encodeKey(pubkey, targetEpoch), this.dbReqOpts);
|
|
58
46
|
return att && this.type.deserialize(att);
|
|
@@ -29,11 +29,6 @@ export enum InvalidAttestationErrorCode {
|
|
|
29
29
|
* bound on target epochs for this validator.
|
|
30
30
|
*/
|
|
31
31
|
TARGET_LESS_THAN_OR_EQ_LOWER_BOUND = "ERR_INVALID_ATTESTATION_TARGET_LESS_THAN_OR_EQ_LOWER_BOUND",
|
|
32
|
-
/**
|
|
33
|
-
* The attestation is invalid because its source epoch is below the min-max span lookback window of the
|
|
34
|
-
* latest attestation of this validator, where a surround vote could not be detected.
|
|
35
|
-
*/
|
|
36
|
-
SOURCE_BELOW_MIN_SPAN_LOOKBACK = "ERR_INVALID_ATTESTATION_SOURCE_BELOW_MIN_SPAN_LOOKBACK",
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
type InvalidAttestationErrorType =
|
|
@@ -66,11 +61,6 @@ type InvalidAttestationErrorType =
|
|
|
66
61
|
code: InvalidAttestationErrorCode.TARGET_LESS_THAN_OR_EQ_LOWER_BOUND;
|
|
67
62
|
targetEpoch: Epoch;
|
|
68
63
|
minTargetEpoch: Epoch;
|
|
69
|
-
}
|
|
70
|
-
| {
|
|
71
|
-
code: InvalidAttestationErrorCode.SOURCE_BELOW_MIN_SPAN_LOOKBACK;
|
|
72
|
-
sourceEpoch: Epoch;
|
|
73
|
-
minSourceEpoch: Epoch;
|
|
74
64
|
};
|
|
75
65
|
|
|
76
66
|
export class InvalidAttestationError extends LodestarError<InvalidAttestationErrorType> {}
|
|
@@ -56,16 +56,9 @@ export class SlashingProtectionAttestationService {
|
|
|
56
56
|
throw new InvalidAttestationError({code: InvalidAttestationErrorCode.SOURCE_EXCEEDS_TARGET});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const latestAtt = await this.attestationByTarget.getLatest(pubKey);
|
|
60
|
-
|
|
61
59
|
// Check for a double vote. Namely, an existing attestation with the same target epoch,
|
|
62
|
-
// and a different signing root.
|
|
63
|
-
|
|
64
|
-
if (latestAtt && latestAtt.targetEpoch === attestation.targetEpoch) {
|
|
65
|
-
sameTargetAtt = latestAtt;
|
|
66
|
-
} else if (latestAtt && latestAtt.targetEpoch > attestation.targetEpoch) {
|
|
67
|
-
sameTargetAtt = await this.attestationByTarget.get(pubKey, attestation.targetEpoch);
|
|
68
|
-
}
|
|
60
|
+
// and a different signing root.
|
|
61
|
+
const sameTargetAtt = await this.attestationByTarget.get(pubKey, attestation.targetEpoch);
|
|
69
62
|
if (sameTargetAtt) {
|
|
70
63
|
// Interchange format allows for attestations without signing_root, then assume root is equal
|
|
71
64
|
if (isEqualNonZeroRoot(sameTargetAtt.signingRoot, attestation.signingRoot)) {
|
|
@@ -78,20 +71,6 @@ export class SlashingProtectionAttestationService {
|
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
73
|
|
|
81
|
-
// Min-span entries only exist within the lookback window below each recorded source epoch, a surround vote
|
|
82
|
-
// with an older source epoch is undetectable by min-max surround and must be rejected outright. Recorded
|
|
83
|
-
// attestations are surround-free, so the latest one has the highest source epoch and the widest window.
|
|
84
|
-
if (latestAtt) {
|
|
85
|
-
const minSourceEpoch = this.minMaxSurround.minSpanCoverageStart(latestAtt.sourceEpoch);
|
|
86
|
-
if (attestation.sourceEpoch < minSourceEpoch) {
|
|
87
|
-
throw new InvalidAttestationError({
|
|
88
|
-
code: InvalidAttestationErrorCode.SOURCE_BELOW_MIN_SPAN_LOOKBACK,
|
|
89
|
-
sourceEpoch: attestation.sourceEpoch,
|
|
90
|
-
minSourceEpoch,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
74
|
// Check for a surround vote
|
|
96
75
|
try {
|
|
97
76
|
await this.minMaxSurround.assertNoSurround(pubKey, attestation);
|
|
@@ -164,26 +143,6 @@ export class SlashingProtectionAttestationService {
|
|
|
164
143
|
* Interchange import / export functionality
|
|
165
144
|
*/
|
|
166
145
|
async importAttestations(pubkey: BLSPubkey, attestations: SlashingProtectionAttestation[]): Promise<void> {
|
|
167
|
-
// Min-max surround misses a surround vote beyond its lookback, require the highest target attestation to
|
|
168
|
-
// have the highest source epoch as `checkAttestation` relies on it
|
|
169
|
-
let latestAtt = await this.attestationByTarget.getLatest(pubkey);
|
|
170
|
-
let maxSourceAtt = latestAtt;
|
|
171
|
-
for (const attestation of attestations) {
|
|
172
|
-
if (latestAtt === null || attestation.targetEpoch >= latestAtt.targetEpoch) {
|
|
173
|
-
latestAtt = attestation;
|
|
174
|
-
}
|
|
175
|
-
if (maxSourceAtt === null || attestation.sourceEpoch > maxSourceAtt.sourceEpoch) {
|
|
176
|
-
maxSourceAtt = attestation;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (latestAtt && maxSourceAtt && latestAtt.sourceEpoch < maxSourceAtt.sourceEpoch) {
|
|
180
|
-
throw new InvalidAttestationError({
|
|
181
|
-
code: InvalidAttestationErrorCode.NEW_SURROUNDS_PREV,
|
|
182
|
-
attestation: latestAtt,
|
|
183
|
-
prev: maxSourceAtt,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
146
|
await this.attestationByTarget.set(pubkey, attestations);
|
|
188
147
|
|
|
189
148
|
// Pre-compute spans for all attestations
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {BLSPubkey
|
|
1
|
+
import {BLSPubkey} from "@lodestar/types";
|
|
2
2
|
import {SurroundAttestationError, SurroundAttestationErrorCode} from "./errors.js";
|
|
3
3
|
import {DistanceEntry, IDistanceStore, IMinMaxSurround, MinMaxSurroundAttestation} from "./interface.js";
|
|
4
4
|
|
|
@@ -9,8 +9,7 @@ import {DistanceEntry, IDistanceStore, IMinMaxSurround, MinMaxSurroundAttestatio
|
|
|
9
9
|
* Number of epochs in the past to check for surrounding attestations.
|
|
10
10
|
*
|
|
11
11
|
* This value can be limited to a reasonable high amount as Lodestar does not solely rely on this strategy but also
|
|
12
|
-
*
|
|
13
|
-
* strategy (formally proven safe, https://github.com/michaelsproul/slashing-proofs) relaxed by this lookback.
|
|
12
|
+
* implements the minimal strategy which has been formally proven to be safe (https://github.com/michaelsproul/slashing-proofs).
|
|
14
13
|
*
|
|
15
14
|
* Limiting this value is required due to practical reasons as otherwise there would be a min-span DB read and write
|
|
16
15
|
* for each validator from current epoch until genesis which massively increases DB size and causes I/O lag, resulting in
|
|
@@ -31,11 +30,6 @@ export class MinMaxSurround implements IMinMaxSurround {
|
|
|
31
30
|
this.maxEpochLookback = options?.maxEpochLookback ?? DEFAULT_MAX_EPOCH_LOOKBACK;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
/** Lowest epoch with a min-span entry after inserting an attestation with `sourceEpoch` */
|
|
35
|
-
minSpanCoverageStart(sourceEpoch: Epoch): Epoch {
|
|
36
|
-
return Math.max(0, sourceEpoch - 1 - this.maxEpochLookback);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
33
|
async assertNoSurround(pubKey: BLSPubkey, attestation: MinMaxSurroundAttestation): Promise<void> {
|
|
40
34
|
await this.assertNotSurrounding(pubKey, attestation);
|
|
41
35
|
await this.assertNotSurrounded(pubKey, attestation);
|
|
@@ -51,7 +45,7 @@ export class MinMaxSurround implements IMinMaxSurround {
|
|
|
51
45
|
private async updateMinSpan(pubKey: BLSPubkey, attestation: MinMaxSurroundAttestation): Promise<void> {
|
|
52
46
|
await this.assertNotSurrounding(pubKey, attestation);
|
|
53
47
|
|
|
54
|
-
const untilEpoch =
|
|
48
|
+
const untilEpoch = Math.max(0, attestation.sourceEpoch - 1 - this.maxEpochLookback);
|
|
55
49
|
|
|
56
50
|
const values: DistanceEntry[] = [];
|
|
57
51
|
for (let epoch = attestation.sourceEpoch - 1; epoch >= untilEpoch; epoch--) {
|