@lodestar/state-transition 1.51.0-dev.c99cf49add → 1.51.0-dev.cda05d18f1
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 +1 -1
- package/lib/block/index.d.ts.map +1 -1
- package/lib/block/index.js +2 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/processDeposit.d.ts.map +1 -1
- package/lib/block/processDeposit.js +1 -1
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processOperations.d.ts +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +1 -1
- package/lib/block/processOperations.js.map +1 -1
- package/lib/cache/epochCache.d.ts +2 -2
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +1 -1
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/syncCommitteeCache.d.ts +1 -1
- package/lib/cache/syncCommitteeCache.d.ts.map +1 -1
- package/lib/epoch/index.d.ts +2 -2
- package/lib/epoch/index.d.ts.map +1 -1
- package/lib/epoch/index.js +2 -2
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
- package/lib/lightClient/spec/store.d.ts +1 -1
- package/lib/lightClient/spec/store.d.ts.map +1 -1
- package/lib/lightClient/spec/utils.d.ts.map +1 -1
- package/lib/lightClient/spec/utils.js +1 -1
- package/lib/lightClient/spec/utils.js.map +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.js +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -1
- package/lib/metrics.d.ts +1 -1
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +4 -4
- package/lib/metrics.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts +1 -1
- package/lib/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
- package/lib/signatureSets/inclusionList.d.ts +5 -0
- package/lib/signatureSets/inclusionList.d.ts.map +1 -0
- package/lib/signatureSets/inclusionList.js +14 -0
- package/lib/signatureSets/inclusionList.js.map +1 -0
- package/lib/signatureSets/index.d.ts +1 -0
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/stateTransition.js +2 -2
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +1 -0
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +5 -1
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +2 -4
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +15 -7
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +76 -26
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +5 -4
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/testUtils/interopPubkeyCache.js +1 -1
- package/lib/testUtils/interopPubkeyCache.js.map +1 -1
- package/lib/testUtils/state.d.ts.map +1 -1
- package/lib/testUtils/state.js +1 -1
- package/lib/testUtils/state.js.map +1 -1
- package/lib/testUtils/util.d.ts +1 -1
- package/lib/testUtils/util.d.ts.map +1 -1
- package/lib/testUtils/util.js +2 -2
- package/lib/testUtils/util.js.map +1 -1
- package/lib/util/blindedBlock.d.ts.map +1 -1
- package/lib/util/blindedBlock.js +4 -12
- package/lib/util/blindedBlock.js.map +1 -1
- package/lib/util/epochShuffling.d.ts.map +1 -1
- package/lib/util/epochShuffling.js +1 -1
- package/lib/util/epochShuffling.js.map +1 -1
- package/lib/util/genesis.d.ts.map +1 -1
- package/lib/util/genesis.js +8 -1
- package/lib/util/genesis.js.map +1 -1
- package/lib/util/inclusionListCommittee.d.ts +9 -0
- package/lib/util/inclusionListCommittee.d.ts.map +1 -0
- package/lib/util/inclusionListCommittee.js +18 -0
- package/lib/util/inclusionListCommittee.js.map +1 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/interop.d.ts +1 -1
- package/lib/util/interop.d.ts.map +1 -1
- package/lib/util/interop.js +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/seed.js +1 -1
- package/lib/util/seed.js.map +1 -1
- package/lib/util/shuffling.d.ts +3 -0
- package/lib/util/shuffling.d.ts.map +1 -1
- package/lib/util/shuffling.js +41 -1
- package/lib/util/shuffling.js.map +1 -1
- package/lib/util/signatureSets.d.ts +1 -1
- package/lib/util/signatureSets.d.ts.map +1 -1
- package/lib/util/signatureSets.js +1 -1
- package/lib/util/signatureSets.js.map +1 -1
- package/lib/util/syncCommittee.d.ts.map +1 -1
- package/lib/util/syncCommittee.js +1 -1
- package/lib/util/syncCommittee.js.map +1 -1
- package/package.json +9 -9
- package/src/block/index.ts +11 -12
- package/src/block/processDeposit.ts +2 -2
- package/src/block/processOperations.ts +5 -5
- package/src/cache/epochCache.ts +2 -2
- package/src/cache/syncCommitteeCache.ts +1 -1
- package/src/epoch/index.ts +14 -15
- package/src/epoch/processSyncCommitteeUpdates.ts +1 -1
- package/src/lightClient/spec/store.ts +1 -1
- package/src/lightClient/spec/utils.ts +1 -1
- package/src/lightClient/spec/validateLightClientUpdate.ts +1 -1
- package/src/metrics.ts +5 -4
- package/src/rewards/attestationsRewards.ts +1 -1
- package/src/rewards/syncCommitteeRewards.ts +1 -1
- package/src/signatureSets/inclusionList.ts +20 -0
- package/src/signatureSets/index.ts +1 -0
- package/src/stateTransition.ts +2 -2
- package/src/stateView/beaconStateView.ts +5 -1
- package/src/stateView/interface.ts +1 -12
- package/src/stateView/nativeBeaconStateView.ts +77 -33
- package/src/stateView/stateViewFactory.ts +5 -4
- package/src/testUtils/interopPubkeyCache.ts +1 -1
- package/src/testUtils/state.ts +1 -1
- package/src/testUtils/util.ts +2 -2
- package/src/util/blindedBlock.ts +4 -12
- package/src/util/epochShuffling.ts +1 -1
- package/src/util/genesis.ts +9 -1
- package/src/util/inclusionListCommittee.ts +17 -0
- package/src/util/index.ts +1 -0
- package/src/util/interop.ts +1 -1
- package/src/util/seed.ts +1 -1
- package/src/util/shuffling.ts +46 -1
- package/src/util/signatureSets.ts +1 -1
- 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";
|
package/src/util/interop.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {toBufferBE} from "@vekexasia/bigint-buffer2";
|
|
2
2
|
import {digest} from "@chainsafe/as-sha256";
|
|
3
|
-
import {SecretKey} from "@
|
|
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 "@
|
|
6
|
+
} from "@lodestar/native/shuffle";
|
|
7
7
|
import {
|
|
8
8
|
DOMAIN_BEACON_PROPOSER,
|
|
9
9
|
DOMAIN_PTC_ATTESTER,
|
package/src/util/shuffling.ts
CHANGED
|
@@ -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 "@
|
|
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 {
|