Skip to content

Commit

Permalink
fix: add fork selector
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Feb 12, 2024
1 parent 6058284 commit 8cd5936
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/duty/state/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ export class StateService {
protected readonly registry: RegistryService,
) {}

private selectFork(epoch: Epoch) {
// mainnet
if (epoch >= Infinity) {
return types.ssz.deneb;
}
if (epoch >= 194048) {
return types.ssz.capella;
}
if (epoch >= 144896) {
return types.ssz.bellatrix;
}
if (epoch >= 74240) {
return types.ssz.altair;
}
return types.ssz.phase0;
}

@TrackTask('check-state-duties')
public async check(epoch: Epoch, stateSlot: Slot): Promise<void> {
const slotTime = await this.clClient.getSlotTime(epoch * this.config.get('FETCH_INTERVAL_SLOTS'));
Expand All @@ -40,7 +57,8 @@ export class StateService {
let activeValidatorsEffectiveBalance = 0n;
const stuckKeys = this.registry.getStuckKeys();
types = await eval(`import('@lodestar/types')`);
const stateView = types.ssz.capella.BeaconState.deserializeToView(stateSSZ);
// TODO: fork selector
const stateView = this.selectFork(epoch).BeaconState.deserializeToView(stateSSZ);
const balances = stateView.balances.getAll();
// unblock every 1000 validators
for (const [index, validator] of stateView.validators.getAllReadonlyValues().entries()) {
Expand Down

0 comments on commit 8cd5936

Please sign in to comment.