@lodestar/state-transition 1.51.0-dev.1b1888604e → 1.51.0-dev.1b22218e60

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 (140) 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/processDeposit.d.ts.map +1 -1
  6. package/lib/block/processDeposit.js +1 -1
  7. package/lib/block/processDeposit.js.map +1 -1
  8. package/lib/block/processOperations.d.ts +1 -1
  9. package/lib/block/processOperations.d.ts.map +1 -1
  10. package/lib/block/processOperations.js +1 -1
  11. package/lib/block/processOperations.js.map +1 -1
  12. package/lib/cache/epochCache.d.ts +2 -2
  13. package/lib/cache/epochCache.d.ts.map +1 -1
  14. package/lib/cache/epochCache.js +1 -1
  15. package/lib/cache/epochCache.js.map +1 -1
  16. package/lib/cache/syncCommitteeCache.d.ts +1 -1
  17. package/lib/cache/syncCommitteeCache.d.ts.map +1 -1
  18. package/lib/epoch/index.d.ts +2 -2
  19. package/lib/epoch/index.d.ts.map +1 -1
  20. package/lib/epoch/index.js +2 -2
  21. package/lib/epoch/index.js.map +1 -1
  22. package/lib/epoch/processSyncCommitteeUpdates.js +1 -1
  23. package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
  24. package/lib/lightClient/spec/store.d.ts +1 -1
  25. package/lib/lightClient/spec/store.d.ts.map +1 -1
  26. package/lib/lightClient/spec/utils.d.ts.map +1 -1
  27. package/lib/lightClient/spec/utils.js +1 -1
  28. package/lib/lightClient/spec/utils.js.map +1 -1
  29. package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -1
  30. package/lib/lightClient/spec/validateLightClientUpdate.js +1 -1
  31. package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -1
  32. package/lib/metrics.d.ts +1 -1
  33. package/lib/metrics.d.ts.map +1 -1
  34. package/lib/metrics.js +4 -4
  35. package/lib/metrics.js.map +1 -1
  36. package/lib/rewards/attestationsRewards.d.ts +1 -1
  37. package/lib/rewards/attestationsRewards.d.ts.map +1 -1
  38. package/lib/rewards/syncCommitteeRewards.d.ts +1 -1
  39. package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
  40. package/lib/signatureSets/inclusionList.d.ts +5 -0
  41. package/lib/signatureSets/inclusionList.d.ts.map +1 -0
  42. package/lib/signatureSets/inclusionList.js +14 -0
  43. package/lib/signatureSets/inclusionList.js.map +1 -0
  44. package/lib/signatureSets/index.d.ts +1 -0
  45. package/lib/signatureSets/index.d.ts.map +1 -1
  46. package/lib/signatureSets/index.js +1 -0
  47. package/lib/signatureSets/index.js.map +1 -1
  48. package/lib/stateTransition.js +2 -2
  49. package/lib/stateTransition.js.map +1 -1
  50. package/lib/stateView/beaconStateView.d.ts +1 -0
  51. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  52. package/lib/stateView/beaconStateView.js +5 -1
  53. package/lib/stateView/beaconStateView.js.map +1 -1
  54. package/lib/stateView/interface.d.ts +2 -4
  55. package/lib/stateView/interface.d.ts.map +1 -1
  56. package/lib/stateView/interface.js.map +1 -1
  57. package/lib/stateView/nativeBeaconStateView.d.ts +15 -7
  58. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  59. package/lib/stateView/nativeBeaconStateView.js +76 -26
  60. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  61. package/lib/stateView/stateViewFactory.d.ts.map +1 -1
  62. package/lib/stateView/stateViewFactory.js +5 -4
  63. package/lib/stateView/stateViewFactory.js.map +1 -1
  64. package/lib/testUtils/interopPubkeyCache.js +1 -1
  65. package/lib/testUtils/interopPubkeyCache.js.map +1 -1
  66. package/lib/testUtils/state.d.ts.map +1 -1
  67. package/lib/testUtils/state.js +1 -1
  68. package/lib/testUtils/state.js.map +1 -1
  69. package/lib/testUtils/util.d.ts +1 -1
  70. package/lib/testUtils/util.d.ts.map +1 -1
  71. package/lib/testUtils/util.js +2 -2
  72. package/lib/testUtils/util.js.map +1 -1
  73. package/lib/util/blindedBlock.d.ts.map +1 -1
  74. package/lib/util/blindedBlock.js +4 -12
  75. package/lib/util/blindedBlock.js.map +1 -1
  76. package/lib/util/epochShuffling.d.ts.map +1 -1
  77. package/lib/util/epochShuffling.js +1 -1
  78. package/lib/util/epochShuffling.js.map +1 -1
  79. package/lib/util/genesis.d.ts.map +1 -1
  80. package/lib/util/genesis.js +8 -1
  81. package/lib/util/genesis.js.map +1 -1
  82. package/lib/util/inclusionListCommittee.d.ts +9 -0
  83. package/lib/util/inclusionListCommittee.d.ts.map +1 -0
  84. package/lib/util/inclusionListCommittee.js +18 -0
  85. package/lib/util/inclusionListCommittee.js.map +1 -0
  86. package/lib/util/index.d.ts +1 -0
  87. package/lib/util/index.d.ts.map +1 -1
  88. package/lib/util/index.js +1 -0
  89. package/lib/util/index.js.map +1 -1
  90. package/lib/util/interop.d.ts +1 -1
  91. package/lib/util/interop.d.ts.map +1 -1
  92. package/lib/util/interop.js +1 -1
  93. package/lib/util/interop.js.map +1 -1
  94. package/lib/util/seed.js +1 -1
  95. package/lib/util/seed.js.map +1 -1
  96. package/lib/util/shuffling.d.ts +3 -0
  97. package/lib/util/shuffling.d.ts.map +1 -1
  98. package/lib/util/shuffling.js +41 -1
  99. package/lib/util/shuffling.js.map +1 -1
  100. package/lib/util/signatureSets.d.ts +1 -1
  101. package/lib/util/signatureSets.d.ts.map +1 -1
  102. package/lib/util/signatureSets.js +1 -1
  103. package/lib/util/signatureSets.js.map +1 -1
  104. package/lib/util/syncCommittee.d.ts.map +1 -1
  105. package/lib/util/syncCommittee.js +1 -1
  106. package/lib/util/syncCommittee.js.map +1 -1
  107. package/package.json +9 -9
  108. package/src/block/index.ts +11 -12
  109. package/src/block/processDeposit.ts +2 -2
  110. package/src/block/processOperations.ts +5 -5
  111. package/src/cache/epochCache.ts +2 -2
  112. package/src/cache/syncCommitteeCache.ts +1 -1
  113. package/src/epoch/index.ts +14 -15
  114. package/src/epoch/processSyncCommitteeUpdates.ts +1 -1
  115. package/src/lightClient/spec/store.ts +1 -1
  116. package/src/lightClient/spec/utils.ts +1 -1
  117. package/src/lightClient/spec/validateLightClientUpdate.ts +1 -1
  118. package/src/metrics.ts +5 -4
  119. package/src/rewards/attestationsRewards.ts +1 -1
  120. package/src/rewards/syncCommitteeRewards.ts +1 -1
  121. package/src/signatureSets/inclusionList.ts +20 -0
  122. package/src/signatureSets/index.ts +1 -0
  123. package/src/stateTransition.ts +2 -2
  124. package/src/stateView/beaconStateView.ts +5 -1
  125. package/src/stateView/interface.ts +1 -12
  126. package/src/stateView/nativeBeaconStateView.ts +77 -33
  127. package/src/stateView/stateViewFactory.ts +5 -4
  128. package/src/testUtils/interopPubkeyCache.ts +1 -1
  129. package/src/testUtils/state.ts +1 -1
  130. package/src/testUtils/util.ts +2 -2
  131. package/src/util/blindedBlock.ts +4 -12
  132. package/src/util/epochShuffling.ts +1 -1
  133. package/src/util/genesis.ts +9 -1
  134. package/src/util/inclusionListCommittee.ts +17 -0
  135. package/src/util/index.ts +1 -0
  136. package/src/util/interop.ts +1 -1
  137. package/src/util/seed.ts +1 -1
  138. package/src/util/shuffling.ts +46 -1
  139. package/src/util/signatureSets.ts +1 -1
  140. package/src/util/syncCommittee.ts +1 -1
@@ -0,0 +1,17 @@
1
+ import {ValidatorIndex} from "@lodestar/types";
2
+
3
+ /** Spec `InclusionListCommittee` of one slot */
4
+ export class InclusionListCommittee {
5
+ constructor(readonly validatorIndices: Uint32Array) {}
6
+
7
+ /** Positions of `validatorIndex`, several when the committee cycles over a slot with fewer validators than its size */
8
+ getCommitteeIndices(validatorIndex: ValidatorIndex): number[] {
9
+ const committeeIndices: number[] = [];
10
+ for (let i = 0; i < this.validatorIndices.length; i++) {
11
+ if (this.validatorIndices[i] === validatorIndex) {
12
+ committeeIndices.push(i);
13
+ }
14
+ }
15
+ return committeeIndices;
16
+ }
17
+ }
package/src/util/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from "./execution.js";
17
17
  export * from "./finality.js";
18
18
  export * from "./genesis.js";
19
19
  export * from "./gloas.js";
20
+ export * from "./inclusionListCommittee.js";
20
21
  export * from "./interop.js";
21
22
  export * from "./loadState/index.js";
22
23
  export * from "./pendingDepositsLookup.js";
@@ -1,6 +1,6 @@
1
1
  import {toBufferBE} from "@vekexasia/bigint-buffer2";
2
2
  import {digest} from "@chainsafe/as-sha256";
3
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
3
+ import {SecretKey} from "@lodestar/native/blst";
4
4
  import {bytesToBigInt, intToBytes} from "@lodestar/utils";
5
5
 
6
6
  let curveOrder: bigint;
package/src/util/seed.ts CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  computePtcIndicesForEpoch,
4
4
  computeProposerIndex as nativeComputeProposerIndex,
5
5
  computeSyncCommitteeIndices as nativeComputeSyncCommitteeIndices,
6
- } from "@chainsafe/lodestar-z/shuffle";
6
+ } from "@lodestar/native/shuffle";
7
7
  import {
8
8
  DOMAIN_BEACON_PROPOSER,
9
9
  DOMAIN_PTC_ATTESTER,
@@ -1,4 +1,4 @@
1
- import {ForkName, ForkSeq, SLOTS_PER_EPOCH, isForkPostFulu} from "@lodestar/params";
1
+ import {ForkName, ForkSeq, INCLUSION_LIST_COMMITTEE_SIZE, SLOTS_PER_EPOCH, isForkPostFulu} from "@lodestar/params";
2
2
  import {
3
3
  Attestation,
4
4
  CommitteeIndex,
@@ -15,6 +15,7 @@ import {IBeaconStateView} from "../stateView/interface.js";
15
15
  import {getBlockRootAtSlot} from "./blockRoot.js";
16
16
  import {computeStartSlotAtEpoch} from "./epoch.js";
17
17
  import {EpochShuffling} from "./epochShuffling.js";
18
+ import {InclusionListCommittee} from "./inclusionListCommittee.js";
18
19
 
19
20
  /**
20
21
  * Block root that decided the proposer shuffling for `proposalEpoch` (keys that shuffling).
@@ -196,6 +197,50 @@ export function getBeaconCommittee(epochShuffling: EpochShuffling, slot: Slot, i
196
197
  return getBeaconCommittees(epochShuffling, slot, [index])[0];
197
198
  }
198
199
 
200
+ /** Inclusion list committees of a shuffling by slot index, computed on first use and freed with the shuffling */
201
+ // TODO HEZE: replace this module-level map with an extended EpochShuffling tracked by the beacon-node ShufflingCache
202
+ const inclusionListCommitteesByShuffling = new WeakMap<EpochShuffling, InclusionListCommittee[]>();
203
+
204
+ /** Spec get_inclusion_list_committee: cycle over the slot's concatenated beacon committees */
205
+ export function getInclusionListCommittee(epochShuffling: EpochShuffling, slot: Slot): InclusionListCommittee {
206
+ let committees = inclusionListCommitteesByShuffling.get(epochShuffling);
207
+ if (committees === undefined) {
208
+ committees = [];
209
+ inclusionListCommitteesByShuffling.set(epochShuffling, committees);
210
+ }
211
+ const slotIndex = slot % SLOTS_PER_EPOCH;
212
+ let committee = committees[slotIndex];
213
+ if (committee === undefined) {
214
+ committee = new InclusionListCommittee(computeInclusionListCommittee(epochShuffling.committees[slotIndex]));
215
+ committees[slotIndex] = committee;
216
+ }
217
+ return committee;
218
+ }
219
+
220
+ function computeInclusionListCommittee(slotCommittees: Uint32Array[]): Uint32Array {
221
+ let totalLen = 0;
222
+ for (const committee of slotCommittees) {
223
+ totalLen += committee.length;
224
+ }
225
+
226
+ const result = new Uint32Array(INCLUSION_LIST_COMMITTEE_SIZE);
227
+ if (totalLen === 0) {
228
+ return result;
229
+ }
230
+
231
+ for (let i = 0; i < INCLUSION_LIST_COMMITTEE_SIZE; i++) {
232
+ let offset = i % totalLen;
233
+ for (const committee of slotCommittees) {
234
+ if (offset < committee.length) {
235
+ result[i] = committee[offset];
236
+ break;
237
+ }
238
+ offset -= committee.length;
239
+ }
240
+ }
241
+ return result;
242
+ }
243
+
199
244
  /**
200
245
  * Return a Uint32Array[] representing committees validator indices
201
246
  */
@@ -1,4 +1,4 @@
1
- import {BLS_VERIFIER_SET_TYPE, type BlsSignatureSet, verifySignatureSets} from "@chainsafe/lodestar-z/bls-verifier";
1
+ import {BLS_VERIFIER_SET_TYPE, type BlsSignatureSet, verifySignatureSets} from "@lodestar/native/bls-verifier";
2
2
  import {Root} from "@lodestar/types";
3
3
 
4
4
  export enum SignatureSetType {
@@ -1,5 +1,5 @@
1
- import {aggregateSerializedPublicKeys} from "@chainsafe/lodestar-z/blst";
2
1
  import {ChainConfig} from "@lodestar/config";
2
+ import {aggregateSerializedPublicKeys} from "@lodestar/native/blst";
3
3
  import {
4
4
  BASE_REWARD_FACTOR,
5
5
  EFFECTIVE_BALANCE_INCREMENT,