@lodestar/beacon-node 1.43.0-dev.38479366cc → 1.43.0-dev.38cd4b01e7
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 +13 -3
- 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 +45 -2
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +0 -1
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +68 -2
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js +4 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +16 -31
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +9 -3
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +37 -15
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +35 -21
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
- package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
- package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
- package/lib/chain/blocks/types.d.ts +2 -1
- package/lib/chain/blocks/types.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.d.ts +1 -3
- package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
- package/lib/chain/blocks/utils/chainSegment.js +34 -23
- package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts +2 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +30 -12
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSanityChecks.js +16 -7
- package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +10 -6
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
- package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
- package/lib/chain/blocks/verifyPayloadsDataAvailability.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 +28 -9
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +0 -11
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +0 -4
- package/lib/chain/emitter.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 +40 -0
- package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
- package/lib/chain/errors/proposerPreferences.js +14 -0
- package/lib/chain/errors/proposerPreferences.js.map +1 -0
- package/lib/chain/initState.d.ts.map +1 -1
- package/lib/chain/initState.js +6 -1
- package/lib/chain/initState.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/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +1 -1
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.d.ts +4 -3
- package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/payloadAttestationPool.js +56 -14
- package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +16 -18
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +12 -3
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +34 -22
- 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/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +1 -4
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +1 -4
- package/lib/chain/regen/regen.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/seenPayloadEnvelopeInput.d.ts +21 -11
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +70 -20
- package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
- package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
- package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
- package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
- package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
- package/lib/chain/validation/executionPayloadBid.js +11 -8
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts +1 -1
- package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +5 -3
- package/lib/chain/validation/payloadAttestationMessage.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 +91 -0
- package/lib/chain/validation/proposerPreferences.js.map +1 -0
- package/lib/metrics/metrics/lodestar.d.ts +4 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -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 +10 -0
- 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/interface.d.ts +2 -0
- package/lib/network/interface.d.ts.map +1 -1
- package/lib/network/network.d.ts +2 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +8 -0
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +69 -18
- 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 +6 -5
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
- package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
- package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
- package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +5 -0
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/interface.d.ts +1 -1
- package/lib/network/reqresp/interface.js +1 -1
- package/lib/network/reqresp/protocols.d.ts +1 -0
- package/lib/network/reqresp/protocols.d.ts.map +1 -1
- package/lib/network/reqresp/protocols.js +5 -0
- package/lib/network/reqresp/protocols.js.map +1 -1
- package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
- package/lib/network/reqresp/rateLimit.js +4 -0
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/reqresp/score.d.ts.map +1 -1
- package/lib/network/reqresp/score.js +1 -0
- package/lib/network/reqresp/score.js.map +1 -1
- package/lib/network/reqresp/types.d.ts +3 -0
- package/lib/network/reqresp/types.d.ts.map +1 -1
- package/lib/network/reqresp/types.js +3 -0
- package/lib/network/reqresp/types.js.map +1 -1
- package/lib/node/nodejs.js +2 -2
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.js +1 -7
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/constants.d.ts +7 -1
- package/lib/sync/constants.d.ts.map +1 -1
- package/lib/sync/constants.js +7 -4
- package/lib/sync/constants.js.map +1 -1
- package/lib/sync/range/batch.d.ts +43 -6
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +243 -44
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +16 -2
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +100 -9
- 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 +54 -5
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/range/utils/peerBalancer.d.ts +2 -1
- package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
- package/lib/sync/range/utils/peerBalancer.js +8 -4
- package/lib/sync/range/utils/peerBalancer.js.map +1 -1
- package/lib/sync/sync.d.ts.map +1 -1
- package/lib/sync/sync.js +13 -0
- package/lib/sync/sync.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +7 -2
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +127 -57
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +36 -9
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +106 -42
- 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 +10 -0
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/sync/utils/rateLimit.d.ts +2 -0
- package/lib/sync/utils/rateLimit.d.ts.map +1 -0
- package/lib/sync/utils/rateLimit.js +15 -0
- package/lib/sync/utils/rateLimit.js.map +1 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +8 -6
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -16
- package/src/api/impl/beacon/blocks/index.ts +16 -3
- package/src/api/impl/beacon/pool/index.ts +83 -1
- package/src/api/impl/debug/index.ts +0 -1
- package/src/api/impl/validator/index.ts +82 -1
- package/src/chain/blocks/blockInput/blockInput.ts +4 -1
- package/src/chain/blocks/importBlock.ts +16 -50
- package/src/chain/blocks/importExecutionPayload.ts +51 -20
- package/src/chain/blocks/index.ts +32 -15
- package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
- package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
- package/src/chain/blocks/types.ts +2 -1
- package/src/chain/blocks/utils/chainSegment.ts +35 -24
- package/src/chain/blocks/verifyBlock.ts +45 -13
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
- package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -6
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +14 -6
- package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
- package/src/chain/chain.ts +32 -7
- package/src/chain/emitter.ts +0 -11
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/errors/proposerPreferences.ts +47 -0
- package/src/chain/initState.ts +9 -1
- package/src/chain/interface.ts +2 -0
- package/src/chain/lightClient/index.ts +6 -6
- package/src/chain/opPools/payloadAttestationPool.ts +63 -18
- package/src/chain/prepareNextSlot.ts +21 -29
- package/src/chain/produceBlock/produceBlockBody.ts +45 -27
- package/src/chain/regen/interface.ts +1 -0
- package/src/chain/regen/queued.ts +2 -7
- package/src/chain/regen/regen.ts +2 -7
- package/src/chain/seenCache/index.ts +1 -0
- package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +90 -24
- package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
- package/src/chain/validation/executionPayloadBid.ts +11 -8
- package/src/chain/validation/payloadAttestationMessage.ts +6 -4
- package/src/chain/validation/proposerPreferences.ts +110 -0
- package/src/metrics/metrics/lodestar.ts +6 -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/interface.ts +2 -0
- package/src/network/network.ts +23 -0
- package/src/network/processor/gossipHandlers.ts +86 -19
- package/src/network/processor/gossipQueues/index.ts +5 -0
- package/src/network/processor/index.ts +6 -5
- package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
- package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
- package/src/network/reqresp/handlers/index.ts +5 -0
- package/src/network/reqresp/interface.ts +1 -1
- package/src/network/reqresp/protocols.ts +6 -0
- package/src/network/reqresp/rateLimit.ts +4 -0
- package/src/network/reqresp/score.ts +1 -0
- package/src/network/reqresp/types.ts +5 -0
- package/src/node/nodejs.ts +2 -2
- package/src/node/notifier.ts +1 -8
- package/src/sync/constants.ts +8 -4
- package/src/sync/range/batch.ts +309 -51
- package/src/sync/range/chain.ts +119 -10
- package/src/sync/range/range.ts +68 -5
- package/src/sync/range/utils/peerBalancer.ts +9 -3
- package/src/sync/sync.ts +13 -1
- package/src/sync/unknownBlock.ts +157 -60
- package/src/sync/utils/downloadByRange.ts +174 -44
- package/src/sync/utils/downloadByRoot.ts +12 -0
- package/src/sync/utils/rateLimit.ts +16 -0
- package/src/util/sszBytes.ts +8 -6
|
@@ -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
|
};
|
package/src/network/interface.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface INetwork extends INetworkCorePublic {
|
|
|
78
78
|
// ReqResp
|
|
79
79
|
sendBeaconBlocksByRange(peerId: PeerIdStr, request: phase0.BeaconBlocksByRangeRequest): Promise<SignedBeaconBlock[]>;
|
|
80
80
|
sendBeaconBlocksByRoot(peerId: PeerIdStr, request: BeaconBlocksByRootRequest): Promise<SignedBeaconBlock[]>;
|
|
81
|
+
sendBeaconBlocksByHead(peerId: PeerIdStr, request: fulu.BeaconBlocksByHeadRequest): Promise<SignedBeaconBlock[]>;
|
|
81
82
|
sendBlobSidecarsByRange(peerId: PeerIdStr, request: deneb.BlobSidecarsByRangeRequest): Promise<deneb.BlobSidecar[]>;
|
|
82
83
|
sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]>;
|
|
83
84
|
sendDataColumnSidecarsByRange(
|
|
@@ -112,6 +113,7 @@ export interface INetwork extends INetworkCorePublic {
|
|
|
112
113
|
publishLightClientFinalityUpdate(update: LightClientFinalityUpdate): Promise<number>;
|
|
113
114
|
publishLightClientOptimisticUpdate(update: LightClientOptimisticUpdate): Promise<number>;
|
|
114
115
|
publishSignedExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope): Promise<number>;
|
|
116
|
+
publishPayloadAttestationMessage(payloadAttestationMessage: gloas.PayloadAttestationMessage): Promise<number>;
|
|
115
117
|
|
|
116
118
|
// Debug
|
|
117
119
|
dumpGossipQueue(gossipType: GossipType): Promise<PendingGossipsubMessage[]>;
|
package/src/network/network.ts
CHANGED
|
@@ -515,6 +515,17 @@ export class Network implements INetwork {
|
|
|
515
515
|
);
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
+
async publishPayloadAttestationMessage(payloadAttestationMessage: gloas.PayloadAttestationMessage): Promise<number> {
|
|
519
|
+
const epoch = computeEpochAtSlot(payloadAttestationMessage.data.slot);
|
|
520
|
+
const boundary = this.config.getForkBoundaryAtEpoch(epoch);
|
|
521
|
+
|
|
522
|
+
return this.publishGossip<GossipType.payload_attestation_message>(
|
|
523
|
+
{type: GossipType.payload_attestation_message, boundary},
|
|
524
|
+
payloadAttestationMessage,
|
|
525
|
+
{ignoreDuplicatePublishError: true}
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
518
529
|
private async publishGossip<K extends GossipType>(
|
|
519
530
|
topic: GossipTopicMap[K],
|
|
520
531
|
object: GossipTypeMap[K],
|
|
@@ -567,6 +578,18 @@ export class Network implements INetwork {
|
|
|
567
578
|
);
|
|
568
579
|
}
|
|
569
580
|
|
|
581
|
+
async sendBeaconBlocksByHead(
|
|
582
|
+
peerId: PeerIdStr,
|
|
583
|
+
request: fulu.BeaconBlocksByHeadRequest
|
|
584
|
+
): Promise<SignedBeaconBlock[]> {
|
|
585
|
+
return collectMaxResponseTypedWithBytes(
|
|
586
|
+
this.sendReqRespRequest(peerId, ReqRespMethod.BeaconBlocksByHead, [Version.V1], request),
|
|
587
|
+
Math.min(request.count, this.config.MAX_REQUEST_BLOCKS_DENEB),
|
|
588
|
+
responseSszTypeByMethod[ReqRespMethod.BeaconBlocksByHead],
|
|
589
|
+
this.chain.serializedCache
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
570
593
|
async sendLightClientBootstrap(peerId: PeerIdStr, request: Root): Promise<LightClientBootstrap> {
|
|
571
594
|
return collectExactOneTyped(
|
|
572
595
|
this.sendReqRespRequest(peerId, ReqRespMethod.LightClientBootstrap, [Version.V1], request),
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
IBlockInput,
|
|
36
36
|
isBlockInputColumns,
|
|
37
37
|
} from "../../chain/blocks/blockInput/index.js";
|
|
38
|
+
import {PayloadError, PayloadErrorCode} from "../../chain/blocks/importExecutionPayload.js";
|
|
38
39
|
import {PayloadEnvelopeInput, PayloadEnvelopeInputSource} from "../../chain/blocks/payloadEnvelopeInput/index.js";
|
|
39
40
|
import {BlobSidecarValidation} from "../../chain/blocks/types.js";
|
|
40
41
|
import {ChainEvent} from "../../chain/emitter.js";
|
|
@@ -52,6 +53,8 @@ import {
|
|
|
52
53
|
ExecutionPayloadEnvelopeErrorCode,
|
|
53
54
|
GossipAction,
|
|
54
55
|
GossipActionError,
|
|
56
|
+
PayloadAttestationError,
|
|
57
|
+
PayloadAttestationErrorCode,
|
|
55
58
|
SyncCommitteeError,
|
|
56
59
|
} from "../../chain/errors/index.js";
|
|
57
60
|
import {IBeaconChain} from "../../chain/interface.js";
|
|
@@ -79,6 +82,7 @@ import {
|
|
|
79
82
|
import {validateLightClientFinalityUpdate} from "../../chain/validation/lightClientFinalityUpdate.js";
|
|
80
83
|
import {validateLightClientOptimisticUpdate} from "../../chain/validation/lightClientOptimisticUpdate.js";
|
|
81
84
|
import {validateGossipPayloadAttestationMessage} from "../../chain/validation/payloadAttestationMessage.js";
|
|
85
|
+
import {validateGossipProposerPreferences} from "../../chain/validation/proposerPreferences.js";
|
|
82
86
|
import {OpSource} from "../../chain/validatorMonitor.js";
|
|
83
87
|
import {Metrics} from "../../metrics/index.js";
|
|
84
88
|
import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
|
|
@@ -182,6 +186,18 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
182
186
|
});
|
|
183
187
|
try {
|
|
184
188
|
await validateGossipBlock(config, chain, signedBlock, fork);
|
|
189
|
+
|
|
190
|
+
if (isForkPostGloas(fork)) {
|
|
191
|
+
chain.seenPayloadEnvelopeInputCache.add({
|
|
192
|
+
blockRootHex,
|
|
193
|
+
block: signedBlock as SignedBeaconBlock<ForkPostGloas>,
|
|
194
|
+
forkName: fork,
|
|
195
|
+
sampledColumns: chain.custodyConfig.sampledColumns,
|
|
196
|
+
custodyColumns: chain.custodyConfig.custodyColumns,
|
|
197
|
+
timeCreatedSec: seenTimestampSec,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
185
201
|
const blockInputMeta = blockInput.getLogMeta();
|
|
186
202
|
|
|
187
203
|
const recvToValidation = Date.now() / 1000 - seenTimestampSec;
|
|
@@ -592,6 +608,24 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
592
608
|
// Returns the delay between the start of `block.slot` and `current time`
|
|
593
609
|
const delaySec = chain.clock.secFromSlot(slot);
|
|
594
610
|
metrics?.gossipBlock.elapsedTimeTillProcessed.observe(delaySec);
|
|
611
|
+
|
|
612
|
+
if (isForkPostGloas(blockInput.forkName)) {
|
|
613
|
+
const payloadInput = chain.seenPayloadEnvelopeInputCache.get(blockInput.blockRootHex);
|
|
614
|
+
// This payloadInput should have been created just after gossip validation
|
|
615
|
+
if (!payloadInput) {
|
|
616
|
+
throw Error(
|
|
617
|
+
`PayloadEnvelopeInput not seeded for block ${blockInput.blockRootHex} during gossip processing`
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Immediately attempt fetch of data columns from execution engine as the bid contains kzg commitments
|
|
622
|
+
// which is all the information we need so there is no reason to delay until execution payload arrives
|
|
623
|
+
// TODO GLOAS: If we want EL retries after this initial attempt, add an explicit retry policy here
|
|
624
|
+
// (for example later in the slot). Do not couple retries to incoming gossip columns.
|
|
625
|
+
// Columns fetched here feed payloadInput.addColumn, which resolves waitForAllData for any
|
|
626
|
+
// in-flight importExecutionPayload. No processExecutionPayload trigger needed from this path.
|
|
627
|
+
chain.getBlobsTracker.triggerGetBlobs(payloadInput);
|
|
628
|
+
}
|
|
595
629
|
})
|
|
596
630
|
.catch((e) => {
|
|
597
631
|
// Adjust verbosity based on error type
|
|
@@ -1060,10 +1094,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1060
1094
|
const signedEnvelope = sszDeserialize(topic, serializedData);
|
|
1061
1095
|
const envelope = signedEnvelope.message;
|
|
1062
1096
|
|
|
1063
|
-
//
|
|
1064
|
-
//
|
|
1065
|
-
// the problem now is we cannot create a PayloadEnvelopeInput without the beacon block being known, we need at least the proposer index
|
|
1066
|
-
// we can achieve that by looking into the EpochCache
|
|
1097
|
+
// unlike BlockInput, we send the envelope into UnknownBlockInput sync
|
|
1098
|
+
// inside the sync it'll reconcile into PayloadEnvelopeInput and share the same cache with gossip
|
|
1067
1099
|
try {
|
|
1068
1100
|
await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope);
|
|
1069
1101
|
} catch (e) {
|
|
@@ -1071,14 +1103,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1071
1103
|
const {beaconBlockRoot} = signedEnvelope.message;
|
|
1072
1104
|
const slot = signedEnvelope.message.payload.slotNumber;
|
|
1073
1105
|
logger.debug("Gossip envelope has error", {slot, root: toRootHex(beaconBlockRoot), code: e.type.code});
|
|
1074
|
-
if (e.type.code === ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN) {
|
|
1075
|
-
// TODO GLOAS: UnknownBlockSync to handle this
|
|
1076
|
-
chain.emitter.emit(ChainEvent.envelopeUnknownBlock, {
|
|
1077
|
-
envelope: signedEnvelope,
|
|
1078
|
-
peer: peerIdStr,
|
|
1079
|
-
source: BlockInputSource.gossip,
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
1106
|
|
|
1083
1107
|
if (e.action === GossipAction.REJECT) {
|
|
1084
1108
|
chain.persistInvalidSszValue(
|
|
@@ -1125,7 +1149,40 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1125
1149
|
});
|
|
1126
1150
|
|
|
1127
1151
|
chain.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
|
|
1128
|
-
|
|
1152
|
+
// Adjust verbosity based on error type
|
|
1153
|
+
let logLevel: LogLevel;
|
|
1154
|
+
|
|
1155
|
+
if (e instanceof PayloadError) {
|
|
1156
|
+
switch (e.type.code) {
|
|
1157
|
+
// BLOCK_NOT_IN_FORK_CHOICE should not happen, validateGossipExecutionPayloadEnvelope above
|
|
1158
|
+
// already verified the block is in fork choice
|
|
1159
|
+
case PayloadErrorCode.BLOCK_NOT_IN_FORK_CHOICE:
|
|
1160
|
+
case PayloadErrorCode.MISS_BLOCK_STATE:
|
|
1161
|
+
case PayloadErrorCode.EXECUTION_ENGINE_ERROR:
|
|
1162
|
+
// Errors might indicate an issue with our node or the connected EL client
|
|
1163
|
+
logLevel = LogLevel.error;
|
|
1164
|
+
break;
|
|
1165
|
+
// INVALID_SIGNATURE should not happen, signature is verified during gossip validation
|
|
1166
|
+
case PayloadErrorCode.INVALID_SIGNATURE:
|
|
1167
|
+
case PayloadErrorCode.ENVELOPE_VERIFICATION_ERROR:
|
|
1168
|
+
case PayloadErrorCode.EXECUTION_ENGINE_INVALID:
|
|
1169
|
+
core.reportPeer(peerIdStr, PeerAction.LowToleranceError, "BadGossipPayload");
|
|
1170
|
+
// Misbehaving peer, but could highlight an issue in another client
|
|
1171
|
+
logLevel = LogLevel.warn;
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
} else {
|
|
1175
|
+
// Any unexpected error
|
|
1176
|
+
logLevel = LogLevel.error;
|
|
1177
|
+
}
|
|
1178
|
+
metrics?.gossipExecutionPayloadEnvelope.processPayloadErrors.inc({
|
|
1179
|
+
error: e instanceof PayloadError ? e.type.code : "NOT_PAYLOAD_ERROR",
|
|
1180
|
+
});
|
|
1181
|
+
chain.logger[logLevel](
|
|
1182
|
+
"Error processing execution payload from gossip",
|
|
1183
|
+
{slot, peer: peerIdStr, root: blockRootHex},
|
|
1184
|
+
e as Error
|
|
1185
|
+
);
|
|
1129
1186
|
});
|
|
1130
1187
|
},
|
|
1131
1188
|
[GossipType.payload_attestation_message]: async ({
|
|
@@ -1140,7 +1197,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1140
1197
|
const insertOutcome = chain.payloadAttestationPool.add(
|
|
1141
1198
|
payloadAttestationMessage,
|
|
1142
1199
|
validationResult.attDataRootHex,
|
|
1143
|
-
validationResult.
|
|
1200
|
+
validationResult.validatorCommitteeIndices
|
|
1144
1201
|
);
|
|
1145
1202
|
metrics?.opPool.payloadAttestationPool.gossipInsertOutcome.inc({insertOutcome});
|
|
1146
1203
|
} catch (e) {
|
|
@@ -1148,7 +1205,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1148
1205
|
}
|
|
1149
1206
|
chain.forkChoice.notifyPtcMessages(
|
|
1150
1207
|
toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
|
|
1151
|
-
|
|
1208
|
+
validationResult.validatorCommitteeIndices,
|
|
1152
1209
|
payloadAttestationMessage.data.payloadPresent
|
|
1153
1210
|
);
|
|
1154
1211
|
},
|
|
@@ -1173,6 +1230,14 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
|
|
|
1173
1230
|
data: executionPayloadBid,
|
|
1174
1231
|
});
|
|
1175
1232
|
},
|
|
1233
|
+
[GossipType.proposer_preferences]: async ({
|
|
1234
|
+
gossipData,
|
|
1235
|
+
topic,
|
|
1236
|
+
}: GossipHandlerParamGeneric<GossipType.proposer_preferences>) => {
|
|
1237
|
+
const {serializedData} = gossipData;
|
|
1238
|
+
const signedProposerPreferences = sszDeserialize(topic, serializedData);
|
|
1239
|
+
await validateGossipProposerPreferences(chain, signedProposerPreferences);
|
|
1240
|
+
},
|
|
1176
1241
|
};
|
|
1177
1242
|
}
|
|
1178
1243
|
|
|
@@ -1295,10 +1360,12 @@ export async function validateGossipFnRetryUnknownRoot<T>(
|
|
|
1295
1360
|
try {
|
|
1296
1361
|
return await fn();
|
|
1297
1362
|
} catch (e) {
|
|
1298
|
-
|
|
1299
|
-
e instanceof AttestationError &&
|
|
1300
|
-
|
|
1301
|
-
|
|
1363
|
+
const isUnknownAttestationRoot =
|
|
1364
|
+
e instanceof AttestationError && e.type.code === AttestationErrorCode.UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT;
|
|
1365
|
+
const isUnknownPayloadAttestationRoot =
|
|
1366
|
+
e instanceof PayloadAttestationError && e.type.code === PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT;
|
|
1367
|
+
|
|
1368
|
+
if (isUnknownAttestationRoot || isUnknownPayloadAttestationRoot) {
|
|
1302
1369
|
if (unknownBlockRootRetries === 0) {
|
|
1303
1370
|
// Trigger unknown block root search here
|
|
1304
1371
|
const rootHex = toRootHex(blockRoot);
|
|
@@ -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: {
|
|
@@ -76,6 +76,7 @@ type WorkOpts = {
|
|
|
76
76
|
*/
|
|
77
77
|
const executeGossipWorkOrderObj: Record<GossipType, WorkOpts> = {
|
|
78
78
|
[GossipType.beacon_block]: {bypassQueue: true},
|
|
79
|
+
[GossipType.execution_payload]: {bypassQueue: true},
|
|
79
80
|
[GossipType.blob_sidecar]: {bypassQueue: true},
|
|
80
81
|
[GossipType.data_column_sidecar]: {bypassQueue: true},
|
|
81
82
|
[GossipType.beacon_aggregate_and_proof]: {},
|
|
@@ -88,9 +89,9 @@ const executeGossipWorkOrderObj: Record<GossipType, WorkOpts> = {
|
|
|
88
89
|
[GossipType.sync_committee]: {},
|
|
89
90
|
[GossipType.light_client_finality_update]: {},
|
|
90
91
|
[GossipType.light_client_optimistic_update]: {},
|
|
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
|
|
|
@@ -443,8 +444,7 @@ export class NetworkProcessor {
|
|
|
443
444
|
}
|
|
444
445
|
case GossipType.execution_payload: {
|
|
445
446
|
// extractBlockSlotRootFn does not return a root for this topic.
|
|
446
|
-
// Extract beacon_block_root directly
|
|
447
|
-
// Do NOT await the block — the handler runs immediately; BlockInputSync handles recovery.
|
|
447
|
+
// Extract beacon_block_root directly
|
|
448
448
|
const blockRoot = getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized(message.msg.data);
|
|
449
449
|
if (blockRoot && !this.chain.forkChoice.hasBlockHexUnsafe(blockRoot)) {
|
|
450
450
|
this.searchUnknownBlock(
|
|
@@ -452,9 +452,10 @@ export class NetworkProcessor {
|
|
|
452
452
|
BlockInputSource.network_processor,
|
|
453
453
|
message.propagationSource.toString()
|
|
454
454
|
);
|
|
455
|
+
// We always want to await the block
|
|
456
|
+
// This allows us to properly forward the payload envelope
|
|
457
|
+
preprocessResult = {action: PreprocessAction.AwaitBlock, root: blockRoot};
|
|
455
458
|
}
|
|
456
|
-
// do not await the block, we want UnknownBlockSync to handle it.
|
|
457
|
-
preprocessResult = {action: PreprocessAction.PushToQueue};
|
|
458
459
|
break;
|
|
459
460
|
}
|
|
460
461
|
case GossipType.execution_payload_bid: {
|
|
@@ -286,6 +286,7 @@ export class ReqRespBeaconNode extends ReqResp {
|
|
|
286
286
|
// instead of protocol version. This is not easily fixable with our current architecture.
|
|
287
287
|
// See https://github.com/ChainSafe/lodestar/pull/8168 for more details.
|
|
288
288
|
[protocols.StatusV2(fork, this.config), this.onStatus.bind(this)],
|
|
289
|
+
[protocols.BeaconBlocksByHead(fork, this.config), this.getHandler(ReqRespMethod.BeaconBlocksByHead)],
|
|
289
290
|
[
|
|
290
291
|
protocols.DataColumnSidecarsByRoot(fork, this.config),
|
|
291
292
|
this.getHandler(ReqRespMethod.DataColumnSidecarsByRoot),
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {PeerId} from "@libp2p/interface";
|
|
2
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
+
import {ForkName, GENESIS_EPOCH, GENESIS_SLOT, isForkPostDeneb} from "@lodestar/params";
|
|
4
|
+
import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
|
|
5
|
+
import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
6
|
+
import {fulu} from "@lodestar/types";
|
|
7
|
+
import {toRootHex} from "@lodestar/utils";
|
|
8
|
+
import {IBeaconChain} from "../../../chain/index.js";
|
|
9
|
+
import {getParentRootFromSignedBeaconBlockSerialized} from "../../../util/sszBytes.js";
|
|
10
|
+
import {prettyPrintPeerId} from "../../util.js";
|
|
11
|
+
|
|
12
|
+
// See https://github.com/ethereum/consensus-specs/pull/5181
|
|
13
|
+
export async function* onBeaconBlocksByHead(
|
|
14
|
+
request: fulu.BeaconBlocksByHeadRequest,
|
|
15
|
+
chain: IBeaconChain,
|
|
16
|
+
peerId: PeerId,
|
|
17
|
+
peerClient: string
|
|
18
|
+
): AsyncIterable<ResponseOutgoing> {
|
|
19
|
+
const currentFork = chain.config.getForkName(chain.clock.currentSlot);
|
|
20
|
+
const {beaconRoot, count} = validateBeaconBlocksByHeadRequest(currentFork, chain.config, request);
|
|
21
|
+
|
|
22
|
+
const requestedRootHex = toRootHex(beaconRoot);
|
|
23
|
+
let blockRootHex = requestedRootHex;
|
|
24
|
+
const minimumRequestEpoch = Math.max(
|
|
25
|
+
GENESIS_EPOCH,
|
|
26
|
+
chain.clock.currentEpoch - chain.config.MIN_EPOCHS_FOR_BLOCK_REQUESTS
|
|
27
|
+
);
|
|
28
|
+
const minimumRequestSlot = computeStartSlotAtEpoch(minimumRequestEpoch);
|
|
29
|
+
|
|
30
|
+
for (let blocksSent = 0; blocksSent < count; blocksSent++) {
|
|
31
|
+
const blockBytes = await chain.getSerializedBlockByRoot(blockRootHex);
|
|
32
|
+
if (!blockBytes) {
|
|
33
|
+
if (blocksSent === 0) {
|
|
34
|
+
throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, `Unknown block root ${requestedRootHex}`);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (blockBytes.slot < minimumRequestSlot) {
|
|
40
|
+
if (blocksSent === 0) {
|
|
41
|
+
chain.logger.verbose("Peer requested unavailable block for BeaconBlocksByHead", {
|
|
42
|
+
peer: prettyPrintPeerId(peerId),
|
|
43
|
+
client: peerClient,
|
|
44
|
+
requestedRoot: requestedRootHex,
|
|
45
|
+
slot: blockBytes.slot,
|
|
46
|
+
minimumRequestSlot,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
yield {
|
|
53
|
+
data: blockBytes.block,
|
|
54
|
+
boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(blockBytes.slot)),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (blockBytes.slot === GENESIS_SLOT) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const parentRootHex = getParentRootFromSignedBeaconBlockSerialized(blockBytes.block);
|
|
62
|
+
if (parentRootHex === null) {
|
|
63
|
+
throw new ResponseError(
|
|
64
|
+
RespStatus.SERVER_ERROR,
|
|
65
|
+
`Invalid block bytes for root ${blockRootHex} slot ${blockBytes.slot}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
blockRootHex = parentRootHex;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function validateBeaconBlocksByHeadRequest(
|
|
73
|
+
fork: ForkName,
|
|
74
|
+
config: BeaconConfig,
|
|
75
|
+
request: fulu.BeaconBlocksByHeadRequest
|
|
76
|
+
): fulu.BeaconBlocksByHeadRequest {
|
|
77
|
+
const {beaconRoot} = request;
|
|
78
|
+
let {count} = request;
|
|
79
|
+
|
|
80
|
+
if (count < 1) {
|
|
81
|
+
throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const maxRequestBlocks = isForkPostDeneb(fork) ? config.MAX_REQUEST_BLOCKS_DENEB : config.MAX_REQUEST_BLOCKS;
|
|
85
|
+
|
|
86
|
+
if (count > maxRequestBlocks) {
|
|
87
|
+
count = maxRequestBlocks;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {beaconRoot, count};
|
|
91
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ExecutionPayloadEnvelopesByRootRequestType,
|
|
10
10
|
} from "../../../util/types.js";
|
|
11
11
|
import {GetReqRespHandlerFn, ReqRespMethod} from "../types.js";
|
|
12
|
+
import {onBeaconBlocksByHead} from "./beaconBlocksByHead.js";
|
|
12
13
|
import {onBeaconBlocksByRange} from "./beaconBlocksByRange.js";
|
|
13
14
|
import {onBeaconBlocksByRoot} from "./beaconBlocksByRoot.js";
|
|
14
15
|
import {onBlobSidecarsByRange} from "./blobSidecarsByRange.js";
|
|
@@ -47,6 +48,10 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
|
|
|
47
48
|
const body = BeaconBlocksByRootRequestType(fork, chain.config).deserialize(req.data);
|
|
48
49
|
return onBeaconBlocksByRoot(body, chain);
|
|
49
50
|
},
|
|
51
|
+
[ReqRespMethod.BeaconBlocksByHead]: (req, peerId, peerClient) => {
|
|
52
|
+
const body = ssz.fulu.BeaconBlocksByHeadRequest.deserialize(req.data);
|
|
53
|
+
return onBeaconBlocksByHead(body, chain, peerId, peerClient);
|
|
54
|
+
},
|
|
50
55
|
[ReqRespMethod.BlobSidecarsByRoot]: (req) => {
|
|
51
56
|
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
52
57
|
const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data);
|
|
@@ -33,7 +33,7 @@ export enum RespStatus {
|
|
|
33
33
|
*/
|
|
34
34
|
SERVER_ERROR = 2,
|
|
35
35
|
/**
|
|
36
|
-
* The responder does not have requested resource.
|
|
36
|
+
* The responder does not have requested resource. The response payload adheres to the ErrorMessage schema.
|
|
37
37
|
*/
|
|
38
38
|
RESOURCE_UNAVAILABLE = 3,
|
|
39
39
|
/**
|
|
@@ -70,6 +70,12 @@ export const BeaconBlocksByRootV2 = toProtocol({
|
|
|
70
70
|
contextBytesType: ContextBytesType.ForkDigest,
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
export const BeaconBlocksByHead = toProtocol({
|
|
74
|
+
method: ReqRespMethod.BeaconBlocksByHead,
|
|
75
|
+
version: Version.V1,
|
|
76
|
+
contextBytesType: ContextBytesType.ForkDigest,
|
|
77
|
+
});
|
|
78
|
+
|
|
73
79
|
export const BlobSidecarsByRange = toProtocol({
|
|
74
80
|
method: ReqRespMethod.BlobSidecarsByRange,
|
|
75
81
|
version: Version.V1,
|
|
@@ -40,6 +40,10 @@ export const rateLimitQuotas: (fork: ForkName, config: BeaconConfig) => Record<R
|
|
|
40
40
|
},
|
|
41
41
|
getRequestCount: getRequestCountFn(fork, config, ReqRespMethod.BeaconBlocksByRoot, (req) => req.length),
|
|
42
42
|
},
|
|
43
|
+
[ReqRespMethod.BeaconBlocksByHead]: {
|
|
44
|
+
byPeer: {quota: config.MAX_REQUEST_BLOCKS_DENEB, quotaTimeMs: 10_000},
|
|
45
|
+
getRequestCount: getRequestCountFn(fork, config, ReqRespMethod.BeaconBlocksByHead, (req) => req.count),
|
|
46
|
+
},
|
|
43
47
|
[ReqRespMethod.BlobSidecarsByRange]: {
|
|
44
48
|
// Rationale: MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
|
|
45
49
|
byPeer: {
|
|
@@ -46,6 +46,7 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
|
|
|
46
46
|
return PeerAction.LowToleranceError;
|
|
47
47
|
case ReqRespMethod.BeaconBlocksByRange:
|
|
48
48
|
case ReqRespMethod.BeaconBlocksByRoot:
|
|
49
|
+
case ReqRespMethod.BeaconBlocksByHead:
|
|
49
50
|
case ReqRespMethod.ExecutionPayloadEnvelopesByRoot:
|
|
50
51
|
case ReqRespMethod.ExecutionPayloadEnvelopesByRange:
|
|
51
52
|
return PeerAction.MidToleranceError;
|
|
@@ -42,6 +42,7 @@ export enum ReqRespMethod {
|
|
|
42
42
|
Metadata = "metadata",
|
|
43
43
|
BeaconBlocksByRange = "beacon_blocks_by_range",
|
|
44
44
|
BeaconBlocksByRoot = "beacon_blocks_by_root",
|
|
45
|
+
BeaconBlocksByHead = "beacon_blocks_by_head",
|
|
45
46
|
BlobSidecarsByRange = "blob_sidecars_by_range",
|
|
46
47
|
BlobSidecarsByRoot = "blob_sidecars_by_root",
|
|
47
48
|
DataColumnSidecarsByRange = "data_column_sidecars_by_range",
|
|
@@ -62,6 +63,7 @@ export type RequestBodyByMethod = {
|
|
|
62
63
|
[ReqRespMethod.Metadata]: null;
|
|
63
64
|
[ReqRespMethod.BeaconBlocksByRange]: phase0.BeaconBlocksByRangeRequest;
|
|
64
65
|
[ReqRespMethod.BeaconBlocksByRoot]: BeaconBlocksByRootRequest;
|
|
66
|
+
[ReqRespMethod.BeaconBlocksByHead]: fulu.BeaconBlocksByHeadRequest;
|
|
65
67
|
[ReqRespMethod.BlobSidecarsByRange]: deneb.BlobSidecarsByRangeRequest;
|
|
66
68
|
[ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequest;
|
|
67
69
|
[ReqRespMethod.DataColumnSidecarsByRange]: fulu.DataColumnSidecarsByRangeRequest;
|
|
@@ -82,6 +84,7 @@ type ResponseBodyByMethod = {
|
|
|
82
84
|
// Do not matter
|
|
83
85
|
[ReqRespMethod.BeaconBlocksByRange]: SignedBeaconBlock;
|
|
84
86
|
[ReqRespMethod.BeaconBlocksByRoot]: SignedBeaconBlock;
|
|
87
|
+
[ReqRespMethod.BeaconBlocksByHead]: SignedBeaconBlock;
|
|
85
88
|
[ReqRespMethod.BlobSidecarsByRange]: deneb.BlobSidecar;
|
|
86
89
|
[ReqRespMethod.BlobSidecarsByRoot]: deneb.BlobSidecar;
|
|
87
90
|
[ReqRespMethod.DataColumnSidecarsByRange]: DataColumnSidecar;
|
|
@@ -111,6 +114,7 @@ export const requestSszTypeByMethod: (
|
|
|
111
114
|
|
|
112
115
|
[ReqRespMethod.BeaconBlocksByRange]: ssz.phase0.BeaconBlocksByRangeRequest,
|
|
113
116
|
[ReqRespMethod.BeaconBlocksByRoot]: BeaconBlocksByRootRequestType(fork, config),
|
|
117
|
+
[ReqRespMethod.BeaconBlocksByHead]: ssz.fulu.BeaconBlocksByHeadRequest,
|
|
114
118
|
[ReqRespMethod.BlobSidecarsByRange]: ssz.deneb.BlobSidecarsByRangeRequest,
|
|
115
119
|
[ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(fork, config),
|
|
116
120
|
[ReqRespMethod.DataColumnSidecarsByRange]: ssz.fulu.DataColumnSidecarsByRangeRequest,
|
|
@@ -142,6 +146,7 @@ export const responseSszTypeByMethod: {[K in ReqRespMethod]: ResponseTypeGetter<
|
|
|
142
146
|
version === Version.V1 ? ssz.phase0.Metadata : version === Version.V2 ? ssz.altair.Metadata : ssz.fulu.Metadata,
|
|
143
147
|
[ReqRespMethod.BeaconBlocksByRange]: blocksResponseType,
|
|
144
148
|
[ReqRespMethod.BeaconBlocksByRoot]: blocksResponseType,
|
|
149
|
+
[ReqRespMethod.BeaconBlocksByHead]: (fork) => ssz[fork].SignedBeaconBlock,
|
|
145
150
|
[ReqRespMethod.BlobSidecarsByRange]: () => ssz.deneb.BlobSidecar,
|
|
146
151
|
[ReqRespMethod.BlobSidecarsByRoot]: () => ssz.deneb.BlobSidecar,
|
|
147
152
|
[ReqRespMethod.LightClientBootstrap]: (fork) => sszTypesFor(onlyPostAltairFork(fork)).LightClientBootstrap,
|
package/src/node/nodejs.ts
CHANGED
|
@@ -221,7 +221,7 @@ export class BeaconNode {
|
|
|
221
221
|
|
|
222
222
|
let executionEngineOpts = opts.executionEngine;
|
|
223
223
|
if (opts.executionEngine.mode === "mock") {
|
|
224
|
-
const
|
|
224
|
+
const latestEth1BlockHash =
|
|
225
225
|
isStatePostBellatrix(anchorState) && anchorState.isExecutionStateType
|
|
226
226
|
? isStatePostGloas(anchorState)
|
|
227
227
|
? toRootHex(anchorState.latestBlockHash)
|
|
@@ -230,7 +230,7 @@ export class BeaconNode {
|
|
|
230
230
|
executionEngineOpts = {
|
|
231
231
|
...opts.executionEngine,
|
|
232
232
|
genesisBlockHash: ZERO_HASH_HEX,
|
|
233
|
-
eth1BlockHash,
|
|
233
|
+
eth1BlockHash: opts.executionEngine.eth1BlockHash ?? latestEth1BlockHash,
|
|
234
234
|
genesisTime: anchorState.genesisTime,
|
|
235
235
|
config,
|
|
236
236
|
};
|
package/src/node/notifier.ts
CHANGED
|
@@ -167,14 +167,7 @@ function getHeadExecutionInfo(
|
|
|
167
167
|
return [];
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
// arrives, in that case the exec-block row surfaces the inherited parent anchor (from the
|
|
172
|
-
// bid), which is already validated. Normalize to "valid" to avoid leaking internal
|
|
173
|
-
// fork-choice bookkeeping into the log. Once the payload envelope arrives and the FULL
|
|
174
|
-
// variant becomes head, executionStatus is Valid/Syncing naturally.
|
|
175
|
-
// TODO GLOAS: revisit once optimistic sync is implemented
|
|
176
|
-
const executionStatusStr =
|
|
177
|
-
headInfo.executionStatus === ExecutionStatus.PayloadSeparated ? "valid" : headInfo.executionStatus.toLowerCase();
|
|
170
|
+
const executionStatusStr = headInfo.executionStatus.toLowerCase();
|
|
178
171
|
|
|
179
172
|
// Add execution status to notifier only if head is on/post bellatrix
|
|
180
173
|
if (isStatePostBellatrix(headState) && headState.isExecutionStateType) {
|