@lodestar/beacon-node 1.48.0-dev.e9c9b8835d → 1.48.0-dev.fd70e5fc15

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 (200) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +4 -4
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/chain/archiveStore/archiveStore.d.ts +0 -1
  5. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  6. package/lib/chain/archiveStore/archiveStore.js +0 -1
  7. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  8. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  9. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
  10. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  11. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  12. package/lib/chain/archiveStore/historicalState/metrics.js +1 -12
  13. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  14. package/lib/chain/archiveStore/historicalState/types.d.ts +0 -2
  15. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  16. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  17. package/lib/chain/archiveStore/historicalState/worker.js +1 -4
  18. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js +34 -31
  21. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  22. package/lib/chain/blocks/index.d.ts.map +1 -1
  23. package/lib/chain/blocks/index.js +2 -3
  24. package/lib/chain/blocks/index.js.map +1 -1
  25. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  26. package/lib/chain/blocks/writeBlockInputToDb.js +16 -9
  27. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  28. package/lib/chain/chain.d.ts +3 -4
  29. package/lib/chain/chain.d.ts.map +1 -1
  30. package/lib/chain/chain.js +35 -60
  31. package/lib/chain/chain.js.map +1 -1
  32. package/lib/chain/errors/blockError.d.ts +2 -16
  33. package/lib/chain/errors/blockError.d.ts.map +1 -1
  34. package/lib/chain/errors/blockError.js.map +1 -1
  35. package/lib/chain/errors/dataColumnSidecarError.d.ts +2 -15
  36. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  37. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  38. package/lib/chain/errors/executionPayloadEnvelope.d.ts +0 -10
  39. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  40. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  41. package/lib/chain/interface.d.ts +2 -2
  42. package/lib/chain/interface.d.ts.map +1 -1
  43. package/lib/chain/prepareNextSlot.js +13 -13
  44. package/lib/chain/prepareNextSlot.js.map +1 -1
  45. package/lib/chain/validation/block.d.ts.map +1 -1
  46. package/lib/chain/validation/block.js +4 -26
  47. package/lib/chain/validation/block.js.map +1 -1
  48. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  49. package/lib/chain/validation/dataColumnSidecar.js +13 -38
  50. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  51. package/lib/chain/validation/executionPayloadEnvelope.js +0 -10
  52. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  53. package/lib/db/beacon.d.ts +5 -14
  54. package/lib/db/beacon.d.ts.map +1 -1
  55. package/lib/db/beacon.js +3 -17
  56. package/lib/db/beacon.js.map +1 -1
  57. package/lib/db/index.d.ts +0 -1
  58. package/lib/db/index.d.ts.map +1 -1
  59. package/lib/db/interface.d.ts +1 -8
  60. package/lib/db/interface.d.ts.map +1 -1
  61. package/lib/db/repositories/blockArchive.d.ts +1 -8
  62. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  63. package/lib/db/repositories/blockArchive.js +28 -65
  64. package/lib/db/repositories/blockArchive.js.map +1 -1
  65. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -1
  66. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  67. package/lib/db/repositories/blockArchiveIndex.js +7 -3
  68. package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
  69. package/lib/metrics/metrics/lodestar.d.ts +0 -18
  70. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  71. package/lib/metrics/metrics/lodestar.js +1 -55
  72. package/lib/metrics/metrics/lodestar.js.map +1 -1
  73. package/lib/monitoring/clientStats.js +1 -1
  74. package/lib/monitoring/clientStats.js.map +1 -1
  75. package/lib/network/gossip/encoding.d.ts.map +1 -1
  76. package/lib/network/gossip/encoding.js +6 -0
  77. package/lib/network/gossip/encoding.js.map +1 -1
  78. package/lib/network/gossip/topic.d.ts +1 -2
  79. package/lib/network/gossip/topic.d.ts.map +1 -1
  80. package/lib/network/gossip/topic.js +20 -4
  81. package/lib/network/gossip/topic.js.map +1 -1
  82. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  83. package/lib/network/processor/gossipHandlers.js +7 -6
  84. package/lib/network/processor/gossipHandlers.js.map +1 -1
  85. package/lib/network/processor/index.d.ts +3 -49
  86. package/lib/network/processor/index.d.ts.map +1 -1
  87. package/lib/network/processor/index.js +98 -232
  88. package/lib/network/processor/index.js.map +1 -1
  89. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  90. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +91 -112
  91. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  92. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  93. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +0 -2
  94. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  95. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  96. package/lib/network/reqresp/protocols.js +22 -6
  97. package/lib/network/reqresp/protocols.js.map +1 -1
  98. package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts +1 -2
  99. package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -1
  100. package/lib/network/reqresp/utils/dataColumnResponseValidation.js +9 -14
  101. package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
  102. package/lib/node/nodejs.d.ts +1 -2
  103. package/lib/node/nodejs.d.ts.map +1 -1
  104. package/lib/node/nodejs.js +2 -4
  105. package/lib/node/nodejs.js.map +1 -1
  106. package/lib/util/sszBytes.d.ts +0 -6
  107. package/lib/util/sszBytes.d.ts.map +1 -1
  108. package/lib/util/sszBytes.js +1 -1
  109. package/lib/util/sszBytes.js.map +1 -1
  110. package/package.json +15 -15
  111. package/src/api/impl/beacon/blocks/index.ts +4 -8
  112. package/src/chain/archiveStore/archiveStore.ts +1 -6
  113. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
  114. package/src/chain/archiveStore/historicalState/metrics.ts +1 -14
  115. package/src/chain/archiveStore/historicalState/types.ts +0 -2
  116. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  117. package/src/chain/archiveStore/utils/archiveBlocks.ts +39 -34
  118. package/src/chain/blocks/index.ts +2 -13
  119. package/src/chain/blocks/writeBlockInputToDb.ts +17 -10
  120. package/src/chain/chain.ts +34 -75
  121. package/src/chain/errors/blockError.ts +8 -20
  122. package/src/chain/errors/dataColumnSidecarError.ts +8 -24
  123. package/src/chain/errors/executionPayloadEnvelope.ts +2 -14
  124. package/src/chain/interface.ts +2 -2
  125. package/src/chain/prepareNextSlot.ts +16 -16
  126. package/src/chain/validation/block.ts +4 -26
  127. package/src/chain/validation/dataColumnSidecar.ts +14 -47
  128. package/src/chain/validation/executionPayloadEnvelope.ts +0 -10
  129. package/src/db/beacon.ts +6 -33
  130. package/src/db/index.ts +0 -1
  131. package/src/db/interface.ts +1 -9
  132. package/src/db/repositories/blockArchive.ts +30 -89
  133. package/src/db/repositories/blockArchiveIndex.ts +9 -4
  134. package/src/metrics/metrics/lodestar.ts +1 -57
  135. package/src/monitoring/clientStats.ts +1 -1
  136. package/src/network/gossip/encoding.ts +6 -0
  137. package/src/network/gossip/topic.ts +25 -3
  138. package/src/network/processor/gossipHandlers.ts +11 -11
  139. package/src/network/processor/index.ts +148 -263
  140. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +105 -139
  141. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +0 -2
  142. package/src/network/reqresp/protocols.ts +24 -7
  143. package/src/network/reqresp/utils/dataColumnResponseValidation.ts +7 -15
  144. package/src/node/nodejs.ts +1 -6
  145. package/src/util/sszBytes.ts +1 -1
  146. package/lib/db/dataColumnStore.d.ts +0 -39
  147. package/lib/db/dataColumnStore.d.ts.map +0 -1
  148. package/lib/db/dataColumnStore.js +0 -81
  149. package/lib/db/dataColumnStore.js.map +0 -1
  150. package/lib/db/flatFileStore/atomicWrite.d.ts +0 -8
  151. package/lib/db/flatFileStore/atomicWrite.d.ts.map +0 -1
  152. package/lib/db/flatFileStore/atomicWrite.js +0 -61
  153. package/lib/db/flatFileStore/atomicWrite.js.map +0 -1
  154. package/lib/db/flatFileStore/dcolFormat.d.ts +0 -90
  155. package/lib/db/flatFileStore/dcolFormat.d.ts.map +0 -1
  156. package/lib/db/flatFileStore/dcolFormat.js +0 -286
  157. package/lib/db/flatFileStore/dcolFormat.js.map +0 -1
  158. package/lib/db/flatFileStore/errors.d.ts +0 -82
  159. package/lib/db/flatFileStore/errors.d.ts.map +0 -1
  160. package/lib/db/flatFileStore/errors.js +0 -32
  161. package/lib/db/flatFileStore/errors.js.map +0 -1
  162. package/lib/db/flatFileStore/flatFileStore.d.ts +0 -41
  163. package/lib/db/flatFileStore/flatFileStore.d.ts.map +0 -1
  164. package/lib/db/flatFileStore/flatFileStore.js +0 -251
  165. package/lib/db/flatFileStore/flatFileStore.js.map +0 -1
  166. package/lib/db/flatFileStore/index.d.ts +0 -4
  167. package/lib/db/flatFileStore/index.d.ts.map +0 -1
  168. package/lib/db/flatFileStore/index.js +0 -2
  169. package/lib/db/flatFileStore/index.js.map +0 -1
  170. package/lib/db/flatFileStore/interface.d.ts +0 -25
  171. package/lib/db/flatFileStore/interface.d.ts.map +0 -1
  172. package/lib/db/flatFileStore/interface.js +0 -2
  173. package/lib/db/flatFileStore/interface.js.map +0 -1
  174. package/lib/db/flatFileStore/metrics.d.ts +0 -24
  175. package/lib/db/flatFileStore/metrics.d.ts.map +0 -1
  176. package/lib/db/flatFileStore/metrics.js +0 -25
  177. package/lib/db/flatFileStore/metrics.js.map +0 -1
  178. package/lib/db/flatFileStore/path.d.ts +0 -9
  179. package/lib/db/flatFileStore/path.d.ts.map +0 -1
  180. package/lib/db/flatFileStore/path.js +0 -21
  181. package/lib/db/flatFileStore/path.js.map +0 -1
  182. package/lib/db/flatFileStore/slotIndex.d.ts +0 -14
  183. package/lib/db/flatFileStore/slotIndex.d.ts.map +0 -1
  184. package/lib/db/flatFileStore/slotIndex.js +0 -46
  185. package/lib/db/flatFileStore/slotIndex.js.map +0 -1
  186. package/lib/db/flatFileStore/snappy.d.ts +0 -3
  187. package/lib/db/flatFileStore/snappy.d.ts.map +0 -1
  188. package/lib/db/flatFileStore/snappy.js +0 -12
  189. package/lib/db/flatFileStore/snappy.js.map +0 -1
  190. package/src/db/dataColumnStore.ts +0 -113
  191. package/src/db/flatFileStore/atomicWrite.ts +0 -65
  192. package/src/db/flatFileStore/dcolFormat.ts +0 -389
  193. package/src/db/flatFileStore/errors.ts +0 -53
  194. package/src/db/flatFileStore/flatFileStore.ts +0 -310
  195. package/src/db/flatFileStore/index.ts +0 -3
  196. package/src/db/flatFileStore/interface.ts +0 -21
  197. package/src/db/flatFileStore/metrics.ts +0 -48
  198. package/src/db/flatFileStore/path.ts +0 -32
  199. package/src/db/flatFileStore/slotIndex.ts +0 -56
  200. package/src/db/flatFileStore/snappy.ts +0 -14
@@ -1,251 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fromHex, toRootHex } from "@lodestar/utils";
4
- import { atomicWrite, mkdirDurable } from "./atomicWrite.js";
5
- import { DCOL_HEADER_SIZE, encodeDcolFile, getColumnByteRange, mergeDcolColumns, offsetTableSize, parseDcolHeader, parseDcolOffsets, readAllColumns, totalBits, } from "./dcolFormat.js";
6
- import { DataColumnStoreError, DataColumnStoreErrorCode, isFsNotFoundError } from "./errors.js";
7
- import { FlatFileStoreOperation, observeFlatFileStoreOperation } from "./metrics.js";
8
- import { assertValidRootHex, padSlot } from "./path.js";
9
- import { SlotIndex } from "./slotIndex.js";
10
- import { uncompress } from "./snappy.js";
11
- /**
12
- * Filesystem storage for data columns, keyed by slot and block root.
13
- * Hot and finalized data share the same layout. The top-level slot index is rebuilt on startup
14
- * without inspecting the contents of slot directories.
15
- * Per-slot mutation locking coordinates incremental writes, deletion, and pruning.
16
- */
17
- export class FlatFileStore {
18
- dataColumnDir;
19
- config;
20
- logger;
21
- slotIndex = new SlotIndex();
22
- mutationLocks = new Map();
23
- minRetainedSlot = 0;
24
- metrics = null;
25
- constructor(dataColumnDir, config, logger, metrics = null) {
26
- this.dataColumnDir = dataColumnDir;
27
- this.config = config;
28
- this.logger = logger;
29
- this.setMetrics(metrics);
30
- }
31
- setMetrics(metrics) {
32
- if (metrics === this.metrics)
33
- return;
34
- this.metrics = metrics;
35
- metrics?.slotIndexSize.addCollect((metric) => metric.set(this.slotIndex.size));
36
- }
37
- async init() {
38
- const endTimer = this.metrics?.startupDuration.startTimer();
39
- try {
40
- await mkdirDurable(this.dataColumnDir);
41
- const stats = await this.slotIndex.rebuildFromDisk(this.dataColumnDir);
42
- if (stats.ignoredEntries > 0) {
43
- this.logger.warn("Ignored non-canonical flat file store entries", {
44
- entries: stats.ignoredEntries,
45
- });
46
- }
47
- this.logger.info("Flat file store initialized", {
48
- slots: stats.slots,
49
- });
50
- }
51
- catch (e) {
52
- this.metrics?.startupErrors.inc();
53
- if (e instanceof DataColumnStoreError) {
54
- throw e;
55
- }
56
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.STARTUP_FAILED }, "Flat file store initialization failed", e);
57
- }
58
- finally {
59
- endTimer?.();
60
- }
61
- }
62
- async close() {
63
- // All operations are stateless file I/O.
64
- }
65
- async getDataColumns(slot, blockRoot) {
66
- return observeFlatFileStoreOperation(this.metrics, FlatFileStoreOperation.read, async () => {
67
- const data = await this.readFile(slot, blockRoot);
68
- if (!data)
69
- return [];
70
- this.metrics?.readBytes.inc(data.length);
71
- const header = parseDcolHeader(data);
72
- validateDcolHeader(header, slot, blockRoot);
73
- const columns = readAllColumns(data, header);
74
- const dataColumnSidecarType = this.config.getForkTypes(slot).DataColumnSidecar;
75
- return columns.map((col) => dataColumnSidecarType.deserialize(col.data));
76
- });
77
- }
78
- async getDataColumnsBinary(slot, blockRoot, indices) {
79
- return observeFlatFileStoreOperation(this.metrics, FlatFileStoreOperation.read, () => this.getColumnsBinaryUninstrumented(slot, blockRoot, indices));
80
- }
81
- async putDataColumnsBinary(slot, blockRoot, columns) {
82
- const rootBytes = fromHex(blockRoot);
83
- if (columns.length === 0)
84
- return;
85
- await observeFlatFileStoreOperation(this.metrics, FlatFileStoreOperation.write, async () => {
86
- const release = await this.acquireMutationLock(slot);
87
- try {
88
- if (slot < this.minRetainedSlot) {
89
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.SLOT_PRUNED, slot, minRetainedSlot: this.minRetainedSlot }, `Cannot write pruned data column slot=${slot} minRetainedSlot=${this.minRetainedSlot}`);
90
- }
91
- const existing = await this.readFile(slot, blockRoot);
92
- let fileData;
93
- if (existing) {
94
- this.metrics?.readBytes.inc(existing.length);
95
- const header = parseDcolHeader(existing);
96
- validateDcolHeader(header, slot, blockRoot);
97
- fileData = mergeDcolColumns(existing, columns);
98
- }
99
- else {
100
- fileData = encodeDcolFile(rootBytes, slot, columns);
101
- }
102
- // The rename can succeed even if syncing its directory fails.
103
- this.slotIndex.add(slot);
104
- await atomicWrite(this.filePath(slot, blockRoot), fileData);
105
- this.metrics?.writeBytes.inc(fileData.length);
106
- }
107
- finally {
108
- release();
109
- }
110
- });
111
- }
112
- async deleteMany(items) {
113
- const results = await Promise.allSettled(items.map(({ slot, blockRoot }) => this.delete(slot, blockRoot)));
114
- const errors = results
115
- .filter((result) => result.status === "rejected")
116
- .map((result) => result.reason);
117
- if (errors.length > 0) {
118
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.BATCH_DELETE_FAILED, failures: errors.length }, "Failed to delete flat file data", new AggregateError(errors));
119
- }
120
- }
121
- async pruneBefore(minSlot) {
122
- return observeFlatFileStoreOperation(this.metrics, FlatFileStoreOperation.prune, async () => {
123
- this.minRetainedSlot = Math.max(this.minRetainedSlot, minSlot);
124
- const slotsToPrune = new Set(this.slotIndex.getBefore(this.minRetainedSlot));
125
- for (const slot of this.mutationLocks.keys()) {
126
- if (slot < this.minRetainedSlot)
127
- slotsToPrune.add(slot);
128
- }
129
- for (const slot of slotsToPrune) {
130
- const release = await this.acquireMutationLock(slot);
131
- try {
132
- await fs.promises.rm(path.join(this.dataColumnDir, padSlot(slot)), { recursive: true, force: true });
133
- this.slotIndex.remove(slot);
134
- this.metrics?.prunedDirectories.inc();
135
- }
136
- finally {
137
- release();
138
- }
139
- }
140
- return [...slotsToPrune].sort((a, b) => a - b);
141
- });
142
- }
143
- filePath(slot, rootHex) {
144
- assertValidRootHex(rootHex);
145
- return path.join(this.dataColumnDir, padSlot(slot), `${rootHex}.dcol`);
146
- }
147
- acquireMutationLock(slot) {
148
- let release;
149
- const prev = this.mutationLocks.get(slot) ?? Promise.resolve();
150
- const next = new Promise((resolve) => {
151
- release = resolve;
152
- });
153
- const chained = prev.then(() => next);
154
- this.mutationLocks.set(slot, chained);
155
- return prev.then(() => {
156
- let released = false;
157
- return () => {
158
- if (released)
159
- return;
160
- released = true;
161
- release();
162
- if (this.mutationLocks.get(slot) === chained) {
163
- this.mutationLocks.delete(slot);
164
- }
165
- };
166
- });
167
- }
168
- async readFile(slot, rootHex) {
169
- try {
170
- return await fs.promises.readFile(this.filePath(slot, rootHex));
171
- }
172
- catch (e) {
173
- if (!isFsNotFoundError(e))
174
- throw e;
175
- return null;
176
- }
177
- }
178
- async getColumnsBinaryUninstrumented(slot, rootHex, indices) {
179
- let fd;
180
- try {
181
- fd = await fs.promises.open(this.filePath(slot, rootHex), "r");
182
- }
183
- catch (e) {
184
- if (!isFsNotFoundError(e))
185
- throw e;
186
- return null;
187
- }
188
- try {
189
- const headerBuf = new Uint8Array(DCOL_HEADER_SIZE);
190
- await readExactly(fd, headerBuf, 0);
191
- this.metrics?.readBytes.inc(headerBuf.length);
192
- const header = parseDcolHeader(headerBuf);
193
- validateDcolHeader(header, slot, rootHex);
194
- const N = totalBits(header.bitmap);
195
- const tableSize = offsetTableSize(N);
196
- const offsetTable = new Uint8Array(tableSize);
197
- await readExactly(fd, offsetTable, DCOL_HEADER_SIZE);
198
- this.metrics?.readBytes.inc(offsetTable.length);
199
- const fileSize = (await fd.stat()).size;
200
- const offsets = parseDcolOffsets(offsetTable, N, fileSize - DCOL_HEADER_SIZE - tableSize);
201
- const results = [];
202
- for (const idx of indices) {
203
- const range = getColumnByteRange(header, offsets, idx);
204
- if (!range) {
205
- results.push(undefined);
206
- continue;
207
- }
208
- const buf = new Uint8Array(range.length);
209
- await readExactly(fd, buf, range.offset);
210
- this.metrics?.readBytes.inc(buf.length);
211
- results.push(uncompress(buf));
212
- }
213
- return results;
214
- }
215
- finally {
216
- await fd.close();
217
- }
218
- }
219
- async delete(slot, rootHex) {
220
- await observeFlatFileStoreOperation(this.metrics, FlatFileStoreOperation.delete, async () => {
221
- const release = await this.acquireMutationLock(slot);
222
- try {
223
- await fs.promises.rm(this.filePath(slot, rootHex), { force: true });
224
- }
225
- finally {
226
- release();
227
- }
228
- });
229
- }
230
- }
231
- function validateDcolHeader(header, slot, rootHex) {
232
- if (header.slot !== slot) {
233
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.SLOT_MISMATCH, headerSlot: header.slot, pathSlot: slot }, `Dcol slot mismatch: header=${header.slot} path=${slot}`);
234
- }
235
- const headerRoot = toRootHex(header.blockRoot);
236
- if (headerRoot !== rootHex) {
237
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.ROOT_MISMATCH, headerRoot, pathRoot: rootHex }, `Dcol block root mismatch: header=${headerRoot} path=${rootHex}`);
238
- }
239
- }
240
- async function readExactly(fd, buffer, position) {
241
- let totalRead = 0;
242
- while (totalRead < buffer.length) {
243
- const { bytesRead } = await fd.read(buffer, totalRead, buffer.length - totalRead, position + totalRead);
244
- if (bytesRead === 0) {
245
- const offset = position + totalRead;
246
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.UNEXPECTED_EOF, offset }, `Unexpected end of dcol file at offset ${offset}`);
247
- }
248
- totalRead += bytesRead;
249
- }
250
- }
251
- //# sourceMappingURL=flatFileStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flatFileStore.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/flatFileStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAS,OAAO,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAEhB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,oBAAoB,EAAE,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAE9F,OAAO,EAA4B,sBAAsB,EAAE,6BAA6B,EAAC,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAC,kBAAkB,E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ACtG,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;YACpC,MAAM,IAAI,oBAAoB,CAC5B,EAAC,IAAI,EAAE,wBAAwB,CAAC,cAAc,EAAE,MAAM,EAAC,EACvD,yCAAyC,MAAM,EAAE,CAClD,CAAC;QACJ,CAAC;QACD,SAAS,IAAI,SAAS,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -1,4 +0,0 @@
1
- export { FlatFileStore } from "./flatFileStore.js";
2
- export type { IFlatFileStore } from "./interface.js";
3
- export type { FlatFileStoreMetrics } from "./metrics.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC"}
@@ -1,2 +0,0 @@
1
- export { FlatFileStore } from "./flatFileStore.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC"}
@@ -1,25 +0,0 @@
1
- import { DataColumnSidecar, RootHex, Slot } from "@lodestar/types";
2
- /**
3
- * Flat file storage interface for data columns.
4
- *
5
- * No hot/cold distinction — data is always keyed by (slot, blockRoot).
6
- * All filesystem operations are crash-safe via atomic writes.
7
- *
8
- */
9
- export interface IFlatFileStore {
10
- init(): Promise<void>;
11
- close(): Promise<void>;
12
- getDataColumns(slot: Slot, blockRoot: RootHex): Promise<DataColumnSidecar[]>;
13
- /** Returns null if the file is absent, and undefined entries for columns missing from an existing file. */
14
- getDataColumnsBinary(slot: Slot, blockRoot: RootHex, indices: number[]): Promise<(Uint8Array | undefined)[] | null>;
15
- putDataColumnsBinary(slot: Slot, blockRoot: RootHex, columns: {
16
- index: number;
17
- data: Uint8Array;
18
- }[]): Promise<void>;
19
- deleteMany(items: {
20
- slot: Slot;
21
- blockRoot: RootHex;
22
- }[]): Promise<void>;
23
- pruneBefore(slot: Slot): Promise<Slot[]>;
24
- }
25
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC7E,2GAA2G;IAC3G,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACpH,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElH,UAAU,CAAC,KAAK,EAAE;QAAC,IAAI,EAAE,IAAI,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;CAC1C"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/interface.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import type { Counter, GaugeExtra, Histogram } from "@lodestar/utils";
2
- export declare const FlatFileStoreOperation: {
3
- readonly read: "read";
4
- readonly write: "write";
5
- readonly delete: "delete";
6
- readonly prune: "prune";
7
- };
8
- export type FlatFileStoreOperation = (typeof FlatFileStoreOperation)[keyof typeof FlatFileStoreOperation];
9
- type OperationLabels = {
10
- operation: FlatFileStoreOperation;
11
- };
12
- export type FlatFileStoreMetrics = {
13
- operationDuration: Record<FlatFileStoreOperation, Histogram>;
14
- operationErrors: Counter<OperationLabels>;
15
- readBytes: Counter;
16
- writeBytes: Counter;
17
- prunedDirectories: Counter;
18
- slotIndexSize: GaugeExtra;
19
- startupDuration: Histogram;
20
- startupErrors: Counter;
21
- };
22
- export declare function observeFlatFileStoreOperation<T>(metrics: FlatFileStoreMetrics | null, operation: FlatFileStoreOperation, fn: () => Promise<T>): Promise<T>;
23
- export {};
24
- //# sourceMappingURL=metrics.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGpE,eAAO,MAAM,sBAAsB;aACjC,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,OAAO;aACd,MAAM,EAAE,QAAQ;aAChB,KAAK,EAAE,OAAO;CACN,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAE1G,KAAK,eAAe,GAAG;IAAC,SAAS,EAAE,sBAAsB,CAAA;CAAC,CAAC;AAE3D,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,EAAE,MAAM,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAC7D,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,eAAe,EAAE,SAAS,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,CAAC,EACnD,OAAO,EAAE,oBAAoB,GAAG,IAAI,EACpC,SAAS,EAAE,sBAAsB,EACjC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
@@ -1,25 +0,0 @@
1
- import { DataColumnStoreError, DataColumnStoreErrorCode } from "./errors.js";
2
- export const FlatFileStoreOperation = {
3
- read: "read",
4
- write: "write",
5
- delete: "delete",
6
- prune: "prune",
7
- };
8
- export async function observeFlatFileStoreOperation(metrics, operation, fn) {
9
- const labels = { operation };
10
- const endTimer = metrics?.operationDuration[operation].startTimer();
11
- try {
12
- return await fn();
13
- }
14
- catch (e) {
15
- metrics?.operationErrors.inc(labels);
16
- if (e instanceof DataColumnStoreError) {
17
- throw e;
18
- }
19
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.OPERATION_FAILED, operation }, `Flat file store ${operation} operation failed`, e);
20
- }
21
- finally {
22
- endTimer?.();
23
- }
24
- }
25
- //# sourceMappingURL=metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/metrics.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAE,wBAAwB,EAAC,MAAM,aAAa,CAAC;AAE3E,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACN,CAAC;AAiBX,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAoC,EACpC,SAAiC,EACjC,EAAoB;IAEpB,MAAM,MAAM,GAAG,EAAC,SAAS,EAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;IACpE,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,YAAY,oBAAoB,EAAE,CAAC;YACtC,MAAM,CAAC,CAAC;QACV,CAAC;QACD,MAAM,IAAI,oBAAoB,CAC5B,EAAC,IAAI,EAAE,wBAAwB,CAAC,gBAAgB,EAAE,SAAS,EAAC,EAC5D,mBAAmB,SAAS,mBAAmB,EAC/C,CAAC,CACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,EAAE,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { RootHex } from "@lodestar/types";
2
- export declare function isValidRootHex(rootHex: string): rootHex is RootHex;
3
- export declare function assertValidRootHex(rootHex: string): asserts rootHex is RootHex;
4
- /**
5
- * Zero-pad a slot number to 12 digits for lexicographic ordering in directory names.
6
- * Twelve digits covers many centuries of Ethereum; larger safe integers remain untruncated.
7
- */
8
- export declare function padSlot(slot: number): string;
9
- //# sourceMappingURL=path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAK7C,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,OAAO,CAElE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAO9E;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5C"}
@@ -1,21 +0,0 @@
1
- import { DataColumnStoreError, DataColumnStoreErrorCode } from "./errors.js";
2
- const ROOT_HEX_PATTERN = /^0x[0-9a-f]{64}$/;
3
- export function isValidRootHex(rootHex) {
4
- return ROOT_HEX_PATTERN.test(rootHex);
5
- }
6
- export function assertValidRootHex(rootHex) {
7
- if (!isValidRootHex(rootHex)) {
8
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.INVALID_ROOT, root: rootHex }, `Invalid flat file root: ${rootHex}`);
9
- }
10
- }
11
- /**
12
- * Zero-pad a slot number to 12 digits for lexicographic ordering in directory names.
13
- * Twelve digits covers many centuries of Ethereum; larger safe integers remain untruncated.
14
- */
15
- export function padSlot(slot) {
16
- if (!Number.isSafeInteger(slot) || slot < 0) {
17
- throw new DataColumnStoreError({ code: DataColumnStoreErrorCode.INVALID_SLOT, slot }, `Invalid flat file slot: ${slot}`);
18
- }
19
- return String(slot).padStart(12, "0");
20
- }
21
- //# sourceMappingURL=path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAE,wBAAwB,EAAC,MAAM,aAAa,CAAC;AAE3E,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,oBAAoB,CAC5B,EAAC,IAAI,EAAE,wBAAwB,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,EAAC,EAC5D,2BAA2B,OAAO,EAAE,CACrC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,CAC5B,EAAC,IAAI,EAAE,wBAAwB,CAAC,YAAY,EAAE,IAAI,EAAC,EACnD,2BAA2B,IAAI,EAAE,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { Slot } from "@lodestar/types";
2
- export type SlotIndexRebuildStats = {
3
- slots: number;
4
- ignoredEntries: number;
5
- };
6
- export declare class SlotIndex {
7
- private readonly slots;
8
- get size(): number;
9
- add(slot: Slot): void;
10
- remove(slot: Slot): void;
11
- getBefore(minSlot: Slot): Slot[];
12
- rebuildFromDisk(columnsDir: string): Promise<SlotIndexRebuildStats>;
13
- }
14
- //# sourceMappingURL=slotIndex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slotIndex.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/slotIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAIrC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IAEzC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAEpB;IAED,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAEvB;IAED,SAAS,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,CAM/B;IAEK,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqBxE;CACF"}
@@ -1,46 +0,0 @@
1
- import fs from "node:fs";
2
- import { isFsNotFoundError } from "./errors.js";
3
- import { padSlot } from "./path.js";
4
- export class SlotIndex {
5
- slots = new Set();
6
- get size() {
7
- return this.slots.size;
8
- }
9
- add(slot) {
10
- this.slots.add(slot);
11
- }
12
- remove(slot) {
13
- this.slots.delete(slot);
14
- }
15
- getBefore(minSlot) {
16
- const slots = [];
17
- for (const slot of this.slots) {
18
- if (slot < minSlot)
19
- slots.push(slot);
20
- }
21
- return slots;
22
- }
23
- async rebuildFromDisk(columnsDir) {
24
- this.slots.clear();
25
- let entries;
26
- try {
27
- entries = await fs.promises.readdir(columnsDir, { withFileTypes: true });
28
- }
29
- catch (e) {
30
- if (!isFsNotFoundError(e))
31
- throw e;
32
- return { slots: 0, ignoredEntries: 0 };
33
- }
34
- let ignoredEntries = 0;
35
- for (const entry of entries) {
36
- const slot = Number(entry.name);
37
- if (!entry.isDirectory() || !Number.isSafeInteger(slot) || slot < 0 || entry.name !== padSlot(slot)) {
38
- ignoredEntries++;
39
- continue;
40
- }
41
- this.slots.add(slot);
42
- }
43
- return { slots: this.slots.size, ignoredEntries };
44
- }
45
- }
46
- //# sourceMappingURL=slotIndex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slotIndex.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/slotIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,EA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WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpG,cAAc,EAAE,CAAC;gBACjB,SAAS;YACX,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,EAAC,CAAC;IAClD,CAAC;CACF"}
@@ -1,3 +0,0 @@
1
- export declare function compress(data: Uint8Array): Uint8Array;
2
- export declare function uncompress(data: Uint8Array): Uint8Array;
3
- //# sourceMappingURL=snappy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snappy.d.ts","sourceRoot":"","sources":["../../../src/db/flatFileStore/snappy.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAErD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAGvD"}
@@ -1,12 +0,0 @@
1
- import { compressSync, uncompressSync } from "snappy";
2
- export function compress(data) {
3
- return compressSync(toBuffer(data));
4
- }
5
- export function uncompress(data) {
6
- const result = uncompressSync(toBuffer(data), { asBuffer: true });
7
- return new Uint8Array(result.buffer, result.byteOffset, result.byteLength);
8
- }
9
- function toBuffer(data) {
10
- return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
11
- }
12
- //# sourceMappingURL=snappy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snappy.js","sourceRoot":"","sources":["../../../src/db/flatFileStore/snappy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,QAAQ,CAAC;AAEpD,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACvC,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB;IACzC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAW,CAAC;IAC1E,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,QAAQ,CAAC,IAAgB;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACpE,CAAC"}
@@ -1,113 +0,0 @@
1
- import {ColumnIndex, DataColumnSidecar, RootHex, Slot} from "@lodestar/types";
2
- import {fromHex} from "@lodestar/utils";
3
- import type {IFlatFileStore} from "./flatFileStore/interface.js";
4
- import type {
5
- BlockArchiveRepository,
6
- DataColumnSidecarArchiveRepository,
7
- DataColumnSidecarRepository,
8
- } from "./repositories/index.js";
9
-
10
- export type DataColumnKey = {slot: Slot; blockRoot: RootHex};
11
- export type IndexedDataColumnBytes = {index: ColumnIndex; data: Uint8Array};
12
-
13
- type LegacyHotDataColumnStore = Pick<DataColumnSidecarRepository, "values" | "getManyBinary" | "deleteMany">;
14
- type LegacyArchiveDataColumnStore = Pick<
15
- DataColumnSidecarArchiveRepository,
16
- "values" | "getManyBinary" | "keys" | "deleteMany"
17
- >;
18
- type BlockRootIndex = Pick<BlockArchiveRepository, "getSlotByRoot">;
19
-
20
- export interface IDataColumnStore {
21
- getAll(key: DataColumnKey): Promise<DataColumnSidecar[]>;
22
- getManyBinary(key: DataColumnKey, indices: ColumnIndex[]): Promise<(Uint8Array | undefined)[]>;
23
- putManyBinary(key: DataColumnKey, columns: IndexedDataColumnBytes[]): Promise<void>;
24
- deleteMany(keys: DataColumnKey[]): Promise<void>;
25
- pruneBefore(slot: Slot): Promise<Slot[]>;
26
- }
27
-
28
- /**
29
- * Bridges pre-flat-file LevelDB columns during the supported in-place upgrade window.
30
- * Remove the legacy repositories after upgrades from the last pre-flat-file release are no longer supported.
31
- */
32
- export class LegacyDataColumnStore implements IDataColumnStore {
33
- constructor(
34
- private readonly flatFiles: IFlatFileStore,
35
- private readonly legacyHot: LegacyHotDataColumnStore,
36
- private readonly legacyArchive: LegacyArchiveDataColumnStore,
37
- private readonly blockArchive: BlockRootIndex
38
- ) {}
39
-
40
- async getAll({slot, blockRoot}: DataColumnKey): Promise<DataColumnSidecar[]> {
41
- const sidecars = await this.flatFiles.getDataColumns(slot, blockRoot);
42
- if (sidecars.length > 0) return sidecars;
43
-
44
- const sidecarsByIndex = new Map<ColumnIndex, DataColumnSidecar>();
45
- const root = fromHex(blockRoot);
46
- for (const sidecar of await this.legacyHot.values(root)) {
47
- if (!sidecarsByIndex.has(sidecar.index)) sidecarsByIndex.set(sidecar.index, sidecar);
48
- }
49
-
50
- if ((await this.blockArchive.getSlotByRoot(root)) === slot) {
51
- for (const sidecar of await this.legacyArchive.values(slot)) {
52
- if (!sidecarsByIndex.has(sidecar.index)) sidecarsByIndex.set(sidecar.index, sidecar);
53
- }
54
- }
55
-
56
- return [...sidecarsByIndex.values()].sort((a, b) => a.index - b.index);
57
- }
58
-
59
- async getManyBinary({slot, blockRoot}: DataColumnKey, indices: ColumnIndex[]): Promise<(Uint8Array | undefined)[]> {
60
- const flatFileSidecars = await this.flatFiles.getDataColumnsBinary(slot, blockRoot, indices);
61
- if (flatFileSidecars !== null) return flatFileSidecars;
62
- if (indices.length === 0) return [];
63
-
64
- const root = fromHex(blockRoot);
65
- const result = await this.legacyHot.getManyBinary(root, indices);
66
-
67
- const missingPositions = getMissingPositions(result);
68
- if (missingPositions.length === 0 || (await this.blockArchive.getSlotByRoot(root)) !== slot) return result;
69
-
70
- const archivedSidecars = await this.legacyArchive.getManyBinary(
71
- slot,
72
- missingPositions.map((position) => indices[position])
73
- );
74
- fillMissing(result, missingPositions, archivedSidecars);
75
- return result;
76
- }
77
-
78
- async putManyBinary({slot, blockRoot}: DataColumnKey, columns: IndexedDataColumnBytes[]): Promise<void> {
79
- await this.flatFiles.putDataColumnsBinary(slot, blockRoot, columns);
80
- }
81
-
82
- async deleteMany(keys: DataColumnKey[]): Promise<void> {
83
- await this.flatFiles.deleteMany(keys);
84
- await this.legacyHot.deleteMany(keys.map(({blockRoot}) => fromHex(blockRoot)));
85
- }
86
-
87
- async pruneBefore(slot: Slot): Promise<Slot[]> {
88
- const flatFileSlots = await this.flatFiles.pruneBefore(slot);
89
- const prefixedKeys = await this.legacyArchive.keys({lt: {prefix: slot, id: 0}});
90
- const slots = [...new Set(prefixedKeys.map(({prefix}) => prefix))];
91
- if (slots.length > 0) await this.legacyArchive.deleteMany(slots);
92
- return [...new Set([...flatFileSlots, ...slots])].sort((a, b) => a - b);
93
- }
94
- }
95
-
96
- function getMissingPositions(sidecars: (Uint8Array | undefined)[]): number[] {
97
- const positions: number[] = [];
98
- for (let i = 0; i < sidecars.length; i++) {
99
- if (sidecars[i] === undefined) positions.push(i);
100
- }
101
- return positions;
102
- }
103
-
104
- function fillMissing(
105
- result: (Uint8Array | undefined)[],
106
- missingPositions: number[],
107
- sidecars: (Uint8Array | null | undefined)[]
108
- ): void {
109
- for (let i = 0; i < missingPositions.length; i++) {
110
- const sidecar = sidecars[i];
111
- if (sidecar != null) result[missingPositions[i]] = sidecar;
112
- }
113
- }