@lodestar/state-transition 1.48.0-dev.df6a2aa429 → 1.48.0-dev.e17b11435f
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/index.d.ts.map +1 -1
- package/lib/block/index.js +41 -11
- package/lib/block/index.js.map +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +62 -33
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +1 -15
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/block/processPayloadAttestation.d.ts +1 -1
- package/lib/block/processPayloadAttestation.d.ts.map +1 -1
- package/lib/block/processPayloadAttestation.js +2 -2
- package/lib/block/processPayloadAttestation.js.map +1 -1
- package/lib/block/types.d.ts +30 -0
- package/lib/block/types.d.ts.map +1 -1
- package/lib/block/types.js +32 -0
- package/lib/block/types.js.map +1 -1
- package/lib/epoch/processPtcWindow.d.ts.map +1 -1
- package/lib/epoch/processPtcWindow.js +12 -9
- package/lib/epoch/processPtcWindow.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics.d.ts +7 -1
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +12 -1
- package/lib/metrics.js.map +1 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +8 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +4 -0
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +9 -0
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +1 -0
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +1 -0
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +3 -0
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +1 -1
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/seed.d.ts +1 -1
- package/lib/util/seed.d.ts.map +1 -1
- package/lib/util/seed.js +14 -11
- package/lib/util/seed.js.map +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +48 -15
- package/src/block/processOperations.ts +63 -45
- package/src/block/processParentExecutionPayload.ts +1 -26
- package/src/block/processPayloadAttestation.ts +3 -2
- package/src/block/types.ts +32 -0
- package/src/epoch/processPtcWindow.ts +15 -8
- package/src/index.ts +1 -1
- package/src/metrics.ts +13 -2
- package/src/signatureSets/index.ts +17 -3
- package/src/stateView/beaconStateView.ts +12 -0
- package/src/stateView/interface.ts +1 -0
- package/src/stateView/nativeBeaconStateView.ts +4 -0
- package/src/util/gloas.ts +1 -0
- package/src/util/seed.ts +25 -13
|
@@ -926,6 +926,10 @@ 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
|
+
|
|
929
933
|
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
|
|
930
934
|
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
931
935
|
}
|
package/src/util/gloas.ts
CHANGED
package/src/util/seed.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {digest} from "@chainsafe/as-sha256";
|
|
2
|
+
import {computePtcIndicesForEpoch} from "@chainsafe/lodestar-z/shuffle";
|
|
2
3
|
import {
|
|
3
4
|
computeProposerIndex as nativeComputeProposerIndex,
|
|
4
5
|
computeSyncCommitteeIndices as nativeComputeSyncCommitteeIndices,
|
|
@@ -275,25 +276,36 @@ export function computePayloadTimelinessCommitteesForEpoch(
|
|
|
275
276
|
state: BeaconStateAllForks,
|
|
276
277
|
epoch: number,
|
|
277
278
|
committees: Uint32Array[][],
|
|
279
|
+
shuffling: Uint32Array,
|
|
278
280
|
effectiveBalanceIncrements: EffectiveBalanceIncrements
|
|
279
281
|
): Uint32Array[] {
|
|
280
282
|
const epochSeed = getSeed(state, epoch, DOMAIN_PTC_ATTESTER);
|
|
281
283
|
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
|
+
);
|
|
282
306
|
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
|
-
|
|
289
307
|
for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
|
|
290
|
-
|
|
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);
|
|
308
|
+
result[i] = flatPtcIndices.subarray(i * PTC_SIZE, (i + 1) * PTC_SIZE);
|
|
297
309
|
}
|
|
298
310
|
return result;
|
|
299
311
|
}
|