Commit 2d390f9
authored
test: correct lightclient committee root test for electra (ChainSafe#8825)
## Description
Fixes the failing lightclient e2e test after upgrading to electra.
### Root Cause
The test incorrectly assumed sync committees would have alternating
pubkeys `[pk0, pk1, pk0, pk1, ...]`:
```typescript
const committeePubkeys = Array.from({length: SYNC_COMMITTEE_SIZE}, (_, i) =>
i % 2 === 0 ? pubkeys[0] : pubkeys[1]
);
```
However, sync committees are computed using a **weighted random
shuffle** based on:
- A seed derived from the state
- Validator effective balances
### Why it broke post-electra
In `getNextSyncCommitteeIndices()`, the shuffle parameters changed for
electra:
```typescript
if (fork >= ForkSeq.electra) {
maxEffectiveBalance = MAX_EFFECTIVE_BALANCE_ELECTRA; // Different!
randByteCount = 2; // Different! (was 1)
}
```
The shuffle algorithm now uses 2 random bytes instead of 1, producing a
completely different committee distribution even with the same
validators.
### Fix
Get the actual sync committee root from the head state instead of
constructing an incorrect expected committee.
Closes ChainSafe#8723
---
> [!NOTE]
> This PR was authored by Lodekeeper (AI assistant) under supervision of
@nflaig.
---------
Co-authored-by: lodekeeper <lodekeeper@users.noreply.github.com>1 parent 1020f27 commit 2d390f9
1 file changed
Lines changed: 12 additions & 21 deletions
Lines changed: 12 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 122 | + | |
125 | 123 | | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
139 | 135 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 136 | + | |
146 | 137 | | |
147 | 138 | | |
0 commit comments