@lodestar/beacon-node 2.1.0-dev.ab28ad52c3 → 2.1.0-dev.ad0f676f6f
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 +1 -3
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/errors.d.ts +7 -0
- package/lib/api/impl/errors.d.ts.map +1 -1
- package/lib/api/impl/errors.js +9 -0
- package/lib/api/impl/errors.js.map +1 -1
- package/lib/api/rest/base.d.ts.map +1 -1
- package/lib/api/rest/base.js +5 -2
- package/lib/api/rest/base.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +3 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +3 -1
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/GetBlobsTracker.d.ts +3 -0
- package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
- package/lib/chain/GetBlobsTracker.js +3 -1
- package/lib/chain/GetBlobsTracker.js.map +1 -1
- package/lib/chain/chain.d.ts +2 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +5 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.d.ts +7 -0
- package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
- package/lib/chain/errors/dataColumnSidecarError.js +1 -0
- package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +1 -2
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +0 -2
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/seenCache/index.d.ts +1 -0
- package/lib/chain/seenCache/index.d.ts.map +1 -1
- package/lib/chain/seenCache/index.js +1 -0
- package/lib/chain/seenCache/index.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +3 -0
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +6 -2
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts +17 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.d.ts.map +1 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js +61 -0
- package/lib/chain/seenCache/seenDataColumnSidecars.js.map +1 -0
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +12 -2
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +1 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/network/core/networkCore.d.ts +1 -3
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js +1 -3
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/network.d.ts +1 -6
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +16 -40
- package/lib/network/network.js.map +1 -1
- package/lib/network/options.d.ts +0 -1
- package/lib/network/options.d.ts.map +1 -1
- package/lib/network/options.js +0 -1
- package/lib/network/options.js.map +1 -1
- package/lib/network/peers/discover.d.ts +1 -0
- package/lib/network/peers/discover.d.ts.map +1 -1
- package/lib/network/peers/discover.js +44 -48
- package/lib/network/peers/discover.js.map +1 -1
- package/lib/network/peers/score/store.d.ts.map +1 -1
- package/lib/network/peers/score/store.js +1 -2
- package/lib/network/peers/score/store.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +61 -3
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/util/dataColumns.d.ts +2 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +7 -2
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/execution.d.ts +2 -1
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -2
- package/lib/util/execution.js.map +1 -1
- package/package.json +18 -18
- package/src/api/impl/beacon/blocks/index.ts +1 -5
- package/src/api/impl/errors.ts +10 -0
- package/src/api/rest/base.ts +4 -2
- package/src/chain/ColumnReconstructionTracker.ts +5 -1
- package/src/chain/GetBlobsTracker.ts +5 -0
- package/src/chain/chain.ts +5 -0
- package/src/chain/errors/dataColumnSidecarError.ts +8 -0
- package/src/chain/forkChoice/index.ts +1 -3
- package/src/chain/interface.ts +2 -0
- package/src/chain/options.ts +0 -2
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenBlockProposers.ts +12 -2
- package/src/chain/seenCache/seenDataColumnSidecars.ts +69 -0
- package/src/chain/validation/block.ts +11 -2
- package/src/chain/validation/dataColumnSidecar.ts +1 -1
- package/src/index.ts +1 -0
- package/src/network/core/networkCore.ts +1 -3
- package/src/network/network.ts +20 -44
- package/src/network/options.ts +0 -2
- package/src/network/peers/discover.ts +42 -52
- package/src/network/peers/score/store.ts +1 -2
- package/src/network/processor/gossipHandlers.ts +107 -3
- package/src/util/dataColumns.ts +13 -1
- package/src/util/execution.ts +16 -1
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "2.1.0-dev.
|
|
14
|
+
"version": "2.1.0-dev.ad0f676f6f",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
"@chainsafe/enr": "^6.0.2",
|
|
104
104
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
105
105
|
"@chainsafe/libp2p-quic": "^2.1.6",
|
|
106
|
-
"@chainsafe/persistent-merkle-tree": "^1.3.
|
|
106
|
+
"@chainsafe/persistent-merkle-tree": "^1.3.2",
|
|
107
107
|
"@chainsafe/prometheus-gc-stats": "^1.0.0",
|
|
108
108
|
"@chainsafe/snappy-wasm": "^0.5.2",
|
|
109
|
-
"@chainsafe/ssz": "^1.9.
|
|
109
|
+
"@chainsafe/ssz": "^1.9.3",
|
|
110
110
|
"@chainsafe/threads": "^1.11.3",
|
|
111
111
|
"@crate-crypto/node-eth-kzg": "0.9.1",
|
|
112
112
|
"@fastify/bearer-auth": "^10.0.1",
|
|
@@ -124,18 +124,18 @@
|
|
|
124
124
|
"@libp2p/prometheus-metrics": "^5.0.31",
|
|
125
125
|
"@libp2p/tcp": "^11.0.30",
|
|
126
126
|
"@libp2p/utils": "^7.4.6",
|
|
127
|
-
"@lodestar/api": "^2.1.0-dev.
|
|
128
|
-
"@lodestar/config": "^2.1.0-dev.
|
|
129
|
-
"@lodestar/db": "^2.1.0-dev.
|
|
130
|
-
"@lodestar/fork-choice": "^2.1.0-dev.
|
|
131
|
-
"@lodestar/logger": "^2.1.0-dev.
|
|
132
|
-
"@lodestar/native": "^2.1.0-dev.
|
|
133
|
-
"@lodestar/params": "^2.1.0-dev.
|
|
134
|
-
"@lodestar/reqresp": "^2.1.0-dev.
|
|
135
|
-
"@lodestar/state-transition": "^2.1.0-dev.
|
|
136
|
-
"@lodestar/types": "^2.1.0-dev.
|
|
137
|
-
"@lodestar/utils": "^2.1.0-dev.
|
|
138
|
-
"@lodestar/validator": "^2.1.0-dev.
|
|
127
|
+
"@lodestar/api": "^2.1.0-dev.ad0f676f6f",
|
|
128
|
+
"@lodestar/config": "^2.1.0-dev.ad0f676f6f",
|
|
129
|
+
"@lodestar/db": "^2.1.0-dev.ad0f676f6f",
|
|
130
|
+
"@lodestar/fork-choice": "^2.1.0-dev.ad0f676f6f",
|
|
131
|
+
"@lodestar/logger": "^2.1.0-dev.ad0f676f6f",
|
|
132
|
+
"@lodestar/native": "^2.1.0-dev.ad0f676f6f",
|
|
133
|
+
"@lodestar/params": "^2.1.0-dev.ad0f676f6f",
|
|
134
|
+
"@lodestar/reqresp": "^2.1.0-dev.ad0f676f6f",
|
|
135
|
+
"@lodestar/state-transition": "^2.1.0-dev.ad0f676f6f",
|
|
136
|
+
"@lodestar/types": "^2.1.0-dev.ad0f676f6f",
|
|
137
|
+
"@lodestar/utils": "^2.1.0-dev.ad0f676f6f",
|
|
138
|
+
"@lodestar/validator": "^2.1.0-dev.ad0f676f6f",
|
|
139
139
|
"@multiformats/multiaddr": "^13.0.1",
|
|
140
140
|
"datastore-core": "^12.0.1",
|
|
141
141
|
"datastore-level": "^13.0.1",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
"@ethereumjs/rlp": "^10.1.3",
|
|
158
158
|
"@libp2p/interface-internal": "^3.2.3",
|
|
159
159
|
"@libp2p/logger": "^6.2.16",
|
|
160
|
-
"@lodestar/spec-test-util": "^2.1.0-dev.
|
|
161
|
-
"@lodestar/test-utils": "^2.1.0-dev.
|
|
160
|
+
"@lodestar/spec-test-util": "^2.1.0-dev.ad0f676f6f",
|
|
161
|
+
"@lodestar/test-utils": "^2.1.0-dev.ad0f676f6f",
|
|
162
162
|
"@types/js-yaml": "^4.0.5",
|
|
163
163
|
"@types/qs": "^6.9.7",
|
|
164
164
|
"@types/tmp": "^0.2.3",
|
|
@@ -171,5 +171,5 @@
|
|
|
171
171
|
"beacon",
|
|
172
172
|
"blockchain"
|
|
173
173
|
],
|
|
174
|
-
"gitHead": "
|
|
174
|
+
"gitHead": "f98d331e3ff997d92fe2761c38cb7a0c602411e0"
|
|
175
175
|
}
|
|
@@ -542,11 +542,7 @@ export function getBeaconBlockApi(
|
|
|
542
542
|
})
|
|
543
543
|
);
|
|
544
544
|
return {
|
|
545
|
-
data: result.filter(
|
|
546
|
-
(item) =>
|
|
547
|
-
// skip if no slot filter
|
|
548
|
-
!(slot !== undefined && slot !== 0) || item.header.message.slot === slot
|
|
549
|
-
),
|
|
545
|
+
data: result.filter((item) => slot === undefined || item.header.message.slot === slot),
|
|
550
546
|
meta: {executionOptimistic, finalized},
|
|
551
547
|
};
|
|
552
548
|
}
|
package/src/api/impl/errors.ts
CHANGED
|
@@ -28,6 +28,16 @@ export class NodeIsSyncing extends ApiError {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A service that is not ready to serve the request yet, e.g. while it is starting up. Expected to happen for every
|
|
33
|
+
* request until it is ready, the REST API server logs it at debug instead of as a warning
|
|
34
|
+
*/
|
|
35
|
+
export class ServiceNotReady extends ApiError {
|
|
36
|
+
constructor(message: string) {
|
|
37
|
+
super(503, message);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
// Error thrown by beacon node APIs that are only supported by distributed validator middleware clients
|
|
32
42
|
// For example https://github.com/ethereum/beacon-APIs/blob/f087fbf2764e657578a6c29bdf0261b36ee8db1e/apis/validator/beacon_committee_selections.yaml
|
|
33
43
|
export class OnlySupportedByDVT extends ApiError {
|
package/src/api/rest/base.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {NUMBER_OF_COLUMNS} from "@lodestar/params";
|
|
|
7
7
|
import {ErrorAborted, Gauge, Histogram, Logger} from "@lodestar/utils";
|
|
8
8
|
import {GossipActionError} from "../../chain/errors/gossipValidation.js";
|
|
9
9
|
import {isLocalhostIP} from "../../util/ip.js";
|
|
10
|
-
import {ApiError, FailureList, IndexedError, NodeIsSyncing} from "../impl/errors.js";
|
|
10
|
+
import {ApiError, FailureList, IndexedError, NodeIsSyncing, ServiceNotReady} from "../impl/errors.js";
|
|
11
11
|
import {HttpActiveSocketsTracker, SocketMetrics} from "./activeSockets.js";
|
|
12
12
|
|
|
13
13
|
export type RestApiServerOpts = {
|
|
@@ -178,7 +178,9 @@ export class RestApiServer {
|
|
|
178
178
|
|
|
179
179
|
const operationId = getOperationId(req);
|
|
180
180
|
|
|
181
|
-
if (
|
|
181
|
+
if (err instanceof ServiceNotReady) {
|
|
182
|
+
this.logger.debug(`Req ${req.id} ${operationId} failed`, {reason: err.message});
|
|
183
|
+
} else if (
|
|
182
184
|
err instanceof ApiError ||
|
|
183
185
|
err instanceof GossipActionError ||
|
|
184
186
|
[INVALID_MEDIA_TYPE_CODE, SCHEMA_VALIDATION_ERROR_CODE].includes(err.code)
|
|
@@ -8,6 +8,7 @@ import {JobItemQueue} from "../util/queue/index.js";
|
|
|
8
8
|
import {BlockInputColumns} from "./blocks/blockInput/index.js";
|
|
9
9
|
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
|
|
10
10
|
import {ChainEventEmitter} from "./emitter.js";
|
|
11
|
+
import {SeenDataColumnSidecars} from "./seenCache/seenDataColumnSidecars.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Minimum time to wait before attempting reconstruction
|
|
@@ -31,6 +32,7 @@ export type ColumnReconstructionInput = BlockInputColumns | PayloadEnvelopeInput
|
|
|
31
32
|
export type ColumnReconstructionTrackerInit = {
|
|
32
33
|
logger: Logger;
|
|
33
34
|
emitter: ChainEventEmitter;
|
|
35
|
+
seenDataColumnSidecars: SeenDataColumnSidecars;
|
|
34
36
|
metrics: Metrics | null;
|
|
35
37
|
config: ChainForkConfig;
|
|
36
38
|
signal: AbortSignal;
|
|
@@ -44,6 +46,7 @@ export type ColumnReconstructionTrackerInit = {
|
|
|
44
46
|
export class ColumnReconstructionTracker {
|
|
45
47
|
logger: Logger;
|
|
46
48
|
emitter: ChainEventEmitter;
|
|
49
|
+
seenDataColumnSidecars: SeenDataColumnSidecars;
|
|
47
50
|
metrics: Metrics | null;
|
|
48
51
|
config: ChainForkConfig;
|
|
49
52
|
|
|
@@ -54,6 +57,7 @@ export class ColumnReconstructionTracker {
|
|
|
54
57
|
constructor(init: ColumnReconstructionTrackerInit) {
|
|
55
58
|
this.logger = init.logger;
|
|
56
59
|
this.emitter = init.emitter;
|
|
60
|
+
this.seenDataColumnSidecars = init.seenDataColumnSidecars;
|
|
57
61
|
this.metrics = init.metrics;
|
|
58
62
|
this.config = init.config;
|
|
59
63
|
this.signal = init.signal;
|
|
@@ -104,7 +108,7 @@ export class ColumnReconstructionTracker {
|
|
|
104
108
|
const logCtx = {slot: input.slot, root: input.blockRootHex};
|
|
105
109
|
this.logger.debug("Attempting data column sidecar reconstruction", logCtx);
|
|
106
110
|
try {
|
|
107
|
-
const result = await recoverDataColumnSidecars(input, this.emitter, this.metrics);
|
|
111
|
+
const result = await recoverDataColumnSidecars(input, this.emitter, this.seenDataColumnSidecars, this.metrics);
|
|
108
112
|
this.metrics?.recoverDataColumnSidecars.reconstructionResult.inc({result});
|
|
109
113
|
this.logger.debug("Data column sidecar reconstruction complete", {...logCtx, result});
|
|
110
114
|
} catch (e) {
|
|
@@ -8,6 +8,7 @@ import {DataColumnEngineResult, getDataColumnSidecarsFromExecution} from "../uti
|
|
|
8
8
|
import {IBlockInput, isBlockInputColumns} from "./blocks/blockInput/index.js";
|
|
9
9
|
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
|
|
10
10
|
import {ChainEventEmitter} from "./emitter.js";
|
|
11
|
+
import {SeenDataColumnSidecars} from "./seenCache/seenDataColumnSidecars.js";
|
|
11
12
|
|
|
12
13
|
/** A `null` answer only changes if the EL receives the transactions later, so retries are few and spaced out */
|
|
13
14
|
export const MAX_GET_BLOBS_ATTEMPTS = 3;
|
|
@@ -18,6 +19,7 @@ export type GetBlobsTrackerInit = {
|
|
|
18
19
|
logger: Logger;
|
|
19
20
|
executionEngine: Pick<IExecutionEngine, "getBlobs">;
|
|
20
21
|
emitter: ChainEventEmitter;
|
|
22
|
+
seenDataColumnSidecars: SeenDataColumnSidecars;
|
|
21
23
|
metrics: Metrics | null;
|
|
22
24
|
config: ChainForkConfig;
|
|
23
25
|
};
|
|
@@ -29,6 +31,7 @@ export class GetBlobsTracker {
|
|
|
29
31
|
logger: Logger;
|
|
30
32
|
executionEngine: Pick<IExecutionEngine, "getBlobs">;
|
|
31
33
|
emitter: ChainEventEmitter;
|
|
34
|
+
seenDataColumnSidecars: SeenDataColumnSidecars;
|
|
32
35
|
metrics: Metrics | null;
|
|
33
36
|
config: ChainForkConfig;
|
|
34
37
|
activeReconstructions = new Set<string>();
|
|
@@ -42,6 +45,7 @@ export class GetBlobsTracker {
|
|
|
42
45
|
this.logger = init.logger;
|
|
43
46
|
this.executionEngine = init.executionEngine;
|
|
44
47
|
this.emitter = init.emitter;
|
|
48
|
+
this.seenDataColumnSidecars = init.seenDataColumnSidecars;
|
|
45
49
|
this.metrics = init.metrics;
|
|
46
50
|
this.config = init.config;
|
|
47
51
|
}
|
|
@@ -101,6 +105,7 @@ export class GetBlobsTracker {
|
|
|
101
105
|
this.config,
|
|
102
106
|
this.executionEngine,
|
|
103
107
|
this.emitter,
|
|
108
|
+
this.seenDataColumnSidecars,
|
|
104
109
|
input,
|
|
105
110
|
this.metrics,
|
|
106
111
|
this.blobsAndProofsBuffers[freeIndex].buffers
|
package/src/chain/chain.ts
CHANGED
|
@@ -127,6 +127,7 @@ import {
|
|
|
127
127
|
SeenAttesters,
|
|
128
128
|
SeenBlockProposers,
|
|
129
129
|
SeenContributionAndProof,
|
|
130
|
+
SeenDataColumnSidecars,
|
|
130
131
|
SeenExecutionPayloadBids,
|
|
131
132
|
SeenPayloadAttesters,
|
|
132
133
|
SeenPayloadEnvelopeInput,
|
|
@@ -224,6 +225,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
224
225
|
readonly seenAggregatedAttestations: SeenAggregatedAttestations;
|
|
225
226
|
readonly seenExecutionPayloadBids = new SeenExecutionPayloadBids();
|
|
226
227
|
readonly seenBlockProposers = new SeenBlockProposers();
|
|
228
|
+
readonly seenDataColumnSidecars = new SeenDataColumnSidecars();
|
|
227
229
|
/** Proposer indexes with an in-flight proposer slashing production */
|
|
228
230
|
private readonly producingProposerSlashing = new Set<ValidatorIndex>();
|
|
229
231
|
readonly seenSyncCommitteeMessages = new SeenSyncCommitteeMessages();
|
|
@@ -527,12 +529,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
527
529
|
logger,
|
|
528
530
|
executionEngine: this.executionEngine,
|
|
529
531
|
emitter,
|
|
532
|
+
seenDataColumnSidecars: this.seenDataColumnSidecars,
|
|
530
533
|
metrics,
|
|
531
534
|
config,
|
|
532
535
|
});
|
|
533
536
|
this.columnReconstructionTracker = new ColumnReconstructionTracker({
|
|
534
537
|
logger,
|
|
535
538
|
emitter,
|
|
539
|
+
seenDataColumnSidecars: this.seenDataColumnSidecars,
|
|
536
540
|
metrics,
|
|
537
541
|
config,
|
|
538
542
|
signal,
|
|
@@ -2039,6 +2043,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
2039
2043
|
|
|
2040
2044
|
const finalizedSlot = computeStartSlotAtEpoch(cp.epoch);
|
|
2041
2045
|
this.seenBlockProposers.prune(finalizedSlot);
|
|
2046
|
+
this.seenDataColumnSidecars.prune(finalizedSlot);
|
|
2042
2047
|
|
|
2043
2048
|
// Update validator custody to account for effective balance changes
|
|
2044
2049
|
try {
|
|
@@ -35,6 +35,7 @@ export enum DataColumnSidecarErrorCode {
|
|
|
35
35
|
|
|
36
36
|
// following errors are adapted from the block errors
|
|
37
37
|
ALREADY_KNOWN = "DATA_COLUMN_SIDECAR_ERROR_ALREADY_KNOWN",
|
|
38
|
+
REPEAT_PROPOSAL = "DATA_COLUMN_SIDECAR_ERROR_REPEAT_PROPOSAL",
|
|
38
39
|
FUTURE_SLOT = "DATA_COLUMN_SIDECAR_ERROR_FUTURE_SLOT",
|
|
39
40
|
WOULD_REVERT_FINALIZED_SLOT = "DATA_COLUMN_SIDECAR_ERROR_WOULD_REVERT_FINALIZED_SLOT",
|
|
40
41
|
PARENT_UNKNOWN = "DATA_COLUMN_SIDECAR_ERROR_PARENT_UNKNOWN",
|
|
@@ -79,6 +80,13 @@ export type DataColumnSidecarErrorType =
|
|
|
79
80
|
limit: number;
|
|
80
81
|
}
|
|
81
82
|
| {code: DataColumnSidecarErrorCode.ALREADY_KNOWN; columnIndex: number; slot: Slot}
|
|
83
|
+
| {
|
|
84
|
+
code: DataColumnSidecarErrorCode.REPEAT_PROPOSAL;
|
|
85
|
+
slot: Slot;
|
|
86
|
+
proposerIndex: number;
|
|
87
|
+
columnIndex: number;
|
|
88
|
+
root: RootHex;
|
|
89
|
+
}
|
|
82
90
|
| {code: DataColumnSidecarErrorCode.FUTURE_SLOT; blockSlot: Slot; currentSlot: Slot}
|
|
83
91
|
| {code: DataColumnSidecarErrorCode.WOULD_REVERT_FINALIZED_SLOT; blockSlot: Slot; finalizedSlot: Slot}
|
|
84
92
|
| {
|
|
@@ -318,9 +318,7 @@ export function initializeNativeForkChoice(
|
|
|
318
318
|
: isPostGloas
|
|
319
319
|
? Number(state.latestExecutionPayloadBid.gasLimit)
|
|
320
320
|
: state.latestExecutionPayloadHeader.gasLimit,
|
|
321
|
-
|
|
322
|
-
executionStatus:
|
|
323
|
-
blockHeader.slot === GENESIS_SLOT && !isPostGloasAnchor ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
|
|
321
|
+
executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
|
|
324
322
|
}
|
|
325
323
|
: {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
|
|
326
324
|
|
package/src/chain/interface.ts
CHANGED
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
SeenAttesters,
|
|
69
69
|
SeenBlockProposers,
|
|
70
70
|
SeenContributionAndProof,
|
|
71
|
+
SeenDataColumnSidecars,
|
|
71
72
|
SeenExecutionPayloadBids,
|
|
72
73
|
SeenPayloadAttesters,
|
|
73
74
|
SeenSyncCommitteeMessages,
|
|
@@ -147,6 +148,7 @@ export interface IBeaconChain {
|
|
|
147
148
|
readonly seenAggregatedAttestations: SeenAggregatedAttestations;
|
|
148
149
|
readonly seenExecutionPayloadBids: SeenExecutionPayloadBids;
|
|
149
150
|
readonly seenBlockProposers: SeenBlockProposers;
|
|
151
|
+
readonly seenDataColumnSidecars: SeenDataColumnSidecars;
|
|
150
152
|
readonly seenSyncCommitteeMessages: SeenSyncCommitteeMessages;
|
|
151
153
|
readonly seenContributionAndProof: SeenContributionAndProof;
|
|
152
154
|
readonly seenAttestationDatas: SeenAttestationDatas;
|
package/src/chain/options.ts
CHANGED
|
@@ -123,8 +123,6 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
123
123
|
maxSkipSlots: 32,
|
|
124
124
|
disableProposerSlashings: false,
|
|
125
125
|
// should be less than or equal to MIN_SIGNATURE_SETS_TO_BATCH_VERIFY
|
|
126
|
-
// batching too much may block the I/O thread so if useWorker=false, suggest this value to be 32
|
|
127
|
-
// since this batch attestation work is designed to work with useWorker=true, make this the lowest value
|
|
128
126
|
minSameMessageSignatureSetsToBatch: 2,
|
|
129
127
|
// as of Feb 2025, this option turned out to be very useful:
|
|
130
128
|
// - it allows to share a persisted checkpoint state to other nodes
|
|
@@ -2,6 +2,7 @@ export {SeenAggregators, SeenAttesters, SeenPayloadAttesters} from "./seenAttest
|
|
|
2
2
|
export {SeenBlockProposers} from "./seenBlockProposers.js";
|
|
3
3
|
export {SeenSyncCommitteeMessages} from "./seenCommittee.js";
|
|
4
4
|
export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
5
|
+
export {SeenDataColumnSidecars} from "./seenDataColumnSidecars.js";
|
|
5
6
|
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
7
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
7
8
|
export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
2
2
|
import {Epoch, RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types";
|
|
3
|
-
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
import {MapDef, byteArrayEquals} from "@lodestar/utils";
|
|
4
4
|
|
|
5
5
|
/** Two distinct block roots signed by the same proposer for the same slot are sufficient to establish an equivocation */
|
|
6
|
-
const MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
6
|
+
export const MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL = 2;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Keeps a cache to filter block proposals from the same validator in the same slot.
|
|
@@ -44,6 +44,16 @@ export class SeenBlockProposers {
|
|
|
44
44
|
return this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.has(blockRoot) === true;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
hasBlockSignature(
|
|
48
|
+
blockSlot: Slot,
|
|
49
|
+
proposerIndex: ValidatorIndex,
|
|
50
|
+
blockRoot: RootHex,
|
|
51
|
+
signature: Uint8Array
|
|
52
|
+
): boolean {
|
|
53
|
+
const signedBlockHeader = this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.get(blockRoot);
|
|
54
|
+
return signedBlockHeader !== undefined && byteArrayEquals(signedBlockHeader.signature, signature);
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
isEquivocating(blockSlot: Slot, proposerIndex: ValidatorIndex): boolean {
|
|
48
58
|
return (
|
|
49
59
|
(this.signedBlockHeadersBySlot.get(blockSlot)?.get(proposerIndex)?.size ?? 0) >=
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {ColumnIndex, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
import {MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL} from "./seenBlockProposers.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tracks the column indices of valid gossip data column sidecars per slot, proposer and block root,
|
|
7
|
+
* to ignore sidecars of a repeated proposal. Sidecars are accepted for at most two block roots per slot and
|
|
8
|
+
* proposer, same as blocks. Pruned on finalization.
|
|
9
|
+
*/
|
|
10
|
+
export class SeenDataColumnSidecars {
|
|
11
|
+
private readonly columnIndicesBySlot = new MapDef<Slot, MapDef<ValidatorIndex, MapDef<RootHex, Set<ColumnIndex>>>>(
|
|
12
|
+
() => new MapDef(() => new MapDef(() => new Set()))
|
|
13
|
+
);
|
|
14
|
+
private readonly evidenceChecksBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set());
|
|
15
|
+
private finalizedSlot: Slot = 0;
|
|
16
|
+
|
|
17
|
+
isRepeatProposal(slot: Slot, proposerIndex: ValidatorIndex, columnIndex: ColumnIndex, blockRoot: RootHex): boolean {
|
|
18
|
+
const columnIndicesByRoot = this.columnIndicesBySlot.get(slot)?.get(proposerIndex);
|
|
19
|
+
if (columnIndicesByRoot === undefined) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (!columnIndicesByRoot.has(blockRoot) && columnIndicesByRoot.size >= MIN_EQUIVOCATION_BLOCK_ROOTS_PER_PROPOSAL) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
for (const [root, columnIndices] of columnIndicesByRoot) {
|
|
26
|
+
if (root !== blockRoot && columnIndices.has(columnIndex)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
isKnown(slot: Slot, proposerIndex: ValidatorIndex, columnIndex: ColumnIndex, blockRoot: RootHex): boolean {
|
|
34
|
+
return this.columnIndicesBySlot.get(slot)?.get(proposerIndex)?.get(blockRoot)?.has(columnIndex) === true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
add(slot: Slot, proposerIndex: ValidatorIndex, columnIndex: ColumnIndex, blockRoot: RootHex): void {
|
|
38
|
+
if (slot < this.finalizedSlot || this.isRepeatProposal(slot, proposerIndex, columnIndex, blockRoot)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.columnIndicesBySlot.getOrDefault(slot).getOrDefault(proposerIndex).getOrDefault(blockRoot).add(columnIndex);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
markEvidenceCheck(slot: Slot, proposerIndex: ValidatorIndex): boolean {
|
|
45
|
+
if (slot < this.finalizedSlot) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const proposers = this.evidenceChecksBySlot.getOrDefault(slot);
|
|
49
|
+
if (proposers.has(proposerIndex)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
proposers.add(proposerIndex);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
prune(finalizedSlot: Slot): void {
|
|
57
|
+
this.finalizedSlot = finalizedSlot;
|
|
58
|
+
for (const slot of this.columnIndicesBySlot.keys()) {
|
|
59
|
+
if (slot < finalizedSlot) {
|
|
60
|
+
this.columnIndicesBySlot.delete(slot);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const slot of this.evidenceChecksBySlot.keys()) {
|
|
64
|
+
if (slot < finalizedSlot) {
|
|
65
|
+
this.evidenceChecksBySlot.delete(slot);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -76,8 +76,17 @@ export async function validateGossipBlock(
|
|
|
76
76
|
const proposerIndex = block.proposerIndex;
|
|
77
77
|
if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
|
|
78
78
|
if (chain.seenBlockProposers.isRepeatProposal(blockSlot, proposerIndex, blockRoot)) {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot)) {
|
|
80
|
+
// The root is known with a verified signature, e.g. from the header of a data column sidecar, and a valid
|
|
81
|
+
// BLS signature of the same message by the same proposer is unique
|
|
82
|
+
if (!chain.seenBlockProposers.hasBlockSignature(blockSlot, proposerIndex, blockRoot, signedBlock.signature)) {
|
|
83
|
+
throw new BlockGossipError(GossipAction.REJECT, {
|
|
84
|
+
code: BlockErrorCode.PROPOSAL_SIGNATURE_INVALID,
|
|
85
|
+
slot: blockSlot,
|
|
86
|
+
root: blockRoot,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} else if (!chain.seenBlockProposers.isEquivocating(blockSlot, proposerIndex)) {
|
|
81
90
|
await verifyBlockProposerSignature(chain, signedBlock, blockRoot, {verifyOnMainThread: false});
|
|
82
91
|
chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
|
|
83
92
|
}
|
|
@@ -225,7 +225,7 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
225
225
|
|
|
226
226
|
// 12) [IGNORE] The sidecar is the first sidecar for the tuple (block_header.slot, block_header.proposer_index,
|
|
227
227
|
// sidecar.index) with valid header signature, sidecar inclusion proof, and kzg proof
|
|
228
|
-
// -- Handled in
|
|
228
|
+
// -- Handled in gossip handler with seenDataColumnSidecars
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// SPEC FUNCTION
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Export generic RestApi server for CLI
|
|
2
2
|
|
|
3
|
+
export {ServiceNotReady} from "./api/impl/errors.js";
|
|
3
4
|
export type {RestApiServerMetrics, RestApiServerModules, RestApiServerOpts} from "./api/rest/base.js";
|
|
4
5
|
export {RestApiServer} from "./api/rest/base.js";
|
|
5
6
|
export {persistAnchorState} from "./chain/index.js";
|
|
@@ -81,9 +81,7 @@ function formatActiveResources(): string {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* This class
|
|
85
|
-
* - In a libp2p worker
|
|
86
|
-
* - In the main thread
|
|
84
|
+
* This class runs in the libp2p worker.
|
|
87
85
|
*
|
|
88
86
|
* libp2p holds the reference to the TCP transport socket. libp2p is in a worker, what components
|
|
89
87
|
* must be in a worker too?
|
package/src/network/network.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {ChainEvent, IBeaconChain} from "../chain/index.js";
|
|
|
36
36
|
import {computeSubnetForDataColumnSidecar} from "../chain/validation/dataColumnSidecar.js";
|
|
37
37
|
import {GoodByeReasonCode} from "../constants/index.js";
|
|
38
38
|
import {IBeaconDb} from "../db/interface.js";
|
|
39
|
-
import {Metrics
|
|
39
|
+
import {Metrics} from "../metrics/index.js";
|
|
40
40
|
import {IClock} from "../util/clock.js";
|
|
41
41
|
import {CustodyConfig} from "../util/dataColumns.js";
|
|
42
42
|
import {PeerIdStr, peerIdToString} from "../util/peerId.js";
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
DataColumnSidecarsByRootRequest,
|
|
47
47
|
ExecutionPayloadEnvelopesByRootRequest,
|
|
48
48
|
} from "../util/types.js";
|
|
49
|
-
import {INetworkCore,
|
|
49
|
+
import {INetworkCore, WorkerNetworkCore} from "./core/index.js";
|
|
50
50
|
import {INetworkEventBus, NetworkEvent, NetworkEventBus, NetworkEventData} from "./events.js";
|
|
51
51
|
import {getActiveForkBoundaries} from "./forks.js";
|
|
52
52
|
import {GossipHandlers, GossipTopicMap, GossipType, GossipTypeMap} from "./gossip/index.js";
|
|
@@ -100,12 +100,7 @@ export type NetworkInitModules = {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Exists a front class that's what consumers interact with.
|
|
106
|
-
* This class will multiplex between:
|
|
107
|
-
* - libp2p in worker
|
|
108
|
-
* - libp2p in main thread
|
|
103
|
+
* Front class that consumers interact with. libp2p runs in a worker thread.
|
|
109
104
|
*/
|
|
110
105
|
export class Network implements INetwork {
|
|
111
106
|
readonly peerId: PeerId;
|
|
@@ -173,42 +168,23 @@ export class Network implements INetwork {
|
|
|
173
168
|
const initialStatus = chain.getStatus();
|
|
174
169
|
const initialCustodyGroupCount = chain.custodyConfig.targetCustodyGroupCount;
|
|
175
170
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
logger,
|
|
194
|
-
events,
|
|
195
|
-
metrics,
|
|
196
|
-
getReqRespHandler,
|
|
197
|
-
})
|
|
198
|
-
: await NetworkCore.init({
|
|
199
|
-
opts,
|
|
200
|
-
config,
|
|
201
|
-
privateKey,
|
|
202
|
-
peerStoreDir,
|
|
203
|
-
logger,
|
|
204
|
-
clock: chain.clock,
|
|
205
|
-
events,
|
|
206
|
-
getReqRespHandler,
|
|
207
|
-
metricsRegistry: metrics ? new RegistryMetricCreator() : null,
|
|
208
|
-
initialStatus,
|
|
209
|
-
initialCustodyGroupCount,
|
|
210
|
-
activeValidatorCount,
|
|
211
|
-
});
|
|
171
|
+
const core = await WorkerNetworkCore.init({
|
|
172
|
+
opts: {
|
|
173
|
+
...opts,
|
|
174
|
+
peerStoreDir,
|
|
175
|
+
metricsEnabled: Boolean(metrics),
|
|
176
|
+
activeValidatorCount,
|
|
177
|
+
genesisTime: chain.genesisTime,
|
|
178
|
+
initialStatus,
|
|
179
|
+
initialCustodyGroupCount,
|
|
180
|
+
},
|
|
181
|
+
config,
|
|
182
|
+
privateKey,
|
|
183
|
+
logger,
|
|
184
|
+
events,
|
|
185
|
+
metrics,
|
|
186
|
+
getReqRespHandler,
|
|
187
|
+
});
|
|
212
188
|
|
|
213
189
|
const networkProcessor = new NetworkProcessor(
|
|
214
190
|
{chain, db, config, logger, metrics, events, gossipHandlers, core, aggregatorTracker},
|
package/src/network/options.ts
CHANGED
|
@@ -28,7 +28,6 @@ export interface NetworkOptions
|
|
|
28
28
|
/** Include the version in libp2p Identify. Private mode takes precedence. */
|
|
29
29
|
advertiseVersion?: boolean;
|
|
30
30
|
private?: boolean;
|
|
31
|
-
useWorker?: boolean;
|
|
32
31
|
maxYoungGenerationSizeMb?: number;
|
|
33
32
|
disableLightClientServer?: boolean;
|
|
34
33
|
/**
|
|
@@ -67,7 +66,6 @@ export const defaultNetworkOptions: NetworkOptions = {
|
|
|
67
66
|
/** disabled by default */
|
|
68
67
|
discv5: null,
|
|
69
68
|
rateLimitMultiplier: 1,
|
|
70
|
-
useWorker: true,
|
|
71
69
|
// set after testing before 1.19.0, see https://github.com/ChainSafe/lodestar/issues/6596
|
|
72
70
|
disableFloodPublish: true,
|
|
73
71
|
// default set via research in https://github.com/ChainSafe/lodestar/issues/2115
|