@lodestar/beacon-node 1.50.0-dev.fda8006fc3 → 1.50.0-rc.0
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/state/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/index.js +26 -5
- package/lib/api/impl/beacon/state/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +26 -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/beaconProposerCache.d.ts +6 -0
- package/lib/chain/beaconProposerCache.d.ts.map +1 -1
- package/lib/chain/beaconProposerCache.js +16 -0
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +14 -8
- 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 +3 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +55 -19
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -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 +4 -0
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +13 -1
- 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/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +11 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +40 -28
- package/lib/chain/produceBlock/produceBlockBody.js.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 +60 -64
- 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/state/index.ts +41 -5
- package/src/api/impl/validator/index.ts +37 -0
- package/src/chain/archiveStore/archiveStore.ts +18 -24
- package/src/chain/archiveStore/utils/pruneHistory.ts +4 -1
- package/src/chain/beaconProposerCache.ts +19 -1
- package/src/chain/blocks/importBlock.ts +17 -7
- package/src/chain/blocks/verifyBlock.ts +7 -6
- package/src/chain/chain.ts +68 -18
- package/src/chain/interface.ts +2 -0
- package/src/chain/opPools/aggregatedAttestationPool.ts +34 -10
- package/src/chain/opPools/opPool.ts +1 -31
- package/src/chain/opPools/proposerPreferencesPool.ts +20 -1
- package/src/chain/opPools/utils.ts +31 -0
- package/src/chain/prepareNextSlot.ts +15 -3
- package/src/chain/produceBlock/produceBlockBody.ts +68 -34
- 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 +91 -77
- 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-
|
|
14
|
+
"version": "1.50.0-rc.0",
|
|
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-
|
|
131
|
-
"@lodestar/config": "^1.50.0-
|
|
132
|
-
"@lodestar/db": "^1.50.0-
|
|
133
|
-
"@lodestar/fork-choice": "^1.50.0-
|
|
134
|
-
"@lodestar/logger": "^1.50.0-
|
|
135
|
-
"@lodestar/params": "^1.50.0-
|
|
136
|
-
"@lodestar/reqresp": "^1.50.0-
|
|
137
|
-
"@lodestar/state-transition": "^1.50.0-
|
|
138
|
-
"@lodestar/types": "^1.50.0-
|
|
139
|
-
"@lodestar/utils": "^1.50.0-
|
|
140
|
-
"@lodestar/validator": "^1.50.0-
|
|
130
|
+
"@lodestar/api": "^1.50.0-rc.0",
|
|
131
|
+
"@lodestar/config": "^1.50.0-rc.0",
|
|
132
|
+
"@lodestar/db": "^1.50.0-rc.0",
|
|
133
|
+
"@lodestar/fork-choice": "^1.50.0-rc.0",
|
|
134
|
+
"@lodestar/logger": "^1.50.0-rc.0",
|
|
135
|
+
"@lodestar/params": "^1.50.0-rc.0",
|
|
136
|
+
"@lodestar/reqresp": "^1.50.0-rc.0",
|
|
137
|
+
"@lodestar/state-transition": "^1.50.0-rc.0",
|
|
138
|
+
"@lodestar/types": "^1.50.0-rc.0",
|
|
139
|
+
"@lodestar/utils": "^1.50.0-rc.0",
|
|
140
|
+
"@lodestar/validator": "^1.50.0-rc.0",
|
|
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-
|
|
162
|
-
"@lodestar/test-utils": "^1.50.0-
|
|
162
|
+
"@lodestar/spec-test-util": "^1.50.0-rc.0",
|
|
163
|
+
"@lodestar/test-utils": "^1.50.0-rc.0",
|
|
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": "e6451d61295de46ca524b2553576e774178d9c7b"
|
|
178
179
|
}
|
|
@@ -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";
|
|
@@ -375,6 +387,28 @@ export function getBeaconStateApi({
|
|
|
375
387
|
};
|
|
376
388
|
},
|
|
377
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
|
+
|
|
378
412
|
async getPendingDeposits({stateId}, context) {
|
|
379
413
|
const {state, executionOptimistic, finalized} = await getState(stateId);
|
|
380
414
|
const fork = state.forkName;
|
|
@@ -386,7 +420,9 @@ export function getBeaconStateApi({
|
|
|
386
420
|
const pendingDeposits = state.pendingDeposits;
|
|
387
421
|
|
|
388
422
|
return {
|
|
389
|
-
data: context?.returnBytes
|
|
423
|
+
data: context?.returnBytes
|
|
424
|
+
? sszTypesFor(state.forkName).PendingDeposits.serialize(pendingDeposits)
|
|
425
|
+
: pendingDeposits,
|
|
390
426
|
meta: {executionOptimistic, finalized, version: fork},
|
|
391
427
|
};
|
|
392
428
|
},
|
|
@@ -403,7 +439,7 @@ export function getBeaconStateApi({
|
|
|
403
439
|
|
|
404
440
|
return {
|
|
405
441
|
data: context?.returnBytes
|
|
406
|
-
?
|
|
442
|
+
? sszTypesFor(state.forkName).PendingPartialWithdrawals.serialize(pendingPartialWithdrawals)
|
|
407
443
|
: pendingPartialWithdrawals,
|
|
408
444
|
meta: {executionOptimistic, finalized, version: fork},
|
|
409
445
|
};
|
|
@@ -421,7 +457,7 @@ export function getBeaconStateApi({
|
|
|
421
457
|
|
|
422
458
|
return {
|
|
423
459
|
data: context?.returnBytes
|
|
424
|
-
?
|
|
460
|
+
? sszTypesFor(state.forkName).PendingConsolidations.serialize(pendingConsolidations)
|
|
425
461
|
: pendingConsolidations,
|
|
426
462
|
meta: {executionOptimistic, finalized, version: fork},
|
|
427
463
|
};
|
|
@@ -1932,6 +1932,17 @@ export function getValidatorApi(
|
|
|
1932
1932
|
},
|
|
1933
1933
|
|
|
1934
1934
|
async prepareBeaconCommitteeSubnet({subscriptions}) {
|
|
1935
|
+
// The subscribing validators use this node for duties regardless of its sync state and
|
|
1936
|
+
// the subscription must not fail on the tracking, e.g. if the finalized state is unavailable
|
|
1937
|
+
try {
|
|
1938
|
+
await chain.updateAttachedValidators(
|
|
1939
|
+
chain.clock.currentEpoch,
|
|
1940
|
+
Array.from(new Set(subscriptions.map(({validatorIndex}) => validatorIndex)))
|
|
1941
|
+
);
|
|
1942
|
+
} catch (e) {
|
|
1943
|
+
logger.warn("Error tracking attached validators", {count: subscriptions.length}, e as Error);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1935
1946
|
notWhileSyncing(chain, sync.state);
|
|
1936
1947
|
|
|
1937
1948
|
await network.prepareBeaconCommitteeSubnets(
|
|
@@ -1995,6 +2006,13 @@ export function getValidatorApi(
|
|
|
1995
2006
|
},
|
|
1996
2007
|
|
|
1997
2008
|
async prepareBeaconProposer({proposers}) {
|
|
2009
|
+
if (isForkPostGloas(config.getForkName(chain.clock.currentSlot))) {
|
|
2010
|
+
throw new ApiError(
|
|
2011
|
+
410,
|
|
2012
|
+
"prepareBeaconProposer is no longer supported from gloas, submit signed proposer preferences via POST /eth/v1/validator/proposer_preferences instead"
|
|
2013
|
+
);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
1998
2016
|
await chain.updateBeaconProposerData(chain.clock.currentEpoch, proposers);
|
|
1999
2017
|
},
|
|
2000
2018
|
|
|
@@ -2029,6 +2047,13 @@ export function getValidatorApi(
|
|
|
2029
2047
|
},
|
|
2030
2048
|
|
|
2031
2049
|
async registerValidator({registrations}) {
|
|
2050
|
+
if (isForkPostGloas(config.getForkName(chain.clock.currentSlot))) {
|
|
2051
|
+
throw new ApiError(
|
|
2052
|
+
410,
|
|
2053
|
+
"registerValidator is no longer supported from gloas, submit builder preferences via POST /eth/v1/validator/builder_preferences instead"
|
|
2054
|
+
);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2032
2057
|
if (!chain.executionBuilder) {
|
|
2033
2058
|
throw Error("External builder not configured");
|
|
2034
2059
|
}
|
|
@@ -2064,11 +2089,14 @@ export function getValidatorApi(
|
|
|
2064
2089
|
|
|
2065
2090
|
async submitProposerPreferences({signedProposerPreferences}) {
|
|
2066
2091
|
const failures: FailureList = [];
|
|
2092
|
+
// Preferences submitted here are signed by validators using this node, gossiped ones are not
|
|
2093
|
+
const attachedValidatorIndices: ValidatorIndex[] = [];
|
|
2067
2094
|
|
|
2068
2095
|
await Promise.all(
|
|
2069
2096
|
signedProposerPreferences.map(async (signed, i) => {
|
|
2070
2097
|
try {
|
|
2071
2098
|
await validateGossipProposerPreferences(chain, signed);
|
|
2099
|
+
attachedValidatorIndices.push(signed.message.validatorIndex);
|
|
2072
2100
|
|
|
2073
2101
|
chain.proposerPreferencesPool.add(signed);
|
|
2074
2102
|
await network.publishProposerPreferences(signed);
|
|
@@ -2084,6 +2112,7 @@ export function getValidatorApi(
|
|
|
2084
2112
|
};
|
|
2085
2113
|
|
|
2086
2114
|
if (e instanceof ProposerPreferencesError && e.type.code === ProposerPreferencesErrorCode.ALREADY_KNOWN) {
|
|
2115
|
+
attachedValidatorIndices.push(signed.message.validatorIndex);
|
|
2087
2116
|
logger.debug("Ignoring known signed proposer preferences", logCtx);
|
|
2088
2117
|
return;
|
|
2089
2118
|
}
|
|
@@ -2097,6 +2126,14 @@ export function getValidatorApi(
|
|
|
2097
2126
|
})
|
|
2098
2127
|
);
|
|
2099
2128
|
|
|
2129
|
+
if (attachedValidatorIndices.length > 0) {
|
|
2130
|
+
try {
|
|
2131
|
+
await chain.updateAttachedValidators(chain.clock.currentEpoch, attachedValidatorIndices);
|
|
2132
|
+
} catch (e) {
|
|
2133
|
+
logger.warn("Error tracking attached validators", {count: attachedValidatorIndices.length}, e as Error);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2100
2137
|
if (failures.length > 0) {
|
|
2101
2138
|
throw new IndexedError("Error processing signed proposer preferences", failures);
|
|
2102
2139
|
}
|
|
@@ -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
|
// ->
|
|
@@ -6,7 +6,7 @@ const PROPOSER_PRESERVE_EPOCHS = 2;
|
|
|
6
6
|
export type ProposerPreparationData = routes.validator.ProposerPreparationData;
|
|
7
7
|
|
|
8
8
|
export class BeaconProposerCache {
|
|
9
|
-
private readonly feeRecipientByValidatorIndex: Map<number, {epoch: Epoch; feeRecipient
|
|
9
|
+
private readonly feeRecipientByValidatorIndex: Map<number, {epoch: Epoch; feeRecipient?: string}>;
|
|
10
10
|
constructor(readonly opts: {suggestedFeeRecipient: string}) {
|
|
11
11
|
this.feeRecipientByValidatorIndex = new Map();
|
|
12
12
|
}
|
|
@@ -15,6 +15,24 @@ export class BeaconProposerCache {
|
|
|
15
15
|
this.feeRecipientByValidatorIndex.set(validatorIndex, {epoch, feeRecipient});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Track a validator that uses this node for duties, keeping the fee recipient it may have
|
|
20
|
+
* registered. Returns true if the validator was not tracked before.
|
|
21
|
+
*/
|
|
22
|
+
track(epoch: Epoch, validatorIndex: number): boolean {
|
|
23
|
+
const entry = this.feeRecipientByValidatorIndex.get(validatorIndex);
|
|
24
|
+
if (entry !== undefined) {
|
|
25
|
+
entry.epoch = epoch;
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
this.feeRecipientByValidatorIndex.set(validatorIndex, {epoch});
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
has(validatorIndex: number): boolean {
|
|
33
|
+
return this.feeRecipientByValidatorIndex.has(validatorIndex);
|
|
34
|
+
}
|
|
35
|
+
|
|
18
36
|
prune(epoch: Epoch): void {
|
|
19
37
|
// This is not so optimized function, but could maintain a 2d array may be?
|
|
20
38
|
for (const [validatorIndex, feeRecipientEntry] of this.feeRecipientByValidatorIndex.entries()) {
|
|
@@ -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}`);
|
|
@@ -400,9 +407,8 @@ export async function importBlock(
|
|
|
400
407
|
const proposalSlot = blockSlot + 1;
|
|
401
408
|
try {
|
|
402
409
|
const proposerIndex = postState.getBeaconProposer(proposalSlot);
|
|
403
|
-
const feeRecipient = this.beaconProposerCache.get(proposerIndex);
|
|
404
410
|
|
|
405
|
-
if (
|
|
411
|
+
if (this.beaconProposerCache.has(proposerIndex)) {
|
|
406
412
|
// We would set this to true if
|
|
407
413
|
// 1) This is a gossip block
|
|
408
414
|
// 2) We are proposer of next slot
|
|
@@ -657,8 +663,12 @@ export function addAttestationPostElectra(
|
|
|
657
663
|
} else {
|
|
658
664
|
const attSlot = attestation.data.slot;
|
|
659
665
|
const attEpoch = computeEpochAtSlot(attSlot);
|
|
660
|
-
|
|
661
|
-
|
|
666
|
+
// calling getShufflingAtEpoch may take some time for NativeBeaconStateView
|
|
667
|
+
// we should have the shuffling inside ShufflingCache most of the time
|
|
668
|
+
const shuffling =
|
|
669
|
+
this.shufflingCache.getSync(attEpoch, state.getShufflingDecisionRoot(attEpoch)) ??
|
|
670
|
+
state.getShufflingAtEpoch(attEpoch);
|
|
671
|
+
const committees = getBeaconCommittees(shuffling, attSlot, committeeIndices);
|
|
662
672
|
const aggregationBools = attestation.aggregationBits.toBoolArray();
|
|
663
673
|
let offset = 0;
|
|
664
674
|
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";
|
|
@@ -279,6 +279,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
279
279
|
validatorMonitor,
|
|
280
280
|
anchorState,
|
|
281
281
|
isAnchorStateFinalized,
|
|
282
|
+
earliestAvailableSlot,
|
|
282
283
|
executionEngine,
|
|
283
284
|
executionBuilder,
|
|
284
285
|
builderApiClientOpts,
|
|
@@ -298,6 +299,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
298
299
|
validatorMonitor: ValidatorMonitor | null;
|
|
299
300
|
anchorState: IBeaconStateView;
|
|
300
301
|
isAnchorStateFinalized: boolean;
|
|
302
|
+
earliestAvailableSlot: Slot;
|
|
301
303
|
executionEngine: IExecutionEngine;
|
|
302
304
|
executionBuilder?: IExecutionBuilder;
|
|
303
305
|
builderApiClientOpts?: BuilderApiClientOpts;
|
|
@@ -326,7 +328,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
326
328
|
|
|
327
329
|
this.blacklistedBlocks = new Map((opts.blacklistedBlocks ?? []).map((hex) => [hex, null]));
|
|
328
330
|
this.attestationPool = new AttestationPool(config, clock, this.opts?.preaggregateSlotDistance, metrics);
|
|
329
|
-
this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
|
|
331
|
+
this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics, logger);
|
|
330
332
|
this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
|
|
331
333
|
this.syncContributionAndProofPool = new SyncContributionAndProofPool(config, clock, metrics, logger);
|
|
332
334
|
this.executionPayloadBidPool = new ExecutionPayloadBidPool();
|
|
@@ -363,7 +365,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
363
365
|
logger,
|
|
364
366
|
});
|
|
365
367
|
|
|
366
|
-
this._earliestAvailableSlot =
|
|
368
|
+
this._earliestAvailableSlot = earliestAvailableSlot;
|
|
367
369
|
|
|
368
370
|
this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
369
371
|
{
|
|
@@ -574,7 +576,11 @@ export class BeaconChain implements IBeaconChain {
|
|
|
574
576
|
}
|
|
575
577
|
|
|
576
578
|
seenBlock(blockRoot: RootHex): boolean {
|
|
577
|
-
return
|
|
579
|
+
return (
|
|
580
|
+
this.seenBlockInputCache.hasBlock(blockRoot) ||
|
|
581
|
+
this.seenBlockInputCache.isValidatingBlock(blockRoot) ||
|
|
582
|
+
this.forkChoice.hasBlockHexUnsafe(blockRoot)
|
|
583
|
+
);
|
|
578
584
|
}
|
|
579
585
|
|
|
580
586
|
seenPayloadEnvelope(blockRoot: RootHex): boolean {
|
|
@@ -614,12 +620,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
614
620
|
async loadFromDisk(): Promise<void> {
|
|
615
621
|
await this.regen.init();
|
|
616
622
|
await this.opPool.fromPersisted(this.db, this.getHeadState(), this.bls, this.clock.currentSlot);
|
|
623
|
+
await this.proposerPreferencesPool.fromPersisted(this.db, this.clock.currentSlot);
|
|
617
624
|
}
|
|
618
625
|
|
|
619
626
|
/** Persist in-memory data to the DB. Call at least once before stopping the process */
|
|
620
627
|
async persistToDisk(): Promise<void> {
|
|
621
628
|
await this.archiveStore.persistToDisk();
|
|
622
629
|
await this.opPool.toPersisted(this.db);
|
|
630
|
+
await this.proposerPreferencesPool.toPersisted(this.db);
|
|
623
631
|
}
|
|
624
632
|
|
|
625
633
|
getHeadState(): IBeaconStateView {
|
|
@@ -1623,21 +1631,48 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1623
1631
|
const blockEpoch = computeEpochAtSlot(attHeadBlock.slot);
|
|
1624
1632
|
|
|
1625
1633
|
let state: IBeaconStateView;
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
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
|
+
);
|
|
1640
1674
|
}
|
|
1675
|
+
|
|
1641
1676
|
// resolve the promise to unblock other calls of the same epoch and dependent root
|
|
1642
1677
|
this.shufflingCache.processState(state);
|
|
1643
1678
|
return state.getShufflingAtEpoch(attEpoch);
|
|
@@ -1901,6 +1936,21 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1901
1936
|
}
|
|
1902
1937
|
}
|
|
1903
1938
|
|
|
1939
|
+
async updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void> {
|
|
1940
|
+
let hasNewValidators = false;
|
|
1941
|
+
for (const validatorIndex of validatorIndices) {
|
|
1942
|
+
if (this.beaconProposerCache.track(epoch, validatorIndex)) {
|
|
1943
|
+
hasNewValidators = true;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// Only update validator custody if we discovered new validators
|
|
1948
|
+
if (hasNewValidators) {
|
|
1949
|
+
const finalizedCheckpoint = this.forkChoice.getFinalizedCheckpoint();
|
|
1950
|
+
await this.updateValidatorsCustodyRequirement(finalizedCheckpoint);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1904
1954
|
private async updateValidatorsCustodyRequirement(finalizedCheckpoint: CheckpointWithHex): Promise<void> {
|
|
1905
1955
|
if (this.custodyConfig.targetCustodyGroupCount === this.config.NUMBER_OF_CUSTODY_GROUPS) {
|
|
1906
1956
|
// Custody requirements can only be increased, we can disable dynamic custody updates
|
package/src/chain/interface.ts
CHANGED
|
@@ -288,6 +288,8 @@ export interface IBeaconChain {
|
|
|
288
288
|
waitForBlock(slot: Slot, root: RootHex): Promise<boolean>;
|
|
289
289
|
|
|
290
290
|
updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void>;
|
|
291
|
+
/** Track validators that use this node for duties, e.g. by subscribing to attestation subnets */
|
|
292
|
+
updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void>;
|
|
291
293
|
|
|
292
294
|
persistBlock(data: BeaconBlock | BlindedBeaconBlock, suffix?: string): void;
|
|
293
295
|
persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void;
|