@lodestar/beacon-node 1.36.0-dev.d42eb95bf0 → 1.36.0-dev.d8afb6dc39

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.
Files changed (169) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +41 -22
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/lodestar/index.d.ts +5 -0
  5. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  6. package/lib/api/impl/lodestar/index.js +35 -10
  7. package/lib/api/impl/lodestar/index.js.map +1 -1
  8. package/lib/api/impl/node/utils.js +1 -1
  9. package/lib/api/impl/node/utils.js.map +1 -1
  10. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  11. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +6 -1
  12. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  13. package/lib/chain/chain.d.ts +5 -2
  14. package/lib/chain/chain.d.ts.map +1 -1
  15. package/lib/chain/chain.js +32 -16
  16. package/lib/chain/chain.js.map +1 -1
  17. package/lib/chain/errors/dataColumnSidecarError.d.ts +17 -14
  18. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  19. package/lib/chain/errors/dataColumnSidecarError.js +4 -0
  20. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  21. package/lib/chain/forkChoice/index.d.ts +9 -1
  22. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  23. package/lib/chain/forkChoice/index.js +109 -4
  24. package/lib/chain/forkChoice/index.js.map +1 -1
  25. package/lib/chain/interface.d.ts +2 -0
  26. package/lib/chain/interface.d.ts.map +1 -1
  27. package/lib/chain/options.d.ts +0 -2
  28. package/lib/chain/options.d.ts.map +1 -1
  29. package/lib/chain/options.js +2 -2
  30. package/lib/chain/options.js.map +1 -1
  31. package/lib/chain/stateCache/datastore/db.d.ts +12 -0
  32. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  33. package/lib/chain/stateCache/datastore/db.js +70 -0
  34. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  35. package/lib/chain/stateCache/datastore/file.d.ts +1 -0
  36. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  37. package/lib/chain/stateCache/datastore/file.js +7 -0
  38. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  39. package/lib/chain/stateCache/datastore/types.d.ts +1 -0
  40. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  41. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +16 -1
  42. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  43. package/lib/chain/stateCache/persistentCheckpointsCache.js +31 -1
  44. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  45. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  46. package/lib/chain/validation/dataColumnSidecar.js +32 -15
  47. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  48. package/lib/index.d.ts +2 -0
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +2 -0
  51. package/lib/index.js.map +1 -1
  52. package/lib/metrics/metrics/lodestar.js +1 -1
  53. package/lib/metrics/metrics/lodestar.js.map +1 -1
  54. package/lib/network/core/networkCore.d.ts.map +1 -1
  55. package/lib/network/core/networkCore.js +5 -1
  56. package/lib/network/core/networkCore.js.map +1 -1
  57. package/lib/network/core/networkCoreWorker.js +8 -8
  58. package/lib/network/core/networkCoreWorker.js.map +1 -1
  59. package/lib/network/core/networkCoreWorkerHandler.js +1 -1
  60. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  61. package/lib/network/discv5/worker.js +2 -7
  62. package/lib/network/discv5/worker.js.map +1 -1
  63. package/lib/network/events.d.ts +1 -0
  64. package/lib/network/events.d.ts.map +1 -1
  65. package/lib/network/gossip/encoding.js +1 -1
  66. package/lib/network/gossip/encoding.js.map +1 -1
  67. package/lib/network/gossip/snappy_bun.d.ts +3 -0
  68. package/lib/network/gossip/snappy_bun.d.ts.map +1 -0
  69. package/lib/network/gossip/snappy_bun.js +3 -0
  70. package/lib/network/gossip/snappy_bun.js.map +1 -0
  71. package/lib/network/metadata.d.ts +1 -1
  72. package/lib/network/metadata.d.ts.map +1 -1
  73. package/lib/network/metadata.js +1 -0
  74. package/lib/network/metadata.js.map +1 -1
  75. package/lib/network/options.d.ts +0 -1
  76. package/lib/network/options.d.ts.map +1 -1
  77. package/lib/network/options.js.map +1 -1
  78. package/lib/network/peers/discover.js +2 -2
  79. package/lib/network/peers/discover.js.map +1 -1
  80. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  81. package/lib/network/processor/gossipHandlers.js +14 -8
  82. package/lib/network/processor/gossipHandlers.js.map +1 -1
  83. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  84. package/lib/network/reqresp/ReqRespBeaconNode.js +3 -1
  85. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  86. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -1
  87. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  88. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -3
  89. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  90. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -1
  91. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  92. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +9 -1
  93. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  94. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +2 -1
  95. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  96. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +9 -1
  97. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  98. package/lib/network/reqresp/handlers/index.js +6 -6
  99. package/lib/network/reqresp/handlers/index.js.map +1 -1
  100. package/lib/network/reqresp/types.d.ts +1 -0
  101. package/lib/network/reqresp/types.d.ts.map +1 -1
  102. package/lib/node/nodejs.d.ts +2 -1
  103. package/lib/node/nodejs.d.ts.map +1 -1
  104. package/lib/node/nodejs.js +2 -1
  105. package/lib/node/nodejs.js.map +1 -1
  106. package/lib/sync/range/range.d.ts.map +1 -1
  107. package/lib/sync/range/range.js +2 -1
  108. package/lib/sync/range/range.js.map +1 -1
  109. package/lib/sync/utils/downloadByRange.d.ts +58 -13
  110. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  111. package/lib/sync/utils/downloadByRange.js +201 -82
  112. package/lib/sync/utils/downloadByRange.js.map +1 -1
  113. package/lib/sync/utils/remoteSyncType.d.ts +2 -1
  114. package/lib/sync/utils/remoteSyncType.d.ts.map +1 -1
  115. package/lib/sync/utils/remoteSyncType.js +19 -4
  116. package/lib/sync/utils/remoteSyncType.js.map +1 -1
  117. package/lib/util/blobs.d.ts +1 -1
  118. package/lib/util/blobs.d.ts.map +1 -1
  119. package/lib/util/blobs.js +53 -20
  120. package/lib/util/blobs.js.map +1 -1
  121. package/lib/util/profile.d.ts +6 -4
  122. package/lib/util/profile.d.ts.map +1 -1
  123. package/lib/util/profile.js +40 -3
  124. package/lib/util/profile.js.map +1 -1
  125. package/lib/util/sszBytes.d.ts +2 -0
  126. package/lib/util/sszBytes.d.ts.map +1 -1
  127. package/lib/util/sszBytes.js +25 -0
  128. package/lib/util/sszBytes.js.map +1 -1
  129. package/package.json +31 -24
  130. package/src/api/impl/beacon/blocks/index.ts +47 -25
  131. package/src/api/impl/lodestar/index.ts +42 -10
  132. package/src/api/impl/node/utils.ts +1 -1
  133. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +5 -1
  134. package/src/chain/chain.ts +48 -23
  135. package/src/chain/errors/dataColumnSidecarError.ts +20 -14
  136. package/src/chain/forkChoice/index.ts +178 -2
  137. package/src/chain/interface.ts +2 -0
  138. package/src/chain/options.ts +2 -3
  139. package/src/chain/stateCache/datastore/db.ts +89 -1
  140. package/src/chain/stateCache/datastore/file.ts +8 -0
  141. package/src/chain/stateCache/datastore/types.ts +1 -0
  142. package/src/chain/stateCache/persistentCheckpointsCache.ts +45 -2
  143. package/src/chain/validation/dataColumnSidecar.ts +34 -16
  144. package/src/index.ts +2 -0
  145. package/src/metrics/metrics/lodestar.ts +1 -1
  146. package/src/network/core/networkCore.ts +5 -1
  147. package/src/network/core/networkCoreWorker.ts +9 -9
  148. package/src/network/core/networkCoreWorkerHandler.ts +1 -1
  149. package/src/network/discv5/worker.ts +2 -7
  150. package/src/network/events.ts +1 -1
  151. package/src/network/gossip/encoding.ts +1 -1
  152. package/src/network/gossip/snappy_bun.ts +2 -0
  153. package/src/network/metadata.ts +3 -1
  154. package/src/network/options.ts +0 -1
  155. package/src/network/peers/discover.ts +2 -2
  156. package/src/network/processor/gossipHandlers.ts +16 -7
  157. package/src/network/reqresp/ReqRespBeaconNode.ts +3 -1
  158. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +18 -3
  159. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +13 -1
  160. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +13 -1
  161. package/src/network/reqresp/handlers/index.ts +6 -6
  162. package/src/network/reqresp/types.ts +1 -0
  163. package/src/node/nodejs.ts +3 -0
  164. package/src/sync/range/range.ts +2 -1
  165. package/src/sync/utils/downloadByRange.ts +259 -103
  166. package/src/sync/utils/remoteSyncType.ts +23 -4
  167. package/src/util/blobs.ts +64 -20
  168. package/src/util/profile.ts +45 -3
  169. package/src/util/sszBytes.ts +30 -0
@@ -6,7 +6,6 @@ import { SeenBlockInput } from "../../chain/seenCache/seenGossipBlockInput.js";
6
6
  import { INetwork } from "../../network/index.js";
7
7
  import { PeerIdStr } from "../../util/peerId.js";
8
8
  import { WarnResult } from "../../util/wrapError.js";
9
- import { DownloadByRootErrorCode } from "./downloadByRoot.js";
10
9
  export type DownloadByRangeRequests = {
11
10
  blocksRequest?: phase0.BeaconBlocksByRangeRequest;
12
11
  blobsRequest?: deneb.BlobSidecarsByRangeRequest;
@@ -76,7 +75,7 @@ export declare function validateResponses({ config, batchBlocks, blocksRequest,
76
75
  * - must allow for skip slots
77
76
  * - check is a chain of blocks where via parentRoot matches hashTreeRoot of block before
78
77
  */
79
- export declare function validateBlockByRangeResponse(config: ChainForkConfig, blocksRequest: phase0.BeaconBlocksByRangeRequest, blocks: SignedBeaconBlock[]): ValidatedBlock[];
78
+ export declare function validateBlockByRangeResponse(config: ChainForkConfig, blocksRequest: phase0.BeaconBlocksByRangeRequest, blocks: SignedBeaconBlock[]): WarnResult<ValidatedBlock[], DownloadByRangeError>;
80
79
  /**
81
80
  * Should not be called directly. Only exported for unit testing purposes.
82
81
  * This is used only in Deneb and Electra
@@ -84,8 +83,47 @@ export declare function validateBlockByRangeResponse(config: ChainForkConfig, bl
84
83
  export declare function validateBlobsByRangeResponse(dataRequestBlocks: ValidatedBlock[], blobSidecars: deneb.BlobSidecars): Promise<ValidatedBlobSidecars[]>;
85
84
  /**
86
85
  * Should not be called directly. Only exported for unit testing purposes
86
+ *
87
+ * Spec states:
88
+ * 1) must be within range [start_slot, start_slot + count]
89
+ * 2) should respond with all columns in the range or and 3:ResourceUnavailable (and potentially get down-scored)
90
+ * 3) must response with at least the sidecars of the first blob-carrying block that exists in the range
91
+ * 4) must include all sidecars from each block from which there are blobs
92
+ * 5) where they exists, sidecars must be sent in (slot, index) order
93
+ * 6) clients may limit the number of sidecars in a response
94
+ * 7) clients may stop responding mid-response if their view of fork-choice changes
95
+ *
96
+ * We will interpret the spec as follows
97
+ * - Errors when validating: 1, 3, 5
98
+ * - Warnings when validating: 2, 4, 6, 7
99
+ *
100
+ * For "warning" cases, where we get a partial response but sidecars are validated and correct with respect to the
101
+ * blocks, then they will be kept. This loosening of the spec is to help ensure sync goes smoothly and we can find
102
+ * the data needed in difficult network situations.
103
+ *
104
+ * Assume for the following two examples we request indices 5, 10, 15 for a range of slots 32-63
105
+ *
106
+ * For slots where we receive no sidecars, example slot 45, but blobs exist we will stop validating subsequent
107
+ * slots, 45-63. The next round of requests will get structured to pull the from the slot that had columns
108
+ * missing to the end of the range for all columns indices that were requested for the current partially failed
109
+ * request (slots 45-63 and indices 5, 10, 15).
110
+ *
111
+ * For slots where only some of the requested sidecars are received we will proceed with validation. For simplicity sake
112
+ * we will assume that if we only get some indices back for a (or several) slot(s) that the indices we get will be
113
+ * consistent. IE if a peer returns only index 5, they will most likely return that same index for subsequent slot
114
+ * (index 5 for slots 34, 35, 36, etc). They will not likely return 5 on slot 34, 10 on slot 35, 15 on slot 36, etc.
115
+ * This assumption makes the code simpler. For both cases the request for the next round will be structured correctly
116
+ * to pull any missing column indices for whatever range remains. The simplification just leads to re-verification
117
+ * of the columns but the number of columns downloaded will be the same regardless of if they are validated twice.
118
+ *
119
+ * validateColumnsByRangeResponse makes some assumptions about the data being passed in
120
+ * blocks are:
121
+ * - slotwise in order
122
+ * - form a chain
123
+ * - non-sparse response (any missing block is a skipped slot not a bad response)
124
+ * - last block is last slot received
87
125
  */
88
- export declare function validateColumnsByRangeResponse(request: fulu.DataColumnSidecarsByRangeRequest, dataRequestBlocks: ValidatedBlock[], columnSidecars: fulu.DataColumnSidecars): Promise<WarnResult<ValidatedColumnSidecars[], DownloadByRangeError>>;
126
+ export declare function validateColumnsByRangeResponse(config: ChainForkConfig, request: fulu.DataColumnSidecarsByRangeRequest, blocks: ValidatedBlock[], columnSidecars: fulu.DataColumnSidecars): Promise<WarnResult<ValidatedColumnSidecars[], DownloadByRangeError>>;
89
127
  /**
90
128
  * Given a data request, return only the blocks and roots that correspond to the data request (sorted). Assumes that
91
129
  * cached have slots that are all before the current batch of downloaded blocks
@@ -95,7 +133,7 @@ export declare function getBlocksForDataValidation(dataRequest: {
95
133
  count: number;
96
134
  }, cached: IBlockInput[] | undefined, current: ValidatedBlock[] | undefined): ValidatedBlock[];
97
135
  export declare enum DownloadByRangeErrorCode {
98
- MISSING_BLOCKS = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOCKS",
136
+ MISSING_BLOCKS_RESPONSE = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOCK_RESPONSE",
99
137
  MISSING_BLOBS_RESPONSE = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOBS_RESPONSE",
100
138
  MISSING_COLUMNS_RESPONSE = "DOWNLOAD_BY_RANGE_ERROR_MISSING_COLUMNS_RESPONSE",
101
139
  /** Error at the reqresp layer */
@@ -110,26 +148,29 @@ export declare enum DownloadByRangeErrorCode {
110
148
  MISSING_COLUMNS = "DOWNLOAD_BY_RANGE_ERROR_MISSING_COLUMNS",
111
149
  OVER_COLUMNS = "DOWNLOAD_BY_RANGE_ERROR_OVER_COLUMNS",
112
150
  EXTRA_COLUMNS = "DOWNLOAD_BY_RANGE_ERROR_EXTRA_COLUMNS",
151
+ NO_COLUMNS_FOR_BLOCK = "DOWNLOAD_BY_RANGE_ERROR_NO_COLUMNS_FOR_BLOCK",
152
+ DUPLICATE_COLUMN = "DOWNLOAD_BY_RANGE_ERROR_DUPLICATE_COLUMN",
153
+ OUT_OF_ORDER_COLUMNS = "DOWNLOAD_BY_RANGE_OUT_OF_ORDER_COLUMNS",
113
154
  /** Cached block input type mismatches new data */
155
+ MISMATCH_BLOCK_FORK = "DOWNLOAD_BY_RANGE_ERROR_MISMATCH_BLOCK_FORK",
114
156
  MISMATCH_BLOCK_INPUT_TYPE = "DOWNLOAD_BY_RANGE_ERROR_MISMATCH_BLOCK_INPUT_TYPE"
115
157
  }
116
158
  export type DownloadByRangeErrorType = {
117
- code: DownloadByRootErrorCode.MISSING_BLOCK_RESPONSE;
118
- expectedCount: number;
119
- } | {
120
- code: DownloadByRangeErrorCode.MISSING_BLOCKS | DownloadByRangeErrorCode.MISSING_BLOBS_RESPONSE | DownloadByRangeErrorCode.MISSING_COLUMNS_RESPONSE;
159
+ code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE | DownloadByRangeErrorCode.MISSING_BLOBS_RESPONSE | DownloadByRangeErrorCode.MISSING_COLUMNS_RESPONSE;
121
160
  blockStartSlot?: number;
122
161
  blockCount?: number;
123
162
  blobStartSlot?: number;
124
163
  blobCount?: number;
125
164
  columnStartSlot?: number;
126
165
  columnCount?: number;
127
- } | {
128
- code: DownloadByRootErrorCode.MISSING_BLOCK_RESPONSE;
129
- expectedCount: number;
130
166
  } | {
131
167
  code: DownloadByRangeErrorCode.OUT_OF_RANGE_BLOCKS;
132
168
  slot: number;
169
+ } | {
170
+ code: DownloadByRangeErrorCode.MISMATCH_BLOCK_FORK;
171
+ slot: number;
172
+ dataFork: string;
173
+ blockFork: string;
133
174
  } | {
134
175
  code: DownloadByRangeErrorCode.OUT_OF_ORDER_BLOCKS;
135
176
  } | {
@@ -155,7 +196,7 @@ export type DownloadByRangeErrorType = {
155
196
  expected: number;
156
197
  actual: number;
157
198
  } | {
158
- code: DownloadByRangeErrorCode.OUT_OF_ORDER_BLOBS;
199
+ code: DownloadByRangeErrorCode.OUT_OF_ORDER_BLOBS | DownloadByRangeErrorCode.OUT_OF_ORDER_COLUMNS;
159
200
  slot: number;
160
201
  } | {
161
202
  code: DownloadByRangeErrorCode.EXTRA_BLOBS;
@@ -171,7 +212,11 @@ export type DownloadByRangeErrorType = {
171
212
  blockRoot: string;
172
213
  missingIndices: string;
173
214
  } | {
174
- code: DownloadByRangeErrorCode.EXTRA_COLUMNS;
215
+ code: DownloadByRangeErrorCode.DUPLICATE_COLUMN;
216
+ slot: Slot;
217
+ index: number;
218
+ } | {
219
+ code: DownloadByRangeErrorCode.EXTRA_COLUMNS | DownloadByRangeErrorCode.NO_COLUMNS_FOR_BLOCK;
175
220
  slot: Slot;
176
221
  blockRoot: string;
177
222
  invalidIndices: string;
@@ -1 +1 @@
1
- {"version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,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,wBAAwB,CAAC,aAAa,GAAG,wBAAwB,CAAC,oBAAoB,CAAC;IAC7F,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,GACD;IACE,IAAI,EAAE,wBAAwB,CAAC,yBAAyB,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,wBAAwB,CAAC;CAAG"}
@@ -1,4 +1,5 @@
1
- import { LodestarError, fromHex, prettyBytes, prettyPrintIndices, toRootHex } from "@lodestar/utils";
1
+ import { isForkPostFulu, isForkPostGloas, } from "@lodestar/params";
2
+ import { LodestarError, fromHex, prettyPrintIndices, toRootHex } from "@lodestar/utils";
2
3
  import { BlockInputSource, DAType, isBlockInputBlobs, isBlockInputColumns, } from "../../chain/blocks/blockInput/index.js";
3
4
  import { validateBlockBlobSidecars } from "../../chain/validation/blobSidecar.js";
4
5
  import { validateBlockDataColumnSidecars } from "../../chain/validation/dataColumnSidecar.js";
@@ -37,7 +38,11 @@ export function cacheByRangeResponses({ cache, peerIdStr, responses, batchBlocks
37
38
  }
38
39
  }
39
40
  for (const { blockRoot, blobSidecars } of responses.validatedBlobSidecars ?? []) {
40
- const existing = updatedBatchBlocks.get(blobSidecars[0].signedBlockHeader.message.slot);
41
+ const dataSlot = blobSidecars.at(0)?.signedBlockHeader.message.slot;
42
+ if (dataSlot === undefined) {
43
+ throw new Error(`Coding Error: empty blobSidecars returned for blockRoot=${toRootHex(blockRoot)} from validation functions`);
44
+ }
45
+ const existing = updatedBatchBlocks.get(dataSlot);
41
46
  const blockRootHex = toRootHex(blockRoot);
42
47
  if (!existing) {
43
48
  throw new Error("Coding error: blockInput must exist when adding blobs");
@@ -46,7 +51,7 @@ export function cacheByRangeResponses({ cache, peerIdStr, responses, batchBlocks
46
51
  throw new DownloadByRangeError({
47
52
  code: DownloadByRangeErrorCode.MISMATCH_BLOCK_INPUT_TYPE,
48
53
  slot: existing.slot,
49
- blockRoot: prettyBytes(existing.blockRootHex),
54
+ blockRoot: existing.blockRootHex,
50
55
  expected: DAType.Blobs,
51
56
  actual: existing.type,
52
57
  });
@@ -63,16 +68,20 @@ export function cacheByRangeResponses({ cache, peerIdStr, responses, batchBlocks
63
68
  }
64
69
  }
65
70
  for (const { blockRoot, columnSidecars } of responses.validatedColumnSidecars ?? []) {
66
- const existing = updatedBatchBlocks.get(columnSidecars[0].signedBlockHeader.message.slot);
71
+ const dataSlot = columnSidecars.at(0)?.signedBlockHeader.message.slot;
72
+ if (dataSlot === undefined) {
73
+ throw new Error(`Coding Error: empty columnSidecars returned for blockRoot=${toRootHex(blockRoot)} from validation functions`);
74
+ }
75
+ const existing = updatedBatchBlocks.get(dataSlot);
67
76
  const blockRootHex = toRootHex(blockRoot);
68
77
  if (!existing) {
69
- throw new Error("Coding error: blockInput must exist when adding blobs");
78
+ throw new Error("Coding error: blockInput must exist when adding columns");
70
79
  }
71
80
  if (!isBlockInputColumns(existing)) {
72
81
  throw new DownloadByRangeError({
73
82
  code: DownloadByRangeErrorCode.MISMATCH_BLOCK_INPUT_TYPE,
74
83
  slot: existing.slot,
75
- blockRoot: prettyBytes(existing.blockRootHex),
84
+ blockRoot: existing.blockRootHex,
76
85
  expected: DAType.Columns,
77
86
  actual: existing.type,
78
87
  });
@@ -157,23 +166,27 @@ export async function validateResponses({ config, batchBlocks, blocksRequest, bl
157
166
  // If no blocksRequest is provided, batchBlocks must have been provided from cache
158
167
  if ((blobsRequest || columnsRequest) && !(blocks || batchBlocks)) {
159
168
  throw new DownloadByRangeError({
160
- code: DownloadByRangeErrorCode.MISSING_BLOCKS,
169
+ code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE,
161
170
  ...requestsLogMeta({ blobsRequest, columnsRequest }),
162
171
  }, "No blocks to validate data requests against");
163
172
  }
164
173
  const validatedResponses = {};
165
174
  let warnings = null;
166
175
  if (blocksRequest) {
167
- validatedResponses.validatedBlocks = validateBlockByRangeResponse(config, blocksRequest, blocks ?? []);
176
+ const result = validateBlockByRangeResponse(config, blocksRequest, blocks ?? []);
177
+ if (result.warnings?.length) {
178
+ warnings = result.warnings;
179
+ }
180
+ validatedResponses.validatedBlocks = result.result;
168
181
  }
169
182
  const dataRequest = blobsRequest ?? columnsRequest;
170
183
  if (!dataRequest) {
171
- return { result: validatedResponses, warnings: null };
184
+ return { result: validatedResponses, warnings };
172
185
  }
173
- const dataRequestBlocks = getBlocksForDataValidation(dataRequest, batchBlocks, blocksRequest ? validatedResponses.validatedBlocks : undefined);
174
- if (!dataRequestBlocks.length) {
186
+ const blocksForDataValidation = getBlocksForDataValidation(dataRequest, batchBlocks, validatedResponses.validatedBlocks?.length ? validatedResponses.validatedBlocks : undefined);
187
+ if (!blocksForDataValidation.length) {
175
188
  throw new DownloadByRangeError({
176
- code: DownloadByRangeErrorCode.MISSING_BLOCKS,
189
+ code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE,
177
190
  ...requestsLogMeta({ blobsRequest, columnsRequest }),
178
191
  }, "No blocks in data request slot range to validate data response against");
179
192
  }
@@ -184,7 +197,7 @@ export async function validateResponses({ config, batchBlocks, blocksRequest, bl
184
197
  ...requestsLogMeta({ blobsRequest, columnsRequest }),
185
198
  }, "No blobSidecars to validate against blobsRequest");
186
199
  }
187
- validatedResponses.validatedBlobSidecars = await validateBlobsByRangeResponse(dataRequestBlocks, blobSidecars);
200
+ validatedResponses.validatedBlobSidecars = await validateBlobsByRangeResponse(blocksForDataValidation, blobSidecars);
188
201
  }
189
202
  if (columnsRequest) {
190
203
  if (!columnSidecars) {
@@ -193,7 +206,7 @@ export async function validateResponses({ config, batchBlocks, blocksRequest, bl
193
206
  ...requestsLogMeta({ blobsRequest, columnsRequest }),
194
207
  }, "No columnSidecars to check columnRequest against");
195
208
  }
196
- const validatedColumnSidecarsResult = await validateColumnsByRangeResponse(columnsRequest, dataRequestBlocks, columnSidecars);
209
+ const validatedColumnSidecarsResult = await validateColumnsByRangeResponse(config, columnsRequest, blocksForDataValidation, columnSidecars);
197
210
  validatedResponses.validatedColumnSidecars = validatedColumnSidecarsResult.result;
198
211
  warnings = validatedColumnSidecarsResult.warnings;
199
212
  }
@@ -210,17 +223,27 @@ export async function validateResponses({ config, batchBlocks, blocksRequest, bl
210
223
  */
211
224
  export function validateBlockByRangeResponse(config, blocksRequest, blocks) {
212
225
  const { startSlot, count } = blocksRequest;
213
- // TODO(fulu): This was added by @twoeths in #8150 but it breaks for epochs with 0 blocks during chain
214
- // liveness issues. See comment https://github.com/ChainSafe/lodestar/issues/8147#issuecomment-3246434697
215
- // if (!blocks.length) {
216
- // throw new DownloadByRangeError(
217
- // {
218
- // code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE,
219
- // expectedCount: blocksRequest.count,
220
- // },
221
- // "Zero blocks in response"
222
- // );
223
- // }
226
+ // An error was thrown here by @twoeths in #8150 but it breaks for epochs with 0 blocks during chain
227
+ // liveness issues. See comment https://github.com/ChainSafe/lodestar/issues/8147#issuecomment-3246434697
228
+ // There are instances where clients return no blocks though. Need to monitor this via the warns to see
229
+ // if what the correct behavior should be
230
+ if (!blocks.length) {
231
+ throw new DownloadByRangeError({
232
+ code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE,
233
+ ...requestsLogMeta({ blocksRequest }),
234
+ });
235
+ // TODO: this was causing deadlock again. need to come back and fix this so that its possible to process through
236
+ // an empty epoch for periods with poor liveness
237
+ // return {
238
+ // result: [],
239
+ // warnings: [
240
+ // new DownloadByRangeError({
241
+ // code: DownloadByRangeErrorCode.MISSING_BLOCKS_RESPONSE,
242
+ // ...requestsLogMeta({blocksRequest}),
243
+ // }),
244
+ // ],
245
+ // };
246
+ }
224
247
  if (blocks.length > count) {
225
248
  throw new DownloadByRangeError({
226
249
  code: DownloadByRangeErrorCode.EXTRA_BLOCKS,
@@ -260,13 +283,16 @@ export function validateBlockByRangeResponse(config, blocksRequest, blocks) {
260
283
  throw new DownloadByRangeError({
261
284
  code: DownloadByRangeErrorCode.PARENT_ROOT_MISMATCH,
262
285
  slot: blocks[i].message.slot,
263
- expected: prettyBytes(blockRoot),
264
- actual: prettyBytes(parentRoot),
286
+ expected: toRootHex(blockRoot),
287
+ actual: toRootHex(parentRoot),
265
288
  }, `Block parent root does not match the previous block's root in BeaconBlocksByRange response`);
266
289
  }
267
290
  }
268
291
  }
269
- return response;
292
+ return {
293
+ result: response,
294
+ warnings: null,
295
+ };
270
296
  }
271
297
  /**
272
298
  * Should not be called directly. Only exported for unit testing purposes.
@@ -313,82 +339,171 @@ export async function validateBlobsByRangeResponse(dataRequestBlocks, blobSideca
313
339
  }
314
340
  /**
315
341
  * Should not be called directly. Only exported for unit testing purposes
342
+ *
343
+ * Spec states:
344
+ * 1) must be within range [start_slot, start_slot + count]
345
+ * 2) should respond with all columns in the range or and 3:ResourceUnavailable (and potentially get down-scored)
346
+ * 3) must response with at least the sidecars of the first blob-carrying block that exists in the range
347
+ * 4) must include all sidecars from each block from which there are blobs
348
+ * 5) where they exists, sidecars must be sent in (slot, index) order
349
+ * 6) clients may limit the number of sidecars in a response
350
+ * 7) clients may stop responding mid-response if their view of fork-choice changes
351
+ *
352
+ * We will interpret the spec as follows
353
+ * - Errors when validating: 1, 3, 5
354
+ * - Warnings when validating: 2, 4, 6, 7
355
+ *
356
+ * For "warning" cases, where we get a partial response but sidecars are validated and correct with respect to the
357
+ * blocks, then they will be kept. This loosening of the spec is to help ensure sync goes smoothly and we can find
358
+ * the data needed in difficult network situations.
359
+ *
360
+ * Assume for the following two examples we request indices 5, 10, 15 for a range of slots 32-63
361
+ *
362
+ * For slots where we receive no sidecars, example slot 45, but blobs exist we will stop validating subsequent
363
+ * slots, 45-63. The next round of requests will get structured to pull the from the slot that had columns
364
+ * missing to the end of the range for all columns indices that were requested for the current partially failed
365
+ * request (slots 45-63 and indices 5, 10, 15).
366
+ *
367
+ * For slots where only some of the requested sidecars are received we will proceed with validation. For simplicity sake
368
+ * we will assume that if we only get some indices back for a (or several) slot(s) that the indices we get will be
369
+ * consistent. IE if a peer returns only index 5, they will most likely return that same index for subsequent slot
370
+ * (index 5 for slots 34, 35, 36, etc). They will not likely return 5 on slot 34, 10 on slot 35, 15 on slot 36, etc.
371
+ * This assumption makes the code simpler. For both cases the request for the next round will be structured correctly
372
+ * to pull any missing column indices for whatever range remains. The simplification just leads to re-verification
373
+ * of the columns but the number of columns downloaded will be the same regardless of if they are validated twice.
374
+ *
375
+ * validateColumnsByRangeResponse makes some assumptions about the data being passed in
376
+ * blocks are:
377
+ * - slotwise in order
378
+ * - form a chain
379
+ * - non-sparse response (any missing block is a skipped slot not a bad response)
380
+ * - last block is last slot received
316
381
  */
317
- export async function validateColumnsByRangeResponse(request, dataRequestBlocks, columnSidecars) {
318
- // Expected column count considering currently-validated batch blocks
319
- // TODO GLOAS: Post-gloas's blobKzgCommitments is not in beacon block body. Need to source it from somewhere else.
320
- const expectedColumnCount = dataRequestBlocks.reduce((acc, { block }) => {
321
- return block.message.body.blobKzgCommitments.length > 0
322
- ? request.columns.length + acc
323
- : acc;
324
- }, 0);
325
- const nextSlot = dataRequestBlocks.length
326
- ? dataRequestBlocks.at(-1).block.message.slot + 1
327
- : request.startSlot;
328
- const possiblyMissingBlocks = nextSlot - request.startSlot + request.count;
329
- // Allow for extra columns if some blocks are missing from the end of a batch
330
- // Eg: If we requested 10 blocks but only 8 were returned, allow for up to 2 * columns.length extra columns
331
- const maxColumnCount = expectedColumnCount + possiblyMissingBlocks * request.columns.length;
332
- if (columnSidecars.length > maxColumnCount) {
333
- // this never happens on devnet, so throw error for now
334
- throw new DownloadByRangeError({
335
- code: DownloadByRangeErrorCode.OVER_COLUMNS,
336
- max: maxColumnCount,
337
- actual: columnSidecars.length,
338
- }, "Extra data columns received in DataColumnSidecarsByRange response");
339
- }
382
+ export async function validateColumnsByRangeResponse(config, request, blocks, columnSidecars) {
340
383
  const warnings = [];
341
- // no need to check for columnSidecars.length vs expectedColumnCount here, will be checked per-block below
342
- const requestedColumns = new Set(request.columns);
343
- const validateSidecarsPromises = [];
344
- for (let blockIndex = 0, columnSidecarIndex = 0; blockIndex < dataRequestBlocks.length; blockIndex++) {
345
- const { block, blockRoot } = dataRequestBlocks[blockIndex];
346
- const slot = block.message.slot;
347
- const blockRootHex = toRootHex(blockRoot);
348
- // TODO GLOAS: Post-gloas's blobKzgCommitments is not in beacon block body. Need to source it from somewhere else.
349
- const blockKzgCommitments = block.message.body
350
- .blobKzgCommitments;
351
- const expectedColumns = blockKzgCommitments.length ? request.columns.length : 0;
352
- if (expectedColumns === 0) {
384
+ const seenColumns = new Map();
385
+ let currentSlot = -1;
386
+ let currentIndex = -1;
387
+ // Check for duplicates and order
388
+ for (const columnSidecar of columnSidecars) {
389
+ const slot = columnSidecar.signedBlockHeader.message.slot;
390
+ let seenSlotColumns = seenColumns.get(slot);
391
+ if (!seenSlotColumns) {
392
+ seenSlotColumns = new Map();
393
+ seenColumns.set(slot, seenSlotColumns);
394
+ }
395
+ if (seenSlotColumns.has(columnSidecar.index)) {
396
+ warnings.push(new DownloadByRangeError({
397
+ code: DownloadByRangeErrorCode.DUPLICATE_COLUMN,
398
+ slot,
399
+ index: columnSidecar.index,
400
+ }));
353
401
  continue;
354
402
  }
355
- const blockColumnSidecars = [];
356
- while (columnSidecarIndex < columnSidecars.length) {
357
- const columnSidecar = columnSidecars[columnSidecarIndex];
358
- if (columnSidecar.signedBlockHeader.message.slot !== block.message.slot) {
359
- // We've reached columns for the next block
360
- break;
403
+ if (currentSlot > slot) {
404
+ warnings.push(new DownloadByRangeError({
405
+ code: DownloadByRangeErrorCode.OUT_OF_ORDER_COLUMNS,
406
+ slot,
407
+ }, "ColumnSidecars received out of slot order"));
408
+ }
409
+ if (currentSlot === slot && currentIndex > columnSidecar.index) {
410
+ warnings.push(new DownloadByRangeError({
411
+ code: DownloadByRangeErrorCode.OUT_OF_ORDER_COLUMNS,
412
+ slot,
413
+ }, "Column indices out of order within a slot"));
414
+ }
415
+ seenSlotColumns.set(columnSidecar.index, columnSidecar);
416
+ if (currentSlot !== slot) {
417
+ // a new slot has started, reset index
418
+ currentIndex = -1;
419
+ }
420
+ else {
421
+ currentIndex = columnSidecar.index;
422
+ }
423
+ currentSlot = slot;
424
+ }
425
+ const validationPromises = [];
426
+ for (const { blockRoot, block } of blocks) {
427
+ const slot = block.message.slot;
428
+ const rootHex = toRootHex(blockRoot);
429
+ const forkName = config.getForkName(slot);
430
+ const columnSidecarsMap = seenColumns.get(slot) ?? new Map();
431
+ const columnSidecars = Array.from(columnSidecarsMap.values()).sort((a, b) => a.index - b.index);
432
+ let blobCount;
433
+ if (!isForkPostFulu(forkName)) {
434
+ const dataSlot = columnSidecars.at(0)?.signedBlockHeader.message.slot;
435
+ throw new DownloadByRangeError({
436
+ code: DownloadByRangeErrorCode.MISMATCH_BLOCK_FORK,
437
+ slot,
438
+ blockFork: forkName,
439
+ dataFork: dataSlot ? config.getForkName(dataSlot) : "unknown",
440
+ });
441
+ }
442
+ if (isForkPostGloas(forkName)) {
443
+ // TODO GLOAS: Post-gloas's blobKzgCommitments is not in beacon block body. Need to source it from somewhere else.
444
+ // if block without columns is passed default to zero and throw below
445
+ blobCount = 0;
446
+ }
447
+ else {
448
+ blobCount = block.message.body.blobKzgCommitments.length;
449
+ }
450
+ if (columnSidecars.length === 0) {
451
+ if (!blobCount) {
452
+ // no columns in the slot
453
+ continue;
361
454
  }
362
- blockColumnSidecars.push(columnSidecar);
363
- columnSidecarIndex++;
455
+ /**
456
+ * If no columns are found for a block and there are commitments on the block then stop checking and just
457
+ * return early. Even if there were columns returned for subsequent slots that doesn't matter because
458
+ * we will be re-requesting them again anyway. Leftovers just get ignored
459
+ */
460
+ warnings.push(new DownloadByRangeError({
461
+ code: DownloadByRangeErrorCode.MISSING_COLUMNS,
462
+ slot,
463
+ blockRoot: rootHex,
464
+ missingIndices: prettyPrintIndices(request.columns),
465
+ }));
466
+ break;
364
467
  }
365
- const returnedColumns = new Set(blockColumnSidecars.map((c) => c.index));
366
- const missingIndices = request.columns.filter((i) => !returnedColumns.has(i));
468
+ const returnedColumns = Array.from(columnSidecarsMap.keys()).sort();
469
+ if (!blobCount) {
470
+ // columns for a block that does not have blobs
471
+ // TODO(fulu): should this be a hard error with no data retained from peer or just a warning
472
+ throw new DownloadByRangeError({
473
+ code: DownloadByRangeErrorCode.NO_COLUMNS_FOR_BLOCK,
474
+ slot,
475
+ blockRoot: rootHex,
476
+ invalidIndices: prettyPrintIndices(returnedColumns),
477
+ }, "Block has no blob commitments but data column sidecars were provided");
478
+ }
479
+ const missingIndices = request.columns.filter((i) => !columnSidecarsMap.has(i));
367
480
  if (missingIndices.length > 0) {
368
481
  warnings.push(new DownloadByRangeError({
369
482
  code: DownloadByRangeErrorCode.MISSING_COLUMNS,
370
483
  slot,
371
- blockRoot: blockRootHex,
484
+ blockRoot: rootHex,
372
485
  missingIndices: prettyPrintIndices(missingIndices),
373
486
  }, "Missing data columns in DataColumnSidecarsByRange response"));
374
487
  }
375
- const extraIndices = [...returnedColumns].filter((i) => !requestedColumns.has(i));
488
+ const extraIndices = returnedColumns.filter((i) => !request.columns.includes(i));
376
489
  if (extraIndices.length > 0) {
377
490
  warnings.push(new DownloadByRangeError({
378
491
  code: DownloadByRangeErrorCode.EXTRA_COLUMNS,
379
492
  slot,
380
- blockRoot: blockRootHex,
493
+ blockRoot: rootHex,
381
494
  invalidIndices: prettyPrintIndices(extraIndices),
382
495
  }, "Data column in not in requested columns in DataColumnSidecarsByRange response"));
383
496
  }
384
- validateSidecarsPromises.push(validateBlockDataColumnSidecars(slot, blockRoot, blockKzgCommitments.length, blockColumnSidecars).then(() => ({
497
+ validationPromises.push(validateBlockDataColumnSidecars(slot, blockRoot, blobCount, columnSidecars).then(() => ({
385
498
  blockRoot,
386
- columnSidecars: blockColumnSidecars,
499
+ columnSidecars,
387
500
  })));
388
501
  }
389
- // Await all sidecar validations in parallel
390
- const result = await Promise.all(validateSidecarsPromises);
391
- return { result, warnings: warnings.length ? warnings : null };
502
+ const validatedColumns = await Promise.all(validationPromises);
503
+ return {
504
+ result: validatedColumns,
505
+ warnings: warnings.length ? warnings : null,
506
+ };
392
507
  }
393
508
  /**
394
509
  * Given a data request, return only the blocks and roots that correspond to the data request (sorted). Assumes that
@@ -438,7 +553,7 @@ function requestsLogMeta({ blocksRequest, blobsRequest, columnsRequest }) {
438
553
  }
439
554
  export var DownloadByRangeErrorCode;
440
555
  (function (DownloadByRangeErrorCode) {
441
- DownloadByRangeErrorCode["MISSING_BLOCKS"] = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOCKS";
556
+ DownloadByRangeErrorCode["MISSING_BLOCKS_RESPONSE"] = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOCK_RESPONSE";
442
557
  DownloadByRangeErrorCode["MISSING_BLOBS_RESPONSE"] = "DOWNLOAD_BY_RANGE_ERROR_MISSING_BLOBS_RESPONSE";
443
558
  DownloadByRangeErrorCode["MISSING_COLUMNS_RESPONSE"] = "DOWNLOAD_BY_RANGE_ERROR_MISSING_COLUMNS_RESPONSE";
444
559
  /** Error at the reqresp layer */
@@ -454,7 +569,11 @@ export var DownloadByRangeErrorCode;
454
569
  DownloadByRangeErrorCode["MISSING_COLUMNS"] = "DOWNLOAD_BY_RANGE_ERROR_MISSING_COLUMNS";
455
570
  DownloadByRangeErrorCode["OVER_COLUMNS"] = "DOWNLOAD_BY_RANGE_ERROR_OVER_COLUMNS";
456
571
  DownloadByRangeErrorCode["EXTRA_COLUMNS"] = "DOWNLOAD_BY_RANGE_ERROR_EXTRA_COLUMNS";
572
+ DownloadByRangeErrorCode["NO_COLUMNS_FOR_BLOCK"] = "DOWNLOAD_BY_RANGE_ERROR_NO_COLUMNS_FOR_BLOCK";
573
+ DownloadByRangeErrorCode["DUPLICATE_COLUMN"] = "DOWNLOAD_BY_RANGE_ERROR_DUPLICATE_COLUMN";
574
+ DownloadByRangeErrorCode["OUT_OF_ORDER_COLUMNS"] = "DOWNLOAD_BY_RANGE_OUT_OF_ORDER_COLUMNS";
457
575
  /** Cached block input type mismatches new data */
576
+ DownloadByRangeErrorCode["MISMATCH_BLOCK_FORK"] = "DOWNLOAD_BY_RANGE_ERROR_MISMATCH_BLOCK_FORK";
458
577
  DownloadByRangeErrorCode["MISMATCH_BLOCK_INPUT_TYPE"] = "DOWNLOAD_BY_RANGE_ERROR_MISMATCH_BLOCK_INPUT_TYPE";
459
578
  })(DownloadByRangeErrorCode || (DownloadByRangeErrorCode = {}));
460
579
  export class DownloadByRangeError extends LodestarError {