@lodestar/beacon-node 1.52.0-dev.53c3aab4e9 → 1.52.0-dev.678e11f626
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 +45 -34
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +3 -1
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +4 -3
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +3 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +17 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +21 -17
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
- package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
- package/lib/chain/bls/utils.js +1 -1
- package/lib/chain/bls/utils.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +12 -6
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +3 -2
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +1 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +1 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
- package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.js +34 -11
- package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
- package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
- package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
- package/lib/chain/opPools/inclusionListStore.js +5 -2
- package/lib/chain/opPools/inclusionListStore.js.map +1 -1
- package/lib/chain/options.js +2 -2
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +5 -0
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +39 -1
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +13 -2
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
- package/lib/chain/validation/dataColumnSidecar.js +8 -1
- package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +29 -11
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +4 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +11 -2
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +2 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +37 -28
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +20 -11
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +4 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +2 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +54 -42
- package/src/api/impl/beacon/pool/index.ts +9 -7
- package/src/api/impl/validator/index.ts +4 -2
- package/src/chain/blocks/blockInput/blockInput.ts +4 -1
- package/src/chain/blocks/importExecutionPayload.ts +21 -2
- package/src/chain/blocks/verifyBlock.ts +24 -17
- package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
- package/src/chain/bls/utils.ts +1 -1
- package/src/chain/chain.ts +12 -6
- package/src/chain/errors/executionPayloadBid.ts +3 -2
- package/src/chain/forkChoice/index.ts +1 -4
- package/src/chain/forkChoiceExecutionEngine.ts +48 -15
- package/src/chain/opPools/inclusionListStore.ts +5 -2
- package/src/chain/options.ts +2 -2
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
- package/src/chain/shufflingCache.ts +40 -1
- package/src/chain/validation/aggregateAndProof.ts +19 -5
- package/src/chain/validation/dataColumnSidecar.ts +7 -1
- package/src/chain/validation/executionPayloadBid.ts +39 -11
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/metrics/metrics/beacon.ts +11 -2
- package/src/metrics/metrics/lodestar.ts +37 -28
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/network.ts +33 -11
- package/src/network/processor/gossipHandlers.ts +10 -7
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
- package/src/sync/unknownBlock.ts +2 -1
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ExecutionStatus,
|
|
3
|
+
IForkChoice,
|
|
4
|
+
LVHInvalidJudged,
|
|
5
|
+
LVHInvalidResponse,
|
|
6
|
+
LVHNotAppliedReason,
|
|
7
|
+
LVHVerdictResult,
|
|
8
|
+
} from "@lodestar/fork-choice";
|
|
2
9
|
import {ForkName, ForkPostFulu} from "@lodestar/params";
|
|
3
10
|
import {RootHex, bellatrix} from "@lodestar/types";
|
|
4
11
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
5
|
-
import {Logger} from "@lodestar/utils";
|
|
12
|
+
import {LogDataBasic, Logger} from "@lodestar/utils";
|
|
6
13
|
import {ExecutionPayloadBodyV2} from "../execution/engine/types.js";
|
|
7
14
|
import {DATA} from "../execution/engine/utils.js";
|
|
8
15
|
import {
|
|
@@ -119,18 +126,25 @@ export class ForkChoiceExecutionEngine {
|
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
/**
|
|
122
|
-
* Apply an execution engine INVALID verdict to fork choice and move the chain head off the invalid chain
|
|
129
|
+
* Apply an execution engine INVALID verdict to fork choice and move the chain head off the invalid chain.
|
|
130
|
+
* `judgedLogCtx` identifies the judged payload in logs when it is not the from node.
|
|
123
131
|
*/
|
|
124
|
-
invalidateExecutionPayloads(
|
|
132
|
+
invalidateExecutionPayloads(
|
|
133
|
+
lvh: LVHInvalidResponse,
|
|
134
|
+
source: ExecutionInvalidSource,
|
|
135
|
+
judgedLogCtx?: Record<string, LogDataBasic>
|
|
136
|
+
): void {
|
|
125
137
|
const logCtx = {
|
|
138
|
+
...judgedLogCtx,
|
|
126
139
|
source,
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
judged: lvh.judged,
|
|
141
|
+
fromBlockRoot: lvh.invalidateFromBlockRoot,
|
|
142
|
+
fromBlockHash: lvh.invalidateFromBlockHash,
|
|
129
143
|
latestValidHash: lvh.latestValidExecHash ?? "null",
|
|
130
144
|
};
|
|
131
|
-
const
|
|
132
|
-
if (!applied) {
|
|
133
|
-
this.
|
|
145
|
+
const result = this.forkChoice.validateLatestHash(lvh);
|
|
146
|
+
if (!result.applied) {
|
|
147
|
+
this.logNotApplied(result, logCtx);
|
|
134
148
|
return;
|
|
135
149
|
}
|
|
136
150
|
this.metrics?.forkChoice.executionInvalidations.inc({source});
|
|
@@ -143,6 +157,20 @@ export class ForkChoiceExecutionEngine {
|
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
159
|
|
|
160
|
+
private logNotApplied(
|
|
161
|
+
result: Exclude<LVHVerdictResult, {applied: true}>,
|
|
162
|
+
logCtx: Record<string, LogDataBasic>
|
|
163
|
+
): void {
|
|
164
|
+
const message = "Execution engine verdict not applied to fork choice";
|
|
165
|
+
if (result.reason === LVHNotAppliedReason.Error) {
|
|
166
|
+
this.logger.error(message, {...logCtx, reason: result.reason}, result.error);
|
|
167
|
+
} else if (result.reason === LVHNotAppliedReason.AlreadyApplied) {
|
|
168
|
+
this.logger.debug(message, {...logCtx, reason: result.reason});
|
|
169
|
+
} else {
|
|
170
|
+
this.logger.warn(message, {...logCtx, reason: result.reason});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
146
174
|
private applyForkchoiceUpdatedResult(
|
|
147
175
|
headBlockRoot: RootHex,
|
|
148
176
|
headBlockHash: RootHex,
|
|
@@ -165,16 +193,21 @@ export class ForkChoiceExecutionEngine {
|
|
|
165
193
|
{
|
|
166
194
|
executionStatus: ExecutionStatus.Invalid,
|
|
167
195
|
latestValidExecHash: latestValidHash,
|
|
168
|
-
|
|
169
|
-
|
|
196
|
+
invalidateFromBlockRoot: headBlockRoot,
|
|
197
|
+
invalidateFromBlockHash: headBlockHash,
|
|
198
|
+
judged: LVHInvalidJudged.FromBlock,
|
|
170
199
|
},
|
|
171
200
|
ExecutionInvalidSource.forkchoiceUpdated
|
|
172
201
|
);
|
|
173
202
|
} else if (status === ExecutionPayloadStatus.VALID && executionStatus === ExecutionStatus.Syncing) {
|
|
174
|
-
this.forkChoice.validateLatestHash(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
const result = this.forkChoice.validateLatestHash({
|
|
204
|
+
executionStatus: ExecutionStatus.Valid,
|
|
205
|
+
latestValidExecHash: headBlockHash,
|
|
206
|
+
blockRoot: headBlockRoot,
|
|
207
|
+
});
|
|
208
|
+
if (!result.applied) {
|
|
209
|
+
this.logNotApplied(result, {source: ExecutionInvalidSource.forkchoiceUpdated, headBlockRoot, headBlockHash});
|
|
210
|
+
}
|
|
178
211
|
}
|
|
179
212
|
} catch (e) {
|
|
180
213
|
this.logger.error("Error applying forkchoice update result", {headBlockRoot, headBlockHash, status}, e as Error);
|
|
@@ -164,9 +164,12 @@ export class InclusionListStore {
|
|
|
164
164
|
return out;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Lists are kept one slot past the MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS serving window, the lists of slot N are
|
|
169
|
+
* read when the payload of slot N + 1 is processed, which may happen during slot N + 2
|
|
170
|
+
*/
|
|
168
171
|
prune(clockSlot: Slot): void {
|
|
169
|
-
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS;
|
|
172
|
+
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS - 1;
|
|
170
173
|
|
|
171
174
|
for (const slot of this.inclusionLists.keys()) {
|
|
172
175
|
if (slot < horizon) {
|
package/src/chain/options.ts
CHANGED
|
@@ -117,7 +117,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
117
117
|
serveHistoricalState: false,
|
|
118
118
|
archiveStateEpochFrequency: 1024,
|
|
119
119
|
archiveMode: DEFAULT_ARCHIVE_MODE,
|
|
120
|
-
pruneHistory:
|
|
120
|
+
pruneHistory: true,
|
|
121
121
|
emitPayloadAttributes: false,
|
|
122
122
|
// for gossip block validation, it's unlikely we see a reorg with 32 slots
|
|
123
123
|
// for attestation validation, having this value ensures we don't have to regen states most of the time
|
|
@@ -132,7 +132,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
132
132
|
// - users can prune the persisted checkpoint state files manually to save disc space
|
|
133
133
|
// - it helps debug easier when network is unfinalized
|
|
134
134
|
nHistoricalStatesFileDataStore: true,
|
|
135
|
-
nativeStateTransition:
|
|
135
|
+
nativeStateTransition: true,
|
|
136
136
|
maxBlockStates: DEFAULT_MAX_BLOCK_STATES,
|
|
137
137
|
maxCPStateEpochsInMemory: DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY,
|
|
138
138
|
maxCPStateEpochsOnDisk: DEFAULT_MAX_CP_STATE_ON_DISK,
|
|
@@ -6,38 +6,58 @@ import {MapDef} from "@lodestar/utils";
|
|
|
6
6
|
*/
|
|
7
7
|
const SLOTS_RETAINED = 2;
|
|
8
8
|
|
|
9
|
+
export type SeenBuilderBids = {
|
|
10
|
+
/** Number of valid bids seen */
|
|
11
|
+
count: number;
|
|
12
|
+
/**
|
|
13
|
+
* The builder's bid limit. Bids for the same slot and parent root are validated against the same state,
|
|
14
|
+
* so it is known without the state once a bid was valid
|
|
15
|
+
*/
|
|
16
|
+
limit: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* Counts the valid execution payload bids seen per
|
|
11
21
|
* (slot, builder, parent block hash, parent block root).
|
|
12
22
|
*/
|
|
13
23
|
export class SeenExecutionPayloadBids {
|
|
14
|
-
private readonly
|
|
15
|
-
() => new MapDef<BuilderIndex,
|
|
24
|
+
private readonly bidsByBranchByBuilderBySlot = new MapDef<Slot, MapDef<BuilderIndex, Map<string, SeenBuilderBids>>>(
|
|
25
|
+
() => new MapDef<BuilderIndex, Map<string, SeenBuilderBids>>(() => new Map<string, SeenBuilderBids>())
|
|
16
26
|
);
|
|
17
27
|
private lowestPermissibleSlot: Slot = 0;
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
get(
|
|
30
|
+
slot: Slot,
|
|
31
|
+
builderIndex: BuilderIndex,
|
|
32
|
+
parentBlockHash: RootHex,
|
|
33
|
+
parentBlockRoot: RootHex
|
|
34
|
+
): SeenBuilderBids | undefined {
|
|
35
|
+
return this.bidsByBranchByBuilderBySlot
|
|
36
|
+
.get(slot)
|
|
37
|
+
?.get(builderIndex)
|
|
38
|
+
?.get(branchKey(parentBlockHash, parentBlockRoot));
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
add(
|
|
41
|
+
add(
|
|
42
|
+
slot: Slot,
|
|
43
|
+
builderIndex: BuilderIndex,
|
|
44
|
+
parentBlockHash: RootHex,
|
|
45
|
+
parentBlockRoot: RootHex,
|
|
46
|
+
bidLimit: number
|
|
47
|
+
): void {
|
|
27
48
|
if (slot < this.lowestPermissibleSlot) {
|
|
28
49
|
throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
|
|
29
50
|
}
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.add(branchKey(parentBlockHash, parentBlockRoot));
|
|
51
|
+
const bidsByBranch = this.bidsByBranchByBuilderBySlot.getOrDefault(slot).getOrDefault(builderIndex);
|
|
52
|
+
const key = branchKey(parentBlockHash, parentBlockRoot);
|
|
53
|
+
bidsByBranch.set(key, {count: (bidsByBranch.get(key)?.count ?? 0) + 1, limit: bidLimit});
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
prune(currentSlot: Slot): void {
|
|
37
57
|
this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
|
|
38
|
-
for (const slot of this.
|
|
58
|
+
for (const slot of this.bidsByBranchByBuilderBySlot.keys()) {
|
|
39
59
|
if (slot < this.lowestPermissibleSlot) {
|
|
40
|
-
this.
|
|
60
|
+
this.bidsByBranchByBuilderBySlot.delete(slot);
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {computeCommitteePubkeys, releaseCommitteePubkeys} from "@lodestar/native/committee-pubkeys";
|
|
2
|
+
import {ForkSeq, GENESIS_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
EpochShuffling,
|
|
4
5
|
IBeaconStateView,
|
|
@@ -272,6 +273,40 @@ export class ShufflingCache {
|
|
|
272
273
|
// set the shuffling
|
|
273
274
|
shufflingAtEpoch.set(decisionRoot, {type: CacheItemType.shuffling, shuffling});
|
|
274
275
|
this.prune();
|
|
276
|
+
if (this.has(shuffling.epoch, decisionRoot)) {
|
|
277
|
+
this.computeCommitteePubkeys(shuffling, decisionRoot);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Committee pubkeys make attestation signature sets cheaper to verify. Until they resolve, and if computing them
|
|
283
|
+
* fails, sets aggregate the participants instead.
|
|
284
|
+
*/
|
|
285
|
+
private computeCommitteePubkeys(shuffling: EpochShuffling, decisionRoot: RootHex): void {
|
|
286
|
+
const timer = this.metrics?.shufflingCache.committeePubkeysComputeTime.startTimer();
|
|
287
|
+
const onError = (e: unknown): void => {
|
|
288
|
+
this.metrics?.shufflingCache.committeePubkeysErrors.inc();
|
|
289
|
+
this.logger?.debug("Error computing committee pubkeys", {epoch: shuffling.epoch, decisionRoot}, e as Error);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
let promise: Promise<number>;
|
|
293
|
+
try {
|
|
294
|
+
promise = computeCommitteePubkeys(shuffling.shuffling, SLOTS_PER_EPOCH, shuffling.committeesPerSlot);
|
|
295
|
+
} catch (e) {
|
|
296
|
+
onError(e);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
promise.then((id) => {
|
|
301
|
+
timer?.();
|
|
302
|
+
const cacheItem = this.itemsByDecisionRootByEpoch.get(shuffling.epoch)?.get(decisionRoot);
|
|
303
|
+
if (cacheItem !== undefined && isShufflingCacheItem(cacheItem) && cacheItem.shuffling === shuffling) {
|
|
304
|
+
shuffling.committeePubkeysId = id;
|
|
305
|
+
} else {
|
|
306
|
+
// Pruned while computing
|
|
307
|
+
releaseCommitteePubkeys(id);
|
|
308
|
+
}
|
|
309
|
+
}, onError);
|
|
275
310
|
}
|
|
276
311
|
|
|
277
312
|
/**
|
|
@@ -294,6 +329,10 @@ export class ShufflingCache {
|
|
|
294
329
|
this.metrics?.shufflingCache.cancelledPromises.inc({reason: ShufflingPromiseCancelReason.pruned});
|
|
295
330
|
} else {
|
|
296
331
|
prunedShufflings++;
|
|
332
|
+
if (cacheItem.shuffling.committeePubkeysId !== undefined) {
|
|
333
|
+
releaseCommitteePubkeys(cacheItem.shuffling.committeePubkeysId);
|
|
334
|
+
cacheItem.shuffling.committeePubkeysId = undefined;
|
|
335
|
+
}
|
|
297
336
|
}
|
|
298
337
|
}
|
|
299
338
|
this.itemsByDecisionRootByEpoch.delete(epoch);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {
|
|
3
|
+
ISignatureSet,
|
|
4
|
+
SignatureSetType,
|
|
3
5
|
computeEpochAtSlot,
|
|
4
6
|
createAggregateSignatureSetFromComponents,
|
|
5
7
|
isAggregatorFromCommitteeLength,
|
|
@@ -259,11 +261,23 @@ async function validateAggregateAndProof(
|
|
|
259
261
|
// [REJECT] The aggregator signature, signed_aggregate_and_proof.signature, is valid.
|
|
260
262
|
// [REJECT] The signature of aggregate is valid.
|
|
261
263
|
const signingRoot = cachedAttData ? cachedAttData.signingRoot : getAttestationDataSigningRoot(chain.config, attData);
|
|
262
|
-
const indexedAttestationSignatureSet =
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
const indexedAttestationSignatureSet: ISignatureSet =
|
|
265
|
+
shuffling.committeePubkeysId === undefined
|
|
266
|
+
? createAggregateSignatureSetFromComponents(
|
|
267
|
+
indexedAttestation.attestingIndices,
|
|
268
|
+
signingRoot,
|
|
269
|
+
indexedAttestation.signature
|
|
270
|
+
)
|
|
271
|
+
: {
|
|
272
|
+
type: SignatureSetType.committee,
|
|
273
|
+
indices: indexedAttestation.attestingIndices,
|
|
274
|
+
committeePubkeysId: shuffling.committeePubkeysId,
|
|
275
|
+
slot: attSlot,
|
|
276
|
+
committeeIndices: [committeeIndex],
|
|
277
|
+
aggregationBits: aggregate.aggregationBits,
|
|
278
|
+
signingRoot,
|
|
279
|
+
signature: indexedAttestation.signature,
|
|
280
|
+
};
|
|
267
281
|
const signatureSets = [
|
|
268
282
|
getSelectionProofSignatureSet(chain.config, attSlot, aggregatorIndex, signedAggregateAndProof),
|
|
269
283
|
getAggregateAndProofSignatureSet(chain.config, attEpoch, aggregatorIndex, signedAggregateAndProof),
|
|
@@ -152,12 +152,15 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
152
152
|
|
|
153
153
|
// 5) [REJECT] The proposer signature of sidecar.signed_block_header, is valid with respect to the block_header.proposer_index pubkey.
|
|
154
154
|
const signature = dataColumnSidecar.signedBlockHeader.signature;
|
|
155
|
-
if (
|
|
155
|
+
if (chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
|
|
156
|
+
metrics?.peerDas.dataColumnSidecarProposerSignatureChecks.inc({result: "cache_hit"});
|
|
157
|
+
} else {
|
|
156
158
|
const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
157
159
|
chain.config,
|
|
158
160
|
dataColumnSidecar.signedBlockHeader
|
|
159
161
|
);
|
|
160
162
|
|
|
163
|
+
metrics?.peerDas.dataColumnSidecarProposerSignatureChecks.inc({result: "verification"});
|
|
161
164
|
if (
|
|
162
165
|
!(await chain.bls.verifySignatureSets([signatureSet], {
|
|
163
166
|
// verify on main thread so that we only need to verify block proposer signature once per block
|
|
@@ -172,6 +175,9 @@ export async function validateGossipFuluDataColumnSidecar(
|
|
|
172
175
|
});
|
|
173
176
|
}
|
|
174
177
|
|
|
178
|
+
if (metrics && !chain.seenBlockInputCache.isVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature)) {
|
|
179
|
+
metrics.peerDas.dataColumnSidecarProposerSignatureBlocks.inc();
|
|
180
|
+
}
|
|
175
181
|
chain.seenBlockInputCache.markVerifiedProposerSignature(blockHeader.slot, blockRootHex, signature);
|
|
176
182
|
}
|
|
177
183
|
|
|
@@ -165,17 +165,23 @@ async function validateExecutionPayloadBid(
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
// [IGNORE]
|
|
169
|
-
// the
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
// [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
|
|
169
|
+
// Bids for the same slot and parent root are validated against the same state, so bids past the
|
|
170
|
+
// limit can be dropped before state regeneration and the other expensive validation steps.
|
|
171
|
+
const seenBids = chain.seenExecutionPayloadBids.get(
|
|
172
|
+
bid.slot,
|
|
173
|
+
bid.builderIndex,
|
|
174
|
+
bidParentBlockHash,
|
|
175
|
+
bidParentBlockRoot
|
|
176
|
+
);
|
|
177
|
+
if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
|
|
173
178
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
174
|
-
code: ExecutionPayloadBidErrorCode.
|
|
179
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
175
180
|
builderIndex: bid.builderIndex,
|
|
176
181
|
slot: bid.slot,
|
|
177
182
|
parentBlockRoot: bidParentBlockRoot,
|
|
178
183
|
parentBlockHash: bidParentBlockHash,
|
|
184
|
+
bidLimit: seenBids.limit,
|
|
179
185
|
});
|
|
180
186
|
}
|
|
181
187
|
|
|
@@ -366,6 +372,24 @@ async function validateExecutionPayloadBid(
|
|
|
366
372
|
});
|
|
367
373
|
}
|
|
368
374
|
|
|
375
|
+
// [IGNORE] The builder has not reached its bid limit for the tuple
|
|
376
|
+
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
|
|
377
|
+
// not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
|
|
378
|
+
const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
|
|
379
|
+
if (
|
|
380
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
381
|
+
0) >= bidLimit
|
|
382
|
+
) {
|
|
383
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
384
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
385
|
+
builderIndex: bid.builderIndex,
|
|
386
|
+
slot: bid.slot,
|
|
387
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
388
|
+
parentBlockHash: bidParentBlockHash,
|
|
389
|
+
bidLimit,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
369
393
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
370
394
|
// i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
|
|
371
395
|
if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
@@ -426,20 +450,24 @@ async function validateExecutionPayloadBid(
|
|
|
426
450
|
});
|
|
427
451
|
}
|
|
428
452
|
|
|
429
|
-
// Repeat the
|
|
430
|
-
// for the same builder and tuple from
|
|
431
|
-
if (
|
|
453
|
+
// Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
|
|
454
|
+
// for the same builder and tuple from all passing validation.
|
|
455
|
+
if (
|
|
456
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
457
|
+
0) >= bidLimit
|
|
458
|
+
) {
|
|
432
459
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
433
|
-
code: ExecutionPayloadBidErrorCode.
|
|
460
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
434
461
|
builderIndex: bid.builderIndex,
|
|
435
462
|
slot: bid.slot,
|
|
436
463
|
parentBlockRoot: bidParentBlockRoot,
|
|
437
464
|
parentBlockHash: bidParentBlockHash,
|
|
465
|
+
bidLimit,
|
|
438
466
|
});
|
|
439
467
|
}
|
|
440
468
|
|
|
441
469
|
// Valid
|
|
442
|
-
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
|
|
470
|
+
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
|
|
443
471
|
|
|
444
472
|
return {proposerIndex: proposerPreferences.message.validatorIndex};
|
|
445
473
|
}
|