@lodestar/state-transition 1.48.0-dev.a427d3dbb5 → 1.48.0-dev.af8bc602aa

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 (64) hide show
  1. package/lib/block/index.d.ts.map +1 -1
  2. package/lib/block/index.js +11 -41
  3. package/lib/block/index.js.map +1 -1
  4. package/lib/block/processOperations.d.ts.map +1 -1
  5. package/lib/block/processOperations.js +33 -62
  6. package/lib/block/processOperations.js.map +1 -1
  7. package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
  8. package/lib/block/processParentExecutionPayload.js +15 -1
  9. package/lib/block/processParentExecutionPayload.js.map +1 -1
  10. package/lib/block/processPayloadAttestation.d.ts +1 -1
  11. package/lib/block/processPayloadAttestation.d.ts.map +1 -1
  12. package/lib/block/processPayloadAttestation.js +2 -2
  13. package/lib/block/processPayloadAttestation.js.map +1 -1
  14. package/lib/block/types.d.ts +0 -30
  15. package/lib/block/types.d.ts.map +1 -1
  16. package/lib/block/types.js +0 -32
  17. package/lib/block/types.js.map +1 -1
  18. package/lib/epoch/processPtcWindow.d.ts.map +1 -1
  19. package/lib/epoch/processPtcWindow.js +9 -12
  20. package/lib/epoch/processPtcWindow.js.map +1 -1
  21. package/lib/index.d.ts +1 -1
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +1 -1
  24. package/lib/index.js.map +1 -1
  25. package/lib/metrics.d.ts +1 -7
  26. package/lib/metrics.d.ts.map +1 -1
  27. package/lib/metrics.js +1 -12
  28. package/lib/metrics.js.map +1 -1
  29. package/lib/signatureSets/index.d.ts.map +1 -1
  30. package/lib/signatureSets/index.js +0 -8
  31. package/lib/signatureSets/index.js.map +1 -1
  32. package/lib/stateView/beaconStateView.d.ts +0 -4
  33. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  34. package/lib/stateView/beaconStateView.js +0 -9
  35. package/lib/stateView/beaconStateView.js.map +1 -1
  36. package/lib/stateView/interface.d.ts +0 -1
  37. package/lib/stateView/interface.d.ts.map +1 -1
  38. package/lib/stateView/interface.js.map +1 -1
  39. package/lib/stateView/nativeBeaconStateView.d.ts +0 -1
  40. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  41. package/lib/stateView/nativeBeaconStateView.js +0 -3
  42. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  43. package/lib/util/gloas.d.ts.map +1 -1
  44. package/lib/util/gloas.js +1 -1
  45. package/lib/util/gloas.js.map +1 -1
  46. package/lib/util/seed.d.ts +1 -1
  47. package/lib/util/seed.d.ts.map +1 -1
  48. package/lib/util/seed.js +11 -14
  49. package/lib/util/seed.js.map +1 -1
  50. package/package.json +8 -8
  51. package/src/block/index.ts +15 -48
  52. package/src/block/processOperations.ts +45 -63
  53. package/src/block/processParentExecutionPayload.ts +26 -1
  54. package/src/block/processPayloadAttestation.ts +2 -3
  55. package/src/block/types.ts +0 -32
  56. package/src/epoch/processPtcWindow.ts +8 -15
  57. package/src/index.ts +1 -1
  58. package/src/metrics.ts +2 -13
  59. package/src/signatureSets/index.ts +3 -17
  60. package/src/stateView/beaconStateView.ts +0 -12
  61. package/src/stateView/interface.ts +0 -1
  62. package/src/stateView/nativeBeaconStateView.ts +0 -4
  63. package/src/util/gloas.ts +0 -1
  64. package/src/util/seed.ts +13 -25
@@ -926,10 +926,6 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
926
926
  return cached;
927
927
  }
928
928
 
929
- getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
930
- return this.binding.getPayloadTimelinessCommittee(slot);
931
- }
932
-
933
929
  getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
934
930
  return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
935
931
  }
package/src/util/gloas.ts CHANGED
@@ -220,7 +220,6 @@ export function initializePtcWindow(state: CachedBeaconStateFulu): Uint32Array[]
220
220
  state,
221
221
  epoch,
222
222
  shuffling.committees,
223
- shuffling.shuffling,
224
223
  state.epochCtx.effectiveBalanceIncrements
225
224
  )
226
225
  );
package/src/util/seed.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {digest} from "@chainsafe/as-sha256";
2
- import {computePtcIndicesForEpoch} from "@chainsafe/lodestar-z/shuffle";
3
2
  import {
4
3
  computeProposerIndex as nativeComputeProposerIndex,
5
4
  computeSyncCommitteeIndices as nativeComputeSyncCommitteeIndices,
@@ -276,36 +275,25 @@ export function computePayloadTimelinessCommitteesForEpoch(
276
275
  state: BeaconStateAllForks,
277
276
  epoch: number,
278
277
  committees: Uint32Array[][],
279
- shuffling: Uint32Array,
280
278
  effectiveBalanceIncrements: EffectiveBalanceIncrements
281
279
  ): Uint32Array[] {
282
280
  const epochSeed = getSeed(state, epoch, DOMAIN_PTC_ATTESTER);
283
281
  const startSlot = epoch * SLOTS_PER_EPOCH;
284
- const slotOffsets = new Uint32Array(SLOTS_PER_EPOCH + 1);
285
- let shufflingLength = 0;
286
- for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
287
- slotOffsets[i] = shufflingLength;
288
- for (const committee of committees[i]) {
289
- shufflingLength += committee.length;
290
- }
291
- }
292
- slotOffsets[SLOTS_PER_EPOCH] = shufflingLength;
293
-
294
- // Native sampling returns all committees concatenated in slot order, with PTC_SIZE indices per slot.
295
- const flatPtcIndices = computePtcIndicesForEpoch(
296
- epochSeed,
297
- startSlot,
298
- SLOTS_PER_EPOCH,
299
- shuffling,
300
- slotOffsets,
301
- effectiveBalanceIncrements,
302
- PTC_SIZE,
303
- MAX_EFFECTIVE_BALANCE_ELECTRA,
304
- EFFECTIVE_BALANCE_INCREMENT
305
- );
306
282
  const result: Uint32Array[] = new Array(SLOTS_PER_EPOCH);
283
+
284
+ // Pre-allocate slot seed buffer once, reuse across all slots
285
+ const slotSeedInput = new Uint8Array(epochSeed.length + 8);
286
+ slotSeedInput.set(epochSeed, 0);
287
+ const slotSeedView = new DataView(slotSeedInput.buffer, slotSeedInput.byteOffset, slotSeedInput.byteLength);
288
+
307
289
  for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
308
- result[i] = flatPtcIndices.subarray(i * PTC_SIZE, (i + 1) * PTC_SIZE);
290
+ const slot = startSlot + i;
291
+ // Write slot as little-endian uint64 (fits in uint32 range)
292
+ slotSeedView.setUint32(epochSeed.length, slot, true);
293
+ slotSeedView.setUint32(epochSeed.length + 4, 0, true);
294
+ const slotSeed = digest(slotSeedInput);
295
+
296
+ result[i] = computePayloadTimelinessCommitteeForSlot(slotSeed, committees[i], effectiveBalanceIncrements);
309
297
  }
310
298
  return result;
311
299
  }