@lodestar/state-transition 1.39.0-dev.d4a47659a5 → 1.39.0-dev.dd21e36997
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/block/index.d.ts.map +1 -1
- package/lib/block/index.js +4 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/isValidIndexedAttestation.d.ts +3 -2
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +4 -4
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/processAttestationPhase0.d.ts.map +1 -1
- package/lib/block/processAttestationPhase0.js +1 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +1 -1
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.js +1 -1
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processExecutionPayload.d.ts.map +1 -1
- package/lib/block/processExecutionPayload.js +6 -4
- package/lib/block/processExecutionPayload.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +1 -1
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processRandao.js +2 -2
- package/lib/block/processRandao.js.map +1 -1
- package/lib/block/processSyncCommittee.d.ts +3 -1
- package/lib/block/processSyncCommittee.d.ts.map +1 -1
- package/lib/block/processSyncCommittee.js +6 -4
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.d.ts.map +1 -1
- package/lib/block/processVoluntaryExit.js +2 -1
- package/lib/block/processVoluntaryExit.js.map +1 -1
- package/lib/block/processWithdrawals.d.ts +3 -3
- package/lib/block/processWithdrawals.d.ts.map +1 -1
- package/lib/block/processWithdrawals.js +152 -105
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/cache/epochCache.d.ts +0 -3
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +0 -3
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/stateCache.d.ts +1 -0
- package/lib/cache/stateCache.d.ts.map +1 -1
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts +6 -0
- package/lib/rewards/attestationsRewards.d.ts.map +1 -0
- package/lib/rewards/attestationsRewards.js +113 -0
- package/lib/rewards/attestationsRewards.js.map +1 -0
- package/lib/rewards/blockRewards.d.ts +13 -0
- package/lib/rewards/blockRewards.d.ts.map +1 -0
- package/lib/rewards/blockRewards.js +95 -0
- package/lib/rewards/blockRewards.js.map +1 -0
- package/lib/rewards/index.d.ts +4 -0
- package/lib/rewards/index.d.ts.map +1 -0
- package/lib/rewards/index.js +4 -0
- package/lib/rewards/index.js.map +1 -0
- package/lib/rewards/syncCommitteeRewards.d.ts +6 -0
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -0
- package/lib/rewards/syncCommitteeRewards.js +36 -0
- package/lib/rewards/syncCommitteeRewards.js.map +1 -0
- package/lib/signatureSets/attesterSlashings.d.ts +5 -5
- package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
- package/lib/signatureSets/attesterSlashings.js +10 -7
- package/lib/signatureSets/attesterSlashings.js.map +1 -1
- package/lib/signatureSets/index.d.ts +3 -2
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +10 -10
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.d.ts +6 -6
- package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedAttestation.js +12 -9
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +6 -6
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +12 -11
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.d.ts +4 -4
- package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
- package/lib/signatureSets/proposerSlashings.js +7 -4
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +3 -3
- package/lib/signatureSets/randao.d.ts.map +1 -1
- package/lib/signatureSets/randao.js +6 -4
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +5 -5
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +10 -7
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/stateTransition.js +1 -1
- package/lib/stateTransition.js.map +1 -1
- package/lib/util/execution.d.ts +11 -1
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +26 -1
- package/lib/util/execution.js.map +1 -1
- package/package.json +14 -11
- package/src/block/index.ts +6 -2
- package/src/block/isValidIndexedAttestation.ts +7 -2
- package/src/block/processAttestationPhase0.ts +1 -0
- package/src/block/processAttestationsAltair.ts +7 -1
- package/src/block/processAttesterSlashing.ts +1 -1
- package/src/block/processExecutionPayload.ts +14 -8
- package/src/block/processProposerSlashing.ts +6 -1
- package/src/block/processRandao.ts +2 -2
- package/src/block/processSyncCommittee.ts +15 -4
- package/src/block/processVoluntaryExit.ts +4 -1
- package/src/block/processWithdrawals.ts +230 -135
- package/src/cache/epochCache.ts +0 -3
- package/src/cache/stateCache.ts +1 -0
- package/src/index.ts +2 -2
- package/src/rewards/attestationsRewards.ts +200 -0
- package/src/rewards/blockRewards.ts +147 -0
- package/src/rewards/index.ts +3 -0
- package/src/rewards/syncCommitteeRewards.ts +59 -0
- package/src/signatureSets/attesterSlashings.ts +14 -9
- package/src/signatureSets/index.ts +14 -11
- package/src/signatureSets/indexedAttestation.ts +18 -11
- package/src/signatureSets/proposer.ts +14 -12
- package/src/signatureSets/proposerSlashings.ts +10 -10
- package/src/signatureSets/randao.ts +7 -5
- package/src/signatureSets/voluntaryExits.ts +14 -9
- package/src/stateTransition.ts +1 -1
- package/src/util/execution.ts +39 -0
package/lib/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export { ProposerRewardType } from "./block/types.js";
|
|
|
10
10
|
export { type EffectiveBalanceIncrements, getEffectiveBalanceIncrementsWithLen, getEffectiveBalanceIncrementsZeroed, } from "./cache/effectiveBalanceIncrements.js";
|
|
11
11
|
export { EpochCache, EpochCacheError, EpochCacheErrorCode, type EpochCacheImmutableData, createEmptyEpochCacheImmutableData, } from "./cache/epochCache.js";
|
|
12
12
|
export { type EpochTransitionCache, beforeProcessEpoch } from "./cache/epochTransitionCache.js";
|
|
13
|
-
export { type Index2PubkeyCache } from "./cache/pubkeyCache.js";
|
|
13
|
+
export { type Index2PubkeyCache, syncPubkeys } from "./cache/pubkeyCache.js";
|
|
14
14
|
export { type BeaconStateCache, createCachedBeaconState, isCachedBeaconState, isStateBalancesNodesPopulated, isStateValidatorsNodesPopulated, loadCachedBeaconState, } from "./cache/stateCache.js";
|
|
15
15
|
export * from "./constants/index.js";
|
|
16
16
|
export type { EpochTransitionStep } from "./epoch/index.js";
|
|
17
17
|
export { type BeaconStateTransitionMetrics, getMetrics } from "./metrics.js";
|
|
18
|
+
export * from "./rewards/index.js";
|
|
18
19
|
export * from "./signatureSets/index.js";
|
|
19
20
|
export * from "./stateTransition.js";
|
|
20
21
|
export type { BeaconStateAllForks, BeaconStateAltair, BeaconStateBellatrix, BeaconStateCapella, BeaconStateDeneb, BeaconStateElectra, BeaconStateExecutions, BeaconStateFulu, BeaconStateGloas, BeaconStatePhase0, CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateBellatrix, CachedBeaconStateCapella, CachedBeaconStateDeneb, CachedBeaconStateElectra, CachedBeaconStateExecutions, CachedBeaconStateFulu, CachedBeaconStateGloas, CachedBeaconStatePhase0, } from "./types.js";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,iCAAiC,EAAE,yBAAyB,EAAC,MAAM,sCAAsC,CAAC;AAClH,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,2BAA2B,EAAC,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAC,qBAAqB,EAAE,wBAAwB,EAAE,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAEtH,OAAO,EAAC,sBAAsB,EAAC,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,KAAK,0BAA0B,EAC/B,oCAAoC,EACpC,mCAAmC,GACpC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,kCAAkC,GACnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,KAAK,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,iCAAiC,EAAE,yBAAyB,EAAC,MAAM,sCAAsC,CAAC;AAClH,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OA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B,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,cAAc,iBAAiB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -13,10 +13,12 @@ export { ProposerRewardType } from "./block/types.js";
|
|
|
13
13
|
export { getEffectiveBalanceIncrementsWithLen, getEffectiveBalanceIncrementsZeroed, } from "./cache/effectiveBalanceIncrements.js";
|
|
14
14
|
export { EpochCache, EpochCacheError, EpochCacheErrorCode, createEmptyEpochCacheImmutableData, } from "./cache/epochCache.js";
|
|
15
15
|
export { beforeProcessEpoch } from "./cache/epochTransitionCache.js";
|
|
16
|
+
export { syncPubkeys } from "./cache/pubkeyCache.js";
|
|
16
17
|
// Main state caches
|
|
17
18
|
export { createCachedBeaconState, isCachedBeaconState, isStateBalancesNodesPopulated, isStateValidatorsNodesPopulated, loadCachedBeaconState, } from "./cache/stateCache.js";
|
|
18
19
|
export * from "./constants/index.js";
|
|
19
20
|
export { getMetrics } from "./metrics.js";
|
|
21
|
+
export * from "./rewards/index.js";
|
|
20
22
|
export * from "./signatureSets/index.js";
|
|
21
23
|
export * from "./stateTransition.js";
|
|
22
24
|
export * from "./util/index.js";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,iCAAiC,EAAE,yBAAyB,EAAC,MAAM,sCAAsC,CAAC;AAClH,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,2BAA2B,EAAC,MAAM,wCAAwC,CAAC;AACnF,qCAAqC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CA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,EACV,eAAe,EACf,mBAAmB,EAEnB,kCAAkC,GACnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAA4B,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAyB,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAC3E,oBAAoB;AACpB,OAAO,EAEL,uBAAuB,EACvB,mBAAmB,EACnB,6BAA6B,EAC7B,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAoC,UAAU,EAAC,MAAM,cAAc,CAAC;AAC3E,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AAwBrC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PubkeyIndexMap } from "@chainsafe/pubkey-index-map";
|
|
2
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
3
|
+
import { ValidatorIndex, rewards } from "@lodestar/types";
|
|
4
|
+
import { CachedBeaconStateAllForks } from "../types.js";
|
|
5
|
+
export declare function computeAttestationsRewards(config: BeaconConfig, pubkey2index: PubkeyIndexMap, state: CachedBeaconStateAllForks, validatorIds?: (ValidatorIndex | string)[]): Promise<rewards.AttestationsRewards>;
|
|
6
|
+
//# sourceMappingURL=attestationsRewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestationsRewards.d.ts","sourceRoot":"","sources":["../../src/rewards/attestationsRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAc9C,OAAO,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAC,yBAAyB,EAA0B,MAAM,aAAa,CAAC;AAgB/E,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,OAAO,CAAC,mBAAmB,CAAC,CAyBtC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 { fromHex } from "@lodestar/utils";
|
|
3
|
+
import { beforeProcessEpoch } from "../cache/epochTransitionCache.js";
|
|
4
|
+
import { FLAG_ELIGIBLE_ATTESTER, FLAG_PREV_HEAD_ATTESTER_UNSLASHED, FLAG_PREV_SOURCE_ATTESTER_UNSLASHED, FLAG_PREV_TARGET_ATTESTER_UNSLASHED, hasMarkers, isInInactivityLeak, } from "../util/index.js";
|
|
5
|
+
const defaultAttestationsReward = { head: 0, target: 0, source: 0, inclusionDelay: 0, inactivity: 0 };
|
|
6
|
+
const defaultAttestationsPenalty = { target: 0, source: 0 };
|
|
7
|
+
export async function computeAttestationsRewards(config, pubkey2index, state, validatorIds) {
|
|
8
|
+
const fork = config.getForkName(state.slot);
|
|
9
|
+
if (fork === ForkName.phase0) {
|
|
10
|
+
throw Error("Unsupported fork. Attestations rewards calculation is not available in phase0");
|
|
11
|
+
}
|
|
12
|
+
const stateAltair = state;
|
|
13
|
+
const transitionCache = beforeProcessEpoch(stateAltair);
|
|
14
|
+
const [idealRewards, penalties] = computeIdealAttestationsRewardsAndPenaltiesAltair(config, stateAltair, transitionCache);
|
|
15
|
+
const totalRewards = computeTotalAttestationsRewardsAltair(config, pubkey2index, stateAltair, transitionCache, idealRewards, penalties, validatorIds);
|
|
16
|
+
return { idealRewards, totalRewards };
|
|
17
|
+
}
|
|
18
|
+
function computeIdealAttestationsRewardsAndPenaltiesAltair(config, state, transitionCache) {
|
|
19
|
+
const baseRewardPerIncrement = transitionCache.baseRewardPerIncrement;
|
|
20
|
+
const activeBalanceByIncrement = transitionCache.totalActiveStakeByIncrement;
|
|
21
|
+
const fork = config.getForkName(state.slot);
|
|
22
|
+
const maxEffectiveBalance = isForkPostElectra(fork) ? MAX_EFFECTIVE_BALANCE_ELECTRA : MAX_EFFECTIVE_BALANCE;
|
|
23
|
+
const maxEffectiveBalanceByIncrement = Math.floor(maxEffectiveBalance / EFFECTIVE_BALANCE_INCREMENT);
|
|
24
|
+
const idealRewards = Array.from({ length: maxEffectiveBalanceByIncrement + 1 }, (_, effectiveBalanceByIncrement) => ({
|
|
25
|
+
...defaultAttestationsReward,
|
|
26
|
+
effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
|
|
27
|
+
}));
|
|
28
|
+
const attestationsPenalties = Array.from({ length: maxEffectiveBalanceByIncrement + 1 }, (_, effectiveBalanceByIncrement) => ({
|
|
29
|
+
...defaultAttestationsPenalty,
|
|
30
|
+
effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
|
|
31
|
+
}));
|
|
32
|
+
for (let i = 0; i < PARTICIPATION_FLAG_WEIGHTS.length; i++) {
|
|
33
|
+
const weight = PARTICIPATION_FLAG_WEIGHTS[i];
|
|
34
|
+
let unslashedStakeByIncrement;
|
|
35
|
+
let flagName;
|
|
36
|
+
switch (i) {
|
|
37
|
+
case TIMELY_SOURCE_FLAG_INDEX: {
|
|
38
|
+
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.sourceStakeByIncrement;
|
|
39
|
+
flagName = "source";
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case TIMELY_TARGET_FLAG_INDEX: {
|
|
43
|
+
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.targetStakeByIncrement;
|
|
44
|
+
flagName = "target";
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case TIMELY_HEAD_FLAG_INDEX: {
|
|
48
|
+
unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.headStakeByIncrement;
|
|
49
|
+
flagName = "head";
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
default: {
|
|
53
|
+
throw Error(`Unable to retrieve unslashed stake. Unknown participation flag index: ${i}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (let effectiveBalanceByIncrement = 0; effectiveBalanceByIncrement <= maxEffectiveBalanceByIncrement; effectiveBalanceByIncrement++) {
|
|
57
|
+
const baseReward = effectiveBalanceByIncrement * baseRewardPerIncrement;
|
|
58
|
+
const rewardNumerator = baseReward * weight * unslashedStakeByIncrement;
|
|
59
|
+
// Both idealReward and penalty are rounded to nearest integer. Loss of precision is minimal as unit is gwei
|
|
60
|
+
const idealReward = Math.round(rewardNumerator / activeBalanceByIncrement / WEIGHT_DENOMINATOR);
|
|
61
|
+
const penalty = Math.round((baseReward * weight) / WEIGHT_DENOMINATOR); // Positive number indicates penalty
|
|
62
|
+
const idealAttestationsReward = idealRewards[effectiveBalanceByIncrement];
|
|
63
|
+
idealAttestationsReward[flagName] = isInInactivityLeak(state) ? 0 : idealReward; // No attestations rewards during inactivity leak
|
|
64
|
+
if (flagName !== "head") {
|
|
65
|
+
const attestationPenalty = attestationsPenalties[effectiveBalanceByIncrement];
|
|
66
|
+
attestationPenalty[flagName] = penalty;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [idealRewards, attestationsPenalties];
|
|
71
|
+
}
|
|
72
|
+
// Same calculation as `getRewardsAndPenaltiesAltair` but returns the breakdown of rewards instead of aggregated
|
|
73
|
+
function computeTotalAttestationsRewardsAltair(config, pubkey2index, state, transitionCache, idealRewards, penalties, validatorIds = []) {
|
|
74
|
+
const rewards = [];
|
|
75
|
+
const { flags } = transitionCache;
|
|
76
|
+
const { epochCtx } = state;
|
|
77
|
+
const validatorIndices = validatorIds
|
|
78
|
+
.map((id) => (typeof id === "number" ? id : pubkey2index.get(fromHex(id))))
|
|
79
|
+
.filter((index) => index !== undefined); // Validator indices to include in the result
|
|
80
|
+
const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_ALTAIR;
|
|
81
|
+
for (let i = 0; i < flags.length; i++) {
|
|
82
|
+
if (validatorIndices.length && !validatorIndices.includes(i)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const flag = flags[i];
|
|
86
|
+
if (!hasMarkers(flag, FLAG_ELIGIBLE_ATTESTER)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const effectiveBalanceIncrement = epochCtx.effectiveBalanceIncrements[i];
|
|
90
|
+
const currentRewards = { ...defaultAttestationsReward, validatorIndex: i };
|
|
91
|
+
if (hasMarkers(flag, FLAG_PREV_SOURCE_ATTESTER_UNSLASHED)) {
|
|
92
|
+
currentRewards.source = idealRewards[effectiveBalanceIncrement].source;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
currentRewards.source = penalties[effectiveBalanceIncrement].source * -1; // Negative reward to indicate penalty
|
|
96
|
+
}
|
|
97
|
+
if (hasMarkers(flag, FLAG_PREV_TARGET_ATTESTER_UNSLASHED)) {
|
|
98
|
+
currentRewards.target = idealRewards[effectiveBalanceIncrement].target;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
currentRewards.target = penalties[effectiveBalanceIncrement].target * -1;
|
|
102
|
+
// Also incur inactivity penalty if not voting target correctly
|
|
103
|
+
const inactivityPenaltyNumerator = effectiveBalanceIncrement * EFFECTIVE_BALANCE_INCREMENT * state.inactivityScores.get(i);
|
|
104
|
+
currentRewards.inactivity = Math.floor(inactivityPenaltyNumerator / inactivityPenaltyDenominator) * -1;
|
|
105
|
+
}
|
|
106
|
+
if (hasMarkers(flag, FLAG_PREV_HEAD_ATTESTER_UNSLASHED)) {
|
|
107
|
+
currentRewards.head = idealRewards[effectiveBalanceIncrement].head;
|
|
108
|
+
}
|
|
109
|
+
rewards.push(currentRewards);
|
|
110
|
+
}
|
|
111
|
+
return rewards;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=attestationsRewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestationsRewards.js","sourceRoot":"","sources":["../../src/rewards/attestationsRewards.ts"],"names":[],"mappings":"AAEA,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;AAE1B,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAuB,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAE1F,OAAO,EACL,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,mCAAmC,EACnC,UAAU,EACV,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,yBAAyB,GAAG,EAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAC,CAAC;AACpG,MAAM,0BAA0B,GAAG,EAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAAoB,EACpB,YAA4B,EAC5B,KAAgC,EAChC,YAA0C;IAE1C,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,I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yB,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { BeaconBlock, rewards } from "@lodestar/types";
|
|
3
|
+
import { CachedBeaconStateAllForks } from "../cache/stateCache.js";
|
|
4
|
+
/**
|
|
5
|
+
* Calculate total proposer block rewards given block and the beacon state of the same slot before the block is applied (preState)
|
|
6
|
+
* postState can be passed in to read reward cache if available
|
|
7
|
+
* Standard (Non MEV) rewards for proposing a block consists of:
|
|
8
|
+
* 1) Including attestations from (beacon) committee
|
|
9
|
+
* 2) Including attestations from sync committee
|
|
10
|
+
* 3) Reporting slashable behaviours from proposer and attester
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeBlockRewards(config: BeaconConfig, block: BeaconBlock, preState: CachedBeaconStateAllForks, postState?: CachedBeaconStateAllForks): Promise<rewards.BlockRewards>;
|
|
13
|
+
//# sourceMappingURL=blockRewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRewards.d.ts","sourceRoot":"","sources":["../../src/rewards/blockRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EAAC,WAAW,EAAkB,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAC,yBAAyB,EAAmD,MAAM,wBAAwB,CAAC;AAKnH;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,yBAAyB,EACnC,SAAS,CAAC,EAAE,yBAAyB,GACpC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAgC/B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ForkName, WHISTLEBLOWER_REWARD_QUOTIENT, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA, isForkPostElectra, } from "@lodestar/params";
|
|
2
|
+
import { processAttestationsAltair } from "../block/processAttestationsAltair.js";
|
|
3
|
+
import { getAttesterSlashableIndices } from "../util/attestation.js";
|
|
4
|
+
/**
|
|
5
|
+
* Calculate total proposer block rewards given block and the beacon state of the same slot before the block is applied (preState)
|
|
6
|
+
* postState can be passed in to read reward cache if available
|
|
7
|
+
* Standard (Non MEV) rewards for proposing a block consists of:
|
|
8
|
+
* 1) Including attestations from (beacon) committee
|
|
9
|
+
* 2) Including attestations from sync committee
|
|
10
|
+
* 3) Reporting slashable behaviours from proposer and attester
|
|
11
|
+
*/
|
|
12
|
+
export async function computeBlockRewards(config, block, preState, postState) {
|
|
13
|
+
const fork = config.getForkName(block.slot);
|
|
14
|
+
const { attestations: cachedAttestationsReward = 0, syncAggregate: cachedSyncAggregateReward = 0 } = postState?.proposerRewards ?? {};
|
|
15
|
+
let blockAttestationReward = cachedAttestationsReward;
|
|
16
|
+
let syncAggregateReward = cachedSyncAggregateReward;
|
|
17
|
+
if (blockAttestationReward === 0) {
|
|
18
|
+
blockAttestationReward =
|
|
19
|
+
fork === ForkName.phase0
|
|
20
|
+
? computeBlockAttestationRewardPhase0(block, preState)
|
|
21
|
+
: computeBlockAttestationRewardAltair(config, block, preState);
|
|
22
|
+
}
|
|
23
|
+
if (syncAggregateReward === 0) {
|
|
24
|
+
syncAggregateReward = computeSyncAggregateReward(block, preState);
|
|
25
|
+
}
|
|
26
|
+
const blockProposerSlashingReward = computeBlockProposerSlashingReward(fork, block, preState);
|
|
27
|
+
const blockAttesterSlashingReward = computeBlockAttesterSlashingReward(fork, block, preState);
|
|
28
|
+
const total = blockAttestationReward + syncAggregateReward + blockProposerSlashingReward + blockAttesterSlashingReward;
|
|
29
|
+
return {
|
|
30
|
+
proposerIndex: block.proposerIndex,
|
|
31
|
+
total,
|
|
32
|
+
attestations: blockAttestationReward,
|
|
33
|
+
syncAggregate: syncAggregateReward,
|
|
34
|
+
proposerSlashings: blockProposerSlashingReward,
|
|
35
|
+
attesterSlashings: blockAttesterSlashingReward,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* TODO: Calculate rewards received by block proposer for including attestations.
|
|
40
|
+
*/
|
|
41
|
+
function computeBlockAttestationRewardPhase0(_block, _preState) {
|
|
42
|
+
throw new Error("Unsupported fork! Block attestation reward calculation is not available in phase0");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate rewards received by block proposer for including attestations since Altair.
|
|
46
|
+
* Reuses `processAttestationsAltair()`. Has dependency on RewardCache
|
|
47
|
+
*/
|
|
48
|
+
function computeBlockAttestationRewardAltair(config, block, preState) {
|
|
49
|
+
const fork = config.getForkSeq(block.slot);
|
|
50
|
+
const { attestations } = block.body;
|
|
51
|
+
processAttestationsAltair(fork, preState, attestations, false);
|
|
52
|
+
return preState.proposerRewards.attestations;
|
|
53
|
+
}
|
|
54
|
+
function computeSyncAggregateReward(block, preState) {
|
|
55
|
+
if (block.body.syncAggregate !== undefined) {
|
|
56
|
+
const { syncCommitteeBits } = block.body.syncAggregate;
|
|
57
|
+
const { syncProposerReward } = preState.epochCtx;
|
|
58
|
+
return syncCommitteeBits.getTrueBitIndexes().length * Math.floor(syncProposerReward); // syncProposerReward should already be integer
|
|
59
|
+
}
|
|
60
|
+
return 0; // phase0 block does not have syncAggregate
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Calculate rewards received by block proposer for including proposer slashings.
|
|
64
|
+
* All proposer slashing rewards go to block proposer and none to whistleblower as of Deneb
|
|
65
|
+
*/
|
|
66
|
+
function computeBlockProposerSlashingReward(fork, block, state) {
|
|
67
|
+
let proposerSlashingReward = 0;
|
|
68
|
+
for (const proposerSlashing of block.body.proposerSlashings) {
|
|
69
|
+
const offendingProposerIndex = proposerSlashing.signedHeader1.message.proposerIndex;
|
|
70
|
+
const offendingProposerBalance = state.validators.getReadonly(offendingProposerIndex).effectiveBalance;
|
|
71
|
+
const whistleblowerRewardQuotient = isForkPostElectra(fork)
|
|
72
|
+
? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
|
73
|
+
: WHISTLEBLOWER_REWARD_QUOTIENT;
|
|
74
|
+
proposerSlashingReward += Math.floor(offendingProposerBalance / whistleblowerRewardQuotient);
|
|
75
|
+
}
|
|
76
|
+
return proposerSlashingReward;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Calculate rewards received by block proposer for including attester slashings.
|
|
80
|
+
* All attester slashing rewards go to block proposer and none to whistleblower as of Deneb
|
|
81
|
+
*/
|
|
82
|
+
function computeBlockAttesterSlashingReward(fork, block, preState) {
|
|
83
|
+
let attesterSlashingReward = 0;
|
|
84
|
+
for (const attesterSlashing of block.body.attesterSlashings) {
|
|
85
|
+
for (const offendingAttesterIndex of getAttesterSlashableIndices(attesterSlashing)) {
|
|
86
|
+
const offendingAttesterBalance = preState.validators.getReadonly(offendingAttesterIndex).effectiveBalance;
|
|
87
|
+
const whistleblowerRewardQuotient = isForkPostElectra(fork)
|
|
88
|
+
? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
|
89
|
+
: WHISTLEBLOWER_REWARD_QUOTIENT;
|
|
90
|
+
attesterSlashingReward += Math.floor(offendingAttesterBalance / whistleblowerRewardQuotient);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return attesterSlashingReward;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=blockRewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRewards.js","sourceRoot":"","sources":["../../src/rewards/blockRewards.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,6BAA6B,EAC7B,qCAAqC,EACrC,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,yBAAyB,EAAC,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAC,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AAInE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAoB,EACpB,KAAkB,EAClB,QAAmC,EACnC,SAAqC;IAErC,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,EAAC,YAAY,EAAE,wBAAwB,GAAG,CAAC,EAAE,aAAa,EAAE,yBAAyB,GAAG,CAAC,EAAC,GAC9F,SAAS,EAAE,eAAe,IAAI,EAAE,CAAC;IACnC,IAAI,sBAAsB,GAAG,wBAAwB,CAAC;IACtD,IAAI,mBAAmB,GAAG,yBAAyB,CAAC;IAEpD,IAAI,sBAAsB,KAAK,CAAC,EAAE,CAAC;QACjC,sBAAsB;YACpB,IAAI,KAAK,QAAQ,CAAC,MAAM;gBACtB,CAAC,CAAC,mCAAmC,CAAC,KAA2B,EAAE,QAAmC,CAAC;gBACvG,CAAC,CAAC,mCAAmC,CAAC,MAAM,EAAE,KAA2B,EAAE,QAAmC,CAAC,CAAC;IACtH,CAAC;IAED,IAAI,mBAAmB,KAAK,CAAC,EAAE,CAAC;QAC9B,mBAAmB,GAAG,0BAA0B,CAAC,KAA2B,EAAE,QAAmC,CAAC,CAAC;IACrH,CAAC;IAED,MAAM,2BAA2B,GAAG,kCAAkC,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,C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CAAC;IAED,OAAO,sBAAsB,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rewards/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rewards/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { BeaconBlock, ValidatorIndex, rewards } from "@lodestar/types";
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
4
|
+
import { CachedBeaconStateAllForks } from "../cache/stateCache.js";
|
|
5
|
+
export declare function computeSyncCommitteeRewards(config: BeaconConfig, index2pubkey: Index2PubkeyCache, block: BeaconBlock, preState: CachedBeaconStateAllForks, validatorIds?: (ValidatorIndex | string)[]): Promise<rewards.SyncCommitteeRewards>;
|
|
6
|
+
//# sourceMappingURL=syncCommitteeRewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncCommitteeRewards.d.ts","sourceRoot":"","sources":["../../src/rewards/syncCommitteeRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAE,cAAc,EAAU,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,yBAAyB,EAA0B,MAAM,wBAAwB,CAAC;AAI1F,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,yBAAyB,EACnC,YAAY,GAAE,CAAC,cAAc,GAAG,MAAM,CAAC,EAAO,GAC7C,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CA4CvC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ForkName, SYNC_COMMITTEE_SIZE } from "@lodestar/params";
|
|
2
|
+
export async function computeSyncCommitteeRewards(config, index2pubkey, block, preState, validatorIds = []) {
|
|
3
|
+
const fork = config.getForkName(block.slot);
|
|
4
|
+
if (fork === ForkName.phase0) {
|
|
5
|
+
throw Error("Cannot get sync rewards as phase0 block does not have sync committee");
|
|
6
|
+
}
|
|
7
|
+
const altairBlock = block;
|
|
8
|
+
const preStateAltair = preState;
|
|
9
|
+
// Bound syncCommitteeValidatorIndices in case it goes beyond SYNC_COMMITTEE_SIZE just to be safe
|
|
10
|
+
const syncCommitteeValidatorIndices = preStateAltair.epochCtx.currentSyncCommitteeIndexed.validatorIndices.slice(0, SYNC_COMMITTEE_SIZE);
|
|
11
|
+
const { syncParticipantReward } = preStateAltair.epochCtx;
|
|
12
|
+
const { syncCommitteeBits } = altairBlock.body.syncAggregate;
|
|
13
|
+
// Use balance of each committee as starting point such that we cap the penalty to avoid balance dropping below 0
|
|
14
|
+
const balances = new Map();
|
|
15
|
+
for (const i of syncCommitteeValidatorIndices) {
|
|
16
|
+
balances.set(i, { val: preStateAltair.balances.get(i) });
|
|
17
|
+
}
|
|
18
|
+
for (const i of syncCommitteeValidatorIndices) {
|
|
19
|
+
const balanceRecord = balances.get(i);
|
|
20
|
+
if (syncCommitteeBits.get(i)) {
|
|
21
|
+
// Positive rewards for participants
|
|
22
|
+
balanceRecord.val += syncParticipantReward;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Negative rewards for non participants
|
|
26
|
+
balanceRecord.val = Math.max(0, balanceRecord.val - syncParticipantReward);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const rewards = Array.from(balances, ([validatorIndex, v]) => ({ validatorIndex, reward: v.val }));
|
|
30
|
+
if (validatorIds.length) {
|
|
31
|
+
const filtersSet = new Set(validatorIds);
|
|
32
|
+
return rewards.filter((reward) => filtersSet.has(reward.validatorIndex) || filtersSet.has(index2pubkey[reward.validatorIndex].toHex()));
|
|
33
|
+
}
|
|
34
|
+
return rewards;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=syncCommitteeRewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncCommitteeRewards.js","sourceRoot":"","sources":["../../src/rewards/syncCommitteeRewards.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAO/D,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAoB,EACpB,YAA+B,EAC/B,KAAkB,EAClB,QAAmC,EACnC,eAA4C,EAAE;IAE9C,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC,sEAAsE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,WAAW,GAAG,KAA2B,CAAC;IAChD,MAAM,cAAc,GAAG,QAAmC,CAAC;IAE3D,iGAAiG;IACjG,MAAM,6BAA6B,GAAG,cAAc,CAAC,QAAQ,CAAC,2BAA2B,CAAC,gBAAgB,CAAC,KAAK,CAC9G,CAAC,EACD,mBAAmB,CACpB,CAAC;IACF,MAAM,EAAC,qBAAqB,EAAC,GAAG,cAAc,CAAC,QAAQ,CAAC;IACxD,MAAM,EAAC,iBAAiB,EAAC,GAAG,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;IAE3D,iHAAiH;IACjH,MAAM,QAAQ,GAAuC,IAAI,GAAG,EAAE,CAA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aconConfig } from "@lodestar/config";
|
|
2
|
+
import { AttesterSlashing, IndexedAttestationBigint, SignedBeaconBlock, Slot } from "@lodestar/types";
|
|
2
3
|
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
|
-
import { CachedBeaconStateAllForks } from "../types.js";
|
|
4
4
|
import { ISignatureSet } from "../util/index.js";
|
|
5
5
|
/** Get signature sets from all AttesterSlashing objects in a block */
|
|
6
|
-
export declare function getAttesterSlashingsSignatureSets(
|
|
6
|
+
export declare function getAttesterSlashingsSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock): ISignatureSet[];
|
|
7
7
|
/** Get signature sets from a single AttesterSlashing object */
|
|
8
|
-
export declare function getAttesterSlashingSignatureSets(index2pubkey: Index2PubkeyCache,
|
|
9
|
-
export declare function getIndexedAttestationBigintSignatureSet(index2pubkey: Index2PubkeyCache,
|
|
8
|
+
export declare function getAttesterSlashingSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, attesterSlashing: AttesterSlashing): ISignatureSet[];
|
|
9
|
+
export declare function getIndexedAttestationBigintSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, indexedAttestation: IndexedAttestationBigint): ISignatureSet;
|
|
10
10
|
//# sourceMappingURL=attesterSlashings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attesterSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/attesterSlashings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attesterSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/attesterSlashings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,gBAAgB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,IAAI,EAAM,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAgE,MAAM,kBAAkB,CAAC;AAE9G,sEAAsE;AACtE,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAC7B,aAAa,EAAE,CAOjB;AAED,+DAA+D;AAC/D,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,gBAAgB,EAAE,gBAAgB,GACjC,aAAa,EAAE,CAIjB;AAED,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,kBAAkB,EAAE,wBAAwB,GAC3C,aAAa,CAUf"}
|
|
@@ -2,16 +2,19 @@ import { DOMAIN_BEACON_ATTESTER } from "@lodestar/params";
|
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch } from "../util/index.js";
|
|
4
4
|
/** Get signature sets from all AttesterSlashing objects in a block */
|
|
5
|
-
export function getAttesterSlashingsSignatureSets(
|
|
6
|
-
|
|
5
|
+
export function getAttesterSlashingsSignatureSets(config, index2pubkey, signedBlock) {
|
|
6
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
7
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
8
|
+
const blockSlot = signedBlock.message.slot;
|
|
9
|
+
return signedBlock.message.body.attesterSlashings.flatMap((attesterSlashing) => getAttesterSlashingSignatureSets(config, index2pubkey, blockSlot, attesterSlashing));
|
|
7
10
|
}
|
|
8
11
|
/** Get signature sets from a single AttesterSlashing object */
|
|
9
|
-
export function getAttesterSlashingSignatureSets(index2pubkey,
|
|
10
|
-
return [attesterSlashing.attestation1, attesterSlashing.attestation2].map((attestation) => getIndexedAttestationBigintSignatureSet(index2pubkey,
|
|
12
|
+
export function getAttesterSlashingSignatureSets(config, index2pubkey, stateSlot, attesterSlashing) {
|
|
13
|
+
return [attesterSlashing.attestation1, attesterSlashing.attestation2].map((attestation) => getIndexedAttestationBigintSignatureSet(config, index2pubkey, stateSlot, attestation));
|
|
11
14
|
}
|
|
12
|
-
export function getIndexedAttestationBigintSignatureSet(index2pubkey,
|
|
13
|
-
const
|
|
14
|
-
const domain =
|
|
15
|
+
export function getIndexedAttestationBigintSignatureSet(config, index2pubkey, stateSlot, indexedAttestation) {
|
|
16
|
+
const messageSlot = computeStartSlotAtEpoch(Number(indexedAttestation.data.target.epoch));
|
|
17
|
+
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_ATTESTER, messageSlot);
|
|
15
18
|
return {
|
|
16
19
|
type: SignatureSetType.aggregate,
|
|
17
20
|
pubkeys: indexedAttestation.attestingIndices.map((i) => index2pubkey[i]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attesterSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/attesterSlashings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attesterSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/attesterSlashings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAsE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEzG,OAAO,EAAgB,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AAE9G,sEAAsE;AACtE,MAAM,UAAU,iCAAiC,CAC/C,MAAoB,EACpB,YAA+B,EAC/B,WAA8B;IAE9B,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAC7E,gCAAgC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,CAAC,CACpF,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,gCAAgC,CAC9C,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,gBAAkC;IAElC,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACxF,uCAAuC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CACtF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,kBAA4C;IAE5C,MAAM,WAAW,GAAG,uBAAuB,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAe,CAAC,CAAC,CAAC;IACpG,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,sBAAsB,EAAE,WAAW,CAAC,CAAC;IAEhF,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,SAAS;QAChC,OAAO,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACxE,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC;QAClG,SAAS,EAAE,kBAAkB,CAAC,SAAS;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
1
2
|
import { IndexedAttestation, SignedBeaconBlock } from "@lodestar/types";
|
|
2
3
|
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
|
-
import {
|
|
4
|
+
import { SyncCommitteeCache } from "../cache/syncCommitteeCache.js";
|
|
4
5
|
import { ISignatureSet } from "../util/index.js";
|
|
5
6
|
export * from "./attesterSlashings.js";
|
|
6
7
|
export * from "./blsToExecutionChange.js";
|
|
@@ -14,7 +15,7 @@ export * from "./voluntaryExits.js";
|
|
|
14
15
|
* Includes all signatures on the block (except the deposit signatures) for verification.
|
|
15
16
|
* Deposits are not included because they can legally have invalid signatures.
|
|
16
17
|
*/
|
|
17
|
-
export declare function getBlockSignatureSets(index2pubkey: Index2PubkeyCache,
|
|
18
|
+
export declare function getBlockSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, currentSyncCommitteeIndexed: SyncCommitteeCache, signedBlock: SignedBeaconBlock, indexedAttestations: IndexedAttestation[], opts?: {
|
|
18
19
|
/** Useful since block proposer signature is verified beforehand on gossip validation */
|
|
19
20
|
skipProposerSignature?: boolean;
|
|
20
21
|
}): ISignatureSet[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signatureSets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signatureSets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAkB,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAS/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,2BAA2B,EAAE,kBAAkB,EAC/C,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,kBAAkB,EAAE,EACzC,IAAI,CAAC,EAAE;IACL,wFAAwF;IACxF,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GACA,aAAa,EAAE,CA0CjB"}
|
|
@@ -19,22 +19,22 @@ export * from "./voluntaryExits.js";
|
|
|
19
19
|
* Includes all signatures on the block (except the deposit signatures) for verification.
|
|
20
20
|
* Deposits are not included because they can legally have invalid signatures.
|
|
21
21
|
*/
|
|
22
|
-
export function getBlockSignatureSets(index2pubkey,
|
|
22
|
+
export function getBlockSignatureSets(config, index2pubkey, currentSyncCommitteeIndexed, signedBlock, indexedAttestations, opts) {
|
|
23
23
|
// fork based validations
|
|
24
|
-
const fork =
|
|
24
|
+
const fork = config.getForkSeq(signedBlock.message.slot);
|
|
25
25
|
const signatureSets = [
|
|
26
|
-
getRandaoRevealSignatureSet(
|
|
27
|
-
...getProposerSlashingsSignatureSets(
|
|
28
|
-
...getAttesterSlashingsSignatureSets(
|
|
29
|
-
...getAttestationsSignatureSets(
|
|
30
|
-
...getVoluntaryExitsSignatureSets(
|
|
26
|
+
getRandaoRevealSignatureSet(config, index2pubkey, signedBlock.message),
|
|
27
|
+
...getProposerSlashingsSignatureSets(config, index2pubkey, signedBlock),
|
|
28
|
+
...getAttesterSlashingsSignatureSets(config, index2pubkey, signedBlock),
|
|
29
|
+
...getAttestationsSignatureSets(config, index2pubkey, signedBlock, indexedAttestations),
|
|
30
|
+
...getVoluntaryExitsSignatureSets(config, index2pubkey, signedBlock),
|
|
31
31
|
];
|
|
32
32
|
if (!opts?.skipProposerSignature) {
|
|
33
|
-
signatureSets.push(getBlockProposerSignatureSet(
|
|
33
|
+
signatureSets.push(getBlockProposerSignatureSet(config, index2pubkey, signedBlock));
|
|
34
34
|
}
|
|
35
35
|
// Only after altair fork, validate tSyncCommitteeSignature
|
|
36
36
|
if (fork >= ForkSeq.altair) {
|
|
37
|
-
const syncCommitteeSignatureSet = getSyncCommitteeSignatureSet(index2pubkey,
|
|
37
|
+
const syncCommitteeSignatureSet = getSyncCommitteeSignatureSet(config, index2pubkey, currentSyncCommitteeIndexed, signedBlock.message);
|
|
38
38
|
// There may be no participants in this syncCommitteeSignature, so it must not be validated
|
|
39
39
|
if (syncCommitteeSignatureSet) {
|
|
40
40
|
signatureSets.push(syncCommitteeSignatureSet);
|
|
@@ -42,7 +42,7 @@ export function getBlockSignatureSets(index2pubkey, state, signedBlock, indexedA
|
|
|
42
42
|
}
|
|
43
43
|
// only after capella fork
|
|
44
44
|
if (fork >= ForkSeq.capella) {
|
|
45
|
-
const blsToExecutionChangeSignatureSets = getBlsToExecutionChangeSignatureSets(
|
|
45
|
+
const blsToExecutionChangeSignatureSets = getBlsToExecutionChangeSignatureSets(config, signedBlock);
|
|
46
46
|
if (blsToExecutionChangeSignatureSets.length > 0) {
|
|
47
47
|
signatureSets.push(...blsToExecutionChangeSignatureSets);
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signatureSets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signatureSets/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAC,4BAA4B,EAAC,MAAM,kCAAkC,CAAC;AAI9E,OAAO,EAAC,iCAAiC,EAAC,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAC,oCAAoC,EAAC,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAC,4BAA4B,EAAC,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,GAAG,4BAA4B,CAC5D,MAAM,EACN,YAAY,EACZ,2BAA2B,EAC1B,WAAwC,CAAC,OAAO,CAClD,CAAC;QACF,2FAA2F;QAC3F,IAAI,yBAAyB,EAAE,CAAC;YAC9B,aAAa,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,iCAAiC,GAAG,oCAAoC,CAC5E,MAAM,EACN,WAAwC,CACzC,CAAC;QACF,IAAI,iCAAiC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,aAAa,CAAC,IAAI,CAAC,GAAG,iCAAiC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { IndexedAttestation, SignedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
2
3
|
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
|
-
import { CachedBeaconStateAllForks } from "../types.js";
|
|
4
4
|
import { ISignatureSet } from "../util/index.js";
|
|
5
|
-
export declare function getAttestationDataSigningRoot(
|
|
6
|
-
export declare function getAttestationWithIndicesSignatureSet(index2pubkey: Index2PubkeyCache,
|
|
7
|
-
export declare function getIndexedAttestationSignatureSet(index2pubkey: Index2PubkeyCache,
|
|
8
|
-
export declare function getAttestationsSignatureSets(
|
|
5
|
+
export declare function getAttestationDataSigningRoot(config: BeaconConfig, stateSlot: Slot, data: phase0.AttestationData): Uint8Array;
|
|
6
|
+
export declare function getAttestationWithIndicesSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, attestation: Pick<phase0.Attestation, "data" | "signature">, attestingIndices: number[]): ISignatureSet;
|
|
7
|
+
export declare function getIndexedAttestationSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, indexedAttestation: IndexedAttestation): ISignatureSet;
|
|
8
|
+
export declare function getAttestationsSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock, indexedAttestations: IndexedAttestation[]): ISignatureSet[];
|
|
9
9
|
//# sourceMappingURL=indexedAttestation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexedAttestation.d.ts","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexedAttestation.d.ts","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAId,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,IAAI,EACf,IAAI,EAAE,MAAM,CAAC,eAAe,GAC3B,UAAU,CAKZ;AAED,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC,EAC3D,gBAAgB,EAAE,MAAM,EAAE,GACzB,aAAa,CAMf;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,kBAAkB,EAAE,kBAAkB,GACrC,aAAa,CAQf;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,kBAAkB,EAAE,GACxC,aAAa,EAAE,CAYjB"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { DOMAIN_BEACON_ATTESTER } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { computeSigningRoot, computeStartSlotAtEpoch, createAggregateSignatureSetFromComponents, } from "../util/index.js";
|
|
4
|
-
export function getAttestationDataSigningRoot(
|
|
5
|
-
const
|
|
6
|
-
const domain =
|
|
4
|
+
export function getAttestationDataSigningRoot(config, stateSlot, data) {
|
|
5
|
+
const messageSlot = computeStartSlotAtEpoch(data.target.epoch);
|
|
6
|
+
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_ATTESTER, messageSlot);
|
|
7
7
|
return computeSigningRoot(ssz.phase0.AttestationData, data, domain);
|
|
8
8
|
}
|
|
9
|
-
export function getAttestationWithIndicesSignatureSet(index2pubkey,
|
|
10
|
-
return createAggregateSignatureSetFromComponents(attestingIndices.map((i) => index2pubkey[i]), getAttestationDataSigningRoot(
|
|
9
|
+
export function getAttestationWithIndicesSignatureSet(config, index2pubkey, stateSlot, attestation, attestingIndices) {
|
|
10
|
+
return createAggregateSignatureSetFromComponents(attestingIndices.map((i) => index2pubkey[i]), getAttestationDataSigningRoot(config, stateSlot, attestation.data), attestation.signature);
|
|
11
11
|
}
|
|
12
|
-
export function getIndexedAttestationSignatureSet(index2pubkey,
|
|
13
|
-
return getAttestationWithIndicesSignatureSet(index2pubkey,
|
|
12
|
+
export function getIndexedAttestationSignatureSet(config, index2pubkey, stateSlot, indexedAttestation) {
|
|
13
|
+
return getAttestationWithIndicesSignatureSet(config, index2pubkey, stateSlot, indexedAttestation, indexedAttestation.attestingIndices);
|
|
14
14
|
}
|
|
15
|
-
export function getAttestationsSignatureSets(
|
|
15
|
+
export function getAttestationsSignatureSets(config, index2pubkey, signedBlock, indexedAttestations) {
|
|
16
16
|
if (indexedAttestations.length !== signedBlock.message.body.attestations.length) {
|
|
17
17
|
throw Error(`Indexed attestations length mismatch: got ${indexedAttestations.length}, expected ${signedBlock.message.body.attestations.length}`);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
20
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
21
|
+
const blockSlot = signedBlock.message.slot;
|
|
22
|
+
return indexedAttestations.map((indexedAttestation) => getIndexedAttestationSignatureSet(config, index2pubkey, blockSlot, indexedAttestation));
|
|
20
23
|
}
|
|
21
24
|
//# sourceMappingURL=indexedAttestation.js.map
|