@lodestar/state-transition 1.43.0-dev.4358217e12 → 1.43.0-dev.4451fec75a

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 (79) hide show
  1. package/lib/block/processConsolidationRequest.d.ts.map +1 -1
  2. package/lib/block/processConsolidationRequest.js +2 -1
  3. package/lib/block/processConsolidationRequest.js.map +1 -1
  4. package/lib/block/processParentExecutionPayload.d.ts +2 -2
  5. package/lib/block/processParentExecutionPayload.js +3 -3
  6. package/lib/block/processWithdrawals.d.ts.map +1 -1
  7. package/lib/block/processWithdrawals.js +2 -4
  8. package/lib/block/processWithdrawals.js.map +1 -1
  9. package/lib/cache/epochCache.js +3 -3
  10. package/lib/cache/epochCache.js.map +1 -1
  11. package/lib/epoch/processPendingDeposits.d.ts.map +1 -1
  12. package/lib/epoch/processPendingDeposits.js +4 -2
  13. package/lib/epoch/processPendingDeposits.js.map +1 -1
  14. package/lib/lightClient/spec/index.d.ts +22 -0
  15. package/lib/lightClient/spec/index.d.ts.map +1 -0
  16. package/lib/lightClient/spec/index.js +58 -0
  17. package/lib/lightClient/spec/index.js.map +1 -0
  18. package/lib/lightClient/spec/isBetterUpdate.d.ts +23 -0
  19. package/lib/lightClient/spec/isBetterUpdate.d.ts.map +1 -0
  20. package/lib/lightClient/spec/isBetterUpdate.js +66 -0
  21. package/lib/lightClient/spec/isBetterUpdate.js.map +1 -0
  22. package/lib/lightClient/spec/processLightClientUpdate.d.ts +12 -0
  23. package/lib/lightClient/spec/processLightClientUpdate.d.ts.map +1 -0
  24. package/lib/lightClient/spec/processLightClientUpdate.js +80 -0
  25. package/lib/lightClient/spec/processLightClientUpdate.js.map +1 -0
  26. package/lib/lightClient/spec/store.d.ts +45 -0
  27. package/lib/lightClient/spec/store.d.ts.map +1 -0
  28. package/lib/lightClient/spec/store.js +56 -0
  29. package/lib/lightClient/spec/store.js.map +1 -0
  30. package/lib/lightClient/spec/utils.d.ts +47 -0
  31. package/lib/lightClient/spec/utils.d.ts.map +1 -0
  32. package/lib/lightClient/spec/utils.js +197 -0
  33. package/lib/lightClient/spec/utils.js.map +1 -0
  34. package/lib/lightClient/spec/validateLightClientBootstrap.d.ts +4 -0
  35. package/lib/lightClient/spec/validateLightClientBootstrap.d.ts.map +1 -0
  36. package/lib/lightClient/spec/validateLightClientBootstrap.js +22 -0
  37. package/lib/lightClient/spec/validateLightClientBootstrap.js.map +1 -0
  38. package/lib/lightClient/spec/validateLightClientUpdate.d.ts +5 -0
  39. package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -0
  40. package/lib/lightClient/spec/validateLightClientUpdate.js +88 -0
  41. package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -0
  42. package/lib/slot/upgradeStateToElectra.d.ts.map +1 -1
  43. package/lib/slot/upgradeStateToElectra.js +2 -2
  44. package/lib/slot/upgradeStateToElectra.js.map +1 -1
  45. package/lib/stateView/beaconStateView.d.ts +14 -5
  46. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  47. package/lib/stateView/beaconStateView.js +40 -11
  48. package/lib/stateView/beaconStateView.js.map +1 -1
  49. package/lib/stateView/interface.d.ts +7 -5
  50. package/lib/stateView/interface.d.ts.map +1 -1
  51. package/lib/stateView/interface.js.map +1 -1
  52. package/lib/util/epoch.d.ts.map +1 -1
  53. package/lib/util/epoch.js +6 -4
  54. package/lib/util/epoch.js.map +1 -1
  55. package/lib/util/loadState/loadState.js +4 -4
  56. package/lib/util/loadState/loadState.js.map +1 -1
  57. package/lib/util/validator.d.ts +14 -2
  58. package/lib/util/validator.d.ts.map +1 -1
  59. package/lib/util/validator.js +24 -2
  60. package/lib/util/validator.js.map +1 -1
  61. package/package.json +13 -8
  62. package/src/block/processConsolidationRequest.ts +2 -1
  63. package/src/block/processParentExecutionPayload.ts +3 -3
  64. package/src/block/processWithdrawals.ts +2 -4
  65. package/src/cache/epochCache.ts +3 -3
  66. package/src/epoch/processPendingDeposits.ts +5 -2
  67. package/src/lightClient/spec/index.ts +101 -0
  68. package/src/lightClient/spec/isBetterUpdate.ts +94 -0
  69. package/src/lightClient/spec/processLightClientUpdate.ts +119 -0
  70. package/src/lightClient/spec/store.ts +106 -0
  71. package/src/lightClient/spec/utils.ts +317 -0
  72. package/src/lightClient/spec/validateLightClientBootstrap.ts +39 -0
  73. package/src/lightClient/spec/validateLightClientUpdate.ts +145 -0
  74. package/src/slot/upgradeStateToElectra.ts +4 -2
  75. package/src/stateView/beaconStateView.ts +43 -12
  76. package/src/stateView/interface.ts +7 -5
  77. package/src/util/epoch.ts +13 -4
  78. package/src/util/loadState/loadState.ts +4 -4
  79. package/src/util/validator.ts +42 -2
@@ -110,8 +110,8 @@ function loadInactivityScores(
110
110
  seedState: BeaconStateAltair,
111
111
  inactivityScoresBytes: Uint8Array
112
112
  ): void {
113
- // migratedState starts with the same inactivityScores to seed state
114
- migratedState.inactivityScores = seedState.inactivityScores.clone();
113
+ // true = do not transfer cache
114
+ migratedState.inactivityScores = seedState.inactivityScores.clone(true);
115
115
  const oldValidator = migratedState.inactivityScores.length;
116
116
  // UintNum64 = 8 bytes
117
117
  const newValidator = inactivityScoresBytes.length / 8;
@@ -187,8 +187,8 @@ function loadValidators(
187
187
  const newValidatorCount = Math.floor(newValidatorsBytes.length / VALIDATOR_BYTES_SIZE);
188
188
  const isMoreValidator = newValidatorCount >= seedValidatorCount;
189
189
  const minValidatorCount = Math.min(seedValidatorCount, newValidatorCount);
190
- // migrated state starts with the same validators to seed state
191
- migratedState.validators = seedState.validators.clone();
190
+ // true = do not transfer cache
191
+ migratedState.validators = seedState.validators.clone(true);
192
192
  // 80% of validators serialization time comes from memory allocation
193
193
  // seedStateValidatorsBytes is an optimization at beacon-node side to avoid memory allocation here
194
194
  const seedValidatorsBytes = seedStateValidatorsBytes ?? seedState.validators.serialize();
@@ -44,7 +44,12 @@ export function getActiveValidatorIndices(state: BeaconStateAllForks, epoch: Epo
44
44
  return new Uint32Array(indices);
45
45
  }
46
46
 
47
- export function getActivationChurnLimit(config: ChainForkConfig, fork: ForkSeq, activeValidatorCount: number): number {
47
+ // Deneb fork upgrade only
48
+ export function getValidatorActivationChurnLimit(
49
+ config: ChainForkConfig,
50
+ fork: ForkSeq,
51
+ activeValidatorCount: number
52
+ ): number {
48
53
  if (fork >= ForkSeq.deneb) {
49
54
  return Math.min(config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, getChurnLimit(config, activeValidatorCount));
50
55
  }
@@ -84,7 +89,42 @@ export function getActivationExitChurnLimit(epochCtx: EpochCache): number {
84
89
  return Math.min(epochCtx.config.MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT, getBalanceChurnLimitFromCache(epochCtx));
85
90
  }
86
91
 
87
- export function getConsolidationChurnLimit(epochCtx: EpochCache): number {
92
+ /**
93
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_activation_churn_limit
94
+ */
95
+ export function getActivationChurnLimit(epochCtx: EpochCache): number {
96
+ const churn = getBalanceChurnLimit(
97
+ epochCtx.totalActiveBalanceIncrements,
98
+ epochCtx.config.CHURN_LIMIT_QUOTIENT_GLOAS,
99
+ epochCtx.config.MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA
100
+ );
101
+ return Math.min(epochCtx.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS, churn);
102
+ }
103
+
104
+ /**
105
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_exit_churn_limit
106
+ */
107
+ export function getExitChurnLimit(epochCtx: EpochCache): number {
108
+ return getBalanceChurnLimit(
109
+ epochCtx.totalActiveBalanceIncrements,
110
+ epochCtx.config.CHURN_LIMIT_QUOTIENT_GLOAS,
111
+ epochCtx.config.MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Spec (electra): get_consolidation_churn_limit (uses combined balance churn minus activation+exit churn)
117
+ * Spec (gloas): get_consolidation_churn_limit (independent quotient, no MIN floor)
118
+ */
119
+ export function getConsolidationChurnLimit(fork: ForkSeq, epochCtx: EpochCache): number {
120
+ if (fork >= ForkSeq.gloas) {
121
+ // No MIN floor — pass 0 so getBalanceChurnLimit's max(churn, min) is a no-op.
122
+ return getBalanceChurnLimit(
123
+ epochCtx.totalActiveBalanceIncrements,
124
+ epochCtx.config.CONSOLIDATION_CHURN_LIMIT_QUOTIENT,
125
+ 0
126
+ );
127
+ }
88
128
  return getBalanceChurnLimitFromCache(epochCtx) - getActivationExitChurnLimit(epochCtx);
89
129
  }
90
130