@lodestar/beacon-node 1.52.0-dev.0ac7778d70 → 1.52.0-dev.18d4ea7338
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 +45 -34
- 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/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +3 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +17 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +21 -17
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.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/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
- package/lib/chain/blocks/verifyPayloadsDataAvailability.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/forkChoice/index.d.ts +1 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +1 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
- package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.js +34 -11
- package/lib/chain/forkChoiceExecutionEngine.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/options.js +1 -1
- package/lib/chain/options.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/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +8 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +4 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +9 -0
- package/lib/metrics/metrics/beacon.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 +54 -42
- package/src/api/impl/validator/index.ts +4 -2
- package/src/chain/blocks/blockInput/blockInput.ts +4 -1
- package/src/chain/blocks/importExecutionPayload.ts +21 -2
- package/src/chain/blocks/verifyBlock.ts +24 -17
- package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
- package/src/chain/bls/utils.ts +1 -1
- package/src/chain/chain.ts +12 -6
- package/src/chain/forkChoice/index.ts +1 -4
- package/src/chain/forkChoiceExecutionEngine.ts +48 -15
- package/src/chain/opPools/inclusionListStore.ts +5 -2
- package/src/chain/options.ts +1 -1
- package/src/chain/shufflingCache.ts +40 -1
- package/src/chain/validation/aggregateAndProof.ts +19 -5
- package/src/chain/validation/dataColumnSidecar.ts +7 -1
- package/src/metrics/metrics/beacon.ts +9 -0
- 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.18d4ea7338",
|
|
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.18d4ea7338",
|
|
130
|
+
"@lodestar/config": "^1.52.0-dev.18d4ea7338",
|
|
131
|
+
"@lodestar/db": "^1.52.0-dev.18d4ea7338",
|
|
132
|
+
"@lodestar/fork-choice": "^1.52.0-dev.18d4ea7338",
|
|
133
|
+
"@lodestar/logger": "^1.52.0-dev.18d4ea7338",
|
|
134
|
+
"@lodestar/native": "^1.52.0-dev.18d4ea7338",
|
|
135
|
+
"@lodestar/params": "^1.52.0-dev.18d4ea7338",
|
|
136
|
+
"@lodestar/reqresp": "^1.52.0-dev.18d4ea7338",
|
|
137
|
+
"@lodestar/state-transition": "^1.52.0-dev.18d4ea7338",
|
|
138
|
+
"@lodestar/types": "^1.52.0-dev.18d4ea7338",
|
|
139
|
+
"@lodestar/utils": "^1.52.0-dev.18d4ea7338",
|
|
140
|
+
"@lodestar/validator": "^1.52.0-dev.18d4ea7338",
|
|
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.18d4ea7338",
|
|
163
|
+
"@lodestar/test-utils": "^1.52.0-dev.18d4ea7338",
|
|
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": "66fe9bc6adbccba42ef987b526de2b036197a6f3"
|
|
178
178
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from "@lodestar/state-transition";
|
|
26
26
|
import {
|
|
27
27
|
ProducedBlockSource,
|
|
28
|
+
RootHex,
|
|
28
29
|
SignedBeaconBlock,
|
|
29
30
|
SignedBlindedBeaconBlock,
|
|
30
31
|
SignedBlockContents,
|
|
@@ -190,28 +191,31 @@ export function getBeaconBlockApi(
|
|
|
190
191
|
|
|
191
192
|
switch (broadcastValidation) {
|
|
192
193
|
case routes.beacon.BroadcastValidation.gossip: {
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
try {
|
|
195
|
+
if (blockLocallyProduced) {
|
|
196
|
+
// Block production does not cover the proposer signature, the validator client signs the block
|
|
197
|
+
await verifyBlockProposerSignature(chain, signedBlock, blockRoot);
|
|
198
|
+
} else {
|
|
195
199
|
await validateGossipBlock(config, chain, signedBlock, fork);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
if (error instanceof BlockGossipError) {
|
|
203
|
+
switch (error.type.code) {
|
|
204
|
+
case BlockErrorCode.ALREADY_KNOWN:
|
|
205
|
+
// Block has already been seen, e.g. via gossip racing the publish API. Benign.
|
|
206
|
+
chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
|
|
207
|
+
return;
|
|
204
208
|
}
|
|
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
209
|
}
|
|
210
|
+
|
|
211
|
+
chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error);
|
|
212
|
+
chain.persistInvalidSszValue(
|
|
213
|
+
chain.config.getForkTypes(slot).SignedBeaconBlock,
|
|
214
|
+
signedBlock,
|
|
215
|
+
"api_reject_gossip_failure",
|
|
216
|
+
blockRoot
|
|
217
|
+
);
|
|
218
|
+
throw error;
|
|
215
219
|
}
|
|
216
220
|
chain.logger.debug("Gossip checks validated while publishing the block", valLogMeta);
|
|
217
221
|
break;
|
|
@@ -507,26 +511,32 @@ export function getBeaconBlockApi(
|
|
|
507
511
|
|
|
508
512
|
const result: routes.beacon.BlockHeaderResponse[] = [];
|
|
509
513
|
if (parentRoot) {
|
|
514
|
+
let finalizedRoot: RootHex | null = null;
|
|
510
515
|
const finalizedBlock = await db.blockArchive.getByParentRoot(fromHex(parentRoot));
|
|
511
516
|
if (finalizedBlock) {
|
|
512
|
-
|
|
517
|
+
const header = toBeaconHeaderResponse(config, finalizedBlock, true);
|
|
518
|
+
finalizedRoot = toRootHex(header.root);
|
|
519
|
+
result.push(header);
|
|
513
520
|
}
|
|
514
521
|
const nonFinalizedBlocks = chain.forkChoice.getBlockSummariesByParentRoot(parentRoot);
|
|
515
522
|
await Promise.all(
|
|
516
523
|
nonFinalizedBlocks.map(async (summary) => {
|
|
524
|
+
// The finalized block stays in fork choice as its anchor after it is archived
|
|
525
|
+
if (summary.blockRoot === finalizedRoot) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
517
528
|
const blockResult = await chain.getBlockByRoot(summary.blockRoot);
|
|
518
529
|
if (blockResult) {
|
|
530
|
+
// There is no canonical block at the slot of a child that was reorged out by a later sibling
|
|
519
531
|
const canonical = chain.forkChoice.getCanonicalBlockAtSlot(blockResult.block.message.slot);
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
executionOptimistic = true;
|
|
526
|
-
}
|
|
527
|
-
// Block from hot db which only contains unfinalized blocks
|
|
528
|
-
finalized = false;
|
|
532
|
+
result.push(
|
|
533
|
+
toBeaconHeaderResponse(config, blockResult.block, canonical?.blockRoot === summary.blockRoot)
|
|
534
|
+
);
|
|
535
|
+
if (isOptimisticBlock(summary)) {
|
|
536
|
+
executionOptimistic = true;
|
|
529
537
|
}
|
|
538
|
+
// Block from hot db which only contains unfinalized blocks
|
|
539
|
+
finalized = false;
|
|
530
540
|
}
|
|
531
541
|
})
|
|
532
542
|
);
|
|
@@ -551,21 +561,18 @@ export function getBeaconBlockApi(
|
|
|
551
561
|
return {data: [], meta: {executionOptimistic: false, finalized: false}};
|
|
552
562
|
}
|
|
553
563
|
|
|
564
|
+
let canonicalRoot: RootHex | null = null;
|
|
554
565
|
const canonicalBlock = await chain.getCanonicalBlockAtSlot(slot);
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
result.push(toBeaconHeaderResponse(config, canonicalBlock.block, true));
|
|
563
|
-
if (!canonicalBlock.finalized) {
|
|
564
|
-
finalized = false;
|
|
566
|
+
if (canonicalBlock) {
|
|
567
|
+
const header = toBeaconHeaderResponse(config, canonicalBlock.block, true);
|
|
568
|
+
canonicalRoot = toRootHex(header.root);
|
|
569
|
+
result.push(header);
|
|
570
|
+
if (!canonicalBlock.finalized) {
|
|
571
|
+
finalized = false;
|
|
572
|
+
}
|
|
565
573
|
}
|
|
566
574
|
|
|
567
|
-
//
|
|
568
|
-
// TODO: What is this logic?
|
|
575
|
+
// Non-canonical blocks at the slot, also if the canonical chain skipped it
|
|
569
576
|
await Promise.all(
|
|
570
577
|
chain.forkChoice.getBlockSummariesAtSlot(slot).map(async (summary) => {
|
|
571
578
|
if (isOptimisticBlock(summary)) {
|
|
@@ -573,7 +580,7 @@ export function getBeaconBlockApi(
|
|
|
573
580
|
}
|
|
574
581
|
finalized = false;
|
|
575
582
|
|
|
576
|
-
if (summary.blockRoot !==
|
|
583
|
+
if (summary.blockRoot !== canonicalRoot) {
|
|
577
584
|
const blockResult = await chain.getBlockByRoot(summary.blockRoot);
|
|
578
585
|
if (blockResult) {
|
|
579
586
|
result.push(toBeaconHeaderResponse(config, blockResult.block));
|
|
@@ -581,6 +588,11 @@ export function getBeaconBlockApi(
|
|
|
581
588
|
}
|
|
582
589
|
})
|
|
583
590
|
);
|
|
591
|
+
|
|
592
|
+
// skip slot
|
|
593
|
+
if (result.length === 0) {
|
|
594
|
+
return {data: [], meta: {executionOptimistic: false, finalized: false}};
|
|
595
|
+
}
|
|
584
596
|
}
|
|
585
597
|
|
|
586
598
|
return {
|
|
@@ -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
|
|
|
@@ -493,12 +493,15 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
|
|
|
493
493
|
const hasComputedAllData =
|
|
494
494
|
// has all sampled columns
|
|
495
495
|
sampledColumns.length === this.sampledColumns.length;
|
|
496
|
+
// A column after the block and its data were complete does not move the completion time
|
|
497
|
+
const timeCompleteSec =
|
|
498
|
+
this.state.hasBlock && this.state.hasAllData ? this.state.timeCompleteSec : seenTimestampSec;
|
|
496
499
|
|
|
497
500
|
this.state = {
|
|
498
501
|
...this.state,
|
|
499
502
|
hasAllData: hasAllData || this.state.hasAllData,
|
|
500
503
|
hasComputedAllData: hasComputedAllData || this.state.hasComputedAllData,
|
|
501
|
-
timeCompleteSec: hasAllData ?
|
|
504
|
+
timeCompleteSec: hasAllData ? timeCompleteSec : undefined,
|
|
502
505
|
} as BlockInputColumnsState;
|
|
503
506
|
|
|
504
507
|
if (hasAllData && sampledColumns !== null) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ForkChoiceError,
|
|
6
6
|
ForkChoiceErrorCode,
|
|
7
7
|
InvalidBlockCode,
|
|
8
|
+
LVHInvalidJudged,
|
|
8
9
|
PayloadExecutionStatus,
|
|
9
10
|
getFinalizedExecutionBlockHash,
|
|
10
11
|
getSafeExecutionBlockHash,
|
|
@@ -16,11 +17,12 @@ import {
|
|
|
16
17
|
isStatePostHeze,
|
|
17
18
|
} from "@lodestar/state-transition";
|
|
18
19
|
import {RootHex, bellatrix} from "@lodestar/types";
|
|
19
|
-
import {isErrorAborted} from "@lodestar/utils";
|
|
20
|
+
import {isErrorAborted, toRootHex} from "@lodestar/utils";
|
|
20
21
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
21
22
|
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
22
23
|
import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
23
24
|
import {BeaconChain} from "../chain.js";
|
|
25
|
+
import {ExecutionInvalidSource} from "../forkChoice/index.js";
|
|
24
26
|
import {RegenCaller} from "../regen/interface.js";
|
|
25
27
|
import {PayloadEnvelopeInput} from "../seenCache/seenPayloadEnvelopeInput.js";
|
|
26
28
|
import {PayloadEnvelopeInputSource} from "./payloadEnvelopeInput/index.js";
|
|
@@ -267,12 +269,29 @@ export async function importExecutionPayload(
|
|
|
267
269
|
case ExecutionPayloadStatus.VALID:
|
|
268
270
|
break;
|
|
269
271
|
|
|
270
|
-
case ExecutionPayloadStatus.INVALID:
|
|
272
|
+
case ExecutionPayloadStatus.INVALID: {
|
|
273
|
+
// An LVH above the parent means the payload chain this block builds on is invalid too. The rejected payload
|
|
274
|
+
// itself never enters fork choice, so an LVH equal to the parent hash changes nothing
|
|
275
|
+
const parentHashHex = toRootHex(envelope.payload.parentHash);
|
|
276
|
+
if (execResult.latestValidHash !== null && execResult.latestValidHash !== parentHashHex) {
|
|
277
|
+
this.executionEngine.invalidateExecutionPayloads(
|
|
278
|
+
{
|
|
279
|
+
executionStatus: ExecutionStatus.Invalid,
|
|
280
|
+
latestValidExecHash: execResult.latestValidHash,
|
|
281
|
+
invalidateFromBlockRoot: protoBlock.parentRoot,
|
|
282
|
+
invalidateFromBlockHash: parentHashHex,
|
|
283
|
+
judged: LVHInvalidJudged.ChildPayload,
|
|
284
|
+
},
|
|
285
|
+
ExecutionInvalidSource.newPayload,
|
|
286
|
+
{slot, root: blockRootHex, payloadBlockHash: blockHashHex}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
271
289
|
throw new PayloadError(payloadInput, {
|
|
272
290
|
code: PayloadErrorCode.EXECUTION_ENGINE_INVALID,
|
|
273
291
|
execStatus: execResult.status,
|
|
274
292
|
errorMessage: execResult.validationError ?? "",
|
|
275
293
|
});
|
|
294
|
+
}
|
|
276
295
|
|
|
277
296
|
case ExecutionPayloadStatus.ACCEPTED:
|
|
278
297
|
case ExecutionPayloadStatus.SYNCING:
|
|
@@ -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:
|
|
@@ -135,7 +138,7 @@ export async function verifyBlocksInEpoch(
|
|
|
135
138
|
const daAvailabilityPromise: Promise<{
|
|
136
139
|
blockDAStatuses: DataAvailabilityStatus[];
|
|
137
140
|
payloadDAStatuses: Map<Slot, DataAvailabilityStatus>;
|
|
138
|
-
|
|
141
|
+
availableTimeMs: number;
|
|
139
142
|
}> =
|
|
140
143
|
fork >= ForkSeq.gloas
|
|
141
144
|
? (async () => {
|
|
@@ -148,7 +151,7 @@ export async function verifyBlocksInEpoch(
|
|
|
148
151
|
payloadEnvelopes !== null
|
|
149
152
|
? Array.from(payloadEnvelopes.values()).filter((payloadInput) => payloadInput.hasPayloadEnvelope())
|
|
150
153
|
: [];
|
|
151
|
-
const {dataAvailabilityStatuses,
|
|
154
|
+
const {dataAvailabilityStatuses, availableTimeMs} = await verifyPayloadsDataAvailability(
|
|
152
155
|
this.config,
|
|
153
156
|
payloadInputsForDa,
|
|
154
157
|
abortController.signal
|
|
@@ -162,25 +165,25 @@ export async function verifyBlocksInEpoch(
|
|
|
162
165
|
// post-gloas, DataAvailabilityStatus is NotRequired for forkChoice.onBlock() ProtoBlock
|
|
163
166
|
blockDAStatuses: blockInputs.map(() => DataAvailabilityStatus.NotRequired),
|
|
164
167
|
payloadDAStatuses,
|
|
165
|
-
|
|
168
|
+
availableTimeMs,
|
|
166
169
|
};
|
|
167
170
|
})()
|
|
168
171
|
: (async () => {
|
|
169
|
-
const {dataAvailabilityStatuses,
|
|
172
|
+
const {dataAvailabilityStatuses, availableTimeMs} = await verifyBlocksDataAvailability(
|
|
170
173
|
blockInputs,
|
|
171
174
|
abortController.signal
|
|
172
175
|
);
|
|
173
176
|
return {
|
|
174
177
|
blockDAStatuses: dataAvailabilityStatuses,
|
|
175
178
|
payloadDAStatuses: new Map<Slot, DataAvailabilityStatus>(),
|
|
176
|
-
|
|
179
|
+
availableTimeMs,
|
|
177
180
|
};
|
|
178
181
|
})();
|
|
179
182
|
|
|
180
183
|
// batch all I/O operations to reduce overhead
|
|
181
184
|
const [
|
|
182
185
|
segmentExecStatus,
|
|
183
|
-
{blockDAStatuses, payloadDAStatuses,
|
|
186
|
+
{blockDAStatuses, payloadDAStatuses, availableTimeMs},
|
|
184
187
|
{verifySignaturesTime},
|
|
185
188
|
{postStates, proposerBalanceDeltas, verifyStateTime},
|
|
186
189
|
] = await Promise.all([
|
|
@@ -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
|
|
|
@@ -304,15 +308,18 @@ export async function verifyBlocksInEpoch(
|
|
|
304
308
|
const recvTofullyVerifedTime = fullyVerifiedTime / 1000 - opts.seenTimestampSec;
|
|
305
309
|
this.metrics?.gossipBlock.receivedToFullyVerifiedTime.observe(recvTofullyVerifedTime);
|
|
306
310
|
|
|
307
|
-
const verifiedToBlobsAvailabiltyTime = Math.max(
|
|
311
|
+
const verifiedToBlobsAvailabiltyTime = Math.max(availableTimeMs - fullyVerifiedTime, 0) / 1000;
|
|
312
|
+
const receivedToBlobsAvailabilityTime = Math.max(availableTimeMs / 1000 - opts.seenTimestampSec, 0);
|
|
308
313
|
const block = blockInputs[0].getBlock();
|
|
309
314
|
const numBlobs = getBlobKzgCommitments(blockInputs[0].forkName, block as deneb.SignedBeaconBlock).length;
|
|
310
315
|
|
|
311
316
|
this.metrics?.gossipBlock.verifiedToBlobsAvailabiltyTime.observe({numBlobs}, verifiedToBlobsAvailabiltyTime);
|
|
317
|
+
this.metrics?.gossipBlock.receivedToBlobsAvailabilityTime.observe({numBlobs}, receivedToBlobsAvailabilityTime);
|
|
312
318
|
this.logger.verbose("Verified blockInput fully with blobs availability", {
|
|
313
319
|
slot: block.message.slot,
|
|
314
320
|
recvTofullyVerifedTime,
|
|
315
321
|
verifiedToBlobsAvailabiltyTime,
|
|
322
|
+
receivedToBlobsAvailabilityTime,
|
|
316
323
|
type: blockInputs[0].type,
|
|
317
324
|
numBlobs,
|
|
318
325
|
});
|
|
@@ -11,7 +11,7 @@ export const BLOB_AVAILABILITY_TIMEOUT = 12_000;
|
|
|
11
11
|
/**
|
|
12
12
|
* Verifies that all block inputs have data available.
|
|
13
13
|
* - Waits a max of BLOB_AVAILABILITY_TIMEOUT for all data to be available
|
|
14
|
-
* - Returns the time at which all data was available
|
|
14
|
+
* - Returns the time at which all data was available, in Unix milliseconds
|
|
15
15
|
* - Returns the data availability status for each block input
|
|
16
16
|
*/
|
|
17
17
|
export async function verifyBlocksDataAvailability(
|
|
@@ -19,7 +19,7 @@ export async function verifyBlocksDataAvailability(
|
|
|
19
19
|
signal: AbortSignal
|
|
20
20
|
): Promise<{
|
|
21
21
|
dataAvailabilityStatuses: DataAvailabilityStatus[];
|
|
22
|
-
|
|
22
|
+
availableTimeMs: number;
|
|
23
23
|
}> {
|
|
24
24
|
const promises: Promise<DAData>[] = [];
|
|
25
25
|
for (const blockInput of blocks) {
|
|
@@ -37,7 +37,7 @@ export async function verifyBlocksDataAvailability(
|
|
|
37
37
|
}
|
|
38
38
|
await Promise.all(promises);
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const availableTimeMs = Math.max(0, Math.max(...blocks.map((blockInput) => blockInput.getTimeComplete()))) * 1000;
|
|
41
41
|
const dataAvailabilityStatuses: DataAvailabilityStatus[] = blocks.map((blockInput) => {
|
|
42
42
|
if (blockInput.type === DAType.NoData) {
|
|
43
43
|
return DataAvailabilityStatus.NotRequired;
|
|
@@ -55,5 +55,5 @@ export async function verifyBlocksDataAvailability(
|
|
|
55
55
|
return DataAvailabilityStatus.Available;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
return {dataAvailabilityStatuses,
|
|
58
|
+
return {dataAvailabilityStatuses, availableTimeMs};
|
|
59
59
|
}
|