@lodestar/beacon-node 1.50.0-dev.773f874b05 → 1.50.0-dev.791f801899
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/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/index.js +13 -0
- package/lib/api/impl/beacon/index.js.map +1 -1
- package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +28 -6
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +26 -18
- 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 +6 -0
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts +5 -0
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +13 -23
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +2 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +13 -6
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +6 -6
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/chain.d.ts +4 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +60 -20
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -2
- package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
- package/lib/chain/opPools/aggregatedAttestationPool.js +30 -8
- package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +1 -23
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +8 -4
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +27 -12
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +11 -0
- package/lib/chain/opPools/utils.d.ts.map +1 -1
- package/lib/chain/opPools/utils.js +22 -0
- package/lib/chain/opPools/utils.js.map +1 -1
- package/lib/chain/options.d.ts +1 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -0
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +21 -0
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +18 -8
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +72 -18
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/db/beacon.d.ts +4 -1
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +6 -1
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +3 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +2 -0
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +4 -1
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/earliestAvailableSlot.d.ts +11 -0
- package/lib/db/repositories/earliestAvailableSlot.d.ts.map +1 -0
- package/lib/db/repositories/earliestAvailableSlot.js +19 -0
- package/lib/db/repositories/earliestAvailableSlot.js.map +1 -0
- package/lib/db/repositories/index.d.ts +1 -0
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +1 -0
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/db/repositories/proposerPreferences.d.ts +14 -0
- package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
- package/lib/db/repositories/proposerPreferences.js +21 -0
- package/lib/db/repositories/proposerPreferences.js.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.js +74 -0
- package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
- package/lib/execution/engine/http.d.ts +45 -13
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +236 -198
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/index.d.ts +3 -2
- package/lib/execution/engine/index.d.ts.map +1 -1
- package/lib/execution/engine/index.js +33 -8
- package/lib/execution/engine/index.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -1
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
- package/lib/execution/engine/jsonRpcTransport.js +158 -0
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
- package/lib/execution/engine/restHttpClient.d.ts +71 -0
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
- package/lib/execution/engine/restHttpClient.js +201 -0
- package/lib/execution/engine/restHttpClient.js.map +1 -0
- package/lib/execution/engine/restTransport.d.ts +46 -0
- package/lib/execution/engine/restTransport.d.ts.map +1 -0
- package/lib/execution/engine/restTransport.js +399 -0
- package/lib/execution/engine/restTransport.js.map +1 -0
- package/lib/execution/engine/sszTypes.d.ts +1261 -0
- package/lib/execution/engine/sszTypes.d.ts.map +1 -0
- package/lib/execution/engine/sszTypes.js +216 -0
- package/lib/execution/engine/sszTypes.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +39 -0
- package/lib/execution/engine/transport.d.ts.map +1 -0
- package/lib/execution/engine/transport.js +2 -0
- package/lib/execution/engine/transport.js.map +1 -0
- package/lib/execution/engine/types.d.ts +2 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +24 -57
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/execution/engine/utils.d.ts.map +1 -1
- package/lib/execution/engine/utils.js +9 -2
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +10 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +22 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +5 -1
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +8 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +59 -63
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/node/nodejs.d.ts +3 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +2 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/options.d.ts +3 -2
- package/lib/node/options.d.ts.map +1 -1
- package/lib/node/options.js +2 -2
- package/lib/node/options.js.map +1 -1
- package/lib/sync/range/batch.d.ts +5 -5
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +11 -17
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts +4 -4
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +7 -5
- 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 +25 -11
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +5 -2
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +44 -20
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +38 -14
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +84 -39
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +10 -2
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +29 -3
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/metadata.d.ts.map +1 -1
- package/lib/util/metadata.js +2 -1
- package/lib/util/metadata.js.map +1 -1
- package/package.json +17 -16
- package/src/api/impl/beacon/index.ts +15 -0
- package/src/api/impl/beacon/state/index.ts +43 -6
- package/src/api/impl/debug/index.ts +28 -19
- package/src/api/impl/validator/index.ts +8 -0
- package/src/chain/archiveStore/archiveStore.ts +18 -24
- package/src/chain/archiveStore/utils/pruneHistory.ts +4 -1
- package/src/chain/blocks/importBlock.ts +16 -5
- package/src/chain/blocks/verifyBlock.ts +7 -6
- package/src/chain/chain.ts +82 -19
- package/src/chain/interface.ts +1 -0
- package/src/chain/opPools/aggregatedAttestationPool.ts +34 -10
- package/src/chain/opPools/opPool.ts +1 -31
- package/src/chain/opPools/proposerPreferencesPool.ts +34 -11
- package/src/chain/opPools/utils.ts +31 -0
- package/src/chain/options.ts +1 -1
- package/src/chain/seenCache/seenGossipBlockInput.ts +23 -0
- package/src/chain/shufflingCache.ts +84 -22
- package/src/db/beacon.ts +6 -0
- package/src/db/buckets.ts +2 -0
- package/src/db/interface.ts +4 -0
- package/src/db/repositories/earliestAvailableSlot.ts +19 -0
- package/src/db/repositories/index.ts +1 -0
- package/src/db/repositories/proposerPreferences.ts +23 -0
- package/src/execution/engine/blobVersionedHashes.ts +72 -0
- package/src/execution/engine/http.ts +304 -271
- package/src/execution/engine/index.ts +41 -7
- package/src/execution/engine/interface.ts +1 -1
- package/src/execution/engine/jsonRpcTransport.ts +247 -0
- package/src/execution/engine/restHttpClient.ts +269 -0
- package/src/execution/engine/restTransport.ts +544 -0
- package/src/execution/engine/sszTypes.ts +354 -0
- package/src/execution/engine/transport.ts +61 -0
- package/src/execution/engine/types.ts +34 -74
- package/src/execution/engine/utils.ts +12 -2
- package/src/metrics/metrics/lodestar.ts +23 -0
- package/src/network/core/events.ts +16 -1
- package/src/network/processor/gossipHandlers.ts +90 -76
- package/src/node/nodejs.ts +4 -0
- package/src/node/options.ts +10 -1
- package/src/sync/range/batch.ts +14 -19
- package/src/sync/range/chain.ts +9 -7
- package/src/sync/range/range.ts +26 -12
- package/src/sync/unknownBlock.ts +57 -21
- package/src/sync/utils/downloadByRange.ts +123 -58
- package/src/util/asyncIterableToEvents.ts +44 -5
- package/src/util/metadata.ts +2 -1
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.50.0-dev.
|
|
14
|
+
"version": "1.50.0-dev.791f801899",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@chainsafe/persistent-merkle-tree": "^1.3.1",
|
|
110
110
|
"@chainsafe/prometheus-gc-stats": "^1.0.0",
|
|
111
111
|
"@chainsafe/snappy-wasm": "^0.5.2",
|
|
112
|
-
"@chainsafe/ssz": "^1.8.
|
|
112
|
+
"@chainsafe/ssz": "^1.8.1",
|
|
113
113
|
"@chainsafe/threads": "^1.11.3",
|
|
114
114
|
"@crate-crypto/node-eth-kzg": "0.9.1",
|
|
115
115
|
"@fastify/bearer-auth": "^10.0.1",
|
|
@@ -127,17 +127,17 @@
|
|
|
127
127
|
"@libp2p/prometheus-metrics": "^5.0.28",
|
|
128
128
|
"@libp2p/tcp": "^11.0.27",
|
|
129
129
|
"@libp2p/utils": "^7.4.0",
|
|
130
|
-
"@lodestar/api": "^1.50.0-dev.
|
|
131
|
-
"@lodestar/config": "^1.50.0-dev.
|
|
132
|
-
"@lodestar/db": "^1.50.0-dev.
|
|
133
|
-
"@lodestar/fork-choice": "^1.50.0-dev.
|
|
134
|
-
"@lodestar/logger": "^1.50.0-dev.
|
|
135
|
-
"@lodestar/params": "^1.50.0-dev.
|
|
136
|
-
"@lodestar/reqresp": "^1.50.0-dev.
|
|
137
|
-
"@lodestar/state-transition": "^1.50.0-dev.
|
|
138
|
-
"@lodestar/types": "^1.50.0-dev.
|
|
139
|
-
"@lodestar/utils": "^1.50.0-dev.
|
|
140
|
-
"@lodestar/validator": "^1.50.0-dev.
|
|
130
|
+
"@lodestar/api": "^1.50.0-dev.791f801899",
|
|
131
|
+
"@lodestar/config": "^1.50.0-dev.791f801899",
|
|
132
|
+
"@lodestar/db": "^1.50.0-dev.791f801899",
|
|
133
|
+
"@lodestar/fork-choice": "^1.50.0-dev.791f801899",
|
|
134
|
+
"@lodestar/logger": "^1.50.0-dev.791f801899",
|
|
135
|
+
"@lodestar/params": "^1.50.0-dev.791f801899",
|
|
136
|
+
"@lodestar/reqresp": "^1.50.0-dev.791f801899",
|
|
137
|
+
"@lodestar/state-transition": "^1.50.0-dev.791f801899",
|
|
138
|
+
"@lodestar/types": "^1.50.0-dev.791f801899",
|
|
139
|
+
"@lodestar/utils": "^1.50.0-dev.791f801899",
|
|
140
|
+
"@lodestar/validator": "^1.50.0-dev.791f801899",
|
|
141
141
|
"@multiformats/multiaddr": "^13.0.1",
|
|
142
142
|
"datastore-core": "^12.0.1",
|
|
143
143
|
"datastore-level": "^13.0.1",
|
|
@@ -156,10 +156,11 @@
|
|
|
156
156
|
"xxhash-wasm": "1.0.2"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
+
"@ethereumjs/rlp": "^4.0.1",
|
|
159
160
|
"@libp2p/interface-internal": "^3.1.12",
|
|
160
161
|
"@libp2p/logger": "^6.2.13",
|
|
161
|
-
"@lodestar/spec-test-util": "^1.50.0-dev.
|
|
162
|
-
"@lodestar/test-utils": "^1.50.0-dev.
|
|
162
|
+
"@lodestar/spec-test-util": "^1.50.0-dev.791f801899",
|
|
163
|
+
"@lodestar/test-utils": "^1.50.0-dev.791f801899",
|
|
163
164
|
"@types/js-yaml": "^4.0.5",
|
|
164
165
|
"@types/qs": "^6.9.7",
|
|
165
166
|
"@types/tmp": "^0.2.3",
|
|
@@ -174,5 +175,5 @@
|
|
|
174
175
|
"beacon",
|
|
175
176
|
"blockchain"
|
|
176
177
|
],
|
|
177
|
-
"gitHead": "
|
|
178
|
+
"gitHead": "cdc3d0477a8809259182fe50777624f3297211cf"
|
|
178
179
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
|
+
import {isForkPostGloas} from "@lodestar/params";
|
|
4
|
+
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
5
|
+
import {toRootHex} from "@lodestar/utils";
|
|
6
|
+
import {ApiError} from "../errors.js";
|
|
3
7
|
import {ApiModules} from "../types.js";
|
|
4
8
|
import {getBeaconBlockApi} from "./blocks/index.js";
|
|
5
9
|
import {getBeaconPoolApi} from "./pool/index.js";
|
|
@@ -31,5 +35,16 @@ export function getBeaconApi(
|
|
|
31
35
|
},
|
|
32
36
|
};
|
|
33
37
|
},
|
|
38
|
+
|
|
39
|
+
async getProposerPreferences({slot, dependentRoot}) {
|
|
40
|
+
// Preferences are broadcast up to one epoch ahead of their proposal slot, the first ones before Gloas is active
|
|
41
|
+
const fork = config.getForkName(slot ?? computeStartSlotAtEpoch(chain.clock.currentEpoch + 1));
|
|
42
|
+
if (!isForkPostGloas(fork)) {
|
|
43
|
+
throw new ApiError(400, `Proposer preferences are not supported before Gloas fork=${fork}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const preferences = chain.proposerPreferencesPool.getAll(slot, dependentRoot && toRootHex(dependentRoot));
|
|
47
|
+
return {data: preferences, meta: {version: fork}};
|
|
48
|
+
},
|
|
34
49
|
};
|
|
35
50
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {routes} from "@lodestar/api";
|
|
2
2
|
import {ApplicationMethods} from "@lodestar/api/server";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
EPOCHS_PER_HISTORICAL_VECTOR,
|
|
5
|
+
MIN_SEED_LOOKAHEAD,
|
|
6
|
+
SLOTS_PER_EPOCH,
|
|
7
|
+
SYNC_COMMITTEE_SUBNET_SIZE,
|
|
8
|
+
} from "@lodestar/params";
|
|
4
9
|
import {
|
|
5
10
|
IBeaconStateView,
|
|
6
11
|
computeEpochAtSlot,
|
|
@@ -11,7 +16,14 @@ import {
|
|
|
11
16
|
isStatePostFulu,
|
|
12
17
|
isStatePostGloas,
|
|
13
18
|
} from "@lodestar/state-transition";
|
|
14
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
ValidatorIndex,
|
|
21
|
+
getBuilderStatus,
|
|
22
|
+
getValidatorStatus,
|
|
23
|
+
mapToGeneralStatus,
|
|
24
|
+
ssz,
|
|
25
|
+
sszTypesFor,
|
|
26
|
+
} from "@lodestar/types";
|
|
15
27
|
import {ApiError} from "../../errors.js";
|
|
16
28
|
import {ApiModules} from "../../types.js";
|
|
17
29
|
import {assertUniqueItems} from "../../utils.js";
|
|
@@ -100,7 +112,8 @@ export function getBeaconStateApi({
|
|
|
100
112
|
if (resp.valid) {
|
|
101
113
|
const validatorIndex = resp.validatorIndex;
|
|
102
114
|
const validator = state.getValidator(validatorIndex);
|
|
103
|
-
|
|
115
|
+
const status = getValidatorStatus(validator, currentEpoch);
|
|
116
|
+
if (statuses.length && !statuses.includes(status) && !statuses.includes(mapToGeneralStatus(status))) {
|
|
104
117
|
continue;
|
|
105
118
|
}
|
|
106
119
|
const validatorResponse = toValidatorResponse(
|
|
@@ -374,6 +387,28 @@ export function getBeaconStateApi({
|
|
|
374
387
|
};
|
|
375
388
|
},
|
|
376
389
|
|
|
390
|
+
async getStatePtc({stateId, slot}) {
|
|
391
|
+
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
392
|
+
if (!isStatePostGloas(state)) {
|
|
393
|
+
throw new ApiError(400, `Cannot retrieve PTC for pre-gloas state fork=${state.forkName}`);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const usedSlot = slot ?? state.slot;
|
|
397
|
+
const epoch = computeEpochAtSlot(usedSlot);
|
|
398
|
+
const stateEpoch = computeEpochAtSlot(state.slot);
|
|
399
|
+
if (epoch < config.GLOAS_FORK_EPOCH) {
|
|
400
|
+
throw new ApiError(400, `Cannot retrieve PTC for pre-gloas slot=${usedSlot}`);
|
|
401
|
+
}
|
|
402
|
+
if (epoch < stateEpoch - 1 || epoch > stateEpoch + MIN_SEED_LOOKAHEAD) {
|
|
403
|
+
throw new ApiError(400, `Slot ${usedSlot} is outside the PTC window of state epoch ${stateEpoch}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
data: {slot: usedSlot, validators: Array.from(state.getPayloadTimelinessCommittee(usedSlot))},
|
|
408
|
+
meta: {executionOptimistic, finalized},
|
|
409
|
+
};
|
|
410
|
+
},
|
|
411
|
+
|
|
377
412
|
async getPendingDeposits({stateId}, context) {
|
|
378
413
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
379
414
|
const fork = state.forkName;
|
|
@@ -385,7 +420,9 @@ export function getBeaconStateApi({
|
|
|
385
420
|
const pendingDeposits = state.pendingDeposits;
|
|
386
421
|
|
|
387
422
|
return {
|
|
388
|
-
data: context?.returnBytes
|
|
423
|
+
data: context?.returnBytes
|
|
424
|
+
? sszTypesFor(state.forkName).PendingDeposits.serialize(pendingDeposits)
|
|
425
|
+
: pendingDeposits,
|
|
389
426
|
meta: {executionOptimistic, finalized, version: fork},
|
|
390
427
|
};
|
|
391
428
|
},
|
|
@@ -402,7 +439,7 @@ export function getBeaconStateApi({
|
|
|
402
439
|
|
|
403
440
|
return {
|
|
404
441
|
data: context?.returnBytes
|
|
405
|
-
?
|
|
442
|
+
? sszTypesFor(state.forkName).PendingPartialWithdrawals.serialize(pendingPartialWithdrawals)
|
|
406
443
|
: pendingPartialWithdrawals,
|
|
407
444
|
meta: {executionOptimistic, finalized, version: fork},
|
|
408
445
|
};
|
|
@@ -420,7 +457,7 @@ export function getBeaconStateApi({
|
|
|
420
457
|
|
|
421
458
|
return {
|
|
422
459
|
data: context?.returnBytes
|
|
423
|
-
?
|
|
460
|
+
? sszTypesFor(state.forkName).PendingConsolidations.serialize(pendingConsolidations)
|
|
424
461
|
: pendingConsolidations,
|
|
425
462
|
meta: {executionOptimistic, finalized, version: fork},
|
|
426
463
|
};
|
|
@@ -4,7 +4,7 @@ import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
|
|
|
4
4
|
import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
|
|
5
5
|
import {computeTimeAtSlot} from "@lodestar/state-transition";
|
|
6
6
|
import {BeaconState, DataColumnSidecar, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
|
|
7
|
-
import {toRootHex} from "@lodestar/utils";
|
|
7
|
+
import {fromHex, toRootHex} from "@lodestar/utils";
|
|
8
8
|
import {getBlobKzgCommitments} from "../../../util/dataColumns.js";
|
|
9
9
|
import {isOptimisticBlock} from "../../../util/forkChoice.js";
|
|
10
10
|
import {getStateSlotFromBytes} from "../../../util/multifork.js";
|
|
@@ -74,46 +74,55 @@ export function getDebugApi({
|
|
|
74
74
|
|
|
75
75
|
async getDebugForkChoiceV2() {
|
|
76
76
|
const {forkChoice} = chain;
|
|
77
|
+
const nodes = forkChoice.getAllNodes();
|
|
78
|
+
const head = forkChoice.getHead();
|
|
77
79
|
return {
|
|
78
80
|
data: {
|
|
79
81
|
justifiedCheckpoint: forkChoice.getJustifiedCheckpoint(),
|
|
80
82
|
finalizedCheckpoint: forkChoice.getFinalizedCheckpoint(),
|
|
81
|
-
forkChoiceNodes:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const ptc = node.payloadStatus === PayloadStatus.FULL ? forkChoice.getPTCVoteCounts(node.blockRoot) : null;
|
|
83
|
+
forkChoiceNodes: nodes.map((node) => {
|
|
84
|
+
const parent = node.parent === undefined ? undefined : nodes[node.parent];
|
|
85
|
+
const ptc = forkChoice.getPTCVoteCounts(node.blockRoot);
|
|
85
86
|
return {
|
|
86
|
-
payloadStatus: toPayloadStatusName(node.payloadStatus),
|
|
87
87
|
slot: node.slot,
|
|
88
88
|
blockRoot: node.blockRoot,
|
|
89
|
-
|
|
89
|
+
payloadStatus: toPayloadStatusName(node.payloadStatus),
|
|
90
|
+
parentRoot:
|
|
91
|
+
node.parentBlockHash !== null && node.payloadStatus !== PayloadStatus.PENDING
|
|
92
|
+
? node.blockRoot
|
|
93
|
+
: node.parentRoot,
|
|
94
|
+
parentPayloadStatus: parent === undefined ? null : toPayloadStatusName(parent.payloadStatus),
|
|
95
|
+
justifiedCheckpoint: {epoch: node.justifiedEpoch, root: fromHex(node.justifiedRoot)},
|
|
96
|
+
finalizedCheckpoint: {epoch: node.finalizedEpoch, root: fromHex(node.finalizedRoot)},
|
|
90
97
|
weight: node.weight,
|
|
91
98
|
validity: toForkChoiceValidity(node.executionStatus),
|
|
92
99
|
executionBlockHash: node.executionPayloadBlockHash ?? ZERO_HASH_HEX,
|
|
100
|
+
payloadAttesterCount: ptc?.attesterCount ?? 0,
|
|
101
|
+
payloadAvailabilityYesCount: ptc?.payloadPresentCount ?? 0,
|
|
102
|
+
payloadDataAvailabilityYesCount: ptc?.dataAvailableCount ?? 0,
|
|
93
103
|
extraData: {
|
|
104
|
+
attestationScore: node.attestationScore,
|
|
94
105
|
executionOptimistic: isOptimisticBlock(node),
|
|
106
|
+
gasLimit:
|
|
107
|
+
node.payloadStatus === PayloadStatus.FULL && node.executionStatus !== ExecutionStatus.PreMerge
|
|
108
|
+
? node.executionPayloadGasLimit
|
|
109
|
+
: null,
|
|
95
110
|
timestamp: computeTimeAtSlot(config, node.slot, chain.genesisTime),
|
|
111
|
+
stateRoot: node.stateRoot,
|
|
96
112
|
target: node.targetRoot,
|
|
97
|
-
justifiedEpoch: node.justifiedEpoch,
|
|
98
|
-
finalizedEpoch: node.finalizedEpoch,
|
|
99
113
|
unrealizedJustifiedEpoch: node.unrealizedJustifiedEpoch,
|
|
114
|
+
unrealizedJustifiedRoot: node.unrealizedJustifiedRoot,
|
|
100
115
|
unrealizedFinalizedEpoch: node.unrealizedFinalizedEpoch,
|
|
101
|
-
|
|
102
|
-
payloadAvailabilityYesCount: ptc?.payloadPresentCount ?? null,
|
|
103
|
-
payloadDataAvailabilityYesCount: ptc?.dataAvailableCount ?? null,
|
|
104
|
-
gasLimit:
|
|
105
|
-
node.payloadStatus === PayloadStatus.FULL && "executionPayloadGasLimit" in node
|
|
106
|
-
? node.executionPayloadGasLimit
|
|
107
|
-
: null,
|
|
116
|
+
unrealizedFinalizedRoot: node.unrealizedFinalizedRoot,
|
|
108
117
|
},
|
|
109
118
|
};
|
|
110
119
|
}),
|
|
111
120
|
extraData: {
|
|
112
|
-
|
|
113
|
-
unrealizedFinalizedCheckpoint: forkChoice.getUnrealizedFinalizedCheckpoint(),
|
|
121
|
+
head: {blockRoot: head.blockRoot, payloadStatus: toPayloadStatusName(head.payloadStatus)},
|
|
114
122
|
proposerBoostRoot: forkChoice.getProposerBoostRoot(),
|
|
115
123
|
previousProposerBoostRoot: forkChoice.getPreviousProposerBoostRoot(),
|
|
116
|
-
|
|
124
|
+
unrealizedJustifiedCheckpoint: forkChoice.getUnrealizedJustifiedCheckpoint(),
|
|
125
|
+
unrealizedFinalizedCheckpoint: forkChoice.getUnrealizedFinalizedCheckpoint(),
|
|
117
126
|
},
|
|
118
127
|
},
|
|
119
128
|
};
|
|
@@ -1300,6 +1300,10 @@ export function getValidatorApi(
|
|
|
1300
1300
|
blobs: blobsBundle.blobs,
|
|
1301
1301
|
};
|
|
1302
1302
|
|
|
1303
|
+
if (chain.opts.persistProducedPayloadEnvelopes) {
|
|
1304
|
+
chain.persistExecutionPayloadEnvelope(blockContents.executionPayloadEnvelope);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1303
1307
|
return {
|
|
1304
1308
|
data: blockContents,
|
|
1305
1309
|
meta: {version: fork, consensusBlockValue, executionPayloadValue, executionPayloadIncluded: true},
|
|
@@ -2187,6 +2191,10 @@ export function getValidatorApi(
|
|
|
2187
2191
|
blockHash: toRootHex(executionPayload.blockHash),
|
|
2188
2192
|
});
|
|
2189
2193
|
|
|
2194
|
+
if (chain.opts.persistProducedPayloadEnvelopes) {
|
|
2195
|
+
chain.persistExecutionPayloadEnvelope(envelope);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2190
2198
|
return {
|
|
2191
2199
|
data: envelope,
|
|
2192
2200
|
meta: {
|
|
@@ -113,7 +113,9 @@ export class ArchiveStore {
|
|
|
113
113
|
this.logger,
|
|
114
114
|
this.metrics,
|
|
115
115
|
this.opts.anchorState.finalizedCheckpoint.epoch,
|
|
116
|
-
this.chain.clock.currentEpoch
|
|
116
|
+
this.chain.clock.currentEpoch,
|
|
117
|
+
this.statePruneFromSlot,
|
|
118
|
+
this.advanceEarliestAvailableSlot
|
|
117
119
|
),
|
|
118
120
|
() => this.logger.info("Still pruning historical data, please wait..."),
|
|
119
121
|
30_000,
|
|
@@ -122,26 +124,6 @@ export class ArchiveStore {
|
|
|
122
124
|
this.statePruneFromSlot = stateCutoffSlot;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
// Initialize earliestAvailableSlot from the earliest block actually retained (after any pruning
|
|
126
|
-
// above), rather than the anchor state slot set in the constructor. On an in-place restart the DB
|
|
127
|
-
// still holds finalized history below the anchor; leaving the value at the anchor makes the node
|
|
128
|
-
// reject by_range requests (beacon_blocks, execution_payload_envelopes and data_column_sidecars
|
|
129
|
-
// all gate on this slot) for data it still retains. An empty archive (e.g. a fresh checkpoint
|
|
130
|
-
// sync with nothing below the anchor) leaves the constructor's anchor slot in place.
|
|
131
|
-
const earliestArchivedBlockSlot = await this.db.blockArchive.firstKey();
|
|
132
|
-
if (earliestArchivedBlockSlot != null) {
|
|
133
|
-
const oldEarliestAvailableSlot = this.chain.earliestAvailableSlot;
|
|
134
|
-
this.chain.earliestAvailableSlot = earliestArchivedBlockSlot;
|
|
135
|
-
this.logger.verbose("Initialized earliestAvailableSlot from retained block archive", {
|
|
136
|
-
oldEarliestAvailableSlot,
|
|
137
|
-
newEarliestAvailableSlot: earliestArchivedBlockSlot,
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
this.logger.verbose("Empty block archive on init, keeping anchor earliestAvailableSlot", {
|
|
141
|
-
earliestAvailableSlot: this.chain.earliestAvailableSlot,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
127
|
if (this.opts.serveHistoricalState) {
|
|
146
128
|
this.historicalStateRegen = await HistoricalStateRegen.init({
|
|
147
129
|
opts: {
|
|
@@ -158,6 +140,18 @@ export class ArchiveStore {
|
|
|
158
140
|
}
|
|
159
141
|
}
|
|
160
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The CLI owns the initial value; this only advances it during pruneHistory.
|
|
145
|
+
* Persisted before any deletion so a crash mid-prune never leaves the floor below deleted data.
|
|
146
|
+
*/
|
|
147
|
+
private advanceEarliestAvailableSlot = async (blockCutoffSlot: Slot): Promise<void> => {
|
|
148
|
+
const earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
|
|
149
|
+
if (earliestAvailableSlot !== this.chain.earliestAvailableSlot) {
|
|
150
|
+
await this.db.earliestAvailableSlot.set(earliestAvailableSlot);
|
|
151
|
+
this.chain.earliestAvailableSlot = earliestAvailableSlot;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
161
155
|
async close(): Promise<void> {
|
|
162
156
|
await this.historicalStateRegen?.close();
|
|
163
157
|
}
|
|
@@ -259,17 +253,17 @@ export class ArchiveStore {
|
|
|
259
253
|
|
|
260
254
|
if (this.opts.pruneHistory) {
|
|
261
255
|
timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
|
|
262
|
-
const {
|
|
256
|
+
const {stateCutoffSlot} = await pruneHistory(
|
|
263
257
|
this.chain.config,
|
|
264
258
|
this.db,
|
|
265
259
|
this.logger,
|
|
266
260
|
this.metrics,
|
|
267
261
|
finalizedEpoch,
|
|
268
262
|
this.chain.clock.currentEpoch,
|
|
269
|
-
this.statePruneFromSlot
|
|
263
|
+
this.statePruneFromSlot,
|
|
264
|
+
this.advanceEarliestAvailableSlot
|
|
270
265
|
);
|
|
271
266
|
this.statePruneFromSlot = stateCutoffSlot;
|
|
272
|
-
this.chain.earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
|
|
273
267
|
timer?.({source: ArchiveStoreTask.PruneHistory});
|
|
274
268
|
}
|
|
275
269
|
|
|
@@ -12,7 +12,8 @@ export async function pruneHistory(
|
|
|
12
12
|
metrics: Metrics | null | undefined,
|
|
13
13
|
finalizedEpoch: Epoch,
|
|
14
14
|
currentEpoch: Epoch,
|
|
15
|
-
statePruneFromSlot: Slot
|
|
15
|
+
statePruneFromSlot: Slot,
|
|
16
|
+
beforePrune: (blockCutoffSlot: Slot) => Promise<void>
|
|
16
17
|
): Promise<{blockCutoffSlot: Slot; stateCutoffSlot: Slot}> {
|
|
17
18
|
const blockCutoffEpoch = Math.min(
|
|
18
19
|
// set by config, with underflow protection
|
|
@@ -51,6 +52,8 @@ export async function pruneHistory(
|
|
|
51
52
|
stateSlots: prettyPrintIndices(states),
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
await beforePrune(blockCutoffSlot);
|
|
56
|
+
|
|
54
57
|
const step1 = metrics?.pruneHistory.pruneKeys.startTimer();
|
|
55
58
|
await Promise.all([
|
|
56
59
|
// ->
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
RootCache,
|
|
23
23
|
computeEpochAtSlot,
|
|
24
24
|
computeTimeAtSlot,
|
|
25
|
+
getBeaconCommittees,
|
|
25
26
|
isStatePostAltair,
|
|
26
27
|
isStatePostBellatrix,
|
|
27
28
|
} from "@lodestar/state-transition";
|
|
@@ -129,11 +130,17 @@ export async function importBlock(
|
|
|
129
130
|
|
|
130
131
|
// Should compute checkpoint balances before forkchoice.onBlock
|
|
131
132
|
this.checkpointBalancesCache.processState(blockRootHex, postState);
|
|
132
|
-
if (
|
|
133
|
+
if (isGloasBeaconBlock(block.message)) {
|
|
134
|
+
// A gloas block has no payload of its own, it inherits the status of the payload it builds on,
|
|
135
|
+
// i.e. the parent variant matching the bid's parent block hash. The parent's default (PENDING)
|
|
136
|
+
// variant does not reflect a SYNCING parent payload, and onBlock would then mark that payload VALID.
|
|
133
137
|
const parentRootHex = toRootHex(block.message.parentRoot);
|
|
134
|
-
const
|
|
138
|
+
const parentBlockHashHex = toRootHex(block.message.body.signedExecutionPayloadBid.message.parentBlockHash);
|
|
139
|
+
const parentBlock = this.forkChoice.getBlockHexAndBlockHash(parentRootHex, parentBlockHashHex);
|
|
135
140
|
if (parentBlock === null) {
|
|
136
|
-
throw Error(
|
|
141
|
+
throw Error(
|
|
142
|
+
`Parent block not found in forkChoice, parentRoot=${parentRootHex} parentBlockHash=${parentBlockHashHex}`
|
|
143
|
+
);
|
|
137
144
|
}
|
|
138
145
|
if (parentBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
139
146
|
throw Error(`Parent block has invalid execution status, parentRoot=${parentRootHex}`);
|
|
@@ -657,8 +664,12 @@ export function addAttestationPostElectra(
|
|
|
657
664
|
} else {
|
|
658
665
|
const attSlot = attestation.data.slot;
|
|
659
666
|
const attEpoch = computeEpochAtSlot(attSlot);
|
|
660
|
-
|
|
661
|
-
|
|
667
|
+
// calling getShufflingAtEpoch may take some time for NativeBeaconStateView
|
|
668
|
+
// we should have the shuffling inside ShufflingCache most of the time
|
|
669
|
+
const shuffling =
|
|
670
|
+
this.shufflingCache.getSync(attEpoch, state.getShufflingDecisionRoot(attEpoch)) ??
|
|
671
|
+
state.getShufflingAtEpoch(attEpoch);
|
|
672
|
+
const committees = getBeaconCommittees(shuffling, attSlot, committeeIndices);
|
|
662
673
|
const aggregationBools = attestation.aggregationBits.toBoolArray();
|
|
663
674
|
let offset = 0;
|
|
664
675
|
for (let i = 0; i < committees.length; i++) {
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DataAvailabilityStatus,
|
|
5
5
|
IBeaconStateView,
|
|
6
6
|
computeEpochAtSlot,
|
|
7
|
+
getIndexedAttestation,
|
|
7
8
|
signedBlockToSignedHeader,
|
|
8
9
|
} from "@lodestar/state-transition";
|
|
9
10
|
import {IndexedAttestation, Slot, deneb} from "@lodestar/types";
|
|
@@ -81,10 +82,6 @@ export async function verifyBlocksInEpoch(
|
|
|
81
82
|
throw new BlockError(block0, {code: BlockErrorCode.PRESTATE_MISSING, error: e as Error});
|
|
82
83
|
});
|
|
83
84
|
|
|
84
|
-
// in forky condition, make sure to populate ShufflingCache with regened state
|
|
85
|
-
// otherwise it may fail to get indexed attestations from shuffling cache later
|
|
86
|
-
this.shufflingCache.processState(preState0);
|
|
87
|
-
|
|
88
85
|
if (!preState0.isStateValidatorsNodesPopulated()) {
|
|
89
86
|
this.logger.verbose("verifyBlocksInEpoch preState0 SSZ cache stats", {
|
|
90
87
|
slot: preState0.slot,
|
|
@@ -117,8 +114,12 @@ export async function verifyBlocksInEpoch(
|
|
|
117
114
|
for (const [i, block] of blocks.entries()) {
|
|
118
115
|
indexedAttestationsByBlock[i] = block.message.body.attestations.map((attestation) => {
|
|
119
116
|
const attEpoch = computeEpochAtSlot(attestation.data.slot);
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
// calling getShufflingAtEpoch may take some time for NativeBeaconStateView
|
|
118
|
+
// we should have the shuffling inside ShufflingCache most of the time
|
|
119
|
+
const shuffling =
|
|
120
|
+
this.shufflingCache.getSync(attEpoch, preState0.getShufflingDecisionRoot(attEpoch)) ??
|
|
121
|
+
preState0.getShufflingAtEpoch(attEpoch);
|
|
122
|
+
return getIndexedAttestation(shuffling, fork, attestation);
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
|
package/src/chain/chain.ts
CHANGED
|
@@ -128,7 +128,7 @@ import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
|
|
|
128
128
|
import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js";
|
|
129
129
|
import {SeenBlockAttesters} from "./seenCache/seenBlockAttesters.js";
|
|
130
130
|
import {SeenBlockInput} from "./seenCache/seenGossipBlockInput.js";
|
|
131
|
-
import {ShufflingCache} from "./shufflingCache.js";
|
|
131
|
+
import {ShufflingCache, ShufflingPromiseCancelReason} from "./shufflingCache.js";
|
|
132
132
|
import {DbCPStateDatastore, checkpointToDatastoreKey} from "./stateCache/datastore/db.js";
|
|
133
133
|
import {FileCPStateDatastore} from "./stateCache/datastore/file.js";
|
|
134
134
|
import {CPStateDatastore} from "./stateCache/datastore/types.js";
|
|
@@ -244,6 +244,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
244
244
|
protected readonly blockProcessor: BlockProcessor;
|
|
245
245
|
protected readonly payloadEnvelopeProcessor: PayloadEnvelopeProcessor;
|
|
246
246
|
protected readonly db: IBeaconDb;
|
|
247
|
+
private genesisStateRoot?: RootHex | null;
|
|
247
248
|
// this is only available if nHistoricalStates is enabled
|
|
248
249
|
private readonly cpStateDatastore?: CPStateDatastore;
|
|
249
250
|
private abortController = new AbortController();
|
|
@@ -278,6 +279,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
278
279
|
validatorMonitor,
|
|
279
280
|
anchorState,
|
|
280
281
|
isAnchorStateFinalized,
|
|
282
|
+
earliestAvailableSlot,
|
|
281
283
|
executionEngine,
|
|
282
284
|
executionBuilder,
|
|
283
285
|
builderApiClientOpts,
|
|
@@ -297,6 +299,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
297
299
|
validatorMonitor: ValidatorMonitor | null;
|
|
298
300
|
anchorState: IBeaconStateView;
|
|
299
301
|
isAnchorStateFinalized: boolean;
|
|
302
|
+
earliestAvailableSlot: Slot;
|
|
300
303
|
executionEngine: IExecutionEngine;
|
|
301
304
|
executionBuilder?: IExecutionBuilder;
|
|
302
305
|
builderApiClientOpts?: BuilderApiClientOpts;
|
|
@@ -325,7 +328,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
325
328
|
|
|
326
329
|
this.blacklistedBlocks = new Map((opts.blacklistedBlocks ?? []).map((hex) => [hex, null]));
|
|
327
330
|
this.attestationPool = new AttestationPool(config, clock, this.opts?.preaggregateSlotDistance, metrics);
|
|
328
|
-
this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
|
|
331
|
+
this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics, logger);
|
|
329
332
|
this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
|
|
330
333
|
this.syncContributionAndProofPool = new SyncContributionAndProofPool(config, clock, metrics, logger);
|
|
331
334
|
this.executionPayloadBidPool = new ExecutionPayloadBidPool();
|
|
@@ -362,7 +365,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
362
365
|
logger,
|
|
363
366
|
});
|
|
364
367
|
|
|
365
|
-
this._earliestAvailableSlot =
|
|
368
|
+
this._earliestAvailableSlot = earliestAvailableSlot;
|
|
366
369
|
|
|
367
370
|
this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
368
371
|
{
|
|
@@ -573,7 +576,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
573
576
|
}
|
|
574
577
|
|
|
575
578
|
seenBlock(blockRoot: RootHex): boolean {
|
|
576
|
-
return
|
|
579
|
+
return (
|
|
580
|
+
this.seenBlockInputCache.hasBlock(blockRoot) ||
|
|
581
|
+
this.seenBlockInputCache.isValidatingBlock(blockRoot) ||
|
|
582
|
+
this.forkChoice.hasBlockHexUnsafe(blockRoot)
|
|
583
|
+
);
|
|
577
584
|
}
|
|
578
585
|
|
|
579
586
|
seenPayloadEnvelope(blockRoot: RootHex): boolean {
|
|
@@ -613,12 +620,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
613
620
|
async loadFromDisk(): Promise<void> {
|
|
614
621
|
await this.regen.init();
|
|
615
622
|
await this.opPool.fromPersisted(this.db, this.getHeadState(), this.bls, this.clock.currentSlot);
|
|
623
|
+
await this.proposerPreferencesPool.fromPersisted(this.db, this.clock.currentSlot);
|
|
616
624
|
}
|
|
617
625
|
|
|
618
626
|
/** Persist in-memory data to the DB. Call at least once before stopping the process */
|
|
619
627
|
async persistToDisk(): Promise<void> {
|
|
620
628
|
await this.archiveStore.persistToDisk();
|
|
621
629
|
await this.opPool.toPersisted(this.db);
|
|
630
|
+
await this.proposerPreferencesPool.toPersisted(this.db);
|
|
622
631
|
}
|
|
623
632
|
|
|
624
633
|
getHeadState(): IBeaconStateView {
|
|
@@ -723,6 +732,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
723
732
|
}
|
|
724
733
|
}
|
|
725
734
|
|
|
735
|
+
if (this.genesisStateRoot === undefined) {
|
|
736
|
+
const genesisBlock = await this.db.blockArchive.get(GENESIS_SLOT);
|
|
737
|
+
this.genesisStateRoot = genesisBlock ? toRootHex(genesisBlock.message.stateRoot) : null;
|
|
738
|
+
}
|
|
739
|
+
if (this.genesisStateRoot === stateRoot) {
|
|
740
|
+
const state = await this.db.stateArchive.getBinary(GENESIS_SLOT);
|
|
741
|
+
if (state) {
|
|
742
|
+
return {state, executionOptimistic: false, finalized: finalizedCheckpoint.epoch !== GENESIS_EPOCH};
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
726
746
|
if (opts?.allowRegen) {
|
|
727
747
|
const state = await this.regen.getState(stateRoot, RegenCaller.restApi);
|
|
728
748
|
const block = this.forkChoice.getBlockDefaultStatus(
|
|
@@ -1524,6 +1544,22 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1524
1544
|
}
|
|
1525
1545
|
}
|
|
1526
1546
|
|
|
1547
|
+
persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void {
|
|
1548
|
+
const blockRoot = toRootHex(envelope.beaconBlockRoot);
|
|
1549
|
+
void this.persistSszObject(
|
|
1550
|
+
"ExecutionPayloadEnvelope",
|
|
1551
|
+
ssz.gloas.ExecutionPayloadEnvelope.serialize(envelope),
|
|
1552
|
+
blockRoot,
|
|
1553
|
+
"produced_execution_payload_envelope"
|
|
1554
|
+
).catch((e) => {
|
|
1555
|
+
this.logger.error(
|
|
1556
|
+
"Error persisting produced execution payload envelope",
|
|
1557
|
+
{slot: envelope.payload.slotNumber, blockRoot},
|
|
1558
|
+
e as Error
|
|
1559
|
+
);
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1527
1563
|
/**
|
|
1528
1564
|
* Invalid state root error is critical and it causes the node to stale most of the time so we want to always
|
|
1529
1565
|
* persist preState, postState and block for further investigation.
|
|
@@ -1595,21 +1631,48 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1595
1631
|
const blockEpoch = computeEpochAtSlot(attHeadBlock.slot);
|
|
1596
1632
|
|
|
1597
1633
|
let state: IBeaconStateView;
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1634
|
+
try {
|
|
1635
|
+
if (blockEpoch < attEpoch - 1) {
|
|
1636
|
+
// thanks to one epoch look ahead, we don't need to dial up to attEpoch
|
|
1637
|
+
const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
|
|
1638
|
+
this.metrics?.gossipAttestation.useHeadBlockStateDialedToTargetEpoch.inc({caller: regenCaller});
|
|
1639
|
+
state = await this.regen.getBlockSlotState(attHeadBlock, targetSlot, {dontTransferCache: true}, regenCaller);
|
|
1640
|
+
} else if (blockEpoch > attEpoch) {
|
|
1641
|
+
// should not happen, handled inside attestation verification code
|
|
1642
|
+
throw Error(`Block epoch ${blockEpoch} is after attestation epoch ${attEpoch}`);
|
|
1643
|
+
} else {
|
|
1644
|
+
// should use either current or next shuffling of head state
|
|
1645
|
+
// it's not likely to hit this since these shufflings are cached already
|
|
1646
|
+
// so handle just in case
|
|
1647
|
+
this.metrics?.gossipAttestation.useHeadBlockState.inc({caller: regenCaller});
|
|
1648
|
+
state = await this.regen.getState(attHeadBlock.stateRoot, regenCaller);
|
|
1649
|
+
}
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
this.shufflingCache.cancelPromise(attEpoch, shufflingDependentRoot, ShufflingPromiseCancelReason.regenError);
|
|
1652
|
+
throw e;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
const stateDecisionRoot = state.getShufflingDecisionRoot(attEpoch);
|
|
1656
|
+
if (stateDecisionRoot !== shufflingDependentRoot) {
|
|
1657
|
+
// the promise would never be resolved by the state's shuffling
|
|
1658
|
+
this.shufflingCache.cancelPromise(
|
|
1659
|
+
attEpoch,
|
|
1660
|
+
shufflingDependentRoot,
|
|
1661
|
+
ShufflingPromiseCancelReason.decisionRootMismatch
|
|
1662
|
+
);
|
|
1663
|
+
this.logger.debug("Shuffling decision root mismatch on attestation regen", {
|
|
1664
|
+
slot: attHeadBlock.slot,
|
|
1665
|
+
root: attHeadBlock.blockRoot,
|
|
1666
|
+
epoch: attEpoch,
|
|
1667
|
+
shufflingDependentRoot,
|
|
1668
|
+
stateDecisionRoot,
|
|
1669
|
+
});
|
|
1670
|
+
|
|
1671
|
+
throw Error(
|
|
1672
|
+
`Shuffling decision root mismatch epoch=${attEpoch} slot=${attHeadBlock.slot} root=${attHeadBlock.blockRoot} expected=${shufflingDependentRoot} actual=${stateDecisionRoot}`
|
|
1673
|
+
);
|
|
1612
1674
|
}
|
|
1675
|
+
|
|
1613
1676
|
// resolve the promise to unblock other calls of the same epoch and dependent root
|
|
1614
1677
|
this.shufflingCache.processState(state);
|
|
1615
1678
|
return state.getShufflingAtEpoch(attEpoch);
|
|
@@ -1719,7 +1782,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1719
1782
|
// remove date suffixes in file name, and check duplicate to avoid redundant persistence
|
|
1720
1783
|
await writeIfNotExist(filepath, bytes);
|
|
1721
1784
|
|
|
1722
|
-
this.logger.debug("Persisted
|
|
1785
|
+
this.logger.debug("Persisted SSZ object", {id: logStr, filepath});
|
|
1723
1786
|
}
|
|
1724
1787
|
|
|
1725
1788
|
private onScrapeMetrics(metrics: Metrics): void {
|