@lodestar/beacon-node 1.44.0-dev.a9a9fe2e63 → 1.44.0-dev.aa2d3a82a3
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 +36 -33
- 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 +0 -25
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/config/constants.d.ts +1 -0
- package/lib/api/impl/config/constants.d.ts.map +1 -1
- package/lib/api/impl/config/constants.js +2 -1
- package/lib/api/impl/config/constants.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +69 -12
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/lodestar/index.d.ts.map +1 -1
- package/lib/api/impl/lodestar/index.js +28 -0
- package/lib/api/impl/lodestar/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +23 -28
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +0 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +0 -4
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.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.map +1 -1
- package/lib/chain/chain.js +8 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +2 -1
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/errors/blockError.d.ts +0 -7
- package/lib/chain/errors/blockError.d.ts.map +1 -1
- package/lib/chain/errors/blockError.js +0 -3
- package/lib/chain/errors/blockError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +6 -0
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -0
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +4 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +10 -7
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +3 -3
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/regen/interface.d.ts +0 -1
- package/lib/chain/regen/interface.d.ts.map +1 -1
- package/lib/chain/regen/queued.d.ts +0 -1
- package/lib/chain/regen/queued.d.ts.map +1 -1
- package/lib/chain/regen/queued.js +0 -4
- package/lib/chain/regen/queued.js.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts +0 -5
- package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
- package/lib/chain/stateCache/fifoBlockStateCache.js +0 -5
- package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +1 -4
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +5 -2
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/stateCache/types.d.ts +0 -2
- package/lib/chain/stateCache/types.d.ts.map +1 -1
- package/lib/chain/stateCache/types.js.map +1 -1
- package/lib/chain/validation/block.d.ts +5 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +4 -14
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +12 -1
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +0 -2
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- 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 +10 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +750 -3
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +9 -2
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts +2 -2
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +25 -23
- 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 +9 -5
- package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +8 -3
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts +2 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +16 -6
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/index.js +2 -2
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -1
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js +15 -5
- package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
- package/lib/sync/types.d.ts +9 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +9 -2
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +64 -30
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/dataColumns.d.ts.map +1 -1
- package/lib/util/dataColumns.js +16 -11
- package/lib/util/dataColumns.js.map +1 -1
- package/lib/util/sszBytes.js +1 -1
- package/package.json +15 -17
- package/src/api/impl/beacon/blocks/index.ts +40 -42
- package/src/api/impl/beacon/pool/index.ts +1 -41
- package/src/api/impl/config/constants.ts +2 -0
- package/src/api/impl/debug/index.ts +73 -12
- package/src/api/impl/lodestar/index.ts +30 -0
- package/src/api/impl/validator/index.ts +32 -44
- package/src/chain/archiveStore/archiveStore.ts +0 -5
- package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +2 -4
- package/src/chain/chain.ts +10 -1
- package/src/chain/emitter.ts +3 -2
- package/src/chain/errors/blockError.ts +0 -4
- package/src/chain/errors/executionPayloadBid.ts +7 -0
- package/src/chain/forkChoice/index.ts +13 -0
- package/src/chain/options.ts +1 -0
- package/src/chain/produceBlock/produceBlockBody.ts +3 -3
- package/src/chain/regen/interface.ts +0 -1
- package/src/chain/regen/queued.ts +0 -5
- package/src/chain/stateCache/fifoBlockStateCache.ts +0 -6
- package/src/chain/stateCache/persistentCheckpointsCache.ts +6 -2
- package/src/chain/stateCache/types.ts +0 -2
- package/src/chain/validation/block.ts +12 -16
- package/src/chain/validation/executionPayloadBid.ts +13 -1
- package/src/chain/validation/executionPayloadEnvelope.ts +0 -2
- package/src/metrics/metrics/lodestar.ts +11 -0
- package/src/network/processor/gossipHandlers.ts +9 -2
- package/src/network/processor/index.ts +27 -27
- package/src/network/reqresp/handlers/beaconBlocksByRange.ts +12 -5
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +11 -3
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +22 -6
- package/src/network/reqresp/handlers/index.ts +2 -2
- package/src/network/reqresp/utils/dataColumnResponseValidation.ts +14 -5
- package/src/sync/types.ts +11 -2
- package/src/sync/unknownBlock.ts +70 -31
- package/src/util/dataColumns.ts +17 -12
- package/src/util/sszBytes.ts +1 -1
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isForkPostGloas,
|
|
10
10
|
} from "@lodestar/params";
|
|
11
11
|
import {isStatePostAltair} from "@lodestar/state-transition";
|
|
12
|
-
import {
|
|
12
|
+
import {Epoch, SingleAttestation, isElectraAttestation, ssz, sszTypesFor} from "@lodestar/types";
|
|
13
13
|
import {toRootHex} from "@lodestar/utils";
|
|
14
14
|
import {
|
|
15
15
|
AttestationError,
|
|
@@ -40,25 +40,6 @@ export function getBeaconPoolApi({
|
|
|
40
40
|
network,
|
|
41
41
|
}: Pick<ApiModules, "chain" | "logger" | "metrics" | "network">): ApplicationMethods<routes.beacon.pool.Endpoints> {
|
|
42
42
|
return {
|
|
43
|
-
async getPoolAttestations({slot, committeeIndex}) {
|
|
44
|
-
// Already filtered by slot
|
|
45
|
-
let attestations: Attestation[] = chain.aggregatedAttestationPool.getAll(slot);
|
|
46
|
-
const fork = chain.config.getForkName(slot ?? chain.clock.currentSlot);
|
|
47
|
-
|
|
48
|
-
if (isForkPostElectra(fork)) {
|
|
49
|
-
throw new ApiError(
|
|
50
|
-
400,
|
|
51
|
-
`Use getPoolAttestationsV2 to retrieve pool attestations for post-electra fork=${fork}`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (committeeIndex !== undefined) {
|
|
56
|
-
attestations = attestations.filter((attestation) => committeeIndex === attestation.data.index);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {data: attestations};
|
|
60
|
-
},
|
|
61
|
-
|
|
62
43
|
async getPoolAttestationsV2({slot, committeeIndex}) {
|
|
63
44
|
// Already filtered by slot
|
|
64
45
|
let attestations = chain.aggregatedAttestationPool.getAll(slot);
|
|
@@ -134,19 +115,6 @@ export function getBeaconPoolApi({
|
|
|
134
115
|
}
|
|
135
116
|
},
|
|
136
117
|
|
|
137
|
-
async getPoolAttesterSlashings() {
|
|
138
|
-
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
139
|
-
|
|
140
|
-
if (isForkPostElectra(fork)) {
|
|
141
|
-
throw new ApiError(
|
|
142
|
-
400,
|
|
143
|
-
`Use getPoolAttesterSlashingsV2 to retrieve pool attester slashings for post-electra fork=${fork}`
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return {data: chain.opPool.getAllAttesterSlashings()};
|
|
148
|
-
},
|
|
149
|
-
|
|
150
118
|
async getPoolAttesterSlashingsV2() {
|
|
151
119
|
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
152
120
|
return {data: chain.opPool.getAllAttesterSlashings(), meta: {version: fork}};
|
|
@@ -164,10 +132,6 @@ export function getBeaconPoolApi({
|
|
|
164
132
|
return {data: chain.opPool.getAllBlsToExecutionChanges().map(({data}) => data)};
|
|
165
133
|
},
|
|
166
134
|
|
|
167
|
-
async submitPoolAttestations({signedAttestations}) {
|
|
168
|
-
await this.submitPoolAttestationsV2({signedAttestations});
|
|
169
|
-
},
|
|
170
|
-
|
|
171
135
|
async submitPoolAttestationsV2({signedAttestations}) {
|
|
172
136
|
const fork = chain.config.getForkName(chain.clock.currentSlot);
|
|
173
137
|
const seenTimestampSec = Date.now() / 1000;
|
|
@@ -247,10 +211,6 @@ export function getBeaconPoolApi({
|
|
|
247
211
|
}
|
|
248
212
|
},
|
|
249
213
|
|
|
250
|
-
async submitPoolAttesterSlashings({attesterSlashing}) {
|
|
251
|
-
await this.submitPoolAttesterSlashingsV2({attesterSlashing});
|
|
252
|
-
},
|
|
253
|
-
|
|
254
214
|
async submitPoolAttesterSlashingsV2({attesterSlashing}) {
|
|
255
215
|
await validateApiAttesterSlashing(chain, attesterSlashing);
|
|
256
216
|
const fork = chain.config.getForkName(Number(attesterSlashing.attestation1.data.slot));
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
VERSIONED_HASH_VERSION_KZG,
|
|
54
54
|
WEIGHT_DENOMINATOR,
|
|
55
55
|
WITHDRAWAL_REQUEST_TYPE,
|
|
56
|
+
ZERO_HASH_HEX,
|
|
56
57
|
} from "@lodestar/params";
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -69,6 +70,7 @@ export const specConstants = {
|
|
|
69
70
|
DEPOSIT_CONTRACT_TREE_DEPTH,
|
|
70
71
|
JUSTIFICATION_BITS_LENGTH,
|
|
71
72
|
ENDIANNESS: "little",
|
|
73
|
+
EMPTY_BLOCK_HASH: ZERO_HASH_HEX,
|
|
72
74
|
// ## Withdrawal prefixes
|
|
73
75
|
BLS_WITHDRAWAL_PREFIX: toHexByte(BLS_WITHDRAWAL_PREFIX),
|
|
74
76
|
ETH1_ADDRESS_WITHDRAWAL_PREFIX: toHexByte(ETH1_ADDRESS_WITHDRAWAL_PREFIX),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
|
-
import {ExecutionStatus} from "@lodestar/fork-choice";
|
|
3
|
+
import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
|
|
4
4
|
import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
|
5
|
+
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
5
6
|
import {BeaconState, DataColumnSidecar, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
|
|
6
7
|
import {toRootHex} from "@lodestar/utils";
|
|
7
8
|
import {getBlobKzgCommitments} from "../../../util/dataColumns.js";
|
|
@@ -12,6 +13,29 @@ import {getStateResponseWithRegen} from "../beacon/state/utils.js";
|
|
|
12
13
|
import {ApiModules} from "../types.js";
|
|
13
14
|
import {assertUniqueItems} from "../utils.js";
|
|
14
15
|
|
|
16
|
+
function toForkChoiceValidity(status: ExecutionStatus): "valid" | "invalid" | "optimistic" {
|
|
17
|
+
switch (status) {
|
|
18
|
+
case ExecutionStatus.Valid:
|
|
19
|
+
return "valid";
|
|
20
|
+
case ExecutionStatus.Invalid:
|
|
21
|
+
return "invalid";
|
|
22
|
+
case ExecutionStatus.Syncing:
|
|
23
|
+
case ExecutionStatus.PreMerge:
|
|
24
|
+
return "optimistic";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function toPayloadStatusName(status: PayloadStatus): "pending" | "empty" | "full" {
|
|
29
|
+
switch (status) {
|
|
30
|
+
case PayloadStatus.PENDING:
|
|
31
|
+
return "pending";
|
|
32
|
+
case PayloadStatus.EMPTY:
|
|
33
|
+
return "empty";
|
|
34
|
+
case PayloadStatus.FULL:
|
|
35
|
+
return "full";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
15
39
|
export function getDebugApi({
|
|
16
40
|
chain,
|
|
17
41
|
config,
|
|
@@ -40,23 +64,60 @@ export function getDebugApi({
|
|
|
40
64
|
justifiedEpoch: node.justifiedEpoch,
|
|
41
65
|
finalizedEpoch: node.finalizedEpoch,
|
|
42
66
|
weight: node.weight,
|
|
43
|
-
validity: (
|
|
44
|
-
switch (node.executionStatus) {
|
|
45
|
-
case ExecutionStatus.Valid:
|
|
46
|
-
return "valid";
|
|
47
|
-
case ExecutionStatus.Invalid:
|
|
48
|
-
return "invalid";
|
|
49
|
-
case ExecutionStatus.Syncing:
|
|
50
|
-
case ExecutionStatus.PreMerge:
|
|
51
|
-
return "optimistic";
|
|
52
|
-
}
|
|
53
|
-
})(),
|
|
67
|
+
validity: toForkChoiceValidity(node.executionStatus),
|
|
54
68
|
executionBlockHash: node.executionPayloadBlockHash ?? ZERO_HASH_HEX,
|
|
55
69
|
})),
|
|
56
70
|
},
|
|
57
71
|
};
|
|
58
72
|
},
|
|
59
73
|
|
|
74
|
+
async getDebugForkChoiceV2() {
|
|
75
|
+
const {forkChoice} = chain;
|
|
76
|
+
return {
|
|
77
|
+
data: {
|
|
78
|
+
justifiedCheckpoint: forkChoice.getJustifiedCheckpoint(),
|
|
79
|
+
finalizedCheckpoint: forkChoice.getFinalizedCheckpoint(),
|
|
80
|
+
forkChoiceNodes: forkChoice.getAllNodes().map((node) => {
|
|
81
|
+
// Payload-specific fields apply only to a revealed Gloas payload = the FULL variant of a
|
|
82
|
+
// Gloas block
|
|
83
|
+
const ptc = node.payloadStatus === PayloadStatus.FULL ? forkChoice.getPTCVoteCounts(node.blockRoot) : null;
|
|
84
|
+
return {
|
|
85
|
+
payloadStatus: toPayloadStatusName(node.payloadStatus),
|
|
86
|
+
slot: node.slot,
|
|
87
|
+
blockRoot: node.blockRoot,
|
|
88
|
+
parentRoot: node.parentRoot,
|
|
89
|
+
weight: node.weight,
|
|
90
|
+
validity: toForkChoiceValidity(node.executionStatus),
|
|
91
|
+
executionBlockHash: node.executionPayloadBlockHash ?? ZERO_HASH_HEX,
|
|
92
|
+
extraData: {
|
|
93
|
+
executionOptimistic: isOptimisticBlock(node),
|
|
94
|
+
timestamp: computeTimeAtSlot(config, node.slot, chain.genesisTime),
|
|
95
|
+
target: node.targetRoot,
|
|
96
|
+
justifiedEpoch: node.justifiedEpoch,
|
|
97
|
+
finalizedEpoch: node.finalizedEpoch,
|
|
98
|
+
unrealizedJustifiedEpoch: node.unrealizedJustifiedEpoch,
|
|
99
|
+
unrealizedFinalizedEpoch: node.unrealizedFinalizedEpoch,
|
|
100
|
+
payloadAttesterCount: ptc?.attesterCount ?? null,
|
|
101
|
+
payloadAvailabilityYesCount: ptc?.payloadPresentCount ?? null,
|
|
102
|
+
payloadDataAvailabilityYesCount: ptc?.dataAvailableCount ?? null,
|
|
103
|
+
gasLimit:
|
|
104
|
+
node.payloadStatus === PayloadStatus.FULL && "executionPayloadGasLimit" in node
|
|
105
|
+
? node.executionPayloadGasLimit
|
|
106
|
+
: null,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}),
|
|
110
|
+
extraData: {
|
|
111
|
+
unrealizedJustifiedCheckpoint: forkChoice.getUnrealizedJustifiedCheckpoint(),
|
|
112
|
+
unrealizedFinalizedCheckpoint: forkChoice.getUnrealizedFinalizedCheckpoint(),
|
|
113
|
+
proposerBoostRoot: forkChoice.getProposerBoostRoot(),
|
|
114
|
+
previousProposerBoostRoot: forkChoice.getPreviousProposerBoostRoot(),
|
|
115
|
+
headRoot: forkChoice.getHeadRoot(),
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
|
|
60
121
|
async getProtoArrayNodes() {
|
|
61
122
|
const nodes = chain.forkChoice.getAllNodes().map((node) => ({
|
|
62
123
|
// if node has executionPayloadNumber, it will overwrite the below default
|
|
@@ -280,6 +280,36 @@ export function getLodestarApi({
|
|
|
280
280
|
};
|
|
281
281
|
},
|
|
282
282
|
|
|
283
|
+
async getFastConfirmationInfo() {
|
|
284
|
+
const confirmedRoot = chain.forkChoice.getConfirmedRoot();
|
|
285
|
+
const confirmedBlock = chain.forkChoice.getConfirmedBlock();
|
|
286
|
+
const justifiedCheckpoint = chain.forkChoice.getJustifiedCheckpoint();
|
|
287
|
+
const finalizedCheckpoint = chain.forkChoice.getFinalizedCheckpoint();
|
|
288
|
+
const headRoot = chain.forkChoice.getHeadRoot();
|
|
289
|
+
const head = chain.forkChoice.getHead();
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
data: {
|
|
293
|
+
confirmed: {
|
|
294
|
+
rootHex: confirmedRoot,
|
|
295
|
+
slot: confirmedBlock?.slot ?? null,
|
|
296
|
+
},
|
|
297
|
+
head: {
|
|
298
|
+
rootHex: headRoot,
|
|
299
|
+
slot: head.slot,
|
|
300
|
+
},
|
|
301
|
+
justifiedCheckpoint: {
|
|
302
|
+
rootHex: justifiedCheckpoint.rootHex,
|
|
303
|
+
epoch: justifiedCheckpoint.epoch,
|
|
304
|
+
},
|
|
305
|
+
finalizedCheckpoint: {
|
|
306
|
+
rootHex: finalizedCheckpoint.rootHex,
|
|
307
|
+
epoch: finalizedCheckpoint.epoch,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
|
|
283
313
|
async getAttesterSlashingsFromBlocks({signedBlocks}) {
|
|
284
314
|
const attestations = new Map<Epoch, Attestation[]>();
|
|
285
315
|
|
|
@@ -927,11 +927,9 @@ export function getValidatorApi(
|
|
|
927
927
|
// TODO GLOAS: respect builderSelection (MaxProfit, BuilderAlways, ExecutionAlways, etc.) to let
|
|
928
928
|
// the user control bid source preferences and value comparison. Also add external builder api
|
|
929
929
|
// support when it is implemented.
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
parentBlockRootHex
|
|
934
|
-
);
|
|
930
|
+
const isBuildingOnFull = chain.forkChoice.shouldBuildOnFull(parentBlock, slot);
|
|
931
|
+
const bidParentBlockHash = isBuildingOnFull ? parentBlock.executionPayloadBlockHash : parentBlock.parentBlockHash;
|
|
932
|
+
const builderBid = chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
|
|
935
933
|
|
|
936
934
|
const logCtx = {
|
|
937
935
|
slot,
|
|
@@ -1209,7 +1207,10 @@ export function getValidatorApi(
|
|
|
1209
1207
|
const isPostFulu = isForkPostFulu(config.getForkName(startSlot));
|
|
1210
1208
|
const maxFutureEpoch = isPostFulu && nearNextEpoch && opts?.v2 ? nextEpoch + 1 : nextEpoch;
|
|
1211
1209
|
if (currentEpoch >= 0 && epoch > maxFutureEpoch) {
|
|
1212
|
-
throw new ApiError(
|
|
1210
|
+
throw new ApiError(
|
|
1211
|
+
400,
|
|
1212
|
+
`Requested epoch ${epoch} must not be more than ${maxFutureEpoch}, currentEpoch=${currentEpoch}, v2=${opts?.v2 ?? false}`
|
|
1213
|
+
);
|
|
1213
1214
|
}
|
|
1214
1215
|
|
|
1215
1216
|
const head = chain.forkChoice.getHead();
|
|
@@ -1293,17 +1294,35 @@ export function getValidatorApi(
|
|
|
1293
1294
|
duties.push({slot: startSlot + i, validatorIndex: indexes[i], pubkey: pubkeys[i]});
|
|
1294
1295
|
}
|
|
1295
1296
|
|
|
1296
|
-
//
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1297
|
+
// In v2 the dependent root is different after fulu due to deterministic proposer lookahead
|
|
1298
|
+
let dependentRoot = proposerShufflingDecisionRoot(
|
|
1299
|
+
opts?.v2 ? config.getForkName(startSlot) : ForkName.phase0,
|
|
1300
|
+
state,
|
|
1301
|
+
epoch
|
|
1302
|
+
);
|
|
1303
|
+
const logCtx = {
|
|
1304
|
+
epoch,
|
|
1305
|
+
stateSlot: state.slot,
|
|
1306
|
+
stateEpoch: state.epoch,
|
|
1307
|
+
v2: opts?.v2 ?? false,
|
|
1308
|
+
};
|
|
1309
|
+
if (dependentRoot === null) {
|
|
1310
|
+
// fallback to get_proposer_duties() v1, also in lodestar v1.43
|
|
1311
|
+
logger.verbose("Proposer duties decision root not in state, falling back to state epoch", logCtx);
|
|
1312
|
+
dependentRoot = proposerShufflingDecisionRoot(ForkName.phase0, state, state.epoch);
|
|
1313
|
+
}
|
|
1314
|
+
if (dependentRoot === null) {
|
|
1315
|
+
logger.verbose("Proposer duties decision root not in state, falling back to genesis block root", logCtx);
|
|
1316
|
+
dependentRoot = await getGenesisBlockRoot(state);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
const dependentRootHex = toRootHex(dependentRoot);
|
|
1320
|
+
logger.verbose("Computed proposer duties decision root", {...logCtx, dependentRoot: dependentRootHex});
|
|
1302
1321
|
|
|
1303
1322
|
return {
|
|
1304
1323
|
data: duties,
|
|
1305
1324
|
meta: {
|
|
1306
|
-
dependentRoot:
|
|
1325
|
+
dependentRoot: dependentRootHex,
|
|
1307
1326
|
executionOptimistic: isOptimisticBlock(head),
|
|
1308
1327
|
},
|
|
1309
1328
|
};
|
|
@@ -1482,33 +1501,6 @@ export function getValidatorApi(
|
|
|
1482
1501
|
};
|
|
1483
1502
|
},
|
|
1484
1503
|
|
|
1485
|
-
async getAggregatedAttestation({attestationDataRoot, slot}) {
|
|
1486
|
-
notWhileSyncing();
|
|
1487
|
-
|
|
1488
|
-
await waitForSlot(slot); // Must never request for a future slot > currentSlot
|
|
1489
|
-
|
|
1490
|
-
const dataRootHex = toRootHex(attestationDataRoot);
|
|
1491
|
-
const aggregate = chain.attestationPool.getAggregate(slot, dataRootHex, null);
|
|
1492
|
-
const fork = chain.config.getForkName(slot);
|
|
1493
|
-
|
|
1494
|
-
if (isForkPostElectra(fork)) {
|
|
1495
|
-
throw new ApiError(
|
|
1496
|
-
400,
|
|
1497
|
-
`Use getAggregatedAttestationV2 to retrieve aggregated attestations for post-electra fork=${fork}`
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
if (!aggregate) {
|
|
1502
|
-
throw new ApiError(404, `No aggregated attestation for slot=${slot}, dataRoot=${dataRootHex}`);
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
metrics?.production.producedAggregateParticipants.observe(aggregate.aggregationBits.getTrueBitIndexes().length);
|
|
1506
|
-
|
|
1507
|
-
return {
|
|
1508
|
-
data: aggregate,
|
|
1509
|
-
};
|
|
1510
|
-
},
|
|
1511
|
-
|
|
1512
1504
|
async getAggregatedAttestationV2({attestationDataRoot, slot, committeeIndex}) {
|
|
1513
1505
|
notWhileSyncing();
|
|
1514
1506
|
|
|
@@ -1532,10 +1524,6 @@ export function getValidatorApi(
|
|
|
1532
1524
|
};
|
|
1533
1525
|
},
|
|
1534
1526
|
|
|
1535
|
-
async publishAggregateAndProofs({signedAggregateAndProofs}) {
|
|
1536
|
-
await this.publishAggregateAndProofsV2({signedAggregateAndProofs});
|
|
1537
|
-
},
|
|
1538
|
-
|
|
1539
1527
|
async publishAggregateAndProofsV2({signedAggregateAndProofs}) {
|
|
1540
1528
|
notWhileSyncing();
|
|
1541
1529
|
|
|
@@ -30,7 +30,6 @@ export enum ArchiveStoreTask {
|
|
|
30
30
|
PruneHistory = "prune_history",
|
|
31
31
|
OnFinalizedCheckpoint = "on_finalized_checkpoint",
|
|
32
32
|
MaybeArchiveState = "maybe_archive_state",
|
|
33
|
-
RegenPruneOnFinalized = "regen_prune_on_finalized",
|
|
34
33
|
ForkchoicePrune = "forkchoice_prune",
|
|
35
34
|
UpdateBackfillRange = "update_backfill_range",
|
|
36
35
|
}
|
|
@@ -229,10 +228,6 @@ export class ArchiveStore {
|
|
|
229
228
|
await this.statesArchiverStrategy.maybeArchiveState(finalized, this.metrics);
|
|
230
229
|
timer?.({source: ArchiveStoreTask.MaybeArchiveState});
|
|
231
230
|
|
|
232
|
-
timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
|
|
233
|
-
this.chain.regen.pruneOnFinalized(finalizedEpoch);
|
|
234
|
-
timer?.({source: ArchiveStoreTask.RegenPruneOnFinalized});
|
|
235
|
-
|
|
236
231
|
// tasks rely on extended fork choice
|
|
237
232
|
timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
|
|
238
233
|
const prunedBlocks = this.chain.forkChoice.prune(finalized.rootHex);
|
|
@@ -61,10 +61,8 @@ export function verifyExecutionPayloadEnvelope(
|
|
|
61
61
|
`Prev randao mismatch between bid and payload bid=${toHex(bid.prevRandao)} payload=${toHex(payload.prevRandao)}`
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
65
|
-
throw new Error(
|
|
66
|
-
`Gas limit mismatch between payload and bid payload=${payload.gasLimit} bid=${Number(bid.gasLimit)}`
|
|
67
|
-
);
|
|
64
|
+
if (bid.gasLimit !== payload.gasLimit) {
|
|
65
|
+
throw new Error(`Gas limit mismatch between payload and bid payload=${payload.gasLimit} bid=${bid.gasLimit}`);
|
|
68
66
|
}
|
|
69
67
|
if (!byteArrayEquals(bid.blockHash, payload.blockHash)) {
|
|
70
68
|
throw new Error(
|
package/src/chain/chain.ts
CHANGED
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import {PrivateKey} from "@libp2p/interface";
|
|
3
3
|
import {Type} from "@chainsafe/ssz";
|
|
4
4
|
import {BeaconConfig} from "@lodestar/config";
|
|
5
|
-
import {CheckpointWithHex, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice";
|
|
5
|
+
import {CheckpointWithHex, ForkChoiceStateGetter, IForkChoice, ProtoBlock, UpdateHeadOpt} from "@lodestar/fork-choice";
|
|
6
6
|
import {LoggerNode} from "@lodestar/logger/node";
|
|
7
7
|
import {
|
|
8
8
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
@@ -382,6 +382,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
382
382
|
blockStateCache.setHeadState(anchorState);
|
|
383
383
|
checkpointStateCache.add(checkpoint, anchorState);
|
|
384
384
|
|
|
385
|
+
const forkChoiceStateGetter: ForkChoiceStateGetter = ({stateRoot, checkpoint}) => {
|
|
386
|
+
if (stateRoot) return blockStateCache.get(stateRoot);
|
|
387
|
+
|
|
388
|
+
if (checkpoint) return checkpointStateCache.get({epoch: checkpoint.epoch, rootHex: checkpoint.rootHex});
|
|
389
|
+
|
|
390
|
+
return null;
|
|
391
|
+
};
|
|
392
|
+
|
|
385
393
|
const forkChoice = initializeForkChoice(
|
|
386
394
|
config,
|
|
387
395
|
emitter,
|
|
@@ -390,6 +398,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
390
398
|
isAnchorStateFinalized,
|
|
391
399
|
opts,
|
|
392
400
|
this.justifiedBalancesGetter.bind(this),
|
|
401
|
+
forkChoiceStateGetter,
|
|
393
402
|
metrics,
|
|
394
403
|
logger
|
|
395
404
|
);
|
package/src/chain/emitter.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {StrictEventEmitter} from "strict-event-emitter-types";
|
|
|
3
3
|
import {routes} from "@lodestar/api";
|
|
4
4
|
import {CheckpointWithHex} from "@lodestar/fork-choice";
|
|
5
5
|
import {IBeaconStateView} from "@lodestar/state-transition";
|
|
6
|
-
import {DataColumnSidecar, RootHex, deneb, phase0} from "@lodestar/types";
|
|
6
|
+
import {DataColumnSidecar, RootHex, Slot, deneb, phase0} from "@lodestar/types";
|
|
7
7
|
import {PeerIdStr} from "../util/peerId.js";
|
|
8
8
|
import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
|
|
9
9
|
import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/payloadEnvelopeInput.js";
|
|
@@ -94,7 +94,8 @@ export type ChainEventData = {
|
|
|
94
94
|
peer: PeerIdStr;
|
|
95
95
|
source: BlockInputSource;
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
// slot is the message slot, not necessarily the envelope's slot, but useful as a logging/prune hint
|
|
98
|
+
[ChainEvent.unknownEnvelopeBlockRoot]: {rootHex: RootHex; slot: Slot; peer?: PeerIdStr; source: BlockInputSource};
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
export type IChainEvents = ApiEvents & {
|
|
@@ -61,9 +61,6 @@ export enum BlockErrorCode {
|
|
|
61
61
|
TRANSACTIONS_TOO_BIG = "BLOCK_ERROR_TRANSACTIONS_TOO_BIG",
|
|
62
62
|
/** Execution engine is unavailable, syncing, or api call errored. Peers must not be downscored on this code */
|
|
63
63
|
EXECUTION_ENGINE_ERROR = "BLOCK_ERROR_EXECUTION_ERROR",
|
|
64
|
-
/** The attestation head block is too far behind the attestation slot, causing many skip slots.
|
|
65
|
-
This is deemed a DoS risk */
|
|
66
|
-
TOO_MANY_SKIPPED_SLOTS = "TOO_MANY_SKIPPED_SLOTS",
|
|
67
64
|
/** The blobs are unavailable */
|
|
68
65
|
DATA_UNAVAILABLE = "BLOCK_ERROR_DATA_UNAVAILABLE",
|
|
69
66
|
/** Block contains too many kzg commitments */
|
|
@@ -89,7 +86,6 @@ export type BlockErrorType =
|
|
|
89
86
|
| {code: BlockErrorCode.FUTURE_SLOT; blockSlot: Slot; currentSlot: Slot}
|
|
90
87
|
| {code: BlockErrorCode.STATE_ROOT_MISMATCH}
|
|
91
88
|
| {code: BlockErrorCode.GENESIS_BLOCK}
|
|
92
|
-
| {code: BlockErrorCode.TOO_MANY_SKIPPED_SLOTS; parentSlot: Slot; blockSlot: Slot}
|
|
93
89
|
| {code: BlockErrorCode.WOULD_REVERT_FINALIZED_SLOT; blockSlot: Slot; finalizedSlot: Slot}
|
|
94
90
|
| {code: BlockErrorCode.ALREADY_KNOWN; root: RootHex}
|
|
95
91
|
| {code: BlockErrorCode.REPEAT_PROPOSAL; proposerIndex: ValidatorIndex}
|
|
@@ -12,6 +12,7 @@ export enum ExecutionPayloadBidErrorCode {
|
|
|
12
12
|
UNKNOWN_PARENT_BLOCK_HASH = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_PARENT_BLOCK_HASH",
|
|
13
13
|
INVALID_SLOT = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SLOT",
|
|
14
14
|
NOT_LATER_THAN_PARENT = "EXECUTION_PAYLOAD_BID_ERROR_NOT_LATER_THAN_PARENT",
|
|
15
|
+
INVALID_PREV_RANDAO = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_PREV_RANDAO",
|
|
15
16
|
INVALID_SIGNATURE = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SIGNATURE",
|
|
16
17
|
NO_MATCHING_PROPOSER_PREFERENCES = "EXECUTION_PAYLOAD_BID_ERROR_NO_MATCHING_PROPOSER_PREFERENCES",
|
|
17
18
|
PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH",
|
|
@@ -43,6 +44,12 @@ export type ExecutionPayloadBidErrorType =
|
|
|
43
44
|
| {code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH; parentBlockHash: RootHex}
|
|
44
45
|
| {code: ExecutionPayloadBidErrorCode.INVALID_SLOT; builderIndex: BuilderIndex; slot: Slot}
|
|
45
46
|
| {code: ExecutionPayloadBidErrorCode.NOT_LATER_THAN_PARENT; parentSlot: Slot; slot: Slot}
|
|
47
|
+
| {
|
|
48
|
+
code: ExecutionPayloadBidErrorCode.INVALID_PREV_RANDAO;
|
|
49
|
+
builderIndex: BuilderIndex;
|
|
50
|
+
bidPrevRandao: string;
|
|
51
|
+
expectedPrevRandao: string;
|
|
52
|
+
}
|
|
46
53
|
| {code: ExecutionPayloadBidErrorCode.INVALID_SIGNATURE; builderIndex: BuilderIndex; slot: Slot}
|
|
47
54
|
| {
|
|
48
55
|
code: ExecutionPayloadBidErrorCode.NO_MATCHING_PROPOSER_PREFERENCES;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import {routes} from "@lodestar/api";
|
|
1
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
3
|
import {
|
|
3
4
|
ExecutionStatus,
|
|
4
5
|
ForkChoice,
|
|
6
|
+
ForkChoiceStateGetter,
|
|
5
7
|
ForkChoiceStore,
|
|
6
8
|
JustifiedBalancesGetter,
|
|
7
9
|
PayloadStatus,
|
|
@@ -45,6 +47,7 @@ export function initializeForkChoice(
|
|
|
45
47
|
isFinalizedState: boolean,
|
|
46
48
|
opts: ForkChoiceOpts,
|
|
47
49
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
50
|
+
stateGetter: ForkChoiceStateGetter,
|
|
48
51
|
metrics: Metrics | null,
|
|
49
52
|
logger?: Logger
|
|
50
53
|
): ForkChoice {
|
|
@@ -56,6 +59,7 @@ export function initializeForkChoice(
|
|
|
56
59
|
state,
|
|
57
60
|
opts,
|
|
58
61
|
justifiedBalancesGetter,
|
|
62
|
+
stateGetter,
|
|
59
63
|
metrics,
|
|
60
64
|
logger
|
|
61
65
|
)
|
|
@@ -66,6 +70,7 @@ export function initializeForkChoice(
|
|
|
66
70
|
state,
|
|
67
71
|
opts,
|
|
68
72
|
justifiedBalancesGetter,
|
|
73
|
+
stateGetter,
|
|
69
74
|
metrics,
|
|
70
75
|
logger
|
|
71
76
|
);
|
|
@@ -81,6 +86,7 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
81
86
|
state: IBeaconStateView,
|
|
82
87
|
opts: ForkChoiceOpts,
|
|
83
88
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
89
|
+
stateGetter: ForkChoiceStateGetter,
|
|
84
90
|
metrics: Metrics | null,
|
|
85
91
|
logger?: Logger
|
|
86
92
|
): ForkChoice {
|
|
@@ -112,9 +118,12 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
112
118
|
finalizedCheckpoint,
|
|
113
119
|
justifiedBalances,
|
|
114
120
|
justifiedBalancesGetter,
|
|
121
|
+
stateGetter,
|
|
115
122
|
{
|
|
116
123
|
onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
|
|
117
124
|
onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
|
|
125
|
+
onFastConfirmation: ({block, slot, currentSlot}) =>
|
|
126
|
+
emitter.emit(routes.events.EventType.fastConfirmation, {block, slot, currentSlot}),
|
|
118
127
|
}
|
|
119
128
|
),
|
|
120
129
|
|
|
@@ -172,6 +181,7 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
172
181
|
unfinalizedState: IBeaconStateView,
|
|
173
182
|
opts: ForkChoiceOpts,
|
|
174
183
|
justifiedBalancesGetter: JustifiedBalancesGetter,
|
|
184
|
+
stateGetter: ForkChoiceStateGetter,
|
|
175
185
|
metrics: Metrics | null,
|
|
176
186
|
logger?: Logger
|
|
177
187
|
): ForkChoice {
|
|
@@ -203,9 +213,12 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
203
213
|
finalizedCheckpoint,
|
|
204
214
|
justifiedBalances,
|
|
205
215
|
justifiedBalancesGetter,
|
|
216
|
+
stateGetter,
|
|
206
217
|
{
|
|
207
218
|
onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
|
|
208
219
|
onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
|
|
220
|
+
onFastConfirmation: ({block, slot, currentSlot}) =>
|
|
221
|
+
emitter.emit(routes.events.EventType.fastConfirmation, {block, slot, currentSlot}),
|
|
209
222
|
}
|
|
210
223
|
);
|
|
211
224
|
|
package/src/chain/options.ts
CHANGED
|
@@ -105,6 +105,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
105
105
|
proposerBoost: true,
|
|
106
106
|
proposerBoostReorg: true,
|
|
107
107
|
computeUnrealized: true,
|
|
108
|
+
fastConfirmation: false,
|
|
108
109
|
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
|
|
109
110
|
serveHistoricalState: false,
|
|
110
111
|
assertCorrectProgressiveBalances: false,
|
|
@@ -276,8 +276,8 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
276
276
|
// Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
|
|
277
277
|
let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
|
|
278
278
|
// Spec: should_build_on_full(store, head). `parentBlock` is the proposer's head
|
|
279
|
-
// (set by chain.getProposerHead(slot)). Returns false when the PTC majority
|
|
280
|
-
//
|
|
279
|
+
// (set by chain.getProposerHead(slot)). Returns false when the PTC majority signalled
|
|
280
|
+
// the blob data is not available or the payload was not timely, forcing a build on EMPTY (reorg).
|
|
281
281
|
const isBuildingOnFull = this.forkChoice.shouldBuildOnFull(parentBlock, blockSlot);
|
|
282
282
|
if (isBuildingOnFull) {
|
|
283
283
|
parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
|
|
@@ -344,7 +344,7 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
344
344
|
blockHash: executionPayload.blockHash,
|
|
345
345
|
prevRandao: currentState.getRandaoMix(currentState.epoch),
|
|
346
346
|
feeRecipient: executionPayload.feeRecipient,
|
|
347
|
-
gasLimit:
|
|
347
|
+
gasLimit: executionPayload.gasLimit,
|
|
348
348
|
builderIndex: BUILDER_INDEX_SELF_BUILD,
|
|
349
349
|
slot: blockSlot,
|
|
350
350
|
value: 0,
|
|
@@ -47,7 +47,6 @@ export interface IStateRegenerator extends IStateRegeneratorInternal {
|
|
|
47
47
|
getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
|
|
48
48
|
getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
|
|
49
49
|
pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
|
|
50
|
-
pruneOnFinalized(finalizedEpoch: Epoch): void;
|
|
51
50
|
processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
|
|
52
51
|
addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
|
|
53
52
|
updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
|
|
@@ -143,11 +143,6 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
|
|
143
143
|
this.blockStateCache.prune(headStateRoot);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
pruneOnFinalized(finalizedEpoch: number): void {
|
|
147
|
-
this.checkpointStateCache.pruneFinalized(finalizedEpoch);
|
|
148
|
-
this.blockStateCache.deleteAllBeforeEpoch(finalizedEpoch);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
146
|
processState(blockRootHex: RootHex, postState: IBeaconStateView): void {
|
|
152
147
|
this.blockStateCache.add(postState);
|
|
153
148
|
this.checkpointStateCache.processState(blockRootHex, postState).catch((e) => {
|
|
@@ -167,12 +167,6 @@ export class FIFOBlockStateCache implements BlockStateCache {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
/**
|
|
171
|
-
* No need for this implementation
|
|
172
|
-
* This is only to conform to the old api
|
|
173
|
-
*/
|
|
174
|
-
deleteAllBeforeEpoch(): void {}
|
|
175
|
-
|
|
176
170
|
/**
|
|
177
171
|
* ONLY FOR DEBUGGING PURPOSES. For lodestar debug API.
|
|
178
172
|
*/
|
|
@@ -414,11 +414,12 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Prune all checkpoint states before the provided finalized epoch.
|
|
417
|
+
* Driven sequentially from processState() so it never interleaves with persist.
|
|
417
418
|
*/
|
|
418
|
-
pruneFinalized(finalizedEpoch: Epoch): void {
|
|
419
|
+
private async pruneFinalized(finalizedEpoch: Epoch): Promise<void> {
|
|
419
420
|
for (const epoch of this.epochIndex.keys()) {
|
|
420
421
|
if (epoch < finalizedEpoch) {
|
|
421
|
-
this.deleteAllEpochItems(epoch).catch((e) =>
|
|
422
|
+
await this.deleteAllEpochItems(epoch).catch((e) =>
|
|
422
423
|
this.logger.debug("Error delete all epoch items", {epoch, finalizedEpoch}, e as Error)
|
|
423
424
|
);
|
|
424
425
|
}
|
|
@@ -476,6 +477,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
|
|
|
476
477
|
* As of Mar 2024, it takes <=350ms to persist a holesky state on fast server
|
|
477
478
|
*/
|
|
478
479
|
async processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number> {
|
|
480
|
+
// prune finalized in the same flow so a finalized cp state is pruned, never persisted
|
|
481
|
+
await this.pruneFinalized(state.finalizedCheckpoint.epoch);
|
|
482
|
+
|
|
479
483
|
let persistCount = 0;
|
|
480
484
|
// it's important to sort the epochs in ascending order, in case of big reorg we always want to keep the most recent checkpoint states
|
|
481
485
|
const sortedEpochs = Array.from(this.epochIndex.keys()).sort((a, b) => a - b);
|
|
@@ -30,7 +30,6 @@ export interface BlockStateCache {
|
|
|
30
30
|
clear(): void;
|
|
31
31
|
size: number;
|
|
32
32
|
prune(headStateRootHex: RootHex): void;
|
|
33
|
-
deleteAllBeforeEpoch(finalizedEpoch: Epoch): void;
|
|
34
33
|
dumpSummary(): routes.lodestar.StateCacheItem[];
|
|
35
34
|
/** Expose beacon states stored in cache. Use with caution */
|
|
36
35
|
getStates(): IterableIterator<IBeaconStateView>;
|
|
@@ -67,7 +66,6 @@ export interface CheckpointStateCache {
|
|
|
67
66
|
getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch): Promise<IBeaconStateView | null>;
|
|
68
67
|
updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null;
|
|
69
68
|
prune(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void;
|
|
70
|
-
pruneFinalized(finalizedEpoch: Epoch): void;
|
|
71
69
|
processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number>;
|
|
72
70
|
clear(): void;
|
|
73
71
|
dumpSummary(): routes.lodestar.StateCacheItem[];
|