@lodestar/beacon-node 1.39.0-dev.c151a164f2 → 1.39.0-dev.c630c55067
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/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -2
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/chain.d.ts +8 -9
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +17 -33
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +3 -3
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/interface.d.ts +4 -7
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +9 -0
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
- package/lib/chain/validation/attesterSlashing.js +1 -1
- package/lib/chain/validation/attesterSlashing.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +3 -3
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/proposerSlashing.js +1 -1
- package/lib/chain/validation/proposerSlashing.js.map +1 -1
- package/lib/chain/validation/voluntaryExit.js +1 -1
- package/lib/chain/validation/voluntaryExit.js.map +1 -1
- package/lib/node/nodejs.d.ts +6 -3
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +3 -1
- package/lib/node/nodejs.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +9 -6
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/backfill/verify.d.ts.map +1 -1
- package/lib/sync/backfill/verify.js +1 -1
- package/lib/sync/backfill/verify.js.map +1 -1
- package/package.json +14 -14
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
- package/src/chain/blocks/verifyBlocksSignatures.ts +11 -3
- package/src/chain/chain.ts +27 -38
- package/src/chain/forkChoice/index.ts +3 -2
- package/src/chain/interface.ts +4 -6
- package/src/chain/validation/aggregateAndProof.ts +12 -0
- package/src/chain/validation/attesterSlashing.ts +6 -1
- package/src/chain/validation/block.ts +3 -2
- package/src/chain/validation/proposerSlashing.ts +6 -1
- package/src/chain/validation/voluntaryExit.ts +1 -1
- package/src/node/nodejs.ts +9 -2
- package/src/node/notifier.ts +13 -7
- package/src/sync/backfill/verify.ts +1 -2
- package/lib/chain/rewards/attestationsRewards.d.ts +0 -8
- package/lib/chain/rewards/attestationsRewards.d.ts.map +0 -1
- package/lib/chain/rewards/attestationsRewards.js +0 -112
- package/lib/chain/rewards/attestationsRewards.js.map +0 -1
- package/lib/chain/rewards/blockRewards.d.ts +0 -15
- package/lib/chain/rewards/blockRewards.d.ts.map +0 -1
- package/lib/chain/rewards/blockRewards.js +0 -94
- package/lib/chain/rewards/blockRewards.js.map +0 -1
- package/lib/chain/rewards/syncCommitteeRewards.d.ts +0 -7
- package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +0 -1
- package/lib/chain/rewards/syncCommitteeRewards.js +0 -36
- package/lib/chain/rewards/syncCommitteeRewards.js.map +0 -1
- package/src/chain/rewards/attestationsRewards.ts +0 -206
- package/src/chain/rewards/blockRewards.ts +0 -153
- package/src/chain/rewards/syncCommitteeRewards.ts +0 -60
package/src/chain/chain.ts
CHANGED
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
EpochShuffling,
|
|
15
15
|
Index2PubkeyCache,
|
|
16
16
|
computeAnchorCheckpoint,
|
|
17
|
+
computeAttestationsRewards,
|
|
18
|
+
computeBlockRewards,
|
|
17
19
|
computeEndSlotAtEpoch,
|
|
18
20
|
computeEpochAtSlot,
|
|
19
21
|
computeStartSlotAtEpoch,
|
|
20
|
-
|
|
22
|
+
computeSyncCommitteeRewards,
|
|
21
23
|
getEffectiveBalanceIncrementsZeroInactive,
|
|
22
24
|
getEffectiveBalancesFromStateBytes,
|
|
23
|
-
isCachedBeaconState,
|
|
24
25
|
processSlots,
|
|
25
26
|
} from "@lodestar/state-transition";
|
|
26
27
|
import {
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
Wei,
|
|
39
40
|
isBlindedBeaconBlock,
|
|
40
41
|
phase0,
|
|
42
|
+
rewards,
|
|
41
43
|
} from "@lodestar/types";
|
|
42
44
|
import {Logger, fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex} from "@lodestar/utils";
|
|
43
45
|
import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
@@ -79,9 +81,6 @@ import {AssembledBlockType, BlockType, ProduceResult} from "./produceBlock/index
|
|
|
79
81
|
import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produceBlock/produceBlockBody.js";
|
|
80
82
|
import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js";
|
|
81
83
|
import {ReprocessController} from "./reprocess.js";
|
|
82
|
-
import {AttestationsRewards, computeAttestationsRewards} from "./rewards/attestationsRewards.js";
|
|
83
|
-
import {BlockRewards, computeBlockRewards} from "./rewards/blockRewards.js";
|
|
84
|
-
import {SyncCommitteeRewards, computeSyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js";
|
|
85
84
|
import {
|
|
86
85
|
SeenAggregators,
|
|
87
86
|
SeenAttesters,
|
|
@@ -204,6 +203,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
204
203
|
{
|
|
205
204
|
privateKey,
|
|
206
205
|
config,
|
|
206
|
+
pubkey2index,
|
|
207
|
+
index2pubkey,
|
|
207
208
|
db,
|
|
208
209
|
dbName,
|
|
209
210
|
dataDir,
|
|
@@ -219,6 +220,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
219
220
|
}: {
|
|
220
221
|
privateKey: PrivateKey;
|
|
221
222
|
config: BeaconConfig;
|
|
223
|
+
pubkey2index: PubkeyIndexMap;
|
|
224
|
+
index2pubkey: Index2PubkeyCache;
|
|
222
225
|
db: IBeaconDb;
|
|
223
226
|
dbName: string;
|
|
224
227
|
dataDir: string;
|
|
@@ -228,7 +231,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
228
231
|
clock?: IClock;
|
|
229
232
|
metrics: Metrics | null;
|
|
230
233
|
validatorMonitor: ValidatorMonitor | null;
|
|
231
|
-
anchorState:
|
|
234
|
+
anchorState: CachedBeaconStateAllForks;
|
|
232
235
|
isAnchorStateFinalized: boolean;
|
|
233
236
|
executionEngine: IExecutionEngine;
|
|
234
237
|
executionBuilder?: IExecutionBuilder;
|
|
@@ -287,39 +290,25 @@ export class BeaconChain implements IBeaconChain {
|
|
|
287
290
|
logger,
|
|
288
291
|
});
|
|
289
292
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// pubkeys takes ~30 seconds for 350k keys (mainnet 2022Q2).
|
|
293
|
-
// When the BeaconStateCache is created in initializeBeaconStateFromEth1 it may be incorrect. Until we can ensure that
|
|
294
|
-
// it's safe to re-use _ANY_ BeaconStateCache, this option is disabled by default and only used in tests.
|
|
295
|
-
const cachedState =
|
|
296
|
-
isCachedBeaconState(anchorState) && opts.skipCreateStateCacheIfAvailable
|
|
297
|
-
? anchorState
|
|
298
|
-
: createCachedBeaconState(anchorState, {
|
|
299
|
-
config,
|
|
300
|
-
pubkey2index: new PubkeyIndexMap(),
|
|
301
|
-
index2pubkey: [],
|
|
302
|
-
});
|
|
303
|
-
this._earliestAvailableSlot = cachedState.slot;
|
|
304
|
-
|
|
305
|
-
this.shufflingCache = cachedState.epochCtx.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
293
|
+
this._earliestAvailableSlot = anchorState.slot;
|
|
294
|
+
this.shufflingCache = anchorState.epochCtx.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
|
|
306
295
|
{
|
|
307
|
-
shuffling:
|
|
308
|
-
decisionRoot:
|
|
296
|
+
shuffling: anchorState.epochCtx.previousShuffling,
|
|
297
|
+
decisionRoot: anchorState.epochCtx.previousDecisionRoot,
|
|
309
298
|
},
|
|
310
299
|
{
|
|
311
|
-
shuffling:
|
|
312
|
-
decisionRoot:
|
|
300
|
+
shuffling: anchorState.epochCtx.currentShuffling,
|
|
301
|
+
decisionRoot: anchorState.epochCtx.currentDecisionRoot,
|
|
313
302
|
},
|
|
314
303
|
{
|
|
315
|
-
shuffling:
|
|
316
|
-
decisionRoot:
|
|
304
|
+
shuffling: anchorState.epochCtx.nextShuffling,
|
|
305
|
+
decisionRoot: anchorState.epochCtx.nextDecisionRoot,
|
|
317
306
|
},
|
|
318
307
|
]);
|
|
319
308
|
|
|
320
|
-
//
|
|
321
|
-
this.pubkey2index =
|
|
322
|
-
this.index2pubkey =
|
|
309
|
+
// Global cache of validators pubkey/index mapping
|
|
310
|
+
this.pubkey2index = pubkey2index;
|
|
311
|
+
this.index2pubkey = index2pubkey;
|
|
323
312
|
|
|
324
313
|
const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
|
|
325
314
|
const blockStateCache = this.opts.nHistoricalStates
|
|
@@ -350,15 +339,15 @@ export class BeaconChain implements IBeaconChain {
|
|
|
350
339
|
}
|
|
351
340
|
|
|
352
341
|
const {checkpoint} = computeAnchorCheckpoint(config, anchorState);
|
|
353
|
-
blockStateCache.add(
|
|
354
|
-
blockStateCache.setHeadState(
|
|
355
|
-
checkpointStateCache.add(checkpoint,
|
|
342
|
+
blockStateCache.add(anchorState);
|
|
343
|
+
blockStateCache.setHeadState(anchorState);
|
|
344
|
+
checkpointStateCache.add(checkpoint, anchorState);
|
|
356
345
|
|
|
357
346
|
const forkChoice = initializeForkChoice(
|
|
358
347
|
config,
|
|
359
348
|
emitter,
|
|
360
349
|
clock.currentSlot,
|
|
361
|
-
|
|
350
|
+
anchorState,
|
|
362
351
|
isAnchorStateFinalized,
|
|
363
352
|
opts,
|
|
364
353
|
this.justifiedBalancesGetter.bind(this),
|
|
@@ -1297,7 +1286,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1297
1286
|
}
|
|
1298
1287
|
}
|
|
1299
1288
|
|
|
1300
|
-
async getBlockRewards(block: BeaconBlock | BlindedBeaconBlock): Promise<BlockRewards> {
|
|
1289
|
+
async getBlockRewards(block: BeaconBlock | BlindedBeaconBlock): Promise<rewards.BlockRewards> {
|
|
1301
1290
|
let preState = this.regen.getPreStateSync(block);
|
|
1302
1291
|
|
|
1303
1292
|
if (preState === null) {
|
|
@@ -1314,7 +1303,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1314
1303
|
async getAttestationsRewards(
|
|
1315
1304
|
epoch: Epoch,
|
|
1316
1305
|
validatorIds?: (ValidatorIndex | string)[]
|
|
1317
|
-
): Promise<{rewards: AttestationsRewards; executionOptimistic: boolean; finalized: boolean}> {
|
|
1306
|
+
): Promise<{rewards: rewards.AttestationsRewards; executionOptimistic: boolean; finalized: boolean}> {
|
|
1318
1307
|
// We use end slot of (epoch + 1) to ensure we have seen all attestations. On-time or late. Any late attestation beyond this slot is not considered
|
|
1319
1308
|
const slot = computeEndSlotAtEpoch(epoch + 1);
|
|
1320
1309
|
const stateResult = await this.getStateBySlot(slot, {allowRegen: false}); // No regen if state not in cache
|
|
@@ -1340,7 +1329,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1340
1329
|
async getSyncCommitteeRewards(
|
|
1341
1330
|
block: BeaconBlock | BlindedBeaconBlock,
|
|
1342
1331
|
validatorIds?: (ValidatorIndex | string)[]
|
|
1343
|
-
): Promise<SyncCommitteeRewards> {
|
|
1332
|
+
): Promise<rewards.SyncCommitteeRewards> {
|
|
1344
1333
|
let preState = this.regen.getPreStateSync(block);
|
|
1345
1334
|
|
|
1346
1335
|
if (preState === null) {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getBlockRootAtSlot,
|
|
19
19
|
getEffectiveBalanceIncrementsZeroInactive,
|
|
20
20
|
isExecutionStateType,
|
|
21
|
+
isMergeTransitionComplete,
|
|
21
22
|
} from "@lodestar/state-transition";
|
|
22
23
|
import {Slot, ssz} from "@lodestar/types";
|
|
23
24
|
import {Logger, toRootHex} from "@lodestar/utils";
|
|
@@ -134,7 +135,7 @@ export function initializeForkChoiceFromFinalizedState(
|
|
|
134
135
|
unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
|
|
135
136
|
unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
|
|
136
137
|
|
|
137
|
-
...(isExecutionStateType(state)
|
|
138
|
+
...(isExecutionStateType(state) && isMergeTransitionComplete(state)
|
|
138
139
|
? {
|
|
139
140
|
executionPayloadBlockHash: toRootHex(state.latestExecutionPayloadHeader.blockHash),
|
|
140
141
|
executionPayloadNumber: state.latestExecutionPayloadHeader.blockNumber,
|
|
@@ -215,7 +216,7 @@ export function initializeForkChoiceFromUnfinalizedState(
|
|
|
215
216
|
unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
|
|
216
217
|
unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
|
|
217
218
|
|
|
218
|
-
...(isExecutionStateType(unfinalizedState)
|
|
219
|
+
...(isExecutionStateType(unfinalizedState) && isMergeTransitionComplete(unfinalizedState)
|
|
219
220
|
? {
|
|
220
221
|
executionPayloadBlockHash: toRootHex(unfinalizedState.latestExecutionPayloadHeader.blockHash),
|
|
221
222
|
executionPayloadNumber: unfinalizedState.latestExecutionPayloadHeader.blockNumber,
|
package/src/chain/interface.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
altair,
|
|
24
24
|
capella,
|
|
25
25
|
phase0,
|
|
26
|
+
rewards,
|
|
26
27
|
} from "@lodestar/types";
|
|
27
28
|
import {Logger} from "@lodestar/utils";
|
|
28
29
|
import {IExecutionBuilder, IExecutionEngine} from "../execution/index.js";
|
|
@@ -48,9 +49,6 @@ import {IChainOptions} from "./options.js";
|
|
|
48
49
|
import {AssembledBlockType, BlockAttributes, BlockType, ProduceResult} from "./produceBlock/produceBlockBody.js";
|
|
49
50
|
import {IStateRegenerator, RegenCaller} from "./regen/index.js";
|
|
50
51
|
import {ReprocessController} from "./reprocess.js";
|
|
51
|
-
import {AttestationsRewards} from "./rewards/attestationsRewards.js";
|
|
52
|
-
import {BlockRewards} from "./rewards/blockRewards.js";
|
|
53
|
-
import {SyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js";
|
|
54
52
|
import {
|
|
55
53
|
SeenAggregators,
|
|
56
54
|
SeenAttesters,
|
|
@@ -255,15 +253,15 @@ export interface IBeaconChain {
|
|
|
255
253
|
regenCanAcceptWork(): boolean;
|
|
256
254
|
blsThreadPoolCanAcceptWork(): boolean;
|
|
257
255
|
|
|
258
|
-
getBlockRewards(blockRef: BeaconBlock | BlindedBeaconBlock): Promise<BlockRewards>;
|
|
256
|
+
getBlockRewards(blockRef: BeaconBlock | BlindedBeaconBlock): Promise<rewards.BlockRewards>;
|
|
259
257
|
getAttestationsRewards(
|
|
260
258
|
epoch: Epoch,
|
|
261
259
|
validatorIds?: (ValidatorIndex | string)[]
|
|
262
|
-
): Promise<{rewards: AttestationsRewards; executionOptimistic: boolean; finalized: boolean}>;
|
|
260
|
+
): Promise<{rewards: rewards.AttestationsRewards; executionOptimistic: boolean; finalized: boolean}>;
|
|
263
261
|
getSyncCommitteeRewards(
|
|
264
262
|
blockRef: BeaconBlock | BlindedBeaconBlock,
|
|
265
263
|
validatorIds?: (ValidatorIndex | string)[]
|
|
266
|
-
): Promise<SyncCommitteeRewards>;
|
|
264
|
+
): Promise<rewards.SyncCommitteeRewards>;
|
|
267
265
|
}
|
|
268
266
|
|
|
269
267
|
export type SSZObjectType =
|
|
@@ -245,6 +245,18 @@ async function validateAggregateAndProof(
|
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
// Same race-condition check as above for seen aggregators
|
|
249
|
+
if (
|
|
250
|
+
!skipValidationKnownAttesters &&
|
|
251
|
+
chain.seenAggregatedAttestations.isKnown(targetEpoch, attIndex, attDataRootHex, aggregationBits)
|
|
252
|
+
) {
|
|
253
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
254
|
+
code: AttestationErrorCode.ATTESTERS_ALREADY_KNOWN,
|
|
255
|
+
targetEpoch,
|
|
256
|
+
aggregateRoot: attDataRootHex,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
248
260
|
chain.seenAggregators.add(targetEpoch, aggregatorIndex);
|
|
249
261
|
chain.seenAggregatedAttestations.add(
|
|
250
262
|
targetEpoch,
|
|
@@ -51,7 +51,12 @@ export async function validateAttesterSlashing(
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const signatureSets = getAttesterSlashingSignatureSets(
|
|
54
|
+
const signatureSets = getAttesterSlashingSignatureSets(
|
|
55
|
+
chain.config,
|
|
56
|
+
chain.index2pubkey,
|
|
57
|
+
state.slot,
|
|
58
|
+
attesterSlashing
|
|
59
|
+
);
|
|
55
60
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
56
61
|
throw new AttesterSlashingError(GossipAction.REJECT, {
|
|
57
62
|
code: AttesterSlashingErrorCode.INVALID,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
computeTimeAtSlot,
|
|
7
7
|
getBlockProposerSignatureSet,
|
|
8
8
|
isExecutionBlockBodyType,
|
|
9
|
+
isExecutionEnabled,
|
|
9
10
|
isExecutionStateType,
|
|
10
11
|
} from "@lodestar/state-transition";
|
|
11
12
|
import {SignedBeaconBlock, deneb} from "@lodestar/types";
|
|
@@ -139,7 +140,7 @@ export async function validateGossipBlock(
|
|
|
139
140
|
if (fork === ForkName.bellatrix) {
|
|
140
141
|
if (!isExecutionBlockBodyType(block.body)) throw Error("Not merge block type");
|
|
141
142
|
const executionPayload = block.body.executionPayload;
|
|
142
|
-
if (isExecutionStateType(blockState)) {
|
|
143
|
+
if (isExecutionStateType(blockState) && isExecutionEnabled(blockState, block)) {
|
|
143
144
|
const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
|
|
144
145
|
if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
|
|
145
146
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -153,7 +154,7 @@ export async function validateGossipBlock(
|
|
|
153
154
|
|
|
154
155
|
// [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
|
|
155
156
|
if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
|
|
156
|
-
const signatureSet = getBlockProposerSignatureSet(chain.config, chain.index2pubkey,
|
|
157
|
+
const signatureSet = getBlockProposerSignatureSet(chain.config, chain.index2pubkey, signedBlock);
|
|
157
158
|
// Don't batch so verification is not delayed
|
|
158
159
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
|
|
159
160
|
throw new BlockGossipError(GossipAction.REJECT, {
|
|
@@ -44,7 +44,12 @@ async function validateProposerSlashing(
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const signatureSets = getProposerSlashingSignatureSets(
|
|
47
|
+
const signatureSets = getProposerSlashingSignatureSets(
|
|
48
|
+
chain.config,
|
|
49
|
+
chain.index2pubkey,
|
|
50
|
+
state.slot,
|
|
51
|
+
proposerSlashing
|
|
52
|
+
);
|
|
48
53
|
if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
|
|
49
54
|
throw new ProposerSlashingError(GossipAction.REJECT, {
|
|
50
55
|
code: ProposerSlashingErrorCode.INVALID,
|
|
@@ -59,7 +59,7 @@ async function validateVoluntaryExit(
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const signatureSet = getVoluntaryExitSignatureSet(chain.config, chain.index2pubkey, state, voluntaryExit);
|
|
62
|
+
const signatureSet = getVoluntaryExitSignatureSet(chain.config, chain.index2pubkey, state.slot, voluntaryExit);
|
|
63
63
|
if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
|
|
64
64
|
throw new VoluntaryExitError(GossipAction.REJECT, {
|
|
65
65
|
code: VoluntaryExitErrorCode.INVALID_SIGNATURE,
|
package/src/node/nodejs.ts
CHANGED
|
@@ -2,10 +2,11 @@ import {setMaxListeners} from "node:events";
|
|
|
2
2
|
import {PrivateKey} from "@libp2p/interface";
|
|
3
3
|
import {Registry} from "prom-client";
|
|
4
4
|
import {hasher} from "@chainsafe/persistent-merkle-tree";
|
|
5
|
+
import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
|
|
5
6
|
import {BeaconApiMethods} from "@lodestar/api/beacon/server";
|
|
6
7
|
import {BeaconConfig} from "@lodestar/config";
|
|
7
8
|
import type {LoggerNode} from "@lodestar/logger/node";
|
|
8
|
-
import {
|
|
9
|
+
import {CachedBeaconStateAllForks, Index2PubkeyCache} from "@lodestar/state-transition";
|
|
9
10
|
import {phase0} from "@lodestar/types";
|
|
10
11
|
import {sleep} from "@lodestar/utils";
|
|
11
12
|
import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
@@ -45,13 +46,15 @@ export type BeaconNodeModules = {
|
|
|
45
46
|
export type BeaconNodeInitModules = {
|
|
46
47
|
opts: IBeaconNodeOptions;
|
|
47
48
|
config: BeaconConfig;
|
|
49
|
+
pubkey2index: PubkeyIndexMap;
|
|
50
|
+
index2pubkey: Index2PubkeyCache;
|
|
48
51
|
db: IBeaconDb;
|
|
49
52
|
logger: LoggerNode;
|
|
50
53
|
processShutdownCallback: ProcessShutdownCallback;
|
|
51
54
|
privateKey: PrivateKey;
|
|
52
55
|
dataDir: string;
|
|
53
56
|
peerStoreDir?: string;
|
|
54
|
-
anchorState:
|
|
57
|
+
anchorState: CachedBeaconStateAllForks;
|
|
55
58
|
isAnchorStateFinalized: boolean;
|
|
56
59
|
wsCheckpoint?: phase0.Checkpoint;
|
|
57
60
|
metricsRegistries?: Registry[];
|
|
@@ -146,6 +149,8 @@ export class BeaconNode {
|
|
|
146
149
|
static async init<T extends BeaconNode = BeaconNode>({
|
|
147
150
|
opts,
|
|
148
151
|
config,
|
|
152
|
+
pubkey2index,
|
|
153
|
+
index2pubkey,
|
|
149
154
|
db,
|
|
150
155
|
logger,
|
|
151
156
|
processShutdownCallback,
|
|
@@ -220,6 +225,8 @@ export class BeaconNode {
|
|
|
220
225
|
privateKey,
|
|
221
226
|
config,
|
|
222
227
|
clock,
|
|
228
|
+
pubkey2index,
|
|
229
|
+
index2pubkey,
|
|
223
230
|
dataDir,
|
|
224
231
|
db,
|
|
225
232
|
dbName: opts.db.name,
|
package/src/node/notifier.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
computeEpochAtSlot,
|
|
7
7
|
computeStartSlotAtEpoch,
|
|
8
8
|
isExecutionCachedStateType,
|
|
9
|
+
isMergeTransitionComplete,
|
|
9
10
|
} from "@lodestar/state-transition";
|
|
10
11
|
import {Epoch} from "@lodestar/types";
|
|
11
12
|
import {ErrorAborted, Logger, prettyBytes, prettyBytesShort, sleep} from "@lodestar/utils";
|
|
@@ -171,13 +172,18 @@ function getHeadExecutionInfo(
|
|
|
171
172
|
|
|
172
173
|
// Add execution status to notifier only if head is on/post bellatrix
|
|
173
174
|
if (isExecutionCachedStateType(headState)) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
if (isMergeTransitionComplete(headState)) {
|
|
176
|
+
const executionPayloadHashInfo =
|
|
177
|
+
headInfo.executionStatus !== ExecutionStatus.PreMerge ? headInfo.executionPayloadBlockHash : "empty";
|
|
178
|
+
const executionPayloadNumberInfo =
|
|
179
|
+
headInfo.executionStatus !== ExecutionStatus.PreMerge ? headInfo.executionPayloadNumber : NaN;
|
|
180
|
+
return [
|
|
181
|
+
`exec-block: ${executionStatusStr}(${executionPayloadNumberInfo} ${prettyBytesShort(
|
|
182
|
+
executionPayloadHashInfo
|
|
183
|
+
)})`,
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
return [`exec-block: ${executionStatusStr}`];
|
|
181
187
|
}
|
|
182
188
|
|
|
183
189
|
return [];
|
|
@@ -55,8 +55,7 @@ export async function verifyBlockProposerSignature(
|
|
|
55
55
|
if (blocks.length === 1 && blocks[0].message.slot === GENESIS_SLOT) return;
|
|
56
56
|
const signatures = blocks.reduce((sigs: ISignatureSet[], block) => {
|
|
57
57
|
// genesis block doesn't have valid signature
|
|
58
|
-
if (block.message.slot !== GENESIS_SLOT)
|
|
59
|
-
sigs.push(getBlockProposerSignatureSet(config, index2pubkey, state, block));
|
|
58
|
+
if (block.message.slot !== GENESIS_SLOT) sigs.push(getBlockProposerSignatureSet(config, index2pubkey, block));
|
|
60
59
|
return sigs;
|
|
61
60
|
}, []);
|
|
62
61
|
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PubkeyIndexMap } from "@chainsafe/pubkey-index-map";
|
|
2
|
-
import { routes } from "@lodestar/api";
|
|
3
|
-
import { BeaconConfig } from "@lodestar/config";
|
|
4
|
-
import { CachedBeaconStateAllForks } from "@lodestar/state-transition";
|
|
5
|
-
import { ValidatorIndex } from "@lodestar/types";
|
|
6
|
-
export type AttestationsRewards = routes.beacon.AttestationsRewards;
|
|
7
|
-
export declare function computeAttestationsRewards(config: BeaconConfig, pubkey2index: PubkeyIndexMap, state: CachedBeaconStateAllForks, validatorIds?: (ValidatorIndex | string)[]): Promise<AttestationsRewards>;
|
|
8
|
-
//# sourceMappingURL=attestationsRewards.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attestationsRewards.d.ts","sourceRoot":"","sources":["../../../src/chain/rewards/attestationsRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAc9C,OAAO,EACL,yBAAyB,EAU1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAG/C,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;AASpE,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,cAAc,EAC5B,KAAK,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,CAAC,cAAc,GAAG,MAAM,CAAC,EAAE,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAyB9B"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { EFFECTIVE_BALANCE_INCREMENT, ForkName, INACTIVITY_PENALTY_QUOTIENT_ALTAIR, MAX_EFFECTIVE_BALANCE, MAX_EFFECTIVE_BALANCE_ELECTRA, PARTICIPATION_FLAG_WEIGHTS, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR, isForkPostElectra, } from "@lodestar/params";
|
|
2
|
-
import { FLAG_ELIGIBLE_ATTESTER, FLAG_PREV_HEAD_ATTESTER_UNSLASHED, FLAG_PREV_SOURCE_ATTESTER_UNSLASHED, FLAG_PREV_TARGET_ATTESTER_UNSLASHED, beforeProcessEpoch, hasMarkers, isInInactivityLeak, } from "@lodestar/state-transition";
|
|
3
|
-
import { fromHex } from "@lodestar/utils";
|
|
4
|
-
const defaultAttestationsReward = { head: 0, target: 0, source: 0, inclusionDelay: 0, inactivity: 0 };
|
|
5
|
-
const defaultAttestationsPenalty = { target: 0, source: 0 };
|
|
6
|
-
export async function computeAttestationsRewards(config, pubkey2index, state, validatorIds) {
|
|
7
|
-
const fork = config.getForkName(state.slot);
|
|
8
|
-
if (fork === ForkName.phase0) {
|
|
9
|
-
throw Error("Unsupported fork. Attestations rewards calculation is not available in phase0");
|
|
10
|
-
}
|
|
11
|
-
const stateAltair = state;
|
|
12
|
-
const transitionCache = beforeProcessEpoch(stateAltair);
|
|
13
|
-
const [idealRewards, penalties] = computeIdealAttestationsRewardsAndPenaltiesAltair(config, stateAltair, transitionCache);
|
|
14
|
-
const totalRewards = computeTotalAttestationsRewardsAltair(config, pubkey2index, stateAltair, transitionCache, idealRewards, penalties, validatorIds);
|
|
15
|
-
return { idealRewards, totalRewards };
|
|
16
|
-
}
|
|
17
|
-
function computeIdealAttestationsRewardsAndPenaltiesAltair(config, state, transitionCache) {
|
|
18
|
-
const baseRewardPerIncrement = transitionCache.baseRewardPerIncrement;
|
|
19
|
-
const activeBalanceByIncrement = transitionCache.totalActiveStakeByIncrement;
|
|
20
|
-
const fork = config.getForkName(state.slot);
|
|
21
|
-
const maxEffectiveBalance = isForkPostElectra(fork) ? MAX_EFFECTIVE_BALANCE_ELECTRA : MAX_EFFECTIVE_BALANCE;
|
|
22
|
-
const maxEffectiveBalanceByIncrement = Math.floor(maxEffectiveBalance / EFFECTIVE_BALANCE_INCREMENT);
|
|
23
|
-
const idealRewards = Array.from({ length: maxEffectiveBalanceByIncrement + 1 }, (_, effectiveBalanceByIncrement) => ({
|
|
24
|
-
...defaultAttestationsReward,
|
|
25
|
-
effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
|
|
26
|
-
}));
|
|
27
|
-
const attestationsPenalties = Array.from({ length: maxEffectiveBalanceByIncrement + 1 }, (_, effectiveBalanceByIncrement) => ({
|
|
28
|
-
...defaultAttestationsPenalty,
|
|
29
|
-
effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
|
|
30
|
-
}));
|
|
31
|
-
for (let i = 0; i < PARTICIPATION_FLAG_WEIGHTS.length; i++) {
|
|
32
|
-
const weight = PARTICIPATION_FLAG_WEIGHTS[i];
|
|
33
|
-
let unslashedStakeByIncrement;
|
|
34
|
-
let flagName;
|
|
35
|
-
switch (i) {
|
|
36
|
-
case TIMELY_SOURCE_FLAG_INDEX: {
|
|
37
|
-
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.sourceStakeByIncrement;
|
|
38
|
-
flagName = "source";
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case TIMELY_TARGET_FLAG_INDEX: {
|
|
42
|
-
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.targetStakeByIncrement;
|
|
43
|
-
flagName = "target";
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case TIMELY_HEAD_FLAG_INDEX: {
|
|
47
|
-
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.headStakeByIncrement;
|
|
48
|
-
flagName = "head";
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
default: {
|
|
52
|
-
throw Error(`Unable to retrieve unslashed stake. Unknown participation flag index: ${i}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
for (let effectiveBalanceByIncrement = 0; effectiveBalanceByIncrement <= maxEffectiveBalanceByIncrement; effectiveBalanceByIncrement++) {
|
|
56
|
-
const baseReward = effectiveBalanceByIncrement * baseRewardPerIncrement;
|
|
57
|
-
const rewardNumerator = baseReward * weight * unslashedStakeByIncrement;
|
|
58
|
-
// Both idealReward and penalty are rounded to nearest integer. Loss of precision is minimal as unit is gwei
|
|
59
|
-
const idealReward = Math.round(rewardNumerator / activeBalanceByIncrement / WEIGHT_DENOMINATOR);
|
|
60
|
-
const penalty = Math.round((baseReward * weight) / WEIGHT_DENOMINATOR); // Positive number indicates penalty
|
|
61
|
-
const idealAttestationsReward = idealRewards[effectiveBalanceByIncrement];
|
|
62
|
-
idealAttestationsReward[flagName] = isInInactivityLeak(state) ? 0 : idealReward; // No attestations rewards during inactivity leak
|
|
63
|
-
if (flagName !== "head") {
|
|
64
|
-
const attestationPenalty = attestationsPenalties[effectiveBalanceByIncrement];
|
|
65
|
-
attestationPenalty[flagName] = penalty;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return [idealRewards, attestationsPenalties];
|
|
70
|
-
}
|
|
71
|
-
// Same calculation as `getRewardsAndPenaltiesAltair` but returns the breakdown of rewards instead of aggregated
|
|
72
|
-
function computeTotalAttestationsRewardsAltair(config, pubkey2index, state, transitionCache, idealRewards, penalties, validatorIds = []) {
|
|
73
|
-
const rewards = [];
|
|
74
|
-
const { flags } = transitionCache;
|
|
75
|
-
const { epochCtx } = state;
|
|
76
|
-
const validatorIndices = validatorIds
|
|
77
|
-
.map((id) => (typeof id === "number" ? id : pubkey2index.get(fromHex(id))))
|
|
78
|
-
.filter((index) => index !== undefined); // Validator indices to include in the result
|
|
79
|
-
const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_ALTAIR;
|
|
80
|
-
for (let i = 0; i < flags.length; i++) {
|
|
81
|
-
if (validatorIndices.length && !validatorIndices.includes(i)) {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const flag = flags[i];
|
|
85
|
-
if (!hasMarkers(flag, FLAG_ELIGIBLE_ATTESTER)) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const effectiveBalanceIncrement = epochCtx.effectiveBalanceIncrements[i];
|
|
89
|
-
const currentRewards = { ...defaultAttestationsReward, validatorIndex: i };
|
|
90
|
-
if (hasMarkers(flag, FLAG_PREV_SOURCE_ATTESTER_UNSLASHED)) {
|
|
91
|
-
currentRewards.source = idealRewards[effectiveBalanceIncrement].source;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
currentRewards.source = penalties[effectiveBalanceIncrement].source * -1; // Negative reward to indicate penalty
|
|
95
|
-
}
|
|
96
|
-
if (hasMarkers(flag, FLAG_PREV_TARGET_ATTESTER_UNSLASHED)) {
|
|
97
|
-
currentRewards.target = idealRewards[effectiveBalanceIncrement].target;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
currentRewards.target = penalties[effectiveBalanceIncrement].target * -1;
|
|
101
|
-
// Also incur inactivity penalty if not voting target correctly
|
|
102
|
-
const inactivityPenaltyNumerator = effectiveBalanceIncrement * EFFECTIVE_BALANCE_INCREMENT * state.inactivityScores.get(i);
|
|
103
|
-
currentRewards.inactivity = Math.floor(inactivityPenaltyNumerator / inactivityPenaltyDenominator) * -1;
|
|
104
|
-
}
|
|
105
|
-
if (hasMarkers(flag, FLAG_PREV_HEAD_ATTESTER_UNSLASHED)) {
|
|
106
|
-
currentRewards.head = idealRewards[effectiveBalanceIncrement].head;
|
|
107
|
-
}
|
|
108
|
-
rewards.push(currentRewards);
|
|
109
|
-
}
|
|
110
|
-
return rewards;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=attestationsRewards.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attestationsRewards.js","sourceRoot":"","sources":["../../../src/chain/rewards/attestationsRewards.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,2BAA2B,EAC3B,QAAQ,EACR,kCAAkC,EAClC,qBAAqB,EACrB,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,mCAAmC,EACnC,kBAAkB,EAClB,UAAU,EACV,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAQxC,MAAM,yBAAyB,GAAG,EAAC,IAAI,EAAE,CAAC,EAAE,MAA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,CAAC,CAAC,CAAC,sCAAsC;QAClH,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,EAAE,mCAAmC,CAAC,EAAE,CAAC;YAC1D,cAAc,CAAC,MAAM,GAAG,YAAY,CAAC,yBAAyB,CAAC,CAAC,MAAM,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,yBAAyB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEzE,+DAA+D;YAC/D,MAAM,0BAA0B,GAC9B,yBAAyB,GAAG,2BAA2B,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1F,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,0BAA0B,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;QACzG,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,EAAE,iCAAiC,CAAC,EAAE,CAAC;YACxD,cAAc,CAAC,IAAI,GAAG,YAAY,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC;QACrE,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { routes } from "@lodestar/api";
|
|
2
|
-
import { BeaconConfig } from "@lodestar/config";
|
|
3
|
-
import { CachedBeaconStateAllForks } from "@lodestar/state-transition";
|
|
4
|
-
import { BeaconBlock } from "@lodestar/types";
|
|
5
|
-
export type BlockRewards = routes.beacon.BlockRewards;
|
|
6
|
-
/**
|
|
7
|
-
* Calculate total proposer block rewards given block and the beacon state of the same slot before the block is applied (preState)
|
|
8
|
-
* postState can be passed in to read reward cache if available
|
|
9
|
-
* Standard (Non MEV) rewards for proposing a block consists of:
|
|
10
|
-
* 1) Including attestations from (beacon) committee
|
|
11
|
-
* 2) Including attestations from sync committee
|
|
12
|
-
* 3) Reporting slashable behaviours from proposer and attester
|
|
13
|
-
*/
|
|
14
|
-
export declare function computeBlockRewards(config: BeaconConfig, block: BeaconBlock, preState: CachedBeaconStateAllForks, postState?: CachedBeaconStateAllForks): Promise<BlockRewards>;
|
|
15
|
-
//# sourceMappingURL=blockRewards.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blockRewards.d.ts","sourceRoot":"","sources":["../../../src/chain/rewards/blockRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EACL,yBAAyB,EAK1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,WAAW,EAAiB,MAAM,iBAAiB,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;AAGtD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,yBAAyB,EACnC,SAAS,CAAC,EAAE,yBAAyB,GACpC,OAAO,CAAC,YAAY,CAAC,CAgCvB"}
|