@lodestar/beacon-node 1.43.0-dev.3d6ae250a4 → 1.43.0-dev.4358217e12
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 +6 -5
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.js +1 -1
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +6 -3
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +18 -6
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +42 -18
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts +5 -3
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +28 -9
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
- package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
- package/lib/chain/blocks/types.d.ts +2 -2
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts +23 -2
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +81 -12
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +3 -2
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +30 -5
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +15 -4
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
- package/lib/chain/chain.d.ts +3 -2
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +10 -4
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +8 -1
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +2 -0
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/index.d.ts +1 -0
- package/lib/chain/errors/index.d.ts.map +1 -1
- package/lib/chain/errors/index.js +1 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/errors/proposerPreferences.d.ts +33 -0
- package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
- package/lib/chain/errors/proposerPreferences.js +13 -0
- package/lib/chain/errors/proposerPreferences.js.map +1 -0
- package/lib/chain/interface.d.ts +3 -2
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +2 -2
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +4 -4
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +9 -4
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +1 -0
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/interface.js +1 -0
- package/lib/chain/regen/interface.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/seenProposerPreferences.d.ts +15 -0
- package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
- package/lib/chain/seenCache/seenProposerPreferences.js +25 -0
- package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +1 -0
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/proposerPreferences.d.ts +8 -0
- package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
- package/lib/chain/validation/proposerPreferences.js +69 -0
- package/lib/chain/validation/proposerPreferences.js.map +1 -0
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +4 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/interface.d.ts +7 -1
- package/lib/network/gossip/interface.d.ts.map +1 -1
- package/lib/network/gossip/interface.js +1 -0
- package/lib/network/gossip/interface.js.map +1 -1
- package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
- package/lib/network/gossip/scoringParameters.js +12 -1
- package/lib/network/gossip/scoringParameters.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +27 -766
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +6 -0
- 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 +10 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
- package/lib/network/processor/gossipQueues/index.js +5 -0
- package/lib/network/processor/gossipQueues/index.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +1 -0
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/node/notifier.js +7 -1
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/range/batch.d.ts +12 -2
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +56 -30
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +6 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +4 -3
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +17 -6
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/types.d.ts +34 -0
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +34 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +24 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +649 -53
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +46 -10
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +147 -24
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +6 -2
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
- package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
- package/lib/sync/utils/pendingBlocksTree.js +0 -9
- package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +8 -5
- package/src/api/impl/lodestar/index.ts +1 -1
- package/src/chain/blocks/importBlock.ts +4 -2
- package/src/chain/blocks/importExecutionPayload.ts +48 -19
- package/src/chain/blocks/index.ts +44 -12
- package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
- package/src/chain/blocks/types.ts +2 -2
- package/src/chain/blocks/utils/chainSegment.ts +106 -17
- package/src/chain/blocks/verifyBlock.ts +35 -6
- package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -7
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +2 -2
- package/src/chain/chain.ts +14 -3
- package/src/chain/errors/blockError.ts +4 -1
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/errors/proposerPreferences.ts +39 -0
- package/src/chain/interface.ts +7 -1
- package/src/chain/opPools/payloadAttestationPool.ts +4 -8
- package/src/chain/produceBlock/produceBlockBody.ts +12 -4
- package/src/chain/regen/interface.ts +1 -0
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenProposerPreferences.ts +29 -0
- package/src/chain/validation/block.ts +1 -0
- package/src/chain/validation/proposerPreferences.ts +91 -0
- package/src/metrics/metrics/lodestar.ts +4 -0
- package/src/network/gossip/interface.ts +6 -0
- package/src/network/gossip/scoringParameters.ts +14 -1
- package/src/network/gossip/topic.ts +6 -0
- package/src/network/processor/gossipHandlers.ts +15 -6
- package/src/network/processor/gossipQueues/index.ts +5 -0
- package/src/network/processor/index.ts +1 -0
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
- package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
- package/src/node/notifier.ts +8 -1
- package/src/sync/range/batch.ts +90 -35
- package/src/sync/range/chain.ts +13 -5
- package/src/sync/range/range.ts +18 -6
- package/src/sync/types.ts +72 -0
- package/src/sync/unknownBlock.ts +810 -57
- package/src/sync/utils/downloadByRange.ts +256 -39
- package/src/sync/utils/downloadByRoot.ts +12 -2
- package/src/sync/utils/pendingBlocksTree.ts +0 -15
|
@@ -74,6 +74,8 @@ export enum BlockErrorCode {
|
|
|
74
74
|
PARENT_EXECUTION_INVALID = "BLOCK_ERROR_PARENT_EXECUTION_INVALID",
|
|
75
75
|
/** The block's parent execution payload (defined by bid.parent_block_hash) has not been seen */
|
|
76
76
|
PARENT_PAYLOAD_UNKNOWN = "BLOCK_ERROR_PARENT_PAYLOAD_UNKNOWN",
|
|
77
|
+
/** An execution payload envelope in the chain segment references a block root that does not match its slot's block */
|
|
78
|
+
ENVELOPE_BLOCK_ROOT_MISMATCH = "BLOCK_ERROR_ENVELOPE_BLOCK_ROOT_MISMATCH",
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
type ExecutionErrorStatus = Exclude<
|
|
@@ -107,6 +109,7 @@ export type BlockErrorType =
|
|
|
107
109
|
| {code: BlockErrorCode.NOT_LATER_THAN_PARENT; parentSlot: Slot; slot: Slot}
|
|
108
110
|
| {code: BlockErrorCode.NON_LINEAR_PARENT_ROOTS}
|
|
109
111
|
| {code: BlockErrorCode.NON_LINEAR_SLOTS}
|
|
112
|
+
| {code: BlockErrorCode.ENVELOPE_BLOCK_ROOT_MISMATCH; envelopeBlockRoot: RootHex; blockRoot: RootHex}
|
|
110
113
|
| {code: BlockErrorCode.PER_BLOCK_PROCESSING_ERROR; error: Error}
|
|
111
114
|
| {code: BlockErrorCode.BEACON_CHAIN_ERROR; error: Error}
|
|
112
115
|
| {code: BlockErrorCode.KNOWN_BAD_BLOCK}
|
|
@@ -120,7 +123,7 @@ export type BlockErrorType =
|
|
|
120
123
|
| {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number}
|
|
121
124
|
| {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex}
|
|
122
125
|
| {code: BlockErrorCode.PARENT_EXECUTION_INVALID; parentRoot: RootHex}
|
|
123
|
-
| {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentBlockHash: RootHex};
|
|
126
|
+
| {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentRoot: RootHex; parentBlockHash: RootHex};
|
|
124
127
|
|
|
125
128
|
export class BlockGossipError extends GossipActionError<BlockErrorType> {}
|
|
126
129
|
|
|
@@ -8,6 +8,7 @@ export * from "./executionPayloadBid.js";
|
|
|
8
8
|
export * from "./executionPayloadEnvelope.js";
|
|
9
9
|
export * from "./gossipValidation.js";
|
|
10
10
|
export * from "./payloadAttestation.js";
|
|
11
|
+
export * from "./proposerPreferences.js";
|
|
11
12
|
export * from "./proposerSlashingError.js";
|
|
12
13
|
export * from "./syncCommitteeError.js";
|
|
13
14
|
export * from "./voluntaryExitError.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {GossipActionError} from "./gossipValidation.js";
|
|
3
|
+
|
|
4
|
+
export enum ProposerPreferencesErrorCode {
|
|
5
|
+
INVALID_EPOCH = "PROPOSER_PREFERENCES_ERROR_INVALID_EPOCH",
|
|
6
|
+
PROPOSAL_SLOT_PASSED = "PROPOSER_PREFERENCES_ERROR_PROPOSAL_SLOT_PASSED",
|
|
7
|
+
INVALID_PROPOSER = "PROPOSER_PREFERENCES_ERROR_INVALID_PROPOSER",
|
|
8
|
+
ALREADY_KNOWN = "PROPOSER_PREFERENCES_ERROR_ALREADY_KNOWN",
|
|
9
|
+
INVALID_SIGNATURE = "PROPOSER_PREFERENCES_ERROR_INVALID_SIGNATURE",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ProposerPreferencesErrorType =
|
|
13
|
+
| {
|
|
14
|
+
code: ProposerPreferencesErrorCode.INVALID_EPOCH;
|
|
15
|
+
proposalSlot: Slot;
|
|
16
|
+
currentEpoch: number;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED;
|
|
20
|
+
proposalSlot: Slot;
|
|
21
|
+
currentSlot: Slot;
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
code: ProposerPreferencesErrorCode.INVALID_PROPOSER;
|
|
25
|
+
proposalSlot: Slot;
|
|
26
|
+
validatorIndex: ValidatorIndex;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
code: ProposerPreferencesErrorCode.ALREADY_KNOWN;
|
|
30
|
+
proposalSlot: Slot;
|
|
31
|
+
validatorIndex: ValidatorIndex;
|
|
32
|
+
}
|
|
33
|
+
| {
|
|
34
|
+
code: ProposerPreferencesErrorCode.INVALID_SIGNATURE;
|
|
35
|
+
proposalSlot: Slot;
|
|
36
|
+
validatorIndex: ValidatorIndex;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class ProposerPreferencesError extends GossipActionError<ProposerPreferencesErrorType> {}
|
package/src/chain/interface.ts
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
SeenContributionAndProof,
|
|
62
62
|
SeenExecutionPayloadBids,
|
|
63
63
|
SeenPayloadAttesters,
|
|
64
|
+
SeenProposerPreferences,
|
|
64
65
|
SeenSyncCommitteeMessages,
|
|
65
66
|
} from "./seenCache/index.js";
|
|
66
67
|
import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
|
|
@@ -131,6 +132,7 @@ export interface IBeaconChain {
|
|
|
131
132
|
readonly seenPayloadAttesters: SeenPayloadAttesters;
|
|
132
133
|
readonly seenAggregatedAttestations: SeenAggregatedAttestations;
|
|
133
134
|
readonly seenExecutionPayloadBids: SeenExecutionPayloadBids;
|
|
135
|
+
readonly seenProposerPreferences: SeenProposerPreferences;
|
|
134
136
|
readonly seenBlockProposers: SeenBlockProposers;
|
|
135
137
|
readonly seenSyncCommitteeMessages: SeenSyncCommitteeMessages;
|
|
136
138
|
readonly seenContributionAndProof: SeenContributionAndProof;
|
|
@@ -250,7 +252,11 @@ export interface IBeaconChain {
|
|
|
250
252
|
/** Process a block until complete */
|
|
251
253
|
processBlock(block: IBlockInput, opts?: ImportBlockOpts): Promise<void>;
|
|
252
254
|
/** Process a chain of blocks until complete */
|
|
253
|
-
processChainSegment(
|
|
255
|
+
processChainSegment(
|
|
256
|
+
blocks: IBlockInput[],
|
|
257
|
+
payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null,
|
|
258
|
+
opts?: ImportBlockOpts
|
|
259
|
+
): Promise<void>;
|
|
254
260
|
|
|
255
261
|
/** Process execution payload envelope: verify, import to fork choice, and persist to DB */
|
|
256
262
|
processExecutionPayload(payloadInput: PayloadEnvelopeInput, opts?: ImportPayloadOpts): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Signature, aggregateSignatures} from "@chainsafe/blst";
|
|
2
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
3
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
|
-
import {MAX_COMMITTEES_PER_SLOT, PTC_SIZE} from "@lodestar/params";
|
|
4
|
+
import {MAX_COMMITTEES_PER_SLOT, MAX_PAYLOAD_ATTESTATIONS, PTC_SIZE} from "@lodestar/params";
|
|
5
5
|
import {RootHex, Slot, gloas} from "@lodestar/types";
|
|
6
6
|
import {MapDef, toRootHex} from "@lodestar/utils";
|
|
7
7
|
import {Metrics} from "../../metrics/metrics.js";
|
|
@@ -95,13 +95,9 @@ export class PayloadAttestationPool {
|
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Get payload attestations to be included in a block.
|
|
98
|
-
* Pick the top `
|
|
98
|
+
* Pick the top `MAX_PAYLOAD_ATTESTATIONS` aggregates with the most votes.
|
|
99
99
|
*/
|
|
100
|
-
getPayloadAttestationsForBlock(
|
|
101
|
-
beaconBlockRoot: BlockRootHex,
|
|
102
|
-
slot: Slot,
|
|
103
|
-
maxAttestation: number
|
|
104
|
-
): gloas.PayloadAttestation[] {
|
|
100
|
+
getPayloadAttestationsForBlock(beaconBlockRoot: BlockRootHex, slot: Slot): gloas.PayloadAttestation[] {
|
|
105
101
|
const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.get(slot);
|
|
106
102
|
|
|
107
103
|
if (!aggregateByDataRootByBlockRoot) {
|
|
@@ -119,7 +115,7 @@ export class PayloadAttestationPool {
|
|
|
119
115
|
return Array.from(aggregateByDataRoot.values())
|
|
120
116
|
.slice()
|
|
121
117
|
.sort((a, b) => b.aggregationBits.getTrueBitIndexes().length - a.aggregationBits.getTrueBitIndexes().length)
|
|
122
|
-
.slice(0,
|
|
118
|
+
.slice(0, MAX_PAYLOAD_ATTESTATIONS)
|
|
123
119
|
.map(fastToPayloadAttestation);
|
|
124
120
|
}
|
|
125
121
|
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
ssz,
|
|
50
50
|
} from "@lodestar/types";
|
|
51
51
|
import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
|
|
52
|
-
import {ZERO_HASH_HEX} from "../../constants/index.js";
|
|
52
|
+
import {ZERO_HASH, ZERO_HASH_HEX} from "../../constants/index.js";
|
|
53
53
|
import {numToQuantity} from "../../execution/engine/utils.js";
|
|
54
54
|
import {
|
|
55
55
|
IExecutionBuilder,
|
|
@@ -215,9 +215,15 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
215
215
|
|
|
216
216
|
// Get execution payload from EL
|
|
217
217
|
const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
|
|
218
|
-
|
|
218
|
+
let parentBlockHash = isExtendingPayload
|
|
219
219
|
? currentState.latestExecutionPayloadBid.blockHash
|
|
220
220
|
: currentState.latestExecutionPayloadBid.parentBlockHash;
|
|
221
|
+
// At gloas genesis the committed bid has no prior EL block to reference
|
|
222
|
+
// (`bid.parentBlockHash` is zero). Fall back to `bid.blockHash` (= eth1 genesis hash) so the
|
|
223
|
+
// FCU to the EL carries a valid head. Post-genesis bids always reference a non-zero parent.
|
|
224
|
+
if (isStatePostGloas(currentState) && byteArrayEquals(parentBlockHash, ZERO_HASH)) {
|
|
225
|
+
parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
|
|
226
|
+
}
|
|
221
227
|
const parentExecutionRequests = isExtendingPayload
|
|
222
228
|
? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
|
|
223
229
|
: ssz.electra.ExecutionRequests.defaultValue();
|
|
@@ -285,8 +291,10 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
285
291
|
const commonBlockBody = await commonBlockBodyPromise;
|
|
286
292
|
const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
|
|
287
293
|
gloasBody.signedExecutionPayloadBid = signedBid;
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
gloasBody.payloadAttestations = this.payloadAttestationPool.getPayloadAttestationsForBlock(
|
|
295
|
+
parentBlock.blockRoot,
|
|
296
|
+
blockSlot - 1
|
|
297
|
+
);
|
|
290
298
|
gloasBody.parentExecutionRequests = parentExecutionRequests;
|
|
291
299
|
blockBody = gloasBody as AssembledBodyType<T>;
|
|
292
300
|
|
|
@@ -21,6 +21,7 @@ export enum RegenCaller {
|
|
|
21
21
|
validateGossipAttestation = "validateGossipAttestation",
|
|
22
22
|
validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
|
|
23
23
|
validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
|
|
24
|
+
validateGossipProposerPreferences = "validateGossipProposerPreferences",
|
|
24
25
|
onForkChoiceFinalized = "onForkChoiceFinalized",
|
|
25
26
|
restApi = "restApi",
|
|
26
27
|
}
|
|
@@ -5,3 +5,4 @@ export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
|
|
|
5
5
|
export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
|
|
6
6
|
export {SeenBlockInput} from "./seenGossipBlockInput.js";
|
|
7
7
|
export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
|
|
8
|
+
export {SeenProposerPreferences} from "./seenProposerPreferences.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {Slot, ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
import {MapDef} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tracks signed proposer preferences we've already seen per (proposal_slot, validator_index).
|
|
6
|
+
*/
|
|
7
|
+
export class SeenProposerPreferences {
|
|
8
|
+
private readonly validatorIndexesBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set<ValidatorIndex>());
|
|
9
|
+
|
|
10
|
+
isKnown(proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
|
|
11
|
+
return this.validatorIndexesBySlot.get(proposalSlot)?.has(validatorIndex) === true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
add(proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
|
|
15
|
+
this.validatorIndexesBySlot.getOrDefault(proposalSlot).add(validatorIndex);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Entries are only load-bearing while `proposal_slot > state.slot`. Once the slot has passed the
|
|
20
|
+
* `[IGNORE] proposal_slot > state.slot` gossip rule takes over, so drop them on each slot tick.
|
|
21
|
+
*/
|
|
22
|
+
prune(currentSlot: Slot): void {
|
|
23
|
+
for (const slot of this.validatorIndexesBySlot.keys()) {
|
|
24
|
+
if (slot < currentSlot) {
|
|
25
|
+
this.validatorIndexesBySlot.delete(slot);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -103,6 +103,7 @@ export async function validateGossipBlock(
|
|
|
103
103
|
if (chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex) === null) {
|
|
104
104
|
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
105
105
|
code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
|
|
106
|
+
parentRoot,
|
|
106
107
|
parentBlockHash: parentBlockHashHex,
|
|
107
108
|
});
|
|
108
109
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
+
import {
|
|
3
|
+
computeEpochAtSlot,
|
|
4
|
+
createSingleSignatureSetFromComponents,
|
|
5
|
+
getProposerPreferencesSigningRoot,
|
|
6
|
+
isStatePostGloas,
|
|
7
|
+
} from "@lodestar/state-transition";
|
|
8
|
+
import {gloas} from "@lodestar/types";
|
|
9
|
+
import {GossipAction, ProposerPreferencesError, ProposerPreferencesErrorCode} from "../errors/index.js";
|
|
10
|
+
import {IBeaconChain} from "../index.js";
|
|
11
|
+
import {RegenCaller} from "../regen/index.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validates a gossiped `SignedProposerPreferences` per
|
|
15
|
+
* https://github.com/ethereum/consensus-specs/blob/master/specs/gloas/p2p-interface.md#proposer_preferences
|
|
16
|
+
*/
|
|
17
|
+
export async function validateGossipProposerPreferences(
|
|
18
|
+
chain: IBeaconChain,
|
|
19
|
+
signedProposerPreferences: gloas.SignedProposerPreferences
|
|
20
|
+
): Promise<void> {
|
|
21
|
+
const preferences = signedProposerPreferences.message;
|
|
22
|
+
const {proposalSlot, validatorIndex} = preferences;
|
|
23
|
+
const proposalEpoch = computeEpochAtSlot(proposalSlot);
|
|
24
|
+
|
|
25
|
+
// [IGNORE] `preferences.proposal_slot` is in the current or next epoch.
|
|
26
|
+
const currentEpoch = chain.clock.currentEpoch;
|
|
27
|
+
if (proposalEpoch < currentEpoch || proposalEpoch > currentEpoch + 1) {
|
|
28
|
+
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
29
|
+
code: ProposerPreferencesErrorCode.INVALID_EPOCH,
|
|
30
|
+
proposalSlot,
|
|
31
|
+
currentEpoch,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// [IGNORE] `preferences.proposal_slot` has not already passed.
|
|
36
|
+
const currentSlot = chain.clock.currentSlot;
|
|
37
|
+
if (proposalSlot <= currentSlot) {
|
|
38
|
+
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
39
|
+
code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED,
|
|
40
|
+
proposalSlot,
|
|
41
|
+
currentSlot,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipProposerPreferences);
|
|
46
|
+
if (!isStatePostGloas(state)) {
|
|
47
|
+
throw new Error(`Expected gloas+ state for proposer preferences validation, got fork=${state.forkName}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// [REJECT] `preferences.validator_index` is present at the correct slot in the current or next
|
|
51
|
+
// epoch's portion of `state.proposer_lookahead` — i.e. `is_valid_proposal_slot(state, preferences)`
|
|
52
|
+
// returns True.
|
|
53
|
+
const epochOffset = proposalEpoch - state.epoch;
|
|
54
|
+
const proposers = epochOffset === 0 ? state.currentProposers : state.nextProposers;
|
|
55
|
+
const expectedProposer = proposers[proposalSlot % SLOTS_PER_EPOCH];
|
|
56
|
+
if (epochOffset < 0 || epochOffset > 1 || expectedProposer !== validatorIndex) {
|
|
57
|
+
throw new ProposerPreferencesError(GossipAction.REJECT, {
|
|
58
|
+
code: ProposerPreferencesErrorCode.INVALID_PROPOSER,
|
|
59
|
+
proposalSlot,
|
|
60
|
+
validatorIndex,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// [IGNORE] The `signed_proposer_preferences` is the first valid message received from the validator
|
|
65
|
+
// with index `preferences.validator_index` and the given slot `preferences.proposal_slot`.
|
|
66
|
+
if (chain.seenProposerPreferences.isKnown(proposalSlot, validatorIndex)) {
|
|
67
|
+
throw new ProposerPreferencesError(GossipAction.IGNORE, {
|
|
68
|
+
code: ProposerPreferencesErrorCode.ALREADY_KNOWN,
|
|
69
|
+
proposalSlot,
|
|
70
|
+
validatorIndex,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// [REJECT] `signed_proposer_preferences.signature` is valid with respect to the validator's public key.
|
|
75
|
+
const signatureSet = createSingleSignatureSetFromComponents(
|
|
76
|
+
chain.pubkeyCache.getOrThrow(validatorIndex),
|
|
77
|
+
getProposerPreferencesSigningRoot(chain.config, preferences),
|
|
78
|
+
signedProposerPreferences.signature
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true}))) {
|
|
82
|
+
throw new ProposerPreferencesError(GossipAction.REJECT, {
|
|
83
|
+
code: ProposerPreferencesErrorCode.INVALID_SIGNATURE,
|
|
84
|
+
proposalSlot,
|
|
85
|
+
validatorIndex,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Valid
|
|
90
|
+
chain.seenProposerPreferences.add(proposalSlot, validatorIndex);
|
|
91
|
+
}
|
|
@@ -613,6 +613,10 @@ export function createLodestarMetrics(
|
|
|
613
613
|
name: "lodestar_sync_unknown_block_pending_blocks_size",
|
|
614
614
|
help: "Current size of UnknownBlockSync pending blocks cache",
|
|
615
615
|
}),
|
|
616
|
+
pendingPayloads: register.gauge({
|
|
617
|
+
name: "lodestar_sync_unknown_block_pending_payloads_size",
|
|
618
|
+
help: "Current size of UnknownBlockSync pending payloads cache",
|
|
619
|
+
}),
|
|
616
620
|
knownBadBlocks: register.gauge({
|
|
617
621
|
name: "lodestar_sync_unknown_block_known_bad_blocks_size",
|
|
618
622
|
help: "Current size of UnknownBlockSync known bad blocks cache",
|
|
@@ -41,6 +41,7 @@ export enum GossipType {
|
|
|
41
41
|
execution_payload = "execution_payload",
|
|
42
42
|
payload_attestation_message = "payload_attestation_message",
|
|
43
43
|
execution_payload_bid = "execution_payload_bid",
|
|
44
|
+
proposer_preferences = "proposer_preferences",
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export type SequentialGossipType = Exclude<GossipType, GossipType.beacon_attestation>;
|
|
@@ -78,6 +79,7 @@ export type GossipTopicTypeMap = {
|
|
|
78
79
|
[GossipType.execution_payload]: {type: GossipType.execution_payload};
|
|
79
80
|
[GossipType.payload_attestation_message]: {type: GossipType.payload_attestation_message};
|
|
80
81
|
[GossipType.execution_payload_bid]: {type: GossipType.execution_payload_bid};
|
|
82
|
+
[GossipType.proposer_preferences]: {type: GossipType.proposer_preferences};
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
export type GossipTopicMap = {
|
|
@@ -110,6 +112,7 @@ export type GossipTypeMap = {
|
|
|
110
112
|
[GossipType.execution_payload]: gloas.SignedExecutionPayloadEnvelope;
|
|
111
113
|
[GossipType.payload_attestation_message]: gloas.PayloadAttestationMessage;
|
|
112
114
|
[GossipType.execution_payload_bid]: gloas.SignedExecutionPayloadBid;
|
|
115
|
+
[GossipType.proposer_preferences]: gloas.SignedProposerPreferences;
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
export type GossipFnByType = {
|
|
@@ -141,6 +144,9 @@ export type GossipFnByType = {
|
|
|
141
144
|
payloadAttestationMessage: gloas.PayloadAttestationMessage
|
|
142
145
|
) => Promise<void> | void;
|
|
143
146
|
[GossipType.execution_payload_bid]: (executionPayloadBid: gloas.SignedExecutionPayloadBid) => Promise<void> | void;
|
|
147
|
+
[GossipType.proposer_preferences]: (
|
|
148
|
+
signedProposerPreferences: gloas.SignedProposerPreferences
|
|
149
|
+
) => Promise<void> | void;
|
|
144
150
|
};
|
|
145
151
|
|
|
146
152
|
export type GossipFn = GossipFnByType[keyof GossipFnByType];
|
|
@@ -27,6 +27,7 @@ const BLS_TO_EXECUTION_CHANGE_WEIGHT = 0.05;
|
|
|
27
27
|
const EXECUTION_PAYLOAD_WEIGHT = 0.5;
|
|
28
28
|
const PAYLOAD_ATTESTATION_WEIGHT = 0.05;
|
|
29
29
|
const EXECUTION_PAYLOAD_BID_WEIGHT = 0.05;
|
|
30
|
+
const PROPOSER_PREFERENCES_WEIGHT = 0.05;
|
|
30
31
|
|
|
31
32
|
const beaconAttestationSubnetWeight = 1 / ATTESTATION_SUBNET_COUNT;
|
|
32
33
|
const maxPositiveScore =
|
|
@@ -40,7 +41,8 @@ const maxPositiveScore =
|
|
|
40
41
|
BLS_TO_EXECUTION_CHANGE_WEIGHT +
|
|
41
42
|
EXECUTION_PAYLOAD_WEIGHT +
|
|
42
43
|
PAYLOAD_ATTESTATION_WEIGHT +
|
|
43
|
-
EXECUTION_PAYLOAD_BID_WEIGHT
|
|
44
|
+
EXECUTION_PAYLOAD_BID_WEIGHT +
|
|
45
|
+
PROPOSER_PREFERENCES_WEIGHT);
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* The following params is implemented by Lighthouse at
|
|
@@ -198,6 +200,17 @@ function getAllTopicsScoreParams(
|
|
|
198
200
|
expectedMessageRate: 1024, // TODO GLOAS: Need an estimate for this
|
|
199
201
|
firstMessageDecayTime: epochDurationMs * 100,
|
|
200
202
|
});
|
|
203
|
+
topicsParams[
|
|
204
|
+
stringifyGossipTopic(config, {
|
|
205
|
+
type: GossipType.proposer_preferences,
|
|
206
|
+
boundary,
|
|
207
|
+
})
|
|
208
|
+
] = getTopicScoreParams(config, precomputedParams, {
|
|
209
|
+
topicWeight: PROPOSER_PREFERENCES_WEIGHT,
|
|
210
|
+
// Upper bound ~64 messages per epoch: one per proposer across the current + next epoch.
|
|
211
|
+
expectedMessageRate: 64 / SLOTS_PER_EPOCH,
|
|
212
|
+
firstMessageDecayTime: epochDurationMs * 100,
|
|
213
|
+
});
|
|
201
214
|
|
|
202
215
|
// other topics
|
|
203
216
|
topicsParams[
|
|
@@ -73,6 +73,7 @@ function stringifyGossipTopicType(topic: GossipTopic): string {
|
|
|
73
73
|
case GossipType.execution_payload:
|
|
74
74
|
case GossipType.payload_attestation_message:
|
|
75
75
|
case GossipType.execution_payload_bid:
|
|
76
|
+
case GossipType.proposer_preferences:
|
|
76
77
|
return topic.type;
|
|
77
78
|
case GossipType.beacon_attestation:
|
|
78
79
|
case GossipType.sync_committee:
|
|
@@ -124,6 +125,8 @@ export function getGossipSSZType(topic: GossipTopic) {
|
|
|
124
125
|
return ssz.gloas.PayloadAttestationMessage;
|
|
125
126
|
case GossipType.execution_payload_bid:
|
|
126
127
|
return ssz.gloas.SignedExecutionPayloadBid;
|
|
128
|
+
case GossipType.proposer_preferences:
|
|
129
|
+
return ssz.gloas.SignedProposerPreferences;
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
|
|
@@ -203,6 +206,7 @@ export function parseGossipTopic(forkDigestContext: ForkDigestContext, topicStr:
|
|
|
203
206
|
case GossipType.execution_payload:
|
|
204
207
|
case GossipType.payload_attestation_message:
|
|
205
208
|
case GossipType.execution_payload_bid:
|
|
209
|
+
case GossipType.proposer_preferences:
|
|
206
210
|
return {type: gossipTypeStr, boundary, encoding};
|
|
207
211
|
}
|
|
208
212
|
|
|
@@ -257,6 +261,7 @@ export function getCoreTopicsAtFork(
|
|
|
257
261
|
topics.push({type: GossipType.execution_payload});
|
|
258
262
|
topics.push({type: GossipType.payload_attestation_message});
|
|
259
263
|
topics.push({type: GossipType.execution_payload_bid});
|
|
264
|
+
topics.push({type: GossipType.proposer_preferences});
|
|
260
265
|
}
|
|
261
266
|
|
|
262
267
|
// After fulu also track data_column_sidecar_{index}
|
|
@@ -351,4 +356,5 @@ export const gossipTopicIgnoreDuplicatePublishError: Record<GossipType, boolean>
|
|
|
351
356
|
[GossipType.execution_payload]: true,
|
|
352
357
|
[GossipType.payload_attestation_message]: true,
|
|
353
358
|
[GossipType.execution_payload_bid]: true,
|
|
359
|
+
[GossipType.proposer_preferences]: true,
|
|
354
360
|
};
|
|
@@ -79,6 +79,7 @@ import {
|
|
|
79
79
|
import {validateLightClientFinalityUpdate} from "../../chain/validation/lightClientFinalityUpdate.js";
|
|
80
80
|
import {validateLightClientOptimisticUpdate} from "../../chain/validation/lightClientOptimisticUpdate.js";
|
|
81
81
|
import {validateGossipPayloadAttestationMessage} from "../../chain/validation/payloadAttestationMessage.js";
|
|
82
|
+
import {validateGossipProposerPreferences} from "../../chain/validation/proposerPreferences.js";
|
|
82
83
|
import {OpSource} from "../../chain/validatorMonitor.js";
|
|
83
84
|
import {Metrics} from "../../metrics/index.js";
|
|
84
85
|
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
|
|
@@ -198,7 +199,10 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
198
199
|
} catch (e) {
|
|
199
200
|
if (e instanceof BlockGossipError) {
|
|
200
201
|
logger.debug("Gossip block has error", {slot, root: blockShortHex, code: e.type.code});
|
|
201
|
-
if (
|
|
202
|
+
if (
|
|
203
|
+
(e.type.code === BlockErrorCode.PARENT_UNKNOWN || e.type.code === BlockErrorCode.PARENT_PAYLOAD_UNKNOWN) &&
|
|
204
|
+
blockInput
|
|
205
|
+
) {
|
|
202
206
|
chain.emitter.emit(ChainEvent.blockUnknownParent, {
|
|
203
207
|
blockInput,
|
|
204
208
|
peer: peerIdStr,
|
|
@@ -1057,10 +1061,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1057
1061
|
const signedEnvelope = sszDeserialize(topic, serializedData);
|
|
1058
1062
|
const envelope = signedEnvelope.message;
|
|
1059
1063
|
|
|
1060
|
-
//
|
|
1061
|
-
//
|
|
1062
|
-
// the problem now is we cannot create a PayloadEnvelopeInput without the beacon block being known, we need at least the proposer index
|
|
1063
|
-
// we can achieve that by looking into the EpochCache
|
|
1064
|
+
// unlike BlockInput, we send the envelope into UnknownBlockInput sync
|
|
1065
|
+
// inside the sync it'll reconcile into PayloadEnvelopeInput and share the same cache with gossip
|
|
1064
1066
|
try {
|
|
1065
1067
|
await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope);
|
|
1066
1068
|
} catch (e) {
|
|
@@ -1069,7 +1071,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1069
1071
|
const slot = signedEnvelope.message.payload.slotNumber;
|
|
1070
1072
|
logger.debug("Gossip envelope has error", {slot, root: toRootHex(beaconBlockRoot), code: e.type.code});
|
|
1071
1073
|
if (e.type.code === ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN) {
|
|
1072
|
-
// TODO GLOAS: UnknownBlockSync to handle this
|
|
1073
1074
|
chain.emitter.emit(ChainEvent.envelopeUnknownBlock, {
|
|
1074
1075
|
envelope: signedEnvelope,
|
|
1075
1076
|
peer: peerIdStr,
|
|
@@ -1170,6 +1171,14 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1170
1171
|
data: executionPayloadBid,
|
|
1171
1172
|
});
|
|
1172
1173
|
},
|
|
1174
|
+
[GossipType.proposer_preferences]: async ({
|
|
1175
|
+
gossipData,
|
|
1176
|
+
topic,
|
|
1177
|
+
}: GossipHandlerParamGeneric<GossipType.proposer_preferences>) => {
|
|
1178
|
+
const {serializedData} = gossipData;
|
|
1179
|
+
const signedProposerPreferences = sszDeserialize(topic, serializedData);
|
|
1180
|
+
await validateGossipProposerPreferences(chain, signedProposerPreferences);
|
|
1181
|
+
},
|
|
1173
1182
|
};
|
|
1174
1183
|
}
|
|
1175
1184
|
|
|
@@ -83,6 +83,11 @@ const linearGossipQueueOpts: {
|
|
|
83
83
|
type: QueueType.FIFO,
|
|
84
84
|
dropOpts: {type: DropType.count, count: 1},
|
|
85
85
|
},
|
|
86
|
+
[GossipType.proposer_preferences]: {
|
|
87
|
+
maxLength: 1024,
|
|
88
|
+
type: QueueType.FIFO,
|
|
89
|
+
dropOpts: {type: DropType.count, count: 1},
|
|
90
|
+
},
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
const indexedGossipQueueOpts: {
|
|
@@ -91,6 +91,7 @@ const executeGossipWorkOrderObj: Record<GossipType, WorkOpts> = {
|
|
|
91
91
|
[GossipType.execution_payload]: {bypassQueue: true},
|
|
92
92
|
[GossipType.payload_attestation_message]: {},
|
|
93
93
|
[GossipType.execution_payload_bid]: {},
|
|
94
|
+
[GossipType.proposer_preferences]: {},
|
|
94
95
|
};
|
|
95
96
|
const executeGossipWorkOrder = Object.keys(executeGossipWorkOrderObj) as (keyof typeof executeGossipWorkOrderObj)[];
|
|
96
97
|
|
|
@@ -24,6 +24,10 @@ export async function* onBeaconBlocksByRange(
|
|
|
24
24
|
// in the case of initializing from a non-finalized state, we don't have the finalized block so this api does not work
|
|
25
25
|
// chain.forkChoice.getFinalizeBlock().slot
|
|
26
26
|
const finalizedSlot = chain.forkChoice.getFinalizedCheckpointSlot();
|
|
27
|
+
// Blocks are migrated to blockArchive at finalization (including the finalized block itself),
|
|
28
|
+
// so the archive loop serves up to AND INCLUDING finalizedSlot and the headChain loop
|
|
29
|
+
// starts above it to avoid duplicate yields. See archiveBlocks.ts for the migration logic.
|
|
30
|
+
const archiveMaxSlot = finalizedSlot;
|
|
27
31
|
|
|
28
32
|
const forkName = chain.config.getForkName(startSlot);
|
|
29
33
|
if (isForkPostFulu(forkName) && startSlot < chain.earliestAvailableSlot) {
|
|
@@ -35,9 +39,12 @@ export async function* onBeaconBlocksByRange(
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
// Finalized range of blocks
|
|
38
|
-
if (startSlot <=
|
|
42
|
+
if (startSlot <= archiveMaxSlot) {
|
|
39
43
|
// Chain of blobs won't change
|
|
40
|
-
for await (const {key, value} of finalized.binaryEntriesStream({
|
|
44
|
+
for await (const {key, value} of finalized.binaryEntriesStream({
|
|
45
|
+
gte: startSlot,
|
|
46
|
+
lt: Math.min(endSlot, archiveMaxSlot + 1),
|
|
47
|
+
})) {
|
|
41
48
|
yield {
|
|
42
49
|
data: value,
|
|
43
50
|
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(finalized.decodeKey(key))),
|
|
@@ -46,19 +53,20 @@ export async function* onBeaconBlocksByRange(
|
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
// Non-finalized range of blocks
|
|
49
|
-
if (endSlot >
|
|
56
|
+
if (endSlot > archiveMaxSlot) {
|
|
50
57
|
const headBlock = chain.forkChoice.getHead();
|
|
51
58
|
const headRoot = headBlock.blockRoot;
|
|
52
59
|
// TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
|
|
53
60
|
const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
|
|
54
|
-
// getAllAncestorBlocks
|
|
61
|
+
// `getAllAncestorBlocks` includes both the head and the previous-finalized boundary.
|
|
55
62
|
|
|
56
63
|
// Iterate head chain with ascending block numbers
|
|
57
64
|
for (let i = headChain.length - 1; i >= 0; i--) {
|
|
58
65
|
const block = headChain[i];
|
|
59
66
|
|
|
60
|
-
// Must include only blocks in the range requested
|
|
61
|
-
|
|
67
|
+
// Must include only blocks in the range requested, and skip anything the archive loop
|
|
68
|
+
// above already served via the block.slot > archiveMaxSlot filter.
|
|
69
|
+
if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
|
|
62
70
|
// Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
|
|
63
71
|
// at the time of the start of the request. Spec is clear the chain of blobs must be consistent, but on
|
|
64
72
|
// re-org there's no need to abort the request
|
|
@@ -20,31 +20,37 @@ export async function* onBlobSidecarsByRange(
|
|
|
20
20
|
const finalized = db.blobSidecarsArchive;
|
|
21
21
|
const unfinalized = db.blobSidecars;
|
|
22
22
|
const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
|
|
23
|
+
// Blobs are migrated to blobSidecarsArchive at finalization (including the finalized block
|
|
24
|
+
// itself), so the archive loop serves up to AND INCLUDING finalizedSlot and the headChain
|
|
25
|
+
// loop starts above it to avoid duplicate yields. See archiveBlocks.ts for the migration logic.
|
|
26
|
+
const archiveMaxSlot = finalizedSlot;
|
|
23
27
|
|
|
24
28
|
// Finalized range of blobs
|
|
25
|
-
if (startSlot <=
|
|
29
|
+
if (startSlot <= archiveMaxSlot) {
|
|
26
30
|
// Chain of blobs won't change
|
|
27
31
|
for await (const {key, value: blobSideCarsBytesWrapped} of finalized.binaryEntriesStream({
|
|
28
32
|
gte: startSlot,
|
|
29
|
-
lt: endSlot,
|
|
33
|
+
lt: Math.min(endSlot, archiveMaxSlot + 1),
|
|
30
34
|
})) {
|
|
31
35
|
yield* iterateBlobBytesFromWrapper(chain, blobSideCarsBytesWrapped, finalized.decodeKey(key));
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
// Non-finalized range of blobs
|
|
36
|
-
if (endSlot >
|
|
40
|
+
if (endSlot > archiveMaxSlot) {
|
|
37
41
|
const headBlock = chain.forkChoice.getHead();
|
|
38
42
|
const headRoot = headBlock.blockRoot;
|
|
39
43
|
// TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
|
|
40
44
|
const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
|
|
45
|
+
// `getAllAncestorBlocks` includes both the head and the previous-finalized boundary.
|
|
41
46
|
|
|
42
47
|
// Iterate head chain with ascending block numbers
|
|
43
48
|
for (let i = headChain.length - 1; i >= 0; i--) {
|
|
44
49
|
const block = headChain[i];
|
|
45
50
|
|
|
46
|
-
// Must include only blobs in the range requested
|
|
47
|
-
|
|
51
|
+
// Must include only blobs in the range requested, and skip anything the archive loop
|
|
52
|
+
// above already served via the block.slot > archiveMaxSlot filter.
|
|
53
|
+
if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
|
|
48
54
|
// Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
|
|
49
55
|
// at the time of the start of the request. Spec is clear the chain of blobs must be consistent, but on
|
|
50
56
|
// re-org there's no need to abort the request
|