@lodestar/beacon-node 1.48.0-dev.fd70e5fc15 → 1.48.0-dev.ff9749be2c
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 +1 -0
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +1 -0
- 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 +1 -0
- 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 +12 -1
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.d.ts +2 -0
- 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 +4 -1
- 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 +31 -34
- 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 +3 -2
- 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 +9 -16
- package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
- package/lib/chain/chain.d.ts +4 -3
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +60 -35
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +14 -7
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +0 -2
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +15 -2
- 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 +10 -0
- 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.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +16 -14
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +4 -2
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +11 -8
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +24 -11
- 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 +38 -13
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +10 -0
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/db/beacon.d.ts +14 -5
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +17 -3
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/dataColumnStore.d.ts +39 -0
- package/lib/db/dataColumnStore.d.ts.map +1 -0
- package/lib/db/dataColumnStore.js +81 -0
- package/lib/db/dataColumnStore.js.map +1 -0
- package/lib/db/flatFileStore/atomicWrite.d.ts +8 -0
- package/lib/db/flatFileStore/atomicWrite.d.ts.map +1 -0
- package/lib/db/flatFileStore/atomicWrite.js +61 -0
- package/lib/db/flatFileStore/atomicWrite.js.map +1 -0
- package/lib/db/flatFileStore/dcolFormat.d.ts +90 -0
- package/lib/db/flatFileStore/dcolFormat.d.ts.map +1 -0
- package/lib/db/flatFileStore/dcolFormat.js +286 -0
- package/lib/db/flatFileStore/dcolFormat.js.map +1 -0
- package/lib/db/flatFileStore/errors.d.ts +82 -0
- package/lib/db/flatFileStore/errors.d.ts.map +1 -0
- package/lib/db/flatFileStore/errors.js +32 -0
- package/lib/db/flatFileStore/errors.js.map +1 -0
- package/lib/db/flatFileStore/flatFileStore.d.ts +41 -0
- package/lib/db/flatFileStore/flatFileStore.d.ts.map +1 -0
- package/lib/db/flatFileStore/flatFileStore.js +251 -0
- package/lib/db/flatFileStore/flatFileStore.js.map +1 -0
- package/lib/db/flatFileStore/index.d.ts +4 -0
- package/lib/db/flatFileStore/index.d.ts.map +1 -0
- package/lib/db/flatFileStore/index.js +2 -0
- package/lib/db/flatFileStore/index.js.map +1 -0
- package/lib/db/flatFileStore/interface.d.ts +25 -0
- package/lib/db/flatFileStore/interface.d.ts.map +1 -0
- package/lib/db/flatFileStore/interface.js +2 -0
- package/lib/db/flatFileStore/interface.js.map +1 -0
- package/lib/db/flatFileStore/metrics.d.ts +24 -0
- package/lib/db/flatFileStore/metrics.d.ts.map +1 -0
- package/lib/db/flatFileStore/metrics.js +25 -0
- package/lib/db/flatFileStore/metrics.js.map +1 -0
- package/lib/db/flatFileStore/path.d.ts +9 -0
- package/lib/db/flatFileStore/path.d.ts.map +1 -0
- package/lib/db/flatFileStore/path.js +21 -0
- package/lib/db/flatFileStore/path.js.map +1 -0
- package/lib/db/flatFileStore/slotIndex.d.ts +14 -0
- package/lib/db/flatFileStore/slotIndex.d.ts.map +1 -0
- package/lib/db/flatFileStore/slotIndex.js +46 -0
- package/lib/db/flatFileStore/slotIndex.js.map +1 -0
- package/lib/db/flatFileStore/snappy.d.ts +3 -0
- package/lib/db/flatFileStore/snappy.d.ts.map +1 -0
- package/lib/db/flatFileStore/snappy.js +12 -0
- package/lib/db/flatFileStore/snappy.js.map +1 -0
- package/lib/db/index.d.ts +1 -0
- package/lib/db/index.d.ts.map +1 -1
- package/lib/db/interface.d.ts +8 -1
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.d.ts +8 -1
- package/lib/db/repositories/blockArchive.d.ts.map +1 -1
- package/lib/db/repositories/blockArchive.js +65 -28
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +1 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.js +3 -7
- package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +18 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +55 -1
- 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 +0 -7
- package/lib/network/gossip/encoding.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +2 -1
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +4 -20
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/libp2p/index.d.ts +9 -1
- package/lib/network/libp2p/index.d.ts.map +1 -1
- package/lib/network/libp2p/index.js +23 -0
- package/lib/network/libp2p/index.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +6 -7
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +49 -3
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +232 -98
- 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 +112 -91
- 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 +2 -0
- 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 +6 -22
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts +2 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js +14 -9
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
- package/lib/node/nodejs.d.ts +2 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +4 -2
- package/lib/node/nodejs.js.map +1 -1
- package/lib/util/sszBytes.d.ts +6 -0
- 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 +18 -19
- package/src/api/impl/beacon/blocks/index.ts +8 -4
- package/src/chain/archiveStore/archiveStore.ts +6 -1
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +1 -0
- package/src/chain/archiveStore/historicalState/metrics.ts +14 -1
- package/src/chain/archiveStore/historicalState/types.ts +2 -0
- package/src/chain/archiveStore/historicalState/worker.ts +4 -1
- package/src/chain/archiveStore/utils/archiveBlocks.ts +34 -39
- package/src/chain/blocks/index.ts +13 -2
- package/src/chain/blocks/writeBlockInputToDb.ts +10 -17
- package/src/chain/chain.ts +75 -34
- package/src/chain/errors/blockError.ts +19 -10
- package/src/chain/errors/dataColumnSidecarError.ts +24 -8
- package/src/chain/errors/executionPayloadEnvelope.ts +14 -2
- package/src/chain/interface.ts +2 -2
- package/src/chain/prepareNextSlot.ts +21 -17
- package/src/chain/produceBlock/produceBlockBody.ts +12 -8
- package/src/chain/validation/block.ts +24 -12
- package/src/chain/validation/dataColumnSidecar.ts +47 -14
- package/src/chain/validation/executionPayloadEnvelope.ts +10 -0
- package/src/db/beacon.ts +33 -6
- package/src/db/dataColumnStore.ts +113 -0
- package/src/db/flatFileStore/atomicWrite.ts +65 -0
- package/src/db/flatFileStore/dcolFormat.ts +389 -0
- package/src/db/flatFileStore/errors.ts +53 -0
- package/src/db/flatFileStore/flatFileStore.ts +310 -0
- package/src/db/flatFileStore/index.ts +3 -0
- package/src/db/flatFileStore/interface.ts +21 -0
- package/src/db/flatFileStore/metrics.ts +48 -0
- package/src/db/flatFileStore/path.ts +32 -0
- package/src/db/flatFileStore/slotIndex.ts +56 -0
- package/src/db/flatFileStore/snappy.ts +14 -0
- package/src/db/index.ts +1 -0
- package/src/db/interface.ts +9 -1
- package/src/db/repositories/blockArchive.ts +89 -30
- package/src/db/repositories/blockArchiveIndex.ts +4 -9
- package/src/metrics/metrics/lodestar.ts +57 -1
- package/src/monitoring/clientStats.ts +1 -1
- package/src/network/gossip/encoding.ts +0 -7
- package/src/network/gossip/topic.ts +3 -25
- package/src/network/libp2p/index.ts +28 -1
- package/src/network/processor/gossipHandlers.ts +11 -11
- package/src/network/processor/index.ts +263 -148
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +139 -105
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +2 -0
- package/src/network/reqresp/protocols.ts +7 -24
- package/src/network/reqresp/utils/dataColumnResponseValidation.ts +15 -7
- package/src/node/nodejs.ts +6 -1
- package/src/util/sszBytes.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
6
5
|
|
|
7
6
|
export const rootIndexBucketId = getBucketNameByValue(Bucket.index_blockArchiveRootIndex);
|
|
@@ -15,14 +14,6 @@ export async function getParentRootIndex(db: Db, parentRoot: Root): Promise<Uint
|
|
|
15
14
|
return db.get(getParentRootIndexKey(parentRoot), {bucketId: parentRootIndexBucketId});
|
|
16
15
|
}
|
|
17
16
|
|
|
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
|
-
|
|
26
17
|
export async function deleteRootIndex(
|
|
27
18
|
db: Db,
|
|
28
19
|
signedBeaconBlockType: SSZTypesFor<ForkAll, "SignedBeaconBlock">,
|
|
@@ -43,3 +34,7 @@ export function getParentRootIndexKey(parentRoot: Root): Uint8Array {
|
|
|
43
34
|
export function getRootIndexKey(root: Root): Uint8Array {
|
|
44
35
|
return encodeKey(Bucket.index_blockArchiveRootIndex, root);
|
|
45
36
|
}
|
|
37
|
+
|
|
38
|
+
export function getSlotIndexKey(slot: Slot): Uint8Array {
|
|
39
|
+
return encodeKey(Bucket.index_mainChain, slot);
|
|
40
|
+
}
|
|
@@ -21,6 +21,7 @@ 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";
|
|
24
25
|
import {ExecutionPayloadStatus} from "../../execution/index.js";
|
|
25
26
|
import {GossipType} from "../../network/index.js";
|
|
26
27
|
import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
|
|
@@ -2099,7 +2100,7 @@ export function createLodestarMetrics(
|
|
|
2099
2100
|
}),
|
|
2100
2101
|
dbSizeTotal: register.gauge({
|
|
2101
2102
|
name: "lodestar_db_size_bytes_total",
|
|
2102
|
-
help: "Approximate number of bytes of file system space used by
|
|
2103
|
+
help: "Approximate number of bytes of file system space used by LevelDB",
|
|
2103
2104
|
}),
|
|
2104
2105
|
dbApproximateSizeTime: register.histogram({
|
|
2105
2106
|
name: "lodestar_db_approximate_size_time_seconds",
|
|
@@ -2108,6 +2109,61 @@ export function createLodestarMetrics(
|
|
|
2108
2109
|
}),
|
|
2109
2110
|
},
|
|
2110
2111
|
|
|
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
|
+
|
|
2111
2167
|
pruneHistory: {
|
|
2112
2168
|
pruneCount: register.gauge({
|
|
2113
2169
|
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 database",
|
|
110
|
+
description: "Amount of bytes consumed on disk by the beacon node's LevelDB database",
|
|
111
111
|
}),
|
|
112
112
|
networkLibp2pBytesTotalReceive: new MetricProperty({
|
|
113
113
|
jsonKey: "network_libp2p_bytes_total_receive",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type {Message} from "@libp2p/gossipsub";
|
|
2
2
|
import type {RPC} from "@libp2p/gossipsub/message";
|
|
3
3
|
import type {DataTransform} from "@libp2p/gossipsub/types";
|
|
4
|
-
// snappyjs is better for compression for smaller payloads
|
|
5
4
|
import xxhashFactory from "xxhash-wasm";
|
|
6
5
|
import {digest} from "@chainsafe/as-sha256";
|
|
7
6
|
import snappyWasm from "@chainsafe/snappy-wasm";
|
|
@@ -123,9 +122,6 @@ export class DataTransformSnappy implements DataTransform {
|
|
|
123
122
|
if (uncompressedDataLength > maxSize) {
|
|
124
123
|
throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${maxSize}`);
|
|
125
124
|
}
|
|
126
|
-
if (uncompressedDataLength > sszType.maxSize) {
|
|
127
|
-
throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${sszType.maxSize}`);
|
|
128
|
-
}
|
|
129
125
|
|
|
130
126
|
// Only after sanity length checks, we can decompress the data
|
|
131
127
|
// Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
|
|
@@ -146,9 +142,6 @@ export class DataTransformSnappy implements DataTransform {
|
|
|
146
142
|
if (data.length > maxSize) {
|
|
147
143
|
throw Error(`ssz_snappy encoded data length ${data.length} > ${maxSize}`);
|
|
148
144
|
}
|
|
149
|
-
if (data.length > sszType.maxSize) {
|
|
150
|
-
throw Error(`ssz_snappy encoded data length ${data.length} > ${sszType.maxSize}`);
|
|
151
|
-
}
|
|
152
145
|
|
|
153
146
|
// Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
|
|
154
147
|
const compressedData = Buffer.alloc(snappyWasm.max_compress_len(data.length));
|
|
@@ -4,17 +4,11 @@ import {
|
|
|
4
4
|
ATTESTATION_SUBNET_COUNT,
|
|
5
5
|
ForkName,
|
|
6
6
|
ForkSeq,
|
|
7
|
-
MAX_ATTESTER_SLASHING_SIZE,
|
|
8
|
-
MAX_DATA_COLUMN_SIDECAR_SIZE,
|
|
9
|
-
MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
|
|
10
|
-
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
|
|
11
|
-
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE,
|
|
12
7
|
SYNC_COMMITTEE_SUBNET_COUNT,
|
|
13
8
|
isForkPostAltair,
|
|
14
9
|
isForkPostElectra,
|
|
15
10
|
isForkPostFulu,
|
|
16
11
|
isForkPostGloas,
|
|
17
|
-
isForkPostHeze,
|
|
18
12
|
} from "@lodestar/params";
|
|
19
13
|
import {Attestation, SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
|
|
20
14
|
import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
|
|
@@ -139,27 +133,11 @@ export function getGossipSSZType(topic: GossipTopic) {
|
|
|
139
133
|
}
|
|
140
134
|
|
|
141
135
|
/**
|
|
142
|
-
* Return the maximum uncompressed SSZ byte length accepted for a gossip object
|
|
136
|
+
* Return the maximum uncompressed SSZ byte length accepted for a gossip object, the SSZ type max size
|
|
137
|
+
* or MAX_PAYLOAD_SIZE, whichever is smaller.
|
|
143
138
|
*/
|
|
144
139
|
export function getGossipSSZMaxSize(topic: GossipTopic, maxPayloadSize: number, sszType?: CompositeTypeAny): number {
|
|
145
|
-
|
|
146
|
-
// Gloas progressive containers have broad theoretical SSZ max sizes; use the preset p2p bounds instead.
|
|
147
|
-
switch (topic.type) {
|
|
148
|
-
case GossipType.beacon_block:
|
|
149
|
-
return maxPayloadSize;
|
|
150
|
-
case GossipType.beacon_aggregate_and_proof:
|
|
151
|
-
return isForkPostGloas(fork) ? MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
|
|
152
|
-
case GossipType.attester_slashing:
|
|
153
|
-
return isForkPostGloas(fork) ? MAX_ATTESTER_SLASHING_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
|
|
154
|
-
case GossipType.data_column_sidecar:
|
|
155
|
-
return isForkPostGloas(fork) ? MAX_DATA_COLUMN_SIDECAR_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
|
|
156
|
-
case GossipType.execution_payload:
|
|
157
|
-
return maxPayloadSize;
|
|
158
|
-
case GossipType.execution_payload_bid:
|
|
159
|
-
return isForkPostHeze(fork) ? MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE : MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE;
|
|
160
|
-
default:
|
|
161
|
-
return (sszType ?? getGossipSSZType(topic)).maxSize;
|
|
162
|
-
}
|
|
140
|
+
return Math.min((sszType ?? getGossipSSZType(topic)).maxSize, maxPayloadSize);
|
|
163
141
|
}
|
|
164
142
|
|
|
165
143
|
/**
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {getCiphers} from "node:crypto";
|
|
2
2
|
import {bootstrap} from "@libp2p/bootstrap";
|
|
3
3
|
import {identify} from "@libp2p/identify";
|
|
4
|
-
import type {PrivateKey} from "@libp2p/interface";
|
|
4
|
+
import type {Address, PrivateKey} from "@libp2p/interface";
|
|
5
5
|
import {mdns} from "@libp2p/mdns";
|
|
6
6
|
import {mplex} from "@libp2p/mplex";
|
|
7
7
|
import {prometheusMetrics} from "@libp2p/prometheus-metrics";
|
|
8
8
|
import {tcp} from "@libp2p/tcp";
|
|
9
|
+
import {loopbackAddressLast, publicAddressesFirst, reliableTransportsFirst} from "@libp2p/utils";
|
|
10
|
+
import type {Multiaddr} from "@multiformats/multiaddr";
|
|
9
11
|
import {Libp2pInit, createLibp2p} from "libp2p";
|
|
10
12
|
import {Registry} from "prom-client";
|
|
11
13
|
import {ENR} from "@chainsafe/enr";
|
|
@@ -24,6 +26,29 @@ const noiseCrypto = getCiphers().includes("chacha20-poly1305")
|
|
|
24
26
|
chaCha20Poly1305Decrypt: asCrypto.chaCha20Poly1305Decrypt,
|
|
25
27
|
};
|
|
26
28
|
|
|
29
|
+
function quicAddressesFirst(a: Multiaddr, b: Multiaddr): -1 | 0 | 1 {
|
|
30
|
+
const aQuic = a.getComponents().some((c) => c.name === "quic-v1");
|
|
31
|
+
const bQuic = b.getComponents().some((c) => c.name === "quic-v1");
|
|
32
|
+
if (aQuic === bQuic) return 0;
|
|
33
|
+
return aQuic ? -1 : 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Custom sorter for libp2p's `addressSorter`.
|
|
38
|
+
*
|
|
39
|
+
* Prefers QUIC > TCP addresses before dialing, per p2p spec.
|
|
40
|
+
*
|
|
41
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/f21dac06e99743b1e98bb80297897b96520c942b/specs/phase0/p2p-interface.md#transport
|
|
42
|
+
*/
|
|
43
|
+
export function quicFirstAddressSorter(a: Address, b: Address): -1 | 0 | 1 {
|
|
44
|
+
return (
|
|
45
|
+
loopbackAddressLast(a.multiaddr, b.multiaddr) ||
|
|
46
|
+
publicAddressesFirst(a.multiaddr, b.multiaddr) ||
|
|
47
|
+
quicAddressesFirst(a.multiaddr, b.multiaddr) ||
|
|
48
|
+
reliableTransportsFirst(a.multiaddr, b.multiaddr)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
27
52
|
export type NodeJsLibp2pOpts = {
|
|
28
53
|
peerStoreDir?: string;
|
|
29
54
|
disablePeerDiscovery?: boolean;
|
|
@@ -150,6 +175,8 @@ export async function createNodeJsLibp2p(
|
|
|
150
175
|
// the maximum number of pending connections libp2p will accept before it starts rejecting incoming connections.
|
|
151
176
|
// make it the same to backlog option above
|
|
152
177
|
maxIncomingPendingConnections: 5,
|
|
178
|
+
// Prefer dialing QUIC > TCP for a peer address if QUIC is enabled
|
|
179
|
+
addressSorter: quicEnabled ? quicFirstAddressSorter : undefined,
|
|
153
180
|
},
|
|
154
181
|
// rely on lodestar's peer manager to ping peers
|
|
155
182
|
connectionMonitor: {
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ssz,
|
|
28
28
|
sszTypesFor,
|
|
29
29
|
} from "@lodestar/types";
|
|
30
|
-
import {LogLevel, Logger,
|
|
30
|
+
import {LogLevel, Logger, toHex, toRootHex} from "@lodestar/utils";
|
|
31
31
|
import {
|
|
32
32
|
BlockInput,
|
|
33
33
|
BlockInputColumns,
|
|
@@ -157,7 +157,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
157
157
|
const slot = signedBlock.message.slot;
|
|
158
158
|
const forkTypes = config.getForkTypes(slot);
|
|
159
159
|
const blockRootHex = toRootHex(forkTypes.BeaconBlock.hashTreeRoot(signedBlock.message));
|
|
160
|
-
const blockShortHex = prettyBytes(blockRootHex);
|
|
161
160
|
const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
|
|
162
161
|
const recvToValLatency = Date.now() / 1000 - seenTimestampSec;
|
|
163
162
|
|
|
@@ -167,6 +166,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
167
166
|
|
|
168
167
|
const logCtx = {
|
|
169
168
|
slot,
|
|
169
|
+
root: blockRootHex,
|
|
170
170
|
currentSlot: chain.clock.currentSlot,
|
|
171
171
|
peerId: peerIdStr,
|
|
172
172
|
delaySec,
|
|
@@ -227,7 +227,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
227
227
|
return blockInput;
|
|
228
228
|
} catch (e) {
|
|
229
229
|
if (e instanceof BlockGossipError) {
|
|
230
|
-
logger.debug("Gossip block has error", {slot, root:
|
|
230
|
+
logger.debug("Gossip block has error", {slot, root: blockRootHex, code: e.type.code});
|
|
231
231
|
if (
|
|
232
232
|
(e.type.code === BlockErrorCode.PARENT_BLOCK_UNKNOWN ||
|
|
233
233
|
e.type.code === BlockErrorCode.PARENT_PAYLOAD_UNKNOWN) &&
|
|
@@ -249,7 +249,12 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
249
249
|
throw e;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
chain.persistInvalidSszValue(
|
|
252
|
+
chain.persistInvalidSszValue(
|
|
253
|
+
forkTypes.SignedBeaconBlock,
|
|
254
|
+
signedBlock,
|
|
255
|
+
`gossip_reject_slot_${slot}`,
|
|
256
|
+
blockRootHex
|
|
257
|
+
);
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
// REJECT or unexpected (non-BlockGossipError) error: drop the optimistically-added entries from
|
|
@@ -279,7 +284,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
279
284
|
const slot = blobBlockHeader.slot;
|
|
280
285
|
const fork = config.getForkName(slot);
|
|
281
286
|
const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobBlockHeader));
|
|
282
|
-
const blockShortHex = prettyBytes(blockRootHex);
|
|
283
287
|
|
|
284
288
|
const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
|
|
285
289
|
const recvToValLatency = Date.now() / 1000 - seenTimestampSec;
|
|
@@ -332,7 +336,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
332
336
|
if (e instanceof BlobSidecarGossipError) {
|
|
333
337
|
// Don't trigger this yet if full block and blobs haven't arrived yet
|
|
334
338
|
if (e.type.code === BlobSidecarErrorCode.PARENT_UNKNOWN) {
|
|
335
|
-
logger.debug("Gossip blob has error", {slot, root:
|
|
339
|
+
logger.debug("Gossip blob has error", {slot, root: blockRootHex, code: e.type.code});
|
|
336
340
|
// no need to trigger `unknownBlockParent` event here, as we already did it in `validateBeaconBlock()`
|
|
337
341
|
//
|
|
338
342
|
// TODO(fulu): is this note above correct? Could have random blob that we see that could trigger
|
|
@@ -696,11 +700,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
696
700
|
logLevel = LogLevel.error;
|
|
697
701
|
}
|
|
698
702
|
metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"});
|
|
699
|
-
logger[logLevel](
|
|
700
|
-
"Error processing block",
|
|
701
|
-
{slot, peer: peerIdStr, blockRoot: prettyBytes(blockInput.blockRootHex)},
|
|
702
|
-
e as Error
|
|
703
|
-
);
|
|
703
|
+
logger[logLevel]("Error processing block", {slot, root: blockInput.blockRootHex, peer: peerIdStr}, e as Error);
|
|
704
704
|
// TODO(fulu): Revisit when we prune block inputs
|
|
705
705
|
chain.seenBlockInputCache.prune(blockInput.blockRootHex);
|
|
706
706
|
});
|