@lodestar/state-transition 1.35.0-dev.98d359db41 → 1.35.0-dev.a70bac5bd3
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/README.md +1 -1
- package/lib/block/index.d.ts +2 -2
- package/lib/block/index.js +2 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/processAttestationPhase0.js +2 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts +1 -1
- package/lib/block/processAttestationsAltair.js +1 -1
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processBlsToExecutionChange.js.map +1 -1
- package/lib/block/processConsolidationRequest.js.map +1 -1
- package/lib/block/processDeposit.d.ts +2 -2
- package/lib/block/processDeposit.js +1 -1
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processSyncCommittee.js +2 -1
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processWithdrawalRequest.js.map +1 -1
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/block/slashValidator.js.map +1 -1
- package/lib/cache/epochCache.js +0 -130
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/epochTransitionCache.js.map +1 -1
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processSlashings.js.map +1 -1
- package/lib/index.d.ts +17 -17
- package/lib/index.js +16 -16
- package/lib/index.js.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/index.d.ts +1 -1
- package/lib/signatureSets/index.js +1 -1
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/slot/upgradeStateToDeneb.d.ts +2 -1
- package/lib/slot/upgradeStateToDeneb.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +2 -2
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/util/blindedBlock.js.map +1 -1
- package/lib/util/execution.js.map +1 -1
- package/lib/util/genesis.js +4 -4
- package/lib/util/genesis.js.map +1 -1
- package/lib/util/index.d.ts +5 -5
- package/lib/util/index.js +5 -5
- package/lib/util/index.js.map +1 -1
- package/lib/util/interop.js +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/rootCache.js +2 -5
- package/lib/util/rootCache.js.map +1 -1
- package/lib/util/seed.js +2 -1
- package/lib/util/seed.js.map +1 -1
- package/lib/util/weakSubjectivity.js.map +1 -1
- package/package.json +11 -13
- package/lib/block/externalData.d.ts.map +0 -1
- package/lib/block/index.d.ts.map +0 -1
- package/lib/block/initiateValidatorExit.d.ts.map +0 -1
- package/lib/block/isValidIndexedAttestation.d.ts.map +0 -1
- package/lib/block/processAttestationPhase0.d.ts.map +0 -1
- package/lib/block/processAttestations.d.ts.map +0 -1
- package/lib/block/processAttestationsAltair.d.ts.map +0 -1
- package/lib/block/processAttesterSlashing.d.ts.map +0 -1
- package/lib/block/processBlobKzgCommitments.d.ts.map +0 -1
- package/lib/block/processBlockHeader.d.ts.map +0 -1
- package/lib/block/processBlsToExecutionChange.d.ts.map +0 -1
- package/lib/block/processConsolidationRequest.d.ts.map +0 -1
- package/lib/block/processDeposit.d.ts.map +0 -1
- package/lib/block/processDepositRequest.d.ts.map +0 -1
- package/lib/block/processEth1Data.d.ts.map +0 -1
- package/lib/block/processExecutionPayload.d.ts.map +0 -1
- package/lib/block/processOperations.d.ts.map +0 -1
- package/lib/block/processProposerSlashing.d.ts.map +0 -1
- package/lib/block/processRandao.d.ts.map +0 -1
- package/lib/block/processSyncCommittee.d.ts.map +0 -1
- package/lib/block/processVoluntaryExit.d.ts.map +0 -1
- package/lib/block/processWithdrawalRequest.d.ts.map +0 -1
- package/lib/block/processWithdrawals.d.ts.map +0 -1
- package/lib/block/slashValidator.d.ts.map +0 -1
- package/lib/block/types.d.ts.map +0 -1
- package/lib/cache/effectiveBalanceIncrements.d.ts.map +0 -1
- package/lib/cache/epochCache.d.ts.map +0 -1
- package/lib/cache/epochTransitionCache.d.ts.map +0 -1
- package/lib/cache/pubkeyCache.d.ts.map +0 -1
- package/lib/cache/rewardCache.d.ts.map +0 -1
- package/lib/cache/stateCache.d.ts.map +0 -1
- package/lib/cache/syncCommitteeCache.d.ts.map +0 -1
- package/lib/cache/types.d.ts.map +0 -1
- package/lib/constants/constants.d.ts.map +0 -1
- package/lib/constants/index.d.ts.map +0 -1
- package/lib/epoch/computeUnrealizedCheckpoints.d.ts.map +0 -1
- package/lib/epoch/getAttestationDeltas.d.ts.map +0 -1
- package/lib/epoch/getRewardsAndPenalties.d.ts.map +0 -1
- package/lib/epoch/index.d.ts.map +0 -1
- package/lib/epoch/processEffectiveBalanceUpdates.d.ts.map +0 -1
- package/lib/epoch/processEth1DataReset.d.ts.map +0 -1
- package/lib/epoch/processHistoricalRootsUpdate.d.ts.map +0 -1
- package/lib/epoch/processHistoricalSummariesUpdate.d.ts.map +0 -1
- package/lib/epoch/processInactivityUpdates.d.ts.map +0 -1
- package/lib/epoch/processJustificationAndFinalization.d.ts.map +0 -1
- package/lib/epoch/processParticipationFlagUpdates.d.ts.map +0 -1
- package/lib/epoch/processParticipationRecordUpdates.d.ts.map +0 -1
- package/lib/epoch/processPendingAttestations.d.ts.map +0 -1
- package/lib/epoch/processPendingConsolidations.d.ts.map +0 -1
- package/lib/epoch/processPendingDeposits.d.ts.map +0 -1
- package/lib/epoch/processProposerLookahead.d.ts.map +0 -1
- package/lib/epoch/processRandaoMixesReset.d.ts.map +0 -1
- package/lib/epoch/processRegistryUpdates.d.ts.map +0 -1
- package/lib/epoch/processRewardsAndPenalties.d.ts.map +0 -1
- package/lib/epoch/processSlashings.d.ts.map +0 -1
- package/lib/epoch/processSlashingsReset.d.ts.map +0 -1
- package/lib/epoch/processSyncCommitteeUpdates.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/metrics.d.ts.map +0 -1
- package/lib/signatureSets/attesterSlashings.d.ts.map +0 -1
- package/lib/signatureSets/blsToExecutionChange.d.ts.map +0 -1
- package/lib/signatureSets/index.d.ts.map +0 -1
- package/lib/signatureSets/indexedAttestation.d.ts.map +0 -1
- package/lib/signatureSets/proposer.d.ts.map +0 -1
- package/lib/signatureSets/proposerSlashings.d.ts.map +0 -1
- package/lib/signatureSets/randao.d.ts.map +0 -1
- package/lib/signatureSets/voluntaryExits.d.ts.map +0 -1
- package/lib/slot/index.d.ts.map +0 -1
- package/lib/slot/upgradeStateToAltair.d.ts.map +0 -1
- package/lib/slot/upgradeStateToBellatrix.d.ts.map +0 -1
- package/lib/slot/upgradeStateToCapella.d.ts.map +0 -1
- package/lib/slot/upgradeStateToDeneb.d.ts.map +0 -1
- package/lib/slot/upgradeStateToElectra.d.ts.map +0 -1
- package/lib/slot/upgradeStateToFulu.d.ts.map +0 -1
- package/lib/slot/upgradeStateToGloas.d.ts.map +0 -1
- package/lib/stateTransition.d.ts.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/util/aggregator.d.ts.map +0 -1
- package/lib/util/altair.d.ts.map +0 -1
- package/lib/util/array.d.ts.map +0 -1
- package/lib/util/attestation.d.ts.map +0 -1
- package/lib/util/attesterStatus.d.ts.map +0 -1
- package/lib/util/balance.d.ts.map +0 -1
- package/lib/util/blindedBlock.d.ts.map +0 -1
- package/lib/util/blockRoot.d.ts.map +0 -1
- package/lib/util/calculateCommitteeAssignments.d.ts.map +0 -1
- package/lib/util/capella.d.ts.map +0 -1
- package/lib/util/computeAnchorCheckpoint.d.ts.map +0 -1
- package/lib/util/deposit.d.ts.map +0 -1
- package/lib/util/domain.d.ts.map +0 -1
- package/lib/util/electra.d.ts.map +0 -1
- package/lib/util/epoch.d.ts.map +0 -1
- package/lib/util/epochShuffling.d.ts.map +0 -1
- package/lib/util/execution.d.ts.map +0 -1
- package/lib/util/finality.d.ts.map +0 -1
- package/lib/util/fulu.d.ts.map +0 -1
- package/lib/util/genesis.d.ts.map +0 -1
- package/lib/util/index.d.ts.map +0 -1
- package/lib/util/interop.d.ts.map +0 -1
- package/lib/util/loadState/findModifiedInactivityScores.d.ts.map +0 -1
- package/lib/util/loadState/findModifiedValidators.d.ts.map +0 -1
- package/lib/util/loadState/index.d.ts.map +0 -1
- package/lib/util/loadState/loadState.d.ts.map +0 -1
- package/lib/util/loadState/loadValidator.d.ts.map +0 -1
- package/lib/util/rootCache.d.ts.map +0 -1
- package/lib/util/seed.d.ts.map +0 -1
- package/lib/util/shufflingDecisionRoot.d.ts.map +0 -1
- package/lib/util/signatureSets.d.ts.map +0 -1
- package/lib/util/signingRoot.d.ts.map +0 -1
- package/lib/util/slot.d.ts.map +0 -1
- package/lib/util/sszBytes.d.ts.map +0 -1
- package/lib/util/syncCommittee.d.ts.map +0 -1
- package/lib/util/targetUnslashedBalance.d.ts.map +0 -1
- package/lib/util/validator.d.ts.map +0 -1
- package/lib/util/weakSubjectivity.d.ts.map +0 -1
- package/src/block/externalData.ts +0 -26
- package/src/block/index.ts +0 -81
- package/src/block/initiateValidatorExit.ts +0 -62
- package/src/block/isValidIndexedAttestation.ts +0 -70
- package/src/block/processAttestationPhase0.ts +0 -158
- package/src/block/processAttestations.ts +0 -25
- package/src/block/processAttestationsAltair.ts +0 -184
- package/src/block/processAttesterSlashing.ts +0 -59
- package/src/block/processBlobKzgCommitments.ts +0 -21
- package/src/block/processBlockHeader.ts +0 -54
- package/src/block/processBlsToExecutionChange.ts +0 -78
- package/src/block/processConsolidationRequest.ts +0 -147
- package/src/block/processDeposit.ts +0 -166
- package/src/block/processDepositRequest.ts +0 -19
- package/src/block/processEth1Data.ts +0 -86
- package/src/block/processExecutionPayload.ts +0 -84
- package/src/block/processOperations.ts +0 -83
- package/src/block/processProposerSlashing.ts +0 -66
- package/src/block/processRandao.ts +0 -27
- package/src/block/processSyncCommittee.ts +0 -117
- package/src/block/processVoluntaryExit.ts +0 -55
- package/src/block/processWithdrawalRequest.ts +0 -98
- package/src/block/processWithdrawals.ts +0 -207
- package/src/block/slashValidator.ts +0 -98
- package/src/block/types.ts +0 -9
- package/src/cache/effectiveBalanceIncrements.ts +0 -39
- package/src/cache/epochCache.ts +0 -1213
- package/src/cache/epochTransitionCache.ts +0 -542
- package/src/cache/pubkeyCache.ts +0 -33
- package/src/cache/rewardCache.ts +0 -19
- package/src/cache/stateCache.ts +0 -268
- package/src/cache/syncCommitteeCache.ts +0 -96
- package/src/cache/types.ts +0 -18
- package/src/constants/constants.ts +0 -12
- package/src/constants/index.ts +0 -1
- package/src/epoch/computeUnrealizedCheckpoints.ts +0 -55
- package/src/epoch/getAttestationDeltas.ts +0 -169
- package/src/epoch/getRewardsAndPenalties.ts +0 -137
- package/src/epoch/index.ts +0 -202
- package/src/epoch/processEffectiveBalanceUpdates.ts +0 -111
- package/src/epoch/processEth1DataReset.ts +0 -17
- package/src/epoch/processHistoricalRootsUpdate.ts +0 -25
- package/src/epoch/processHistoricalSummariesUpdate.ts +0 -23
- package/src/epoch/processInactivityUpdates.ts +0 -60
- package/src/epoch/processJustificationAndFinalization.ts +0 -90
- package/src/epoch/processParticipationFlagUpdates.ts +0 -27
- package/src/epoch/processParticipationRecordUpdates.ts +0 -14
- package/src/epoch/processPendingAttestations.ts +0 -75
- package/src/epoch/processPendingConsolidations.ts +0 -59
- package/src/epoch/processPendingDeposits.ts +0 -136
- package/src/epoch/processProposerLookahead.ts +0 -39
- package/src/epoch/processRandaoMixesReset.ts +0 -18
- package/src/epoch/processRegistryUpdates.ts +0 -65
- package/src/epoch/processRewardsAndPenalties.ts +0 -58
- package/src/epoch/processSlashings.ts +0 -97
- package/src/epoch/processSlashingsReset.ts +0 -20
- package/src/epoch/processSyncCommitteeUpdates.ts +0 -44
- package/src/index.ts +0 -67
- package/src/metrics.ts +0 -169
- package/src/signatureSets/attesterSlashings.ts +0 -39
- package/src/signatureSets/blsToExecutionChange.ts +0 -43
- package/src/signatureSets/index.ts +0 -73
- package/src/signatureSets/indexedAttestation.ts +0 -51
- package/src/signatureSets/proposer.ts +0 -47
- package/src/signatureSets/proposerSlashings.ts +0 -41
- package/src/signatureSets/randao.ts +0 -31
- package/src/signatureSets/voluntaryExits.ts +0 -44
- package/src/slot/index.ts +0 -32
- package/src/slot/upgradeStateToAltair.ts +0 -149
- package/src/slot/upgradeStateToBellatrix.ts +0 -63
- package/src/slot/upgradeStateToCapella.ts +0 -71
- package/src/slot/upgradeStateToDeneb.ts +0 -40
- package/src/slot/upgradeStateToElectra.ts +0 -126
- package/src/slot/upgradeStateToFulu.ts +0 -31
- package/src/slot/upgradeStateToGloas.ts +0 -29
- package/src/stateTransition.ts +0 -305
- package/src/types.ts +0 -26
- package/src/util/aggregator.ts +0 -33
- package/src/util/altair.ts +0 -13
- package/src/util/array.ts +0 -53
- package/src/util/attestation.ts +0 -36
- package/src/util/attesterStatus.ts +0 -83
- package/src/util/balance.ts +0 -83
- package/src/util/blindedBlock.ts +0 -144
- package/src/util/blockRoot.ts +0 -72
- package/src/util/calculateCommitteeAssignments.ts +0 -43
- package/src/util/capella.ts +0 -8
- package/src/util/computeAnchorCheckpoint.ts +0 -38
- package/src/util/deposit.ts +0 -22
- package/src/util/domain.ts +0 -31
- package/src/util/electra.ts +0 -68
- package/src/util/epoch.ts +0 -135
- package/src/util/epochShuffling.ts +0 -185
- package/src/util/execution.ts +0 -177
- package/src/util/finality.ts +0 -17
- package/src/util/fulu.ts +0 -43
- package/src/util/genesis.ts +0 -343
- package/src/util/index.ts +0 -29
- package/src/util/interop.ts +0 -22
- package/src/util/loadState/findModifiedInactivityScores.ts +0 -47
- package/src/util/loadState/findModifiedValidators.ts +0 -46
- package/src/util/loadState/index.ts +0 -2
- package/src/util/loadState/loadState.ts +0 -225
- package/src/util/loadState/loadValidator.ts +0 -77
- package/src/util/rootCache.ts +0 -37
- package/src/util/seed.ts +0 -381
- package/src/util/shufflingDecisionRoot.ts +0 -78
- package/src/util/signatureSets.ts +0 -65
- package/src/util/signingRoot.ts +0 -13
- package/src/util/slot.ts +0 -27
- package/src/util/sszBytes.ts +0 -52
- package/src/util/syncCommittee.ts +0 -69
- package/src/util/targetUnslashedBalance.ts +0 -30
- package/src/util/validator.ts +0 -105
- package/src/util/weakSubjectivity.ts +0 -186
package/lib/util/seed.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/util/seed.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,OAAO,EAOR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,MAAM,aAAa,CAAC;AAG3E;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,aAAa,EAAE,WAAW,CAAA;CAAC,EACrD,0BAA0B,EAAE,0BAA0B,GACrD,MAAM,EAAE,CAeV;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,OAAO,EACb,0BAA0B,EAAE,0BAA0B,EACtD,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,EAClC,IAAI,EAAE,UAAU,GACf,cAAc,CAwChB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,EACb,0BAA0B,EAAE,0BAA0B,EACtD,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,UAAU,GACf,cAAc,CAwBhB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,yBAAyB,EAChC,SAAS,EAAE;IAAC,aAAa,EAAE,WAAW,CAAA;CAAC,EACvC,KAAK,EAAE,KAAK,GACX,cAAc,EAAE,CAgBlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,mBAAmB,EAC1B,sBAAsB,EAAE,SAAS,CAAC,cAAc,CAAC,EACjD,0BAA0B,EAAE,0BAA0B,GACrD,cAAc,EAAE,CAkDlB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,mBAAmB,EAC1B,sBAAsB,EAAE,WAAW,EACnC,0BAA0B,EAAE,0BAA0B,GACrD,WAAW,CAwBb;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAiB7F;AAED,KAAK,sBAAsB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAExD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,sBAAsB,CA8DnG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAE9E;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAIpG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shufflingDecisionRoot.d.ts","sourceRoot":"","sources":["../../src/util/shufflingDecisionRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAO,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAC;AAItD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI,GAAG,IAAI,CAM3F;AAWD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAMlH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signatureSets.d.ts","sourceRoot":"","sources":["../../src/util/signatureSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAyC,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAErC,oBAAY,gBAAgB;IAC1B,MAAM,WAAW;IACjB,SAAS,cAAc;CACxB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC;IACjC,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,WAAW,EAAE,IAAI,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;AAExE,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,aAAa,GAAG,OAAO,CAcvE;AAED,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,IAAI,EACjB,SAAS,EAAE,UAAU,GACpB,kBAAkB,CAOpB;AAED,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,SAAS,EAAE,EACpB,WAAW,EAAE,IAAI,EACjB,SAAS,EAAE,UAAU,GACpB,sBAAsB,CAOxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signingRoot.d.ts","sourceRoot":"","sources":["../../src/util/signingRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAC,MAAM,EAAc,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAM7F"}
|
package/lib/util/slot.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAGzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAGxF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAElF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAG3E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAExG;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAGvF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sszBytes.d.ts","sourceRoot":"","sources":["../../src/util/sszBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAQlD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAcxC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAGzF;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,GAAG,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,CAGrH;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAE7D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"syncCommittee.d.ts","sourceRoot":"","sources":["../../src/util/syncCommittee.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,OAAO,EAKR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAGhD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,mBAAmB,EAC1B,sBAAsB,EAAE,WAAW,EACnC,0BAA0B,EAAE,0BAA0B,GACrD;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAA;CAAC,CAgB7D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,4BAA4B,EAAE,MAAM,GAAG,MAAM,CAUzF;AAED;;;IAGI;AACJ,wBAAgB,6BAA6B,CAAC,2BAA2B,EAAE,MAAM,GAAG,MAAM,CAKzF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targetUnslashedBalance.d.ts","sourceRoot":"","sources":["../../src/util/targetUnslashedBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAM9C;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EAAE,EACvB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,GAC7B,MAAM,CAWR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/util/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAEL,OAAO,EAGR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAC,mBAAmB,EAAE,wBAAwB,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAGtF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAEpF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAEvF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,WAAW,CAW/F;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAKpH;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAE3F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,4BAA4B,EAAE,MAAM,EACpC,kBAAkB,EAAE,MAAM,EAC1B,qBAAqB,EAAE,MAAM,GAC5B,MAAM,CAQR;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAM1E;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAExE;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAEvE;AAED,wBAAgB,sBAAsB,CAAC,qBAAqB,EAAE,UAAU,GAAG,MAAM,CAMhF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAQnH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"weakSubjectivity.d.ts","sourceRoot":"","sources":["../../src/util/weakSubjectivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAQ/D,OAAO,EAAC,KAAK,EAAE,IAAI,EAAM,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAGlD,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,MAAM,aAAa,CAAC;AAU3E,eAAO,MAAM,WAAW,QAAU,CAAC;AAGnC;;;GAGG;AACH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,yBAAyB,GAC/B,KAAK,CAEP;AAED;;;;;;;GAOG;AACH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,yBAAyB,GAC/B,MAAM,CAgBR;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,mBAAmB,GAAG,MAAM,CA6BzG;AAED,wBAAgB,mDAAmD,CACjE,oBAAoB,EAAE,MAAM,EAC5B,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,EAClB,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAuBR;AAED,wBAAgB,oDAAoD,CAClE,uBAAuB,EAAE,MAAM,EAE/B,iBAAiB,EAAE,MAAM,EACzB,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAOR;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAMnE;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,EAC5B,YAAY,EAAE,UAAU,GACvB,OAAO,CAOT;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,EAC5B,YAAY,EAAE,UAAU,GACvB,IAAI,CAgBN"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Should emulate the return value of `ExecutionEngine.notifyNewPayload()`, such that:
|
|
3
|
-
*
|
|
4
|
-
* Returns ``True`` iff ``execution_payload`` is valid with respect to ``self.execution_state``.
|
|
5
|
-
*
|
|
6
|
-
* Note: `processExecutionPayload()` depends on process_randao function call as it retrieves the most recent randao
|
|
7
|
-
* mix from the state. Implementations that are considering parallel processing of execution payload with respect to
|
|
8
|
-
* beacon chain state transition function should work around this dependency.
|
|
9
|
-
*/
|
|
10
|
-
export enum ExecutionPayloadStatus {
|
|
11
|
-
preMerge = "preMerge",
|
|
12
|
-
invalid = "invalid",
|
|
13
|
-
valid = "valid",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export enum DataAvailabilityStatus {
|
|
17
|
-
PreData = "PreData",
|
|
18
|
-
/* validator activities can't be performed on out of range data */
|
|
19
|
-
OutOfRange = "OutOfRange",
|
|
20
|
-
Available = "Available",
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface BlockExternalData {
|
|
24
|
-
executionPayloadStatus: ExecutionPayloadStatus;
|
|
25
|
-
dataAvailabilityStatus: DataAvailabilityStatus;
|
|
26
|
-
}
|
package/src/block/index.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {ForkSeq} from "@lodestar/params";
|
|
2
|
-
import {BeaconBlock, BlindedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
3
|
-
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
4
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js";
|
|
5
|
-
import {getFullOrBlindedPayload, isExecutionEnabled} from "../util/execution.js";
|
|
6
|
-
import {BlockExternalData, DataAvailabilityStatus} from "./externalData.js";
|
|
7
|
-
import {processBlobKzgCommitments} from "./processBlobKzgCommitments.js";
|
|
8
|
-
import {processBlockHeader} from "./processBlockHeader.js";
|
|
9
|
-
import {processEth1Data} from "./processEth1Data.js";
|
|
10
|
-
import {processExecutionPayload} from "./processExecutionPayload.js";
|
|
11
|
-
import {processOperations} from "./processOperations.js";
|
|
12
|
-
import {processRandao} from "./processRandao.js";
|
|
13
|
-
import {processSyncAggregate} from "./processSyncCommittee.js";
|
|
14
|
-
import {processWithdrawals} from "./processWithdrawals.js";
|
|
15
|
-
import {ProcessBlockOpts, ProposerRewardType} from "./types.js";
|
|
16
|
-
|
|
17
|
-
// Spec tests
|
|
18
|
-
export {
|
|
19
|
-
processBlockHeader,
|
|
20
|
-
processExecutionPayload,
|
|
21
|
-
processRandao,
|
|
22
|
-
processEth1Data,
|
|
23
|
-
processSyncAggregate,
|
|
24
|
-
processWithdrawals,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export * from "./externalData.js";
|
|
28
|
-
export * from "./initiateValidatorExit.js";
|
|
29
|
-
export * from "./isValidIndexedAttestation.js";
|
|
30
|
-
export * from "./processOperations.js";
|
|
31
|
-
|
|
32
|
-
export function processBlock(
|
|
33
|
-
fork: ForkSeq,
|
|
34
|
-
state: CachedBeaconStateAllForks,
|
|
35
|
-
block: BeaconBlock | BlindedBeaconBlock,
|
|
36
|
-
externalData: BlockExternalData & ProcessBlockOpts,
|
|
37
|
-
opts?: ProcessBlockOpts,
|
|
38
|
-
metrics?: BeaconStateTransitionMetrics | null
|
|
39
|
-
): void {
|
|
40
|
-
const {verifySignatures = true} = opts ?? {};
|
|
41
|
-
|
|
42
|
-
processBlockHeader(state, block);
|
|
43
|
-
|
|
44
|
-
// The call to the process_execution_payload must happen before the call to the process_randao as the former depends
|
|
45
|
-
// on the randao_mix computed with the reveal of the previous block.
|
|
46
|
-
if (fork >= ForkSeq.bellatrix && isExecutionEnabled(state as CachedBeaconStateBellatrix, block)) {
|
|
47
|
-
const fullOrBlindedPayload = getFullOrBlindedPayload(block);
|
|
48
|
-
// TODO Deneb: Allow to disable withdrawals for interop testing
|
|
49
|
-
// https://github.com/ethereum/consensus-specs/blob/b62c9e877990242d63aa17a2a59a49bc649a2f2e/specs/eip4844/beacon-chain.md#disabling-withdrawals
|
|
50
|
-
if (fork >= ForkSeq.capella) {
|
|
51
|
-
processWithdrawals(
|
|
52
|
-
fork,
|
|
53
|
-
state as CachedBeaconStateCapella,
|
|
54
|
-
fullOrBlindedPayload as capella.FullOrBlindedExecutionPayload
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
processExecutionPayload(fork, state as CachedBeaconStateBellatrix, block.body, externalData);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
processRandao(state, block, verifySignatures);
|
|
62
|
-
processEth1Data(state, block.body.eth1Data);
|
|
63
|
-
processOperations(fork, state, block.body, opts, metrics);
|
|
64
|
-
if (fork >= ForkSeq.altair) {
|
|
65
|
-
processSyncAggregate(state, block as altair.BeaconBlock, verifySignatures);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (fork >= ForkSeq.deneb) {
|
|
69
|
-
processBlobKzgCommitments(externalData);
|
|
70
|
-
// Only throw PreData so beacon can also sync/process blocks optimistically
|
|
71
|
-
// and let forkChoice handle it
|
|
72
|
-
if (externalData.dataAvailabilityStatus === DataAvailabilityStatus.PreData) {
|
|
73
|
-
throw Error("dataAvailabilityStatus.PreData");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const rewards = state.proposerRewards;
|
|
78
|
-
metrics?.proposerRewards.set({type: ProposerRewardType.attestation}, rewards.attestations);
|
|
79
|
-
metrics?.proposerRewards.set({type: ProposerRewardType.syncAggregate}, rewards.syncAggregate);
|
|
80
|
-
metrics?.proposerRewards.set({type: ProposerRewardType.slashing}, rewards.slashing);
|
|
81
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {CompositeViewDU} from "@chainsafe/ssz";
|
|
2
|
-
import {FAR_FUTURE_EPOCH, ForkSeq} from "@lodestar/params";
|
|
3
|
-
import {ssz} from "@lodestar/types";
|
|
4
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateElectra} from "../types.js";
|
|
5
|
-
import {computeExitEpochAndUpdateChurn} from "../util/epoch.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Initiate the exit of the validator with index ``index``.
|
|
9
|
-
*
|
|
10
|
-
* NOTE: This function takes a `validator` as argument instead of the validator index.
|
|
11
|
-
* SSZ TreeViews have a dangerous edge case that may break the code here in a non-obvious way.
|
|
12
|
-
* When running `state.validators[i]` you get a SubTree of that validator with a hook to the state.
|
|
13
|
-
* Then, when a property of `validator` is set it propagates the changes upwards to the parent tree up to the state.
|
|
14
|
-
* This means that `validator` will propagate its new state along with the current state of its parent tree up to
|
|
15
|
-
* the state, potentially overwriting changes done in other SubTrees before.
|
|
16
|
-
* ```ts
|
|
17
|
-
* // default state.validators, all zeroes
|
|
18
|
-
* const validatorsA = state.validators
|
|
19
|
-
* const validatorsB = state.validators
|
|
20
|
-
* validatorsA[0].exitEpoch = 9
|
|
21
|
-
* validatorsB[0].exitEpoch = 9 // Setting a value in validatorsB will overwrite all changes from validatorsA
|
|
22
|
-
* // validatorsA[0].exitEpoch is 0
|
|
23
|
-
* // validatorsB[0].exitEpoch is 9
|
|
24
|
-
* ```
|
|
25
|
-
* Forcing consumers to pass the SubTree of `validator` directly mitigates this issue.
|
|
26
|
-
*/
|
|
27
|
-
export function initiateValidatorExit(
|
|
28
|
-
fork: ForkSeq,
|
|
29
|
-
state: CachedBeaconStateAllForks,
|
|
30
|
-
validator: CompositeViewDU<typeof ssz.phase0.Validator>
|
|
31
|
-
): void {
|
|
32
|
-
const {config, epochCtx} = state;
|
|
33
|
-
|
|
34
|
-
// return if validator already initiated exit
|
|
35
|
-
if (validator.exitEpoch !== FAR_FUTURE_EPOCH) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (fork < ForkSeq.electra) {
|
|
40
|
-
// Limits the number of validators that can exit on each epoch.
|
|
41
|
-
// Expects all state.validators to follow this rule, i.e. no validator.exitEpoch is greater than exitQueueEpoch.
|
|
42
|
-
// If there the churnLimit is reached at this current exitQueueEpoch, advance epoch and reset churn.
|
|
43
|
-
if (epochCtx.exitQueueChurn >= epochCtx.churnLimit) {
|
|
44
|
-
epochCtx.exitQueueEpoch += 1;
|
|
45
|
-
epochCtx.exitQueueChurn = 1; // = 1 to account for this validator with exitQueueEpoch
|
|
46
|
-
} else {
|
|
47
|
-
// Add this validator to the current exitQueueEpoch churn
|
|
48
|
-
epochCtx.exitQueueChurn += 1;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// set validator exit epoch
|
|
52
|
-
validator.exitEpoch = epochCtx.exitQueueEpoch;
|
|
53
|
-
} else {
|
|
54
|
-
// set validator exit epoch
|
|
55
|
-
// Note we don't use epochCtx.exitQueueChurn and exitQueueEpoch anymore
|
|
56
|
-
validator.exitEpoch = computeExitEpochAndUpdateChurn(
|
|
57
|
-
state as CachedBeaconStateElectra,
|
|
58
|
-
BigInt(validator.effectiveBalance)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
validator.withdrawableEpoch = validator.exitEpoch + config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY;
|
|
62
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {ForkSeq, MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params";
|
|
2
|
-
import {IndexedAttestation, IndexedAttestationBigint} from "@lodestar/types";
|
|
3
|
-
import {getIndexedAttestationBigintSignatureSet, getIndexedAttestationSignatureSet} from "../signatureSets/index.js";
|
|
4
|
-
import {CachedBeaconStateAllForks} from "../types.js";
|
|
5
|
-
import {verifySignatureSet} from "../util/index.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Check if `indexedAttestation` has sorted and unique indices and a valid aggregate signature.
|
|
9
|
-
*/
|
|
10
|
-
export function isValidIndexedAttestation(
|
|
11
|
-
state: CachedBeaconStateAllForks,
|
|
12
|
-
indexedAttestation: IndexedAttestation,
|
|
13
|
-
verifySignature: boolean
|
|
14
|
-
): boolean {
|
|
15
|
-
if (!isValidIndexedAttestationIndices(state, indexedAttestation.attestingIndices)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (verifySignature) {
|
|
20
|
-
return verifySignatureSet(getIndexedAttestationSignatureSet(state, indexedAttestation));
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isValidIndexedAttestationBigint(
|
|
26
|
-
state: CachedBeaconStateAllForks,
|
|
27
|
-
indexedAttestation: IndexedAttestationBigint,
|
|
28
|
-
verifySignature: boolean
|
|
29
|
-
): boolean {
|
|
30
|
-
if (!isValidIndexedAttestationIndices(state, indexedAttestation.attestingIndices)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (verifySignature) {
|
|
35
|
-
return verifySignatureSet(getIndexedAttestationBigintSignatureSet(state, indexedAttestation));
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Check if `indexedAttestation` has sorted and unique indices and a valid aggregate signature.
|
|
42
|
-
*/
|
|
43
|
-
export function isValidIndexedAttestationIndices(state: CachedBeaconStateAllForks, indices: number[]): boolean {
|
|
44
|
-
// verify max number of indices
|
|
45
|
-
const maxIndices =
|
|
46
|
-
state.config.getForkSeq(state.slot) >= ForkSeq.electra
|
|
47
|
-
? MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT
|
|
48
|
-
: MAX_VALIDATORS_PER_COMMITTEE;
|
|
49
|
-
if (!(indices.length > 0 && indices.length <= maxIndices)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// verify indices are sorted and unique.
|
|
54
|
-
// Just check if they are monotonically increasing,
|
|
55
|
-
// instead of creating a set and sorting it. Should be (O(n)) instead of O(n log(n))
|
|
56
|
-
let prev = -1;
|
|
57
|
-
for (const index of indices) {
|
|
58
|
-
if (index <= prev) return false;
|
|
59
|
-
prev = index;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// check if indices are out of bounds, by checking the highest index (since it is sorted)
|
|
63
|
-
// TODO - SLOW CODE - Does this .length check the tree and is expensive?
|
|
64
|
-
const lastIndex = indices.at(-1);
|
|
65
|
-
if (lastIndex && lastIndex >= state.validators.length) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
-
import {Attestation, Slot, electra, phase0, ssz} from "@lodestar/types";
|
|
3
|
-
import {assert, toRootHex} from "@lodestar/utils";
|
|
4
|
-
import {CachedBeaconStateAllForks, CachedBeaconStatePhase0} from "../types.js";
|
|
5
|
-
import {computeEndSlotAtEpoch, computeEpochAtSlot} from "../util/index.js";
|
|
6
|
-
import {isValidIndexedAttestation} from "./index.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Process an Attestation operation. Validates an attestation and appends it to state.currentEpochAttestations or
|
|
10
|
-
* state.previousEpochAttestations to be processed in bulk at the epoch transition.
|
|
11
|
-
*
|
|
12
|
-
* PERF: Work depends on number of Attestation per block. On mainnet the average is 89.7 / block, with 87.8 participant
|
|
13
|
-
* true bits on average. See `packages/state-transition/test/perf/analyzeBlocks.ts`
|
|
14
|
-
*/
|
|
15
|
-
export function processAttestationPhase0(
|
|
16
|
-
state: CachedBeaconStatePhase0,
|
|
17
|
-
attestation: phase0.Attestation,
|
|
18
|
-
verifySignature = true
|
|
19
|
-
): void {
|
|
20
|
-
const {epochCtx} = state;
|
|
21
|
-
const slot = state.slot;
|
|
22
|
-
const data = attestation.data;
|
|
23
|
-
|
|
24
|
-
validateAttestation(ForkSeq.phase0, state, attestation);
|
|
25
|
-
|
|
26
|
-
const pendingAttestation = ssz.phase0.PendingAttestation.toViewDU({
|
|
27
|
-
data: data,
|
|
28
|
-
aggregationBits: attestation.aggregationBits,
|
|
29
|
-
inclusionDelay: slot - data.slot,
|
|
30
|
-
proposerIndex: epochCtx.getBeaconProposer(slot),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (data.target.epoch === epochCtx.epoch) {
|
|
34
|
-
if (!ssz.phase0.Checkpoint.equals(data.source, state.currentJustifiedCheckpoint)) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Attestation source does not equal current justified checkpoint: source=${checkpointToStr(
|
|
37
|
-
data.source
|
|
38
|
-
)} currentJustifiedCheckpoint=${checkpointToStr(state.currentJustifiedCheckpoint)}`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
state.currentEpochAttestations.push(pendingAttestation);
|
|
42
|
-
} else {
|
|
43
|
-
if (!ssz.phase0.Checkpoint.equals(data.source, state.previousJustifiedCheckpoint)) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Attestation source does not equal previous justified checkpoint: source=${checkpointToStr(
|
|
46
|
-
data.source
|
|
47
|
-
)} previousJustifiedCheckpoint=${checkpointToStr(state.previousJustifiedCheckpoint)}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
state.previousEpochAttestations.push(pendingAttestation);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!isValidIndexedAttestation(state, epochCtx.getIndexedAttestation(ForkSeq.phase0, attestation), verifySignature)) {
|
|
54
|
-
throw new Error("Attestation is not valid");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function validateAttestation(fork: ForkSeq, state: CachedBeaconStateAllForks, attestation: Attestation): void {
|
|
59
|
-
const {epochCtx} = state;
|
|
60
|
-
const slot = state.slot;
|
|
61
|
-
const data = attestation.data;
|
|
62
|
-
const computedEpoch = computeEpochAtSlot(data.slot);
|
|
63
|
-
const committeeCount = epochCtx.getCommitteeCountPerSlot(computedEpoch);
|
|
64
|
-
|
|
65
|
-
if (!(data.target.epoch === epochCtx.previousShuffling.epoch || data.target.epoch === epochCtx.epoch)) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
"Attestation target epoch not in previous or current epoch: " +
|
|
68
|
-
`targetEpoch=${data.target.epoch} currentEpoch=${epochCtx.epoch}`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
if (!(data.target.epoch === computedEpoch)) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
"Attestation target epoch does not match epoch computed from slot: " +
|
|
74
|
-
`targetEpoch=${data.target.epoch} computedEpoch=${computedEpoch}`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// post deneb, the attestations are valid till end of next epoch
|
|
79
|
-
if (!(data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= slot && isTimelyTarget(fork, slot - data.slot))) {
|
|
80
|
-
const windowStart = data.slot + MIN_ATTESTATION_INCLUSION_DELAY;
|
|
81
|
-
const windowEnd = fork >= ForkSeq.deneb ? computeEndSlotAtEpoch(computedEpoch + 1) : data.slot + SLOTS_PER_EPOCH;
|
|
82
|
-
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Attestation slot not within inclusion window: slot=${data.slot} window=${windowStart}..${windowEnd}`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (fork >= ForkSeq.electra) {
|
|
89
|
-
assert.equal(data.index, 0, `AttestationData.index must be zero: index=${data.index}`);
|
|
90
|
-
const attestationElectra = attestation as electra.Attestation;
|
|
91
|
-
const committeeIndices = attestationElectra.committeeBits.getTrueBitIndexes();
|
|
92
|
-
|
|
93
|
-
const lastCommitteeIndex = committeeIndices.at(-1);
|
|
94
|
-
if (lastCommitteeIndex === undefined) {
|
|
95
|
-
throw Error("Attestation should have at least one committee bit set");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (lastCommitteeIndex >= committeeCount) {
|
|
99
|
-
throw new Error(
|
|
100
|
-
`Attestation committee index exceeds committee count: lastCommitteeIndex=${lastCommitteeIndex} numCommittees=${committeeCount}`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const validatorsByCommittee = epochCtx.getBeaconCommittees(data.slot, committeeIndices);
|
|
105
|
-
const aggregationBitsArray = attestationElectra.aggregationBits.toBoolArray();
|
|
106
|
-
|
|
107
|
-
// Total number of attestation participants of every committee specified
|
|
108
|
-
let committeeOffset = 0;
|
|
109
|
-
for (const committeeValidators of validatorsByCommittee) {
|
|
110
|
-
const committeeAggregationBits = aggregationBitsArray.slice(
|
|
111
|
-
committeeOffset,
|
|
112
|
-
committeeOffset + committeeValidators.length
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Assert aggregation bits in this committee have at least one true bit
|
|
116
|
-
if (committeeAggregationBits.every((bit) => !bit)) {
|
|
117
|
-
throw new Error("Every committee in aggregation bits must have at least one attester");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
committeeOffset += committeeValidators.length;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Bitfield length matches total number of participants
|
|
124
|
-
assert.equal(
|
|
125
|
-
attestationElectra.aggregationBits.bitLen,
|
|
126
|
-
committeeOffset,
|
|
127
|
-
`Attestation aggregation bits length does not match total number of committee participants aggregationBitsLength=${attestation.aggregationBits.bitLen} participantCount=${committeeOffset}`
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
if (!(data.index < committeeCount)) {
|
|
131
|
-
throw new Error(
|
|
132
|
-
"Attestation committee index not within current committee count: " +
|
|
133
|
-
`committeeIndex=${data.index} committeeCount=${committeeCount}`
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const committee = epochCtx.getBeaconCommittee(data.slot, data.index);
|
|
138
|
-
if (attestation.aggregationBits.bitLen !== committee.length) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
"Attestation aggregation bits length does not match committee length: " +
|
|
141
|
-
`aggregationBitsLength=${attestation.aggregationBits.bitLen} committeeLength=${committee.length}`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Modified https://github.com/ethereum/consensus-specs/pull/3360
|
|
148
|
-
export function isTimelyTarget(fork: ForkSeq, inclusionDistance: Slot): boolean {
|
|
149
|
-
// post deneb attestation is valid till end of next epoch for target
|
|
150
|
-
if (fork >= ForkSeq.deneb) {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
return inclusionDistance <= SLOTS_PER_EPOCH;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function checkpointToStr(checkpoint: phase0.Checkpoint): string {
|
|
157
|
-
return `${toRootHex(checkpoint.root)}:${checkpoint.epoch}`;
|
|
158
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {ForkSeq} from "@lodestar/params";
|
|
2
|
-
import {Attestation} from "@lodestar/types";
|
|
3
|
-
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
4
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js";
|
|
5
|
-
import {processAttestationPhase0} from "./processAttestationPhase0.js";
|
|
6
|
-
import {processAttestationsAltair} from "./processAttestationsAltair.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TODO
|
|
10
|
-
*/
|
|
11
|
-
export function processAttestations(
|
|
12
|
-
fork: ForkSeq,
|
|
13
|
-
state: CachedBeaconStateAllForks,
|
|
14
|
-
attestations: Attestation[],
|
|
15
|
-
verifySignatures = true,
|
|
16
|
-
metrics?: BeaconStateTransitionMetrics | null
|
|
17
|
-
): void {
|
|
18
|
-
if (fork === ForkSeq.phase0) {
|
|
19
|
-
for (const attestation of attestations) {
|
|
20
|
-
processAttestationPhase0(state as CachedBeaconStatePhase0, attestation, verifySignatures);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
processAttestationsAltair(fork, state as CachedBeaconStateAltair, attestations, verifySignatures, metrics);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import {byteArrayEquals} from "@chainsafe/ssz";
|
|
2
|
-
import {
|
|
3
|
-
ForkSeq,
|
|
4
|
-
MIN_ATTESTATION_INCLUSION_DELAY,
|
|
5
|
-
PROPOSER_WEIGHT,
|
|
6
|
-
SLOTS_PER_EPOCH,
|
|
7
|
-
TIMELY_HEAD_FLAG_INDEX,
|
|
8
|
-
TIMELY_HEAD_WEIGHT,
|
|
9
|
-
TIMELY_SOURCE_FLAG_INDEX,
|
|
10
|
-
TIMELY_SOURCE_WEIGHT,
|
|
11
|
-
TIMELY_TARGET_FLAG_INDEX,
|
|
12
|
-
TIMELY_TARGET_WEIGHT,
|
|
13
|
-
WEIGHT_DENOMINATOR,
|
|
14
|
-
} from "@lodestar/params";
|
|
15
|
-
import {Attestation, Epoch, phase0} from "@lodestar/types";
|
|
16
|
-
import {intSqrt} from "@lodestar/utils";
|
|
17
|
-
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
18
|
-
import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js";
|
|
19
|
-
import {CachedBeaconStateAltair} from "../types.js";
|
|
20
|
-
import {increaseBalance, verifySignatureSet} from "../util/index.js";
|
|
21
|
-
import {RootCache} from "../util/rootCache.js";
|
|
22
|
-
import {checkpointToStr, isTimelyTarget, validateAttestation} from "./processAttestationPhase0.js";
|
|
23
|
-
|
|
24
|
-
const PROPOSER_REWARD_DOMINATOR = ((WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR) / PROPOSER_WEIGHT;
|
|
25
|
-
|
|
26
|
-
/** Same to https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.5/specs/altair/beacon-chain.md#has_flag */
|
|
27
|
-
const TIMELY_SOURCE = 1 << TIMELY_SOURCE_FLAG_INDEX;
|
|
28
|
-
const TIMELY_TARGET = 1 << TIMELY_TARGET_FLAG_INDEX;
|
|
29
|
-
const TIMELY_HEAD = 1 << TIMELY_HEAD_FLAG_INDEX;
|
|
30
|
-
const SLOTS_PER_EPOCH_SQRT = intSqrt(SLOTS_PER_EPOCH);
|
|
31
|
-
|
|
32
|
-
export function processAttestationsAltair(
|
|
33
|
-
fork: ForkSeq,
|
|
34
|
-
state: CachedBeaconStateAltair,
|
|
35
|
-
attestations: Attestation[],
|
|
36
|
-
verifySignature = true,
|
|
37
|
-
metrics?: BeaconStateTransitionMetrics | null
|
|
38
|
-
): void {
|
|
39
|
-
const {epochCtx} = state;
|
|
40
|
-
const {effectiveBalanceIncrements} = epochCtx;
|
|
41
|
-
const stateSlot = state.slot;
|
|
42
|
-
const rootCache = new RootCache(state);
|
|
43
|
-
const currentEpoch = epochCtx.epoch;
|
|
44
|
-
|
|
45
|
-
// Process all attestations first and then increase the balance of the proposer once
|
|
46
|
-
let proposerReward = 0;
|
|
47
|
-
let newSeenAttesters = 0;
|
|
48
|
-
let newSeenAttestersEffectiveBalance = 0;
|
|
49
|
-
for (const attestation of attestations) {
|
|
50
|
-
const data = attestation.data;
|
|
51
|
-
|
|
52
|
-
validateAttestation(fork, state, attestation);
|
|
53
|
-
|
|
54
|
-
// Retrieve the validator indices from the attestation participation bitfield
|
|
55
|
-
const attestingIndices = epochCtx.getAttestingIndices(fork, attestation);
|
|
56
|
-
|
|
57
|
-
// this check is done last because its the most expensive (if signature verification is toggled on)
|
|
58
|
-
// TODO: Why should we verify an indexed attestation that we just created? If it's just for the signature
|
|
59
|
-
// we can verify only that and nothing else.
|
|
60
|
-
if (verifySignature) {
|
|
61
|
-
const sigSet = getAttestationWithIndicesSignatureSet(state, attestation, attestingIndices);
|
|
62
|
-
if (!verifySignatureSet(sigSet)) {
|
|
63
|
-
throw new Error("Attestation signature is not valid");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const inCurrentEpoch = data.target.epoch === currentEpoch;
|
|
68
|
-
const epochParticipation = inCurrentEpoch ? state.currentEpochParticipation : state.previousEpochParticipation;
|
|
69
|
-
|
|
70
|
-
const flagsAttestation = getAttestationParticipationStatus(
|
|
71
|
-
fork,
|
|
72
|
-
data,
|
|
73
|
-
stateSlot - data.slot,
|
|
74
|
-
epochCtx.epoch,
|
|
75
|
-
rootCache
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
// For each participant, update their participation
|
|
79
|
-
// In epoch processing, this participation info is used to calculate balance updates
|
|
80
|
-
let totalBalanceIncrementsWithWeight = 0;
|
|
81
|
-
const validators = state.validators;
|
|
82
|
-
for (const validatorIndex of attestingIndices) {
|
|
83
|
-
const flags = epochParticipation.get(validatorIndex);
|
|
84
|
-
|
|
85
|
-
// For normal block, > 90% of attestations belong to current epoch
|
|
86
|
-
// At epoch boundary, 100% of attestations belong to previous epoch
|
|
87
|
-
// so we want to update the participation flag tree in batch
|
|
88
|
-
|
|
89
|
-
// Note ParticipationFlags type uses option {setBitwiseOR: true}, .set() does a |= operation
|
|
90
|
-
epochParticipation.set(validatorIndex, flagsAttestation);
|
|
91
|
-
// epochParticipation.setStatus(index, newStatus);
|
|
92
|
-
|
|
93
|
-
// Returns flags that are NOT set before (~ bitwise NOT) AND are set after
|
|
94
|
-
const flagsNewSet = ~flags & flagsAttestation;
|
|
95
|
-
if (flagsNewSet !== 0) {
|
|
96
|
-
newSeenAttesters++;
|
|
97
|
-
newSeenAttestersEffectiveBalance += effectiveBalanceIncrements[validatorIndex];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Spec:
|
|
101
|
-
// baseReward = state.validators[index].effectiveBalance / EFFECTIVE_BALANCE_INCREMENT * baseRewardPerIncrement;
|
|
102
|
-
// proposerRewardNumerator += baseReward * totalWeight
|
|
103
|
-
let totalWeight = 0;
|
|
104
|
-
if ((flagsNewSet & TIMELY_SOURCE) === TIMELY_SOURCE) totalWeight += TIMELY_SOURCE_WEIGHT;
|
|
105
|
-
if ((flagsNewSet & TIMELY_TARGET) === TIMELY_TARGET) totalWeight += TIMELY_TARGET_WEIGHT;
|
|
106
|
-
if ((flagsNewSet & TIMELY_HEAD) === TIMELY_HEAD) totalWeight += TIMELY_HEAD_WEIGHT;
|
|
107
|
-
|
|
108
|
-
if (totalWeight > 0) {
|
|
109
|
-
totalBalanceIncrementsWithWeight += effectiveBalanceIncrements[validatorIndex] * totalWeight;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// TODO: describe issue. Compute progressive target balances
|
|
113
|
-
// When processing each attestation, increase the cummulative target balance. Only applies post-altair
|
|
114
|
-
if ((flagsNewSet & TIMELY_TARGET) === TIMELY_TARGET) {
|
|
115
|
-
const validator = validators.getReadonly(validatorIndex);
|
|
116
|
-
if (!validator.slashed) {
|
|
117
|
-
if (inCurrentEpoch) {
|
|
118
|
-
epochCtx.currentTargetUnslashedBalanceIncrements += effectiveBalanceIncrements[validatorIndex];
|
|
119
|
-
} else {
|
|
120
|
-
epochCtx.previousTargetUnslashedBalanceIncrements += effectiveBalanceIncrements[validatorIndex];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Do the discrete math inside the loop to ensure a deterministic result
|
|
127
|
-
const totalIncrements = totalBalanceIncrementsWithWeight;
|
|
128
|
-
const proposerRewardNumerator = totalIncrements * state.epochCtx.baseRewardPerIncrement;
|
|
129
|
-
proposerReward += Math.floor(proposerRewardNumerator / PROPOSER_REWARD_DOMINATOR);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
metrics?.newSeenAttestersPerBlock.set(newSeenAttesters);
|
|
133
|
-
metrics?.newSeenAttestersEffectiveBalancePerBlock.set(newSeenAttestersEffectiveBalance);
|
|
134
|
-
metrics?.attestationsPerBlock.set(attestations.length);
|
|
135
|
-
|
|
136
|
-
increaseBalance(state, epochCtx.getBeaconProposer(state.slot), proposerReward);
|
|
137
|
-
state.proposerRewards.attestations = proposerReward;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices
|
|
142
|
-
*/
|
|
143
|
-
export function getAttestationParticipationStatus(
|
|
144
|
-
fork: ForkSeq,
|
|
145
|
-
data: phase0.AttestationData,
|
|
146
|
-
inclusionDelay: number,
|
|
147
|
-
currentEpoch: Epoch,
|
|
148
|
-
rootCache: RootCache
|
|
149
|
-
): number {
|
|
150
|
-
const justifiedCheckpoint =
|
|
151
|
-
data.target.epoch === currentEpoch ? rootCache.currentJustifiedCheckpoint : rootCache.previousJustifiedCheckpoint;
|
|
152
|
-
|
|
153
|
-
// The source and target votes are part of the FFG vote, the head vote is part of the fork choice vote
|
|
154
|
-
// Both are tracked to properly incentivise validators
|
|
155
|
-
//
|
|
156
|
-
// The source vote always matches the justified checkpoint (else its invalid)
|
|
157
|
-
// The target vote should match the most recent checkpoint (eg: the first root of the epoch)
|
|
158
|
-
// The head vote should match the root at the attestation slot (eg: the root at data.slot)
|
|
159
|
-
const isMatchingSource = checkpointValueEquals(data.source, justifiedCheckpoint);
|
|
160
|
-
if (!isMatchingSource) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`Attestation source does not equal justified checkpoint: source=${checkpointToStr(
|
|
163
|
-
data.source
|
|
164
|
-
)} justifiedCheckpoint=${checkpointToStr(justifiedCheckpoint)}`
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const isMatchingTarget = byteArrayEquals(data.target.root, rootCache.getBlockRoot(data.target.epoch));
|
|
169
|
-
|
|
170
|
-
// a timely head is only be set if the target is _also_ matching
|
|
171
|
-
const isMatchingHead =
|
|
172
|
-
isMatchingTarget && byteArrayEquals(data.beaconBlockRoot, rootCache.getBlockRootAtSlot(data.slot));
|
|
173
|
-
|
|
174
|
-
let flags = 0;
|
|
175
|
-
if (isMatchingSource && inclusionDelay <= SLOTS_PER_EPOCH_SQRT) flags |= TIMELY_SOURCE;
|
|
176
|
-
if (isMatchingTarget && isTimelyTarget(fork, inclusionDelay)) flags |= TIMELY_TARGET;
|
|
177
|
-
if (isMatchingHead && inclusionDelay === MIN_ATTESTATION_INCLUSION_DELAY) flags |= TIMELY_HEAD;
|
|
178
|
-
|
|
179
|
-
return flags;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export function checkpointValueEquals(cp1: phase0.Checkpoint, cp2: phase0.Checkpoint): boolean {
|
|
183
|
-
return cp1.epoch === cp2.epoch && byteArrayEquals(cp1.root, cp2.root);
|
|
184
|
-
}
|