@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.
- package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +4 -4
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +0 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +0 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +1 -12
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.d.ts +0 -2
- package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -4
- package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +34 -31
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +2 -3
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
- package/lib/chain/blocks/writeBlockInputToDb.js +16 -9
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +3 -4
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +35 -60
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +2 -16
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +2 -15
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +0 -10
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +13 -13
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +4 -26
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +13 -38
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +0 -10
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/db/beacon.d.ts +5 -14
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +3 -17
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/index.d.ts +0 -1
- package/lib/db/index.d.ts.map +1 -1
- package/lib/db/interface.d.ts +1 -8
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.d.ts +1 -8
- package/lib/db/repositories/blockArchive.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.js +28 -65
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.js +7 -3
- package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +0 -18
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +1 -55
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/monitoring/clientStats.js +1 -1
- package/lib/monitoring/clientStats.js.map +1 -1
- package/lib/network/gossip/encoding.d.ts.map +1 -1
- package/lib/network/gossip/encoding.js +6 -0
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -2
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +20 -4
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +7 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +3 -49
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +98 -232
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +91 -112
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +0 -2
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +22 -6
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts +1 -2
- package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js +9 -14
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
- package/lib/node/nodejs.d.ts +1 -2
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -4
- package/lib/node/nodejs.js.map +1 -1
- package/lib/util/sszBytes.d.ts +0 -6
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +4 -8
- package/src/chain/archiveStore/archiveStore.ts +1 -6
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
- package/src/chain/archiveStore/historicalState/metrics.ts +1 -14
- package/src/chain/archiveStore/historicalState/types.ts +0 -2
- package/src/chain/archiveStore/historicalState/worker.ts +1 -4
- package/src/chain/archiveStore/utils/archiveBlocks.ts +39 -34
- package/src/chain/blocks/index.ts +2 -13
- package/src/chain/blocks/writeBlockInputToDb.ts +17 -10
- package/src/chain/chain.ts +34 -75
- package/src/chain/errors/blockError.ts +8 -20
- package/src/chain/errors/dataColumnSidecarError.ts +8 -24
- package/src/chain/errors/executionPayloadEnvelope.ts +2 -14
- package/src/chain/interface.ts +2 -2
- package/src/chain/prepareNextSlot.ts +16 -16
- package/src/chain/validation/block.ts +4 -26
- package/src/chain/validation/dataColumnSidecar.ts +14 -47
- package/src/chain/validation/executionPayloadEnvelope.ts +0 -10
- package/src/db/beacon.ts +6 -33
- package/src/db/index.ts +0 -1
- package/src/db/interface.ts +1 -9
- package/src/db/repositories/blockArchive.ts +30 -89
- package/src/db/repositories/blockArchiveIndex.ts +9 -4
- package/src/metrics/metrics/lodestar.ts +1 -57
- package/src/monitoring/clientStats.ts +1 -1
- package/src/network/gossip/encoding.ts +6 -0
- package/src/network/gossip/topic.ts +25 -3
- package/src/network/processor/gossipHandlers.ts +11 -11
- package/src/network/processor/index.ts +148 -263
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +105 -139
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +0 -2
- package/src/network/reqresp/protocols.ts +24 -7
- package/src/network/reqresp/utils/dataColumnResponseValidation.ts +7 -15
- package/src/node/nodejs.ts +1 -6
- package/src/util/sszBytes.ts +1 -1
- package/lib/db/dataColumnStore.d.ts +0 -39
- package/lib/db/dataColumnStore.d.ts.map +0 -1
- package/lib/db/dataColumnStore.js +0 -81
- package/lib/db/dataColumnStore.js.map +0 -1
- package/lib/db/flatFileStore/atomicWrite.d.ts +0 -8
- package/lib/db/flatFileStore/atomicWrite.d.ts.map +0 -1
- package/lib/db/flatFileStore/atomicWrite.js +0 -61
- package/lib/db/flatFileStore/atomicWrite.js.map +0 -1
- package/lib/db/flatFileStore/dcolFormat.d.ts +0 -90
- package/lib/db/flatFileStore/dcolFormat.d.ts.map +0 -1
- package/lib/db/flatFileStore/dcolFormat.js +0 -286
- package/lib/db/flatFileStore/dcolFormat.js.map +0 -1
- package/lib/db/flatFileStore/errors.d.ts +0 -82
- package/lib/db/flatFileStore/errors.d.ts.map +0 -1
- package/lib/db/flatFileStore/errors.js +0 -32
- package/lib/db/flatFileStore/errors.js.map +0 -1
- package/lib/db/flatFileStore/flatFileStore.d.ts +0 -41
- package/lib/db/flatFileStore/flatFileStore.d.ts.map +0 -1
- package/lib/db/flatFileStore/flatFileStore.js +0 -251
- package/lib/db/flatFileStore/flatFileStore.js.map +0 -1
- package/lib/db/flatFileStore/index.d.ts +0 -4
- package/lib/db/flatFileStore/index.d.ts.map +0 -1
- package/lib/db/flatFileStore/index.js +0 -2
- package/lib/db/flatFileStore/index.js.map +0 -1
- package/lib/db/flatFileStore/interface.d.ts +0 -25
- package/lib/db/flatFileStore/interface.d.ts.map +0 -1
- package/lib/db/flatFileStore/interface.js +0 -2
- package/lib/db/flatFileStore/interface.js.map +0 -1
- package/lib/db/flatFileStore/metrics.d.ts +0 -24
- package/lib/db/flatFileStore/metrics.d.ts.map +0 -1
- package/lib/db/flatFileStore/metrics.js +0 -25
- package/lib/db/flatFileStore/metrics.js.map +0 -1
- package/lib/db/flatFileStore/path.d.ts +0 -9
- package/lib/db/flatFileStore/path.d.ts.map +0 -1
- package/lib/db/flatFileStore/path.js +0 -21
- package/lib/db/flatFileStore/path.js.map +0 -1
- package/lib/db/flatFileStore/slotIndex.d.ts +0 -14
- package/lib/db/flatFileStore/slotIndex.d.ts.map +0 -1
- package/lib/db/flatFileStore/slotIndex.js +0 -46
- package/lib/db/flatFileStore/slotIndex.js.map +0 -1
- package/lib/db/flatFileStore/snappy.d.ts +0 -3
- package/lib/db/flatFileStore/snappy.d.ts.map +0 -1
- package/lib/db/flatFileStore/snappy.js +0 -12
- package/lib/db/flatFileStore/snappy.js.map +0 -1
- package/src/db/dataColumnStore.ts +0 -113
- package/src/db/flatFileStore/atomicWrite.ts +0 -65
- package/src/db/flatFileStore/dcolFormat.ts +0 -389
- package/src/db/flatFileStore/errors.ts +0 -53
- package/src/db/flatFileStore/flatFileStore.ts +0 -310
- package/src/db/flatFileStore/index.ts +0 -3
- package/src/db/flatFileStore/interface.ts +0 -21
- package/src/db/flatFileStore/metrics.ts +0 -48
- package/src/db/flatFileStore/path.ts +0 -32
- package/src/db/flatFileStore/slotIndex.ts +0 -56
- package/src/db/flatFileStore/snappy.ts +0 -14
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
computeStartSlotAtEpoch,
|
|
12
12
|
getBlockHeaderProposerSignatureSetByHeaderSlot,
|
|
13
13
|
} from "@lodestar/state-transition";
|
|
14
|
-
import {DataColumnSidecar, Root,
|
|
14
|
+
import {DataColumnSidecar, Root, Slot, SubnetID, ValidatorIndex, fulu, gloas, ssz} from "@lodestar/types";
|
|
15
15
|
import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
|
|
16
16
|
import {BeaconMetrics} from "../../metrics/metrics/beacon.js";
|
|
17
17
|
import {Metrics} from "../../metrics/metrics.js";
|
|
@@ -39,14 +39,12 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
39
39
|
const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader));
|
|
40
40
|
|
|
41
41
|
// 1) [REJECT] The sidecar is valid as verified by verify_data_column_sidecar
|
|
42
|
-
verifyFuluDataColumnSidecar(chain.config, dataColumnSidecar
|
|
42
|
+
verifyFuluDataColumnSidecar(chain.config, dataColumnSidecar);
|
|
43
43
|
|
|
44
44
|
// 2) [REJECT] The sidecar is for the correct subnet -- i.e. compute_subnet_for_data_column_sidecar(sidecar.index) == subnet_id
|
|
45
45
|
if (computeSubnetForDataColumnSidecar(chain.config, dataColumnSidecar) !== gossipSubnet) {
|
|
46
46
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
47
47
|
code: DataColumnSidecarErrorCode.INVALID_SUBNET,
|
|
48
|
-
slot: blockHeader.slot,
|
|
49
|
-
root: blockRootHex,
|
|
50
48
|
columnIndex: dataColumnSidecar.index,
|
|
51
49
|
gossipSubnet: gossipSubnet,
|
|
52
50
|
});
|
|
@@ -102,9 +100,8 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
102
100
|
if (parentBlock.slot >= blockHeader.slot) {
|
|
103
101
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
104
102
|
code: DataColumnSidecarErrorCode.NOT_LATER_THAN_PARENT,
|
|
105
|
-
slot: blockHeader.slot,
|
|
106
|
-
root: blockRootHex,
|
|
107
103
|
parentSlot: parentBlock.slot,
|
|
104
|
+
slot: blockHeader.slot,
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
107
|
|
|
@@ -143,8 +140,6 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
143
140
|
if (proposerIndex !== expectedProposerIndex) {
|
|
144
141
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
145
142
|
code: DataColumnSidecarErrorCode.INCORRECT_PROPOSER,
|
|
146
|
-
slot: blockHeader.slot,
|
|
147
|
-
root: blockRootHex,
|
|
148
143
|
actualProposerIndex: proposerIndex,
|
|
149
144
|
expectedProposerIndex,
|
|
150
145
|
});
|
|
@@ -166,9 +161,9 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
166
161
|
) {
|
|
167
162
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
168
163
|
code: DataColumnSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
169
|
-
|
|
170
|
-
root: blockRootHex,
|
|
164
|
+
blockRoot: blockRootHex,
|
|
171
165
|
index: dataColumnSidecar.index,
|
|
166
|
+
slot: blockHeader.slot,
|
|
172
167
|
});
|
|
173
168
|
}
|
|
174
169
|
|
|
@@ -190,8 +185,7 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
190
185
|
if (!valid) {
|
|
191
186
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
192
187
|
code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID,
|
|
193
|
-
slot:
|
|
194
|
-
root: blockRootHex,
|
|
188
|
+
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
195
189
|
columnIndex: dataColumnSidecar.index,
|
|
196
190
|
});
|
|
197
191
|
}
|
|
@@ -210,7 +204,6 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
210
204
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
211
205
|
code: DataColumnSidecarErrorCode.INVALID_KZG_PROOF,
|
|
212
206
|
slot: blockHeader.slot,
|
|
213
|
-
root: blockRootHex,
|
|
214
207
|
columnIndex: dataColumnSidecar.index,
|
|
215
208
|
});
|
|
216
209
|
} finally {
|
|
@@ -247,7 +240,6 @@ export async function validateGossipGloasDataColumnSidecar(
|
|
|
247
240
|
if (block.slot !== dataColumnSidecar.slot) {
|
|
248
241
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
249
242
|
code: DataColumnSidecarErrorCode.INCORRECT_SIDECAR_SLOT,
|
|
250
|
-
root: blockRootHex,
|
|
251
243
|
columnIndex: dataColumnSidecar.index,
|
|
252
244
|
expected: block.slot,
|
|
253
245
|
actual: dataColumnSidecar.slot,
|
|
@@ -256,14 +248,12 @@ export async function validateGossipGloasDataColumnSidecar(
|
|
|
256
248
|
|
|
257
249
|
// [REJECT] The sidecar must pass verify_data_column_sidecar against the block commitments
|
|
258
250
|
const kzgCommitments = payloadInput.getBlobKzgCommitments();
|
|
259
|
-
verifyGloasDataColumnSidecar(dataColumnSidecar, kzgCommitments
|
|
251
|
+
verifyGloasDataColumnSidecar(dataColumnSidecar, kzgCommitments);
|
|
260
252
|
|
|
261
253
|
// [REJECT] The sidecar must be on the correct subnet
|
|
262
254
|
if (computeSubnetForDataColumnSidecar(chain.config, dataColumnSidecar) !== gossipSubnet) {
|
|
263
255
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
264
256
|
code: DataColumnSidecarErrorCode.INVALID_SUBNET,
|
|
265
|
-
slot: dataColumnSidecar.slot,
|
|
266
|
-
root: blockRootHex,
|
|
267
257
|
columnIndex: dataColumnSidecar.index,
|
|
268
258
|
gossipSubnet,
|
|
269
259
|
});
|
|
@@ -282,7 +272,6 @@ export async function validateGossipGloasDataColumnSidecar(
|
|
|
282
272
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
283
273
|
code: DataColumnSidecarErrorCode.INVALID_KZG_PROOF,
|
|
284
274
|
slot: dataColumnSidecar.slot,
|
|
285
|
-
root: blockRootHex,
|
|
286
275
|
columnIndex: dataColumnSidecar.index,
|
|
287
276
|
});
|
|
288
277
|
} finally {
|
|
@@ -294,17 +283,11 @@ export async function validateGossipGloasDataColumnSidecar(
|
|
|
294
283
|
* SPEC FUNCTION
|
|
295
284
|
* https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/p2p-interface.md#verify_data_column_sidecar
|
|
296
285
|
*/
|
|
297
|
-
function verifyFuluDataColumnSidecar(
|
|
298
|
-
config: ChainForkConfig,
|
|
299
|
-
dataColumnSidecar: fulu.DataColumnSidecar,
|
|
300
|
-
blockRootHex: RootHex
|
|
301
|
-
): void {
|
|
302
|
-
const slot = dataColumnSidecar.signedBlockHeader.message.slot;
|
|
286
|
+
function verifyFuluDataColumnSidecar(config: ChainForkConfig, dataColumnSidecar: fulu.DataColumnSidecar): void {
|
|
303
287
|
if (dataColumnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
304
288
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
305
289
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
306
|
-
slot,
|
|
307
|
-
root: blockRootHex,
|
|
290
|
+
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
308
291
|
columnIndex: dataColumnSidecar.index,
|
|
309
292
|
});
|
|
310
293
|
}
|
|
@@ -312,20 +295,18 @@ function verifyFuluDataColumnSidecar(
|
|
|
312
295
|
if (dataColumnSidecar.kzgCommitments.length === 0) {
|
|
313
296
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
314
297
|
code: DataColumnSidecarErrorCode.NO_COMMITMENTS,
|
|
315
|
-
slot,
|
|
316
|
-
root: blockRootHex,
|
|
298
|
+
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
317
299
|
columnIndex: dataColumnSidecar.index,
|
|
318
300
|
});
|
|
319
301
|
}
|
|
320
302
|
|
|
321
|
-
const epoch = computeEpochAtSlot(slot);
|
|
303
|
+
const epoch = computeEpochAtSlot(dataColumnSidecar.signedBlockHeader.message.slot);
|
|
322
304
|
const maxBlobsPerBlock = config.getMaxBlobsPerBlock(epoch);
|
|
323
305
|
|
|
324
306
|
if (dataColumnSidecar.kzgCommitments.length > maxBlobsPerBlock) {
|
|
325
307
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
326
308
|
code: DataColumnSidecarErrorCode.TOO_MANY_KZG_COMMITMENTS,
|
|
327
|
-
slot,
|
|
328
|
-
root: blockRootHex,
|
|
309
|
+
slot: dataColumnSidecar.signedBlockHeader.message.slot,
|
|
329
310
|
columnIndex: dataColumnSidecar.index,
|
|
330
311
|
count: dataColumnSidecar.kzgCommitments.length,
|
|
331
312
|
limit: maxBlobsPerBlock,
|
|
@@ -338,8 +319,6 @@ function verifyFuluDataColumnSidecar(
|
|
|
338
319
|
) {
|
|
339
320
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
340
321
|
code: DataColumnSidecarErrorCode.MISMATCHED_LENGTHS,
|
|
341
|
-
slot,
|
|
342
|
-
root: blockRootHex,
|
|
343
322
|
columnLength: dataColumnSidecar.column.length,
|
|
344
323
|
commitmentsLength: dataColumnSidecar.kzgCommitments.length,
|
|
345
324
|
proofsLength: dataColumnSidecar.kzgProofs.length,
|
|
@@ -351,17 +330,12 @@ function verifyFuluDataColumnSidecar(
|
|
|
351
330
|
* SPEC FUNCTION
|
|
352
331
|
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/p2p-interface.md#modified-verify_data_column_sidecar
|
|
353
332
|
*/
|
|
354
|
-
function verifyGloasDataColumnSidecar(
|
|
355
|
-
dataColumnSidecar: gloas.DataColumnSidecar,
|
|
356
|
-
kzgCommitments: Uint8Array[],
|
|
357
|
-
blockRootHex: RootHex
|
|
358
|
-
): void {
|
|
333
|
+
function verifyGloasDataColumnSidecar(dataColumnSidecar: gloas.DataColumnSidecar, kzgCommitments: Uint8Array[]): void {
|
|
359
334
|
const slot = getDataColumnSidecarSlot(dataColumnSidecar);
|
|
360
335
|
if (dataColumnSidecar.index >= NUMBER_OF_COLUMNS) {
|
|
361
336
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
362
337
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
363
338
|
slot,
|
|
364
|
-
root: blockRootHex,
|
|
365
339
|
columnIndex: dataColumnSidecar.index,
|
|
366
340
|
});
|
|
367
341
|
}
|
|
@@ -370,7 +344,6 @@ function verifyGloasDataColumnSidecar(
|
|
|
370
344
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
371
345
|
code: DataColumnSidecarErrorCode.NO_COMMITMENTS,
|
|
372
346
|
slot,
|
|
373
|
-
root: blockRootHex,
|
|
374
347
|
columnIndex: dataColumnSidecar.index,
|
|
375
348
|
});
|
|
376
349
|
}
|
|
@@ -381,8 +354,6 @@ function verifyGloasDataColumnSidecar(
|
|
|
381
354
|
) {
|
|
382
355
|
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
|
|
383
356
|
code: DataColumnSidecarErrorCode.MISMATCHED_LENGTHS,
|
|
384
|
-
slot,
|
|
385
|
-
root: blockRootHex,
|
|
386
357
|
columnLength: dataColumnSidecar.column.length,
|
|
387
358
|
commitmentsLength: kzgCommitments.length,
|
|
388
359
|
proofsLength: dataColumnSidecar.kzgProofs.length,
|
|
@@ -494,8 +465,8 @@ export async function validateFuluBlockDataColumnSidecars(
|
|
|
494
465
|
) {
|
|
495
466
|
throw new DataColumnSidecarValidationError({
|
|
496
467
|
code: DataColumnSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
468
|
+
blockRoot: rootHex,
|
|
497
469
|
slot: blockSlot,
|
|
498
|
-
root: rootHex,
|
|
499
470
|
index: dataColumnSidecars[0].index,
|
|
500
471
|
});
|
|
501
472
|
}
|
|
@@ -528,7 +499,6 @@ export async function validateFuluBlockDataColumnSidecars(
|
|
|
528
499
|
{
|
|
529
500
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
530
501
|
slot: blockSlot,
|
|
531
|
-
root: toRootHex(blockRoot),
|
|
532
502
|
columnIndex: columnSidecar.index,
|
|
533
503
|
},
|
|
534
504
|
"DataColumnSidecar has invalid index"
|
|
@@ -573,7 +543,6 @@ export async function validateFuluBlockDataColumnSidecars(
|
|
|
573
543
|
{
|
|
574
544
|
code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID,
|
|
575
545
|
slot: blockSlot,
|
|
576
|
-
root: toRootHex(blockRoot),
|
|
577
546
|
columnIndex: columnSidecar.index,
|
|
578
547
|
},
|
|
579
548
|
"DataColumnSidecar has invalid inclusion proof"
|
|
@@ -654,7 +623,6 @@ export async function validateGloasBlockDataColumnSidecars(
|
|
|
654
623
|
if (columnSidecar.slot !== blockSlot) {
|
|
655
624
|
throw new DataColumnSidecarValidationError({
|
|
656
625
|
code: DataColumnSidecarErrorCode.INCORRECT_SIDECAR_SLOT,
|
|
657
|
-
root: toRootHex(blockRoot),
|
|
658
626
|
columnIndex: columnSidecar.index,
|
|
659
627
|
expected: blockSlot,
|
|
660
628
|
actual: columnSidecar.slot,
|
|
@@ -676,7 +644,6 @@ export async function validateGloasBlockDataColumnSidecars(
|
|
|
676
644
|
{
|
|
677
645
|
code: DataColumnSidecarErrorCode.INVALID_INDEX,
|
|
678
646
|
slot: blockSlot,
|
|
679
|
-
root: toRootHex(blockRoot),
|
|
680
647
|
columnIndex: columnSidecar.index,
|
|
681
648
|
},
|
|
682
649
|
"DataColumnSidecar has invalid index"
|
|
@@ -82,8 +82,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
82
82
|
if (block.slot !== payload.slotNumber) {
|
|
83
83
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
84
84
|
code: ExecutionPayloadEnvelopeErrorCode.SLOT_MISMATCH,
|
|
85
|
-
slot: payload.slotNumber,
|
|
86
|
-
root: blockRootHex,
|
|
87
85
|
envelopeSlot: payload.slotNumber,
|
|
88
86
|
blockSlot: block.slot,
|
|
89
87
|
});
|
|
@@ -93,8 +91,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
93
91
|
if (envelope.builderIndex !== payloadInput.getBuilderIndex()) {
|
|
94
92
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
95
93
|
code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH,
|
|
96
|
-
slot: payload.slotNumber,
|
|
97
|
-
root: blockRootHex,
|
|
98
94
|
envelopeBuilderIndex: envelope.builderIndex,
|
|
99
95
|
bidBuilderIndex: payloadInput.getBuilderIndex(),
|
|
100
96
|
});
|
|
@@ -104,8 +100,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
104
100
|
if (toRootHex(payload.blockHash) !== payloadInput.getBlockHashHex()) {
|
|
105
101
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
106
102
|
code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH,
|
|
107
|
-
slot: payload.slotNumber,
|
|
108
|
-
root: blockRootHex,
|
|
109
103
|
envelopeBlockHash: toRootHex(payload.blockHash),
|
|
110
104
|
bidBlockHash: payloadInput.getBlockHashHex(),
|
|
111
105
|
});
|
|
@@ -116,8 +110,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
116
110
|
if (!byteArrayEquals(requestsRoot, payloadInput.getBid().executionRequestsRoot)) {
|
|
117
111
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
118
112
|
code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
|
|
119
|
-
slot: payload.slotNumber,
|
|
120
|
-
root: blockRootHex,
|
|
121
113
|
envelopeRequestsRoot: toRootHex(requestsRoot),
|
|
122
114
|
bidRequestsRoot: toRootHex(payloadInput.getBid().executionRequestsRoot),
|
|
123
115
|
});
|
|
@@ -149,8 +141,6 @@ async function validateExecutionPayloadEnvelope(
|
|
|
149
141
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
|
|
150
142
|
throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
|
|
151
143
|
code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE,
|
|
152
|
-
slot: payload.slotNumber,
|
|
153
|
-
root: blockRootHex,
|
|
154
144
|
});
|
|
155
145
|
}
|
|
156
146
|
}
|
package/src/db/beacon.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
2
|
import {Db, LevelDbControllerMetrics, encodeKey} from "@lodestar/db";
|
|
3
|
-
import {Slot} from "@lodestar/types";
|
|
4
|
-
import {Logger} from "@lodestar/utils";
|
|
5
3
|
import {Bucket} from "./buckets.js";
|
|
6
|
-
import {type IDataColumnStore, LegacyDataColumnStore} from "./dataColumnStore.js";
|
|
7
|
-
import {FlatFileStore} from "./flatFileStore/flatFileStore.js";
|
|
8
|
-
import type {FlatFileStoreMetrics} from "./flatFileStore/metrics.js";
|
|
9
4
|
import {IBeaconDb} from "./interface.js";
|
|
10
5
|
import {CheckpointStateRepository} from "./repositories/checkpointState.js";
|
|
11
6
|
import {
|
|
@@ -29,10 +24,9 @@ import {
|
|
|
29
24
|
VoluntaryExitRepository,
|
|
30
25
|
} from "./repositories/index.js";
|
|
31
26
|
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
metrics?: FlatFileStoreMetrics | null;
|
|
27
|
+
export type BeaconDbModules = {
|
|
28
|
+
config: ChainForkConfig;
|
|
29
|
+
db: Db;
|
|
36
30
|
};
|
|
37
31
|
|
|
38
32
|
export class BeaconDb implements IBeaconDb {
|
|
@@ -63,14 +57,9 @@ export class BeaconDb implements IBeaconDb {
|
|
|
63
57
|
|
|
64
58
|
backfilledRanges: BackfilledRanges;
|
|
65
59
|
|
|
66
|
-
readonly dataColumns: IDataColumnStore;
|
|
67
|
-
lastLegacyArchiveSlot: Slot | null = null;
|
|
68
|
-
private readonly flatFileStore: FlatFileStore;
|
|
69
|
-
|
|
70
60
|
constructor(
|
|
71
61
|
config: ChainForkConfig,
|
|
72
|
-
protected readonly db: Db
|
|
73
|
-
opts: BeaconDbOpts
|
|
62
|
+
protected readonly db: Db
|
|
74
63
|
) {
|
|
75
64
|
// Warning: If code is ever run in the constructor, must change this stub to not extend 'packages/beacon-node/test/utils/stub/beaconDb.ts' -
|
|
76
65
|
this.block = new BlockRepository(config, db);
|
|
@@ -98,30 +87,14 @@ export class BeaconDb implements IBeaconDb {
|
|
|
98
87
|
this.syncCommitteeWitness = new SyncCommitteeWitnessRepository(config, db);
|
|
99
88
|
|
|
100
89
|
this.backfilledRanges = new BackfilledRanges(config, db);
|
|
101
|
-
|
|
102
|
-
this.flatFileStore = new FlatFileStore(opts.dataColumnDir, config, opts.logger, opts.metrics);
|
|
103
|
-
this.dataColumns = new LegacyDataColumnStore(
|
|
104
|
-
this.flatFileStore,
|
|
105
|
-
this.dataColumnSidecar,
|
|
106
|
-
this.dataColumnSidecarArchive,
|
|
107
|
-
this.blockArchive
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async init(): Promise<void> {
|
|
112
|
-
await this.flatFileStore.init();
|
|
113
|
-
const [lastLegacyKey] = await this.dataColumnSidecarArchive.keys({reverse: true, limit: 1});
|
|
114
|
-
this.lastLegacyArchiveSlot = lastLegacyKey?.prefix ?? null;
|
|
115
90
|
}
|
|
116
91
|
|
|
117
|
-
|
|
118
|
-
await this.flatFileStore.close();
|
|
92
|
+
close(): Promise<void> {
|
|
119
93
|
return this.db.close();
|
|
120
94
|
}
|
|
121
95
|
|
|
122
|
-
setMetrics(metrics: LevelDbControllerMetrics
|
|
96
|
+
setMetrics(metrics: LevelDbControllerMetrics): void {
|
|
123
97
|
this.db.setMetrics(metrics);
|
|
124
|
-
this.flatFileStore.setMetrics(flatFileStoreMetrics);
|
|
125
98
|
}
|
|
126
99
|
|
|
127
100
|
async pruneHotDb(): Promise<void> {
|
package/src/db/index.ts
CHANGED
package/src/db/interface.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import {LevelDbControllerMetrics} from "@lodestar/db";
|
|
2
|
-
import {Slot} from "@lodestar/types";
|
|
3
|
-
import type {IDataColumnStore} from "./dataColumnStore.js";
|
|
4
|
-
import type {FlatFileStoreMetrics} from "./flatFileStore/metrics.js";
|
|
5
2
|
import {CheckpointStateRepository} from "./repositories/checkpointState.js";
|
|
6
3
|
import {
|
|
7
4
|
AttesterSlashingRepository,
|
|
@@ -62,11 +59,6 @@ export interface IBeaconDb {
|
|
|
62
59
|
|
|
63
60
|
backfilledRanges: BackfilledRanges;
|
|
64
61
|
|
|
65
|
-
dataColumns: IDataColumnStore;
|
|
66
|
-
/** Highest legacy column slot at startup; later archival writes the block-root index first. */
|
|
67
|
-
readonly lastLegacyArchiveSlot: Slot | null;
|
|
68
|
-
init(): Promise<void>;
|
|
69
|
-
|
|
70
62
|
pruneHotDb(): Promise<void>;
|
|
71
63
|
|
|
72
64
|
deleteDeprecatedEth1Data(): Promise<void>;
|
|
@@ -74,5 +66,5 @@ export interface IBeaconDb {
|
|
|
74
66
|
/** Close the connection to the db instance and close the db store. */
|
|
75
67
|
close(): Promise<void>;
|
|
76
68
|
/** To inject metrics after CLI initialization */
|
|
77
|
-
setMetrics(metrics: LevelDbControllerMetrics
|
|
69
|
+
setMetrics(metrics: LevelDbControllerMetrics): void;
|
|
78
70
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {Db,
|
|
2
|
+
import {Db, FilterOptions, KeyValue, Repository} from "@lodestar/db";
|
|
3
3
|
import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
|
|
4
|
-
import {bytesToInt
|
|
4
|
+
import {bytesToInt} from "@lodestar/utils";
|
|
5
5
|
import {getSignedBlockTypeFromBytes} from "../../util/multifork.js";
|
|
6
6
|
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
7
7
|
import {
|
|
8
8
|
deleteParentRootIndex,
|
|
9
9
|
deleteRootIndex,
|
|
10
10
|
getParentRootIndex,
|
|
11
|
-
getParentRootIndexKey,
|
|
12
11
|
getRootIndex,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
storeParentRootIndex,
|
|
13
|
+
storeRootIndex,
|
|
15
14
|
} from "./blockArchiveIndex.js";
|
|
16
15
|
|
|
17
16
|
export interface BlockFilterOptions extends FilterOptions<Slot> {
|
|
@@ -57,91 +56,37 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
|
|
|
57
56
|
// Overrides to index
|
|
58
57
|
|
|
59
58
|
async put(key: Slot, value: SignedBeaconBlock): Promise<void> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
key,
|
|
68
|
-
value,
|
|
69
|
-
slot: block.message.slot,
|
|
70
|
-
blockRoot: this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message),
|
|
71
|
-
parentRoot: block.message.parentRoot,
|
|
72
|
-
},
|
|
59
|
+
const blockRoot = this.config.getForkTypes(value.message.slot).BeaconBlock.hashTreeRoot(value.message);
|
|
60
|
+
const slot = value.message.slot;
|
|
61
|
+
await Promise.all([
|
|
62
|
+
super.put(key, value),
|
|
63
|
+
storeRootIndex(this.db, slot, blockRoot),
|
|
64
|
+
storeParentRootIndex(this.db, slot, value.message.parentRoot),
|
|
73
65
|
]);
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
async batchPut(items: KeyValue<Slot, SignedBeaconBlock>[]): Promise<void> {
|
|
77
|
-
await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
slot
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
await Promise.all([
|
|
70
|
+
super.batchPut(items),
|
|
71
|
+
Array.from(items).map((item) => {
|
|
72
|
+
const slot = item.value.message.slot;
|
|
73
|
+
const blockRoot = this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(item.value.message);
|
|
74
|
+
return storeRootIndex(this.db, slot, blockRoot);
|
|
75
|
+
}),
|
|
76
|
+
Array.from(items).map((item) => {
|
|
77
|
+
const slot = item.value.message.slot;
|
|
78
|
+
const parentRoot = item.value.message.parentRoot;
|
|
79
|
+
return storeParentRootIndex(this.db, slot, parentRoot);
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
async batchPutBinary(items: BlockArchiveBatchPutBinaryItem[]): Promise<void> {
|
|
89
|
-
await
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
async delete(slot: Slot): Promise<void> {
|
|
96
|
-
await this.batchDelete([slot]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async batchDelete(slots: Slot[]): Promise<void> {
|
|
100
|
-
await this.db.batchDelete(
|
|
101
|
-
slots.flatMap((slot) => [this.encodeKey(slot), getSlotIndexKey(slot)]),
|
|
102
|
-
this.dbReqOpts
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async batch(operations: DbBatch<Slot, SignedBeaconBlock>): Promise<void> {
|
|
107
|
-
await this.batchBinary(
|
|
108
|
-
operations.map((operation) =>
|
|
109
|
-
operation.type === "put" ? {...operation, value: this.encodeValue(operation.value)} : operation
|
|
110
|
-
)
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async batchBinary(operations: DbBatch<Slot, Uint8Array>): Promise<void> {
|
|
115
|
-
const batch: DbBatch<Uint8Array, Uint8Array> = [];
|
|
116
|
-
for (const operation of operations) {
|
|
117
|
-
if (operation.type === "del") {
|
|
118
|
-
batch.push(
|
|
119
|
-
{type: "del", key: this.encodeKey(operation.key)},
|
|
120
|
-
{type: "del", key: getSlotIndexKey(operation.key)}
|
|
121
|
-
);
|
|
122
|
-
} else {
|
|
123
|
-
const block = this.decodeValue(operation.value);
|
|
124
|
-
const entries = this.indexedBlockEntries({
|
|
125
|
-
key: operation.key,
|
|
126
|
-
value: operation.value,
|
|
127
|
-
slot: block.message.slot,
|
|
128
|
-
blockRoot: this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message),
|
|
129
|
-
parentRoot: block.message.parentRoot,
|
|
130
|
-
});
|
|
131
|
-
batch.push(...entries.map((entry) => ({type: "put" as const, ...entry})));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
await this.db.batch(batch, this.dbReqOpts);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private indexedBlockEntries(item: BlockArchiveBatchPutBinaryItem): KeyValue<Uint8Array, Uint8Array>[] {
|
|
138
|
-
const slotBytes = intToBytes(item.slot, 8, "be");
|
|
139
|
-
return [
|
|
140
|
-
{key: this.encodeKey(item.key), value: item.value},
|
|
141
|
-
{key: getRootIndexKey(item.blockRoot), value: slotBytes},
|
|
142
|
-
{key: getParentRootIndexKey(item.parentRoot), value: slotBytes},
|
|
143
|
-
{key: getSlotIndexKey(item.key), value: item.blockRoot},
|
|
144
|
-
];
|
|
85
|
+
await Promise.all([
|
|
86
|
+
super.batchPutBinary(items),
|
|
87
|
+
Array.from(items).map((item) => storeRootIndex(this.db, item.slot, item.blockRoot)),
|
|
88
|
+
Array.from(items).map((item) => storeParentRootIndex(this.db, item.slot, item.parentRoot)),
|
|
89
|
+
]);
|
|
145
90
|
}
|
|
146
91
|
|
|
147
92
|
async remove(value: SignedBeaconBlock): Promise<void> {
|
|
@@ -155,10 +100,10 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
|
|
|
155
100
|
async batchRemove(values: SignedBeaconBlock[]): Promise<void> {
|
|
156
101
|
await Promise.all([
|
|
157
102
|
super.batchRemove(values),
|
|
158
|
-
|
|
103
|
+
Array.from(values).map((value) =>
|
|
159
104
|
deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value)
|
|
160
105
|
),
|
|
161
|
-
|
|
106
|
+
Array.from(values).map((value) => deleteParentRootIndex(this.db, value)),
|
|
162
107
|
]);
|
|
163
108
|
}
|
|
164
109
|
|
|
@@ -195,10 +140,6 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
|
|
|
195
140
|
return slot !== null ? this.get(slot) : null;
|
|
196
141
|
}
|
|
197
142
|
|
|
198
|
-
async getRootBySlot(slot: Slot): Promise<Root | null> {
|
|
199
|
-
return this.db.get(getSlotIndexKey(slot), {bucketId: getBucketNameByValue(Bucket.index_mainChain)});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
143
|
async getSlotByRoot(root: Root): Promise<Slot | null> {
|
|
203
144
|
return this.parseSlot(await getRootIndex(this.db, root));
|
|
204
145
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Db, encodeKey} from "@lodestar/db";
|
|
2
2
|
import {ForkAll} from "@lodestar/params";
|
|
3
3
|
import {Root, SSZTypesFor, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
|
|
4
|
+
import {intToBytes} from "@lodestar/utils";
|
|
4
5
|
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
5
6
|
|
|
6
7
|
export const rootIndexBucketId = getBucketNameByValue(Bucket.index_blockArchiveRootIndex);
|
|
@@ -14,6 +15,14 @@ export async function getParentRootIndex(db: Db, parentRoot: Root): Promise<Uint
|
|
|
14
15
|
return db.get(getParentRootIndexKey(parentRoot), {bucketId: parentRootIndexBucketId});
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
export async function storeRootIndex(db: Db, slot: Slot, blockRoot: Root): Promise<void> {
|
|
19
|
+
return db.put(getRootIndexKey(blockRoot), intToBytes(slot, 8, "be"), {bucketId: rootIndexBucketId});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function storeParentRootIndex(db: Db, slot: Slot, parentRoot: Root): Promise<void> {
|
|
23
|
+
return db.put(getParentRootIndexKey(parentRoot), intToBytes(slot, 8, "be"), {bucketId: parentRootIndexBucketId});
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
export async function deleteRootIndex(
|
|
18
27
|
db: Db,
|
|
19
28
|
signedBeaconBlockType: SSZTypesFor<ForkAll, "SignedBeaconBlock">,
|
|
@@ -34,7 +43,3 @@ export function getParentRootIndexKey(parentRoot: Root): Uint8Array {
|
|
|
34
43
|
export function getRootIndexKey(root: Root): Uint8Array {
|
|
35
44
|
return encodeKey(Bucket.index_blockArchiveRootIndex, root);
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
export function getSlotIndexKey(slot: Slot): Uint8Array {
|
|
39
|
-
return encodeKey(Bucket.index_mainChain, slot);
|
|
40
|
-
}
|
|
@@ -21,7 +21,6 @@ import {ReprocessStatus} from "../../chain/reprocess.js";
|
|
|
21
21
|
import {RejectReason} from "../../chain/seenCache/seenAttestationData.js";
|
|
22
22
|
import {CacheItemType} from "../../chain/stateCache/types.js";
|
|
23
23
|
import {OpSource} from "../../chain/validatorMonitor.js";
|
|
24
|
-
import type {FlatFileStoreOperation} from "../../db/flatFileStore/metrics.js";
|
|
25
24
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
26
25
|
import {GossipType} from "../../network/index.js";
|
|
27
26
|
import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
|
|
@@ -2100,7 +2099,7 @@ export function createLodestarMetrics(
|
|
|
2100
2099
|
}),
|
|
2101
2100
|
dbSizeTotal: register.gauge({
|
|
2102
2101
|
name: "lodestar_db_size_bytes_total",
|
|
2103
|
-
help: "Approximate number of bytes of file system space used by
|
|
2102
|
+
help: "Approximate number of bytes of file system space used by db",
|
|
2104
2103
|
}),
|
|
2105
2104
|
dbApproximateSizeTime: register.histogram({
|
|
2106
2105
|
name: "lodestar_db_approximate_size_time_seconds",
|
|
@@ -2109,61 +2108,6 @@ export function createLodestarMetrics(
|
|
|
2109
2108
|
}),
|
|
2110
2109
|
},
|
|
2111
2110
|
|
|
2112
|
-
flatFileStore: {
|
|
2113
|
-
operationDuration: {
|
|
2114
|
-
read: register.histogram({
|
|
2115
|
-
name: "lodestar_flat_file_store_read_duration_seconds",
|
|
2116
|
-
help: "Duration of flat file store reads in seconds",
|
|
2117
|
-
buckets: [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05],
|
|
2118
|
-
}),
|
|
2119
|
-
write: register.histogram({
|
|
2120
|
-
name: "lodestar_flat_file_store_write_duration_seconds",
|
|
2121
|
-
help: "Duration of flat file store writes in seconds",
|
|
2122
|
-
buckets: [0.005, 0.01, 0.05, 0.1, 0.5, 1],
|
|
2123
|
-
}),
|
|
2124
|
-
delete: register.histogram({
|
|
2125
|
-
name: "lodestar_flat_file_store_delete_duration_seconds",
|
|
2126
|
-
help: "Duration of flat file store deletions in seconds",
|
|
2127
|
-
buckets: [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05],
|
|
2128
|
-
}),
|
|
2129
|
-
prune: register.histogram({
|
|
2130
|
-
name: "lodestar_flat_file_store_prune_duration_seconds",
|
|
2131
|
-
help: "Duration of flat file store pruning in seconds",
|
|
2132
|
-
buckets: [0.0005, 0.01, 0.05, 0.5, 5, 30],
|
|
2133
|
-
}),
|
|
2134
|
-
},
|
|
2135
|
-
operationErrors: register.counter<{operation: FlatFileStoreOperation}>({
|
|
2136
|
-
name: "lodestar_flat_file_store_operation_errors_total",
|
|
2137
|
-
help: "Total count of failed flat file store operations",
|
|
2138
|
-
labelNames: ["operation"],
|
|
2139
|
-
}),
|
|
2140
|
-
readBytes: register.counter({
|
|
2141
|
-
name: "lodestar_flat_file_store_read_bytes_total",
|
|
2142
|
-
help: "Total bytes read from flat file storage",
|
|
2143
|
-
}),
|
|
2144
|
-
writeBytes: register.counter({
|
|
2145
|
-
name: "lodestar_flat_file_store_write_bytes_total",
|
|
2146
|
-
help: "Total bytes written to flat file storage",
|
|
2147
|
-
}),
|
|
2148
|
-
prunedDirectories: register.counter({
|
|
2149
|
-
name: "lodestar_flat_file_store_pruned_directories_total",
|
|
2150
|
-
help: "Total count of slot directories pruned from flat file storage",
|
|
2151
|
-
}),
|
|
2152
|
-
slotIndexSize: register.gauge({
|
|
2153
|
-
name: "lodestar_flat_file_store_indexed_slots",
|
|
2154
|
-
help: "Count of indexed flat file slot directories, including empty directories awaiting pruning",
|
|
2155
|
-
}),
|
|
2156
|
-
startupDuration: register.histogram({
|
|
2157
|
-
name: "lodestar_flat_file_store_startup_duration_seconds",
|
|
2158
|
-
help: "Duration of flat file store slot index reconstruction in seconds",
|
|
2159
|
-
buckets: [0.1, 0.5, 1, 5, 10, 30, 60, 300],
|
|
2160
|
-
}),
|
|
2161
|
-
startupErrors: register.counter({
|
|
2162
|
-
name: "lodestar_flat_file_store_startup_errors_total",
|
|
2163
|
-
help: "Total count of flat file store startup failures",
|
|
2164
|
-
}),
|
|
2165
|
-
},
|
|
2166
|
-
|
|
2167
2111
|
pruneHistory: {
|
|
2168
2112
|
pruneCount: register.gauge({
|
|
2169
2113
|
name: "lodestar_prune_history_prune_count_total",
|
|
@@ -107,7 +107,7 @@ function createBeaconNodeStats(): ClientStats {
|
|
|
107
107
|
metricName: "lodestar_db_size_bytes_total",
|
|
108
108
|
jsonType: JsonType.Number,
|
|
109
109
|
defaultValue: 0,
|
|
110
|
-
description: "Amount of bytes consumed on disk by the beacon node's
|
|
110
|
+
description: "Amount of bytes consumed on disk by the beacon node's database",
|
|
111
111
|
}),
|
|
112
112
|
networkLibp2pBytesTotalReceive: new MetricProperty({
|
|
113
113
|
jsonKey: "network_libp2p_bytes_total_receive",
|