@lodestar/beacon-node 1.52.0-dev.8bada2d599 → 1.52.0-dev.93209fd84a
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/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +17 -13
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +4 -3
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +12 -11
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/bls/utils.js +1 -1
- package/lib/chain/bls/utils.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +12 -6
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
- package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
- package/lib/chain/opPools/inclusionListStore.js +5 -2
- package/lib/chain/opPools/inclusionListStore.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +5 -0
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +39 -1
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +13 -2
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +2 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +9 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +20 -11
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +22 -19
- package/src/api/impl/validator/index.ts +4 -2
- package/src/chain/blocks/verifyBlock.ts +14 -10
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
- package/src/chain/bls/utils.ts +1 -1
- package/src/chain/chain.ts +12 -6
- package/src/chain/opPools/inclusionListStore.ts +5 -2
- package/src/chain/shufflingCache.ts +40 -1
- package/src/chain/validation/aggregateAndProof.ts +19 -5
- package/src/metrics/metrics/lodestar.ts +9 -0
- package/src/network/network.ts +33 -11
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
|
@@ -9,7 +9,7 @@ import { ResponseTypeGetter } from "../types.js";
|
|
|
9
9
|
* ```
|
|
10
10
|
* Expects exactly one response
|
|
11
11
|
*/
|
|
12
|
-
export declare function collectExactOneTyped<T>(source: AsyncIterable<ResponseIncoming>, typeFn: ResponseTypeGetter<T
|
|
12
|
+
export declare function collectExactOneTyped<T>(source: AsyncIterable<ResponseIncoming>, typeFn: ResponseTypeGetter<T>, onInvalidResponse?: (chunk: ResponseIncoming) => void): Promise<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Sink for `<response_chunk>*`, from
|
|
15
15
|
* ```bnf
|
|
@@ -17,7 +17,7 @@ export declare function collectExactOneTyped<T>(source: AsyncIterable<ResponseIn
|
|
|
17
17
|
* ```
|
|
18
18
|
* Collects a bounded list of responses up to `maxResponses`
|
|
19
19
|
*/
|
|
20
|
-
export declare function collectMaxResponseTyped<T>(source: AsyncIterable<ResponseIncoming>, maxResponses: number, typeFn: ResponseTypeGetter<T>, serializedCache?: SerializedCache): Promise<T[]>;
|
|
20
|
+
export declare function collectMaxResponseTyped<T>(source: AsyncIterable<ResponseIncoming>, maxResponses: number, typeFn: ResponseTypeGetter<T>, serializedCache?: SerializedCache, onInvalidResponse?: (chunk: ResponseIncoming) => void): Promise<T[]>;
|
|
21
21
|
/**
|
|
22
22
|
* Sink for `<response_chunk>*`, from
|
|
23
23
|
* ```bnf
|
|
@@ -25,7 +25,7 @@ export declare function collectMaxResponseTyped<T>(source: AsyncIterable<Respons
|
|
|
25
25
|
* ```
|
|
26
26
|
* Collects a bounded list of responses up to `maxResponses`
|
|
27
27
|
*/
|
|
28
|
-
export declare function collectMaxResponseTypedWithBytes<T>(source: AsyncIterable<ResponseIncoming>, maxResponses: number, typeFn: ResponseTypeGetter<T>, serializedCache?: SerializedCache): Promise<T[]>;
|
|
28
|
+
export declare function collectMaxResponseTypedWithBytes<T>(source: AsyncIterable<ResponseIncoming>, maxResponses: number, typeFn: ResponseTypeGetter<T>, serializedCache?: SerializedCache, onInvalidResponse?: (chunk: ResponseIncoming) => void): Promise<T[]>;
|
|
29
29
|
/** Light wrapper on type to wrap deserialize errors */
|
|
30
|
-
export declare function sszDeserializeResponse<T>(type: Type<T>,
|
|
30
|
+
export declare function sszDeserializeResponse<T>(type: Type<T>, chunk: ResponseIncoming, onInvalidResponse?: (chunk: ResponseIncoming) => void): T;
|
|
31
31
|
//# sourceMappingURL=collect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAiC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAiC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACpD,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,EAC7C,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACvC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,eAAe,CAAC,EAAE,eAAe,EACjC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACpD,OAAO,CAAC,CAAC,EAAE,CAAC,CAed;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CAAC,CAAC,EACtD,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACvC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC7B,eAAe,CAAC,EAAE,eAAe,EACjC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACpD,OAAO,CAAC,CAAC,EAAE,CAAC,CAed;AAED,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,KAAK,EAAE,gBAAgB,EACvB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACpD,CAAC,CAOH"}
|
|
@@ -6,10 +6,10 @@ import { RequestError, RequestErrorCode } from "@lodestar/reqresp";
|
|
|
6
6
|
* ```
|
|
7
7
|
* Expects exactly one response
|
|
8
8
|
*/
|
|
9
|
-
export async function collectExactOneTyped(source, typeFn) {
|
|
9
|
+
export async function collectExactOneTyped(source, typeFn, onInvalidResponse) {
|
|
10
10
|
for await (const chunk of source) {
|
|
11
11
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
12
|
-
const response = sszDeserializeResponse(type, chunk
|
|
12
|
+
const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
13
13
|
return response;
|
|
14
14
|
}
|
|
15
15
|
throw new RequestError({ code: RequestErrorCode.EMPTY_RESPONSE });
|
|
@@ -21,12 +21,12 @@ export async function collectExactOneTyped(source, typeFn) {
|
|
|
21
21
|
* ```
|
|
22
22
|
* Collects a bounded list of responses up to `maxResponses`
|
|
23
23
|
*/
|
|
24
|
-
export async function collectMaxResponseTyped(source, maxResponses, typeFn, serializedCache) {
|
|
24
|
+
export async function collectMaxResponseTyped(source, maxResponses, typeFn, serializedCache, onInvalidResponse) {
|
|
25
25
|
// else: zero or more responses
|
|
26
26
|
const responses = [];
|
|
27
27
|
for await (const chunk of source) {
|
|
28
28
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
29
|
-
const response = sszDeserializeResponse(type, chunk
|
|
29
|
+
const response = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
30
30
|
// optionally cache the serialized response if the cache is available
|
|
31
31
|
serializedCache?.set(response, chunk.data);
|
|
32
32
|
responses.push(response);
|
|
@@ -43,12 +43,12 @@ export async function collectMaxResponseTyped(source, maxResponses, typeFn, seri
|
|
|
43
43
|
* ```
|
|
44
44
|
* Collects a bounded list of responses up to `maxResponses`
|
|
45
45
|
*/
|
|
46
|
-
export async function collectMaxResponseTypedWithBytes(source, maxResponses, typeFn, serializedCache) {
|
|
46
|
+
export async function collectMaxResponseTypedWithBytes(source, maxResponses, typeFn, serializedCache, onInvalidResponse) {
|
|
47
47
|
// else: zero or more responses
|
|
48
48
|
const responses = [];
|
|
49
49
|
for await (const chunk of source) {
|
|
50
50
|
const type = typeFn(chunk.fork, chunk.protocolVersion);
|
|
51
|
-
const data = sszDeserializeResponse(type, chunk
|
|
51
|
+
const data = sszDeserializeResponse(type, chunk, onInvalidResponse);
|
|
52
52
|
responses.push(data);
|
|
53
53
|
// optionally cache the serialized response if the cache is available
|
|
54
54
|
serializedCache?.set(data, chunk.data);
|
|
@@ -59,11 +59,12 @@ export async function collectMaxResponseTypedWithBytes(source, maxResponses, typ
|
|
|
59
59
|
return responses;
|
|
60
60
|
}
|
|
61
61
|
/** Light wrapper on type to wrap deserialize errors */
|
|
62
|
-
export function sszDeserializeResponse(type,
|
|
62
|
+
export function sszDeserializeResponse(type, chunk, onInvalidResponse) {
|
|
63
63
|
try {
|
|
64
|
-
return type.deserialize(
|
|
64
|
+
return type.deserialize(chunk.data);
|
|
65
65
|
}
|
|
66
66
|
catch (e) {
|
|
67
|
+
onInvalidResponse?.(chunk);
|
|
67
68
|
throw new RequestError({ code: RequestErrorCode.INVALID_RESPONSE_SSZ, errorMessage: e.message });
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collect.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAInF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAuC,EACvC,MAA6B;
|
|
1
|
+
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collect.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAInF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAuC,EACvC,MAA6B,EAC7B,iBAAqD;IAErD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,YAAY,CAAC,EAAC,IAAI,EAAE,gBAAgB,CAAC,cAAc,EAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAuC,EACvC,YAAoB,EACpB,MAA6B,EAC7B,eAAiC,EACjC,iBAAqD;IAErD,+BAA+B;IAC/B,MAAM,SAAS,GAAQ,EAAE,CAAC;IAC1B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QACxE,qEAAqE;QACrE,eAAe,EAAE,GAAG,CAAC,QAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACrD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,YAAY,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YACnE,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,MAAuC,EACvC,YAAoB,EACpB,MAA6B,EAC7B,eAAiC,EACjC,iBAAqD;IAErD,+BAA+B;IAC/B,MAAM,SAAS,GAAQ,EAAE,CAAC;IAC1B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QACpE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,qEAAqE;QACrE,eAAe,EAAE,GAAG,CAAC,IAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,YAAY,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YACnE,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,sBAAsB,CACpC,IAAa,EACb,KAAuB,EACvB,iBAAqD;IAErD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,IAAI,YAAY,CAAC,EAAC,IAAI,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,YAAY,EAAG,CAAW,CAAC,OAAO,EAAC,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { SerializedCache } from "../../../util/serializedCache.js";
|
|
|
6
6
|
* Asserts a response from BeaconBlocksByRange respects the request and is sequential
|
|
7
7
|
* Note: MUST allow missing block for skipped slots.
|
|
8
8
|
*/
|
|
9
|
-
export declare function collectSequentialBlocksInRange(blockStream: AsyncIterable<ResponseIncoming>, { count, startSlot }: Pick<phase0.BeaconBlocksByRangeRequest, "count" | "startSlot">, serializedCache?: SerializedCache): Promise<SignedBeaconBlock[]>;
|
|
9
|
+
export declare function collectSequentialBlocksInRange(blockStream: AsyncIterable<ResponseIncoming>, { count, startSlot }: Pick<phase0.BeaconBlocksByRangeRequest, "count" | "startSlot">, serializedCache?: SerializedCache, onInvalidResponse?: (chunk: ResponseIncoming) => void): Promise<SignedBeaconBlock[]>;
|
|
10
10
|
export declare enum BlocksByRangeErrorCode {
|
|
11
11
|
UNDER_START_SLOT = "BLOCKS_BY_RANGE_ERROR_UNDER_START_SLOT",
|
|
12
12
|
OVER_MAX_SLOT = "BLOCKS_BY_RANGE_ERROR_OVER_MAX_SLOT",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectSequentialBlocksInRange.d.ts","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collectSequentialBlocksInRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAIjE;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC5C,EAAC,KAAK,EAAE,SAAS,EAAC,EAAE,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,OAAO,GAAG,WAAW,CAAC,EAClF,eAAe,CAAC,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"collectSequentialBlocksInRange.d.ts","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collectSequentialBlocksInRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAIjE;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC5C,EAAC,KAAK,EAAE,SAAS,EAAC,EAAE,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,OAAO,GAAG,WAAW,CAAC,EAClF,eAAe,CAAC,EAAE,eAAe,EACjC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GACpD,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAgC9B;AAED,oBAAY,sBAAsB;IAChC,gBAAgB,2CAA2C;IAC3D,aAAa,wCAAwC;IACrD,YAAY,uCAAuC;CACpD;AAED,KAAK,sBAAsB,GACvB;IAAC,IAAI,EAAE,sBAAsB,CAAC,gBAAgB,CAAA;CAAC,GAC/C;IAAC,IAAI,EAAE,sBAAsB,CAAC,aAAa,CAAA;CAAC,GAC5C;IAAC,IAAI,EAAE,sBAAsB,CAAC,YAAY,CAAA;CAAC,CAAC;AAEhD,qBAAa,kBAAmB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;CAAG"}
|
|
@@ -5,11 +5,11 @@ import { sszDeserializeResponse } from "./collect.js";
|
|
|
5
5
|
* Asserts a response from BeaconBlocksByRange respects the request and is sequential
|
|
6
6
|
* Note: MUST allow missing block for skipped slots.
|
|
7
7
|
*/
|
|
8
|
-
export async function collectSequentialBlocksInRange(blockStream, { count, startSlot }, serializedCache) {
|
|
8
|
+
export async function collectSequentialBlocksInRange(blockStream, { count, startSlot }, serializedCache, onInvalidResponse) {
|
|
9
9
|
const blocks = [];
|
|
10
10
|
for await (const chunk of blockStream) {
|
|
11
11
|
const blockType = responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByRange](chunk.fork, chunk.protocolVersion);
|
|
12
|
-
const block = sszDeserializeResponse(blockType, chunk
|
|
12
|
+
const block = sszDeserializeResponse(blockType, chunk, onInvalidResponse);
|
|
13
13
|
const blockSlot = block.message.slot;
|
|
14
14
|
// Note: step is deprecated and assumed to be 1
|
|
15
15
|
if (blockSlot >= startSlot + count) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectSequentialBlocksInRange.js","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collectSequentialBlocksInRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAE,uBAAuB,EAAC,MAAM,aAAa,CAAC;AACnE,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,WAA4C,EAC5C,EAAC,KAAK,EAAE,SAAS,EAAiE,EAClF,eAAiC;
|
|
1
|
+
{"version":3,"file":"collectSequentialBlocksInRange.js","sourceRoot":"","sources":["../../../../src/network/reqresp/utils/collectSequentialBlocksInRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAE,uBAAuB,EAAC,MAAM,aAAa,CAAC;AACnE,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,WAA4C,EAC5C,EAAC,KAAK,EAAE,SAAS,EAAiE,EAClF,eAAiC,EACjC,iBAAqD;IAErD,MAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,uBAAuB,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QAChH,MAAM,KAAK,GAAG,sBAAsB,CAAC,SAAS,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAE1E,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAErC,+CAA+C;QAC/C,IAAI,SAAS,IAAI,SAAS,GAAG,KAAK,EAAE,CAAC;YACnC,MAAM,IAAI,kBAAkB,CAAC,EAAC,IAAI,EAAE,sBAAsB,CAAC,aAAa,EAAC,CAAC,CAAC;QAC7E,CAAC;QAED,IAAI,SAAS,GAAG,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,kBAAkB,CAAC,EAAC,IAAI,EAAE,sBAAsB,CAAC,gBAAgB,EAAC,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,SAAS,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;YACrD,MAAM,IAAI,kBAAkB,CAAC,EAAC,IAAI,EAAE,sBAAsB,CAAC,YAAY,EAAC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,qEAAqE;QACrE,eAAe,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3B,MAAM,CAAC,6BAA6B;QACtC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,qFAA2D,CAAA;IAC3D,+EAAqD,CAAA;IACrD,6EAAmD,CAAA;AACrD,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC;AAOD,MAAM,OAAO,kBAAmB,SAAQ,aAAqC;CAAG"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.52.0-dev.
|
|
14
|
+
"version": "1.52.0-dev.93209fd84a",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -126,18 +126,18 @@
|
|
|
126
126
|
"@libp2p/prometheus-metrics": "^5.0.31",
|
|
127
127
|
"@libp2p/tcp": "^11.0.30",
|
|
128
128
|
"@libp2p/utils": "^7.4.3",
|
|
129
|
-
"@lodestar/api": "^1.52.0-dev.
|
|
130
|
-
"@lodestar/config": "^1.52.0-dev.
|
|
131
|
-
"@lodestar/db": "^1.52.0-dev.
|
|
132
|
-
"@lodestar/fork-choice": "^1.52.0-dev.
|
|
133
|
-
"@lodestar/logger": "^1.52.0-dev.
|
|
134
|
-
"@lodestar/native": "^1.52.0-dev.
|
|
135
|
-
"@lodestar/params": "^1.52.0-dev.
|
|
136
|
-
"@lodestar/reqresp": "^1.52.0-dev.
|
|
137
|
-
"@lodestar/state-transition": "^1.52.0-dev.
|
|
138
|
-
"@lodestar/types": "^1.52.0-dev.
|
|
139
|
-
"@lodestar/utils": "^1.52.0-dev.
|
|
140
|
-
"@lodestar/validator": "^1.52.0-dev.
|
|
129
|
+
"@lodestar/api": "^1.52.0-dev.93209fd84a",
|
|
130
|
+
"@lodestar/config": "^1.52.0-dev.93209fd84a",
|
|
131
|
+
"@lodestar/db": "^1.52.0-dev.93209fd84a",
|
|
132
|
+
"@lodestar/fork-choice": "^1.52.0-dev.93209fd84a",
|
|
133
|
+
"@lodestar/logger": "^1.52.0-dev.93209fd84a",
|
|
134
|
+
"@lodestar/native": "^1.52.0-dev.93209fd84a",
|
|
135
|
+
"@lodestar/params": "^1.52.0-dev.93209fd84a",
|
|
136
|
+
"@lodestar/reqresp": "^1.52.0-dev.93209fd84a",
|
|
137
|
+
"@lodestar/state-transition": "^1.52.0-dev.93209fd84a",
|
|
138
|
+
"@lodestar/types": "^1.52.0-dev.93209fd84a",
|
|
139
|
+
"@lodestar/utils": "^1.52.0-dev.93209fd84a",
|
|
140
|
+
"@lodestar/validator": "^1.52.0-dev.93209fd84a",
|
|
141
141
|
"@multiformats/multiaddr": "^13.0.1",
|
|
142
142
|
"datastore-core": "^12.0.1",
|
|
143
143
|
"datastore-level": "^13.0.1",
|
|
@@ -159,8 +159,8 @@
|
|
|
159
159
|
"@ethereumjs/rlp": "^4.0.1",
|
|
160
160
|
"@libp2p/interface-internal": "^3.2.0",
|
|
161
161
|
"@libp2p/logger": "^6.2.15",
|
|
162
|
-
"@lodestar/spec-test-util": "^1.52.0-dev.
|
|
163
|
-
"@lodestar/test-utils": "^1.52.0-dev.
|
|
162
|
+
"@lodestar/spec-test-util": "^1.52.0-dev.93209fd84a",
|
|
163
|
+
"@lodestar/test-utils": "^1.52.0-dev.93209fd84a",
|
|
164
164
|
"@types/js-yaml": "^4.0.5",
|
|
165
165
|
"@types/qs": "^6.9.7",
|
|
166
166
|
"@types/tmp": "^0.2.3",
|
|
@@ -174,5 +174,5 @@
|
|
|
174
174
|
"beacon",
|
|
175
175
|
"blockchain"
|
|
176
176
|
],
|
|
177
|
-
"gitHead": "
|
|
177
|
+
"gitHead": "35d0dd163baa3816b01e3b5a30d51770ebc14f28"
|
|
178
178
|
}
|
|
@@ -190,28 +190,31 @@ export function getBeaconBlockApi(
|
|
|
190
190
|
|
|
191
191
|
switch (broadcastValidation) {
|
|
192
192
|
case routes.beacon.BroadcastValidation.gossip: {
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
try {
|
|
194
|
+
if (blockLocallyProduced) {
|
|
195
|
+
// Block production does not cover the proposer signature, the validator client signs the block
|
|
196
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot);
|
|
197
|
+
} else {
|
|
195
198
|
await validateGossipBlock(config, chain, signedBlock, fork);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (error instanceof BlockGossipError) {
|
|
202
|
+
switch (error.type.code) {
|
|
203
|
+
case BlockErrorCode.ALREADY_KNOWN:
|
|
204
|
+
// Block has already been seen, e.g. via gossip racing the publish API. Benign.
|
|
205
|
+
chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
|
|
206
|
+
return;
|
|
204
207
|
}
|
|
205
|
-
|
|
206
|
-
chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error);
|
|
207
|
-
chain.persistInvalidSszValue(
|
|
208
|
-
chain.config.getForkTypes(slot).SignedBeaconBlock,
|
|
209
|
-
signedBlock,
|
|
210
|
-
"api_reject_gossip_failure",
|
|
211
|
-
blockRoot
|
|
212
|
-
);
|
|
213
|
-
throw error;
|
|
214
208
|
}
|
|
209
|
+
|
|
210
|
+
chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error);
|
|
211
|
+
chain.persistInvalidSszValue(
|
|
212
|
+
chain.config.getForkTypes(slot).SignedBeaconBlock,
|
|
213
|
+
signedBlock,
|
|
214
|
+
"api_reject_gossip_failure",
|
|
215
|
+
blockRoot
|
|
216
|
+
);
|
|
217
|
+
throw error;
|
|
215
218
|
}
|
|
216
219
|
chain.logger.debug("Gossip checks validated while publishing the block", valLogMeta);
|
|
217
220
|
break;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ForkPreDeneb,
|
|
10
10
|
ForkPreGloas,
|
|
11
11
|
ForkSeq,
|
|
12
|
+
GENESIS_EPOCH,
|
|
12
13
|
GENESIS_SLOT,
|
|
13
14
|
SLOTS_PER_EPOCH,
|
|
14
15
|
SLOTS_PER_HISTORICAL_ROOT,
|
|
@@ -1684,7 +1685,8 @@ export function getValidatorApi(
|
|
|
1684
1685
|
|
|
1685
1686
|
// should not compare to headEpoch in order to handle skipped slots
|
|
1686
1687
|
// Check if the epoch is in the future after waiting for requested slot
|
|
1687
|
-
|
|
1688
|
+
// Before genesis the clock epoch is negative, treat it as GENESIS_EPOCH so the next epoch can be requested
|
|
1689
|
+
if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
|
|
1688
1690
|
throw new ApiError(400, "Cannot get duties for epoch more than one ahead");
|
|
1689
1691
|
}
|
|
1690
1692
|
|
|
@@ -1747,7 +1749,7 @@ export function getValidatorApi(
|
|
|
1747
1749
|
|
|
1748
1750
|
await waitForNextClosestEpoch();
|
|
1749
1751
|
|
|
1750
|
-
if (epoch > chain.clock.currentEpoch + 1) {
|
|
1752
|
+
if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
|
|
1751
1753
|
throw new ApiError(400, "Cannot get PTC duties for epoch more than one ahead");
|
|
1752
1754
|
}
|
|
1753
1755
|
|
|
@@ -2,6 +2,7 @@ import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
|
2
2
|
import {ForkName, ForkSeq, isForkPostFulu} from "@lodestar/params";
|
|
3
3
|
import {
|
|
4
4
|
DataAvailabilityStatus,
|
|
5
|
+
EpochShuffling,
|
|
5
6
|
IBeaconStateView,
|
|
6
7
|
computeEpochAtSlot,
|
|
7
8
|
getAttestingIndices,
|
|
@@ -111,22 +112,24 @@ export async function verifyBlocksInEpoch(
|
|
|
111
112
|
|
|
112
113
|
// Store indexed attestations for each block to avoid recomputing them during import
|
|
113
114
|
const indexedAttestationsByBlock: IndexedAttestation[][] = [];
|
|
115
|
+
const attestationShufflingsByBlock: EpochShuffling[][] = [];
|
|
114
116
|
for (const [i, block] of blocks.entries()) {
|
|
115
|
-
|
|
117
|
+
attestationShufflingsByBlock[i] = block.message.body.attestations.map((attestation) => {
|
|
116
118
|
const attEpoch = computeEpochAtSlot(attestation.data.slot);
|
|
117
119
|
// calling getShufflingAtEpoch may take some time for NativeBeaconStateView
|
|
118
120
|
// we should have the shuffling inside ShufflingCache most of the time
|
|
119
|
-
|
|
121
|
+
return (
|
|
120
122
|
this.shufflingCache.getSync(attEpoch, preState0.getShufflingDecisionRoot(attEpoch)) ??
|
|
121
|
-
preState0.getShufflingAtEpoch(attEpoch)
|
|
122
|
-
|
|
123
|
-
// these on mainnet blocks. See FullyVerifiedBlock.indexedAttestations.
|
|
124
|
-
return {
|
|
125
|
-
attestingIndices: getAttestingIndices(shuffling, fork, attestation),
|
|
126
|
-
data: attestation.data,
|
|
127
|
-
signature: attestation.signature,
|
|
128
|
-
};
|
|
123
|
+
preState0.getShufflingAtEpoch(attEpoch)
|
|
124
|
+
);
|
|
129
125
|
});
|
|
126
|
+
// Unlike getIndexedAttestation, keep attestingIndices in committee order: sorting them dominates building
|
|
127
|
+
// these on mainnet blocks. See FullyVerifiedBlock.indexedAttestations.
|
|
128
|
+
indexedAttestationsByBlock[i] = block.message.body.attestations.map((attestation, j) => ({
|
|
129
|
+
attestingIndices: getAttestingIndices(attestationShufflingsByBlock[i][j], fork, attestation),
|
|
130
|
+
data: attestation.data,
|
|
131
|
+
signature: attestation.signature,
|
|
132
|
+
}));
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
// Pick the data-availability source by fork:
|
|
@@ -200,6 +203,7 @@ export async function verifyBlocksInEpoch(
|
|
|
200
203
|
preState0,
|
|
201
204
|
blocks,
|
|
202
205
|
indexedAttestationsByBlock,
|
|
206
|
+
attestationShufflingsByBlock,
|
|
203
207
|
opts
|
|
204
208
|
),
|
|
205
209
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {
|
|
3
|
+
EpochShuffling,
|
|
3
4
|
IBeaconStateView,
|
|
4
5
|
SyncCommitteeCacheEmpty,
|
|
5
6
|
getBlockSignatureSets,
|
|
@@ -28,6 +29,7 @@ export async function verifyBlocksSignatures(
|
|
|
28
29
|
preState0: IBeaconStateView,
|
|
29
30
|
blocks: SignedBeaconBlock[],
|
|
30
31
|
indexedAttestationsByBlock: IndexedAttestation[][],
|
|
32
|
+
attestationShufflingsByBlock: EpochShuffling[][],
|
|
31
33
|
opts: ImportBlockOpts
|
|
32
34
|
): Promise<{verifySignaturesTime: number}> {
|
|
33
35
|
const isValidPromises: Promise<boolean>[] = [];
|
|
@@ -49,6 +51,7 @@ export async function verifyBlocksSignatures(
|
|
|
49
51
|
bls.verifySignatureSets(
|
|
50
52
|
getBlockSignatureSets(config, currentSyncCommitteeIndexed, preState0, block, indexedAttestationsByBlock[i], {
|
|
51
53
|
skipProposerSignature: opts.validProposerSignature,
|
|
54
|
+
attestationShufflings: attestationShufflingsByBlock[i],
|
|
52
55
|
}),
|
|
53
56
|
// Prioritize block verification over attestations, since
|
|
54
57
|
// attestations already buffer up to `MAX_BUFFER_WAIT_MS`
|
package/src/chain/bls/utils.ts
CHANGED
|
@@ -32,7 +32,7 @@ export function chunkSameMessageSignatureSets(sets: SameMessageSignatureSet[]):
|
|
|
32
32
|
export function getAggregatedPubkeysCount(signatureSets: ISignatureSet[]): number {
|
|
33
33
|
let pubkeysCount = 0;
|
|
34
34
|
for (const set of signatureSets) {
|
|
35
|
-
if (set.type === SignatureSetType.aggregate) {
|
|
35
|
+
if (set.type === SignatureSetType.aggregate || set.type === SignatureSetType.committee) {
|
|
36
36
|
pubkeysCount += set.indices.length;
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/chain/chain.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
AncestorStatus,
|
|
8
8
|
CheckpointWithHex,
|
|
9
9
|
EpochDifference,
|
|
10
|
+
ForkChoiceError,
|
|
11
|
+
ForkChoiceErrorCode,
|
|
10
12
|
ForkChoiceStateGetter,
|
|
11
13
|
IForkChoice,
|
|
12
14
|
PayloadStatus,
|
|
@@ -1855,14 +1857,18 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1855
1857
|
private onClockSlot(slot: Slot): void {
|
|
1856
1858
|
this.logger.verbose("Clock slot", {slot});
|
|
1857
1859
|
|
|
1858
|
-
// CRITICAL UPDATE
|
|
1859
|
-
if (this.forkChoice.irrecoverableError) {
|
|
1860
|
-
this.processShutdownCallback(this.forkChoice.irrecoverableError);
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
1860
|
// updateTime() recomputes the head on epoch-boundary checkpoint pull-up and under fast confirmation
|
|
1864
1861
|
const prevHead = this.forkChoice.getHead();
|
|
1865
|
-
|
|
1862
|
+
try {
|
|
1863
|
+
this.forkChoice.updateTime(slot);
|
|
1864
|
+
} catch (e) {
|
|
1865
|
+
// Per optimistic sync the node MAY exit once the justified checkpoint is INVALIDATED, fork choice has no head
|
|
1866
|
+
if (e instanceof ForkChoiceError && e.type.code === ForkChoiceErrorCode.INVALID_JUSTIFIED_EXECUTION_STATUS) {
|
|
1867
|
+
this.processShutdownCallback(e);
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
throw e;
|
|
1871
|
+
}
|
|
1866
1872
|
this.emitHeadEvents(prevHead, this.forkChoice.getHead());
|
|
1867
1873
|
this.metrics?.clockSlot.set(slot);
|
|
1868
1874
|
|
|
@@ -164,9 +164,12 @@ export class InclusionListStore {
|
|
|
164
164
|
return out;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Lists are kept one slot past the MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS serving window, the lists of slot N are
|
|
169
|
+
* read when the payload of slot N + 1 is processed, which may happen during slot N + 2
|
|
170
|
+
*/
|
|
168
171
|
prune(clockSlot: Slot): void {
|
|
169
|
-
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS;
|
|
172
|
+
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS - 1;
|
|
170
173
|
|
|
171
174
|
for (const slot of this.inclusionLists.keys()) {
|
|
172
175
|
if (slot < horizon) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {computeCommitteePubkeys, releaseCommitteePubkeys} from "@lodestar/native/committee-pubkeys";
|
|
2
|
+
import {ForkSeq, GENESIS_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
EpochShuffling,
|
|
4
5
|
IBeaconStateView,
|
|
@@ -272,6 +273,40 @@ export class ShufflingCache {
|
|
|
272
273
|
// set the shuffling
|
|
273
274
|
shufflingAtEpoch.set(decisionRoot, {type: CacheItemType.shuffling, shuffling});
|
|
274
275
|
this.prune();
|
|
276
|
+
if (this.has(shuffling.epoch, decisionRoot)) {
|
|
277
|
+
this.computeCommitteePubkeys(shuffling, decisionRoot);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Committee pubkeys make attestation signature sets cheaper to verify. Until they resolve, and if computing them
|
|
283
|
+
* fails, sets aggregate the participants instead.
|
|
284
|
+
*/
|
|
285
|
+
private computeCommitteePubkeys(shuffling: EpochShuffling, decisionRoot: RootHex): void {
|
|
286
|
+
const timer = this.metrics?.shufflingCache.committeePubkeysComputeTime.startTimer();
|
|
287
|
+
const onError = (e: unknown): void => {
|
|
288
|
+
this.metrics?.shufflingCache.committeePubkeysErrors.inc();
|
|
289
|
+
this.logger?.debug("Error computing committee pubkeys", {epoch: shuffling.epoch, decisionRoot}, e as Error);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
let promise: Promise<number>;
|
|
293
|
+
try {
|
|
294
|
+
promise = computeCommitteePubkeys(shuffling.shuffling, SLOTS_PER_EPOCH, shuffling.committeesPerSlot);
|
|
295
|
+
} catch (e) {
|
|
296
|
+
onError(e);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
promise.then((id) => {
|
|
301
|
+
timer?.();
|
|
302
|
+
const cacheItem = this.itemsByDecisionRootByEpoch.get(shuffling.epoch)?.get(decisionRoot);
|
|
303
|
+
if (cacheItem !== undefined && isShufflingCacheItem(cacheItem) && cacheItem.shuffling === shuffling) {
|
|
304
|
+
shuffling.committeePubkeysId = id;
|
|
305
|
+
} else {
|
|
306
|
+
// Pruned while computing
|
|
307
|
+
releaseCommitteePubkeys(id);
|
|
308
|
+
}
|
|
309
|
+
}, onError);
|
|
275
310
|
}
|
|
276
311
|
|
|
277
312
|
/**
|
|
@@ -294,6 +329,10 @@ export class ShufflingCache {
|
|
|
294
329
|
this.metrics?.shufflingCache.cancelledPromises.inc({reason: ShufflingPromiseCancelReason.pruned});
|
|
295
330
|
} else {
|
|
296
331
|
prunedShufflings++;
|
|
332
|
+
if (cacheItem.shuffling.committeePubkeysId !== undefined) {
|
|
333
|
+
releaseCommitteePubkeys(cacheItem.shuffling.committeePubkeysId);
|
|
334
|
+
cacheItem.shuffling.committeePubkeysId = undefined;
|
|
335
|
+
}
|
|
297
336
|
}
|
|
298
337
|
}
|
|
299
338
|
this.itemsByDecisionRootByEpoch.delete(epoch);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {
|
|
3
|
+
ISignatureSet,
|
|
4
|
+
SignatureSetType,
|
|
3
5
|
computeEpochAtSlot,
|
|
4
6
|
createAggregateSignatureSetFromComponents,
|
|
5
7
|
isAggregatorFromCommitteeLength,
|
|
@@ -259,11 +261,23 @@ async function validateAggregateAndProof(
|
|
|
259
261
|
// [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
|
|
260
262
|
// [REJECT] The signature of aggregate is valid.
|
|
261
263
|
const signingRoot = cachedAttData ? cachedAttData.signingRoot : getAttestationDataSigningRoot(chain.config, attData);
|
|
262
|
-
const indexedAttestationSignatureSet =
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
const indexedAttestationSignatureSet: ISignatureSet =
|
|
265
|
+
shuffling.committeePubkeysId === undefined
|
|
266
|
+
? createAggregateSignatureSetFromComponents(
|
|
267
|
+
indexedAttestation.attestingIndices,
|
|
268
|
+
signingRoot,
|
|
269
|
+
indexedAttestation.signature
|
|
270
|
+
)
|
|
271
|
+
: {
|
|
272
|
+
type: SignatureSetType.committee,
|
|
273
|
+
indices: indexedAttestation.attestingIndices,
|
|
274
|
+
committeePubkeysId: shuffling.committeePubkeysId,
|
|
275
|
+
slot: attSlot,
|
|
276
|
+
committeeIndices: [committeeIndex],
|
|
277
|
+
aggregationBits: aggregate.aggregationBits,
|
|
278
|
+
signingRoot,
|
|
279
|
+
signature: indexedAttestation.signature,
|
|
280
|
+
};
|
|
267
281
|
const signatureSets = [
|
|
268
282
|
getSelectionProofSignatureSet(chain.config, attSlot, aggregatorIndex, signedAggregateAndProof),
|
|
269
283
|
getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregatorIndex, signedAggregateAndProof),
|
|
@@ -1784,6 +1784,15 @@ export function createLodestarMetrics(
|
|
|
1784
1784
|
help: "Time from promise insertion until promise resolution when shuffling was ready in seconds",
|
|
1785
1785
|
buckets: [0.5, 1, 1.5, 2],
|
|
1786
1786
|
}),
|
|
1787
|
+
committeePubkeysComputeTime: register.histogram({
|
|
1788
|
+
name: "lodestar_shuffling_cache_committee_pubkeys_compute_seconds",
|
|
1789
|
+
help: "Time to aggregate the committee pubkeys of a shuffling off the main thread in seconds",
|
|
1790
|
+
buckets: [0.1, 0.25, 0.5, 1, 2, 5],
|
|
1791
|
+
}),
|
|
1792
|
+
committeePubkeysErrors: register.counter({
|
|
1793
|
+
name: "lodestar_shuffling_cache_committee_pubkeys_errors_total",
|
|
1794
|
+
help: "Total number of shufflings whose committee pubkeys could not be computed",
|
|
1795
|
+
}),
|
|
1787
1796
|
},
|
|
1788
1797
|
|
|
1789
1798
|
seenCache: {
|