@lodestar/state-transition 1.42.0 → 1.43.0-dev.0bc48d3b54
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.
- package/lib/block/processDepositRequest.d.ts +11 -2
- package/lib/block/processDepositRequest.d.ts.map +1 -1
- package/lib/block/processDepositRequest.js +34 -4
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +7 -3
- package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
- package/lib/cache/epochCache.d.ts +3 -1
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +31 -13
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/epochTransitionCache.d.ts +5 -0
- package/lib/cache/epochTransitionCache.d.ts.map +1 -1
- package/lib/cache/epochTransitionCache.js +1 -0
- package/lib/cache/epochTransitionCache.js.map +1 -1
- package/lib/epoch/index.d.ts +3 -1
- package/lib/epoch/index.d.ts.map +1 -1
- package/lib/epoch/index.js +8 -1
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processPtcWindow.d.ts +11 -0
- package/lib/epoch/processPtcWindow.d.ts.map +1 -0
- package/lib/epoch/processPtcWindow.js +28 -0
- package/lib/epoch/processPtcWindow.js.map +1 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.js +4 -0
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +2 -2
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +4 -0
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +2 -1
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateTransition.d.ts +1 -2
- package/lib/stateTransition.d.ts.map +1 -1
- package/lib/stateTransition.js +1 -2
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +10 -10
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +37 -34
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +103 -52
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js +22 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/util/attestation.d.ts +12 -1
- package/lib/util/attestation.d.ts.map +1 -1
- package/lib/util/attestation.js +23 -8
- package/lib/util/attestation.js.map +1 -1
- package/lib/util/execution.d.ts +4 -2
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -0
- package/lib/util/execution.js.map +1 -1
- package/lib/util/gloas.d.ts +7 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +26 -1
- package/lib/util/gloas.js.map +1 -1
- package/package.json +8 -8
- package/src/block/processDepositRequest.ts +50 -5
- package/src/block/processExecutionPayloadEnvelope.ts +8 -3
- package/src/cache/epochCache.ts +32 -30
- package/src/cache/epochTransitionCache.ts +7 -0
- package/src/epoch/index.ts +9 -0
- package/src/epoch/processPtcWindow.ts +38 -0
- package/src/index.ts +20 -2
- package/src/signatureSets/executionPayloadEnvelope.ts +5 -1
- package/src/signatureSets/voluntaryExits.ts +5 -2
- package/src/slot/upgradeStateToGloas.ts +2 -1
- package/src/stateTransition.ts +1 -2
- package/src/stateView/beaconStateView.ts +57 -41
- package/src/stateView/interface.ts +155 -74
- package/src/util/attestation.ts +37 -8
- package/src/util/execution.ts +11 -1
- package/src/util/gloas.ts +48 -1
package/src/util/gloas.ts
CHANGED
|
@@ -6,15 +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 {CachedBeaconStateGloas} from "../types.js";
|
|
16
|
+
import {CachedBeaconStateFulu, CachedBeaconStateGloas} from "../types.js";
|
|
15
17
|
import {getBlockRootAtSlot} from "./blockRoot.js";
|
|
16
18
|
import {computeEpochAtSlot} from "./epoch.js";
|
|
19
|
+
import {computeEpochShuffling} from "./epochShuffling.js";
|
|
17
20
|
import {RootCache} from "./rootCache.js";
|
|
21
|
+
import {computePayloadTimelinessCommitteesForEpoch} from "./seed.js";
|
|
22
|
+
import {getActiveValidatorIndices} from "./validator.js";
|
|
18
23
|
|
|
19
24
|
export function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean {
|
|
20
25
|
return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
|
|
@@ -170,3 +175,45 @@ export function isAttestationSameSlotRootCache(rootCache: RootCache, data: Attes
|
|
|
170
175
|
export function isParentBlockFull(state: CachedBeaconStateGloas): boolean {
|
|
171
176
|
return byteArrayEquals(state.latestExecutionPayloadBid.blockHash, state.latestBlockHash);
|
|
172
177
|
}
|
|
178
|
+
|
|
179
|
+
export function initializePtcWindow(state: CachedBeaconStateFulu): Uint32Array[] {
|
|
180
|
+
const ptcWindow: Uint32Array[] = Array.from({length: SLOTS_PER_EPOCH}, () => new Uint32Array(PTC_SIZE));
|
|
181
|
+
const currentEpoch = state.epochCtx.epoch;
|
|
182
|
+
|
|
183
|
+
for (let epochOffset = 0; epochOffset <= MIN_SEED_LOOKAHEAD; epochOffset++) {
|
|
184
|
+
const epoch = currentEpoch + epochOffset;
|
|
185
|
+
const shuffling =
|
|
186
|
+
state.epochCtx.getShufflingAtEpochOrNull(epoch) ??
|
|
187
|
+
computeEpochShuffling(state, getActiveValidatorIndices(state, epoch), epoch);
|
|
188
|
+
|
|
189
|
+
ptcWindow.push(
|
|
190
|
+
...computePayloadTimelinessCommitteesForEpoch(
|
|
191
|
+
state,
|
|
192
|
+
epoch,
|
|
193
|
+
shuffling.committees,
|
|
194
|
+
state.epochCtx.effectiveBalanceIncrements
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return ptcWindow;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function getPtcWindowEpochCacheData(state: CachedBeaconStateGloas): {
|
|
203
|
+
previousPayloadTimelinessCommittees: Uint32Array[];
|
|
204
|
+
payloadTimelinessCommittees: Uint32Array[];
|
|
205
|
+
nextPayloadTimelinessCommittees: Uint32Array[];
|
|
206
|
+
} {
|
|
207
|
+
const toUint32Arrays = (views: ReturnType<typeof state.ptcWindow.getReadonlyByRange>) =>
|
|
208
|
+
views.map((v) => Uint32Array.from(v.getAll()));
|
|
209
|
+
|
|
210
|
+
const previousPtcWindow = state.ptcWindow.getReadonlyByRange(0, SLOTS_PER_EPOCH);
|
|
211
|
+
const currentPtcWindow = state.ptcWindow.getReadonlyByRange(SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
212
|
+
const nextPtcWindow = state.ptcWindow.getReadonlyByRange(2 * SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
previousPayloadTimelinessCommittees: toUint32Arrays(previousPtcWindow),
|
|
216
|
+
payloadTimelinessCommittees: toUint32Arrays(currentPtcWindow),
|
|
217
|
+
nextPayloadTimelinessCommittees: toUint32Arrays(nextPtcWindow),
|
|
218
|
+
};
|
|
219
|
+
}
|