@lodestar/state-transition 1.51.0-dev.2593063a82 → 1.51.0-dev.2aff7aaeb7

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.
Files changed (173) hide show
  1. package/lib/block/index.d.ts +1 -1
  2. package/lib/block/index.d.ts.map +1 -1
  3. package/lib/block/index.js +2 -2
  4. package/lib/block/index.js.map +1 -1
  5. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  6. package/lib/block/processAttestationsAltair.js +3 -1
  7. package/lib/block/processAttestationsAltair.js.map +1 -1
  8. package/lib/block/processDeposit.d.ts.map +1 -1
  9. package/lib/block/processDeposit.js +1 -1
  10. package/lib/block/processDeposit.js.map +1 -1
  11. package/lib/block/processOperations.d.ts +1 -1
  12. package/lib/block/processOperations.d.ts.map +1 -1
  13. package/lib/block/processOperations.js +1 -1
  14. package/lib/block/processOperations.js.map +1 -1
  15. package/lib/cache/epochCache.d.ts +5 -2
  16. package/lib/cache/epochCache.d.ts.map +1 -1
  17. package/lib/cache/epochCache.js +12 -5
  18. package/lib/cache/epochCache.js.map +1 -1
  19. package/lib/cache/epochTransitionCache.d.ts.map +1 -1
  20. package/lib/cache/epochTransitionCache.js +2 -1
  21. package/lib/cache/epochTransitionCache.js.map +1 -1
  22. package/lib/cache/syncCommitteeCache.d.ts +1 -1
  23. package/lib/cache/syncCommitteeCache.d.ts.map +1 -1
  24. package/lib/epoch/getRewardsAndPenalties.d.ts.map +1 -1
  25. package/lib/epoch/getRewardsAndPenalties.js +9 -2
  26. package/lib/epoch/getRewardsAndPenalties.js.map +1 -1
  27. package/lib/epoch/index.d.ts +2 -2
  28. package/lib/epoch/index.d.ts.map +1 -1
  29. package/lib/epoch/index.js +2 -2
  30. package/lib/epoch/index.js.map +1 -1
  31. package/lib/epoch/processSyncCommitteeUpdates.js +1 -1
  32. package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
  33. package/lib/lightClient/spec/store.d.ts +1 -1
  34. package/lib/lightClient/spec/store.d.ts.map +1 -1
  35. package/lib/lightClient/spec/utils.d.ts.map +1 -1
  36. package/lib/lightClient/spec/utils.js +1 -1
  37. package/lib/lightClient/spec/utils.js.map +1 -1
  38. package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -1
  39. package/lib/lightClient/spec/validateLightClientUpdate.js +1 -1
  40. package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -1
  41. package/lib/metrics.d.ts +1 -1
  42. package/lib/metrics.d.ts.map +1 -1
  43. package/lib/metrics.js +4 -4
  44. package/lib/metrics.js.map +1 -1
  45. package/lib/rewards/attestationsRewards.d.ts +1 -1
  46. package/lib/rewards/attestationsRewards.d.ts.map +1 -1
  47. package/lib/rewards/attestationsRewards.js +10 -3
  48. package/lib/rewards/attestationsRewards.js.map +1 -1
  49. package/lib/rewards/syncCommitteeRewards.d.ts +1 -1
  50. package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
  51. package/lib/signatureSets/inclusionList.d.ts +5 -0
  52. package/lib/signatureSets/inclusionList.d.ts.map +1 -0
  53. package/lib/signatureSets/inclusionList.js +14 -0
  54. package/lib/signatureSets/inclusionList.js.map +1 -0
  55. package/lib/signatureSets/index.d.ts +1 -0
  56. package/lib/signatureSets/index.d.ts.map +1 -1
  57. package/lib/signatureSets/index.js +1 -0
  58. package/lib/signatureSets/index.js.map +1 -1
  59. package/lib/stateTransition.js +2 -2
  60. package/lib/stateTransition.js.map +1 -1
  61. package/lib/stateView/beaconStateView.d.ts +1 -0
  62. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  63. package/lib/stateView/beaconStateView.js +5 -1
  64. package/lib/stateView/beaconStateView.js.map +1 -1
  65. package/lib/stateView/interface.d.ts +2 -4
  66. package/lib/stateView/interface.d.ts.map +1 -1
  67. package/lib/stateView/interface.js.map +1 -1
  68. package/lib/stateView/nativeBeaconStateView.d.ts +15 -7
  69. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  70. package/lib/stateView/nativeBeaconStateView.js +76 -26
  71. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  72. package/lib/stateView/stateViewFactory.d.ts.map +1 -1
  73. package/lib/stateView/stateViewFactory.js +5 -4
  74. package/lib/stateView/stateViewFactory.js.map +1 -1
  75. package/lib/testUtils/interopPubkeyCache.js +1 -1
  76. package/lib/testUtils/interopPubkeyCache.js.map +1 -1
  77. package/lib/testUtils/state.d.ts.map +1 -1
  78. package/lib/testUtils/state.js +1 -1
  79. package/lib/testUtils/state.js.map +1 -1
  80. package/lib/testUtils/util.d.ts +1 -1
  81. package/lib/testUtils/util.d.ts.map +1 -1
  82. package/lib/testUtils/util.js +2 -2
  83. package/lib/testUtils/util.js.map +1 -1
  84. package/lib/util/altair.d.ts +3 -1
  85. package/lib/util/altair.d.ts.map +1 -1
  86. package/lib/util/altair.js +7 -4
  87. package/lib/util/altair.js.map +1 -1
  88. package/lib/util/blindedBlock.d.ts.map +1 -1
  89. package/lib/util/blindedBlock.js +4 -12
  90. package/lib/util/blindedBlock.js.map +1 -1
  91. package/lib/util/clock.js +1 -1
  92. package/lib/util/clock.js.map +1 -1
  93. package/lib/util/epochShuffling.d.ts.map +1 -1
  94. package/lib/util/epochShuffling.js +1 -1
  95. package/lib/util/epochShuffling.js.map +1 -1
  96. package/lib/util/inclusionListCommittee.d.ts +9 -0
  97. package/lib/util/inclusionListCommittee.d.ts.map +1 -0
  98. package/lib/util/inclusionListCommittee.js +18 -0
  99. package/lib/util/inclusionListCommittee.js.map +1 -0
  100. package/lib/util/index.d.ts +1 -0
  101. package/lib/util/index.d.ts.map +1 -1
  102. package/lib/util/index.js +1 -0
  103. package/lib/util/index.js.map +1 -1
  104. package/lib/util/interop.d.ts +1 -1
  105. package/lib/util/interop.d.ts.map +1 -1
  106. package/lib/util/interop.js +1 -1
  107. package/lib/util/interop.js.map +1 -1
  108. package/lib/util/seed.js +1 -1
  109. package/lib/util/seed.js.map +1 -1
  110. package/lib/util/shuffling.d.ts +3 -0
  111. package/lib/util/shuffling.d.ts.map +1 -1
  112. package/lib/util/shuffling.js +41 -1
  113. package/lib/util/shuffling.js.map +1 -1
  114. package/lib/util/signatureSets.d.ts +1 -1
  115. package/lib/util/signatureSets.d.ts.map +1 -1
  116. package/lib/util/signatureSets.js +1 -1
  117. package/lib/util/signatureSets.js.map +1 -1
  118. package/lib/util/slot.d.ts +15 -1
  119. package/lib/util/slot.d.ts.map +1 -1
  120. package/lib/util/slot.js +66 -6
  121. package/lib/util/slot.js.map +1 -1
  122. package/lib/util/syncCommittee.d.ts +4 -3
  123. package/lib/util/syncCommittee.d.ts.map +1 -1
  124. package/lib/util/syncCommittee.js +10 -8
  125. package/lib/util/syncCommittee.js.map +1 -1
  126. package/lib/util/validator.d.ts +1 -1
  127. package/lib/util/validator.d.ts.map +1 -1
  128. package/lib/util/validator.js +32 -11
  129. package/lib/util/validator.js.map +1 -1
  130. package/lib/util/weakSubjectivity.d.ts.map +1 -1
  131. package/lib/util/weakSubjectivity.js +4 -3
  132. package/lib/util/weakSubjectivity.js.map +1 -1
  133. package/package.json +9 -9
  134. package/src/block/index.ts +11 -12
  135. package/src/block/processAttestationsAltair.ts +4 -1
  136. package/src/block/processDeposit.ts +2 -2
  137. package/src/block/processOperations.ts +5 -5
  138. package/src/cache/epochCache.ts +30 -6
  139. package/src/cache/epochTransitionCache.ts +2 -1
  140. package/src/cache/syncCommitteeCache.ts +1 -1
  141. package/src/epoch/getRewardsAndPenalties.ts +11 -1
  142. package/src/epoch/index.ts +14 -15
  143. package/src/epoch/processSyncCommitteeUpdates.ts +1 -1
  144. package/src/lightClient/spec/store.ts +1 -1
  145. package/src/lightClient/spec/utils.ts +1 -1
  146. package/src/lightClient/spec/validateLightClientUpdate.ts +1 -1
  147. package/src/metrics.ts +5 -4
  148. package/src/rewards/attestationsRewards.ts +13 -2
  149. package/src/rewards/syncCommitteeRewards.ts +1 -1
  150. package/src/signatureSets/inclusionList.ts +20 -0
  151. package/src/signatureSets/index.ts +1 -0
  152. package/src/stateTransition.ts +2 -2
  153. package/src/stateView/beaconStateView.ts +5 -1
  154. package/src/stateView/interface.ts +1 -12
  155. package/src/stateView/nativeBeaconStateView.ts +77 -33
  156. package/src/stateView/stateViewFactory.ts +5 -4
  157. package/src/testUtils/interopPubkeyCache.ts +1 -1
  158. package/src/testUtils/state.ts +1 -1
  159. package/src/testUtils/util.ts +2 -2
  160. package/src/util/altair.ts +15 -4
  161. package/src/util/blindedBlock.ts +4 -12
  162. package/src/util/clock.ts +1 -1
  163. package/src/util/epochShuffling.ts +1 -1
  164. package/src/util/inclusionListCommittee.ts +17 -0
  165. package/src/util/index.ts +1 -0
  166. package/src/util/interop.ts +1 -1
  167. package/src/util/seed.ts +1 -1
  168. package/src/util/shuffling.ts +46 -1
  169. package/src/util/signatureSets.ts +1 -1
  170. package/src/util/slot.ts +72 -7
  171. package/src/util/syncCommittee.ts +22 -10
  172. package/src/util/validator.ts +47 -20
  173. package/src/util/weakSubjectivity.ts +3 -3
@@ -1,7 +1,8 @@
1
- import { EFFECTIVE_BALANCE_INCREMENT, ForkSeq, GENESIS_SLOT, MAX_DEPOSITS, MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH, isForkPostElectra, isForkPostGloas, } from "@lodestar/params";
1
+ import { EFFECTIVE_BALANCE_INCREMENT, ForkSeq, MAX_DEPOSITS, MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH, isForkPostElectra, isForkPostGloas, } from "@lodestar/params";
2
2
  import { ssz } from "@lodestar/types";
3
3
  import { ZERO_HASH } from "../constants/constants.js";
4
4
  import { computeCheckpointEpochAtStateSlot, computeEpochAtSlot, getCurrentEpoch } from "./epoch.js";
5
+ import { computeSlotAtTimeMs } from "./slot.js";
5
6
  import { getStateTypeFromBytes, scanActiveValidatorsFromStateBytes } from "./sszBytes.js";
6
7
  import { getActivationChurnLimit, getActiveValidatorIndices, getBalanceChurnLimit, getBalanceChurnLimitFromCache, getChurnLimit, getConsolidationChurnLimit, getExitChurnLimit, getGloasChurnLimits, } from "./validator.js";
7
8
  export const ETH_TO_GWEI = 10 ** 9;
@@ -50,7 +51,7 @@ export function computeWeakSubjectivityPeriod(config, state) {
50
51
  }
51
52
  function computeWeakSubjectivityPeriodFromActiveValidators(config, slot, { activeValidatorCount, totalActiveBalanceIncrements, }) {
52
53
  const fork = config.getForkName(slot);
53
- const churnLimitsGloas = getGloasChurnLimits(config, totalActiveBalanceIncrements);
54
+ const churnLimitsGloas = getGloasChurnLimits(config, computeEpochAtSlot(slot), totalActiveBalanceIncrements);
54
55
  return isForkPostGloas(fork)
55
56
  ? computeWeakSubjectivityPeriodFromConstituentsGloas(totalActiveBalanceIncrements, churnLimitsGloas.exit, churnLimitsGloas.activation, churnLimitsGloas.consolidation, config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
56
57
  : isForkPostElectra(fork)
@@ -113,7 +114,7 @@ export function computeWeakSubjectivitySummaryFromStateBytes(config, bytes, meta
113
114
  return { checkpointEpoch: computeCheckpointEpochAtStateSlot(slot), genesisTime, period };
114
115
  }
115
116
  export function isWithinWeakSubjectivityPeriodFromSummary(config, summary, now = Date.now() / 1000) {
116
- const clockSlot = GENESIS_SLOT + Math.floor((now - summary.genesisTime) / (config.SLOT_DURATION_MS / 1000));
117
+ const clockSlot = computeSlotAtTimeMs(config, now * 1000, summary.genesisTime * 1000);
117
118
  return computeEpochAtSlot(clockSlot) <= summary.checkpointEpoch + summary.period;
118
119
  }
119
120
  //# sourceMappingURL=weakSubjectivity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"weakSubjectivity.js","sourceRoot":"","sources":["../../src/util/weakSubjectivity.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpE,OAA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,GAAG,IAAI,CAAC,CAAC;IACtF,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;AACnF,CAAC"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.51.0-dev.2593063a82",
14
+ "version": "1.51.0-dev.2aff7aaeb7",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -66,17 +66,17 @@
66
66
  "types": "lib/index.d.ts",
67
67
  "dependencies": {
68
68
  "@chainsafe/as-sha256": "^1.2.5",
69
- "@chainsafe/lodestar-z": "catalog:",
70
69
  "@chainsafe/persistent-merkle-tree": "^1.3.1",
71
- "@chainsafe/ssz": "^1.8.1",
72
- "@lodestar/config": "^1.51.0-dev.2593063a82",
73
- "@lodestar/params": "^1.51.0-dev.2593063a82",
74
- "@lodestar/types": "^1.51.0-dev.2593063a82",
75
- "@lodestar/utils": "^1.51.0-dev.2593063a82",
70
+ "@chainsafe/ssz": "^1.9.0",
71
+ "@lodestar/config": "^1.51.0-dev.2aff7aaeb7",
72
+ "@lodestar/native": "^1.51.0-dev.2aff7aaeb7",
73
+ "@lodestar/params": "^1.51.0-dev.2aff7aaeb7",
74
+ "@lodestar/types": "^1.51.0-dev.2aff7aaeb7",
75
+ "@lodestar/utils": "^1.51.0-dev.2aff7aaeb7",
76
76
  "@vekexasia/bigint-buffer2": "^1.1.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@lodestar/test-utils": "^1.51.0-dev.2593063a82"
79
+ "@lodestar/test-utils": "^1.51.0-dev.2aff7aaeb7"
80
80
  },
81
81
  "keywords": [
82
82
  "ethereum",
@@ -84,5 +84,5 @@
84
84
  "beacon",
85
85
  "blockchain"
86
86
  ],
87
- "gitHead": "9ef629e5938036e197e32f9dd5c99eeeb89a9e48"
87
+ "gitHead": "f21e6d99691b70fbc32f5b2fe1653d379fac34c5"
88
88
  }
@@ -23,27 +23,26 @@ import {processSyncAggregate} from "./processSyncCommittee.js";
23
23
  import {processWithdrawals} from "./processWithdrawals.js";
24
24
  import {BlockProcessStep, ProcessBlockOpts, ProposerRewardType} from "./types.js";
25
25
 
26
+ export * from "./externalData.js";
27
+ export * from "./initiateValidatorExit.js";
28
+ export * from "./isValidIndexedAttestation.js";
29
+ export * from "./processBuilderDepositRequest.js";
30
+ export * from "./processBuilderExitRequest.js";
31
+ export * from "./processDepositRequest.js";
32
+ export * from "./processOperations.js";
26
33
  // Spec tests
27
34
  export {
28
35
  processBlockHeader,
36
+ processEth1Data,
29
37
  processExecutionPayload,
38
+ processExecutionPayloadBid,
39
+ processParentExecutionPayload,
40
+ processPayloadAttestation,
30
41
  processRandao,
31
- processEth1Data,
32
42
  processSyncAggregate,
33
43
  processWithdrawals,
34
- processExecutionPayloadBid,
35
- processPayloadAttestation,
36
- processParentExecutionPayload,
37
44
  };
38
45
 
39
- export * from "./externalData.js";
40
- export * from "./initiateValidatorExit.js";
41
- export * from "./isValidIndexedAttestation.js";
42
- export * from "./processBuilderDepositRequest.js";
43
- export * from "./processBuilderExitRequest.js";
44
- export * from "./processDepositRequest.js";
45
- export * from "./processOperations.js";
46
-
47
46
  export function processBlock(
48
47
  fork: ForkSeq,
49
48
  state: CachedBeaconStateAllForks,
@@ -141,7 +141,10 @@ export function processAttestationsAltair(
141
141
 
142
142
  // Do the discrete math inside the loop to ensure a deterministic result
143
143
  const totalIncrements = totalBalanceIncrementsWithWeight;
144
- const proposerRewardNumerator = totalIncrements * state.epochCtx.baseRewardPerIncrement;
144
+ // The proposer reward is priced at the attestation's target epoch
145
+ const proposerRewardNumerator =
146
+ totalIncrements *
147
+ (inCurrentEpoch ? state.epochCtx.baseRewardPerIncrement : state.epochCtx.baseRewardPerIncrementPrevEpoch);
145
148
  proposerReward += Math.floor(proposerRewardNumerator / PROPOSER_REWARD_DOMINATOR);
146
149
 
147
150
  if (fork >= ForkSeq.gloas) {
@@ -1,10 +1,10 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {
2
3
  BLS_VERIFIER_MAX_BATCH_SIZE,
3
4
  BLS_VERIFIER_SET_TYPE,
4
5
  type BlsSignatureSet,
5
6
  verifySignatureSets,
6
- } from "@chainsafe/lodestar-z/bls-verifier";
7
- import {BeaconConfig} from "@lodestar/config";
7
+ } from "@lodestar/native/bls-verifier";
8
8
  import {
9
9
  DEPOSIT_CONTRACT_TREE_DEPTH,
10
10
  DOMAIN_DEPOSIT,
@@ -22,15 +22,15 @@ import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
22
22
  import {ProcessBlockOpts, ProcessOperationsStep} from "./types.js";
23
23
 
24
24
  export {
25
- processProposerSlashing,
26
- processAttesterSlashing,
27
25
  processAttestations,
26
+ processAttesterSlashing,
27
+ processBlsToExecutionChange,
28
+ processConsolidationRequest,
28
29
  processDeposit,
30
+ processDepositRequest,
31
+ processProposerSlashing,
29
32
  processVoluntaryExit,
30
33
  processWithdrawalRequest,
31
- processBlsToExecutionChange,
32
- processDepositRequest,
33
- processConsolidationRequest,
34
34
  };
35
35
 
36
36
  export function processOperations(
@@ -1,6 +1,6 @@
1
- import {PublicKey} from "@chainsafe/lodestar-z/blst";
2
- import {type PubkeyCache, pubkeyCache as defaultPubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
3
1
  import {BeaconConfig, ChainConfig, createBeaconConfig} from "@lodestar/config";
2
+ import {PublicKey} from "@lodestar/native/blst";
3
+ import {type PubkeyCache, pubkeyCache as defaultPubkeyCache} from "@lodestar/native/pubkeys";
4
4
  import {
5
5
  ATTESTATION_SUBNET_COUNT,
6
6
  DOMAIN_BEACON_PROPOSER,
@@ -178,6 +178,8 @@ export class EpochCache {
178
178
  * Update freq: once per epoch after `process_effective_balance_updates()`
179
179
  */
180
180
  baseRewardPerIncrement: number;
181
+ /** As baseRewardPerIncrement but priced at the previous epoch's slot duration */
182
+ baseRewardPerIncrementPrevEpoch: number;
181
183
  /**
182
184
  * Total active balance for current epoch, to be used instead of getTotalBalance()
183
185
  */
@@ -269,6 +271,7 @@ export class EpochCache {
269
271
  syncParticipantReward: number;
270
272
  syncProposerReward: number;
271
273
  baseRewardPerIncrement: number;
274
+ baseRewardPerIncrementPrevEpoch: number;
272
275
  totalActiveBalanceIncrements: number;
273
276
  churnLimit: number;
274
277
  activationChurnLimit: number;
@@ -302,6 +305,7 @@ export class EpochCache {
302
305
  this.syncParticipantReward = data.syncParticipantReward;
303
306
  this.syncProposerReward = data.syncProposerReward;
304
307
  this.baseRewardPerIncrement = data.baseRewardPerIncrement;
308
+ this.baseRewardPerIncrementPrevEpoch = data.baseRewardPerIncrementPrevEpoch;
305
309
  this.totalActiveBalanceIncrements = data.totalActiveBalanceIncrements;
306
310
  this.churnLimit = data.churnLimit;
307
311
  this.activationChurnLimit = data.activationChurnLimit;
@@ -452,9 +456,14 @@ export class EpochCache {
452
456
 
453
457
  // Values syncParticipantReward, syncProposerReward, baseRewardPerIncrement are only used after altair.
454
458
  // However, since they are very cheap to compute they are computed always to simplify upgradeState function.
455
- const syncParticipantReward = computeSyncParticipantReward(totalActiveBalanceIncrements);
459
+ const syncParticipantReward = computeSyncParticipantReward(config, currentEpoch, totalActiveBalanceIncrements);
456
460
  const syncProposerReward = Math.floor(syncParticipantReward * PROPOSER_WEIGHT_FACTOR);
457
- const baseRewardPerIncrement = computeBaseRewardPerIncrement(totalActiveBalanceIncrements);
461
+ const baseRewardPerIncrement = computeBaseRewardPerIncrement(config, currentEpoch, totalActiveBalanceIncrements);
462
+ const baseRewardPerIncrementPrevEpoch = computeBaseRewardPerIncrement(
463
+ config,
464
+ Math.max(currentEpoch - 1, GENESIS_EPOCH),
465
+ totalActiveBalanceIncrements
466
+ );
458
467
 
459
468
  let currentSyncCommitteeIndexed: SyncCommitteeCache;
460
469
  let nextSyncCommitteeIndexed: SyncCommitteeCache;
@@ -542,6 +551,7 @@ export class EpochCache {
542
551
  syncParticipantReward,
543
552
  syncProposerReward,
544
553
  baseRewardPerIncrement,
554
+ baseRewardPerIncrementPrevEpoch,
545
555
  totalActiveBalanceIncrements,
546
556
  churnLimit,
547
557
  activationChurnLimit,
@@ -591,6 +601,7 @@ export class EpochCache {
591
601
  syncParticipantReward: this.syncParticipantReward,
592
602
  syncProposerReward: this.syncProposerReward,
593
603
  baseRewardPerIncrement: this.baseRewardPerIncrement,
604
+ baseRewardPerIncrementPrevEpoch: this.baseRewardPerIncrementPrevEpoch,
594
605
  totalActiveBalanceIncrements: this.totalActiveBalanceIncrements,
595
606
  churnLimit: this.churnLimit,
596
607
  activationChurnLimit: this.activationChurnLimit,
@@ -685,9 +696,22 @@ export class EpochCache {
685
696
 
686
697
  this.totalActiveBalanceIncrements = epochTransitionCache.nextEpochTotalActiveBalanceByIncrement;
687
698
  if (upcomingEpoch >= this.config.ALTAIR_FORK_EPOCH) {
688
- this.syncParticipantReward = computeSyncParticipantReward(this.totalActiveBalanceIncrements);
699
+ this.syncParticipantReward = computeSyncParticipantReward(
700
+ this.config,
701
+ upcomingEpoch,
702
+ this.totalActiveBalanceIncrements
703
+ );
689
704
  this.syncProposerReward = Math.floor(this.syncParticipantReward * PROPOSER_WEIGHT_FACTOR);
690
- this.baseRewardPerIncrement = computeBaseRewardPerIncrement(this.totalActiveBalanceIncrements);
705
+ this.baseRewardPerIncrement = computeBaseRewardPerIncrement(
706
+ this.config,
707
+ upcomingEpoch,
708
+ this.totalActiveBalanceIncrements
709
+ );
710
+ this.baseRewardPerIncrementPrevEpoch = computeBaseRewardPerIncrement(
711
+ this.config,
712
+ Math.max(upcomingEpoch - 1, GENESIS_EPOCH),
713
+ this.totalActiveBalanceIncrements
714
+ );
691
715
  }
692
716
 
693
717
  this.previousTargetUnslashedBalanceIncrements = this.currentTargetUnslashedBalanceIncrements;
@@ -384,7 +384,8 @@ export function beforeProcessEpoch(
384
384
  }
385
385
 
386
386
  // SPEC: function getBaseRewardPerIncrement()
387
- const baseRewardPerIncrement = computeBaseRewardPerIncrement(totalActiveStakeByIncrement);
387
+ // Flag deltas pay for the previous epoch, so they are priced at its slot duration
388
+ const baseRewardPerIncrement = computeBaseRewardPerIncrement(config, prevEpoch, totalActiveStakeByIncrement);
388
389
 
389
390
  // To optimize process_registry_updates():
390
391
  // order by sequence of activationEligibilityEpoch setting and then index
@@ -1,5 +1,5 @@
1
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {CompositeViewDU} from "@chainsafe/ssz";
2
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
3
3
  import {ValidatorIndex, ssz} from "@lodestar/types";
4
4
  import {toPubkeyHex} from "@lodestar/utils";
5
5
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  EFFECTIVE_BALANCE_INCREMENT,
3
3
  ForkSeq,
4
+ GENESIS_EPOCH,
4
5
  INACTIVITY_PENALTY_QUOTIENT_ALTAIR,
5
6
  INACTIVITY_PENALTY_QUOTIENT_BELLATRIX,
6
7
  PARTICIPATION_FLAG_WEIGHTS,
@@ -18,6 +19,7 @@ import {
18
19
  hasMarkers,
19
20
  } from "../util/attesterStatus.js";
20
21
  import {isInInactivityLeak} from "../util/index.js";
22
+ import {getSlotDurationMsAtEpoch} from "../util/slot.js";
21
23
 
22
24
  type RewardPenaltyItem = {
23
25
  baseReward: number;
@@ -67,7 +69,15 @@ export function getRewardsAndPenaltiesAltair(
67
69
 
68
70
  const inactivityPenalityMultiplier =
69
71
  fork === ForkSeq.altair ? INACTIVITY_PENALTY_QUOTIENT_ALTAIR : INACTIVITY_PENALTY_QUOTIENT_BELLATRIX;
70
- const penaltyDenominator = config.INACTIVITY_SCORE_BIAS * inactivityPenalityMultiplier;
72
+ let penaltyDenominator = config.INACTIVITY_SCORE_BIAS * inactivityPenalityMultiplier;
73
+ // The penalty pays for the previous epoch and scales with the square of its slot duration
74
+ const genesisSlotDurationMs = getSlotDurationMsAtEpoch(config, GENESIS_EPOCH);
75
+ const prevEpochSlotDurationMs = getSlotDurationMsAtEpoch(config, Math.max(epochCtx.epoch - 1, GENESIS_EPOCH));
76
+ if (prevEpochSlotDurationMs !== genesisSlotDurationMs) {
77
+ penaltyDenominator = Number(
78
+ (BigInt(penaltyDenominator) * BigInt(genesisSlotDurationMs) ** 2n) / BigInt(prevEpochSlotDurationMs) ** 2n
79
+ );
80
+ }
71
81
 
72
82
  const {flags} = cache;
73
83
  for (let i = 0; i < flags.length; i++) {
@@ -37,32 +37,31 @@ import {processSlashings} from "./processSlashings.js";
37
37
  import {processSlashingsReset} from "./processSlashingsReset.js";
38
38
  import {processSyncCommitteeUpdates} from "./processSyncCommitteeUpdates.js";
39
39
 
40
+ export {computeUnrealizedCheckpoints} from "./computeUnrealizedCheckpoints.js";
40
41
  // For spec tests
41
42
  export {getRewardsAndPenalties} from "./processRewardsAndPenalties.js";
42
43
  export {
43
- processJustificationAndFinalization,
44
- processInactivityUpdates,
45
- processRewardsAndPenalties,
46
- processRegistryUpdates,
47
- processSlashings,
48
- processEth1DataReset,
44
+ processBuilderPendingPayments,
49
45
  processEffectiveBalanceUpdates,
50
- processSlashingsReset,
51
- processRandaoMixesReset,
46
+ processEth1DataReset,
52
47
  processHistoricalRootsUpdate,
53
- processParticipationRecordUpdates,
54
- processParticipationFlagUpdates,
55
- processSyncCommitteeUpdates,
56
48
  processHistoricalSummariesUpdate,
57
- processPendingDeposits,
49
+ processInactivityUpdates,
50
+ processJustificationAndFinalization,
51
+ processParticipationFlagUpdates,
52
+ processParticipationRecordUpdates,
58
53
  processPendingConsolidations,
54
+ processPendingDeposits,
59
55
  processProposerLookahead,
60
56
  processPtcWindow,
61
- processBuilderPendingPayments,
57
+ processRandaoMixesReset,
58
+ processRegistryUpdates,
59
+ processRewardsAndPenalties,
60
+ processSlashings,
61
+ processSlashingsReset,
62
+ processSyncCommitteeUpdates,
62
63
  };
63
64
 
64
- export {computeUnrealizedCheckpoints} from "./computeUnrealizedCheckpoints.js";
65
-
66
65
  const maxValidatorsPerStateSlashing = SLOTS_PER_EPOCH * MAX_ATTESTER_SLASHINGS * MAX_VALIDATORS_PER_COMMITTEE;
67
66
  const maxSafeValidators = Math.floor(Number.MAX_SAFE_INTEGER / MAX_EFFECTIVE_BALANCE);
68
67
 
@@ -1,4 +1,4 @@
1
- import {aggregateSerializedPublicKeys} from "@chainsafe/lodestar-z/blst";
1
+ import {aggregateSerializedPublicKeys} from "@lodestar/native/blst";
2
2
  import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, ForkSeq} from "@lodestar/params";
3
3
  import {ssz} from "@lodestar/types";
4
4
  import {CachedBeaconStateAltair} from "../types.js";
@@ -1,5 +1,5 @@
1
- import type {PublicKey} from "@chainsafe/lodestar-z/blst";
2
1
  import {BeaconConfig} from "@lodestar/config";
2
+ import type {PublicKey} from "@lodestar/native/blst";
3
3
  import {LightClientBootstrap, LightClientHeader, LightClientUpdate, SyncPeriod} from "@lodestar/types";
4
4
  import {computeSyncPeriodAtSlot} from "../../util/epoch.js";
5
5
  import type {LightClientUpdateSummary} from "./isBetterUpdate.js";
@@ -1,7 +1,7 @@
1
- import {PublicKey} from "@chainsafe/lodestar-z/blst";
2
1
  import {Tree} from "@chainsafe/persistent-merkle-tree";
3
2
  import {BitArray} from "@chainsafe/ssz";
4
3
  import {ChainForkConfig} from "@lodestar/config";
4
+ import {PublicKey} from "@lodestar/native/blst";
5
5
  import {
6
6
  BLOCK_BODY_EXECUTION_PAYLOAD_GINDEX,
7
7
  CURRENT_SYNC_COMMITTEE_GINDEX,
@@ -1,5 +1,5 @@
1
- import {PublicKey, Signature, fastAggregateVerify} from "@chainsafe/lodestar-z/blst";
2
1
  import {ChainForkConfig} from "@lodestar/config";
2
+ import {PublicKey, Signature, fastAggregateVerify} from "@lodestar/native/blst";
3
3
  import {DOMAIN_SYNC_COMMITTEE, GENESIS_SLOT, MIN_SYNC_COMMITTEE_PARTICIPANTS} from "@lodestar/params";
4
4
  import {LightClientUpdate, Root, ssz} from "@lodestar/types";
5
5
  import type {ILightClientStore, SyncCommitteeFast} from "./store.js";
package/src/metrics.ts CHANGED
@@ -156,19 +156,20 @@ export function getMetrics(register: MetricsRegister) {
156
156
  }
157
157
 
158
158
  export function onStateCloneMetrics(
159
- state: CachedBeaconStateAllForks,
159
+ clonedState: CachedBeaconStateAllForks,
160
+ clonedCount: number,
160
161
  metrics: BeaconStateTransitionMetrics,
161
162
  source: StateCloneSource
162
163
  ): void {
163
- metrics.preStateClonedCount.observe(state.clonedCount);
164
+ metrics.preStateClonedCount.observe(clonedCount);
164
165
 
165
- if (isBalancesNodesPopulated(state)) {
166
+ if (isBalancesNodesPopulated(clonedState)) {
166
167
  metrics.preStateBalancesNodesPopulatedHit.inc({source});
167
168
  } else {
168
169
  metrics.preStateBalancesNodesPopulatedMiss.inc({source});
169
170
  }
170
171
 
171
- if (isValidatorsNodesPopulated(state)) {
172
+ if (isValidatorsNodesPopulated(clonedState)) {
172
173
  metrics.preStateValidatorsNodesPopulatedHit.inc({source});
173
174
  } else {
174
175
  metrics.preStateValidatorsNodesPopulatedMiss.inc({source});
@@ -1,9 +1,10 @@
1
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {BeaconConfig} from "@lodestar/config";
2
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
3
3
  import {
4
4
  EFFECTIVE_BALANCE_INCREMENT,
5
5
  ForkName,
6
6
  ForkSeq,
7
+ GENESIS_EPOCH,
7
8
  INACTIVITY_PENALTY_QUOTIENT_ALTAIR,
8
9
  INACTIVITY_PENALTY_QUOTIENT_BELLATRIX,
9
10
  MAX_EFFECTIVE_BALANCE,
@@ -26,6 +27,7 @@ import {
26
27
  FLAG_PREV_HEAD_ATTESTER_UNSLASHED,
27
28
  FLAG_PREV_SOURCE_ATTESTER_UNSLASHED,
28
29
  FLAG_PREV_TARGET_ATTESTER_UNSLASHED,
30
+ getSlotDurationMsAtEpoch,
29
31
  hasMarkers,
30
32
  isInInactivityLeak,
31
33
  } from "../util/index.js";
@@ -168,7 +170,16 @@ function computeTotalAttestationsRewardsAltair(
168
170
  config.getForkSeq(state.slot) === ForkSeq.altair
169
171
  ? INACTIVITY_PENALTY_QUOTIENT_ALTAIR
170
172
  : INACTIVITY_PENALTY_QUOTIENT_BELLATRIX;
171
- const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * inactivityPenaltyQuotient;
173
+ let inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * inactivityPenaltyQuotient;
174
+ // The penalty pays for the previous epoch and scales with the square of its slot duration
175
+ const genesisSlotDurationMs = getSlotDurationMsAtEpoch(config, GENESIS_EPOCH);
176
+ const prevEpochSlotDurationMs = getSlotDurationMsAtEpoch(config, Math.max(epochCtx.epoch - 1, GENESIS_EPOCH));
177
+ if (prevEpochSlotDurationMs !== genesisSlotDurationMs) {
178
+ inactivityPenaltyDenominator = Number(
179
+ (BigInt(inactivityPenaltyDenominator) * BigInt(genesisSlotDurationMs) ** 2n) /
180
+ BigInt(prevEpochSlotDurationMs) ** 2n
181
+ );
182
+ }
172
183
 
173
184
  for (let i = 0; i < flags.length; i++) {
174
185
  if (validatorIndices.length && !validatorIndices.includes(i)) {
@@ -1,5 +1,5 @@
1
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {BeaconConfig} from "@lodestar/config";
2
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
3
3
  import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
4
4
  import {BeaconBlock, ValidatorIndex, altair, rewards} from "@lodestar/types";
5
5
  import {toPubkeyHex} from "@lodestar/utils";
@@ -0,0 +1,20 @@
1
+ import {BeaconConfig} from "@lodestar/config";
2
+ import {DOMAIN_INCLUSION_LIST_COMMITTEE} from "@lodestar/params";
3
+ import {Slot, heze, ssz} from "@lodestar/types";
4
+ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index.js";
5
+
6
+ export function getInclusionListSignatureSet(
7
+ config: BeaconConfig,
8
+ stateSlot: Slot,
9
+ signedInclusionList: heze.SignedInclusionList
10
+ ): ISignatureSet {
11
+ const message = signedInclusionList.message;
12
+ const domain = config.getDomain(stateSlot, DOMAIN_INCLUSION_LIST_COMMITTEE, message.slot);
13
+
14
+ return {
15
+ type: SignatureSetType.indexed,
16
+ index: message.validatorIndex,
17
+ signingRoot: computeSigningRoot(ssz.heze.InclusionList, message, domain),
18
+ signature: signedInclusionList.signature,
19
+ };
20
+ }
@@ -18,6 +18,7 @@ export * from "./attesterSlashings.js";
18
18
  export * from "./blsToExecutionChange.js";
19
19
  export * from "./executionPayloadBid.js";
20
20
  export * from "./executionPayloadEnvelope.js";
21
+ export * from "./inclusionList.js";
21
22
  export * from "./indexedAttestation.js";
22
23
  export * from "./indexedPayloadAttestation.js";
23
24
  export * from "./proposer.js";
@@ -101,7 +101,7 @@ export function stateTransition(
101
101
  let postState = state.clone(options.dontTransferCache);
102
102
 
103
103
  if (metrics) {
104
- onStateCloneMetrics(postState, metrics, StateCloneSource.stateTransition);
104
+ onStateCloneMetrics(postState, state.clonedCount, metrics, StateCloneSource.stateTransition);
105
105
  }
106
106
 
107
107
  // State is already a ViewDU, which won't commit changes. Equivalent to .setStateCachesAsTransient()
@@ -168,7 +168,7 @@ export function processSlots(
168
168
  let postState = state.clone(opts?.dontTransferCache);
169
169
 
170
170
  if (metrics) {
171
- onStateCloneMetrics(postState, metrics, StateCloneSource.processSlots);
171
+ onStateCloneMetrics(postState, state.clonedCount, metrics, StateCloneSource.processSlots);
172
172
  }
173
173
 
174
174
  // State is already a ViewDU, which won't commit changes. Equivalent to .setStateCachesAsTransient()
@@ -84,6 +84,7 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
84
84
  // phase0
85
85
  private cachedFork: Fork | null = null;
86
86
  private cachedLatestBlockHeader: phase0.BeaconBlockHeader | null = null;
87
+ private cachedEffectiveBalanceIncrementsZeroInactive: EffectiveBalanceIncrements | null = null;
87
88
  // altair
88
89
  private cachedCurrentSyncCommittee: SyncCommittee | null = null;
89
90
  private cachedNextSyncCommittee: SyncCommittee | null = null;
@@ -638,7 +639,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
638
639
  }
639
640
 
640
641
  getEffectiveBalanceIncrementsZeroInactive(): EffectiveBalanceIncrements {
641
- return getEffectiveBalanceIncrementsZeroInactive(this.cachedState);
642
+ if (this.cachedEffectiveBalanceIncrementsZeroInactive === null) {
643
+ this.cachedEffectiveBalanceIncrementsZeroInactive = getEffectiveBalanceIncrementsZeroInactive(this.cachedState);
644
+ }
645
+ return this.cachedEffectiveBalanceIncrementsZeroInactive;
642
646
  }
643
647
 
644
648
  getBalance(index: number): number {
@@ -336,8 +336,6 @@ export type IBeaconStateViewLatestFork = Omit<
336
336
  */
337
337
  export type IBeaconStateViewNative = Omit<
338
338
  IBeaconStateViewLatestFork,
339
- | "builderPendingPayments"
340
- | "builderPendingWithdrawals"
341
339
  | "computeAttestationsRewards"
342
340
  | "computeBlockRewards"
343
341
  | "computeNewStateRoot"
@@ -346,14 +344,10 @@ export type IBeaconStateViewNative = Omit<
346
344
  | "eth1Data"
347
345
  | "executionPayloadAvailability"
348
346
  | "getBeaconCommittee"
349
- | "getIndicesInPayloadTimelinessCommittee"
350
- | "getPayloadTimelinessCommittee"
351
347
  | "loadOtherState"
352
348
  | "pendingConsolidations"
353
349
  | "pendingDeposits"
354
350
  | "pendingPartialWithdrawals"
355
- | "preVerifyBuilderDepositsPreGloas"
356
- | "clearPreGloasBuilderDepositCache"
357
351
  | "processSlots"
358
352
  | "proposerLookahead"
359
353
  | "stateTransition"
@@ -365,7 +359,6 @@ export type IBeaconStateViewNative = Omit<
365
359
  pendingPartialWithdrawals: Uint8Array;
366
360
  pendingConsolidations: Uint8Array;
367
361
  proposerLookahead: Uint32Array;
368
- // UintBn64 lowers to number across the FFI boundary; the wrapper lifts it back to bigint
369
362
  eth1Data: phase0.Eth1Data;
370
363
  executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
371
364
  computeBlockRewards(
@@ -379,8 +372,6 @@ export type IBeaconStateViewNative = Omit<
379
372
  validatorIds: (ValidatorIndex | string)[]
380
373
  ): rewards.SyncCommitteeRewards;
381
374
  getBeaconCommittee(slot: Slot, index: CommitteeIndex): Uint32Array;
382
- getIndexInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number;
383
- getIndicesInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number[];
384
375
  loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
385
376
  stateTransition(
386
377
  signedBlockBytes: Uint8Array,
@@ -388,9 +379,7 @@ export type IBeaconStateViewNative = Omit<
388
379
  options?: StateTransitionOpts
389
380
  ): IBeaconStateViewNative;
390
381
  processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
391
- withParentPayloadApplied(
392
- ...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
393
- ): IBeaconStateViewNative;
382
+ withParentPayloadApplied(executionRequestsBytes: Uint8Array): IBeaconStateViewNative;
394
383
  };
395
384
 
396
385
  export function isStatePostAltair(state: IBeaconStateView): state is IBeaconStateViewAltair {