|
1 | 1 | import {afterEach, beforeEach, describe, expect, it} from "vitest"; |
2 | | -import {aggregateSerializedPublicKeys} from "@chainsafe/blst"; |
3 | 2 | import {HttpHeader, getClient, routes} from "@lodestar/api"; |
4 | 3 | import {ChainConfig, createBeaconConfig} from "@lodestar/config"; |
5 | | -import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params"; |
| 4 | +import {ForkName} from "@lodestar/params"; |
6 | 5 | import {phase0, ssz} from "@lodestar/types"; |
7 | 6 | import {sleep} from "@lodestar/utils"; |
8 | 7 | import {Validator} from "@lodestar/validator"; |
@@ -119,29 +118,19 @@ describe("lightclient api", () => { |
119 | 118 | expect(finalityUpdate).toBeDefined(); |
120 | 119 | }); |
121 | 120 |
|
122 | | - it.skip("getLightClientCommitteeRoot() for the 1st period", async () => { |
123 | | - // need to investigate why this test fails after upgrading to electra |
124 | | - // TODO: https://github.com/ChainSafe/lodestar/issues/8723 |
| 121 | + it("getLightClientCommitteeRoot() for the 1st period", async () => { |
125 | 122 | await waitForBestUpdate(); |
126 | 123 |
|
127 | 124 | const lightclient = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).lightclient; |
128 | 125 | const committeeRes = await lightclient.getLightClientCommitteeRoot({startPeriod: 0, count: 1}); |
129 | 126 | committeeRes.assertOk(); |
130 | | - const client = getClient({baseUrl: `http://127.0.0.1:${restPort}`}, {config}).beacon; |
131 | | - const validators = (await client.postStateValidators({stateId: "head"})).value(); |
132 | | - const pubkeys = validators.map((v) => v.validator.pubkey); |
133 | | - expect(pubkeys.length).toBe(validatorCount); |
134 | | - // only 2 validators spreading to 512 committee slots |
135 | | - const committeePubkeys = Array.from({length: SYNC_COMMITTEE_SIZE}, (_, i) => |
136 | | - i % 2 === 0 ? pubkeys[0] : pubkeys[1] |
137 | | - ); |
138 | | - const aggregatePubkey = aggregateSerializedPublicKeys(committeePubkeys).toBytes(); |
| 127 | + |
| 128 | + // Get the actual sync committee root from the head state |
| 129 | + // The sync committee is computed using a weighted random shuffle, not simple alternation |
| 130 | + const headState = bn.chain.getHeadState(); |
| 131 | + const expectedRoot = headState.currentSyncCommittee.hashTreeRoot(); |
| 132 | + |
139 | 133 | // single committee hash since we requested for the first period |
140 | | - expect(committeeRes.value()).toEqual([ |
141 | | - ssz.altair.SyncCommittee.hashTreeRoot({ |
142 | | - pubkeys: committeePubkeys, |
143 | | - aggregatePubkey, |
144 | | - }), |
145 | | - ]); |
| 134 | + expect(committeeRes.value()).toEqual([expectedRoot]); |
146 | 135 | }); |
147 | 136 | }); |
0 commit comments