@lodestar/state-transition 1.43.0-dev.aef3645690 → 1.43.0-dev.ca1fc40294

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 (56) hide show
  1. package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
  2. package/lib/block/processExecutionPayloadEnvelope.js +4 -7
  3. package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
  4. package/lib/cache/epochCache.d.ts +3 -1
  5. package/lib/cache/epochCache.d.ts.map +1 -1
  6. package/lib/cache/epochCache.js +31 -13
  7. package/lib/cache/epochCache.js.map +1 -1
  8. package/lib/cache/epochTransitionCache.d.ts +5 -0
  9. package/lib/cache/epochTransitionCache.d.ts.map +1 -1
  10. package/lib/cache/epochTransitionCache.js +1 -0
  11. package/lib/cache/epochTransitionCache.js.map +1 -1
  12. package/lib/epoch/index.d.ts +3 -1
  13. package/lib/epoch/index.d.ts.map +1 -1
  14. package/lib/epoch/index.js +8 -1
  15. package/lib/epoch/index.js.map +1 -1
  16. package/lib/epoch/processPtcWindow.d.ts +11 -0
  17. package/lib/epoch/processPtcWindow.d.ts.map +1 -0
  18. package/lib/epoch/processPtcWindow.js +28 -0
  19. package/lib/epoch/processPtcWindow.js.map +1 -0
  20. package/lib/signatureSets/executionPayloadEnvelope.js +1 -1
  21. package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
  22. package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
  23. package/lib/slot/upgradeStateToGloas.js +2 -1
  24. package/lib/slot/upgradeStateToGloas.js.map +1 -1
  25. package/lib/stateTransition.d.ts +1 -2
  26. package/lib/stateTransition.d.ts.map +1 -1
  27. package/lib/stateTransition.js +1 -2
  28. package/lib/stateTransition.js.map +1 -1
  29. package/lib/stateView/beaconStateView.d.ts +4 -8
  30. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  31. package/lib/stateView/beaconStateView.js +19 -29
  32. package/lib/stateView/beaconStateView.js.map +1 -1
  33. package/lib/stateView/interface.d.ts +13 -9
  34. package/lib/stateView/interface.d.ts.map +1 -1
  35. package/lib/stateView/interface.js.map +1 -1
  36. package/lib/util/execution.d.ts +4 -2
  37. package/lib/util/execution.d.ts.map +1 -1
  38. package/lib/util/execution.js +7 -0
  39. package/lib/util/execution.js.map +1 -1
  40. package/lib/util/gloas.d.ts +8 -3
  41. package/lib/util/gloas.d.ts.map +1 -1
  42. package/lib/util/gloas.js +27 -1
  43. package/lib/util/gloas.js.map +1 -1
  44. package/package.json +8 -8
  45. package/src/block/processExecutionPayloadEnvelope.ts +4 -10
  46. package/src/cache/epochCache.ts +32 -30
  47. package/src/cache/epochTransitionCache.ts +7 -0
  48. package/src/epoch/index.ts +9 -0
  49. package/src/epoch/processPtcWindow.ts +38 -0
  50. package/src/signatureSets/executionPayloadEnvelope.ts +1 -1
  51. package/src/slot/upgradeStateToGloas.ts +2 -1
  52. package/src/stateTransition.ts +1 -2
  53. package/src/stateView/beaconStateView.ts +31 -33
  54. package/src/stateView/interface.ts +20 -9
  55. package/src/util/execution.ts +11 -1
  56. package/src/util/gloas.ts +50 -3
package/src/util/gloas.ts CHANGED
@@ -6,16 +6,20 @@ import {
6
6
  EFFECTIVE_BALANCE_INCREMENT,
7
7
  FAR_FUTURE_EPOCH,
8
8
  MIN_DEPOSIT_AMOUNT,
9
+ MIN_SEED_LOOKAHEAD,
10
+ PTC_SIZE,
9
11
  SLOTS_PER_EPOCH,
10
12
  } from "@lodestar/params";
11
13
  import {BuilderIndex, Epoch, ValidatorIndex, gloas} from "@lodestar/types";
12
14
  import {AttestationData} from "@lodestar/types/phase0";
13
15
  import {byteArrayEquals} from "@lodestar/utils";
14
- import {IBeaconStateViewGloas} from "../stateView/interface.js";
15
- import {CachedBeaconStateGloas} from "../types.js";
16
+ import {CachedBeaconStateFulu, CachedBeaconStateGloas} from "../types.js";
16
17
  import {getBlockRootAtSlot} from "./blockRoot.js";
17
18
  import {computeEpochAtSlot} from "./epoch.js";
19
+ import {computeEpochShuffling} from "./epochShuffling.js";
18
20
  import {RootCache} from "./rootCache.js";
21
+ import {computePayloadTimelinessCommitteesForEpoch} from "./seed.js";
22
+ import {getActiveValidatorIndices} from "./validator.js";
19
23
 
20
24
  export function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean {
21
25
  return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
@@ -168,6 +172,49 @@ export function isAttestationSameSlotRootCache(rootCache: RootCache, data: Attes
168
172
  return isMatchingBlockRoot && isCurrentBlockRoot;
169
173
  }
170
174
 
171
- export function isParentBlockFull(state: CachedBeaconStateGloas | IBeaconStateViewGloas): boolean {
175
+ // TODO GLOAS: This function no longer exists in v1.7.0-alpha.5 specs. Remove it when appropriate to do so
176
+ export function isParentBlockFull(state: CachedBeaconStateGloas): boolean {
172
177
  return byteArrayEquals(state.latestExecutionPayloadBid.blockHash, state.latestBlockHash);
173
178
  }
179
+
180
+ export function initializePtcWindow(state: CachedBeaconStateFulu): Uint32Array[] {
181
+ const ptcWindow: Uint32Array[] = Array.from({length: SLOTS_PER_EPOCH}, () => new Uint32Array(PTC_SIZE));
182
+ const currentEpoch = state.epochCtx.epoch;
183
+
184
+ for (let epochOffset = 0; epochOffset <= MIN_SEED_LOOKAHEAD; epochOffset++) {
185
+ const epoch = currentEpoch + epochOffset;
186
+ const shuffling =
187
+ state.epochCtx.getShufflingAtEpochOrNull(epoch) ??
188
+ computeEpochShuffling(state, getActiveValidatorIndices(state, epoch), epoch);
189
+
190
+ ptcWindow.push(
191
+ ...computePayloadTimelinessCommitteesForEpoch(
192
+ state,
193
+ epoch,
194
+ shuffling.committees,
195
+ state.epochCtx.effectiveBalanceIncrements
196
+ )
197
+ );
198
+ }
199
+
200
+ return ptcWindow;
201
+ }
202
+
203
+ export function getPtcWindowEpochCacheData(state: CachedBeaconStateGloas): {
204
+ previousPayloadTimelinessCommittees: Uint32Array[];
205
+ payloadTimelinessCommittees: Uint32Array[];
206
+ nextPayloadTimelinessCommittees: Uint32Array[];
207
+ } {
208
+ const toUint32Arrays = (views: ReturnType<typeof state.ptcWindow.getReadonlyByRange>) =>
209
+ views.map((v) => Uint32Array.from(v.getAll()));
210
+
211
+ const previousPtcWindow = state.ptcWindow.getReadonlyByRange(0, SLOTS_PER_EPOCH);
212
+ const currentPtcWindow = state.ptcWindow.getReadonlyByRange(SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
213
+ const nextPtcWindow = state.ptcWindow.getReadonlyByRange(2 * SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
214
+
215
+ return {
216
+ previousPayloadTimelinessCommittees: toUint32Arrays(previousPtcWindow),
217
+ payloadTimelinessCommittees: toUint32Arrays(currentPtcWindow),
218
+ nextPayloadTimelinessCommittees: toUint32Arrays(nextPtcWindow),
219
+ };
220
+ }